diff --git a/ccm-themedirector/src/org/libreccm/theming/FreeMarkerPresentationManager.java b/ccm-themedirector/src/org/libreccm/theming/FreeMarkerPresentationManager.java
index d304ca416..78fbd1639 100644
--- a/ccm-themedirector/src/org/libreccm/theming/FreeMarkerPresentationManager.java
+++ b/ccm-themedirector/src/org/libreccm/theming/FreeMarkerPresentationManager.java
@@ -1,5 +1,9 @@
package org.libreccm.theming;
+import org.libreccm.theming.manifest.ApplicationTemplate;
+import org.libreccm.theming.manifest.ContentItemTemplate;
+import org.libreccm.theming.manifest.Templates;
+
import com.arsdigita.bebop.Bebop;
import com.arsdigita.bebop.page.PageTransformer;
import com.arsdigita.domain.DataObjectNotFoundException;
@@ -102,39 +106,6 @@ public class FreeMarkerPresentationManager implements PresentationManager {
final ServletContext servletContext = Web.getServletContext();
-// final String themeManifest = "";
-// final String themeManifest = new BufferedReader(
-// new InputStreamReader(
-// servletContext.getResourceAsStream(themeManifestPath),
-// StandardCharsets.UTF_8))
-// .lines()
-// .collect(Collectors.joining(System.lineSeparator()));
-//
-// String name = "???";
-// final JsonFactory jsonFactory = new JsonFactory();
-// try {
-// final JsonParser parser = jsonFactory.createParser(servletContext
-// .getResourceAsStream(themeManifestPath));
-//
-// while (!parser.isClosed()) {
-//
-// final JsonToken token = parser.nextToken();
-// if (JsonToken.FIELD_NAME.equals(token)) {
-// final String fieldName = parser.getCurrentName();
-//
-// if ("name".equals(fieldName)) {
-//
-// final JsonToken valueToken = parser.nextToken();
-// final String value = parser.getValueAsString();
-// name = value;
-// }
-// }
-//
-// }
-//
-// } catch (IOException ex) {
-// throw new UncheckedWrapperException(ex);
-// }
final InputStream manifestInputStream = servletContext
.getResourceAsStream(themeManifestPath);
if (manifestInputStream == null) {
@@ -148,17 +119,7 @@ public class FreeMarkerPresentationManager implements PresentationManager {
.loadManifest(manifestInputStream,
themeManifestPath);
- final ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.registerModule(new JaxbAnnotationModule());
- final Templates templates;
- try {
- templates = objectMapper.readValue(
- servletContext.getResourceAsStream(
- String.format("%stemplates.json", themePath)),
- Templates.class);
- } catch (IOException ex) {
- throw new UncheckedWrapperException(ex);
- }
+ final Templates templates = manifest.getTemplates();
// ToDo
final NamedNodeMap pageAttrs = root.getAttributes();
diff --git a/ccm-themedirector/src/org/libreccm/theming/ApplicationTemplate.java b/ccm-themedirector/src/org/libreccm/theming/manifest/ApplicationTemplate.java
similarity index 98%
rename from ccm-themedirector/src/org/libreccm/theming/ApplicationTemplate.java
rename to ccm-themedirector/src/org/libreccm/theming/manifest/ApplicationTemplate.java
index 5df031e09..3c05a9cb2 100644
--- a/ccm-themedirector/src/org/libreccm/theming/ApplicationTemplate.java
+++ b/ccm-themedirector/src/org/libreccm/theming/manifest/ApplicationTemplate.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.libreccm.theming;
+package org.libreccm.theming.manifest;
import static org.libreccm.theming.ThemeConstants.*;
diff --git a/ccm-themedirector/src/org/libreccm/theming/ContentItemTemplate.java b/ccm-themedirector/src/org/libreccm/theming/manifest/ContentItemTemplate.java
similarity index 98%
rename from ccm-themedirector/src/org/libreccm/theming/ContentItemTemplate.java
rename to ccm-themedirector/src/org/libreccm/theming/manifest/ContentItemTemplate.java
index 187dfb5e8..93610a861 100644
--- a/ccm-themedirector/src/org/libreccm/theming/ContentItemTemplate.java
+++ b/ccm-themedirector/src/org/libreccm/theming/manifest/ContentItemTemplate.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.libreccm.theming;
+package org.libreccm.theming.manifest;
import static org.libreccm.theming.ThemeConstants.*;
@@ -14,6 +14,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import org.libreccm.theming.ContentItemViews;
+
/**
*
* @author Jens Pelzetter
diff --git a/ccm-themedirector/src/org/libreccm/theming/Templates.java b/ccm-themedirector/src/org/libreccm/theming/manifest/Templates.java
similarity index 98%
rename from ccm-themedirector/src/org/libreccm/theming/Templates.java
rename to ccm-themedirector/src/org/libreccm/theming/manifest/Templates.java
index 7a7138c92..9b9126c41 100644
--- a/ccm-themedirector/src/org/libreccm/theming/Templates.java
+++ b/ccm-themedirector/src/org/libreccm/theming/manifest/Templates.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package org.libreccm.theming;
+package org.libreccm.theming.manifest;
import static org.libreccm.theming.ThemeConstants.*;
@@ -18,6 +18,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+
/**
*
* @author Jens Pelzetter
diff --git a/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeManifest.java b/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeManifest.java
index 76133ed7e..75d411dfa 100644
--- a/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeManifest.java
+++ b/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeManifest.java
@@ -20,15 +20,11 @@ package org.libreccm.theming.manifest;
import org.libreccm.l10n.LocalizedString;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import static org.libreccm.theming.ThemeConstants.*;
@@ -75,12 +71,14 @@ public class ThemeManifest implements Serializable {
@XmlElement(name = "description", namespace = THEMES_XML_NS)
private LocalizedString description;
- /**
- * The templates provided by the theme.
- */
- @XmlElementWrapper(name = "templates", namespace = THEMES_XML_NS)
- @XmlElement(name = "template", namespace = THEMES_XML_NS)
- private List templates;
+// /**
+// * The templates provided by the theme.
+// */
+// @XmlElementWrapper(name = "templates", namespace = THEMES_XML_NS)
+// @XmlElement(name = "template", namespace = THEMES_XML_NS)
+// private List templates;
+ @XmlElement(name = "templates")
+ private Templates templates;
/**
* Path of the default template.
@@ -89,7 +87,7 @@ public class ThemeManifest implements Serializable {
private String defaultTemplate;
public ThemeManifest() {
- templates = new ArrayList<>();
+// templates = new ArrayList<>();
}
public String getName() {
@@ -132,20 +130,12 @@ public class ThemeManifest implements Serializable {
this.description = description;
}
- public List getTemplates() {
- return Collections.unmodifiableList(templates);
+ public Templates getTemplates() {
+ return templates;
}
- public void setTemplates(final List templates) {
- this.templates = new ArrayList<>(templates);
- }
-
- public void addThemeTemplate(final ThemeTemplate template) {
- templates.add(template);
- }
-
- public void removeThemeTemplate(final ThemeTemplate template) {
- templates.remove(template);
+ public void setTemplates(final Templates templates) {
+ this.templates = templates;
}
public String getDefaultTemplate() {
diff --git a/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeTemplate.java b/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeTemplate.java
deleted file mode 100644
index 236862e77..000000000
--- a/ccm-themedirector/src/org/libreccm/theming/manifest/ThemeTemplate.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2017 LibreCCM Foundation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-package org.libreccm.theming.manifest;
-
-import org.libreccm.l10n.LocalizedString;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Informations about a template provided by a theme.
- *
- * @author Jens Pelzetter
- */
-@XmlRootElement(name = "template", namespace = "http://themes.libreccm.org")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class ThemeTemplate implements Serializable {
-
- private static final long serialVersionUID = -9034588759798295569L;
-
- /**
- * The name of the template (usually the filename).
- */
- @XmlElement(name = "name", namespace = "http://themes.libreccm.org")
- private String name;
-
- /**
- * The (localised) title of the template.
- */
- @XmlElement(name = "title", namespace = "http://themes.libreccm.org")
- private LocalizedString title;
-
- /**
- * A (localised) description of the template.
- */
- @XmlElement(name = "description", namespace = "http://themes.libreccm.org")
- private LocalizedString description;
-
- /**
- * Path of template relative to the directory of the theme.
- */
- @XmlElement(name = "path", namespace = "http://themes.libreccm.org")
- private String path;
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public LocalizedString getTitle() {
- return title;
- }
-
- public void setTitle(final LocalizedString title) {
- this.title = title;
- }
-
- public LocalizedString getDescription() {
- return description;
- }
-
- public void setDescription(final LocalizedString description) {
- this.description = description;
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(final String path) {
- this.path = path;
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 67 * hash + Objects.hashCode(name);
- hash = 67 * hash + Objects.hashCode(title);
- hash = 67 * hash + Objects.hashCode(description);
- hash = 67 * hash + Objects.hashCode(path);
- return hash;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof ThemeTemplate)) {
- return false;
- }
- final ThemeTemplate other = (ThemeTemplate) obj;
- if (!other.canEqual(this)) {
- return false;
- }
- if (!Objects.equals(name, other.getName())) {
- return false;
- }
- if (!Objects.equals(path, other.getPath())) {
- return false;
- }
- if (!Objects.equals(title, other.getTitle())) {
- return false;
- }
- return Objects.equals(description, other.getDescription());
- }
-
- public boolean canEqual(final Object obj) {
- return obj instanceof ThemeTemplate;
- }
-
- @Override
- public String toString() {
- return toString("");
- }
-
- public String toString(final String data) {
-
- return String.format("%s{ "
- + "name = \"%s\", "
- + "title = %s, "
- + "description = %s, "
- + "path = \"%s\"%s"
- + " }",
- super.toString(),
- name,
- Objects.toString(title),
- Objects.toString(description),
- path,
- data);
- }
-
-}