Author: julien(a)jboss.com
Date: 2008-06-07 17:22:25 -0400 (Sat, 07 Jun 2008)
New Revision: 10942
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelImporter.java
Removed:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ContextNode.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/NodeImporter.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PageNode.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNode.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeManager.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/NodeImporter.java
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java
Log:
rename NodeImporter to ModelImporter
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ContextNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ContextNode.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ContextNode.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIContext;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class ContextNode extends PortalNode
-{
- public ContextNode(String name, PortalNodeManager structuralStateContext)
- {
- super(name, structuralStateContext);
- }
-
- public Class<? extends UIObject> getType()
- {
- return UIContext.class;
- }
-}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelImporter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelImporter.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/ModelImporter.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -0,0 +1,305 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.portal.model;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.xml.XMLTools;
+import org.jboss.portal.common.NotYetImplemented;
+import static org.jboss.portal.common.xml.XMLTools.*;
+import org.jboss.portal.presentation.portal.content.markup.MarkupContent;
+import org.jboss.portal.presentation.portal.content.portlet.PortletContent;
+import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
+import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
+import org.jboss.portal.presentation.portal.model.layout.StructureElement;
+import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
+import org.jboss.portal.presentation.portal.model.object.PortalNode;
+import org.jboss.portal.presentation.portal.model.object.PageNode;
+import org.jboss.portal.presentation.portal.model.object.WindowNode;
+import org.jboss.portal.presentation.model.layout.Constants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ModelImporter
+{
+
+ /** . */
+ private final static Schema schema;
+
+ /** . */
+ private static final URL schemaURL;
+
+ static
+ {
+ try
+ {
+ schemaURL =
ModelImporter.class.getClassLoader().getResource("org/jboss/portal/presentation/portal/page_structure_1_0.xsd");
+ SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ schema = factory.newSchema(schemaURL);
+ }
+ catch (SAXException e)
+ {
+ throw new Error("Could not load the page structure 1.0 schema", e);
+ }
+
+ }
+
+ /** The root to import the children to. */
+ private final PortalNode root;
+
+ /** . */
+ private final LayoutStore layoutStore;
+
+ public ModelImporter(PortalNode root, LayoutStore layoutStore)
+ {
+ this.root = root;
+ this.layoutStore = layoutStore;
+ }
+
+ /**
+ * Imports the specified document.
+ *
+ * @param document the document
+ * @throws IllegalArgumentException if the document is null
+ */
+ public void importDocument(Document document) throws IllegalArgumentException
+ {
+ if (document == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ importContextDef(document.getDocumentElement());
+ }
+
+ public void importDocument(InputStream in) throws IllegalArgumentException,
ParserConfigurationException, IOException, SAXException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ InputStream schemaStream = schemaURL.openStream();
+
+ try
+ {
+ DocumentBuilderFactory factory = XMLTools.getDocumentBuilderFactory();
+ factory.setValidating(true);
+ factory.setNamespaceAware(true);
+
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
"http://www.w3.org/2001/XMLSchema");
+
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
schemaStream);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(in);
+ importDocument(doc);
+ }
+ finally
+ {
+ IOTools.safeClose(schemaStream);
+ }
+ }
+
+ private void importContextDef(org.w3c.dom.Element contextDefElt)
+ {
+ // Children pages
+ for (org.w3c.dom.Element childElt : getChildren(contextDefElt,
"page-def"))
+ {
+ importPageDef(root, childElt);
+ }
+ }
+
+ private PageNode importPageDef(PortalNode parentNode, org.w3c.dom.Element pageDefElt)
+ {
+ PageNode page = createStructuralNode(parentNode, PageNode.class, pageDefElt);
+
+ // Sub pages
+ for (org.w3c.dom.Element childElt : getChildren(pageDefElt, "page-def"))
+ {
+ importPageDef(page, childElt);
+ }
+
+ //
+ Element element = getUniqueChild(pageDefElt, "simple-layout", false);
+
+ //
+ if (element != null)
+ {
+ importLayout(page, element);
+ }
+
+ //
+ return page;
+ }
+
+ private void importLayout(PageNode page, Element element)
+ {
+ LayoutStructure pageStructure = layoutStore.createStructure(page.getId());
+
+ //
+ page.setLayoutStructureId(pageStructure.getId());
+
+ //
+ importLayout(page, pageStructure, element);
+ }
+
+ private void importLayout(PageNode page, LayoutStructure layout, Element element)
+ {
+ if ("simple-layout".equals(element.getNodeName()))
+ {
+ String orientation =
"horizontal".equals(element.getAttribute("orientation")) ?
Constants.HORIZONTAL_ORIENTATION : Constants.VERTICAL_ORIENTATION;
+
+ //
+ layout.setProperty(Constants.LAYOUT_ID, Constants.SIMPLE_LAYOUT);
+ layout.setProperty(Constants.SIMPLE_LAYOUT_ORIENTATION, orientation);
+
+ //
+ int index = 0;
+ for (org.w3c.dom.Element childElt : getChildren(element))
+ {
+ String childName = childElt.getNamespaceURI() == null ? childElt.getTagName()
: childElt.getLocalName();
+
+ //
+ LayoutElement structureElement;
+ if ("window-def".equals(childName))
+ {
+ WindowNode window = importWindowDef(page, childElt);
+
+ //
+ structureElement = layout.addObjectElement(window.getId());
+ }
+ else if ("simple-layout".equals(childName))
+ {
+ StructureElement nestedLayout = layout.addStructureElement();
+
+ //
+ importLayout(page, nestedLayout.getNestedStructure(), childElt);
+
+ //
+ structureElement = nestedLayout;
+ }
+ else
+ {
+ throw new NotYetImplemented();
+ }
+
+ //
+ structureElement.setProperty(Constants.SIMPLE_LAYOUT_INDEX, index++);
+ }
+ }
+ else
+ {
+ throw new NotYetImplemented();
+ }
+ }
+
+ private WindowNode importWindowDef(PortalNode parentNode, org.w3c.dom.Element
windowDefElt)
+ {
+ WindowNode windowNode = createStructuralNode(parentNode, WindowNode.class,
windowDefElt);
+
+ //
+ WindowNode.Content content = null;
+ org.w3c.dom.Element markupElt = getUniqueChild(windowDefElt, "markup",
false);
+ if (markupElt != null)
+ {
+ String markup = asString(markupElt);
+ content = new MarkupContent(markup);
+ }
+ else
+ {
+ org.w3c.dom.Element portletElt = getUniqueChild(windowDefElt,
"portlet", false);
+ if (portletElt != null)
+ {
+ String portletRef = portletElt.getAttribute("ref");
+ content = new PortletContent(portletRef);
+ }
+ }
+
+ //
+ windowNode.setContent(content);
+
+ //
+ return windowNode;
+ }
+
+ private <T extends PortalNode> T createStructuralNode(PortalNode parent,
Class<T> type, org.w3c.dom.Element nodeDefElt)
+ {
+ String nodeName = nodeDefElt.getAttribute("name");
+
+ //
+ T node = parent.addChild(nodeName, type);
+
+ //
+ org.w3c.dom.Element propertiesElt = XMLTools.getUniqueChild(nodeDefElt,
"properties", false);
+
+ //
+ if (propertiesElt != null)
+ {
+ for (org.w3c.dom.Element propertyElt : XMLTools.getChildren(propertiesElt,
"property"))
+ {
+ org.w3c.dom.Element nameElt = XMLTools.getUniqueChild(propertyElt,
"name", true);
+ String propertyName = XMLTools.asString(nameElt);
+
+ //
+ org.w3c.dom.Element valueElt = XMLTools.getUniqueChild(propertyElt,
"value", true);
+ String litteralPropertyValue = XMLTools.asString(valueElt);
+
+ Serializable propertyValue;
+ String propertyType = valueElt.getAttribute("type");
+ if (propertyType == null || "string".equals(propertyType))
+ {
+ propertyValue = litteralPropertyValue;
+ }
+ else if ("int".equals(propertyType))
+ {
+ propertyValue = Integer.parseInt(litteralPropertyValue);
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+
+ //
+ node.setProperty(propertyName, propertyValue);
+ }
+ }
+
+ //
+ return node;
+ }
+}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/NodeImporter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/NodeImporter.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/NodeImporter.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,303 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.NotYetImplemented;
-import static org.jboss.portal.common.xml.XMLTools.*;
-import org.jboss.portal.presentation.portal.content.markup.MarkupContent;
-import org.jboss.portal.presentation.portal.content.portlet.PortletContent;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
-import org.jboss.portal.presentation.portal.model.layout.StructureElement;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
-import org.jboss.portal.presentation.model.layout.Constants;
-import org.jboss.portal.presentation.model.layout.Orientation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class NodeImporter
-{
-
- /** . */
- private final static Schema schema;
-
- /** . */
- private static final URL schemaURL;
-
- static
- {
- try
- {
- schemaURL =
NodeImporter.class.getClassLoader().getResource("org/jboss/portal/presentation/portal/page_structure_1_0.xsd");
- SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- schema = factory.newSchema(schemaURL);
- }
- catch (SAXException e)
- {
- throw new Error("Could not load the page structure 1.0 schema", e);
- }
-
- }
-
- /** The root to import the children to. */
- private final PortalNode root;
-
- /** . */
- private final LayoutStore layoutStore;
-
- public NodeImporter(PortalNode root, LayoutStore layoutStore)
- {
- this.root = root;
- this.layoutStore = layoutStore;
- }
-
- /**
- * Imports the specified document.
- *
- * @param document the document
- * @throws IllegalArgumentException if the document is null
- */
- public void importDocument(Document document) throws IllegalArgumentException
- {
- if (document == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- importContextDef(document.getDocumentElement());
- }
-
- public void importDocument(InputStream in) throws IllegalArgumentException,
ParserConfigurationException, IOException, SAXException
- {
- if (in == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- InputStream schemaStream = schemaURL.openStream();
-
- try
- {
- DocumentBuilderFactory factory = XMLTools.getDocumentBuilderFactory();
- factory.setValidating(true);
- factory.setNamespaceAware(true);
-
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
"http://www.w3.org/2001/XMLSchema");
-
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
schemaStream);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(in);
- importDocument(doc);
- }
- finally
- {
- IOTools.safeClose(schemaStream);
- }
- }
-
- private void importContextDef(org.w3c.dom.Element contextDefElt)
- {
- // Children pages
- for (org.w3c.dom.Element childElt : getChildren(contextDefElt,
"page-def"))
- {
- importPageDef(root, childElt);
- }
- }
-
- private PageNode importPageDef(PortalNode parentNode, org.w3c.dom.Element pageDefElt)
- {
- PageNode page = createStructuralNode(parentNode, PageNode.class, pageDefElt);
-
- // Sub pages
- for (org.w3c.dom.Element childElt : getChildren(pageDefElt, "page-def"))
- {
- importPageDef(page, childElt);
- }
-
- //
- Element element = getUniqueChild(pageDefElt, "simple-layout", false);
-
- //
- if (element != null)
- {
- importLayout(page, element);
- }
-
- //
- return page;
- }
-
- private void importLayout(PageNode page, Element element)
- {
- LayoutStructure pageStructure = layoutStore.createStructure(page.getId());
-
- //
- page.setLayoutStructureId(pageStructure.getId());
-
- //
- importLayout(page, pageStructure, element);
- }
-
- private void importLayout(PageNode page, LayoutStructure layout, Element element)
- {
- if ("simple-layout".equals(element.getNodeName()))
- {
- String orientation =
"horizontal".equals(element.getAttribute("orientation")) ?
Constants.HORIZONTAL_ORIENTATION : Constants.VERTICAL_ORIENTATION;
-
- //
- layout.setProperty(Constants.LAYOUT_ID, Constants.SIMPLE_LAYOUT);
- layout.setProperty(Constants.SIMPLE_LAYOUT_ORIENTATION, orientation);
-
- //
- int index = 0;
- for (org.w3c.dom.Element childElt : getChildren(element))
- {
- String childName = childElt.getNamespaceURI() == null ? childElt.getTagName()
: childElt.getLocalName();
-
- //
- LayoutElement structureElement;
- if ("window-def".equals(childName))
- {
- WindowNode window = importWindowDef(page, childElt);
-
- //
- structureElement = layout.addObjectElement(window.getId());
- }
- else if ("simple-layout".equals(childName))
- {
- StructureElement nestedLayout = layout.addStructureElement();
-
- //
- importLayout(page, nestedLayout.getNestedStructure(), childElt);
-
- //
- structureElement = nestedLayout;
- }
- else
- {
- throw new NotYetImplemented();
- }
-
- //
- structureElement.setProperty(Constants.SIMPLE_LAYOUT_INDEX, index++);
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- private WindowNode importWindowDef(PortalNode parentNode, org.w3c.dom.Element
windowDefElt)
- {
- WindowNode windowNode = createStructuralNode(parentNode, WindowNode.class,
windowDefElt);
-
- //
- WindowNode.Content content = null;
- org.w3c.dom.Element markupElt = getUniqueChild(windowDefElt, "markup",
false);
- if (markupElt != null)
- {
- String markup = asString(markupElt);
- content = new MarkupContent(markup);
- }
- else
- {
- org.w3c.dom.Element portletElt = getUniqueChild(windowDefElt,
"portlet", false);
- if (portletElt != null)
- {
- String portletRef = portletElt.getAttribute("ref");
- content = new PortletContent(portletRef);
- }
- }
-
- //
- windowNode.setContent(content);
-
- //
- return windowNode;
- }
-
- private <T extends PortalNode> T createStructuralNode(PortalNode parent,
Class<T> type, org.w3c.dom.Element nodeDefElt)
- {
- String nodeName = nodeDefElt.getAttribute("name");
-
- //
- T node = parent.addChild(nodeName, type);
-
- //
- org.w3c.dom.Element propertiesElt = XMLTools.getUniqueChild(nodeDefElt,
"properties", false);
-
- //
- if (propertiesElt != null)
- {
- for (org.w3c.dom.Element propertyElt : XMLTools.getChildren(propertiesElt,
"property"))
- {
- org.w3c.dom.Element nameElt = XMLTools.getUniqueChild(propertyElt,
"name", true);
- String propertyName = XMLTools.asString(nameElt);
-
- //
- org.w3c.dom.Element valueElt = XMLTools.getUniqueChild(propertyElt,
"value", true);
- String litteralPropertyValue = XMLTools.asString(valueElt);
-
- Serializable propertyValue;
- String propertyType = valueElt.getAttribute("type");
- if (propertyType == null || "string".equals(propertyType))
- {
- propertyValue = litteralPropertyValue;
- }
- else if ("int".equals(propertyType))
- {
- propertyValue = Integer.parseInt(litteralPropertyValue);
- }
- else
- {
- throw new AssertionError();
- }
-
- //
- node.setProperty(propertyName, propertyValue);
- }
- }
-
- //
- return node;
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PageNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PageNode.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PageNode.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,57 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIPage;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PageNode extends PortalNode
-{
-
- /** . */
- private String layoutStructureId;
-
- public PageNode(String name, PortalNodeManager structuralStateContext)
- {
- super(name, structuralStateContext);
- }
-
- public String getLayoutStructureId()
- {
- return layoutStructureId;
- }
-
- public void setLayoutStructureId(String layoutStructureId)
- {
- this.layoutStructureId = layoutStructureId;
- }
-
- public Class<? extends UIObject> getType()
- {
- return UIPage.class;
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNode.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNode.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,245 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public abstract class PortalNode
-{
-
- /** . */
- private PortalNode parent;
-
- /** . */
- final Map<String, PortalNode> children = new HashMap<String,
PortalNode>();
-
- /** . */
- private final PortalNodeManager structuralStateContext;
-
- /** . */
- final String id;
-
- /** . */
- private boolean valid;
-
- /** . */
- final String name;
-
- /** . */
- final Map<String, Serializable> properties;
-
- /** . */
- final Map<String, Serializable> immutableProperties;
-
- protected PortalNode(String name, PortalNodeManager structuralStateContext)
- {
- this.name = name;
- this.id = structuralStateContext.nextId();
- this.structuralStateContext = structuralStateContext;
- this.properties = new HashMap<String, Serializable>();
- this.valid = true;
- this.immutableProperties = Collections.unmodifiableMap(properties);
- }
-
- public abstract Class<? extends UIObject> getType();
-
- public boolean isValid()
- {
- return valid;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public PortalNode getParent()
- {
- return parent;
- }
-
- public Map<String, Serializable> getProperties()
- {
- return immutableProperties;
- }
-
- public Serializable getProperty(String propertyName)
- {
- if (propertyName == null)
- {
- throw new IllegalArgumentException("No null property name");
- }
-
- //
- synchronized (this)
- {
- return properties.get(propertyName);
- }
- }
-
- public void setProperty(String propertyName, Serializable propertyValue)
- {
- if (propertyName == null)
- {
- throw new IllegalArgumentException("No null property name");
- }
-
- //
- synchronized (this)
- {
- if (propertyValue != null)
- {
- properties.put(propertyName, propertyValue);
- }
- else
- {
- properties.remove(propertyName);
- }
- }
- }
-
- public Collection<? extends PortalNode> getChildren()
- {
- return Collections.unmodifiableCollection(children.values());
- }
-
- public <T extends PortalNode> T addChild(String name, Class<T> type)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
- if (type == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- T child;
- try
- {
- Constructor<T> ctor = type.getConstructor(String.class,
PortalNodeManager.class);
- child = ctor.newInstance(name, structuralStateContext);
- }
- catch (InstantiationException e)
- {
- throw new AssertionError(e);
- }
- catch (IllegalAccessException e)
- {
- throw new AssertionError(e);
- }
- catch (NoSuchMethodException e)
- {
- throw new AssertionError(e);
- }
- catch (InvocationTargetException e)
- {
- throw new AssertionError(e);
- }
-
- //
- synchronized (this)
- {
- if (children.containsKey(name))
- {
- throw new IllegalArgumentException("Child already exist");
- }
- children.put(name, child);
- child.parent = this;
- }
-
- //
- structuralStateContext.nodes.put(child.id, child);
-
- //
- return child;
- }
-
- public void destroyChild(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- PortalNode child;
- synchronized (this)
- {
- if (!children.containsKey(name))
- {
- throw new IllegalArgumentException("No such child " + name);
- }
-
- child = children.get(name);
-
- //
- for (String blah : new ArrayList<String>(child.children.keySet()))
- {
- child.destroyChild(blah);
- }
-
- //
- children.remove(name);
- structuralStateContext.nodes.remove(child.id);
-
- //
- child.valid = false;
- child.parent = null;
- }
- }
-
- public PortalNode getChild(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- synchronized (this)
- {
- return children.get(name);
- }
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeAdapter.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,284 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.portal.model.structural.StructuralAdapter;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
-import org.jboss.portal.presentation.portal.model.layout.StructureElement;
-import org.jboss.portal.presentation.portal.model.layout.NestedStructure;
-import org.jboss.portal.presentation.portal.model.layout.ObjectStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
-import org.jboss.portal.presentation.portal.model.layout.LayoutObject;
-import org.jboss.portal.presentation.portal.model.layout.ObjectElement;
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIPane;
-import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-import org.jboss.portal.common.NotYetImplemented;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PortalNodeAdapter implements StructuralAdapter<Object>
-{
-
- /** . */
- private PortalNodeManager nodeManager;
-
- /** . */
- private LayoutStore layoutStore;
-
- public PortalNodeAdapter(PortalNodeManager nodeManager, LayoutStore layoutStore)
- {
- this.nodeManager = nodeManager;
- this.layoutStore = layoutStore;
- }
-
- public String getRootId()
- {
- return "node." + nodeManager.getRoot().getId();
- }
-
- public Object getNode(String id)
- {
- if (id.startsWith("node."))
- {
- return nodeManager.getNode(id.substring(5));
- }
- else if (id.startsWith("structure."))
- {
- return layoutStore.getObject(id.substring(10));
- }
- else
- {
- throw new IllegalArgumentException("Unrecognized id " + id);
- }
- }
-
- public Object getParent(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getParent();
- }
- else if (o instanceof LayoutElement)
- {
- LayoutStructure layout = ((LayoutElement)o).getStructure();
-
- //
- if (layout instanceof NestedStructure)
- {
- return ((NestedStructure)layout).getStructureElement();
- }
- else
- {
- ObjectStructure objectStructure = (ObjectStructure)layout;
- String objectId = objectStructure.getObjectRef();
- return nodeManager.getNode(objectId);
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Collection<?> getChilren(Object o)
- {
- if (o instanceof PortalNode)
- {
- if (o instanceof PageNode)
- {
- String layoutStructureId = ((PageNode)o).getLayoutStructureId();
-
- //
- LayoutStructure layoutStructure =
(LayoutStructure)layoutStore.getObject(layoutStructureId);
-
- //
- return layoutStructure.getElements();
- }
- else
- {
- return ((PortalNode)o).getChildren();
- }
- }
- else if (o instanceof LayoutElement)
- {
- if (o instanceof StructureElement)
- {
- return ((StructureElement)o).getNestedStructure().getElements();
- }
- else
- {
- return Collections.emptyList();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public String getId(Object o)
- {
- if (o instanceof PortalNode)
- {
- return "node." + ((PortalNode)o).getId();
- }
- else if (o instanceof LayoutObject)
- {
- return "structure." + ((LayoutObject)o).getId();
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Class<? extends UIObject> getType(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getType();
- }
- else if (o instanceof LayoutElement)
- {
- if (o instanceof StructureElement)
- {
- return UIPane.class;
- }
- else if (o instanceof ObjectElement)
- {
- return UIWindow.class;
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public String getName(Object o)
- {
- if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getName();
- }
- else if (o instanceof LayoutObject)
- {
- // no natural name, for now use id
- return ((LayoutObject)o).getId();
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public Map<String, Serializable> getProperties(Object o)
- {
- if (o instanceof PageNode)
- {
- PageNode page = (PageNode)o;
-
- //
- String layoutStructureId = ((PageNode)o).getLayoutStructureId();
-
- //
- LayoutStructure layoutStructure =
(LayoutStructure)layoutStore.getObject(layoutStructureId);
-
- //
- Map<String, Serializable> properties = new HashMap<String,
Serializable>(page.getProperties());
-
- //
- properties.putAll(layoutStructure.getState().getProperties());
-
- //
- return properties;
- }
- else if (o instanceof PortalNode)
- {
- return ((PortalNode)o).getProperties();
- }
- else if (o instanceof LayoutObject)
- {
- if (o instanceof ObjectElement)
- {
- ObjectElement element = (ObjectElement)o;
-
- //
- String windowId = element.getObjectRef();
-
- //
- WindowNode window = (WindowNode)nodeManager.getNode(windowId);
-
- //
- Map<String, Serializable> properties = new HashMap<String,
Serializable>(window.getProperties());
-
- //
- properties.putAll(element.getState().getProperties());
-
- //
- return properties;
- }
- else
- {
- return ((LayoutObject)o).getState().getProperties();
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- public StructuralState getState(Object o)
- {
- Class<? extends UIObject> type = getType(o);
- String name = getName(o);
- Map<String, Serializable> properties = getProperties(o);
-
- //
- return new PortalNodeState(type, name, properties);
- }
-
- public void lock(Object o)
- {
- }
-
- public void unlock(Object o)
- {
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeManager.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeManager.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeManager.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PortalNodeManager
-{
-
- /** . */
- private final AtomicLong sequence = new AtomicLong();
-
- /** . */
- final ConcurrentMap<String, PortalNode> nodes = new ConcurrentHashMap<String,
PortalNode>();
-
- /** . */
- private final ContextNode root = new ContextNode("", this);
-
- public PortalNodeManager()
- {
- nodes.put(root.getId(), root);
- }
-
- String nextId()
- {
- return Long.toString(sequence.getAndIncrement());
- }
-
- public PortalNode getNode(String nodeId)
- {
- if (nodeId == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- return nodes.get(nodeId);
- }
-
- public ContextNode getRoot()
- {
- return root;
- }
-
- public void destroy(String objectId)
- {
- if (objectId == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- PortalNode node = nodes.get(objectId);
-
- //
- PortalNode parent = node.getParent();
-
- //
- if (parent == null)
- {
- throw new IllegalArgumentException("Cannot destroy root");
- }
-
- //
- parent.destroyChild(node.getName());
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/PortalNodeState.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,99 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.state.structural.StructuralState;
-
-import java.util.Map;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class PortalNodeState implements StructuralState
-{
-
- /** . */
- private final Class<? extends UIObject> type;
-
- /** . */
- private final String name;
-
- /** . */
- private final Map<String, Serializable> properties;
-
- public PortalNodeState(
- Class<? extends UIObject> type,
- String name,
- Map<String, Serializable> properties)
- {
- this.type = type;
- this.name = name;
- this.properties = properties;
- }
-
- public Class<? extends UIObject> getType()
- {
- return type;
- }
-
- public String getName()
- {
- return name;
- }
-
- public Map<String, Serializable> getProperties()
- {
- return properties;
- }
-
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
- if (obj instanceof PortalNodeState)
- {
- PortalNodeState that = (PortalNodeState)obj;
-
- //
- if (!that.type.equals(this.type))
- {
- return false;
- }
-
- //
- if (!that.name.equals(this.name))
- {
- return false;
- }
-
- //
- return that.properties.equals(this.properties);
- }
- return false;
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,69 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model;
-
-import org.jboss.portal.presentation.model.ui.UIObject;
-import org.jboss.portal.presentation.model.ui.UIWindow;
-import org.jboss.portal.presentation.model.content.WindowContent;
-import org.jboss.portal.presentation.client.PresentationClient;
-import org.jboss.portal.presentation.server.PresentationServerException;
-import org.jboss.portal.portlet.PortletInvoker;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class WindowNode extends PortalNode
-{
-
- /** . */
- private Content content;
-
- public WindowNode(String name, PortalNodeManager structuralStateContext)
- {
- super(name, structuralStateContext);
- }
-
- public Class<? extends UIObject> getType()
- {
- return UIWindow.class;
- }
-
- public void setContent(Content content)
- {
- this.content = content;
- }
-
- public Content getContent()
- {
- return content;
- }
-
- public static abstract class Content
- {
- public abstract WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException;
-
- public abstract String getType();
-
- }
-}
Deleted:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/NodeImporter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/NodeImporter.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/object/NodeImporter.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -1,302 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This 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 software 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 software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.portal.model.object;
-
-import org.jboss.portal.common.io.IOTools;
-import org.jboss.portal.common.xml.XMLTools;
-import org.jboss.portal.common.NotYetImplemented;
-import static org.jboss.portal.common.xml.XMLTools.*;
-import org.jboss.portal.presentation.portal.content.markup.MarkupContent;
-import org.jboss.portal.presentation.portal.content.portlet.PortletContent;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
-import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
-import org.jboss.portal.presentation.portal.model.layout.StructureElement;
-import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
-import org.jboss.portal.presentation.model.layout.Constants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.net.URL;
-
-/**
- * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
- * @version $Revision: 630 $
- */
-public class NodeImporter
-{
-
- /** . */
- private final static Schema schema;
-
- /** . */
- private static final URL schemaURL;
-
- static
- {
- try
- {
- schemaURL =
NodeImporter.class.getClassLoader().getResource("org/jboss/portal/presentation/portal/page_structure_1_0.xsd");
- SchemaFactory factory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- schema = factory.newSchema(schemaURL);
- }
- catch (SAXException e)
- {
- throw new Error("Could not load the page structure 1.0 schema", e);
- }
-
- }
-
- /** The root to import the children to. */
- private final PortalNode root;
-
- /** . */
- private final LayoutStore layoutStore;
-
- public NodeImporter(PortalNode root, LayoutStore layoutStore)
- {
- this.root = root;
- this.layoutStore = layoutStore;
- }
-
- /**
- * Imports the specified document.
- *
- * @param document the document
- * @throws IllegalArgumentException if the document is null
- */
- public void importDocument(Document document) throws IllegalArgumentException
- {
- if (document == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- importContextDef(document.getDocumentElement());
- }
-
- public void importDocument(InputStream in) throws IllegalArgumentException,
ParserConfigurationException, IOException, SAXException
- {
- if (in == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- InputStream schemaStream = schemaURL.openStream();
-
- try
- {
- DocumentBuilderFactory factory = XMLTools.getDocumentBuilderFactory();
- factory.setValidating(true);
- factory.setNamespaceAware(true);
-
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
"http://www.w3.org/2001/XMLSchema");
-
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schema...;,
schemaStream);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(in);
- importDocument(doc);
- }
- finally
- {
- IOTools.safeClose(schemaStream);
- }
- }
-
- private void importContextDef(org.w3c.dom.Element contextDefElt)
- {
- // Children pages
- for (org.w3c.dom.Element childElt : getChildren(contextDefElt,
"page-def"))
- {
- importPageDef(root, childElt);
- }
- }
-
- private PageNode importPageDef(PortalNode parentNode, org.w3c.dom.Element pageDefElt)
- {
- PageNode page = createStructuralNode(parentNode, PageNode.class, pageDefElt);
-
- // Sub pages
- for (org.w3c.dom.Element childElt : getChildren(pageDefElt, "page-def"))
- {
- importPageDef(page, childElt);
- }
-
- //
- Element element = getUniqueChild(pageDefElt, "simple-layout", false);
-
- //
- if (element != null)
- {
- importLayout(page, element);
- }
-
- //
- return page;
- }
-
- private void importLayout(PageNode page, Element element)
- {
- LayoutStructure pageStructure = layoutStore.createStructure(page.getId());
-
- //
- page.setLayoutStructureId(pageStructure.getId());
-
- //
- importLayout(page, pageStructure, element);
- }
-
- private void importLayout(PageNode page, LayoutStructure layout, Element element)
- {
- if ("simple-layout".equals(element.getNodeName()))
- {
- String orientation =
"horizontal".equals(element.getAttribute("orientation")) ?
Constants.HORIZONTAL_ORIENTATION : Constants.VERTICAL_ORIENTATION;
-
- //
- layout.setProperty(Constants.LAYOUT_ID, Constants.SIMPLE_LAYOUT);
- layout.setProperty(Constants.SIMPLE_LAYOUT_ORIENTATION, orientation);
-
- //
- int index = 0;
- for (org.w3c.dom.Element childElt : getChildren(element))
- {
- String childName = childElt.getNamespaceURI() == null ? childElt.getTagName()
: childElt.getLocalName();
-
- //
- LayoutElement structureElement;
- if ("window-def".equals(childName))
- {
- WindowNode window = importWindowDef(page, childElt);
-
- //
- structureElement = layout.addObjectElement(window.getId());
- }
- else if ("simple-layout".equals(childName))
- {
- StructureElement nestedLayout = layout.addStructureElement();
-
- //
- importLayout(page, nestedLayout.getNestedStructure(), childElt);
-
- //
- structureElement = nestedLayout;
- }
- else
- {
- throw new NotYetImplemented();
- }
-
- //
- structureElement.setProperty(Constants.SIMPLE_LAYOUT_INDEX, index++);
- }
- }
- else
- {
- throw new NotYetImplemented();
- }
- }
-
- private WindowNode importWindowDef(PortalNode parentNode, org.w3c.dom.Element
windowDefElt)
- {
- WindowNode windowNode = createStructuralNode(parentNode, WindowNode.class,
windowDefElt);
-
- //
- WindowNode.Content content = null;
- org.w3c.dom.Element markupElt = getUniqueChild(windowDefElt, "markup",
false);
- if (markupElt != null)
- {
- String markup = asString(markupElt);
- content = new MarkupContent(markup);
- }
- else
- {
- org.w3c.dom.Element portletElt = getUniqueChild(windowDefElt,
"portlet", false);
- if (portletElt != null)
- {
- String portletRef = portletElt.getAttribute("ref");
- content = new PortletContent(portletRef);
- }
- }
-
- //
- windowNode.setContent(content);
-
- //
- return windowNode;
- }
-
- private <T extends PortalNode> T createStructuralNode(PortalNode parent,
Class<T> type, org.w3c.dom.Element nodeDefElt)
- {
- String nodeName = nodeDefElt.getAttribute("name");
-
- //
- T node = parent.addChild(nodeName, type);
-
- //
- org.w3c.dom.Element propertiesElt = XMLTools.getUniqueChild(nodeDefElt,
"properties", false);
-
- //
- if (propertiesElt != null)
- {
- for (org.w3c.dom.Element propertyElt : XMLTools.getChildren(propertiesElt,
"property"))
- {
- org.w3c.dom.Element nameElt = XMLTools.getUniqueChild(propertyElt,
"name", true);
- String propertyName = XMLTools.asString(nameElt);
-
- //
- org.w3c.dom.Element valueElt = XMLTools.getUniqueChild(propertyElt,
"value", true);
- String litteralPropertyValue = XMLTools.asString(valueElt);
-
- Serializable propertyValue;
- String propertyType = valueElt.getAttribute("type");
- if (propertyType == null || "string".equals(propertyType))
- {
- propertyValue = litteralPropertyValue;
- }
- else if ("int".equals(propertyType))
- {
- propertyValue = Integer.parseInt(litteralPropertyValue);
- }
- else
- {
- throw new AssertionError();
- }
-
- //
- node.setProperty(propertyName, propertyValue);
- }
- }
-
- //
- return node;
- }
-}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java 2008-06-07
21:20:31 UTC (rev 10941)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/servlet/StructuralStateContextImporter.java 2008-06-07
21:22:25 UTC (rev 10942)
@@ -23,7 +23,7 @@
package org.jboss.portal.presentation.portal.servlet;
import org.jboss.portal.presentation.portal.model.object.PortalNodeManager;
-import org.jboss.portal.presentation.portal.model.object.NodeImporter;
+import org.jboss.portal.presentation.portal.model.ModelImporter;
import org.jboss.portal.presentation.portal.model.object.ContextNode;
import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
import org.jboss.portal.common.io.IOTools;
@@ -85,7 +85,7 @@
try
{
ContextNode root = portalNodeManager.getRoot();
- new NodeImporter(root, layoutStore).importDocument(in);
+ new ModelImporter(root, layoutStore).importDocument(in);
}
finally
{