diff --git a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionServlet.java b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionServlet.java
index f3041abb4..4c6596ad6 100644
--- a/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionServlet.java
+++ b/ccm-cms/src/main/java/org/librecms/contentsection/ContentSectionServlet.java
@@ -242,6 +242,16 @@ public class ContentSectionServlet extends BaseApplicationServlet {
final RequestContext ctx = DispatcherHelper.getRequestContext();
final String url = ctx.getRemainingURLPart();
+
+ //Only for testing PageModel
+ if (url != null && url.endsWith("page-model/")) {
+ getServletContext()
+ .getRequestDispatcher("/page-model.bebop")
+ .include(request, response);
+ return;
+ }
+ //End Test PageModel
+
LOGGER.info("Resolving URL {} and trying as item first.");
final ItemResolver itemResolver = getItemResolver(section);
diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql
index 226e373bf..d09970939 100644
--- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql
+++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/h2/V7_0_0_0__create_tables.sql
@@ -1575,4 +1575,4 @@ alter table CCM_CMS.ARTICLE_LEADS
alter table CCM_CMS.WORKFLOW_TASKS
add constraint FKge2x94m1y9tr7mk26ensyn674
foreign key (TASK_ID)
- references CCM_CORE.WORKFLOW_USER_TASKS;
+ references CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS;
diff --git a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_0__create_tables.sql b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_0__create_tables.sql
index 594d04efd..3232e3e96 100644
--- a/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_0__create_tables.sql
+++ b/ccm-cms/src/main/resources/db/migrations/org/librecms/ccm_cms/pgsql/V7_0_0_0__create_tables.sql
@@ -1,5 +1,3 @@
-
-
create table CCM_CMS.ARTICLE_LEADS (
OBJECT_ID int8 not null,
LOCALIZED_VALUE text,
@@ -1577,4 +1575,4 @@
alter table CCM_CMS.WORKFLOW_TASKS
add constraint FKge2x94m1y9tr7mk26ensyn674
foreign key (TASK_ID)
- references CCM_CORE.WORKFLOW_USER_TASKS;
+ references CCM_CORE.WORKFLOW_ASSIGNABLE_TASKS;
diff --git a/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java b/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
index 0a30f6bcc..5dae5f9fa 100644
--- a/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
+++ b/ccm-core/src/main/java/com/arsdigita/web/CCMDispatcherServlet.java
@@ -495,6 +495,7 @@ public class CCMDispatcherServlet extends BaseServlet {
final StringBuffer target = new StringBuffer(128);
target.append(m_typeURI);
+ target.append("/");
target.append(path.substring(m_instanceURI.length()));
target.append("?");
target.append(BaseApplicationServlet.APPLICATION_ID_PARAMETER);
diff --git a/ccm-core/src/main/java/org/libreccm/pagemodel/AbstractPageBuilder.java b/ccm-core/src/main/java/org/libreccm/pagemodel/AbstractPageBuilder.java
new file mode 100644
index 000000000..81f9a4e0f
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/pagemodel/AbstractPageBuilder.java
@@ -0,0 +1,64 @@
+/*
+ * 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 javax.inject.Inject;
+
+/**
+ *
+ * @param
Page class
+ *
+ * @author Jens Pelzetter
+ *
+ */
+public abstract class AbstractPageBuilder
implements PageBuilder
{
+
+ @Inject
+ private ComponentBuilderManager componentBuilderManager;
+
+ @Override
+ public P buildPage(final PageModel pageModel) {
+ final P page = buildPage();
+
+ for (final ComponentModel componentModel : pageModel.getComponents()) {
+ final Object component = buildComponent(
+ componentModel, componentModel.getClass());
+ addComponent(page, component);
+ }
+
+ return page;
+ }
+
+ protected Object buildComponent(
+ final ComponentModel componentModel,
+ final Class componentModelClass) {
+
+ componentBuilderManager.findComponentBuilder(componentModel.getClass(),
+ getType());
+
+ final ComponentBuilder builder = componentBuilderManager
+ .findComponentBuilder(componentModelClass, getType());
+
+ return builder.buildComponent((M) componentModel);
+ }
+
+ protected abstract String getType();
+
+ protected abstract void addComponent(P page, Object component);
+}
diff --git a/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentBuilderManager.java b/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentBuilderManager.java
new file mode 100644
index 000000000..e19cc7942
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentBuilderManager.java
@@ -0,0 +1,95 @@
+/*
+ * 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.Iterator;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+@RequestScoped
+public class ComponentBuilderManager {
+
+ @Inject
+ private Instance> componentBuilders;
+
+ public ComponentBuilder findComponentBuilder(
+ final Class componentModelClass,
+ final String type) {
+
+ final ComponentModelTypeLiteral literal = new ComponentModelTypeLiteral(
+ componentModelClass, type);
+
+ final Instance> instance = componentBuilders
+ .select(literal);
+ if (instance.isUnsatisfied()) {
+ throw new IllegalArgumentException(String.format(
+ "No ComponentBuilder for component model \"%s\" and type \"%s\" "
+ + "available.",
+ componentModelClass.getName(),
+ type));
+ } else if(instance.isAmbiguous()) {
+ throw new IllegalArgumentException(String.format(
+ "Multiple ComponentBuilders for component model \"%s\" and type \"%s\" "
+ + "available. Something is wrong",
+ componentModelClass.getName(),
+ type));
+ } else {
+ final Iterator> iterator = instance.iterator();
+ final ComponentBuilder, ?> componentBuilder = iterator.next();
+
+ return (ComponentBuilder) componentBuilder;
+ }
+
+ }
+
+ private class ComponentModelTypeLiteral
+ extends AnnotationLiteral
+ implements ComponentModelType {
+
+ private static final long serialVersionUID = -2601632434295178600L;
+
+ private final Class extends ComponentModel> componentModel;
+ private final String type;
+
+ public ComponentModelTypeLiteral(
+ final Class extends ComponentModel> componentModel,
+ final String type) {
+ this.componentModel = componentModel;
+ this.type = type;
+ }
+
+ @Override
+ public Class extends ComponentModel> componentModel() {
+ return componentModel;
+ }
+
+ @Override
+ public String type() {
+ return type;
+ }
+
+ }
+
+}
diff --git a/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentModelType.java b/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentModelType.java
index b42eac467..c08a9c5d5 100644
--- a/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentModelType.java
+++ b/ccm-core/src/main/java/org/libreccm/pagemodel/ComponentModelType.java
@@ -26,7 +26,7 @@ import java.lang.annotation.Target;
import javax.inject.Qualifier;
/**
- * Specifies for which view technology a {@link ComponentBuilder} builds the
+ * Specifies for which component and view technology a {@link ComponentBuilder} builds the
* components.
*
* @author Jens Pelzetter
@@ -36,6 +36,8 @@ import javax.inject.Qualifier;
@Target(ElementType.TYPE)
public @interface ComponentModelType {
+ Class extends ComponentModel> componentModel();
+
String type();
}
diff --git a/ccm-core/src/main/java/org/libreccm/pagemodel/PageBuilderManager.java b/ccm-core/src/main/java/org/libreccm/pagemodel/PageBuilderManager.java
index 2e5e263f6..c27e8fccc 100644
--- a/ccm-core/src/main/java/org/libreccm/pagemodel/PageBuilderManager.java
+++ b/ccm-core/src/main/java/org/libreccm/pagemodel/PageBuilderManager.java
@@ -45,7 +45,6 @@ public class PageBuilderManager {
type, applicationType);
final Instance> instance = pageBuilders.select(literal);
-
if (instance.isUnsatisfied()) {
throw new IllegalArgumentException(String.format(
"No PageBuilder for type \"%s\" and application type \"%s\" "
@@ -54,7 +53,7 @@ public class PageBuilderManager {
applicationType));
} else if (instance.isAmbiguous()) {
throw new IllegalArgumentException(String.format(
- "There are more than one PageBuilders for type \"%s\" and "
+ "Multiple PageBuilders for type \"%s\" and "
+ "application type \"%s\" avilable. Something is wrong.",
type,
applicationType));
diff --git a/ccm-core/src/main/java/org/libreccm/pagemodel/bebop/AbstractBebopPageBuilder.java b/ccm-core/src/main/java/org/libreccm/pagemodel/bebop/AbstractBebopPageBuilder.java
new file mode 100644
index 000000000..b279da0ee
--- /dev/null
+++ b/ccm-core/src/main/java/org/libreccm/pagemodel/bebop/AbstractBebopPageBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * 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.bebop;
+
+import com.arsdigita.bebop.Component;
+import com.arsdigita.bebop.Page;
+import com.arsdigita.bebop.PageFactory;
+import com.arsdigita.web.Web;
+import org.libreccm.pagemodel.AbstractPageBuilder;
+
+/**
+ *
+ * @author Jens Pelzetter
+ */
+public abstract class AbstractBebopPageBuilder extends AbstractPageBuilder{
+
+ public static final String BEBOP = "Bebop";
+
+ @Override
+ protected String getType() {
+ return BEBOP;
+ }
+
+ @Override
+ protected void addComponent(final Page page, final Object component) {
+ final Component bebopComponent = (Component) component;
+
+ page.add(bebopComponent);
+ }
+
+ @Override
+ public Page buildPage() {
+
+ final String application = Web.getWebContext().getApplication().getPrimaryUrl();
+ final Page page = PageFactory.buildPage(application, "");
+
+ return page;
+ }
+
+ public abstract void addDefaultComponents(final Page page);
+}