JBoss Portal SVN: r8916 - branches/UIServer/uiserver/src/main/org/jboss/portal/presentation.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 17:07:31 -0500 (Tue, 13 Nov 2007)
New Revision: 8916
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
Log:
minor update
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 22:06:10 UTC (rev 8915)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 22:07:31 UTC (rev 8916)
@@ -47,6 +47,6 @@
/**
* Returns the root UI context provided by the portal.
*/
- UIContext getUIContext(ModelLoader loader);
+ UIContext getUIContext();
}
16 years, 11 months
JBoss Portal SVN: r8915 - in branches/UIServer/uiserver/src/main/org/jboss/portal/presentation: model2/state and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 17:06:10 -0500 (Tue, 13 Nov 2007)
New Revision: 8915
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ModelLoader.java
Removed:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
Log:
moved model loader in a more convenient place
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 21:53:52 UTC (rev 8914)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 22:06:10 UTC (rev 8915)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.action.server.ServerAction;
import org.jboss.portal.presentation.model2.UIContext;
-import org.jboss.portal.presentation.server.ModelLoader;
+import org.jboss.portal.presentation.model2.state.ModelLoader;
/**
* The contract that defines the services that the client provides to the server during a server invocation.
Copied: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ModelLoader.java (from rev 8914, branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java)
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ModelLoader.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ModelLoader.java 2007-11-13 22:06:10 UTC (rev 8915)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2.state;
+
+import org.jboss.portal.presentation.model2.state.ObjectState;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ModelLoader
+{
+
+ /**
+ * Load the state of a specified object.
+ *
+ * @param objectId the object id
+ * @return the state of the object or null if such state does not exist
+ * @throws IllegalArgumentException if the object id argument is null
+ */
+ ObjectState loadState(String objectId) throws IllegalArgumentException;
+
+}
Deleted: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 21:53:52 UTC (rev 8914)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 22:06:10 UTC (rev 8915)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.server;
-
-import org.jboss.portal.presentation.model2.state.ObjectState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ModelLoader
-{
-
- /**
- * Load the state of a specified object.
- *
- * @param objectId the object id
- * @return the state of the object or null if such state does not exist
- * @throws IllegalArgumentException if the object id argument is null
- */
- ObjectState loadState(String objectId) throws IllegalArgumentException;
-
-}
16 years, 11 months
JBoss Portal SVN: r8914 - in branches/UIServer/uiserver/src/main/org/jboss/portal/presentation: model2/state and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 16:53:52 -0500 (Tue, 13 Nov 2007)
New Revision: 8914
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ObjectState.java
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
Log:
update of model loader.
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ObjectState.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ObjectState.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/state/ObjectState.java 2007-11-13 21:53:52 UTC (rev 8914)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2.state;
+
+import java.util.Map;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectState
+{
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Map<String, String> properties;
+
+ /** . */
+ private final String parentId;
+
+ /** . */
+ private final List<String> childrenIds;
+
+ public ObjectState(String name, Map<String, String> properties, String parentId, List<String> childrenIds)
+ {
+ this.name = name;
+ this.properties = properties;
+ this.parentId = parentId;
+ this.childrenIds = childrenIds;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public String getParentId()
+ {
+ return parentId;
+ }
+
+ public List<String> getChildrenIds()
+ {
+ return childrenIds;
+ }
+}
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 21:47:48 UTC (rev 8913)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 21:53:52 UTC (rev 8914)
@@ -22,8 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.server;
-import java.util.Map;
-import java.util.List;
+import org.jboss.portal.presentation.model2.state.ObjectState;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -32,10 +31,13 @@
public interface ModelLoader
{
- Map<String, String> loadState(String objectId);
+ /**
+ * Load the state of a specified object.
+ *
+ * @param objectId the object id
+ * @return the state of the object or null if such state does not exist
+ * @throws IllegalArgumentException if the object id argument is null
+ */
+ ObjectState loadState(String objectId) throws IllegalArgumentException;
- List<String> loadChildren(String objectId);
-
- String loadParent(String objectId);
-
}
16 years, 11 months
JBoss Portal SVN: r8913 - branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 16:47:48 -0500 (Tue, 13 Nov 2007)
New Revision: 8913
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
Log:
update of model loader.
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 19:30:14 UTC (rev 8912)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 21:47:48 UTC (rev 8913)
@@ -22,7 +22,8 @@
******************************************************************************/
package org.jboss.portal.presentation.server;
-import org.jboss.portal.presentation.model2.UIObject;
+import java.util.Map;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -31,8 +32,10 @@
public interface ModelLoader
{
- void loadState(UIObject object);
+ Map<String, String> loadState(String objectId);
- void loadChildren(UIObject object);
+ List<String> loadChildren(String objectId);
+ String loadParent(String objectId);
+
}
16 years, 11 months
JBoss Portal SVN: r8912 - in branches/UIServer/uiserver/src/main/org/jboss/portal/presentation: server and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 14:30:14 -0500 (Tue, 13 Nov 2007)
New Revision: 8912
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
Log:
udpates
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 18:29:00 UTC (rev 8911)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 19:30:14 UTC (rev 8912)
@@ -24,6 +24,7 @@
import org.jboss.portal.presentation.action.server.ServerAction;
import org.jboss.portal.presentation.model2.UIContext;
+import org.jboss.portal.presentation.server.ModelLoader;
/**
* The contract that defines the services that the client provides to the server during a server invocation.
@@ -46,6 +47,6 @@
/**
* Returns the root UI context provided by the portal.
*/
- UIContext getUIContext();
+ UIContext getUIContext(ModelLoader loader);
}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/server/ModelLoader.java 2007-11-13 19:30:14 UTC (rev 8912)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.server;
+
+import org.jboss.portal.presentation.model2.UIObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ModelLoader
+{
+
+ void loadState(UIObject object);
+
+ void loadChildren(UIObject object);
+
+}
16 years, 11 months
JBoss Portal SVN: r8911 - in branches/UIServer/uiserver/src/main/org/jboss/portal/presentation: model2 and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-11-13 13:29:00 -0500 (Tue, 13 Nov 2007)
New Revision: 8911
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContainer.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContext.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIObject.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPage.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPortal.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIWindow.java
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
Log:
udpates
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 17:51:48 UTC (rev 8910)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/RequestContext.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation;
import org.jboss.portal.presentation.action.server.ServerAction;
+import org.jboss.portal.presentation.model2.UIContext;
/**
* The contract that defines the services that the client provides to the server during a server invocation.
@@ -42,4 +43,9 @@
*/
String render(ServerAction action) throws IllegalArgumentException;
+ /**
+ * Returns the root UI context provided by the portal.
+ */
+ UIContext getUIContext();
+
}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContainer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContainer.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContainer.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIContainer extends UIObject
+{
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContext.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContext.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIContext.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIContext extends UIObject
+{
+
+ UIObject getObject(String id);
+
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIObject.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIObject.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIObject.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIObject
+{
+
+ String getId();
+
+ /**
+ * Create a child with a specified type.
+ *
+ * @param name the child name
+ * @param type the child type
+ * @return the newly created child
+ * @throws IllegalArgumentException if the name is null, already exists or this kind of object does not accept children of the specified type
+ */
+ <T extends UIObject> T createChild(String name, Class<T> type) throws IllegalArgumentException;
+
+ void destroyChild(String name);
+
+ List<UIObject> getChildren();
+
+ <T extends UIObject> List<T> getChildren(Class<T> type);
+
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPage.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPage.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPage.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIPage extends UIObject
+{
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPortal.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPortal.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIPortal.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIPortal extends UIObject
+{
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIWindow.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIWindow.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/model2/UIWindow.java 2007-11-13 18:29:00 UTC (rev 8911)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.model2;
+
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UIWindow extends UIObject
+{
+
+ String getTitle();
+
+ void setTitle(String title);
+
+ WindowState getWindowState();
+
+ void setWindowState(WindowState windowState);
+
+ Mode getMode();
+
+ void setMode(Mode mode);
+
+}
16 years, 11 months
JBoss Portal SVN: r8910 - in branches/UIServer/uiserver/src/main/org/jboss/portal/presentation: service and 1 other directory.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-11-13 12:51:48 -0500 (Tue, 13 Nov 2007)
New Revision: 8910
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPoint.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPointImpl.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/GWTClientFilter.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/PortalEntryPoint.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/UIServer.java
Log:
refactoring
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPoint.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPoint.java 2007-11-13 17:51:48 UTC (rev 8910)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.service;
+
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.Server;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+
+/**
+ * A Utility Service used by different Portal Server Entry Points
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface EntryPoint
+{
+ /**
+ *
+ * @return
+ */
+ public Server getPortalServer();
+
+ /**
+ *
+ * @return
+ */
+ public RequestControllerFactory getControllerFactory();
+
+ /**
+ *
+ * @return
+ */
+ public InterceptorStackFactory getInterceptorStackFactory();
+
+ /**
+ *
+ * @param contentType
+ * @return
+ */
+ public String retrieveMediaType(String contentType);
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPointImpl.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPointImpl.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/EntryPointImpl.java 2007-11-13 17:51:48 UTC (rev 8910)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.service;
+
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.Server;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+/**
+ * Implementation of an Entry Point Utility
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class EntryPointImpl extends AbstractJBossService implements EntryPoint
+{
+ /** The interceptor stack. */
+ private InterceptorStackFactory interceptorStackFactory = null;
+
+ /** The controller for this servlet. */
+ private RequestControllerFactory controllerFactory = null;
+
+ /**
+ *
+ */
+ private Server portalServer = null;
+
+
+ /**
+ *
+ * @return
+ */
+ public RequestControllerFactory getControllerFactory()
+ {
+ return controllerFactory;
+ }
+
+
+ /**
+ *
+ * @param controllerFactory
+ */
+ public void setControllerFactory(RequestControllerFactory controllerFactory)
+ {
+ this.controllerFactory = controllerFactory;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public InterceptorStackFactory getInterceptorStackFactory()
+ {
+ return interceptorStackFactory;
+ }
+
+
+ /**
+ *
+ * @param interceptorStackFactory
+ */
+ public void setInterceptorStackFactory(
+ InterceptorStackFactory interceptorStackFactory)
+ {
+ this.interceptorStackFactory = interceptorStackFactory;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Server getPortalServer()
+ {
+ return portalServer;
+ }
+
+
+ /**
+ *
+ * @param portalServer
+ */
+ public void setPortalServer(Server portalServer)
+ {
+ this.portalServer = portalServer;
+ }
+
+
+ /**
+ *
+ * @param contentType
+ * @return
+ */
+ public String retrieveMediaType(String contentType)
+ {
+ String mediaType = contentType;
+
+ //
+ if (mediaType != null)
+ {
+ // Remove any parameters
+ int index = mediaType.indexOf(';');
+ if (index != -1)
+ {
+ mediaType = contentType.substring(0, index);
+ }
+
+ // Trim
+ mediaType = mediaType.trim();
+
+ // Media type matching is case insensitive, so we convert to lower case
+ mediaType = mediaType.toLowerCase();
+ }
+ return mediaType;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/GWTClientFilter.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/GWTClientFilter.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/GWTClientFilter.java 2007-11-13 17:51:48 UTC (rev 8910)
@@ -0,0 +1,154 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This filter is activated or deactivated depending on whether the Portal needs to runs in Ajax mode or Classic Html mode
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class GWTClientFilter implements Filter
+{
+ /**
+ *
+ */
+ public void init(FilterConfig arg0) throws ServletException
+ {
+ }
+
+ /**
+ *
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ *
+ */
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
+ {
+ HttpServletRequest request = (HttpServletRequest)servletRequest;
+ HttpServletResponse response = (HttpServletResponse)servletResponse;
+ String contextPath = request.getContextPath();
+
+ //Extract the resource that is being accessed
+ String resource = request.getRequestURI().replaceFirst(contextPath, "");
+ while(resource.startsWith("/"))
+ {
+ if(resource.length() > 1)
+ {
+ resource = resource.substring(1);
+ }
+ else
+ {
+ resource = "";
+ }
+ }
+
+ if(resource == null || resource.trim().length() == 0)
+ {
+ response.sendRedirect("index.html");
+ return;
+ }
+
+ //Now make sure the resource requested is a GWT resource
+ if( resource.equals("index.html") ||
+ resource.equals("portal.css") ||
+ resource.equals("mygwt-all.css") ||
+ resource.equals("mygwt-all-gray.css") ||
+ resource.equals("gwt.js") ||
+ resource.equals("prototype.js") ||
+ resource.contains(".cache.") ||
+ resource.contains(".nocache.") ||
+ resource.contains(".gwt.rpc") ||
+ resource.contains("images/default") ||
+ resource.contains("images/gray")
+ )
+ {
+ byte[] gwtResource = this.readContent(resource);
+ response.getOutputStream().write(gwtResource);
+ response.getOutputStream().flush();
+ return;
+ }
+ }
+
+ /**
+ *
+ * @param path
+ * @return
+ */
+ private byte[] readContent(String path)
+ {
+ byte[] content = null;
+
+ InputStream is = null;
+ ByteArrayOutputStream bos = null;
+ try
+ {
+ bos = new ByteArrayOutputStream();
+ is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+ int bytesRead = 0;
+ byte[] data = new byte[1024];
+ while((bytesRead=is.read(data)) != -1)
+ {
+ byte[] cour = new byte[bytesRead];
+ System.arraycopy(data, 0, cour, 0, bytesRead);
+ bos.write(cour);
+ bos.flush();
+ }
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ if(is != null)
+ {
+ try{is.close();}catch(Exception e){}
+ }
+ if(bos != null)
+ {
+ content = bos.toByteArray();
+ try{bos.close();}catch(Exception e){}
+ }
+ }
+
+ return content;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/PortalEntryPoint.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/PortalEntryPoint.java 2007-11-13 17:51:48 UTC (rev 8910)
@@ -0,0 +1,633 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.service;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.UnavailableException;
+
+import org.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.util.Exceptions;
+import org.jboss.portal.server.PortalConstants;
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.RequestControllerDispatcher;
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.Server;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.ServerRequest;
+import org.jboss.portal.server.ServerResponse;
+import org.jboss.portal.server.impl.ServerInvocationContextImpl;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.presentation.layout.LayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGrid;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridLayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.RegionConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.RegionLayoutManager;
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Page;
+import org.jboss.portal.presentation.model.Window;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+
+/**
+ * The Portal Server Entry Point for classic html mode
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PortalEntryPoint extends HttpServlet
+{
+ /**
+ *
+ */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private static final int GET_METHOD = 0;
+
+ /** . */
+ private static final int POST_METHOD = 1;
+
+ /** Describes a default servlet mapping. */
+ private static final int DEFAULT_SERVLET_MAPPING = 0;
+
+ /** Describes a root path mapping. */
+ private static final int ROOT_PATH_MAPPING = 1;
+
+ /** Describes a path mapping. */
+ private static final int PATH_MAPPING = 2;
+
+ /** Are we or not the default servlet ? */
+ private boolean asDefaultServlet = false;
+
+ /**
+ *
+ */
+ private EntryPoint entryPoint = null;
+
+ /** Configure the as default servlet. */
+ public void init() throws ServletException
+ {
+ asDefaultServlet = getAsDefaultServletInitValue();
+ try
+ {
+ MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+ this.entryPoint = (EntryPoint) MBeanProxy.get(EntryPoint.class, new ObjectName(
+ this.getInitParameter("entryPointServiceName")),
+ mbeanServer);
+ }
+ catch (Exception e)
+ {
+ this.entryPoint = null;
+ String msg = "Portal Entry Point could not be created";
+ log.error(msg, e);
+ throw new UnavailableException(msg);
+ }
+ }
+
+ /**
+ *
+ */
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ //
+ String servletPath = req.getServletPath();
+ String requestURI = req.getRequestURI();
+ String contextPath = req.getContextPath();
+
+ String resource = req.getRequestURI().replaceFirst(contextPath, "");
+ while(resource.startsWith("/"))
+ {
+ if(resource.length() > 1)
+ {
+ resource = resource.substring(1);
+ }
+ else
+ {
+ resource = "";
+ }
+ }
+
+ if(resource == null || resource.trim().length() == 0)
+ {
+ resp.sendRedirect("index.html");
+ return;
+ }
+
+ int method;
+ if ("GET".equals(req.getMethod()))
+ {
+ method = GET_METHOD;
+ }
+ else if ("POST".equals(req.getMethod()))
+ {
+ method = POST_METHOD;
+ }
+ else
+ {
+ throw new ServletException();
+ }
+
+ // Compute the media type in the content type
+ String mediaType = this.entryPoint.retrieveMediaType(req.getContentType());
+
+ // Only affect the charset encoding if the servlet container will decode the request
+ if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
+ {
+ // Now we must ensure that we have either an equals or a trailing space after the media-type
+ String characterEncoding = req.getCharacterEncoding();
+ if (characterEncoding == null)
+ {
+ // Set out charset for the portal request
+ req.setCharacterEncoding(PortalConstants.UTF_8.name());
+ }
+ else
+ {
+ Charset charset = Charset.forName(characterEncoding);
+ if (!PortalConstants.UTF_8.equals(charset))
+ {
+ throw new ServletException("Unaccepted charset " + characterEncoding);
+ }
+ }
+ }
+
+ // Determine the mapping we have
+ int mapping = DEFAULT_SERVLET_MAPPING;
+ if (!asDefaultServlet)
+ {
+ if (servletPath.length() == 0)
+ {
+ mapping = ROOT_PATH_MAPPING;
+ }
+ else
+ {
+ mapping = PATH_MAPPING;
+ }
+ }
+
+ // Determine the host for this request
+ String portalHost = req.getServerName();
+
+ // Determine the request path
+ String portalRequestPath = null;
+ String portalContextPath = null;
+ switch (mapping)
+ {
+ case DEFAULT_SERVLET_MAPPING:
+ portalRequestPath = requestURI.substring(contextPath.length());
+ portalContextPath = requestURI.substring(0, contextPath.length());
+ break;
+ case ROOT_PATH_MAPPING:
+ portalRequestPath = requestURI.substring(contextPath.length());
+ portalContextPath = requestURI.substring(0, contextPath.length());
+ break;
+ case PATH_MAPPING:
+ portalRequestPath = requestURI.substring(contextPath.length() + servletPath.length());
+ portalContextPath = requestURI.substring(0, contextPath.length() + servletPath.length());
+ break;
+ }
+
+ // Apply the url decoding
+ portalRequestPath = URLTools.decodeXWWWFormURL(portalRequestPath);
+ portalContextPath = URLTools.decodeXWWWFormURL(portalContextPath);
+
+ //
+ URLContext urlContext = URLContext.newInstance(req.isSecure(), req.getRemoteUser() != null);
+
+ // ***************
+ // ***************
+ // ***************
+ // ***************
+
+ // Parse the query string to have the get parameters
+ // The resulting map has its parameters decoded from the x-www-form-url encoding
+ Map queryParameterMap = Collections.EMPTY_MAP;
+ String queryString = req.getQueryString();
+ if (queryString != null)
+ {
+ queryParameterMap = QueryStringParser.parseQueryString(queryString);
+ }
+
+ //
+ Map bodyParameterMap = null;
+ if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
+ {
+ bodyParameterMap = Collections.EMPTY_MAP;
+ for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+
+ // Get param name
+ String paramName = (String)entry.getKey();
+
+ // Values that are aggregated from the query string and the body
+ String[] paramValues = (String[])entry.getValue();
+
+ // Values decoded from the query string
+ String[] queryValues = (String[])queryParameterMap.get(paramName);
+ if (queryValues != null)
+ {
+ int bodyValuesLength = paramValues.length - queryValues.length;
+ if (bodyValuesLength > 0)
+ {
+ String[] bodyValues = new String[bodyValuesLength];
+ System.arraycopy(paramValues, queryValues.length, bodyValues, 0, bodyValuesLength);
+ if (bodyParameterMap.isEmpty())
+ {
+ bodyParameterMap = new HashMap();
+ }
+ bodyParameterMap.put(paramName, bodyValues);
+ }
+ }
+ else
+ {
+ if (bodyParameterMap.isEmpty())
+ {
+ bodyParameterMap = new HashMap();
+ }
+ bodyParameterMap.put(paramName, paramValues);
+ }
+ }
+
+ // Make the map unmodifiable
+ bodyParameterMap = bodyParameterMap.isEmpty() ? bodyParameterMap : Collections.unmodifiableMap(bodyParameterMap);
+ }
+
+ // ***************
+ // ***************
+ // ***************
+ // ***************
+
+ //
+ Server server = this.entryPoint.getPortalServer();
+
+ //
+ ServerInvocationContext invocationCtx = new ServerInvocationContextImpl(
+ req,
+ resp,
+ portalHost,
+ portalRequestPath,
+ portalContextPath,
+ queryParameterMap,
+ bodyParameterMap,
+ urlContext,
+ mediaType);
+
+ //
+ ServerRequest request = new ServerRequest(invocationCtx);
+ request.setServer(server);
+
+ //
+ ServerResponse response = new ServerResponse(request, invocationCtx);
+
+ //
+ ServerInvocation invocation = new ServerInvocation(invocationCtx);
+ invocation.setRequest(request);
+ invocation.setResponse(response);
+
+ //
+ RequestControllerFactory controllerFactory = this.entryPoint.getControllerFactory();
+ RequestController controller = controllerFactory.createRequestController(invocation);
+ invocation.setHandler(new RequestControllerDispatcher(controller));
+
+ //
+ try
+ {
+ InterceptorStackFactory stack = this.entryPoint.getInterceptorStackFactory();
+ invocation.invoke(stack.getInterceptorStack());
+ ProcessorResponse processorResponse = (ProcessorResponse)req.getAttribute("processorResponse");
+ if(processorResponse != null)
+ {
+ Page displayedPage = processorResponse.findDisplayedPage();
+ if(displayedPage != null)
+ {
+ this.render(invocation.getServerContext().getClientResponse().getWriter(),
+ displayedPage);
+ }
+ }
+ }
+ catch (ServerException e)
+ {
+ log.error("Server exception", e);
+ Throwable nested = Exceptions.unwrap(e);
+ throw new ServletException(nested);
+ }
+ catch (InvocationException e)
+ {
+ log.error("Invocation exception", e);
+ Throwable nested = Exceptions.unwrap(e);
+ throw new ServletException(nested);
+ }
+ catch (ServletException e)
+ {
+ throw e;
+ }
+ catch (IOException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ log.error("Unexpected exception", e);
+ Throwable nested = Exceptions.unwrap(e);
+ throw new ServletException(nested);
+ }
+ }
+
+ /**
+ * Return the value for the servlet mapping. This implementation get the
+ * value from an init parameter of the servlet called <b>asDefaultServlet</b>
+ */
+ private boolean getAsDefaultServletInitValue()
+ {
+ ServletConfig config = getServletConfig();
+ String value = config.getInitParameter("asDefaultServlet");
+ if ("true".equalsIgnoreCase(value))
+ {
+ log.debug("Servlet loaded as default servlet mapping");
+ return true;
+ }
+ else if ("false".equalsIgnoreCase(value))
+ {
+ log.debug("Servlet loaded as path mapping servlet");
+ return false;
+ }
+ else
+ {
+ log.warn("Servlet mapping cannot be determined with init parameter value="
+ + value);
+ return false;
+ }
+ }
+ // ---------All these are just helper methods for the prototype-----------------------------------------------------------------------------------------------
+ //----It containts mostly hard coded logic for the prototype-------------------------------------------------------------------------------------------------
+ /**
+ * Based on the latest design discussion, this method is not needed.
+ *
+ * This will be an implementation detail of the UIServer processing the Response that is sent back to it
+ * from the Core Portal Processor
+ *
+ * @param clientConnection
+ * @param page
+ */
+ private void render(PrintWriter clientConnection, Page pageResult)
+ {
+ /**
+ * Special Note: Currently this prototype code and layout configuration including page result creation is hard coded for the purpose
+ * of getting the architecture right
+ *
+ * In the real implementation, LayoutState would be fetched dynamically based on the Page State/Configuration being rendered
+ * Even type of Client considerations would be handled here
+ *
+ * Basically the UIServer would delegate functions to its various components and then send back the result to the client
+ *
+ */
+ //Some flexible grid layout testing code
+ Object[] gridData = this.getFlexibleGridLayoutManager(pageResult);
+ Page page = (Page)gridData[0];
+ LayoutManager layoutManager = (LayoutManager)gridData[1];
+
+ //Some region layout testing code
+ //Object[] regionData = this.getRegionBasedLayoutManager(pageResult);
+ //Page page = (Page)regionData[0];
+ //LayoutManager layoutManager = (LayoutManager)regionData[1];
+
+ //Peform Page Layout
+ String output = layoutManager.doLayout(page);
+
+
+ //Create the final output...Also hardcoded without any preprocessing/postprocessing etc
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>JBoss Portal UIServer</title><link rel=\"stylesheet\" id=\"dyna_css\" href=\"/portal-ajax/dyna/style.css\" type=\"text/css\"/><link rel=\"stylesheet\" type=\"text/css\" id=\"main_css\" href=\"/portal-core/themes/renaissance/portal_style.css\"/><link rel=\"shortcut icon\" href=\"/portal-core/themes/renaissance/images/favicon.ico\" /><link rel=\"icon\" type=\"image/gif\" href=\"/portal-core/themes/renaissance/images/animated_favicon1.gif\" /></head><body id=\"body\">\n");
+ buffer.append(output);
+ buffer.append("</body></html>\n");
+
+
+ //Sending the results back to the Client
+ clientConnection.write(buffer.toString());
+ clientConnection.flush();
+ }
+
+ /**
+ *
+ */
+ private Object[] getFlexibleGridLayoutManager(Page pageResult)
+ {
+ /**
+ * Hard coding the FlexibleGridLayout Management here
+ */
+ Page page = new Page();
+ Container header = new Container("header");
+ Container leftPanel = new Container("leftPanel");
+ Container mainPanel = new Container("mainPanel");
+ Window headerTabsWindow = new Window("header-tabs-window");
+ Window menuWindow = new Window("menu-window");
+ Window leftPanelWindow1 = new Window("left-panel-window1");
+ Window leftPanelWindow2 = new Window("left-panel-window2");
+ Window mainPanelWindow = new Window("main-panel-window");
+ header.addComponent(headerTabsWindow);
+ header.addComponent(menuWindow);
+ leftPanel.addComponent(leftPanelWindow1);
+ leftPanel.addComponent(leftPanelWindow2);
+ mainPanel.addComponent(mainPanelWindow);
+
+ //Setup the Grid for headerTabs container
+ page.addContainer(header);
+ FlexibleGrid headerGrid = this.getGrid("header", 1, 2);
+ FlexibleGridConstraints[] headerTabConstraints = { this.getConstraints("header-tabs-window", "100", 0, 0, 10, 0, 0, 0),
+ this.getConstraints("menu-window", "100", 0, 0, 0, 0, 0, 1) };
+ headerGrid.setConstraints(headerTabConstraints);
+
+ //Setup the Grid for left panel container
+ page.addContainer(leftPanel);
+ FlexibleGrid leftPanelGrid = this.getGrid("leftPanel", 2, 1);
+ FlexibleGridConstraints[] leftPanelConstraints = { this.getConstraints("left-panel-window1", "75", 0, 0, 0, 0, 0, 0),
+ this.getConstraints("left-panel-window2", "75", 0, 0, 0, 0, 1, 0) };
+ leftPanelGrid.setConstraints(leftPanelConstraints);
+
+ //Setup the Grid for main panel container
+ page.addContainer(mainPanel);
+ FlexibleGrid mainPanelGrid = this.getGrid("mainPanel", 1, 1);
+ FlexibleGridConstraints[] mainPanelConstraints = { this.getConstraints("main-panel-window", "100", 0, 0, 0, 0, 0, 0) };
+ mainPanelGrid.setConstraints(mainPanelConstraints);
+
+ //Setup the FlexibleGrid Layout Manager with the different grids
+ FlexibleGrid[] row1 = { headerGrid };
+ FlexibleGrid[] row2 = { leftPanelGrid, mainPanelGrid };
+ FlexibleGridLayoutManager layoutManager = new FlexibleGridLayoutManager();
+ layoutManager.addRowOfGrids(row1);
+ layoutManager.addRowOfGrids(row2);
+
+ //Populate the grid windows with proper content
+ List windows = pageResult.getWindows();
+ int counter = 0;
+ for(Iterator itr=windows.iterator();itr.hasNext();)
+ {
+ Window result = (Window)itr.next();
+
+ switch(counter)
+ {
+ case 0:
+ leftPanelWindow1.setContent(result.getContent());
+ break;
+
+ case 1:
+ leftPanelWindow2.setContent(result.getContent());
+ break;
+
+ case 2:
+ mainPanelWindow.setContent(result.getContent());
+ break;
+
+ case 3:
+ menuWindow.setContent(result.getContent());
+ break;
+
+ case 4:
+ headerTabsWindow.setContent(result.getContent());
+ break;
+ }
+
+ counter++;
+ }
+
+ return new Object[]{page, layoutManager};
+ }
+
+
+ /**
+ *
+ * @param containerId
+ * @param rows
+ * @param columns
+ * @return
+ */
+ private FlexibleGrid getGrid(String containerId,int rows, int columns)
+ {
+ FlexibleGrid grid = new FlexibleGrid(containerId);
+ grid.setRows(rows);
+ grid.setColumns(columns);
+ return grid;
+ }
+
+ /**
+ *
+ * @param componentId
+ * @param widthPercentage
+ * @param top
+ * @param bottom
+ * @param left
+ * @param right
+ */
+ private FlexibleGridConstraints getConstraints(String componentId, String widthPercentage, int top, int bottom, int left, int right, int row, int column)
+ {
+ FlexibleGridConstraints constraints = new FlexibleGridConstraints();
+ constraints.setComponentId(componentId);
+ constraints.setWidthPercentage(widthPercentage);
+ constraints.setRow(row);
+ constraints.setColumn(column);
+ constraints.setTop(top);
+ constraints.setBottom(bottom);
+ constraints.setLeft(left);
+ constraints.setRight(right);
+ return constraints;
+ }
+
+ /**
+ *
+ * @param pageResult
+ * @return
+ */
+ private Object[] getRegionBasedLayoutManager(Page pageResult)
+ {
+ Page page = new Page();
+ Container left = new Container("left");
+ Container center = new Container("center");
+ page.addContainer(left);
+ page.addContainer(center);
+
+ //Populate the grid windows with proper content
+ List windows = pageResult.getWindows();
+ int counter = 0;
+ for(Iterator itr=windows.iterator();itr.hasNext();)
+ {
+ Window result = (Window)itr.next();
+ Window uiWindow = new Window(result.getId());
+ uiWindow.setContent(result.getContent());
+ switch(counter)
+ {
+ case 0:
+ left.addComponent(uiWindow);
+ break;
+
+ case 1:
+ left.addComponent(uiWindow);
+ break;
+
+ case 2:
+ center.addComponent(uiWindow);
+ break;
+
+ case 3:
+ center.addComponent(uiWindow);
+ break;
+
+ case 4:
+ left.addComponent(uiWindow);
+ break;
+ }
+
+ counter++;
+ }
+
+ RegionLayoutManager layoutManager = new RegionLayoutManager();
+ RegionConstraints leftConstraints = new RegionConstraints("left", RegionConstraints.LEFT);
+ RegionConstraints centerConstraints = new RegionConstraints("center", RegionConstraints.CENTER);
+ layoutManager.addRegionConstraints(leftConstraints);
+ layoutManager.addRegionConstraints(centerConstraints);
+
+ return new Object[]{page, layoutManager};
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/UIServer.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/UIServer.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/service/UIServer.java 2007-11-13 17:51:48 UTC (rev 8910)
@@ -0,0 +1,233 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.service;
+
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+import org.jboss.portal.presentation.RequestContext;
+
+import org.jboss.portal.presentation.model.Portal;
+import org.jboss.portal.presentation.model.PortalObject;
+import org.jboss.portal.presentation.server.ProcessorRequest;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+import org.jboss.portal.presentation.server.PresentationServer;
+import org.jboss.portal.presentation.action.server.ServerAction;
+import org.jboss.portal.presentation.action.server.LinkActivation;
+import org.jboss.portal.presentation.action.server.GetActivation;
+import org.jboss.portal.presentation.action.server.PostActivation;
+
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.ServerException;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerInvocationContext;
+
+
+/**
+ * The UIServer is responsible for generating the output that is sent back to the client based on the Portal state of a particular Portal Request
+ *
+ * The UIServer provides various UI level services like Page Aggregation, Page Layout, Web 2.0 client interactions etc.
+ *
+ * Typically the Core component of the Portal delegates all UI specific functions to this component
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class UIServer implements RequestController
+{
+ /**
+ *
+ */
+ private PresentationServer presentationServer = null;
+
+
+ /**
+ *
+ *
+ */
+ public UIServer()
+ {
+ }
+
+
+ /**
+ * handle is the entry point for handling an incoming Portal request. The request is handed over
+ * from the Http Layer via the main Portal Servlet
+ *
+ */
+ public void handle(ServerInvocation invocation) throws ServerException
+ {
+ try
+ {
+ ServerAction serverAction = this.getServerAction(invocation);
+ ProcessorRequest processorRequest = new ProcessorRequest(serverAction, invocation);
+ RequestContext requestContext = null; //Just use null until proper implementation is provided
+ ProcessorResponse processorResponse = this.presentationServer.getProcessor().process(requestContext,
+ processorRequest);
+
+ //Go ahead and render to the client based on ProcessorResponse received from the core Portal
+ if(processorResponse != null)
+ {
+ invocation.getServerContext().getClientRequest().setAttribute("processorResponse", processorResponse);
+ }
+ }
+ catch(Exception e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ /**
+ *
+ *
+ */
+ public void start()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public void stop()
+ {
+
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public PresentationServer getPresentationServer()
+ {
+ return presentationServer;
+ }
+
+ /**
+ *
+ * @param presentationServer
+ */
+ public void setPresentationServer(PresentationServer presentationServer)
+ {
+ this.presentationServer = presentationServer;
+ }
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ private ServerAction getServerAction(ServerInvocation invocation)
+ {
+ ServerAction serverAction = null;
+
+ ServerInvocationContext invocationContext = invocation.getServerContext();
+ HttpServletRequest request = invocationContext.getClientRequest();
+ if(request.getMethod().equals("GET"))
+ {
+ GetActivation get = new GetActivation();
+ get.setUrl(request.getRequestURL().toString());
+ get.setContentType(invocationContext.getMediaType());
+ get.setQueryParameters(invocationContext.getQueryParameterMap());
+ serverAction = get;
+ }
+ else if(request.getMethod().equals("POST"))
+ {
+ PostActivation post = new PostActivation();
+ post.setUrl(request.getRequestURL().toString());
+ post.setContentType(invocationContext.getMediaType());
+ post.setQueryParameters(invocationContext.getQueryParameterMap());
+ post.setBodyParameters(invocationContext.getBodyParameterMap());
+ serverAction = post;
+ }
+
+ //If this is a link activation, then interpret the Portal and the PortalObject that
+ //this link is targetted for
+ if(serverAction instanceof LinkActivation)
+ {
+ String portalRequestPath = invocation.getServerContext().getPortalRequestPath();
+
+ //Process the incoming request and produce a proper ProcessorRequest to be
+ //processed by the core Portal component
+ Portal portal = null;
+ PortalObject target = null;
+ StringTokenizer st = new StringTokenizer(portalRequestPath, "/");
+ StringBuffer buffer = new StringBuffer("/");
+ while(st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ if(portal == null)
+ {
+ portal = this.presentationServer.getPortalObjectReader().findPortal(token);
+ if(portal != null)
+ {
+ buffer.append(token);
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+ }
+ }
+ else
+ {
+ buffer.append(token);
+ String id = buffer.toString();
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+
+ if(target == null)
+ {
+ target = portal.findChild(id);
+ if(target == null)
+ {
+ target = this.presentationServer.getPortalObjectReader().findPortalObject(portal, id);
+ }
+ }
+ else
+ {
+ PortalObject cour = target.findChild(id);
+ if(cour == null)
+ {
+ target = this.presentationServer.getPortalObjectReader().findPortalObject(target, id);
+ }
+ else
+ {
+ target = cour;
+ }
+ }
+ }
+ }
+
+ //Setting up the proper targets for this link
+ ((LinkActivation)serverAction).setPortal(portal);
+ ((LinkActivation)serverAction).setTarget(target);
+ }
+
+
+ return serverAction;
+ }
+
+
+}
16 years, 11 months
JBoss Portal SVN: r8909 - in branches/UIServer: uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service and 3 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-11-13 12:36:35 -0500 (Tue, 13 Nov 2007)
New Revision: 8909
Removed:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/
Modified:
branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java
branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml
branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml
Log:
refactoring
Modified: branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java
===================================================================
--- branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java 2007-11-13 17:25:35 UTC (rev 8908)
+++ branches/UIServer/core/src/main/org/jboss/portal/core/theme/PageRendition.java 2007-11-13 17:36:35 UTC (rev 8909)
@@ -43,7 +43,7 @@
import java.util.List;
import java.util.ArrayList;
-//import org.jboss.portal.uiserver.service.UIServer;
+//import org.jboss.portal.presentation.service.UIServer;
/**
* Should not be a controller response, but it comes from legacy design.
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java 2007-11-13 17:25:35 UTC (rev 8908)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java 2007-11-13 17:36:35 UTC (rev 8909)
@@ -33,7 +33,7 @@
import org.jboss.portal.uiserver.ajax.client.protocol.Page;
import org.jboss.portal.uiserver.ajax.client.protocol.Window;
import org.jboss.portal.presentation.server.ProcessorResponse;
-import org.jboss.portal.uiserver.service.EntryPoint;
+import org.jboss.portal.presentation.service.EntryPoint;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
Modified: branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml 2007-11-13 17:25:35 UTC (rev 8908)
+++ branches/UIServer/uiserver/src/resources/portal-uiserver.sar/META-INF/jboss-service.xml 2007-11-13 17:36:35 UTC (rev 8909)
@@ -24,7 +24,7 @@
<server>
<mbean
- code="org.jboss.portal.uiserver.service.UIServer"
+ code="org.jboss.portal.presentation.service.UIServer"
name="portal:service=Controller"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -32,7 +32,7 @@
<depends optional-attribute-name="PresentationServer" proxy-type="attribute">portal:service=PresentationServer</depends>
</mbean>
<mbean
- code="org.jboss.portal.uiserver.service.EntryPointImpl"
+ code="org.jboss.portal.presentation.service.EntryPointImpl"
name="portal:service=EntryPoint"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml 2007-11-13 17:25:35 UTC (rev 8908)
+++ branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml 2007-11-13 17:36:35 UTC (rev 8909)
@@ -29,7 +29,7 @@
<!-- Add the GWT Client Filter to run the Portal in full Web 2.0 Ajax Mode. In turn, to run in Classic Html Mode, turn this filter off -->
<filter>
<filter-name>GWTClientFilter</filter-name>
- <filter-class>org.jboss.portal.uiserver.service.GWTClientFilter</filter-class>
+ <filter-class>org.jboss.portal.presentation.service.GWTClientFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>GWTClientFilter</filter-name>
@@ -40,7 +40,7 @@
<!-- The portal servlet is the main entrance point -->
<servlet>
<servlet-name>PortalEntryPoint</servlet-name>
- <servlet-class>org.jboss.portal.uiserver.service.PortalEntryPoint</servlet-class>
+ <servlet-class>org.jboss.portal.presentation.service.PortalEntryPoint</servlet-class>
<init-param>
<param-name>asDefaultServlet</param-name>
<param-value>false</param-value>
16 years, 11 months
JBoss Portal SVN: r8908 - in branches/UIServer/uiserver/src: main/org/jboss/portal/presentation/impl/ajax/service and 3 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-11-13 12:25:35 -0500 (Tue, 13 Nov 2007)
New Revision: 8908
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortletServiceImpl.java
Removed:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/ajax/
Modified:
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PartialRefresh.gwt.xml
branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PortalLayout.gwt.xml
branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml
Log:
refactoring
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortalEntryPoint.java 2007-11-13 17:25:35 UTC (rev 8908)
@@ -0,0 +1,224 @@
+package org.jboss.portal.presentation.impl.ajax.service;
+
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.MBeanServerLocator;
+
+import org.jboss.portal.common.invocation.InterceptorStackFactory;
+import org.jboss.portal.server.RequestControllerFactory;
+import org.jboss.portal.server.Server;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.impl.ServerInvocationContextImpl;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.ServerRequest;
+import org.jboss.portal.server.ServerResponse;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.RequestController;
+import org.jboss.portal.server.RequestControllerDispatcher;
+
+import org.jboss.portal.uiserver.ajax.client.service.PortalRPC;
+import org.jboss.portal.uiserver.ajax.client.protocol.Page;
+import org.jboss.portal.uiserver.ajax.client.protocol.Window;
+import org.jboss.portal.presentation.server.ProcessorResponse;
+import org.jboss.portal.uiserver.service.EntryPoint;
+
+import com.google.gwt.user.client.rpc.SerializationException;
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+/**
+ * This serves as the Portal Entry Point for AJAX (Asynchronous) RPC calls being made by the
+ * client-side Ajax agent of the Presentation Framework
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PortalEntryPoint extends RemoteServiceServlet implements
+PortalRPC
+{
+ /** The logger. */
+ private Logger log = Logger.getLogger(getClass());
+
+ /**
+ *
+ */
+ private EntryPoint entryPoint = null;
+
+ /** Configure the as default servlet. */
+ public void init() throws ServletException
+ {
+ try
+ {
+ MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+ this.entryPoint = (EntryPoint) MBeanProxy.get(EntryPoint.class, new ObjectName(
+ this.getInitParameter("entryPointServiceName")),
+ mbeanServer);
+ }
+ catch (Exception e)
+ {
+ this.entryPoint = null;
+ String msg = "Portal Entry Point could not be created";
+ log.error(msg, e);
+ throw new UnavailableException(msg);
+ }
+ }
+
+ /**
+ *
+ */
+ public String processCall(String payload) throws SerializationException
+ {
+ HttpServletRequest request = this.getThreadLocalRequest();
+
+ //Perform the remote procedure call
+ String returnVal = super.processCall(payload);
+
+ //Perform any post-processing after calling the actual remote method that will perform
+ //the functionality for this particular remote procedure call
+ if(request.getAttribute("processorResponse") != null)
+ {
+ ProcessorResponse processorResponse = (ProcessorResponse)request.getAttribute("processorResponse");
+ request.getSession().setAttribute("processorResponse", processorResponse);
+ }
+
+ return returnVal;
+ }
+ // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ * Loads the initial Portal Page at the start of a Portal session
+ *
+ * @return The Initial Portal Page
+ */
+ public Page loadPortal()
+ {
+ try
+ {
+ Page display = null;
+ HttpServletRequest request = this.getThreadLocalRequest();
+ this.callPortalServer();
+ display = this.getDisplay((ProcessorResponse)request.getAttribute("processorResponse"));
+ return display;
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @return The Page of the Portal that should be currently displayed
+ */
+ public Page getCurrentPage()
+ {
+ Page currentPage = null;
+
+ HttpServletRequest request = this.getThreadLocalRequest();
+
+ ProcessorResponse processorResponse = (ProcessorResponse) request.getSession().getAttribute("processorResponse");
+
+ currentPage = this.getDisplay(processorResponse);
+
+ return currentPage;
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param processorResponse
+ * @return
+ */
+ private Page getDisplay(ProcessorResponse processorResponse)
+ {
+ Page display = null;
+
+ org.jboss.portal.presentation.model.Page portalPage = processorResponse
+ .findDisplayedPage();
+
+ // Construct the ajax currentPage object from the portalPage that has been
+ // chosen to be displayed
+ if (portalPage != null)
+ {
+ display = new Page();
+ display.setName(portalPage.getName());
+ List pageWindows = portalPage.getWindows();
+ if(pageWindows != null && pageWindows.size()>0)
+ {
+ Window[] windows = new Window[pageWindows.size()];
+ display.setWindows(windows);
+ for(int i=0; i<pageWindows.size(); i++)
+ {
+ org.jboss.portal.presentation.model.Window pageWindow = (org.jboss.portal.presentation.model.Window)pageWindows.get(i);
+ Window window = new Window();
+ window.setName(pageWindow.getName());
+ window.setContent(pageWindow.getContent());
+ windows[i] = window;
+ }
+ }
+ }
+
+ return display;
+ }
+
+ /**
+ *
+ *
+ */
+ private void callPortalServer() throws Exception
+ {
+ HttpServletRequest req = this.getThreadLocalRequest();
+ HttpServletResponse resp = this.getThreadLocalResponse();
+ String requestURI = req.getRequestURI();
+ String contextPath = req.getContextPath();
+ String portalHost = req.getServerName();
+ String portalRequestPath = requestURI.substring(contextPath.length());
+ String portalContextPath = requestURI.substring(0, contextPath.length());
+ Map queryParameterMap = new HashMap();
+ URLContext urlContext = URLContext.newInstance(req.isSecure(), req.getRemoteUser() != null);
+
+ Server server = this.entryPoint.getPortalServer();
+
+ //
+ ServerInvocationContext invocationCtx = new ServerInvocationContextImpl(
+ req,
+ resp,
+ portalHost,
+ portalRequestPath,
+ portalContextPath,
+ queryParameterMap,
+ null, //body parameter map is not applicable for asynchronous RPC calls
+ urlContext,
+ null //media type information is not applicable for asynchronous RPC calls
+ );
+
+ //
+ ServerRequest request = new ServerRequest(invocationCtx);
+ request.setServer(server);
+
+ //
+ ServerResponse response = new ServerResponse(request, invocationCtx);
+
+ //
+ ServerInvocation invocation = new ServerInvocation(invocationCtx);
+ invocation.setRequest(request);
+ invocation.setResponse(response);
+
+ //
+ RequestControllerFactory controllerFactory = this.entryPoint.getControllerFactory();
+ RequestController controller = controllerFactory.createRequestController(invocation);
+ invocation.setHandler(new RequestControllerDispatcher(controller));
+
+ InterceptorStackFactory stack = this.entryPoint.getInterceptorStackFactory();
+ invocation.invoke(stack.getInterceptorStack());
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortletServiceImpl.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortletServiceImpl.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/service/PortletServiceImpl.java 2007-11-13 17:25:35 UTC (rev 8908)
@@ -0,0 +1,232 @@
+package org.jboss.portal.presentation.impl.ajax.service;
+
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.jboss.portal.uiserver.ajax.client.PortletService;
+import org.jboss.portal.uiserver.ajax.client.protocol.Page;
+import org.jboss.portal.uiserver.ajax.client.protocol.Window;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+/**
+ * This is just a STUB server side component to test the client side components
+ * of the GWT-based AJAX UI
+ *
+ * Only used for Prototyping stuff
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class PortletServiceImpl extends RemoteServiceServlet implements
+ PortletService
+{
+ /**
+ *
+ */
+ public String getPortlet(String portletId)
+ {
+ String portletContent = null;
+
+ String contentPath = portletId;
+ InputStream is = null;
+ try
+ {
+ is = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream(contentPath);
+ StringBuffer contentBuffer = new StringBuffer();
+ int bytesRead = 0;
+ byte[] data = new byte[1024];
+ while ((bytesRead = is.read(data)) != -1)
+ {
+ byte[] cour = new byte[bytesRead];
+ System.arraycopy(data, 0, cour, 0, bytesRead);
+ contentBuffer.append(new String(cour));
+ }
+ portletContent = contentBuffer.toString();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+
+ return portletContent;
+ }
+
+ /**
+ *
+ * @param pageId
+ * @return
+ */
+ public Page getPage(String pageId)
+ {
+ Page page = new Page();
+ page.setName(pageId);
+
+ if (pageId.equals("index") || pageId.equals("Page 1"))
+ {
+ String weatherContent = this.getPortlet("weatherPortlet.html");
+ String cmsContent = this.getPortlet("cmsPortlet.html");
+ Window[] windows = new Window[2];
+ page.setWindows(windows);
+
+ Window weatherWindow = new Window();
+ weatherWindow.setName("weatherPortlet");
+ weatherWindow.setContent(weatherContent);
+
+ Window cmsWindow = new Window();
+ cmsWindow.setName("cmsPortlet");
+ cmsWindow.setContent(cmsContent);
+
+ windows[0] = weatherWindow;
+ windows[1] = cmsWindow;
+ }
+ else if (pageId.equals("Page 2"))
+ {
+ String weatherContent = this.getPortlet("weatherPortlet.html");
+ Window[] windows = new Window[1];
+ page.setWindows(windows);
+
+ Window weatherWindow = new Window();
+ weatherWindow.setName("weatherPortlet");
+ weatherWindow.setContent(weatherContent);
+
+ windows[0] = weatherWindow;
+ }
+ else if (pageId.equals("Page 3"))
+ {
+ String cmsContent = this.getPortlet("cmsPortlet.html");
+ Window[] windows = new Window[1];
+ page.setWindows(windows);
+
+ Window cmsWindow = new Window();
+ cmsWindow.setName("cmsPortlet");
+ cmsWindow.setContent(cmsContent);
+
+ windows[0] = cmsWindow;
+ }
+
+ HttpServletRequest request = this.getThreadLocalRequest();
+ request.getSession().setAttribute("currentPage", page);
+
+ return page;
+ }
+
+ /**
+ *
+ * @param window
+ * @param state
+ */
+ public Page setState(String window, String newState)
+ {
+ HttpServletRequest request = this.getThreadLocalRequest();
+ Page page = (Page) request.getSession().getAttribute("currentPage");
+
+ Window selectedWindow = this.findWindow(page, window);
+ selectedWindow.setState(newState);
+ if (selectedWindow.getState().equals(Window.NORMAL))
+ {
+ if (selectedWindow.getName().equals("cmsPortlet"))
+ {
+ selectedWindow.setContent(this.getPortlet("cmsPortlet.html"));
+ }
+ else
+ {
+ selectedWindow.setContent(this.getPortlet("weatherPortlet.html"));
+ }
+ this.hideWindows(page.getWindows(), null, false);
+ }
+ else if (selectedWindow.getState().equals(Window.MINIMIZED))
+ {
+ selectedWindow.setContent("");
+ this.hideWindows(page.getWindows(), null, false);
+ }
+ if (selectedWindow.getState().equals(Window.MAXIMIZED))
+ {
+ if (selectedWindow.getName().equals("cmsPortlet"))
+ {
+ selectedWindow.setContent(this.getPortlet("cmsPortlet.html"));
+ }
+ else
+ {
+ selectedWindow.setContent(this.getPortlet("weatherPortlet.html"));
+ }
+ this.hideWindows(page.getWindows(), selectedWindow, true);
+ }
+
+ return page;
+ }
+
+ /**
+ *
+ * @param window
+ * @param state
+ */
+ public Page setMode(String window, String newMode)
+ {
+ HttpServletRequest request = this.getThreadLocalRequest();
+ Page page = (Page) request.getSession().getAttribute("currentPage");
+
+ Window selectedWindow = this.findWindow(page, window);
+ selectedWindow.setMode(newMode);
+
+ return page;
+ }
+
+ /**
+ *
+ * @param page
+ * @param windowName
+ * @return
+ */
+ private Window findWindow(Page page, String windowName)
+ {
+ Window window = null;
+
+ Window[] windows = page.getWindows();
+ for (int i = 0; i < windows.length; i++)
+ {
+ if (windows[i].getName().equals(windowName))
+ {
+ window = windows[i];
+ break;
+ }
+ }
+
+ return window;
+ }
+
+ /**
+ *
+ * @param excludedWindow
+ * @param hide
+ */
+ private void hideWindows(Window[] windows, Window excludedWindow,
+ boolean hide)
+ {
+ for (int i = 0; i < windows.length; i++)
+ {
+ if (excludedWindow != null
+ && windows[i].getName().equals(excludedWindow.getName()))
+ {
+ continue;
+ }
+
+ windows[i].setVisible(!hide);
+ }
+ }
+}
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml 2007-11-13 17:19:15 UTC (rev 8907)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/AsyncPages.gwt.xml 2007-11-13 17:25:35 UTC (rev 8908)
@@ -8,5 +8,5 @@
<entry-point class="org.jboss.portal.uiserver.ajax.client.AsyncPages"/>
<!-- RPC related configuration -->
- <servlet path="/portletService" class="org.jboss.portal.uiserver.service.ajax.PortletServiceImpl"/>
+ <servlet path="/portletService" class="org.jboss.portal.presentation.impl.ajax.service.PortletServiceImpl"/>
</module>
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PartialRefresh.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PartialRefresh.gwt.xml 2007-11-13 17:19:15 UTC (rev 8907)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PartialRefresh.gwt.xml 2007-11-13 17:25:35 UTC (rev 8908)
@@ -6,5 +6,5 @@
<entry-point class="org.jboss.portal.uiserver.ajax.client.PartialRefresh"/>
<!-- RPC related configuration -->
- <servlet path="/portletService" class="org.jboss.portal.uiserver.service.ajax.PortletServiceImpl"/>
+ <servlet path="/portletService" class="org.jboss.portal.presentation.impl.ajax.service.PortletServiceImpl"/>
</module>
Modified: branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PortalLayout.gwt.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PortalLayout.gwt.xml 2007-11-13 17:19:15 UTC (rev 8907)
+++ branches/UIServer/uiserver/src/resources/client/ajax/src/org/jboss/portal/uiserver/ajax/PortalLayout.gwt.xml 2007-11-13 17:25:35 UTC (rev 8908)
@@ -6,5 +6,5 @@
<entry-point class="org.jboss.portal.uiserver.ajax.client.PortalLayout"/>
<!-- RPC related configuration -->
- <servlet path="/portletService" class="org.jboss.portal.uiserver.service.ajax.PortletServiceImpl"/>
+ <servlet path="/portletService" class="org.jboss.portal.presentation.impl.ajax.service.PortletServiceImpl"/>
</module>
Modified: branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml
===================================================================
--- branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml 2007-11-13 17:19:15 UTC (rev 8907)
+++ branches/UIServer/uiserver/src/resources/portal-uiserver.war/WEB-INF/web.xml 2007-11-13 17:25:35 UTC (rev 8908)
@@ -74,7 +74,7 @@
<!-- Asynchronous service request processor -->
<servlet>
<servlet-name>AjaxPortalEntryPoint</servlet-name>
- <servlet-class>org.jboss.portal.uiserver.service.ajax.PortalEntryPoint</servlet-class>
+ <servlet-class>org.jboss.portal.presentation.impl.ajax.service.PortalEntryPoint</servlet-class>
<init-param>
<param-name>asDefaultServlet</param-name>
<param-value>false</param-value>
16 years, 11 months
JBoss Portal SVN: r8907 - in branches/UIServer/uiserver/src/main/org/jboss/portal: presentation/impl and 6 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-11-13 12:19:15 -0500 (Tue, 13 Nov 2007)
New Revision: 8907
Added:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/ajax/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java
Removed:
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/layout/
Modified:
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java
branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java
branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
Log:
refactoring
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGrid.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,344 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.impl.classic.layout;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Window;
+
+import java.io.Serializable;
+
+/**
+ * This layout provides a Flexible Grid for laying out the UI components (which would be Portlet Windows)
+ * inside a flexible coordinates based Grid on a classic HTML page
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGrid implements Serializable
+{
+ private static Logger log = Logger.getLogger(FlexibleGrid.class);
+
+ private FlexibleGridConstraints[] constraints = null;
+
+ private int rows = 0;
+ private int columns = 0;
+
+ /**
+ * Id of the container being laid out inside this grid. This is a required value
+ */
+ private String containerId = null;
+
+ /**
+ * minimumWidth of the grid
+ */
+ private int minimumWidth = 0;
+
+ /**
+ * Float this grid to the left side of the page so that another grid can be placed next to it
+ *
+ * Used for placing multiple grids horizontally on the page
+ */
+ private boolean isFloatLeft = false;
+
+
+ /**
+ *
+ *
+ */
+ public FlexibleGrid(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public FlexibleGridConstraints[] getConstraints()
+ {
+ return constraints;
+ }
+
+ /**
+ *
+ * @param constraints
+ */
+ public void setConstraints(FlexibleGridConstraints[] constraints)
+ {
+ this.constraints = constraints;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getColumns()
+ {
+ return columns;
+ }
+
+ /**
+ *
+ * @param columns
+ */
+ public void setColumns(int columns)
+ {
+ this.columns = columns;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRows()
+ {
+ return rows;
+ }
+
+ /**
+ *
+ * @param rows
+ */
+ public void setRows(int rows)
+ {
+ this.rows = rows;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getMinimumWidth()
+ {
+ return minimumWidth;
+ }
+
+
+ /**
+ *
+ * @param minimumWidth
+ */
+ public void setMinimumWidth(int minimumWidth)
+ {
+ this.minimumWidth = minimumWidth;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isFloatLeft()
+ {
+ return isFloatLeft;
+ }
+
+ /**
+ *
+ * @param isFloatLeft
+ */
+ public void setFloatLeft(boolean isFloatLeft)
+ {
+ this.isFloatLeft = isFloatLeft;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContainerId()
+ {
+ return containerId;
+ }
+
+ /**
+ *
+ * @param containerId
+ */
+ public void setContainerId(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ * Note: this method is given only package level visibility since it should be used only by the FlexibleGridLayoutManager
+ */
+
+ /**
+ *
+ */
+ String doLayout(Container container)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<div id=\"grid-"+this.containerId+"\">\n");
+
+ buffer.append("<table>\n");
+
+ for(int row=0;row<rows;row++)
+ {
+ buffer.append("<tr>\n");
+
+ for(int column=0;column<columns;column++)
+ {
+ buffer.append("<td>\n");
+
+ buffer.append("<div id=\"grid-"+this.containerId+"-"+row+"-"+column+"\">\n");
+ buffer.append(this.getPortletMarkup(container, row, column));
+ buffer.append("</div>\n");
+
+ buffer.append("</td>\n");
+ }
+
+ buffer.append("</tr>\n");
+ }
+
+ buffer.append("</table>\n");
+
+ buffer.append("</div>\n");
+
+
+ output = buffer.toString();
+
+ return output;
+ }
+
+
+ /**
+ *
+ * @param container
+ * @return
+ */
+ String generateInlineStyle(Container container)
+ {
+ String style = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ for(int row=0;row<this.rows;row++)
+ {
+ for(int column=0;column<this.columns;column++)
+ {
+ String cellStyle = this.getCellStyle(row, column);
+ if(cellStyle != null && cellStyle.trim().length()>0)
+ {
+ buffer.append(cellStyle);
+ }
+ }
+ }
+
+ style = buffer.toString();
+
+ return style;
+ }
+
+ /**
+ *
+ * @param row
+ * @param column
+ * @return
+ */
+ String getCellStyle(int row, int column)
+ {
+ String style = null;
+
+ if(this.constraints != null)
+ {
+ for(int i=0;i<this.constraints.length;i++)
+ {
+ FlexibleGridConstraints constraint = this.constraints[i];
+ if(constraint.getRow() == row && constraint.getColumn() == column)
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ //Generate the layout style to be used for this cell
+ buffer.append("#grid-"+this.containerId+"-"+row+"-"+column+"{float: left; margin: 0px; padding: 0px; width: "+constraint.getWidthPercentage()+"%; position: relative;");
+
+ if(constraint.getTop() > 0)
+ {
+ buffer.append(" top: "+String.valueOf(constraint.getTop())+"%;");
+ }
+
+ if(constraint.getBottom() > 0)
+ {
+ buffer.append(" bottom: "+String.valueOf(constraint.getBottom())+"%;");
+ }
+
+ if(constraint.getLeft() > 0)
+ {
+ buffer.append(" left: "+String.valueOf(constraint.getLeft())+"%;");
+ }
+
+ if(constraint.getRight() > 0)
+ {
+ buffer.append(" right: "+String.valueOf(constraint.getRight())+"%;");
+ }
+
+ buffer.append("}\n");
+
+ style = buffer.toString();
+
+ return style;
+ }
+ }
+
+ //If we get here....need to use a spacer for this cell
+ int minWidth = 770/this.columns;
+ style = "#grid-"+this.containerId+"-"+row+"-"+column+"{float: left; line-height: 0px; font-size: 0px; min-width: "+minWidth+"px; height: "+minWidth+"px;}\n";
+ }
+
+ return style;
+ }
+
+ /**
+ *
+ * @param row
+ * @param column
+ * @return
+ */
+ private String getPortletMarkup(Container container,int row,int column)
+ {
+ String markup = "";
+
+ if(this.constraints != null)
+ {
+ for(int i=0;i<this.constraints.length;i++)
+ {
+ FlexibleGridConstraints constraint = this.constraints[i];
+
+ if(constraint.getRow() == row && constraint.getColumn() == column)
+ {
+ String componentId = constraint.getComponentId();
+ Window window = (Window)container.getComponent(componentId);
+ markup = window.getMarkup();
+ }
+
+ }
+ }
+
+ return markup;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridConstraints.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.impl.classic.layout;
+
+import java.io.Serializable;
+
+/**
+ * The FlexibleGridConstraints class specifies constraints for components that are laid out using the FlexibleGrid layout manager.
+ *
+ * These constraints apply to an instance of a UIComponent being laid out inside the given cell of the FlexibleGrid
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGridConstraints implements Serializable
+{
+ /**
+ * Unique Id of the component that these constraints should be applied to
+ */
+ private String componentId = null;
+
+ /**
+ * width in percentage that this component should occupy in the grid
+ */
+ private String widthPercentage = null;
+
+ /**
+ * top position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component downwards and vice versa
+ */
+ private int top = 0;
+
+ /**
+ * bottom position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component upwards and vice versa
+ */
+ private int bottom = 0;
+
+ /**
+ * left position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component to the right and vice versa
+ */
+ private int left = 0;
+
+ /**
+ * right position of the component inside a grid cell.
+ * Value calculated in percentage. A positive value moves the component to the left and vice versa
+ */
+ private int right = 0;
+
+ /**
+ * row in the grid where this component should be placed
+ */
+ private int row = 0;
+
+ /**
+ * column in the grid where this component should be placed
+ */
+ private int column = 0;
+
+
+ /**
+ *
+ *
+ */
+ public FlexibleGridConstraints()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getColumn()
+ {
+ return column;
+ }
+
+ /**
+ *
+ * @param column
+ */
+ public void setColumn(int column)
+ {
+ this.column = column;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getComponentId()
+ {
+ return componentId;
+ }
+
+ /**
+ *
+ * @param componentId
+ */
+ public void setComponentId(String componentId)
+ {
+ this.componentId = componentId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRow()
+ {
+ return row;
+ }
+
+ /**
+ *
+ * @param row
+ */
+ public void setRow(int row)
+ {
+ this.row = row;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getWidthPercentage()
+ {
+ return widthPercentage;
+ }
+
+ /**
+ *
+ * @param widthPercentage
+ */
+ public void setWidthPercentage(String widthPercentage)
+ {
+ this.widthPercentage = widthPercentage;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getBottom()
+ {
+ return bottom;
+ }
+
+ /**
+ *
+ * @param bottom
+ */
+ public void setBottom(int bottom)
+ {
+ this.bottom = bottom;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getLeft()
+ {
+ return left;
+ }
+
+ /**
+ *
+ * @param left
+ */
+ public void setLeft(int left)
+ {
+ this.left = left;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getRight()
+ {
+ return right;
+ }
+
+ /**
+ *
+ * @param right
+ */
+ public void setRight(int right)
+ {
+ this.right = right;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getTop()
+ {
+ return top;
+ }
+
+ /**
+ *
+ * @param top
+ */
+ public void setTop(int top)
+ {
+ this.top = top;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/FlexibleGridLayoutManager.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,186 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.impl.classic.layout;
+
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Page;
+import org.jboss.portal.presentation.layout.LayoutManager;
+
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * This layout manager provides a Flexible Grid for laying out the UI components (which would be Portlet Windows)
+ * inside a flexible coordinates based Grid on a classic HTML page
+ *
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class FlexibleGridLayoutManager implements LayoutManager
+{
+ /**
+ * A list of array of flexible grids. Each element of this list is an array of
+ * flexible grid objects that needs to be laid out horizontally from left to right
+ * on the page. This array of FlexibleGrid objects can also be thought of as a row of
+ * FlexibleGrid objects
+ *
+ * The grids are laid out in the order they are added to this list
+ */
+ private List pageGrids = null;
+
+ /**
+ *
+ *
+ */
+ public FlexibleGridLayoutManager()
+ {
+ this.pageGrids = new ArrayList();
+ }
+
+ /**
+ *
+ * @param grids
+ */
+ public void addRowOfGrids(FlexibleGrid[] grids)
+ {
+ this.pageGrids.add(grids);
+ }
+
+
+ /**
+ *
+ */
+ public String doLayout(Page page)
+ {
+ String layoutOutput = "";
+
+ StringBuffer buffer = new StringBuffer();
+
+ if(this.pageGrids != null)
+ {
+ for(int i=0;i<this.pageGrids.size();i++)
+ {
+ FlexibleGrid[] grids = (FlexibleGrid[])this.pageGrids.get(i);
+ Container[] containers = this.findContainers(page, grids);
+
+ buffer.append(this.generateInlineStyle(grids, containers));
+
+ for(int gridCounter=0;gridCounter<grids.length;gridCounter++)
+ {
+ FlexibleGrid grid = grids[gridCounter];
+ Container container = containers[gridCounter];
+
+ buffer.append(grid.doLayout(container));
+ }
+
+ }
+ }
+
+ layoutOutput = buffer.toString();
+
+ return layoutOutput;
+ }
+
+ /**
+ *
+ * @param page
+ * @param grids
+ * @return
+ */
+ private Container[] findContainers(Page page, FlexibleGrid[] grids)
+ {
+ Container[] containers = null;
+
+ containers = new Container[grids.length];
+ List allContainers = page.getContainers();
+
+ //Find containers from the page associated with each grid instance in the array of grids
+ for(int gridCount=0; gridCount<grids.length ; gridCount++)
+ {
+ FlexibleGrid grid = grids[gridCount];
+ String containerId = grid.getContainerId();
+
+ //Look for a container inside the page whose id matches the containerId that
+ //the grid is associated with
+ for(int containerCount=0; containerCount < allContainers.size(); containerCount++)
+ {
+ Container container = (Container)allContainers.get(containerCount);
+
+ if(container.getId().equals(containerId))
+ {
+ containers[gridCount] = container;
+ break;
+ }
+ }
+ }
+
+ return containers;
+ }
+
+ /**
+ *
+ * @param grids
+ * @param containers
+ * @return
+ */
+ private String generateInlineStyle(FlexibleGrid[] grids,Container[] containers)
+ {
+ String inlineStyle = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<style type=\"text/css\">\n");
+
+ for(int gridCounter=0;gridCounter<grids.length;gridCounter++)
+ {
+ FlexibleGrid grid = grids[gridCounter];
+ Container container = containers[gridCounter];
+
+ buffer.append("#grid-"+grid.getContainerId()+"{text-align: left; position: relative;");
+
+ if(grid.getMinimumWidth() > 0)
+ {
+ buffer.append(" min-width: "+String.valueOf(grid.getMinimumWidth())+"px;");
+ }
+
+ if(gridCounter == 0 && grids.length > 1)
+ {
+ buffer.append(" float: left;");
+ }
+
+ buffer.append("}\n");
+
+ //Now generate the styles for each individual cell of the grid which will hold
+ //the components of this container
+ buffer.append(grid.generateInlineStyle(container));
+ }
+
+ buffer.append("</style>\n");
+
+ inlineStyle = buffer.toString();
+
+ return inlineStyle;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionConstraints.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.impl.classic.layout;
+
+import java.io.Serializable;
+
+/**
+ * The RegionConstraints class specifies constraints for containers that are laid out using the Region based layout manager.
+ *
+ * These constraints apply to an instance of a Container and its placement as its laid out within a specified region on the Page
+ *
+ * When the Container is placed, all its Components (which are Windows) are laid out vertically inside the Region
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class RegionConstraints implements Serializable
+{
+ public static final int LEFT = 1;
+ public static final int CENTER = 2;
+ public static final int RIGHT = 3;
+
+ /**
+ * Unique Id of the container that these constraints should be applied to
+ */
+ private String containerId = null;
+
+ /**
+ * Type of region where the component should be added
+ *
+ * makes it belong to LEFT region by default
+ */
+ private int type = 1;
+
+ /**
+ *
+ * @param containerId
+ * @param type
+ */
+ public RegionConstraints(String containerId, int type)
+ {
+ this.containerId = containerId;
+ this.type = type;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getContainerId()
+ {
+ return containerId;
+ }
+
+ /**
+ *
+ * @param containerId
+ */
+ public void setContainerId(String containerId)
+ {
+ this.containerId = containerId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getType()
+ {
+ return type;
+ }
+
+ /**
+ *
+ * @param type
+ */
+ public void setType(int type)
+ {
+ this.type = type;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/impl/classic/layout/RegionLayoutManager.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,183 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.impl.classic.layout;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.portal.presentation.model.Container;
+import org.jboss.portal.presentation.model.Page;
+import org.jboss.portal.presentation.model.Window;
+import org.jboss.portal.presentation.layout.LayoutManager;
+
+/**
+ * This layout manager splits the page up into Regions. Containers which contain the Portlet Windows
+ * are then laid out vertically inside each Region.
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class RegionLayoutManager implements LayoutManager
+{
+ /**
+ *
+ */
+ private List regionConstraints = null;
+
+ /**
+ *
+ *
+ */
+ public RegionLayoutManager()
+ {
+ this.regionConstraints = new ArrayList();
+ }
+
+ /**
+ *
+ * @param constraints
+ */
+ public void addRegionConstraints(RegionConstraints constraints)
+ {
+ this.regionConstraints.add(constraints);
+ }
+
+ /**
+ *
+ */
+ public String doLayout(Page page)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("<div id=\"portal-container\">\n");
+
+ //Perform layout of the containers on this page
+ Container leftContainer = this.findContainerByRegion(RegionConstraints.LEFT, page);
+ Container centerContainer = this.findContainerByRegion(RegionConstraints.CENTER, page);
+ Container rightContainer = this.findContainerByRegion(RegionConstraints.RIGHT, page);
+
+ if(leftContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.LEFT, leftContainer));
+ }
+
+ if(centerContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.CENTER, centerContainer));
+ }
+
+ if(rightContainer != null)
+ {
+ buffer.append(this.layoutRegion(RegionConstraints.RIGHT, rightContainer));
+ }
+
+ buffer.append("</div>\n");
+
+ output = buffer.toString();
+
+ return output;
+ }
+
+ /**
+ *
+ * @param regionType
+ * @param page
+ * @return
+ */
+ private Container findContainerByRegion(int regionType, Page page)
+ {
+ Container container = null;
+
+ for(int containerCtr=0; containerCtr<page.getContainers().size(); containerCtr++)
+ {
+ Container cour = (Container)page.getContainers().get(containerCtr);
+
+ for(int constraintCtr=0; constraintCtr<this.regionConstraints.size(); constraintCtr++)
+ {
+ RegionConstraints constraints = (RegionConstraints)this.regionConstraints.get(constraintCtr);
+
+ if(constraints.getContainerId() == cour.getId() && constraints.getType() == regionType)
+ {
+ container = cour;
+ break;
+ }
+ }
+
+ if(container != null)
+ {
+ break;
+ }
+ }
+
+ return container;
+ }
+
+ /**
+ *
+ * @param regionType
+ * @param container
+ */
+ private String layoutRegion(int regionType, Container container)
+ {
+ String output = null;
+
+ StringBuffer buffer = new StringBuffer();
+
+ switch(regionType)
+ {
+ case RegionConstraints.LEFT:
+ buffer.append("<div id=\"regionA\">\n");
+ break;
+
+ case RegionConstraints.CENTER:
+ buffer.append("<div id=\"regionB\">\n");
+ break;
+
+ case RegionConstraints.RIGHT:
+ buffer.append("<div id=\"regionC\">\n");
+ break;
+
+ default:
+ buffer.append("<div id=\"regionA\">\n");
+ break;
+ }
+
+ for(int i=0; i<container.getComponents().size(); i++)
+ {
+ Window window = (Window)container.getComponents().get(i);
+
+ buffer.append("<div class=\"portlet-container\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"portlet-titlebar-left\"></td><td class=\"portlet-titlebar-center\"><div class=\"portlet-titlebar-decoration\"></div><span class=\"portlet-titlebar-title\"></span><div class=\"portlet-mode-container\"><span title=\"minimized\"><a class=\"portlet-mode-minimized\" href=\"\"> </a></span><span title=\"maximized\"><a class=\"portlet-mode-maximized\" href=\"\"> </a></span></div></td><td class=\"portlet-titlebar-right\"></td></tr><tr><td class=\"portlet-content-left\"></td><td class=\"portlet-body\"><div class=\"portlet-content-center\">\n");
+
+ buffer.append(window.getMarkup());
+
+ buffer.append("</div></td><td class=\"portlet-content-right\"></td></tr><tr><td class=\"portlet-footer-left\"></td><td class=\"portlet-footer-center\"></td><td class=\"portlet-footer-right\"></td></tr></table></div>\n\n\n\n");
+ }
+
+ buffer.append("</div>\n\n\n\n");
+ output = buffer.toString();
+
+ return output;
+ }
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutManager.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.layout;
+
+import org.jboss.portal.presentation.model.Page;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface LayoutManager
+{
+ /**
+ *
+ * @param container
+ * @return
+ */
+ public String doLayout(Page page);
+}
Added: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java (rev 0)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/layout/LayoutService.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.layout;
+
+import org.jboss.portal.presentation.model.Page;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class LayoutService
+{
+ /**
+ *
+ *
+ */
+ public LayoutService()
+ {
+ }
+
+ /**
+ *
+ * @param container
+ * @param layoutManager
+ * @return
+ */
+ public String doLayout(Page page, LayoutManager layoutManager)
+ {
+ String output = null;
+
+ output = layoutManager.doLayout(page);
+
+ return output;
+ }
+}
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java 2007-11-13 17:07:24 UTC (rev 8906)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestFlexibleGrid.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -31,9 +31,9 @@
import org.jboss.portal.presentation.model.Container;
import org.jboss.portal.presentation.model.Page;
import org.jboss.portal.presentation.model.Window;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGrid;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGrid;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridLayoutManager;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java 2007-11-13 17:07:24 UTC (rev 8906)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/presentation/test/layout/TestRegionLayoutManager.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -31,8 +31,8 @@
import org.jboss.portal.presentation.model.Container;
import org.jboss.portal.presentation.model.Page;
import org.jboss.portal.presentation.model.Window;
-import org.jboss.portal.uiserver.layout.classic.RegionConstraints;
-import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.RegionConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.RegionLayoutManager;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
Modified: branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java
===================================================================
--- branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java 2007-11-13 17:07:24 UTC (rev 8906)
+++ branches/UIServer/uiserver/src/main/org/jboss/portal/uiserver/service/PortalEntryPoint.java 2007-11-13 17:19:15 UTC (rev 8907)
@@ -60,12 +60,12 @@
import org.jboss.portal.server.ServerResponse;
import org.jboss.portal.server.impl.ServerInvocationContextImpl;
import org.jboss.portal.server.request.URLContext;
-import org.jboss.portal.uiserver.layout.LayoutManager;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGrid;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGridConstraints;
-import org.jboss.portal.uiserver.layout.classic.FlexibleGridLayoutManager;
-import org.jboss.portal.uiserver.layout.classic.RegionConstraints;
-import org.jboss.portal.uiserver.layout.classic.RegionLayoutManager;
+import org.jboss.portal.presentation.layout.LayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGrid;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.FlexibleGridLayoutManager;
+import org.jboss.portal.presentation.impl.classic.layout.RegionConstraints;
+import org.jboss.portal.presentation.impl.classic.layout.RegionLayoutManager;
import org.jboss.portal.presentation.model.Container;
import org.jboss.portal.presentation.model.Page;
import org.jboss.portal.presentation.model.Window;
16 years, 11 months