CCM NG: Several fixes and improvments
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5152 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
3685b1f341
commit
b918a7cd5c
|
|
@ -22,6 +22,7 @@ import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
|
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
|
||||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||||
import org.libreccm.categorization.Category;
|
import org.libreccm.categorization.Category;
|
||||||
|
|
@ -233,13 +234,17 @@ public class PagesRouter {
|
||||||
|
|
||||||
final JacksonXmlModule xmlModule = new JacksonXmlModule();
|
final JacksonXmlModule xmlModule = new JacksonXmlModule();
|
||||||
final ObjectMapper mapper = new XmlMapper(xmlModule);
|
final ObjectMapper mapper = new XmlMapper(xmlModule);
|
||||||
|
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Map<String, Object> result = getCategoryIndexPage(uriInfo,
|
final Map<String, Object> result = getCategoryIndexPage(uriInfo,
|
||||||
"/",
|
"/",
|
||||||
language,
|
language,
|
||||||
pageModelVersion);
|
pageModelVersion);
|
||||||
final String html = mapper.writeValueAsString(result);
|
final String html = mapper
|
||||||
|
.writer()
|
||||||
|
.withRootName("page")
|
||||||
|
.writeValueAsString(result);
|
||||||
return html;
|
return html;
|
||||||
// return mapper
|
// return mapper
|
||||||
// .writeValueAsString(getCategoryIndexPage(uriInfo,
|
// .writeValueAsString(getCategoryIndexPage(uriInfo,
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package org.libreccm.admin.ui;
|
package org.libreccm.admin.ui;
|
||||||
|
|
||||||
import com.vaadin.cdi.ViewScoped;
|
import com.vaadin.cdi.ViewScoped;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
import org.libreccm.l10n.GlobalizationHelper;
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -39,6 +40,9 @@ class AdminViewController implements Serializable {
|
||||||
@Inject
|
@Inject
|
||||||
private ApplicationTreeDataProvider applicationTreeDataProvider;
|
private ApplicationTreeDataProvider applicationTreeDataProvider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ConfigurationManager configurationManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ConfigurationsTabController confTabController;
|
private ConfigurationsTabController confTabController;
|
||||||
|
|
||||||
|
|
@ -65,6 +69,10 @@ class AdminViewController implements Serializable {
|
||||||
return applicationTreeDataProvider;
|
return applicationTreeDataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigurationManager getConfigurationManager() {
|
||||||
|
return configurationManager;
|
||||||
|
}
|
||||||
|
|
||||||
public ConfigurationsTabController getConfTabController() {
|
public ConfigurationsTabController getConfTabController() {
|
||||||
return confTabController;
|
return confTabController;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,72 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.admin.ui;
|
package org.libreccm.admin.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||||
|
|
||||||
|
import com.vaadin.ui.FormLayout;
|
||||||
|
import com.vaadin.ui.Label;
|
||||||
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.l10n.LocalizedTextsUtil;
|
||||||
import org.libreccm.pagemodel.PageModel;
|
import org.libreccm.pagemodel.PageModel;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
class PageModelDetails extends Window {
|
class PageModelDetails extends Window {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3617001410191320596L;
|
private static final long serialVersionUID = -3617001410191320596L;
|
||||||
|
|
||||||
PageModelDetails(final PageModel pageModel,
|
PageModelDetails(final PageModel pageModel,
|
||||||
final AdminViewController controller) {
|
final AdminViewController controller) {
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
final GlobalizationHelper globalizationHelper = controller
|
||||||
|
.getGlobalizationHelper();
|
||||||
|
final LocalizedTextsUtil textsUtil = globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(AdminUiConstants.ADMIN_BUNDLE);
|
||||||
|
final ConfigurationManager configurationManager = controller
|
||||||
|
.getConfigurationManager();
|
||||||
|
final KernelConfig kernelConfig = configurationManager
|
||||||
|
.findConfiguration(KernelConfig.class);
|
||||||
|
final Locale defaultLocale = kernelConfig.getDefaultLocale();
|
||||||
|
|
||||||
|
super.setCaption(textsUtil
|
||||||
|
.getText("ui.admin.pagemodels.details.heading",
|
||||||
|
new String[]{pageModel.getName()}));
|
||||||
|
|
||||||
|
final Label nameLabel = new Label(pageModel.getName());
|
||||||
|
nameLabel.setCaption(textsUtil
|
||||||
|
.getText("ui.admin.pagemodels.details.model_name"));
|
||||||
|
|
||||||
|
final Label titleLabel = new Label(pageModel
|
||||||
|
.getTitle().getValue(defaultLocale));
|
||||||
|
titleLabel.setCaption(textsUtil
|
||||||
|
.getText("ui.admin.pagemodels.details.model_title"));
|
||||||
|
|
||||||
|
final Label applicationLabel = new Label(pageModel
|
||||||
|
.getApplication().getPrimaryUrl());
|
||||||
|
applicationLabel.setCaption(textsUtil
|
||||||
|
.getText("ui.admin.pagemodels.details.model_application"));
|
||||||
|
|
||||||
|
final Label descLabel = new Label(pageModel
|
||||||
|
.getDescription().getValue(defaultLocale));
|
||||||
|
descLabel.setCaption(textsUtil
|
||||||
|
.getText("ui.admin.pagemodels.details.model_desc"));
|
||||||
|
|
||||||
|
final FormLayout propertiesSheetLayout = new FormLayout(
|
||||||
|
nameLabel, titleLabel, applicationLabel, descLabel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
super.setContent(new VerticalLayout(propertiesSheetLayout));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -252,15 +252,50 @@ public class StaticThemeProvider implements ThemeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<InputStream> getThemeFileAsStream(String theme,
|
public Optional<InputStream> getThemeFileAsStream(final String theme,
|
||||||
ThemeVersion version,
|
final ThemeVersion version,
|
||||||
String path) {
|
final String path) {
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
||||||
|
Objects.requireNonNull(theme);
|
||||||
|
Objects.requireNonNull(path);
|
||||||
|
|
||||||
|
if (theme.isEmpty()
|
||||||
|
|| theme.matches("\\s*")) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"The name of the theme can't be empty.");
|
||||||
|
}
|
||||||
|
if (path.isEmpty()
|
||||||
|
|| path.matches("\\s*")) {
|
||||||
|
throw new IllegalArgumentException("The path can't be empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String filePath;
|
||||||
|
if (path.startsWith("/")) {
|
||||||
|
filePath = String.format("/" + THEMES_PACKAGE + "/%s/%s",
|
||||||
|
theme,
|
||||||
|
path.substring(1));
|
||||||
|
} else {
|
||||||
|
filePath = String.format("/" + THEMES_PACKAGE + "/%s/%s",
|
||||||
|
theme,
|
||||||
|
path);
|
||||||
|
}
|
||||||
|
|
||||||
|
final InputStream stream = getClass().getResourceAsStream(filePath);
|
||||||
|
if (stream == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
} else {
|
||||||
|
return Optional.of(stream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getOutputStreamForThemeFile(String theme, String path) {
|
public OutputStream getOutputStreamForThemeFile(final String theme,
|
||||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
final String path) {
|
||||||
|
|
||||||
|
throw new UnsupportedOperationException(String
|
||||||
|
.format("This implementation of %s interface does not support "
|
||||||
|
+ "changes to the theme files.",
|
||||||
|
ThemeProvider.class.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import java.io.Serializable;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.enterprise.inject.Any;
|
||||||
import javax.enterprise.inject.Instance;
|
import javax.enterprise.inject.Instance;
|
||||||
import javax.enterprise.util.AnnotationLiteral;
|
import javax.enterprise.util.AnnotationLiteral;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -42,6 +43,7 @@ public class ThemeProcessors implements Serializable {
|
||||||
* All available implementations of {@link ThemeProcessor}.
|
* All available implementations of {@link ThemeProcessor}.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
|
@Any
|
||||||
private Instance<ThemeProcessor> processors;
|
private Instance<ThemeProcessor> processors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.enterprise.inject.Any;
|
||||||
import javax.enterprise.inject.Instance;
|
import javax.enterprise.inject.Instance;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ public class Themes implements Serializable {
|
||||||
private static final Logger LOGGER = LogManager.getLogger(Themes.class);
|
private static final Logger LOGGER = LogManager.getLogger(Themes.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Any
|
||||||
private Instance<ThemeProvider> providers;
|
private Instance<ThemeProvider> providers;
|
||||||
//
|
//
|
||||||
// @Inject
|
// @Inject
|
||||||
|
|
|
||||||
|
|
@ -39,16 +39,22 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import static org.libreccm.theming.ThemeConstants.*;
|
import static org.libreccm.theming.ThemeConstants.*;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.theming.ProcessesThemes;
|
import org.libreccm.theming.ProcessesThemes;
|
||||||
import org.libreccm.theming.manifest.ThemeTemplate;
|
import org.libreccm.theming.manifest.ThemeTemplate;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.xml.transform.ErrorListener;
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
import javax.xml.transform.Transformer;
|
import javax.xml.transform.Transformer;
|
||||||
import javax.xml.transform.TransformerConfigurationException;
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
|
@ -69,6 +75,9 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3883625727845105417L;
|
private static final long serialVersionUID = -3883625727845105417L;
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager
|
||||||
|
.getLogger(XsltThemeProcessor.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String process(final Map<String, Object> page,
|
public String process(final Map<String, Object> page,
|
||||||
final ThemeInfo theme,
|
final ThemeInfo theme,
|
||||||
|
|
@ -77,10 +86,14 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
//Convert page to XML
|
//Convert page to XML
|
||||||
final JacksonXmlModule xmlModule = new JacksonXmlModule();
|
final JacksonXmlModule xmlModule = new JacksonXmlModule();
|
||||||
final ObjectMapper mapper = new XmlMapper(xmlModule);
|
final ObjectMapper mapper = new XmlMapper(xmlModule);
|
||||||
|
mapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||||
|
|
||||||
final String pageAsXml;
|
final String pageAsXml;
|
||||||
try {
|
try {
|
||||||
pageAsXml = mapper.writeValueAsString(page);
|
pageAsXml = mapper
|
||||||
|
.writer()
|
||||||
|
.withRootName("page")
|
||||||
|
.writeValueAsString(page);
|
||||||
} catch (JsonProcessingException ex) {
|
} catch (JsonProcessingException ex) {
|
||||||
throw new UnexpectedErrorException(ex);
|
throw new UnexpectedErrorException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +109,9 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
|
|
||||||
final Document document;
|
final Document document;
|
||||||
try {
|
try {
|
||||||
document = documentBuilder.parse(pageAsXml);
|
final InputStream xmlBytesStream = new ByteArrayInputStream(
|
||||||
|
pageAsXml.getBytes(StandardCharsets.UTF_8));
|
||||||
|
document = documentBuilder.parse(xmlBytesStream);
|
||||||
} catch (SAXException | IOException ex) {
|
} catch (SAXException | IOException ex) {
|
||||||
throw new UnexpectedErrorException(ex);
|
throw new UnexpectedErrorException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -152,6 +167,36 @@ public class XsltThemeProcessor implements ThemeProcessor {
|
||||||
transformer.setURIResolver(new CcmUriResolver(theme.getName(),
|
transformer.setURIResolver(new CcmUriResolver(theme.getName(),
|
||||||
theme.getVersion(),
|
theme.getVersion(),
|
||||||
themeProvider));
|
themeProvider));
|
||||||
|
transformer.setErrorListener(new ErrorListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void warning(final TransformerException te)
|
||||||
|
throws TransformerException {
|
||||||
|
|
||||||
|
LOGGER.warn("A WARNING was reported by the "
|
||||||
|
+ "XSLT Transformer:",
|
||||||
|
te);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(final TransformerException te)
|
||||||
|
throws TransformerException {
|
||||||
|
|
||||||
|
LOGGER.warn("An ERROR was reported by the "
|
||||||
|
+ "XSLT Transformer:",
|
||||||
|
te);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fatalError(final TransformerException te)
|
||||||
|
throws TransformerException {
|
||||||
|
|
||||||
|
LOGGER.warn("An FATAL ERROR was reported by the "
|
||||||
|
+ "XSLT Transformer:",
|
||||||
|
te);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
} catch (TransformerConfigurationException ex) {
|
} catch (TransformerConfigurationException ex) {
|
||||||
throw new UnexpectedErrorException(ex);
|
throw new UnexpectedErrorException(ex);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -688,3 +688,5 @@ ui.admin.users.table.filter.rolename.placeholder=Name of role
|
||||||
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
||||||
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
||||||
ui.admin.pagemodels.select_application=Please select an application
|
ui.admin.pagemodels.select_application=Please select an application
|
||||||
|
ui.admin.pagemodels.table.columns.edit.label=Edit
|
||||||
|
ui.admin.pagemodels.table.columns.delete.label=Delete
|
||||||
|
|
|
||||||
|
|
@ -692,3 +692,5 @@ ui.admin.users.table.filter.rolename.placeholder=Name der Rolle
|
||||||
ui.admin.users.table.filter.rolename.description=Rollen nach Name filtern
|
ui.admin.users.table.filter.rolename.description=Rollen nach Name filtern
|
||||||
ui.admin.pagemodels.table.columns.headers.islive=Ist publiziert?
|
ui.admin.pagemodels.table.columns.headers.islive=Ist publiziert?
|
||||||
ui.admin.pagemodels.select_application=Bitte eine Applikation ausw\u00e4hlen
|
ui.admin.pagemodels.select_application=Bitte eine Applikation ausw\u00e4hlen
|
||||||
|
ui.admin.pagemodels.table.columns.edit.label=Bearbeiten
|
||||||
|
ui.admin.pagemodels.table.columns.delete.label=L\u00f6schen
|
||||||
|
|
|
||||||
|
|
@ -685,3 +685,5 @@ ui.admin.users.table.filter.rolename.placeholder=Name of role
|
||||||
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
||||||
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
||||||
ui.admin.pagemodels.select_application=Please select an application
|
ui.admin.pagemodels.select_application=Please select an application
|
||||||
|
ui.admin.pagemodels.table.columns.edit.label=Edit
|
||||||
|
ui.admin.pagemodels.table.columns.delete.label=Delete
|
||||||
|
|
|
||||||
|
|
@ -676,3 +676,5 @@ ui.admin.users.table.filter.rolename.placeholder=Name of role
|
||||||
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
ui.admin.users.table.filter.rolename.description=Filter roles by name
|
||||||
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
ui.admin.pagemodels.table.columns.headers.islive=Is live?
|
||||||
ui.admin.pagemodels.select_application=Please select an application
|
ui.admin.pagemodels.select_application=Please select an application
|
||||||
|
ui.admin.pagemodels.table.columns.edit.label=Edit
|
||||||
|
ui.admin.pagemodels.table.columns.delete.label=Delete
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
<xsl:stylesheet version="2.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
xmlns:ccm="http://xmlns.libreccm.org">
|
xmlns:ccm="http://xmlns.libreccm.org">
|
||||||
|
|
||||||
<xsl:template match="ccm:categoryPage">
|
<xsl:template match="page">
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Category page</title>
|
<title>Category page</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<xsl:apply-template select="ccm:greetingItem" />
|
<xsl:apply-templates select="indexItem" />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="ccm:greetingItem">
|
<xsl:template match="indexItem">
|
||||||
|
|
||||||
<h1>
|
<h1>
|
||||||
<xsl:value-of select="./ccm:title" />
|
<xsl:value-of select="./title" />
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ccm",
|
"name": "ccm",
|
||||||
"type": "xsl"
|
"type": "xsl",
|
||||||
|
|
||||||
|
"default-template": "category-page.xsl"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue