diff --git a/ccm-pages/application.xml b/ccm-pages/application.xml deleted file mode 100644 index f9c89ae51..000000000 --- a/ccm-pages/application.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - A backport of the new Pages application from 7.0.0. The Pages - application replaces ccm-navigation and the current JSP templates 7.0.0. - Pages has been backported to ease the migration to 7.0.0. This - application only if the ccm-theming application (another backport - from 7.0.0) is also installed. - - - \ No newline at end of file diff --git a/ccm-pages/lib/freemarker.jar b/ccm-pages/lib/freemarker.jar deleted file mode 100644 index 75edf6c03..000000000 Binary files a/ccm-pages/lib/freemarker.jar and /dev/null differ diff --git a/ccm-pages/pdl/org/libreccm/pagemodel/PageModel.pdl b/ccm-pages/pdl/org/libreccm/pagemodel/PageModel.pdl deleted file mode 100644 index fd6fad87f..000000000 --- a/ccm-pages/pdl/org/libreccm/pagemodel/PageModel.pdl +++ /dev/null @@ -1,119 +0,0 @@ -model org.libreccm.pagemodel; - -import com.arsdigita.web.Application; -import com.arsdigita.kernel.ACSObject; - -import com.arsdigita.cms.ContentItem; - -object type PageModel { - - BigDecimal[1..1] pageModelId = ccm_page_models.page_model_id INTEGER; - - String[1..1] uuid = ccm_page_models.uuid VARCHAR(38); - - String[1..1] modelUuid = ccm_page_models.model_uuid VARCHAR(38); - - String[1..1] name = ccm_page_models.name VARCHAR(512); - - String[1..1] pageModelVersion = ccm_page_models.page_model_version VARCHAR(256); - - Date[0..1] lastModified = ccm_page_models.last_modified TIMESTAMP; - - String[0..1] title = ccm_page_models.title VARCHAR(1024); - - String[0..1] description = ccm_page_models.description VARCHAR(4096); - - String[0..1] type = ccm_page_models.type VARCHAR(256); - - Application[1..1] application = join ccm_page_models.application_id - to applications.application_id; - - ContainerModel[0..n] containerModels = join ccm_page_models.page_model_id - to ccm_page_model_container_models.page_model_id; - - object key(pageModelId); -} - -object type ContainerModel { - - BigDecimal[1..1] containerModelId = ccm_page_model_container_models.container_model_id INTEGER; - - String[1..1] uuid = ccm_page_model_container_models.uuid VARCHAR(38); - - String[1..1] containerUuid = ccm_page_model_container_models.container_uuid VARCHAR(38); - - String[1..1] key = ccm_page_model_container_models.key VARCHAR(256); - - PageModel[1..1] pageModel = join ccm_page_model_container_models.page_model_id - to ccm_page_models.page_model_id; - - ComponentModel[0..n] componentModel = join ccm_page_model_container_models.container_model_id - to ccm_page_model_component_models.container_model_id; - - object key(containerModelId); -} - -object type ComponentModel { - - BigDecimal[1..1] componentModelId = ccm_page_model_component_models.component_model_id; - - String[1..1] uuid = ccm_page_model_component_models.uuid VARCHAR(38); - - String[1..1] componentModelUuid = ccm_page_model_component_models.component_model_uuid VARCHAR(38); - - String[0..1] idAttribute = ccm_page_model_component_models.id_attribute VARCHAR(255); - - String[0..1] classAttribute = ccm_page_model_component_models.class_attribute VARCHAR(512); - - String[0..1] styleAttribute = ccm_page_model_component_models.style_attribute VARCHAR(1024); - - String[0..1] key = ccm_page_model_component_models.component_key VARCHAR(255); - - object key(componentModelId); -} - -object type CategoryTreeComponent extends ComponentModel { - - Boolean[0..1] showFullTree = ccm_page_model_category_tree_components.show_full_tree BIT; - - reference key(ccm_page_model_category_tree_components.component_model_id); -} - -object type ContentItemComponent extends ComponentModel { - - String[0..1] mode = ccm_page_model_content_item_components.mode VARCHAR(255); - - reference key(ccm_page_model_item_list_components.component_model_id); -} - -object type ItemListComponent extends ComponentModel { - - Boolean[0..1] descending = ccm_page_model_item_list_components.descending BIT; - - String[0..1] limitToType = ccm_page_model_item_list_components.limit_to_type VARCHAR(255); - - Integer[0..1] pageSize = ccm_page_model_item_list_components.page_size INTEGER; - - String[0..1] listOrder = ccm_page_model_item_list_components.list_order VARCHAR(255); - - reference key(ccm_page_model_item_list_components.component_model_id); -} - -object type CategorizedItemComponent extends ContentItemComponent { - - reference key(ccm_page_model_categorized_item_components.component_model_id); -} - -object type GreetingItemComponent extends ContentItemComponent { - - reference key(ccm_page_model_greeting_item_components.component_model_id); -} - -object type FixedContentItemComponent extends ContentItemComponent { - - ContentItem[0..1] contentItem = join ccm_page_model_fixed_content_item_components.content_item_id - to cms_items.item_id; - - reference key(ccm_page_model_fixed_content_item_components.component_model_id); -} - diff --git a/ccm-pages/pdl/org/librecms/pages/Pages.pdl b/ccm-pages/pdl/org/librecms/pages/Pages.pdl deleted file mode 100644 index 3464dc402..000000000 --- a/ccm-pages/pdl/org/librecms/pages/Pages.pdl +++ /dev/null @@ -1,32 +0,0 @@ -model org.librecms.pages.Pages; - -import com.arsdigita.web.Application; -import com.arsdigita.kernel.ACSObject; - -import com.arsdigita.subsite.Site; - -import com.arsdigita.london.terms.Domain; - -import org.libreccm.pagemodel.PageModel; - -object type Pages extends Application { - - Site[1..1] site = join ccm_pages.site_id - to subsite_sites.site_id; - - Domain[1..1] domainCategory = join ccm_pages.domain_category_id - to cat_categories.category_id; - - reference key(ccm_pages.page_id); -} - -object type Page extends ACSObject { - - reference key(ccm_pages_pages.page_id); - - PageModel[1..1] indexPageModel = join ccm_pages_pages.index_page_model_id - to ccm_page_models.page_model_id; - - PageModel[1..1] itemPageModel = join ccm_pages_pages.item_page_model_id - to ccm_page_models.page_model_id; -} diff --git a/ccm-pages/sql/ccm-pages/oracle-se-create.sql b/ccm-pages/sql/ccm-pages/oracle-se-create.sql deleted file mode 100644 index b0de6e153..000000000 --- a/ccm-pages/sql/ccm-pages/oracle-se-create.sql +++ /dev/null @@ -1,3 +0,0 @@ -@ ddl/oracle-se/create.sql - -@ ddl/oracle-se/deferred.sql diff --git a/ccm-pages/sql/ccm-pages/postgres-create.sql b/ccm-pages/sql/ccm-pages/postgres-create.sql deleted file mode 100644 index 38209a696..000000000 --- a/ccm-pages/sql/ccm-pages/postgres-create.sql +++ /dev/null @@ -1,4 +0,0 @@ -begin; -\i ddl/postgres/create.sql -\i ddl/postgres/deferred.sql -end; diff --git a/ccm-pages/src/ccm-pages.config b/ccm-pages/src/ccm-pages.config deleted file mode 100644 index 0ece1ac86..000000000 --- a/ccm-pages/src/ccm-pages.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/ccm-pages/src/ccm-pages.load b/ccm-pages/src/ccm-pages.load deleted file mode 100644 index a005c94f7..000000000 --- a/ccm-pages/src/ccm-pages.load +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- - - - diff --git a/ccm-pages/src/org/libreccm/l10n/L10NConstants.java b/ccm-pages/src/org/libreccm/l10n/L10NConstants.java deleted file mode 100644 index 73f3b20a0..000000000 --- a/ccm-pages/src/org/libreccm/l10n/L10NConstants.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2015 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.l10n; - -/** - * - * @author Jens Pelzetter - */ -public final class L10NConstants { - - public static final String L10N_XML_NS = "http://l10n.libreccm.org"; - - private L10NConstants() { - //Nothing - } - -} diff --git a/ccm-pages/src/org/libreccm/l10n/LocalizedString.java b/ccm-pages/src/org/libreccm/l10n/LocalizedString.java deleted file mode 100644 index fb21d3732..000000000 --- a/ccm-pages/src/org/libreccm/l10n/LocalizedString.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2015 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.l10n; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import org.libreccm.l10n.jaxb.LocalizedStringValuesAdapter; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -/** - * - * @author Jens Pelzetter - */ -@XmlRootElement(name = "localized-string", - namespace = L10NConstants.L10N_XML_NS) -@XmlAccessorType(XmlAccessType.FIELD) -public class LocalizedString implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * The localised values of the string. - */ - @XmlElement(name = "values", namespace = L10NConstants.L10N_XML_NS) - @XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class) - private Map values; - - /** - * Constructor. Only creates the initial, empty map for new instances. - */ - public LocalizedString() { - values = new HashMap<>(); - } - - /** - * Get all localised values. - * - * @return A unmodifiable {@code Map} containing all localised values of - * this localised string. - */ - public Map getValues() { - if (values == null) { - return null; - } else { - return Collections.unmodifiableMap(values); - } - } - - /** - * Setter for replacing the complete {@code Map} of values. Only to be used - * by JPA and the Repository classes in the package. - * - * @param values The new map of values. - */ - protected void setValues(final Map values) { - if (values == null) { - this.values = new HashMap<>(); - } else { - this.values = new HashMap<>(values); - } - } - - /** - * Retrieves the values for the default locale. - * - * @return The localised value for the default locale of the system the - * application is running on. In most cases this is not what you - * want. Use {@link #getValue(java.util.Locale)} instead. - */ - public String getValue() { - return getValue(Locale.getDefault()); - } - - /** - * Retrieves the localised value of a locale. - * - * @param locale The locale for which the value shall be retrieved. - * - * @return The localised for the {@code locale} or {@code null} if there is - * no value for the provided locale. - */ - public String getValue(final Locale locale) { - return values.get(locale); - } - - /** - * Add a new localised value for a locale. If there is already a value for - * the provided locale the value is replaced with the new value. - * - * @param locale The locale of the provided value. - * @param value The localised value for the provided locale. - */ - public void addValue(final Locale locale, final String value) { - values.put(locale, value); - } - - /** - * Removes the value for the provided locale. - * - * @param locale The locale for which the value shall be removed. - */ - public void removeValue(final Locale locale) { - values.remove(locale); - } - - /** - * Checks if a localised string instance has a value for a locale. - * - * @param locale The locale. - * - * @return {@code true} if this localised string has a value for the - * provided locale, {@code false} if not. - */ - public boolean hasValue(final Locale locale) { - return values.containsKey(locale); - } - - /** - * Retrieves all present locales. - * - * @return A {@link Set} containing all locales for which this localised - * string has values. - */ - @JsonIgnore - public Set getAvailableLocales() { - return values.keySet(); - } - - @Override - public int hashCode() { - int hash = 7; - hash = 41 * hash + Objects.hashCode(this.values); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof LocalizedString)) { - return false; - } - final LocalizedString other = (LocalizedString) obj; - if (!other.canEqual(this)) { - return false; - } - - return Objects.equals(values, other.getValues()); - } - - public boolean canEqual(final Object obj) { - return obj instanceof LocalizedString; - } - - @Override - public String toString() { - return String.format( - "%s{ " - + "%s" - + " }", - super.toString(), - Objects.toString(values)); - } - -} diff --git a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValue.java b/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValue.java deleted file mode 100644 index 260a45dd6..000000000 --- a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValue.java +++ /dev/null @@ -1,112 +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.l10n.jaxb; - -import static org.libreccm.l10n.L10NConstants.*; - -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.XmlAttribute; -import javax.xml.bind.annotation.XmlValue; - -/** - * - * @author Jens Pelzetter - */ -@XmlAccessorType(XmlAccessType.FIELD) -public class LocalizedStringValue implements Serializable { - - private static final long serialVersionUID = 8435485565736441379L; - - @XmlAttribute(name = "lang", namespace = L10N_XML_NS) - private String locale; - - @XmlValue - private String value; - - public String getLocale() { - return locale; - } - - public void setLocale(final String locale) { - this.locale = locale; - } - - public String getValue() { - return value; - } - - public void setValue(final String value) { - this.value = value; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 97 * hash + Objects.hashCode(locale); - hash = 97 * hash + Objects.hashCode(value); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof LocalizedStringValue)) { - return false; - } - final LocalizedStringValue other = (LocalizedStringValue) obj; - if (!other.canEqual(this)) { - return false; - } - if (!Objects.equals(locale, other.getLocale())) { - return false; - } - return Objects.equals(value, other.getValue()); - } - - public boolean canEqual(final Object obj) { - return obj instanceof LocalizedStringValue; - } - - @Override - public final String toString() { - return toString(""); - } - - public String toString(final String data) { - - return String.format("%s{ " - + "locale = %s, " - + "value = \"%s\"%s" - + " }", - super.toString(), - Objects.toString(locale), - value, - data); - } - -} diff --git a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValues.java b/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValues.java deleted file mode 100644 index ee74ccc20..000000000 --- a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValues.java +++ /dev/null @@ -1,98 +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.l10n.jaxb; - -import static org.libreccm.l10n.L10NConstants.*; - -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; - -import java.io.Serializable; -import java.util.ArrayList; -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; - -/** - * - * @author Jens Pelzetter - */ -@XmlAccessorType(XmlAccessType.FIELD) -public class LocalizedStringValues implements Serializable { - - private static final long serialVersionUID = 1L; - - @JacksonXmlElementWrapper(useWrapping = false) - @XmlElement(name = "value", namespace = L10N_XML_NS) - private List values; - - public List getValues() { - return new ArrayList<>(values); - } - - public void setValues(final List values) { - this.values = new ArrayList<>(values); - } - - @Override - public int hashCode() { - int hash = 3; - hash = 41 * hash + Objects.hashCode(values); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof LocalizedStringValues)) { - return false; - } - final LocalizedStringValues other = (LocalizedStringValues) obj; - if (!other.canEqual(this)) { - return false; - } - return Objects.equals(values, other.getValues()); - } - - public boolean canEqual(final Object obj) { - return obj instanceof LocalizedStringValues; - } - - @Override - public final String toString() { - return toString(""); - } - - public String toString(final String data) { - return String.format("%s{ " - + "values = %s%s" - + " }", - super.toString(), - Objects.toString(values), - data); - } - -} diff --git a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValuesAdapter.java b/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValuesAdapter.java deleted file mode 100644 index bb472b1af..000000000 --- a/ccm-pages/src/org/libreccm/l10n/jaxb/LocalizedStringValuesAdapter.java +++ /dev/null @@ -1,77 +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.l10n.jaxb; - -import org.libreccm.l10n.LocalizedString; - -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - -/** - * JAXB adapter for {@link LocalizedString#values} to produce a more compact XML - * for the values map. - * - * @author Jens Pelzetter - */ -public class LocalizedStringValuesAdapter - extends XmlAdapter> { - - @Override - public Map unmarshal(final LocalizedStringValues values) - throws Exception { - - return values - .getValues() - .stream() - .collect(Collectors.toMap(value -> new Locale(value.getLocale()), - value -> value.getValue())); - - } - - @Override - public LocalizedStringValues marshal(final Map values) - throws Exception { - - final List list = values - .entrySet() - .stream() - .map(this::generateValue) - .collect(Collectors.toList()); - - final LocalizedStringValues result = new LocalizedStringValues(); - result.setValues(list); - - return result; - } - - private LocalizedStringValue generateValue( - final Map.Entry entry) { - - final LocalizedStringValue value = new LocalizedStringValue(); - value.setLocale(entry.getKey().toString()); - value.setValue(entry.getValue()); - - return value; - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/AbstractPageRenderer.java b/ccm-pages/src/org/libreccm/pagemodel/AbstractPageRenderer.java deleted file mode 100644 index edc4d5369..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/AbstractPageRenderer.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2016 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.pagemodel; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * An abstract base class for implementations of the {@link PageRenderer} - * interface providing some functionality needed by all implementations of the - * {@link PageRenderer} interface. - * - * @author Jens Pelzetter - * - */ -public abstract class AbstractPageRenderer implements PageRenderer { - - private ComponentRendererManager componentRendererManager; - - /** - * Renders a {@code Page} based on a {@link PageModel}. This implementation - * first calls {@link #renderPage()} to create the page object. After that - * all {@link ComponentModel}s of the {@link PageModel} are processed and - * the component objects created by the {@link ComponentRenderer}s are added - * to the page. - * - * @param pageModel The {@link PageModel} to render. - * @param parameters Parameters provided by application which wants to - * render a {@link PageModel}. The parameters are passed - * the {@link ComponentRenderer}s. - * - * @return A map containing the results from rendering the components of the - * page model. - */ - @Override - public Map renderPage( - final PageModel pageModel, final Map parameters) { - - final Map page = renderPage(parameters); - - final ContainerModelCollection containers = pageModel - .getContainerModels(); - while(containers.next()) { - final ContainerModel containerModel = containers - .getContainerModel(); - - final Map container = renderContainer( - containerModel, parameters); - page.put(containerModel.getKey(), container); - } - - return page; - } - - protected Map renderContainer( - final ContainerModel containerModel, - final Map parameters) { - - final Map container = new HashMap<>(); - - container.put("key", containerModel.getKey()); - - final ComponentModelCollection components = containerModel - .getComponents(); - while (components.next()) { - final ComponentModel componentModel = components.getComponentModel(); - - renderComponent(componentModel, - componentModel.getClass(), - parameters) - .ifPresent(component -> container.put(componentModel.getKey(), - component)); - } - - return container; - } - - /** - * Helper method for rendering the components. - * - * @param Generics variable for the type of rendered - * component - * @param componentModel The {@link ComponentModel} to process. - * @param componentModelClass The class of the {@link ComponentModel}. - * @param parameters Parameters provided by application which wants - * to render a {@link PageModel}. The parameters - * are passed the {@link ComponentRenderer}s. - * - * @return A map containing the results from rendering the components of the - * page model. - */ - protected Optional renderComponent( - final ComponentModel componentModel, - final Class componentModelClass, - final Map parameters) { - - final Optional> renderer = componentRendererManager - .findComponentRenderer(componentModelClass); - - if (renderer.isPresent()) { - @SuppressWarnings("unchecked") - final M model = (M) componentModel; - return Optional - .of(renderer.get().renderComponent(model, parameters)); - } else { - return Optional.empty(); - } - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/CategorizedItemComponent.java b/ccm-pages/src/org/libreccm/pagemodel/CategorizedItemComponent.java deleted file mode 100644 index 3cf6cfeaf..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/CategorizedItemComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class CategorizedItemComponent extends ContentItemComponent { - - public static final String BASE_DATA_OBJECT_TYPE - = "org.libreccm.pagemodel.CategorizedItemComponent"; - - public CategorizedItemComponent(final DataObject dataObject) { - - super(dataObject); - } - - public CategorizedItemComponent(final OID oid) { - super(oid); - } - - public CategorizedItemComponent(final BigDecimal componentModelId) { - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/CategoryTreeComponent.java b/ccm-pages/src/org/libreccm/pagemodel/CategoryTreeComponent.java deleted file mode 100644 index 4cf86bcc9..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/CategoryTreeComponent.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class CategoryTreeComponent extends ComponentModel { - - public static final String BASE_DATA_OBJECT_TYPE = "org.libreccm.pagemodel.CategoryTreeComponent"; - - public static final String SHOW_FULL_TREE = "showFullTree"; - - public CategoryTreeComponent(final DataObject dataObject) { - - super(dataObject); - } - - public CategoryTreeComponent(final OID oid) { - - super(oid); - } - - public CategoryTreeComponent(final BigDecimal componentModelId) { - - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - - public Boolean isShowFullTree() { - - return (Boolean) get(SHOW_FULL_TREE); - } - - public void setShowFullTree(final Boolean showFullTree) { - - set(SHOW_FULL_TREE, showFullTree); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ComponentModel.java b/ccm-pages/src/org/libreccm/pagemodel/ComponentModel.java deleted file mode 100644 index 655039e86..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ComponentModel.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.domain.DomainObject; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class ComponentModel extends DomainObject { - - public static final String BASE_DATA_OBJECT_TYPE = "org.libreccm.pagemodel.ComponentModel"; - - public static final String COMPONENT_MODEL_ID = "componentModelId"; - - public static final String UUID = "uuid"; - - public static final String MODEL_UUID = "modelUuid"; - - public static final String ID_ATTRIBUTE = "idAttribute"; - - public static final String CLASS_ATTRIBUTE = "classAttribute"; - - public static final String STYLE_ATTRIBUTE = "styleAttribute"; - - public static final String KEY = "key"; - - public ComponentModel(final DataObject dataObject) { - super(dataObject); - } - - public ComponentModel(final OID oid) { - super(oid); - } - - public ComponentModel(final BigDecimal componentModelId) { - - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - - public BigDecimal getComponentModelId() { - return (BigDecimal) get(COMPONENT_MODEL_ID); - } - - protected void setComponentModelId(final BigDecimal componentModelId) { - set(COMPONENT_MODEL_ID, componentModelId); - } - - public String getUuid() { - return (String) get(UUID); - } - - protected void setUuid(final String uuid) { - set(UUID, uuid); - } - - public String getModelUuid() { - return (String) get(MODEL_UUID); - } - - protected void setModelUuid(final String modelUuid) { - set(MODEL_UUID, modelUuid); - } - - public String getIdAttribute() { - - return (String) get(ID_ATTRIBUTE); - } - - public void setIdAttribute(final String idAttribute) { - - set(ID_ATTRIBUTE, idAttribute); - } - - public String getClassAttribute() { - - return (String) get(CLASS_ATTRIBUTE); - } - - public void setClassAttribute(final String classAttribute) { - - set(CLASS_ATTRIBUTE, classAttribute); - } - - public String getStyleAttribute(final String styleAttribute) { - - return (String) get(STYLE_ATTRIBUTE); - } - - public void setStyleAttribute(final String styleAttribute) { - - set(STYLE_ATTRIBUTE, styleAttribute); - } - - public String getKey() { - - return (String) get(KEY); - } - - public void setKey(final String key) { - - set(KEY, key); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ComponentModelCollection.java b/ccm-pages/src/org/libreccm/pagemodel/ComponentModelCollection.java deleted file mode 100644 index e0747c861..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ComponentModelCollection.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.domain.DomainCollection; -import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.persistence.DataCollection; - -/** - * - * @author Jens Pelzetter - */ -public class ComponentModelCollection extends DomainCollection { - - public ComponentModelCollection(final DataCollection dataCollection) { - - super(dataCollection); - } - - public ComponentModel getComponentModel() { - - return (ComponentModel) DomainObjectFactory - .newInstance(m_dataCollection.getDataObject()); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ComponentRenderer.java b/ccm-pages/src/org/libreccm/pagemodel/ComponentRenderer.java deleted file mode 100644 index 45dfb55e1..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ComponentRenderer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2016 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.pagemodel; - -import java.util.Map; - -/** - * A {@code ComponentRenderer} transforms a {@link ComponentModel} into a - * component. - * - * An implementation must be annotation with the {@link RendersComponent} - * qualifier annotation. - * - * @author Jens Pelzetter - * @param Type of the model the component renderer processes. - */ -public interface ComponentRenderer { - - /** - * Renders a {@link ComponentModel}. - * - * The result of the rendering process is a {@link Map} which uses strings - * as key. The values are either Java primitive types or Collections. More - * exactly the values are objects of one the following types: - * - *
    - *
  • {@link Double}
  • - *
  • {@link Float}
  • - *
  • {@link Integer}
  • - *
  • {@link Long}
  • - *
  • {@link Short}
  • - *
  • {@link String}
  • - *
  • {@link List}
  • - *
  • {@link Map}
  • - *
- * - * Other subtypes {@link Collection} are might be supported but there is no - * guarantee for that. The values in a collection must be one of the types - * in the list above. Collections might contain multiple types from the list - * above. The keys for a map should always be strings. - * - * @param componentModel The component model to render. - * @param parameters Parameters provided by the calling - * {@link PageRenderer}. - * - * @return A map representing the rendered component. - */ - Map renderComponent(M componentModel, - Map parameters); - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ComponentRendererManager.java b/ccm-pages/src/org/libreccm/pagemodel/ComponentRendererManager.java deleted file mode 100644 index cc985a0c2..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ComponentRendererManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.libreccm.pagemodel; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * - * @author Jens Pelzetter - */ -public class ComponentRendererManager { - - private static final Logger LOGGER = LogManager - .getLogger(ComponentRendererManager.class); - - private static final ComponentRendererManager INSTANCE - = new ComponentRendererManager(); - - private final Map, ComponentRenderer> componentRenderers; - - public ComponentRendererManager() { - - componentRenderers = new HashMap<>(); - } - - public static ComponentRendererManager getInstance() { - return INSTANCE; - } - - /** - * Find an implementation of the {@link ComponentRenderer} interface for a - * specific {@link ComponentModel}. - * - * @param Generic variable for the subtype of - * {@link ComponentModel} which is produced by - * the {@link ComponentRenderer} implementation. - * @param componentModelClass The sub class of the {@link ComponentModel} - * for which is processed by the - * {@link ComponentRenderer}. - * - * @return An {@link Optional} containing the implementation of the - * {@link ComponentRenderer} interface for the specified parameters. - * If there is no implementation for the specified parameters an - * empty {@link Optional} is returned. - */ - @SuppressWarnings({"unchecked"}) - public Optional> findComponentRenderer( - final Class componentModelClass) { - - if (componentRenderers.containsKey(componentModelClass)) { - return Optional.of((ComponentRenderer) componentRenderers - .get(componentModelClass)); - } else { - return Optional.empty(); - } - } - - public void registerComponentRenderer( - final Class componentClass, - final ComponentRenderer componentRenderer) { - - componentRenderers.put(componentClass, componentRenderer); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ContainerModel.java b/ccm-pages/src/org/libreccm/pagemodel/ContainerModel.java deleted file mode 100644 index d5b90c3ad..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ContainerModel.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.libreccm.pagemodel; - -import com.arsdigita.domain.DomainObject; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class ContainerModel extends DomainObject { - - public static final String BASE_DATA_OBJECT_TYPE = "org.libreccm.pagemodel.ContainerModel"; - - public static final String CONTAINER_ID = "containerId"; - - public static final String UUID = "uuid"; - - public static final String CONTAINER_UUID = "containerUuid"; - - public static final String KEY = "key"; - - public static final String PAGE_MODEL = "pageModel"; - - public static final String COMPONENT_MODEL = "componentModel"; - - public ContainerModel(final DataObject dataObject) { - super(dataObject); - } - - public ContainerModel(final OID oid) { - super(oid); - } - - public ContainerModel(final BigDecimal containerModelId) { - this(new OID(BASE_DATA_OBJECT_TYPE, containerModelId)); - } - - public BigDecimal getContainerModelId() { - return (BigDecimal) get(CONTAINER_ID); - } - - protected void setContainerModelId(final BigDecimal containerModelId) { - - set(CONTAINER_ID, containerModelId); - } - - public String getUuid() { - return (String) get(UUID); - } - - protected void setUuid(final String uuid) { - - set(UUID, uuid); - } - - public String getContainerUuid() { - - return (String) get(CONTAINER_UUID); - } - - protected void setContainerUuid(final String containerUuid) { - - set(CONTAINER_UUID, containerUuid); - } - - public String getKey() { - - return (String) get(KEY); - } - - public void setKey(final String key) { - - set(KEY, key); - } - - public PageModel getPageModel() { - - return (PageModel) get(PAGE_MODEL); - } - - protected void setPageModel(final PageModel pageModel) { - - setAssociation(PAGE_MODEL, pageModel); - } - - public ComponentModelCollection getComponents() { - - final DataCollection dataCollection = (DataCollection) get( - COMPONENT_MODEL); - - return new ComponentModelCollection(dataCollection); - } - - protected void addComponent(final ComponentModel component) { - - add(COMPONENT_MODEL, component); - } - - protected void removeComponent(final ComponentModel component) { - - remove(COMPONENT_MODEL, component); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ContainerModelCollection.java b/ccm-pages/src/org/libreccm/pagemodel/ContainerModelCollection.java deleted file mode 100644 index d3ee49300..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ContainerModelCollection.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.domain.DomainCollection; -import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.persistence.DataCollection; - -/** - * - * @author Jens Pelzetter - */ -public class ContainerModelCollection extends DomainCollection { - - public ContainerModelCollection(final DataCollection dataCollection) { - super(dataCollection); - } - - public ContainerModel getContainerModel() { - return (ContainerModel) DomainObjectFactory - .newInstance(m_dataCollection.getDataObject()); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ContentItemComponent.java b/ccm-pages/src/org/libreccm/pagemodel/ContentItemComponent.java deleted file mode 100644 index 974a09080..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ContentItemComponent.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class ContentItemComponent extends ComponentModel { - - public static final String BASE_DATA_OBJECT_TYPE - = "org.libreccm.pagemodel.ContentItemComponent"; - - public static final String MODE = "mode"; - - public ContentItemComponent(final DataObject dataObject) { - - super(dataObject); - } - - public ContentItemComponent(final OID oid) { - - super(oid); - } - - public ContentItemComponent(final BigDecimal componentModelId) { - - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - - public String getMode() { - return (String) get(MODE); - } - - public void setMode(final String mode) { - - set(MODE, mode); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/GreetingItemComponent.java b/ccm-pages/src/org/libreccm/pagemodel/GreetingItemComponent.java deleted file mode 100644 index b250417a9..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/GreetingItemComponent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class GreetingItemComponent extends ContentItemComponent { - - public static final String BASE_DATA_OBJECT_TYPE - = "org.libreccm.pagemodel.GreetingItemComponent"; - - public GreetingItemComponent(final DataObject dataObject) { - - super(dataObject); - } - - public GreetingItemComponent(final OID oid) { - super(oid); - } - - public GreetingItemComponent(final BigDecimal componentModelId) { - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/ItemListComponent.java b/ccm-pages/src/org/libreccm/pagemodel/ItemListComponent.java deleted file mode 100644 index a5b9e235e..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/ItemListComponent.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; - -import java.math.BigDecimal; - -/** - * - * @author Jens Pelzetter - */ -public class ItemListComponent extends ComponentModel { - - public static final String BASE_DATA_OBJECT_TYPE = "org.libreccm.pagemodel.ItemListComponent"; - - public static final String DESCENDING = "descending"; - - public static final String LIMIT_TO_TYPE = "limitToType"; - - public static final String PAGE_SIZE = "pageSize"; - - public static final String PROPERTIES = "properties"; - - public ItemListComponent(final DataObject dataObject) { - super(dataObject); - } - - public ItemListComponent(final OID oid) { - super(oid); - } - - public ItemListComponent(final BigDecimal componentModelId) { - - this(new OID(BASE_DATA_OBJECT_TYPE, componentModelId)); - } - - public Boolean isDescending() { - - return (Boolean) get(DESCENDING); - } - - public void setDescending(final Boolean descending) { - - set(DESCENDING, descending); - } - - public String getLimitToType() { - - return (String) get(LIMIT_TO_TYPE); - } - - public void setLimitToType(final String limitToType) { - - set(LIMIT_TO_TYPE, limitToType); - } - - public Integer getPageSize() { - - return (Integer)get(PAGE_SIZE); - } - - public void setPageSize(final Integer pageSize) { - - set(PAGE_SIZE, pageSize); - } - - public String getProperties() { - - return (String) get(PROPERTIES); - } - - public void setProperties(final String properties) { - - set(PROPERTIES, properties); - } -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/PageModel.java b/ccm-pages/src/org/libreccm/pagemodel/PageModel.java deleted file mode 100644 index 4973a757b..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/PageModel.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.libreccm.pagemodel; - -import com.arsdigita.domain.DomainObject; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; -import com.arsdigita.web.Application; - -import java.math.BigDecimal; -import java.util.Date; - -/** - * - * @author Jens Pelzetter - */ -public class PageModel extends DomainObject { - - public static final String BASE_DATA_OBJECT_TYPE = "org.libreccm.pagemodel.PageModel"; - - public static final String PAGE_MODEL_ID = "pageModelId"; - - public static final String UUID = "uuid"; - - public static final String MODEL_UUID = "modelUuid"; - - public static final String NAME = "name"; - - public static final String PAGE_MODEL_VERSION = "pageModelVersion"; - - public static final String LAST_MODIFIED = "lastModified"; - - public static final String TITLE = "title"; - - public static final String DESCRIPTION = "description"; - - public static final String TYPE = "type"; - - public static final String APPLICATION = "application"; - - public static final String CONTAINER_MODELS = "containerModels"; - - public PageModel(final OID oid) { - super(oid); - } - - public PageModel(final BigDecimal pageModelId) { - this(new OID(BASE_DATA_OBJECT_TYPE, pageModelId)); - } - - public PageModel(final DataObject dataObject) { - super(dataObject); - } - - public BigDecimal getPageModelId() { - return (BigDecimal) get(PAGE_MODEL_ID); - } - - protected void setPageModelId(final BigDecimal pageModelId) { - set(PAGE_MODEL_ID, pageModelId); - } - - public String getUuid() { - return (String) get(UUID); - } - - protected void setUuid(final String uuid) { - set(UUID, uuid); - } - - public String getModelUuid() { - return (String) get(MODEL_UUID); - } - - protected void setModelUuid(final String modelUuid) { - set(MODEL_UUID, modelUuid); - } - - public String getName() { - return (String) get(NAME); - } - - public void setName(final String name) { - set(NAME, name); - } - - public String getVersion() { - return (String) get(PAGE_MODEL_VERSION); - } - - protected void setVersion(final String pageModelVersion) { - - set(PAGE_MODEL_VERSION, pageModelVersion); - } - - public Date getLastModified() { - return (Date) get(LAST_MODIFIED); - } - - protected void setLastModified(final Date lastModified) { - set(LAST_MODIFIED, lastModified); - } - - public String getTitle() { - return (String) get(TITLE); - } - - protected void setTitle(final String title) { - set(TITLE, title); - } - - public String getDescription() { - return (String) get(DESCRIPTION); - } - - public void setDescription(final String description) { - set(DESCRIPTION, description); - } - - public Application getApplication() { - return (Application) get(APPLICATION); - } - - public void setApplication(final Application application) { - setAssociation(APPLICATION, application); - } - - public String getType() { - return (String) get(TYPE); - } - - public void setType(final String type) { - set(TYPE, type); - } - - public ContainerModelCollection getContainerModels() { - final DataCollection dataCollection = (DataCollection) get( - CONTAINER_MODELS); - - return new ContainerModelCollection(dataCollection); - } - - protected void addContainerModel(final ContainerModel containerModel) { - - add(CONTAINER_MODELS, containerModel); - } - - protected void removeContainerModel(final ContainerModel containerModel) { - - remove(CONTAINER_MODELS, containerModel); - } -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/PageModelRepository.java b/ccm-pages/src/org/libreccm/pagemodel/PageModelRepository.java deleted file mode 100644 index 0524f8b6e..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/PageModelRepository.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2016 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.pagemodel; - -import java.util.Date; -import java.util.Objects; -import java.util.UUID; - -/** - * - * @author Jens Pelzetter - */ -public class PageModelRepository { - - private static final PageModelRepository INSTANCE = new PageModelRepository(); - - private PageModelRepository() { - - } - - public static final PageModelRepository getInstance() { - return INSTANCE; - } - - public void save(final PageModel pageModel) { - - Objects.requireNonNull(pageModel); - - pageModel.setLastModified(new Date()); - - if (pageModel.getUuid() == null) { - pageModel.setUuid(UUID.randomUUID().toString()); - } - - if (pageModel.getModelUuid() == null) { - pageModel.setModelUuid(pageModel.getUuid()); - } - } - -} diff --git a/ccm-pages/src/org/libreccm/pagemodel/PageRenderer.java b/ccm-pages/src/org/libreccm/pagemodel/PageRenderer.java deleted file mode 100644 index 7d9c539a5..000000000 --- a/ccm-pages/src/org/libreccm/pagemodel/PageRenderer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2016 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.pagemodel; - -import java.util.Map; - -/** - * Interface for page renderers. A page renderer is invoked to render a page of - * specific type. An implementation should be a CDI bean which is annotated with - * the qualifier {@link RendersPageModelType}. - * - * An implementation should add all default components which have to be present - * in page. The {@link PageModel} should only specify - * additional components. - * - * - * @author Jens Pelzetter - */ -public interface PageRenderer { - - /** - * Render a page with the default components for a application. An - * implementation of {@link #renderPage(org.libreccm.pagemodel.PageModel)} - * should use this method for creating the default page. - * - * The result of the rendering process is a map with the values of the - * {@link ComponentModel#key} property as key and the result of rendering - * the component as value. - * - * @param parameters Parameters provided by application which wants to - * render a {@link PageModel}. The parameters are passed - * the {@link ComponentRenderer}s. - * - * @return A page with the default components. - */ - Map renderPage(Map parameters); - - /** - * Render a page using the provided {@link PageModel}. Implementations - * should call the implementation of {@link #renderPage()} for creating the - * basic page with the default components. - * - * The result of the rendering process is a map with the values of the - * {@link ComponentModel#key} property as key and the result of rendering - * the component as value. - * - * - * @param pageModel The {@link PageModel} from which the page is generated. - * @param parameters Parameters provided by application which wants to - * render a {@link PageModel}. The parameters are passed - * the {@link ComponentRenderer}s. - * - * @return The page generated from the provided {@link PageModel}. - */ - Map renderPage(PageModel pageModel, - Map parameters); - -} diff --git a/ccm-pages/src/org/libreccm/theming/ApplicationTemplate.java b/ccm-pages/src/org/libreccm/theming/ApplicationTemplate.java deleted file mode 100644 index 5df031e09..000000000 --- a/ccm-pages/src/org/libreccm/theming/ApplicationTemplate.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.libreccm.theming; - -import static org.libreccm.theming.ThemeConstants.*; - -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; - -/** - * - * @author Jens Pelzetter - */ -@XmlRootElement(name = "application-template", namespace = THEMES_XML_NS) -@XmlAccessorType(XmlAccessType.FIELD) -public class ApplicationTemplate { - - @XmlElement(name = "application-name", namespace = THEMES_XML_NS) - private String applicationName; - - @XmlElement(name = "application-class", namespace = THEMES_XML_NS) - private String applicationClass; - - @XmlElement(name = "template", namespace = THEMES_XML_NS) - private String template; - - public String getApplicationName() { - return applicationName; - } - - public void setApplicationName(final String applicationName) { - this.applicationName = applicationName; - } - - public String getApplicationClass() { - return applicationClass; - } - - public void setApplicationClass(final String applicationClass) { - this.applicationClass = applicationClass; - } - - public String getTemplate() { - return template; - } - - public void setTemplate(final String template) { - this.template = template; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 79 * hash + Objects.hashCode(applicationName); - hash = 79 * hash + Objects.hashCode(applicationClass); - hash = 79 * hash + Objects.hashCode(template); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof ApplicationTemplate)) { - return false; - } - final ApplicationTemplate other = (ApplicationTemplate) obj; - if (!other.canEqual(this)) { - return false; - } - if (!Objects.equals(applicationName, other.getApplicationName())) { - return false; - } - if (!Objects.equals(applicationClass, other.getApplicationClass())) { - return false; - } - - return Objects.equals(template, other.getTemplate()); - } - - public boolean canEqual(final Object obj) { - - return obj instanceof ApplicationTemplate; - } - - @Override - public final String toString() { - return toString(""); - } - - public String toString(final String data) { - - return String.format("%s{ " - + "applicationName = \"%s\", " - + "applicationClass = \"%s\", " - + "template = \"%s\"%s" - + " }", - super.toString(), - applicationName, - applicationClass, - template, - data - ); - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/ContentItemTemplate.java b/ccm-pages/src/org/libreccm/theming/ContentItemTemplate.java deleted file mode 100644 index bf235be16..000000000 --- a/ccm-pages/src/org/libreccm/theming/ContentItemTemplate.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.libreccm.theming; - -import static org.libreccm.theming.ThemeConstants.*; - -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; - -/** - * - * @author Jens Pelzetter - */ -@XmlRootElement(name = "contentitem-template", namespace = THEMES_XML_NS) -@XmlAccessorType(XmlAccessType.FIELD) -public class ContentItemTemplate { - - @XmlElement(name = "view", namespace = THEMES_XML_NS) - private ContentItemViews view; - - @XmlElement(name = "contenttype", namespace = THEMES_XML_NS) - private String contentType; - - @XmlElement(name = "style", namespace = THEMES_XML_NS) - private String style; - - @XmlElement(name = "contentsection", namespace = THEMES_XML_NS) - private String contentSection; - - @XmlElement(name = "category", namespace = THEMES_XML_NS) - private String category; - - @XmlElement(name = "template", namespace = THEMES_XML_NS) - private String template; - - public ContentItemViews getView() { - return view; - } - - public void setView(final ContentItemViews view) { - this.view = view; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(final String contentType) { - this.contentType = contentType; - } - - public String getStyle() { - return style; - } - - public void setStyle(final String style) { - this.style = style; - } - - public String getContentSection() { - return contentSection; - } - - public void setContentSection(final String contentSection) { - this.contentSection = contentSection; - } - - public String getCategory() { - return category; - } - - public void setCategory(final String category) { - this.category = category; - } - - public String getTemplate() { - return template; - } - - public void setTemplate(final String template) { - this.template = template; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 73 * hash + Objects.hashCode(view); - hash = 73 * hash + Objects.hashCode(contentType); - hash = 73 * hash + Objects.hashCode(style); - hash = 73 * hash + Objects.hashCode(contentSection); - hash = 73 * hash + Objects.hashCode(category); - hash = 73 * hash + Objects.hashCode(template); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof ContentItemTemplate)) { - return false; - } - final ContentItemTemplate other = (ContentItemTemplate) obj; - if (!other.canEqual(this)) { - return false; - } - if (!Objects.equals(contentType, other.getContentType())) { - return false; - } - if (!Objects.equals(style, other.getStyle())) { - return false; - } - if (!Objects.equals(contentSection, other.getContentSection())) { - return false; - } - if (!Objects.equals(category, other.getCategory())) { - return false; - } - if (view != other.getView()) { - return false; - } - return Objects.equals(template, other.getTemplate()); - } - - public boolean canEqual(final Object obj) { - - return obj instanceof ContentItemTemplate; - } - - @Override - public final String toString() { - - return toString(""); - } - - public String toString(final String data) { - - return String.format("%s{ " - + "contentType = \"%s\", " - + "style = \"%s\", " - + "contentSection = \"%s\", " - + "category = \"%s\"" - + "template = \"%s\"%s" - + " }", - super.toString(), - contentType, - style, - contentSection, - category, - template, - data); - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/ContentItemViews.java b/ccm-pages/src/org/libreccm/theming/ContentItemViews.java deleted file mode 100644 index e62829390..000000000 --- a/ccm-pages/src/org/libreccm/theming/ContentItemViews.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.libreccm.theming; - -/** - * - * @author Jens Pelzetter - */ -public enum ContentItemViews { - - DETAIL, - GREETING_ITEM, - LIST, - PORTLET_ITEM, -} diff --git a/ccm-pages/src/org/libreccm/theming/FreeMarkerPresentationManager.java b/ccm-pages/src/org/libreccm/theming/FreeMarkerPresentationManager.java deleted file mode 100644 index 9c5b43013..000000000 --- a/ccm-pages/src/org/libreccm/theming/FreeMarkerPresentationManager.java +++ /dev/null @@ -1,353 +0,0 @@ -package org.libreccm.theming; - -import com.arsdigita.bebop.Bebop; -import com.arsdigita.bebop.page.PageTransformer; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.globalization.GlobalizationHelper; -import com.arsdigita.subsite.Site; -import com.arsdigita.templating.PresentationManager; -import com.arsdigita.themedirector.ThemeDirector; -import com.arsdigita.util.UncheckedWrapperException; -import com.arsdigita.web.Web; -import com.arsdigita.xml.Document; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; -import freemarker.cache.MultiTemplateLoader; -import freemarker.cache.TemplateLoader; -import freemarker.cache.WebappTemplateLoader; -import freemarker.ext.dom.NodeModel; -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; -import org.libreccm.theming.manifest.ThemeManifest; -import org.libreccm.theming.manifest.ThemeManifestUtil; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * - * @author Jens Pelzetter - */ -public class FreeMarkerPresentationManager implements PresentationManager { - - @Override - public void servePage(final Document document, - final HttpServletRequest request, - final HttpServletResponse response) { - - final org.w3c.dom.Document w3cDocument = document.getInternalDocument(); - - final Node root = w3cDocument.getDocumentElement(); - - final String currentSiteName = Web.getConfig().getSiteName(); - Site subSite; - try { - subSite = Site.findByHostname(currentSiteName); - } catch (DataObjectNotFoundException ex) { - subSite = null; - } - final boolean isSubSite = subSite != null; - - final String defaultTheme; - if (subSite == null) { - defaultTheme = ThemeDirector - .getThemeDirector() - .getDefaultTheme() - .getURL(); - } else { - defaultTheme = subSite.getStyleDirectory(); - } - - final String selectedTheme; - if (request.getParameter("theme") == null) { - selectedTheme = defaultTheme; - } else { - selectedTheme = request.getParameter("theme"); - } - - final String previewParam = request.getParameter("preview-theme"); - boolean preview = previewParam != null - && ("true".equalsIgnoreCase(previewParam) - || "yes".equalsIgnoreCase(previewParam)); - - final StringBuilder themePathBuilder = new StringBuilder( - "/themes/"); - if (preview) { - themePathBuilder.append("devel-themedir/"); - } else { - themePathBuilder.append("published-themedir/"); - } - themePathBuilder.append(selectedTheme).append("/"); - final String themePath = themePathBuilder.toString(); - final String themeManifestPath = String.format( - "%s" + ThemeConstants.THEME_MANIFEST_JSON, themePath); - - 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) { - final PageTransformer pageTransformer = new PageTransformer(); - pageTransformer.servePage(document, request, response); - return; - } - final ThemeManifestUtil manifestUtil = ThemeManifestUtil.getInstance(); - - final ThemeManifest manifest = manifestUtil - .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); - } - - // ToDo - final NamedNodeMap pageAttrs = root.getAttributes(); - final Node applicationNameAttr = pageAttrs.getNamedItem("application"); - final Node applicationClassAttr = pageAttrs.getNamedItem("class"); - final String applicationName = applicationNameAttr.getNodeValue(); - final String applicationClass = applicationClassAttr.getNodeValue(); - - final Optional applicationTemplate - = findApplicationTemplate( - templates, - applicationName, - applicationClass); - final String applicationTemplatePath; - if (applicationTemplate.isPresent()) { - applicationTemplatePath = applicationTemplate.get().getTemplate(); - } else { - applicationTemplatePath = templates.getDefaultApplicationTemplate(); - } - - if ("XSL_FALLBACK.XSL".equals(applicationTemplatePath)) { - final PageTransformer pageTransformer = new PageTransformer(); - pageTransformer.servePage(document, request, response); - return; - } - - final Configuration configuration = new Configuration( - Configuration.VERSION_2_3_28); - final WebappTemplateLoader themeTemplateLoader - = new WebappTemplateLoader(servletContext, - themePath); - final WebappTemplateLoader macrosLoader = new WebappTemplateLoader( - servletContext, - "/themes/freemarker"); - final MultiTemplateLoader templateLoader = new MultiTemplateLoader( - new TemplateLoader[]{themeTemplateLoader, macrosLoader}); -// configuration.setServletContextForTemplateLoading(servletContext, -// themePath); - configuration.setTemplateLoader(templateLoader); - configuration.setDefaultEncoding("UTF-8"); - - final Map data = new HashMap<>(); - - // The XML document - data.put("model", NodeModel.wrap(root)); - - // Parameters (in XSL provided as XSL parameters) - data.put("contextPath", request.getContextPath()); - data.put("contextPrefix", - Web.getWebContext().getRequestURL().getContextPath()); - data.put("dcpOnButtons", - Bebop.getConfig().doubleClickProtectionOnButtons()); - data.put("dcpOnLinks", - Bebop.getConfig().doubleClickProtectionOnLinks()); - data.put("dispatcherPrefix", com.arsdigita.web.URL.getDispatcherPath()); - final String host; - if (request.getServerPort() == 80) { - host = String.format("%s://%s", - request.getScheme(), - request.getServerName()); - } else { - host = String.format("%s://%s:%d", - request.getScheme(), - request.getServerName(), - request.getServerPort()); - } - data.put("host", host); - data.put("internalTheme", - Web.getWebContext().getRequestURL().getContextPath() - + com.arsdigita.web.URL.INTERNAL_THEME_DIR); - data.put("negotiatedLanguage", - GlobalizationHelper.getNegotiatedLocale().getLanguage()); - data.put("requestScheme", request.getScheme()); - data.put("rootContextPrefix", - Web.getConfig().getDispatcherContextPath()); - final Locale selectedLocale = GlobalizationHelper - .getSelectedLocale(request); - if (selectedLocale == null) { - data.put("selectedLanguage", ""); - } else { - data.put("selectedLanguage", selectedLocale.getLanguage()); - } - data.put("serverName", request.getServerName()); - data.put("serverPort", request.getServerPort()); - data.put("userAgent", request.getHeader("user-Agent")); - - final Template template; - try { - template = configuration.getTemplate(applicationTemplatePath); - } catch (IOException ex) { - throw new UncheckedWrapperException(ex); - } - - response.setCharacterEncoding(StandardCharsets.UTF_8.toString()); - response.setContentType("text/html"); - - try (PrintWriter writer = response.getWriter()) { - - template.process(data, writer); - -// writer.append("Data:\n"); -// writer -// .append("Current Site Name: ") -// .append(currentSiteName).append("\n"); -// writer -// .append("isSubSite: ") -// .append(Boolean.toString(isSubSite)) -// .append("\n"); -// writer -// .append("default theme: ") -// .append(defaultTheme) -// .append("\n"); -// writer -// .append("selected theme: ") -// .append(selectedTheme) -// .append("\n"); -// writer -// .append("preview theme? ") -// .append(Boolean.toString(preview)) -// .append("\n"); -// writer -// .append("themePath: ") -// .append(themePath) -// .append("\n"); -// writer -// .append("themeManifestPath: ") -// .append(themeManifestPath) -// .append("\n"); -// writer -// .append("themeManifest: ") -// .append(manifest.toString()) -// .append("\n"); -// writer -// .append("theme name: ") -// .append(manifest.getName()) -// .append("\n"); -// writer -// .append("Application name: ") -// .append(applicationName) -// .append("\n"); -// writer -// .append("Application class: ") -// .append(applicationClass) -// .append("\n"); -// writer -// .append("Application templates:\n"); -// for (final ApplicationTemplate template : templates -// .getApplications()) { -// writer -// .append("\t") -// .append(template.toString()) -// .append("\n"); -// } - } catch (IOException | TemplateException ex) { - throw new UncheckedWrapperException(ex); - } - -// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - private Optional findApplicationTemplate( - final Templates templates, - final String applicationName, - final String applicationClass) { - - final Optional forNameAndClass = templates - .getApplications() - .stream() - .filter(template -> filterApplicationTemplates(template, - applicationName, - applicationClass)) - .findAny(); - if (forNameAndClass.isPresent()) { - return forNameAndClass; - } else { - - final Optional forName = templates - .getApplications() - .stream() - .filter(tpl -> tpl.getApplicationName().equals(applicationName)) - .findAny(); - - return forName; - } - } - - private boolean filterApplicationTemplates( - final ApplicationTemplate template, - final String applicationName, - final String applicationClass) { - - return template.getApplicationName().equals(applicationName) - && template.getApplicationClass().equals(applicationClass); - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/Templates.java b/ccm-pages/src/org/libreccm/theming/Templates.java deleted file mode 100644 index 7a7138c92..000000000 --- a/ccm-pages/src/org/libreccm/theming/Templates.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.libreccm.theming; - - -import static org.libreccm.theming.ThemeConstants.*; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -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; - -/** - * - * @author Jens Pelzetter - */ -@XmlRootElement(name = "templates", namespace = THEMES_XML_NS) -@XmlAccessorType(XmlAccessType.FIELD) -public class Templates { - - @XmlElementWrapper(name = "applications", namespace = THEMES_XML_NS) - @XmlElement(name = "applications", namespace = THEMES_XML_NS) - private List applications; - - @XmlElement(name = "default-application-template", - namespace = THEMES_XML_NS) - private String defaultApplicationTemplate; - - @XmlElementWrapper(name = "contentitems", namespace = THEMES_XML_NS) - @XmlElement(name = "contentitems", namespace = THEMES_XML_NS) - private List contentItems; - - @XmlElement(name = "default-contentitem-template", - namespace = THEMES_XML_NS) - private String defaultContentItemsTemplate; - - public Templates() { - - applications = new ArrayList<>(); - contentItems= new ArrayList<>(); - } - - public List getApplications() { - - return Collections.unmodifiableList(applications); - } - - public void addApplication(final ApplicationTemplate template) { - - applications.add(template); - } - - public void removeApplication(final ApplicationTemplate template) { - - applications.remove(template); - } - - public void setApplications(final List applications) { - - this.applications = new ArrayList<>(applications); - } - - public String getDefaultApplicationTemplate() { - return defaultApplicationTemplate; - } - - public void setDefaultApplicationTemplate( - final String defaultApplicationTemplate) { - this.defaultApplicationTemplate = defaultApplicationTemplate; - } - - public List getContentItems() { - - return Collections.unmodifiableList(contentItems); - } - - public void addContentItem(final ContentItemTemplate template) { - - contentItems.add(template); - } - - public void removeContentItem(final ContentItemTemplate template) { - - contentItems.remove(template); - } - - public void setContentItems(final List contentItems) { - - this.contentItems = new ArrayList<>(contentItems); - } - - public String getDefaultContentItemsTemplate() { - return defaultContentItemsTemplate; - } - - public void setDefaultContentItemsTemplate( - final String defaultContentItemsTemplate) { - this.defaultContentItemsTemplate = defaultContentItemsTemplate; - } -} diff --git a/ccm-pages/src/org/libreccm/theming/ThemeConstants.java b/ccm-pages/src/org/libreccm/theming/ThemeConstants.java deleted file mode 100644 index 3ed285aca..000000000 --- a/ccm-pages/src/org/libreccm/theming/ThemeConstants.java +++ /dev/null @@ -1,38 +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; - -/** - * - * @author Jens Pelzetter - */ -public final class ThemeConstants { - - public static final String PAGE_PARAMETER_TEMPLATE = "template"; - - public final static String THEME_MANIFEST_JSON = "theme.json"; - public final static String THEME_MANIFEST_XML = "theme.xml"; - - public final static String THEMES_XML_NS = "http://themes.libreccm.org"; - - private ThemeConstants() { - //Nothing - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifest.java b/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifest.java deleted file mode 100644 index 76133ed7e..000000000 --- a/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifest.java +++ /dev/null @@ -1,240 +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.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.*; - -import java.io.Serializable; - -/** - * Each theme contains a Manifest (either in XML or JSON format) which provides - * informations about the theme. - * - * @author Jens Pelzetter - */ -@XmlRootElement(name = "theme", namespace = THEMES_XML_NS) -@XmlAccessorType(XmlAccessType.FIELD) -public class ThemeManifest implements Serializable { - - private static final long serialVersionUID = 699497658459398231L; - - /** - * The name of the theme. Usually the same as the name of directory which - * contains the theme. - */ - @XmlElement(name = "name", namespace = THEMES_XML_NS) - private String name; - - /** - * The type of the theme, for example XSLT. - */ - @XmlElement(name = "type", namespace = THEMES_XML_NS) - private String type; - - @XmlElement(name = "master-theme", namespace = THEMES_XML_NS) - private String masterTheme; - - /** - * The (localised) title of the theme. - */ - @XmlElement(name = "title", namespace = THEMES_XML_NS) - private LocalizedString title; - - /** - * A (localised) description of the theme. - */ - @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; - - /** - * Path of the default template. - */ - @XmlElement(name = "default-template", namespace = THEMES_XML_NS) - private String defaultTemplate; - - public ThemeManifest() { - templates = new ArrayList<>(); - } - - public String getName() { - return name; - } - - public void setName(final String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(final String type) { - this.type = type; - } - - public String getMasterTheme() { - return masterTheme; - } - - public void setMasterTheme(final String masterTheme) { - this.masterTheme = masterTheme; - } - - 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 List getTemplates() { - return Collections.unmodifiableList(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 String getDefaultTemplate() { - return defaultTemplate; - } - - public void setDefaultTemplate(final String defaultTemplate) { - this.defaultTemplate = defaultTemplate; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 83 * hash + Objects.hashCode(name); - hash = 83 * hash + Objects.hashCode(type); - hash = 83 * hash + Objects.hashCode(masterTheme); - hash = 83 * hash + Objects.hashCode(title); - hash = 83 * hash + Objects.hashCode(description); - hash = 83 * hash + Objects.hashCode(templates); - hash = 83 * hash + Objects.hashCode(defaultTemplate); - return hash; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (!(obj instanceof ThemeManifest)) { - return false; - } - final ThemeManifest other = (ThemeManifest) obj; - if (!other.canEqual(this)) { - return false; - } - if (!Objects.equals(name, other.getName())) { - return false; - } - if (!Objects.equals(type, other.getType())) { - return false; - } - if (!Objects.equals(masterTheme, other.getMasterTheme())) { - return false; - } - if (!Objects.equals(title, other.getTitle())) { - return false; - } - if (!Objects.equals(description, other.getDescription())) { - return false; - } - if (!Objects.equals(templates, other.getTemplates())) { - return false; - } - return Objects.equals(defaultTemplate, other.getDefaultTemplate()); - } - - public boolean canEqual(final Object obj) { - return obj instanceof ThemeManifest; - } - - @Override - public String toString() { - return toString(""); - } - - public String toString(final String data) { - - return String.format("%s{ " - + "name = \"%s\", " - + "type = \"%s\", " - + "masterTheme = \"%s\", " - + "title = \"%s\", " - + "description = \"%s\", " - + "templates = %s, " - + "defaultTemplate%s" - + " }", - super.toString(), - name, - type, - masterTheme, - Objects.toString(title), - Objects.toString(description), - Objects.toString(templates), - defaultTemplate, - data); - - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifestUtil.java b/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifestUtil.java deleted file mode 100644 index 5841515bd..000000000 --- a/ccm-pages/src/org/libreccm/theming/manifest/ThemeManifestUtil.java +++ /dev/null @@ -1,202 +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 com.arsdigita.util.UncheckedWrapperException; - -import static org.libreccm.theming.ThemeConstants.*; - -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.XmlMapper; -import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.Serializable; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Locale; - - -/** - * A Utility class for loading them manifest file of a theme. - * - * @author Jens Pelzetter - */ -public class ThemeManifestUtil implements Serializable { - - private static final long serialVersionUID = -7650437144515619682L; - - private static final ThemeManifestUtil INSTANCE = new ThemeManifestUtil(); - - private ThemeManifestUtil() {}; - - public static final ThemeManifestUtil getInstance() { - - return INSTANCE; - } - - /** - * Reads the manifest file at {@code path}. - * - * @param path The path of the manifest file. - * - * @return The parsed manifest file. - */ - public ThemeManifest loadManifest(final Path path) { - -// final String pathStr = path.toString().toLowerCase(Locale.ROOT); - final BufferedReader reader; - try { - reader = Files.newBufferedReader(path, Charset.forName("UTF-8")); - } catch (IOException ex) { - throw new UncheckedWrapperException(ex); - } - - return parseManifest(reader, path.toString()); - -// final ObjectMapper mapper; -// if (pathStr.endsWith(THEME_MANIFEST_JSON)) { -// mapper = new ObjectMapper(); -// } else if (pathStr.endsWith(THEME_MANIFEST_XML)) { -// final JacksonXmlModule xmlModule = new JacksonXmlModule(); -// mapper = new XmlMapper(xmlModule); -// } else { -// throw new IllegalArgumentException(String -// .format("The provided path \"%s\" does not point to a theme " -// + "manifest file.", -// path.toString())); -// } -// -// mapper.registerModule(new JaxbAnnotationModule()); -// -// final ThemeManifest manifest; -// try { -// manifest = mapper.readValue(reader, ThemeManifest.class); -// } catch (IOException ex) { -// throw new UnexpectedErrorException(ex); -// } -// return manifest; - } - - public ThemeManifest loadManifest(final InputStream inputStream, - final String fileName) { - - final InputStreamReader reader; - try { - reader = new InputStreamReader(inputStream, "UTF-8"); - } catch (UnsupportedEncodingException ex) { - throw new UncheckedWrapperException(ex); - } - - return parseManifest(reader, fileName); - -// final ObjectMapper mapper; -// if (fileName.endsWith(THEME_MANIFEST_JSON)) { -// mapper = new ObjectMapper(); -// } else if (fileName.endsWith(THEME_MANIFEST_XML)) { -// final JacksonXmlModule xmlModule = new JacksonXmlModule(); -// mapper = new XmlMapper(xmlModule); -// } else { -// throw new IllegalArgumentException(String -// .format("The provided path \"%s\" does not point to a theme " -// + "manifest file.", -// fileName)); -// } -// -// mapper.registerModule(new JaxbAnnotationModule()); -// -// final ThemeManifest manifest; -// try { -// manifest = mapper.readValue(reader, ThemeManifest.class); -// } catch (IOException ex) { -// throw new UnexpectedErrorException(ex); -// } -// return manifest; - } - - public String serializeManifest(final ThemeManifest manifest, - final String format) { - - final ObjectMapper mapper; - - switch (format) { - case THEME_MANIFEST_JSON: - mapper = new ObjectMapper(); - break; - case THEME_MANIFEST_XML: - final JacksonXmlModule xmlModule = new JacksonXmlModule(); - mapper = new XmlMapper(xmlModule); - break; - default: - throw new IllegalArgumentException( - "Unsupported format for ThemeManifest"); - } - - mapper.registerModule(new JaxbAnnotationModule()); - mapper.configure(SerializationFeature.INDENT_OUTPUT, true); - - final StringWriter writer = new StringWriter(); - try { - mapper.writeValue(writer, manifest); - } catch (IOException ex) { - throw new UncheckedWrapperException(ex); - } - - return writer.toString(); - } - - private ThemeManifest parseManifest(final Reader reader, - final String path) { - - final String pathStr = path.toLowerCase(Locale.ROOT); - - final ObjectMapper mapper; - if (pathStr.endsWith(THEME_MANIFEST_JSON)) { - mapper = new ObjectMapper(); - } else if (pathStr.endsWith(THEME_MANIFEST_XML)) { - final JacksonXmlModule xmlModule = new JacksonXmlModule(); - mapper = new XmlMapper(xmlModule); - } else { - throw new IllegalArgumentException(String - .format("The provided path \"%s\" does not point to a theme " - + "manifest file.", - path)); - } - - mapper.registerModule(new JaxbAnnotationModule()); - - final ThemeManifest manifest; - try { - manifest = mapper.readValue(reader, ThemeManifest.class); - } catch (IOException ex) { - throw new UncheckedWrapperException(ex); - } - return manifest; - } - -} diff --git a/ccm-pages/src/org/libreccm/theming/manifest/ThemeTemplate.java b/ccm-pages/src/org/libreccm/theming/manifest/ThemeTemplate.java deleted file mode 100644 index 236862e77..000000000 --- a/ccm-pages/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); - } - -} diff --git a/ccm-pages/src/org/librecms/pages/Pages.java b/ccm-pages/src/org/librecms/pages/Pages.java deleted file mode 100644 index 1e7fcefd1..000000000 --- a/ccm-pages/src/org/librecms/pages/Pages.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.librecms.pages; - -import com.arsdigita.categorization.Category; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.london.terms.Domain; -import com.arsdigita.persistence.DataObject; -import com.arsdigita.persistence.OID; -import com.arsdigita.subsite.Site; -import com.arsdigita.web.Application; - -import java.math.BigDecimal; - -public class Pages extends Application { - - public static final String BASE_DATA_OBJECT_TYPE = "org.librecms.cms.Pages"; - - public static final String SITE = "site"; - public static final String DOMAIN_CATEGORY = "domainCategory"; - - public Pages(final OID oid) { - super(oid); - } - - public Pages(final DataObject dataObject) { - super(dataObject); - } - - public Pages(final BigDecimal pagesId) throws DataObjectNotFoundException { - - this(new OID(BASE_DATA_OBJECT_TYPE, pagesId)); - } - - public Site getSite() { - - final Object obj = get(SITE); - - if (obj == null) { - return null; - } else { - return (Site) obj; - } - - } - - public void setSite(final Site site) { - - setAssociation(SITE, site); - } - - public Domain getCategoryDomain() { - - final Object dataObject = get(DOMAIN_CATEGORY); - - if (dataObject == null) { - return null; - } else { - final Category domainCategory = (Category) dataObject; - - return Domain.findByModel(domainCategory); - } - } - - protected void setCategoryDomain(final Domain domain) { - - final Category domainCategory; - if (domain == null) { - domainCategory = null; - } else { - domainCategory = domain.getModel(); - } - - setAssociation(DOMAIN_CATEGORY, domainCategory); - } - - @Override - public String getServletPath() { - return "/"; - } - -} diff --git a/ccm-pages/web/themes/freemarker/language.ftl b/ccm-pages/web/themes/freemarker/language.ftl deleted file mode 100644 index c253dd3f4..000000000 --- a/ccm-pages/web/themes/freemarker/language.ftl +++ /dev/null @@ -1,23 +0,0 @@ -<#ftl ns_prefixes={ -"bebop":"http://www.arsdigita.com/bebop/1.0", -"cms":"http://www.arsdigita.com/cms/1.0", -"nav":"http://ccm.redhat.com/navigation", -"ui": "http://www.arsdigita.com/ui/1.0"} -> - -<#macro availableLanguages> - - <#assign langs=["empty"]> - <#if (model["/bebop:page/cms:contentPanel"]?size > 0)> - <#assign langs=model["/bebop:page/cms:contentPanel/availableLanguages/language/@locale"]> - <#elseif (model["/bebop:page/nav:greetingItem"]?size > 0)> - <#assign langs=model["/bebop:page/nav:greetingItem/availableLanguages/language/@locale"]> - <#else> - <#assign langs=model["/bebop:page/ui:siteBanner/supportedLanguages/language/@locale"]> - - - <#list langs?sort as lang> - <#nested lang, lang==negotiatedLanguage> - - - diff --git a/ccm-pages/web/themes/freemarker/macros.ftl b/ccm-pages/web/themes/freemarker/macros.ftl deleted file mode 100644 index 531e752ae..000000000 --- a/ccm-pages/web/themes/freemarker/macros.ftl +++ /dev/null @@ -1,12 +0,0 @@ -<#ftl ns_prefixes={ -"bebop":"http://www.arsdigita.com/bebop/1.0", -"cms":"http://www.arsdigita.com/cms/1.0", -"nav":"http://ccm.redhat.com/navigation", -"ui": "http://www.arsdigita.com/ui/1.0"} -> - -<#-- Move to Navigation tags? --> -<#macro pageTitle> - ${model["//nav:categoryMenu/nav:category/@title"]} - -