2020-09-21 00:20:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
|
|
|
|
*
|
|
|
|
* This file is part of StatoolInfos, simple service statistics tool.
|
|
|
|
*
|
|
|
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* StatoolInfos is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package fr.devinsy.statoolinfos.htmlize;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2020-10-28 15:34:04 +01:00
|
|
|
import fr.devinsy.statoolinfos.HtmlizerContext;
|
2020-09-21 00:20:14 +02:00
|
|
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
|
|
|
import fr.devinsy.statoolinfos.util.BuildInformation;
|
|
|
|
import fr.devinsy.xidyn.XidynException;
|
|
|
|
import fr.devinsy.xidyn.data.TagDataManager;
|
|
|
|
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
2020-09-21 03:41:46 +02:00
|
|
|
import fr.devinsy.xidyn.utils.XidynUtils;
|
2020-09-21 00:20:14 +02:00
|
|
|
|
|
|
|
/**
|
2020-09-21 03:41:46 +02:00
|
|
|
* The Class WebCharterView.
|
2020-09-21 00:20:14 +02:00
|
|
|
*/
|
2020-09-21 03:41:46 +02:00
|
|
|
public class WebCharterView
|
2020-09-21 00:20:14 +02:00
|
|
|
{
|
2020-09-21 03:41:46 +02:00
|
|
|
private static Logger logger = LoggerFactory.getLogger(WebCharterView.class);
|
2020-09-21 00:20:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the.
|
|
|
|
*
|
2020-09-21 03:41:46 +02:00
|
|
|
* @param content
|
|
|
|
* the content
|
2020-09-21 00:20:14 +02:00
|
|
|
* @return the string
|
|
|
|
* @throws StatoolInfosException
|
|
|
|
* the statool infos exception
|
|
|
|
*/
|
2020-09-21 03:41:46 +02:00
|
|
|
public static String build(final String content) throws StatoolInfosException
|
2020-09-21 00:20:14 +02:00
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-09-24 02:45:31 +02:00
|
|
|
result = build(content, new BreadcrumbTrail());
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds the.
|
|
|
|
*
|
|
|
|
* @param content
|
|
|
|
* the content
|
|
|
|
* @param trail
|
|
|
|
* the trail
|
|
|
|
* @return the string
|
|
|
|
* @throws StatoolInfosException
|
|
|
|
* the statool infos exception
|
|
|
|
*/
|
|
|
|
public static String build(final String content, final BreadcrumbTrail trail) throws StatoolInfosException
|
|
|
|
{
|
|
|
|
String result;
|
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
try
|
|
|
|
{
|
2020-09-21 03:41:46 +02:00
|
|
|
logger.debug("Building WebCharterView.");
|
|
|
|
|
2020-09-21 00:20:14 +02:00
|
|
|
TagDataManager data = new TagDataManager();
|
|
|
|
|
2020-10-28 15:34:04 +01:00
|
|
|
data.setContent("federationButton", HtmlizerContext.instance().getFederation().getName());
|
2020-09-21 00:20:14 +02:00
|
|
|
data.setContent("versionsup", BuildInformation.instance().version());
|
|
|
|
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
|
2020-09-21 03:41:46 +02:00
|
|
|
data.setContent("webCharterContent", XidynUtils.extractBodyContent(content));
|
2020-09-24 02:45:31 +02:00
|
|
|
data.setContent("breadcrumbTrail", trail.toString());
|
2020-11-21 07:09:55 +01:00
|
|
|
data.setAttribute("federationStatsButton", "href", HtmlizerContext.instance().getFederation().getTechnicalName() + "-stats.xhtml");
|
2020-09-21 00:20:14 +02:00
|
|
|
|
2020-09-21 03:41:46 +02:00
|
|
|
result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml", data).toString();
|
2020-09-21 00:20:14 +02:00
|
|
|
}
|
|
|
|
catch (XidynException exception)
|
|
|
|
{
|
2020-09-21 03:41:46 +02:00
|
|
|
throw new StatoolInfosException("Error building webCharter view: " + exception.getMessage(), exception);
|
2020-09-21 00:20:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|