gatein SVN: r4924 - in portal/trunk/component/wsrp: src/main/java/org/gatein/portal/wsrp and 3 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-11-03 16:48:19 -0400 (Wed, 03 Nov 2010)
New Revision: 4924
Added:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java
portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/
portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java
Removed:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
Modified:
portal/trunk/component/wsrp/pom.xml
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
Log:
- Re-factored MOPConsumerStructureProvider so that it's decoupled from MOP objects by introducing the PortalStructureAccess interface and its MOPPortalStructureAccess implementation. Made it easier to test.
- Added test case.
Modified: portal/trunk/component/wsrp/pom.xml
===================================================================
--- portal/trunk/component/wsrp/pom.xml 2010-11-03 20:28:48 UTC (rev 4923)
+++ portal/trunk/component/wsrp/pom.xml 2010-11-03 20:48:19 UTC (rev 4924)
@@ -104,6 +104,10 @@
<groupId>org.chromattic</groupId>
<artifactId>chromattic.spi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.gatein.wci</groupId>
+ <artifactId>wci-wci</artifactId>
+ </dependency>
<!-- Required to process Chromattic annotations -->
<dependency>
@@ -119,8 +123,10 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.gatein.wci</groupId>
- <artifactId>wci-wci</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
</dependency>
</dependencies>
Deleted: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java 2010-11-03 20:28:48 UTC (rev 4923)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -1,312 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, 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.gatein.portal.wsrp;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.mop.Described;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.data.Mapper;
-import org.exoplatform.portal.pom.data.PageKey;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.exoplatform.services.listener.Event;
-import org.exoplatform.services.listener.Listener;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.ObjectType;
-import org.gatein.mop.api.workspace.Page;
-import org.gatein.mop.api.workspace.Site;
-import org.gatein.mop.api.workspace.Workspace;
-import org.gatein.mop.api.workspace.ui.UIComponent;
-import org.gatein.mop.api.workspace.ui.UIContainer;
-import org.gatein.mop.api.workspace.ui.UIWindow;
-import org.gatein.pc.api.PortletContext;
-import org.gatein.pc.api.PortletStateType;
-import org.gatein.pc.api.StatefulPortletContext;
-import org.gatein.wsrp.api.context.ConsumerStructureProvider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
- * @version $Revision$
- */
-public class MOPConsumerStructureProvider extends Listener<DataStorage, org.exoplatform.portal.config.model.Page> implements ConsumerStructureProvider
-{
- private static final String PAGES_CHILD_NAME = "pages";
- private final POMSessionManager pomManager;
- private Map<String, PageInfo> pageInfos;
- private boolean pagesHaveBeenInitialized;
-
- public MOPConsumerStructureProvider(ExoContainer container)
- {
- pomManager = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
- pageInfos = new HashMap<String, PageInfo>();
- }
-
- public List<String> getPageIdentifiers()
- {
- if (!pagesHaveBeenInitialized)
- {
- // initialize page information
- POMSession session = pomManager.getSession();
- Workspace workspace = session.getWorkspace();
- Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
-
- for (Site site : sites)
- {
- Page page = getPagesFrom(site);
- if (page != null)
- {
- addPage(page, true);
- }
- }
-
- pagesHaveBeenInitialized = true;
- }
-
- LinkedList<String> identifiers = new LinkedList<String>(pageInfos.keySet());
- Collections.sort(identifiers);
- return identifiers;
- }
-
- private Page getPagesFrom(Site site)
- {
- // a site contains a root page with templates and pages
- // more info at http://code.google.com/p/chromattic/wiki/MOPUseCases
-
- return site.getRootPage().getChild(PAGES_CHILD_NAME);
- }
-
- private void addPage(Page page, boolean ignoreCurrent)
- {
- if (!ignoreCurrent)
- {
- Described described = page.adapt(Described.class);
- PageInfo pageInfo = new PageInfo(page.getObjectId(), described.getName());
- pageInfos.put(pageInfo.getName(), pageInfo);
- UIContainer container = page.getRootComponent();
- processContainer(container, pageInfo);
- }
-
- Collection<Page> children = page.getChildren();
- if (ParameterValidation.existsAndIsNotEmpty(children))
- {
- for (Page child : children)
- {
- addPage(child, false);
- }
- }
- }
-
- public List<String> getWindowIdentifiersFor(String pageId)
- {
- PageInfo pageInfo = pageInfos.get(pageId);
- ParameterValidation.throwIllegalArgExceptionIfNull(pageInfo, "PageInfo for " + pageId);
-
- return pageInfo.getChildrenWindows();
- }
-
- private void processContainer(UIContainer container, PageInfo pageInfo)
- {
- List<UIComponent> components = container.getComponents();
- for (UIComponent component : components)
- {
- ObjectType<? extends UIComponent> type = component.getObjectType();
- if (ObjectType.WINDOW.equals(type))
- {
- Described described = component.adapt(Described.class);
- String name = described.getName();
-
- pageInfo.addWindow(name, component.getObjectId());
- }
- else if (ObjectType.CONTAINER.equals(type))
- {
- processContainer((UIContainer)component, pageInfo);
- }
- else
- {
- // ignore
- }
- }
- }
-
- public void assignPortletToWindow(PortletContext portletContext, String windowId, String pageId, String exportedPortletHandle)
- {
- PageInfo pageInfo = pageInfos.get(pageId);
- String uuid = pageInfo.getWindowUUID(windowId);
- ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " + windowId);
-
- // get the window
- POMSession session = pomManager.getSession();
- UIWindow window = session.findObjectById(ObjectType.WINDOW, uuid);
-
- // construct the new customization state
- WSRP wsrp = new WSRP();
- String portletId = portletContext.getId();
- wsrp.setPortletId(portletId);
- if (portletContext instanceof StatefulPortletContext)
- {
- StatefulPortletContext context = (StatefulPortletContext)portletContext;
- if (PortletStateType.OPAQUE.equals(context.getType()))
- {
- wsrp.setState((byte[])context.getState());
- }
- else
- {
- throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
- }
- }
-
- // destroy existing customization as otherwise re-customizing will fail
- Customization<?> customization = window.getCustomization();
- customization.destroy();
-
- // and re-customize
- window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
-
- // Change the window's name so that it's less confusing to users
- Described described = window.adapt(Described.class);
- String newName = exportedPortletHandle + " (remote)";
- described.setName(newName); // should be the same as ApplicationRegistryService.REMOTE_DISPLAY_NAME_SUFFIX
-
- // update window mappings
- pageInfo.updateWindowName(windowId, newName);
-
- // mark page for cache invalidation otherwise DataCache will use the previous customization id when trying to set
- // the portlet state in UIPortlet.setState and will not find it resulting in an error
- Page page = window.getPage();
- session.scheduleForEviction(new PageKey("portal", page.getSite().getName(), page.getName()));
-
- // save
- session.close(true);
- }
-
- @Override
- public void onEvent(Event<DataStorage, org.exoplatform.portal.config.model.Page> event) throws Exception
- {
- String eventName = event.getEventName();
-
- // get the MOP page from the event data
- org.exoplatform.portal.config.model.Page portalPage = event.getData();
- Site site = pomManager.getSession().getWorkspace().getSite(Mapper.parseSiteType(portalPage.getOwnerType()), portalPage.getOwnerId());
- Page page = getPagesFrom(site).getChild(portalPage.getName());
-
- if (page != null)
- {
- if (DataStorage.PAGE_CREATED.equals(eventName))
- {
- // add information for new page
- addPage(page, false);
- }
- else if (DataStorage.PAGE_REMOVED.equals(eventName))
- {
- removePage(page);
- }
- else if (DataStorage.PAGE_UPDATED.equals(eventName))
- {
- removePage(page);
- addPage(page, false);
- }
- }
- }
-
- private void removePage(Page page)
- {
- Described described = page.adapt(Described.class);
- String name = described.getName();
-
- PageInfo pageInfo = pageInfos.get(name);
- if (pageInfo != null)
- {
- // remove page info
- pageInfos.remove(name);
- }
- }
-
- private static class PageInfo
- {
- private final String uuid;
- private final Map<String, String> childrenWindows = new HashMap<String, String>();
- private final String name;
-
- private PageInfo(String uuid, String name)
- {
- this.uuid = uuid;
- this.name = name;
- }
-
- public String getUUID()
- {
- return uuid;
- }
-
- public List<String> getChildrenWindows()
- {
- return new ArrayList<String>(childrenWindows.keySet());
- }
-
- public void addWindow(String windowName, String uuid)
- {
- // add suffix in case we have several windows with the same name in the page
- if (childrenWindows.containsKey(windowName))
- {
- if (windowName.endsWith("|"))
- {
- windowName += "|";
- }
- else
- {
- windowName += windowName + " |";
- }
- }
-
- childrenWindows.put(windowName, uuid);
- }
-
- public void updateWindowName(String oldWindowName, String newWindowName)
- {
- String windowUUID = getWindowUUID(oldWindowName);
- childrenWindows.remove(oldWindowName);
- childrenWindows.put(newWindowName, windowUUID);
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getWindowUUID(String windowId)
- {
- return childrenWindows.get(windowId);
- }
- }
-}
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-11-03 20:28:48 UTC (rev 4923)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -29,6 +29,7 @@
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.pc.ExoKernelIntegration;
+import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.services.listener.ListenerService;
import org.gatein.common.logging.Logger;
@@ -48,6 +49,9 @@
import org.gatein.portal.wsrp.state.producer.configuration.JCRProducerConfigurationService;
import org.gatein.portal.wsrp.state.producer.registrations.JCRRegistrationPersistenceManager;
import org.gatein.portal.wsrp.state.producer.state.JCRPortletStatePersistenceManager;
+import org.gatein.portal.wsrp.structure.MOPConsumerStructureProvider;
+import org.gatein.portal.wsrp.structure.MOPPortalStructureAccess;
+import org.gatein.portal.wsrp.structure.PortalStructureAccess;
import org.gatein.registration.RegistrationManager;
import org.gatein.registration.RegistrationPersistenceManager;
import org.gatein.registration.impl.RegistrationManagerImpl;
@@ -280,7 +284,9 @@
consumerRegistry.setSessionEventBroadcaster(sessionEventBroadcaster);
// create ConsumerStructureProvider and register it to listen to page events
- MOPConsumerStructureProvider structureprovider = new MOPConsumerStructureProvider(container);
+ POMSessionManager sessionManager = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ PortalStructureAccess structureAccess = new MOPPortalStructureAccess(sessionManager);
+ MOPConsumerStructureProvider structureprovider = new MOPConsumerStructureProvider(structureAccess);
listenerService.addListener(DataStorage.PAGE_CREATED, structureprovider);
listenerService.addListener(DataStorage.PAGE_REMOVED, structureprovider);
listenerService.addListener(DataStorage.PAGE_UPDATED, structureprovider);
Copied: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java (from rev 4915, portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/MOPConsumerStructureProvider.java)
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProvider.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.structure;
+
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.exoplatform.services.listener.Event;
+import org.exoplatform.services.listener.Listener;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIComponent;
+import org.gatein.mop.api.workspace.ui.UIContainer;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletStateType;
+import org.gatein.pc.api.StatefulPortletContext;
+import org.gatein.wsrp.api.context.ConsumerStructureProvider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPConsumerStructureProvider extends Listener<DataStorage, org.exoplatform.portal.config.model.Page> implements ConsumerStructureProvider
+{
+ private final PortalStructureAccess structureAccess;
+ private Map<String, PageInfo> pageInfos;
+ private boolean pagesHaveBeenInitialized;
+
+ public MOPConsumerStructureProvider(PortalStructureAccess structureAccess)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(structureAccess, "PortalStructureAccess");
+
+ this.structureAccess = structureAccess;
+ pageInfos = new HashMap<String, PageInfo>();
+ }
+
+ public List<String> getPageIdentifiers()
+ {
+ if (!pagesHaveBeenInitialized)
+ {
+ // initialize page information
+ Collection<Page> pages = structureAccess.getPages();
+ for (Page page : pages)
+ {
+ addPage(page);
+ }
+
+ pagesHaveBeenInitialized = true;
+ }
+
+ LinkedList<String> identifiers = new LinkedList<String>(pageInfos.keySet());
+ Collections.sort(identifiers);
+ return identifiers;
+ }
+
+ private void addPage(Page page)
+ {
+ Described described = page.adapt(Described.class);
+ PageInfo pageInfo = new PageInfo(page.getObjectId(), described.getName());
+ pageInfos.put(pageInfo.getName(), pageInfo);
+ UIContainer container = page.getRootComponent();
+ processContainer(container, pageInfo);
+
+ Collection<Page> children = page.getChildren();
+ if (ParameterValidation.existsAndIsNotEmpty(children))
+ {
+ for (Page child : children)
+ {
+ addPage(child);
+ }
+ }
+ }
+
+ public List<String> getWindowIdentifiersFor(String pageId)
+ {
+ PageInfo pageInfo = pageInfos.get(pageId);
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageInfo, "PageInfo for " + pageId);
+
+ return pageInfo.getChildrenWindows();
+ }
+
+ private void processContainer(UIContainer container, PageInfo pageInfo)
+ {
+ if (container != null)
+ {
+ List<UIComponent> components = container.getComponents();
+ for (UIComponent component : components)
+ {
+ ObjectType<? extends UIComponent> type = component.getObjectType();
+ if (ObjectType.WINDOW.equals(type))
+ {
+ Described described = component.adapt(Described.class);
+ String name = described.getName();
+
+ pageInfo.addWindow(name, component.getObjectId());
+ }
+ else if (ObjectType.CONTAINER.equals(type))
+ {
+ processContainer((UIContainer)component, pageInfo);
+ }
+ else
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public void assignPortletToWindow(PortletContext portletContext, String windowId, String pageId, String exportedPortletHandle)
+ {
+ PageInfo pageInfo = pageInfos.get(pageId);
+ String uuid = pageInfo.getWindowUUID(windowId);
+ ParameterValidation.throwIllegalArgExceptionIfNull(uuid, "UUID for " + windowId);
+
+ // get the window
+ UIWindow window = structureAccess.getWindowFrom(uuid);
+
+ // construct the new customization state
+ WSRP wsrp = new WSRP();
+ String portletId = portletContext.getId();
+ wsrp.setPortletId(portletId);
+ if (portletContext instanceof StatefulPortletContext)
+ {
+ StatefulPortletContext context = (StatefulPortletContext)portletContext;
+ if (PortletStateType.OPAQUE.equals(context.getType()))
+ {
+ wsrp.setState((byte[])context.getState());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());
+ }
+ }
+
+ // destroy existing customization as otherwise re-customizing will fail
+ Customization<?> customization = window.getCustomization();
+ customization.destroy();
+
+ // and re-customize
+ window.customize(WSRP.CONTENT_TYPE, portletId, wsrp);
+
+ // Change the window's name so that it's less confusing to users
+ Described described = window.adapt(Described.class);
+ String newName = exportedPortletHandle + " (remote)";
+ described.setName(newName); // should be the same as ApplicationRegistryService.REMOTE_DISPLAY_NAME_SUFFIX
+
+ // update window mappings
+ pageInfo.updateWindowName(windowId, newName);
+
+ structureAccess.saveChangesTo(window);
+ }
+
+ @Override
+ public void onEvent(Event<DataStorage, org.exoplatform.portal.config.model.Page> event) throws Exception
+ {
+ String eventName = event.getEventName();
+
+ // get the MOP page from the event data
+ org.exoplatform.portal.config.model.Page portalPage = event.getData();
+ Page page = structureAccess.getPageFrom(portalPage);
+
+ if (page != null)
+ {
+ if (DataStorage.PAGE_CREATED.equals(eventName))
+ {
+ // add information for new page
+ addPage(page);
+ }
+ else if (DataStorage.PAGE_REMOVED.equals(eventName))
+ {
+ removePage(page);
+ }
+ else if (DataStorage.PAGE_UPDATED.equals(eventName))
+ {
+ removePage(page);
+ addPage(page);
+ }
+ }
+ }
+
+ private void removePage(Page page)
+ {
+ Described described = page.adapt(Described.class);
+ String name = described.getName();
+
+ PageInfo pageInfo = pageInfos.get(name);
+ if (pageInfo != null)
+ {
+ // remove page info
+ pageInfos.remove(name);
+ }
+ }
+
+ private static class PageInfo
+ {
+ private final String uuid;
+ private final Map<String, String> childrenWindows = new HashMap<String, String>();
+ private final String name;
+
+ private PageInfo(String uuid, String name)
+ {
+ this.uuid = uuid;
+ this.name = name;
+ }
+
+ public String getUUID()
+ {
+ return uuid;
+ }
+
+ public List<String> getChildrenWindows()
+ {
+ return new ArrayList<String>(childrenWindows.keySet());
+ }
+
+ public void addWindow(String windowName, String uuid)
+ {
+ // add suffix in case we have several windows with the same name in the page
+ if (childrenWindows.containsKey(windowName))
+ {
+ if (windowName.endsWith("|"))
+ {
+ windowName += "|";
+ }
+ else
+ {
+ windowName += windowName + " |";
+ }
+ }
+
+ childrenWindows.put(windowName, uuid);
+ }
+
+ public void updateWindowName(String oldWindowName, String newWindowName)
+ {
+ String windowUUID = getWindowUUID(oldWindowName);
+ childrenWindows.remove(oldWindowName);
+ childrenWindows.put(newWindowName, windowUUID);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getWindowUUID(String windowId)
+ {
+ return childrenWindows.get(windowId);
+ }
+ }
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/MOPPortalStructureAccess.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.structure;
+
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.data.Mapper;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.Site;
+import org.gatein.mop.api.workspace.Workspace;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPPortalStructureAccess implements PortalStructureAccess
+{
+ private static final String PAGES_CHILD_NAME = "pages";
+ private final POMSessionManager pomManager;
+
+ public MOPPortalStructureAccess(POMSessionManager pomManager)
+ {
+ this.pomManager = pomManager;
+ }
+
+ public Collection<Page> getPages()
+ {
+ POMSession session = pomManager.getSession();
+ Workspace workspace = session.getWorkspace();
+ Collection<Site> sites = workspace.getSites(ObjectType.PORTAL_SITE);
+
+ List<Page> pages = new ArrayList<Page>(sites.size() * 10);
+
+ for (Site site : sites)
+ {
+ Page pagesRoot = getPagesFrom(site);
+ if (pagesRoot != null)
+ {
+ Collection<Page> children = pagesRoot.getChildren();
+ for (Page child : children)
+ {
+ pages.add(child);
+ }
+ }
+ }
+
+ return pages;
+ }
+
+ public UIWindow getWindowFrom(String uuid)
+ {
+ POMSession session = pomManager.getSession();
+ return session.findObjectById(ObjectType.WINDOW, uuid);
+ }
+
+ public void saveChangesTo(UIWindow window)
+ {
+ POMSession session = pomManager.getSession();
+
+ // mark page for cache invalidation otherwise DataCache will use the previous customization id when trying to set
+ // the portlet state in UIPortlet.setState and will not find it resulting in an error
+ Page page = window.getPage();
+ session.scheduleForEviction(new PageKey("portal", page.getSite().getName(), page.getName()));
+
+ // save
+ session.close(true);
+ }
+
+ public Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage)
+ {
+ POMSession session = pomManager.getSession();
+ Site site = session.getWorkspace().getSite(Mapper.parseSiteType(portalPage.getOwnerType()), portalPage.getOwnerId());
+ return getPagesFrom(site).getChild(portalPage.getName());
+ }
+
+ private Page getPagesFrom(Site site)
+ {
+ // a site contains a root page with templates and pages
+ // more info at http://code.google.com/p/chromattic/wiki/MOPUseCases
+
+ return site.getRootPage().getChild(PAGES_CHILD_NAME);
+ }
+}
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/structure/PortalStructureAccess.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.structure;
+
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public interface PortalStructureAccess
+{
+ Collection<Page> getPages();
+
+ UIWindow getWindowFrom(String uuid);
+
+ void saveChangesTo(UIWindow window);
+
+ Page getPageFrom(org.exoplatform.portal.config.model.Page portalPage);
+}
Added: portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java
===================================================================
--- portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java (rev 0)
+++ portal/trunk/component/wsrp/src/test/java/org/gatein/portal/wsrp/structure/MOPConsumerStructureProviderTestCase.java 2010-11-03 20:48:19 UTC (rev 4924)
@@ -0,0 +1,289 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.structure;
+
+import junit.framework.TestCase;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.mop.Described;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.exoplatform.services.listener.Event;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
+import org.gatein.mop.api.workspace.ui.UIComponent;
+import org.gatein.mop.api.workspace.ui.UIContainer;
+import org.gatein.mop.api.workspace.ui.UIWindow;
+import org.gatein.pc.api.PortletContext;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.*;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class MOPConsumerStructureProviderTestCase extends TestCase
+{
+ private MOPConsumerStructureProvider provider;
+ private PortalStructureAccess structureAccess;
+ private Page page1;
+
+ public void testGetPageIdentifiers()
+ {
+ List<String> pageIdentifiers = provider.getPageIdentifiers();
+ assertEquals(5, pageIdentifiers.size());
+ assertTrue(pageIdentifiers.contains("page1"));
+ assertTrue(pageIdentifiers.contains("page11"));
+ assertTrue(pageIdentifiers.contains("page12"));
+ assertTrue(pageIdentifiers.contains("page2"));
+ assertTrue(pageIdentifiers.contains("page21"));
+ }
+
+ public void testGetWindowIdentifiersForInexistingPage()
+ {
+ List<String> windows = provider.getWindowIdentifiersFor("inexisting");
+ assertTrue(windows.isEmpty());
+ }
+
+ public void testGetWindowIdentifiersFor()
+ {
+ checkWindows("page1", "window11", "window12");
+ checkWindows("page2");
+ checkWindows("page11", "window111", "window112");
+ checkWindows("page12", "window121");
+ checkWindows("page21", "window211");
+ }
+
+ public void testAssignPortletToWindow()
+ {
+ String newCustomizationId = "new";
+ String newWindowName = "portlet";
+ provider.assignPortletToWindow(PortletContext.createPortletContext(newCustomizationId), "window11", "page1", newWindowName);
+ verify(structureAccess).getWindowFrom(getIdFor("window11"));
+
+ UIWindow window11 = structureAccess.getWindowFrom(getIdFor("window11"));
+ verify(structureAccess).saveChangesTo(window11);
+
+ Described described = window11.adapt(Described.class);
+ verify(described).setName(newWindowName + " (remote)");
+
+ WSRP state = new WSRP();
+ state.setPortletId(newCustomizationId);
+ verify(window11).customize(WSRP.CONTENT_TYPE, newCustomizationId, state);
+
+ Customization<?> customization = window11.getCustomization();
+ assertEquals(WSRP.CONTENT_TYPE, customization.getType());
+ }
+
+ public void testPageCreationEvent() throws Exception
+ {
+ Page foo = createPage("foo", new String[]{"foo1"}, new String[]{"windowfoo1"});
+ Page foo1 = foo.getChild("foo1");
+ addWindows(foo1, "windowfoo11");
+ org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
+ when(structureAccess.getPageFrom(portalPage)).thenReturn(foo);
+
+ int pageNumber = provider.getPageIdentifiers().size();
+
+ provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_CREATED, null, portalPage));
+
+ List<String> identifiers = provider.getPageIdentifiers();
+ assertEquals(pageNumber + 2, identifiers.size());
+ assertTrue(identifiers.contains("foo"));
+ assertTrue(identifiers.contains("foo1"));
+
+ checkWindows("foo", "windowfoo1");
+ checkWindows("foo1", "windowfoo11");
+
+ assertEquals(foo1.getRootComponent().get("windowfoo11"), structureAccess.getWindowFrom(getIdFor("windowfoo11")));
+ }
+
+ public void testPageDeletionEvent() throws Exception
+ {
+ org.exoplatform.portal.config.model.Page portalPage = mock(org.exoplatform.portal.config.model.Page.class);
+ when(structureAccess.getPageFrom(portalPage)).thenReturn(page1);
+
+ int pageNumber = provider.getPageIdentifiers().size();
+
+ provider.onEvent(new Event<DataStorage, org.exoplatform.portal.config.model.Page>(DataStorage.PAGE_REMOVED, null, portalPage));
+
+ List<String> identifiers = provider.getPageIdentifiers();
+ assertEquals(pageNumber - 3, identifiers.size());
+ assertFalse(identifiers.contains("page1"));
+ assertFalse(identifiers.contains("page11"));
+ assertFalse(identifiers.contains("page12"));
+
+ assertNull(structureAccess.getWindowFrom(getIdFor("window11")));
+ assertNull(structureAccess.getWindowFrom(getIdFor("window12")));
+ assertNull(structureAccess.getWindowFrom(getIdFor("window111")));
+ assertNull(structureAccess.getWindowFrom(getIdFor("window112")));
+ assertNull(structureAccess.getWindowFrom(getIdFor("window121")));
+ }
+
+ public void testPageUpdatedEvent() throws Exception
+ {
+ // todo!
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ structureAccess = mock(PortalStructureAccess.class);
+
+ page1 = createPage("page1", new String[]{"page11", "page12"}, new String[]{"window11", "window12"});
+ Page page2 = createPage("page2", new String[]{"page21"}, null);
+
+ Page page11 = page1.getChild("page11");
+ addWindows(page11, "window111", "window112");
+
+ Page page12 = page1.getChild("page12");
+ addWindows(page12, "window121");
+
+ Page page21 = page2.getChild("page21");
+ addWindows(page21, "window211");
+
+ ArrayList<Page> pages = new ArrayList<Page>();
+ pages.add(page1);
+ pages.add(page11);
+ pages.add(page12);
+ pages.add(page2);
+ pages.add(page21);
+ when(structureAccess.getPages()).thenReturn(pages);
+
+ provider = new MOPConsumerStructureProvider(structureAccess);
+
+ // needed to initialize state
+ provider.getPageIdentifiers();
+ }
+
+ private void checkWindows(final String pageName, String... windowNames)
+ {
+ List<String> windows = provider.getWindowIdentifiersFor(pageName);
+
+ if (windowNames != null)
+ {
+ assertEquals(windowNames.length, windows.size());
+ for (String windowName : windowNames)
+ {
+ assertTrue(windows.contains(windowName));
+ }
+ }
+ }
+
+ private Page createPage(String name, String[] childrenPages, String[] windowNames)
+ {
+ Page page = mock(Page.class);
+
+ when(page.getName()).thenThrow(new RuntimeException("Page.getName returns the internal name, not the human readable one"));
+
+ // mock call to adapt
+ Described described = mock(Described.class);
+ when(described.getName()).thenReturn(name);
+
+ when(page.adapt(Described.class)).thenReturn(described);
+
+ if (childrenPages != null)
+ {
+ List<Page> children = new ArrayList<Page>(childrenPages.length);
+ for (String pageId : childrenPages)
+ {
+ Page childPage = createPage(pageId, null, null);
+ when(page.getChild(pageId)).thenReturn(childPage);
+ children.add(childPage);
+ }
+
+ when(page.getChildren()).thenReturn(children);
+ }
+
+ addWindows(page, windowNames);
+
+ return page;
+ }
+
+ private void addWindows(Page page, String... windowNames)
+ {
+ if (windowNames != null)
+ {
+ // mock page container
+ UIContainer root = mock(UIContainer.class);
+ when(page.getRootComponent()).thenReturn(root);
+
+ // for each provided window name, create a mock UIWindow...
+ List<UIComponent> children = new ArrayList<UIComponent>(windowNames.length);
+ for (String windowName : windowNames)
+ {
+ UIWindow window = mock(UIWindow.class);
+ when(window.getName()).thenThrow(new RuntimeException("Window.getName returns the internal name, not the human readable one"));
+ when(window.getObjectId()).thenReturn(getIdFor(windowName));
+
+ // need to use thenAnswer instead of thenReturn here because it doesn't play well with generics
+ when(window.getObjectType()).thenAnswer(new Answer<Object>()
+ {
+ public Object answer(InvocationOnMock invocationOnMock) throws Throwable
+ {
+ return ObjectType.WINDOW;
+ }
+ });
+
+ // mock call to adapt
+ Described described = mock(Described.class);
+ when(described.getName()).thenReturn(windowName);
+
+ when(window.adapt(Described.class)).thenReturn(described);
+
+ // mock Customization
+ final Customization<WSRP> customization = mock(Customization.class);
+ when(customization.getType()).thenReturn(WSRP.CONTENT_TYPE);
+ when(window.getCustomization()).thenAnswer(new Answer<Object>()
+ {
+ public Object answer(InvocationOnMock invocationOnMock) throws Throwable
+ {
+ return customization;
+ }
+ });
+
+ // add it to the list of windows for this page
+ children.add(window);
+
+ // make sure that we return the window when we ask for it from its uuid
+ when(structureAccess.getWindowFrom(getIdFor(windowName))).thenReturn(window);
+
+ // make sure that we return the window if we ask the root component for it
+ when(root.get(windowName)).thenReturn(window);
+ }
+
+ // the container should return the list of windows when asked for its components
+ when(root.getComponents()).thenReturn(children);
+ }
+ }
+
+ private String getIdFor(String windowName)
+ {
+ return windowName + "Id";
+ }
+}
14 years, 2 months
gatein SVN: r4923 - components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers.
by do-not-reply@jboss.org
Author: mwringe
Date: 2010-11-03 16:28:48 -0400 (Wed, 03 Nov 2010)
New Revision: 4923
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
Log:
GTNWSRP-146: Throw an error if we receive a null resourceURL instead of an NPE.
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2010-11-03 19:52:26 UTC (rev 4922)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationDispatcher.java 2010-11-03 20:28:48 UTC (rev 4923)
@@ -116,10 +116,14 @@
{
handler = resourceHandler;
}
- else
+ else if (resourceURL != null)
{
return performDirectURLRequest(resourceURL);
}
+ else
+ {
+ return new ErrorResponse("Did not get a resource URL or a resource ID, cannot fetch resource.");
+ }
}
else if (invocation instanceof EventInvocation)
{
14 years, 2 months
gatein SVN: r4922 - portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application.
by do-not-reply@jboss.org
Author: mwringe
Date: 2010-11-03 15:52:26 -0400 (Wed, 03 Nov 2010)
New Revision: 4922
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
Log:
GTNPORTAL-1629: fix NPE when dealing with ErrorResponse which don't contain a cause. Should use the error message if this is the case, or throw a generic exception if both are missing.
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-03 14:07:14 UTC (rev 4921)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-03 19:52:26 UTC (rev 4922)
@@ -388,7 +388,19 @@
if (portletResponse instanceof ErrorResponse)
{
ErrorResponse errorResponse = (ErrorResponse)portletResponse;
- throw (Exception)errorResponse.getCause();
+ if (errorResponse.getCause() != null)
+ {
+ throw (Exception)errorResponse.getCause();
+ }
+ else if (errorResponse.getMessage() != null)
+ {
+ throw new Exception("Received an error response with message : " + errorResponse.getMessage());
+ }
+ else
+ {
+ throw new Exception("Received an error response.");
+ }
+
}
else
{
14 years, 2 months
gatein SVN: r4921 - portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-11-03 10:07:14 -0400 (Wed, 03 Nov 2010)
New Revision: 4921
Modified:
portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java
Log:
GTNPORTAL-1626: Improve the writeTextData method in DOMSerializer
Modified: portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java 2010-11-03 13:55:37 UTC (rev 4920)
+++ portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java 2010-11-03 14:07:14 UTC (rev 4921)
@@ -168,6 +168,8 @@
private static void writeTextData(XMLStreamWriter writer, String data) throws XMLStreamException
{
+ StringBuilder builder = new StringBuilder();
+
for(int i = 0; i < data.length(); i++)
{
char c = data.charAt(i);
@@ -175,12 +177,14 @@
if(encodedValue == null)
{
- writer.writeCharacters("" + c);
+ builder.append(c);
}
else
{
- writer.writeCharacters(encodedValue);
+ builder.append(encodedValue);
}
}
+
+ writer.writeCharacters(builder.toString());
}
}
14 years, 2 months
gatein SVN: r4920 - in portal/branches/navcontroller: webui/portal/src/main/java/org/exoplatform/portal/url and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-11-03 09:55:37 -0400 (Wed, 03 Nov 2010)
New Revision: 4920
Added:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ControllerURL.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
Log:
introduce MimeType enum for configuring the mimetype for which the URL should be generated for
Modified: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ControllerURL.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ControllerURL.java 2010-11-03 11:45:36 UTC (rev 4919)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ControllerURL.java 2010-11-03 13:55:37 UTC (rev 4920)
@@ -47,6 +47,9 @@
/** . */
protected ParameterMap queryParams;
+ /** . */
+ protected MimeType mimeType;
+
/**
* Create a resource URL instance.
*
@@ -66,6 +69,7 @@
this.ajax = ajax;
this.confirm = null;
this.queryParams = null;
+ this.mimeType = null;
}
/**
@@ -144,6 +148,28 @@
return this;
}
+ /**
+ * Returns the current mime type that this URL will be generated for, or null if none is set (which means
+ * there is no guarantees about the mime type that will be used as target but it's likely to be {@link MimeType#XHTML}}).
+ *
+ * @return the current mime type
+ */
+ public MimeType getMimeType()
+ {
+ return mimeType;
+ }
+
+ /**
+ * Set the mime type on this URL. The mime type will be used when URL is generated to encode the URL for the specified
+ * mime type.
+ *
+ * @param mimeType the new mime type
+ */
+ public void setMimeType(MimeType mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
public Map<String, String[]> getQueryParameters()
{
if (queryParams == null)
Added: portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java (rev 0)
+++ portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/MimeType.java 2010-11-03 13:55:37 UTC (rev 4920)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.web.url;
+
+/**
+ * A simple mime type enumeration that is used when a URL is generated.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public enum MimeType
+{
+
+ XHTML, PLAIN
+
+}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-11-03 11:45:36 UTC (rev 4919)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-11-03 13:55:37 UTC (rev 4920)
@@ -26,8 +26,10 @@
import org.exoplatform.web.controller.QualifiedName;
import org.exoplatform.web.controller.router.SimpleRenderContext;
import org.exoplatform.web.url.ControllerURL;
+import org.exoplatform.web.url.MimeType;
import org.exoplatform.web.url.ResourceLocator;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
@@ -39,6 +41,15 @@
{
/** . */
+ private static final Map<MimeType, String> AMP_MAP = new EnumMap<MimeType, String>(MimeType.class);
+
+ static
+ {
+ AMP_MAP.put(MimeType.XHTML, "&");
+ AMP_MAP.put(MimeType.PLAIN, "&");
+ }
+
+ /** . */
private final ControllerContext controllerContext;
/** . */
@@ -93,8 +104,6 @@
}
//
-
- //
if (ajax)
{
buffer.append("javascript:");
@@ -137,13 +146,21 @@
controllerContext.renderURL(parameters, renderContext);
//
+ MimeType mt = mimeType;
+ if (mt == null)
+ {
+ mt = MimeType.XHTML;
+ }
+ String amp = AMP_MAP.get(mt);
+
+ //
boolean questionMarkDone = false;
Map<String, String> queryParams = renderContext.getQueryParams();
if (queryParams.size() > 0)
{
for (Map.Entry<String, String> entry : queryParams.entrySet())
{
- buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
+ buffer.append(questionMarkDone ? amp : "?");
buffer.append(entry.getKey());
buffer.append('=');
buffer.append(entry.getValue());
@@ -156,7 +173,7 @@
{
for (String value : entry.getValue())
{
- buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
+ buffer.append(questionMarkDone ? amp : "?");
buffer.append(entry.getKey());
buffer.append("=");
buffer.append(value);
@@ -167,7 +184,7 @@
//
if (ajax)
{
- buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
+ buffer.append(questionMarkDone ? amp : "?");
buffer.append("ajaxRequest=true");
buffer.append("')");
}
14 years, 2 months
gatein SVN: r4919 - in portal/branches/navcontroller: component/portal/src/main/java/org/exoplatform/portal/config and 23 other directories.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-11-03 07:45:36 -0400 (Wed, 03 Nov 2010)
New Revision: 4919
Added:
portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapTree.java
Removed:
portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java
portal/branches/navcontroller/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/FCKEditorPortlet/
portal/branches/navcontroller/portlet/web/src/main/webapp/WEB-INF/conf/portlet/web/PortalNavigationPortlet/
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap2.gtmpl
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
Modified:
portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/Constants.java
portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java
portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java
portal/branches/navcontroller/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl
portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl
portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl
portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
portal/branches/navcontroller/web/portal/src/main/webapp/index.jsp
portal/branches/navcontroller/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLProvider.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationResource.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
- Support to specify siteType and siteName in URL
- Clean up and improve the code
Modified: portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/Constants.java
===================================================================
--- portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/Constants.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/Constants.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -32,4 +32,6 @@
public static final String PORTAL_WINDOW_STATE = "portal:windowState";
public static final String PORTAL_PORTLET_MODE = "portal:portletMode";
+
+ public static final String QMARK = "?";
}
Modified: portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java
===================================================================
--- portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfig.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -27,68 +27,49 @@
public class UserPortalConfig
{
+ private String portalName;
+
+ private PortalConfig siteConfig;
- private PortalConfig portal;
-
private List<PageNavigation> navigations;
- /** Added by Minh Hoang TO */
- private PageNavigation selectedNavigation;
-
public UserPortalConfig()
{
}
- public UserPortalConfig(PortalConfig portal, List<PageNavigation> navigations)
+ public UserPortalConfig(PortalConfig siteConfig, List<PageNavigation> navigations)
{
- this.portal = portal;
+ this(null, siteConfig, navigations);
+ }
+
+ public UserPortalConfig(String portalName, PortalConfig siteConfig, List<PageNavigation> navigations)
+ {
+ this.portalName = portalName;
+ this.siteConfig = siteConfig;
this.navigations = navigations;
}
- public PortalConfig getPortalConfig()
+ public String getPortalName()
{
- return portal;
+ return portalName;
}
-
- public void setPortal(PortalConfig portal)
+
+ public void setPortalName(String name)
{
- this.portal = portal;
+ portalName = name;
}
- public void setSelectedNavigation(PageNavigation _selectedNavigation)
+ public PortalConfig getPortalConfig()
{
- this.selectedNavigation = _selectedNavigation;
+ return siteConfig;
}
- /** Fetch navigation (specified by ownerType, ownerId) from the list of all navigations and set it as selected navigation **/
- public void updateSelectedNavigation(String ownerType, String ownerId)
+ public void setPortal(PortalConfig portal)
{
- PageNavigation targetNavigation = null;
- for (PageNavigation nav : navigations)
- {
- if (nav.getOwnerType().equals(ownerType) && nav.getOwnerId().equals(ownerId))
- {
- targetNavigation = nav;
- break;
- }
- }
-
- if (targetNavigation != null)
- {
- this.setSelectedNavigation(targetNavigation);
- }
+ this.siteConfig = portal;
}
- public PageNavigation getSelectedNavigation()
- {
- if(this.selectedNavigation != null)
- {
- return this.selectedNavigation;
- }
- return navigations.get(0);
- }
-
public void setNavigations(List<PageNavigation> navs)
{
navigations = navs;
@@ -99,12 +80,28 @@
return navigations;
}
+ public PageNavigation getNavigation(String siteType, String siteName)
+ {
+ for (PageNavigation navi : navigations)
+ {
+ if (navi.getOwnerType().equals(siteType) && navi.getOwnerId().equals(siteName))
+ {
+ return navi;
+ }
+ }
+ return null;
+ }
+
public void addNavigation(PageNavigation nav)
{
- if (navigations == null)
- navigations = new ArrayList<PageNavigation>();
if (nav == null)
+ {
return;
+ }
+ if (navigations == null)
+ {
+ navigations = new ArrayList<PageNavigation>();
+ }
navigations.add(nav);
}
}
\ No newline at end of file
Modified: portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
--- portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -65,44 +65,29 @@
this.userACL_ = userACL;
}
- /**
- * <p> Build and returns an instance of <tt>UserPortalConfig</tt>. </p>
- * <p/>
- * <p> To return a valid config, the current thread must be associated with an identity that will grant him access to
- * the portal as returned by the {@link UserACL#hasPermission(org.exoplatform.portal.config.model.PortalConfig)}
- * method. </p>
- * <p/>
- * <p> The navigation loaded on the <tt>UserPortalConfig<tt> object are obtained according to the specified user
- * argument. The portal navigation is always loaded. If the specified user is null then the navigation of the guest
- * group as configured by {@link org.exoplatform.portal.config.UserACL#getGuestsGroup()} is also loaded, otherwise
- * the navigations are loaded according to the following rules:
- * <p/>
- * <ul> <li>The navigation corresponding to the user is loaded.</li> <li>When the user is root according to the value
- * returned by {@link org.exoplatform.portal.config.UserACL#getSuperUser()} then the navigation of all groups are
- * loaded.</li> <li>When the user is not root, then all its groups are added except the guest group as configued per
- * {@link org.exoplatform.portal.config.UserACL#getGuestsGroup()}.</li> </ul>
- * <p/>
- * All the navigations are sorted using the value returned by {@link org.exoplatform.portal.config.model.PageNavigation#getPriority()}.
- * </p>
- *
- * @param portalName the portal name
- * @param accessUser the user name
- * @return the config
- * @throws Exception any exception
- */
- public UserPortalConfig getUserPortalConfig(String portalName, String accessUser) throws Exception
+ public UserPortalConfig getUserPortalConfig(String siteType, String siteName, String accessUser) throws Exception
{
- PortalConfig portal = storage_.getPortalConfig(portalName);
- if (portal == null || !userACL_.hasPermission(portal))
+ PortalConfig siteConfig = storage_.getPortalConfig(siteType, siteName);
+ if (siteConfig == null || !userACL_.hasPermission(siteConfig))
{
return null;
}
List<PageNavigation> navigations = new ArrayList<PageNavigation>();
+ String portalName = null;
+ if (PortalConfig.PORTAL_TYPE.equals(siteType))
+ {
+ portalName = siteName;
+ }
+ else
+ {
+ portalName = getDefaultPortal();
+ }
+
PageNavigation navigation = storage_.getPageNavigation(PortalConfig.PORTAL_TYPE, portalName);
if (navigation != null)
{
- navigation.setModifiable(userACL_.hasPermission(portal.getEditPermission()));
+ navigation.setModifiable(userACL_.hasPermission(siteConfig.getEditPermission()));
navigations.add(navigation);
}
@@ -156,8 +141,38 @@
}
});
- return new UserPortalConfig(portal, navigations);
+ return new UserPortalConfig(portalName, siteConfig, navigations);
}
+
+ /**
+ * <p> Build and returns an instance of <tt>UserPortalConfig</tt>. </p>
+ * <p/>
+ * <p> To return a valid config, the current thread must be associated with an identity that will grant him access to
+ * the portal as returned by the {@link UserACL#hasPermission(org.exoplatform.portal.config.model.PortalConfig)}
+ * method. </p>
+ * <p/>
+ * <p> The navigation loaded on the <tt>UserPortalConfig<tt> object are obtained according to the specified user
+ * argument. The portal navigation is always loaded. If the specified user is null then the navigation of the guest
+ * group as configured by {@link org.exoplatform.portal.config.UserACL#getGuestsGroup()} is also loaded, otherwise
+ * the navigations are loaded according to the following rules:
+ * <p/>
+ * <ul> <li>The navigation corresponding to the user is loaded.</li> <li>When the user is root according to the value
+ * returned by {@link org.exoplatform.portal.config.UserACL#getSuperUser()} then the navigation of all groups are
+ * loaded.</li> <li>When the user is not root, then all its groups are added except the guest group as configued per
+ * {@link org.exoplatform.portal.config.UserACL#getGuestsGroup()}.</li> </ul>
+ * <p/>
+ * All the navigations are sorted using the value returned by {@link org.exoplatform.portal.config.model.PageNavigation#getPriority()}.
+ * </p>
+ *
+ * @param portalName the portal name
+ * @param accessUser the user name
+ * @return the config
+ * @throws Exception any exception
+ */
+ public UserPortalConfig getUserPortalConfig(String portalName, String accessUser) throws Exception
+ {
+ return getUserPortalConfig(PortalConfig.PORTAL_TYPE, portalName, accessUser);
+ }
/**
* Compute and returns the list that the specified user can manage. If the user is root then all existing groups are
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestDescriptorBuilder.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -53,13 +53,13 @@
//
assertTrue(i.hasNext());
RouteDescriptor route1 = i.next();
- assertEquals("/public/{{gtn}sitename}{{gtn}path:.*}", route1.getPath());
+ assertEquals("/public/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}", route1.getPath());
assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM, "portal"), route1.getParams());
//
assertTrue(i.hasNext());
RouteDescriptor route2 = i.next();
- assertEquals("/private/{{gtn}sitename}{{gtn}path:.*}", route2.getPath());
+ assertEquals("/private/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}", route2.getPath());
assertEquals(Collections.singletonMap(WebAppController.HANDLER_PARAM, "portal"), route2.getParams());
//
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/TestPortalConfiguration.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -43,28 +43,24 @@
RouterDescriptor routerMD = new RouterDescriptor();
//
- RouteDescriptor portalRouteMD = new RouteDescriptor("/private/{{gtn}sitename}{{gtn}path:.*}");
+ RouteDescriptor portalRouteMD = new RouteDescriptor("/private/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}");
portalRouteMD.addParam(new QualifiedName("gtn", "controller"), "site");
- portalRouteMD.addParam(new QualifiedName("gtn", "sitetype"), "portal");
portalRouteMD.addRequestParam(new QualifiedName("gtn", "componentid"), "portal:componentId", null, false);
routerMD.addRoute(portalRouteMD);
//
- RouteDescriptor portalRouteMD2 = new RouteDescriptor("/private/{{gtn}sitename}{{gtn}path:.*}");
+ RouteDescriptor portalRouteMD2 = new RouteDescriptor("/private/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}");
portalRouteMD2.addParam(new QualifiedName("gtn", "controller"), "site");
- portalRouteMD2.addParam(new QualifiedName("gtn", "sitetype"), "portal");
routerMD.addRoute(portalRouteMD2);
//
- RouteDescriptor groupRouteMD = new RouteDescriptor("/groups/{{gtn}sitename}{{gtn}path:.*}");
+ RouteDescriptor groupRouteMD = new RouteDescriptor("/groups/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}");
portalRouteMD.addParam(new QualifiedName("gtn", "controller"), "site");
- groupRouteMD.addParam(new QualifiedName("gtn", "sitetype"), "group");
routerMD.addRoute(groupRouteMD);
//
- RouteDescriptor userRouteMD = new RouteDescriptor("/users/{{gtn}sitename}{{gtn}path:.*}");
+ RouteDescriptor userRouteMD = new RouteDescriptor("/users/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}");
portalRouteMD.addParam(new QualifiedName("gtn", "controller"), "site");
- userRouteMD.addParam(new QualifiedName("gtn", "sitetype"), "user");
routerMD.addRoute(userRouteMD);
//
@@ -81,8 +77,8 @@
expectedParameters.put(new QualifiedName("gtn", "componentid"), "foo");
//
- assertEquals(expectedParameters, router.route("/private/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
- assertEquals("/private/classic/", router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/portal/classic/", Collections.singletonMap("portal:componentId", new String[]{"foo"})));
+ assertEquals("/private/portal/classic/", router.render(expectedParameters));
}
public void testPrivateClassic() throws Exception
@@ -94,13 +90,12 @@
expectedParameters.put(new QualifiedName("gtn", "path"), "");
//
- assertEquals(expectedParameters, router.route("/private/classic"));
- assertEquals("/private/classic", router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/portal/classic"));
+ assertEquals("/private/portal/classic", router.render(expectedParameters));
}
public void testPrivateClassicSlash() throws Exception
{
- router.route("/private/classic/");
Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
expectedParameters.put(new QualifiedName("gtn", "controller"), "site");
expectedParameters.put(new QualifiedName("gtn", "sitename"), "classic");
@@ -108,8 +103,8 @@
expectedParameters.put(new QualifiedName("gtn", "path"), "/");
//
- assertEquals(expectedParameters, router.route("/private/classic/"));
- assertEquals("/private/classic/", router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/portal/classic/"));
+ assertEquals("/private/portal/classic/", router.render(expectedParameters));
}
public void testPrivateClassicHome() throws Exception
@@ -121,7 +116,30 @@
expectedParameters.put(new QualifiedName("gtn", "path"), "/home");
//
- assertEquals(expectedParameters, router.route("/private/classic/home"));
- assertEquals("/private/classic/home", router.render(expectedParameters));
+ assertEquals(expectedParameters, router.route("/private/portal/classic/home"));
+ assertEquals("/private/portal/classic/home", router.render(expectedParameters));
}
+
+ public void testSiteType() throws Exception
+ {
+ Map<QualifiedName, String> expectedParameters = new HashMap<QualifiedName, String>();
+ expectedParameters.put(new QualifiedName("gtn", "controller"), "site");
+ expectedParameters.put(new QualifiedName("gtn", "sitetype"), "group");
+ expectedParameters.put(new QualifiedName("gtn", "sitename"), "platform_administrator");
+ expectedParameters.put(new QualifiedName("gtn", "path"), "/administration/registry");
+
+ //
+ assertEquals(expectedParameters, router.route("/private/group/platform_administrator/administration/registry"));
+ assertEquals("/private/group/platform_administrator/administration/registry", router.render(expectedParameters));
+
+ Map<QualifiedName, String> expectedParameters1 = new HashMap<QualifiedName, String>();
+ expectedParameters1.put(new QualifiedName("gtn", "controller"), "site");
+ expectedParameters1.put(new QualifiedName("gtn", "sitetype"), "user");
+ expectedParameters1.put(new QualifiedName("gtn", "sitename"), "root");
+ expectedParameters1.put(new QualifiedName("gtn", "path"), "/tab_0");
+
+ //
+ assertEquals(expectedParameters1, router.route("/private/user/root/tab_0"));
+ assertEquals("/private/user/root/tab_0", router.render(expectedParameters1));
+ }
}
Modified: portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml
===================================================================
--- portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/controller/src/test/java/org/exoplatform/web/controller/router/router.xml 2010-11-03 11:45:36 UTC (rev 4919)
@@ -3,11 +3,11 @@
xsi:schemaLocation="http://www.gatein.org/xml/ns/gatein_router_1_0 http://www.gatein.org/xml/ns/gatein_router_1_0"
xmlns="http://www.gatein.org/xml/ns/gatein_router_1_0">
- <route path="/public/{{gtn}sitename}{{gtn}path:.*}">
+ <route path="/public/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}">
<param name="{gtn}handler" value="portal"/>
</route>
- <route path="/private/{{gtn}sitename}{{gtn}path:.*}">
+ <route path="/private/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}">
<param name="{gtn}handler" value="portal"/>
</route>
Modified: portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
--- portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -87,7 +87,8 @@
/** Immutable and therefore thread safe. */
private static final Pattern BACKGROUND_PATTERN =
- Pattern.compile("(background.*:.*url" + LEFT_P + "['\"]?" + ")([^'\"]+)(" + "['\"]?" + RIGHT_P + ".*;)");
+ Pattern.compile("(background.*:.*url" + LEFT_P + "['\"]?"
+ + ")([^'\"]+)(" + "['\"]?" + RIGHT_P + ".*;)");
/** Immutable and therefore thread safe. */
private static final Pattern LT = Pattern.compile("/\\*\\s*orientation=lt\\s*\\*/");
@@ -101,6 +102,8 @@
/** One hour caching. */
private static final int ONE_HOUR = 3600;
+ public static final String DEFAULT_SKIN = "Default";
+
/** The deployer. */
private final AbstractResourceHandler deployer;
@@ -497,13 +500,13 @@
* Get SkinConfig by module and skin name
* @param module
* @param skinName
- * @return SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, "Default")
+ * @return SkinConfig by SkinKey(module, skinName), or SkinConfig by SkinKey(module, SkinService.DEFAULT_SKIN)
*/
public SkinConfig getSkin(String module, String skinName)
{
SkinConfig config = skinConfigs_.get(new SkinKey(module, skinName));
if (config == null)
- skinConfigs_.get(new SkinKey(module, "Default"));
+ skinConfigs_.get(new SkinKey(module, SkinService.DEFAULT_SKIN));
return config;
}
@@ -528,7 +531,7 @@
{
SkinKey key;
if (skinName.length() == 0)
- key = new SkinKey(module, "Default");
+ key = new SkinKey(module, DEFAULT_SKIN);
else
key = new SkinKey(module, skinName);
skinConfigs_.remove(key);
Modified: portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java
===================================================================
--- portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortalSkinTask.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -40,13 +40,11 @@
private static final String DEFAULT_MODULE_NAME = "CoreSkin";
- private static final String DEFAULT_SKIN_NAME = "Default";
-
private String moduleName;
public PortalSkinTask()
{
- super(DEFAULT_SKIN_NAME);
+ super(SkinService.DEFAULT_SKIN);
this.overwrite = true;
this.moduleName = DEFAULT_MODULE_NAME;
}
Modified: portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java
===================================================================
--- portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/component/web/resources/src/main/java/org/exoplatform/portal/resource/config/tasks/PortletSkinTask.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -44,7 +44,7 @@
public PortletSkinTask()
{
- super("Default");
+ super(SkinService.DEFAULT_SKIN);
this.overwrite = true;
}
Modified: portal/branches/navcontroller/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
===================================================================
--- portal/branches/navcontroller/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -70,7 +70,7 @@
PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
PortalRequestContext prc = (PortalRequestContext)context.getParentAppRequestContext();
UIPortalApplication portalApp = (UIPortalApplication)prc.getUIApplication();
- UIPortal portal = portalApp.getShowedUIPortal();
+ UIPortal portal = portalApp.getCurrentSite();
//
try
Modified: portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
--- portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -26,11 +26,11 @@
import org.exoplatform.portal.config.Query;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
import org.exoplatform.portal.webui.navigation.UINavigationManagement;
import org.exoplatform.portal.webui.navigation.UINavigationNodeSelector;
import org.exoplatform.portal.webui.page.UIPageNodeForm;
@@ -53,8 +53,8 @@
import org.exoplatform.webui.core.UIPopupWindow;
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.Event.Phase;
import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.event.Event.Phase;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -82,7 +82,7 @@
public static String[] ACTIONS = {"EditNavigation", "DeletePortal", "EditPortalLayout"};
- private LazyPageList pageList;
+ private LazyPageList<PortalConfig> pageList;
private PageNavigation selectedNavigation;
@@ -142,7 +142,7 @@
}
}
- this.pageList = new LazyPageList(new ListAccess<PortalConfig>()
+ this.pageList = new LazyPageList<PortalConfig>(new ListAccess<PortalConfig>()
{
public int getSize() throws Exception
@@ -208,7 +208,7 @@
UISiteManagement uicomp = event.getSource();
String portalName = event.getRequestContext().getRequestParameter(OBJECTID);
- UserPortalConfigService service = event.getSource().getApplicationComponent(UserPortalConfigService.class);
+ UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
String defaultPortalName = service.getDefaultPortal();
PortalRequestContext prContext = Util.getPortalRequestContext();
@@ -221,17 +221,23 @@
return;
}
- UserPortalConfig config = service.getUserPortalConfig(portalName, prContext.getRemoteUser());
- if (config != null && config.getPortalConfig().isModifiable())
+ DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
+ UserACL acl = uicomp.getApplicationComponent(UserACL.class);
+
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
+ if (pConfig != null)
{
- service.removeUserPortalConfig(portalName);
+ if (acl.hasPermission(pConfig))
+ {
+ service.removeUserPortalConfig(portalName);
+ }
+ else
+ {
+ uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
+ new String[]{pConfig.getName()}));;
+ return;
+ }
}
- else if (config != null)
- {
- uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
- new String[]{config.getPortalConfig().getName()}));;
- return;
- }
else
{
if (uicomp.stillKeptInPageList(portalName))
@@ -242,14 +248,14 @@
return;
}
- if (config == null && !Util.getUIPortal().getName().equals(portalName))
+ if (pConfig == null && !Util.getUIPortal().getName().equals(portalName))
{
uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
new String[]{portalName}));
return;
}
- if (config == null || Util.getUIPortal().getName().equals(portalName))
+ if (pConfig == null || Util.getUIPortal().getName().equals(portalName))
{
HttpServletRequest request = prContext.getRequest();
request.getSession().invalidate();
@@ -270,25 +276,24 @@
{
UISiteManagement uicomp = event.getSource();
String portalName = event.getRequestContext().getRequestParameter(OBJECTID);
- UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
+ DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
PortalRequestContext prContext = Util.getPortalRequestContext();
UIPortalApplication portalApp = (UIPortalApplication)prContext.getUIApplication();
- UserPortalConfig userConfig = service.getUserPortalConfig(portalName, prContext.getRemoteUser());
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
- if (userConfig == null)
+ if (pConfig == null)
{
portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.portal-not-exist",
new String[]{portalName}));
return;
}
- PortalConfig portalConfig = userConfig.getPortalConfig();
UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- if (!userACL.hasEditPermission(portalConfig))
+ if (!userACL.hasEditPermission(pConfig))
{
portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission",
- new String[]{portalConfig.getName()}));
+ new String[]{pConfig.getName()}));
return;
}
@@ -306,7 +311,7 @@
uiWorkingWS.setBackupUIPortal(uiPortal);
UIPortal editPortal = uiWorkingWS.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(editPortal, userConfig);
+ PortalDataMapper.toUIPortal(editPortal, pConfig);
uiEditWS.setUIComponent(editPortal);
// Check if edit current portal
@@ -317,6 +322,10 @@
UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
siteBody.setUIComponent(null);
}
+ else
+ {
+ editPortal.setNavigation(portalApp.getNavigation(PortalConfig.PORTAL_TYPE, portalName));
+ }
editPortal.refreshUIPage();
portalApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
@@ -339,9 +348,9 @@
//Minh Hoang TO: User could edit navigation if he/she has edit permissions on PortalConfig. That is not
//at all logical and should be modified after release 3.1 GA
- UserPortalConfigService configService = uicomp.getApplicationComponent(UserPortalConfigService.class);
- UserPortalConfig userPortalConfig = configService.getUserPortalConfig(portalName, context.getRemoteUser());
- if(userPortalConfig == null)
+ DataStorage configService = uicomp.getApplicationComponent(DataStorage.class);
+ PortalConfig pConfig = configService.getPortalConfig(portalName);
+ if(pConfig == null)
{
uiApplication.addMessage(new ApplicationMessage("UISiteManagement.msg.portal-not-exist",
new String[]{portalName}));
@@ -349,7 +358,7 @@
}
UserACL userACL = uicomp.getApplicationComponent(UserACL.class);
- if (!userACL.hasEditPermission(userPortalConfig.getPortalConfig()))
+ if (!userACL.hasEditPermission(pConfig))
{
uiApplication.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));;
return;
Modified: portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java
===================================================================
--- portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarDashboardPortlet.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -26,9 +26,12 @@
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.url.navigation.NavigationLocator;
+import org.exoplatform.portal.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.exoplatform.web.url.ControllerURL;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIComponent;
@@ -103,12 +106,13 @@
{
createDashboard(nodeName, cachedNavigation, configService);
}
- else
- {
- PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.getResponse().sendRedirect(
- prContext.getPortalURI() + cachedNavigation.getNodes().get(0).getName());
- }
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+
+ ControllerURL<NavigationResource, NavigationLocator> nodeURL =
+ pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
+ nodeURL.setResource(new NavigationResource(PortalConfig.USER_TYPE, pcontext.getRemoteUser(), cachedNavigation
+ .getNodes().get(0)));
+ pcontext.sendRedirect(nodeURL.toString());
}
private static void createDashboard(String _nodeName, PageNavigation _pageNavigation,
@@ -138,8 +142,6 @@
_pageNavigation.addNode(pageNode);
_configService.create(page);
_configService.update(_pageNavigation);
-
- prContext.getResponse().sendRedirect(prContext.getPortalURI() + _nodeName);
}
catch (Exception ex)
{
Modified: portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl
===================================================================
--- portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarDashboardPortlet.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -4,6 +4,10 @@
import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.portal.webui.util.Util ;
import org.exoplatform.webui.organization.OrganizationUtils;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.ControllerURL;
+ import org.exoplatform.portal.url.navigation.NavigationResource;
+ import org.exoplatform.portal.config.model.PortalConfig;
def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
@@ -12,8 +16,11 @@
jsmanager.addCustomizedOnLoadScript('eXo.portal.UIAdminToolbar.onLoad("' + uicomponent.id + '");');
def currentUserNavigation = uicomponent.getCurrentUserNavigation();
- def portalURI = Util.getPortalRequestContext().getPortalURI();
- void renderDashboards(){
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ ControllerURL nodeURL = pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
+
+ void renderDashboards(ControllerURL nodeURL, PortalRequestContext pcontext){
PageNavigation userNavigation = uicomponent.getCurrentUserNavigation();
if(userNavigation == null){
return;
@@ -31,7 +38,7 @@
<div class="SubBlock">
""";
for(int i = 0; i < size; i++) {
- renderPageNode( nodes.get(i), i%2 == 0);
+ renderPageNode(nodeURL, nodes.get(i), pcontext);
}
print """
</div>
@@ -39,7 +46,7 @@
""" ;
}
- void renderPageNode(PageNode node, boolean flag) {
+ void renderPageNode(ControllerURL nodeURL, PageNode node, PortalRequestContext pcontext) {
PageNode selectedNode = uicomponent.getSelectedPageNode();
String tabStyleNavigation = "";
if(selectedNode != null && node.getUri() == selectedNode.getUri()) {
@@ -49,7 +56,7 @@
boolean hasChild = (node.getChildren() != null && node.getChildren().size() > 0);
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String href = Util.getPortalRequestContext().getPortalURI() + node.getUri();
+ String href = nodeURL.setResource(new NavigationResource(PortalConfig.USER_TYPE, pcontext.getRemoteUser(), node)).toString();
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
boolean toolong = (node.resolvedLabel.length() > 60);
@@ -90,9 +97,8 @@
%>
<%
- String defaultDashboardPage;
if(currentUserNavigation.getNodes() ==null || currentUserNavigation.getNodes().size() < 1){
- defaultDashboardPage = org.exoplatform.toolbar.webui.component.UIUserToolBarDashboardPortlet.DEFAULT_TAB_NAME;
+ String defaultDashboardPage = org.exoplatform.toolbar.webui.component.UIUserToolBarDashboardPortlet.DEFAULT_TAB_NAME;
%>
<div class="UIUserToolBarDashboardPortlet" id="$uicomponent.id">
<div class="UIHorizontalTabs">
@@ -107,16 +113,17 @@
</div>
<%
}else{
- defaultDashboardPage = currentUserNavigation.getNodes().get(0).getName();
+ def firstNode = currentUserNavigation.getNodes().get(0);
+ String link = nodeURL.setResource(new NavigationResource(PortalConfig.USER_TYPE, pcontext.getRemoteUser(), firstNode)).toString();
%>
<div class="UIUserToolBarDashboardPortlet" id="$uicomponent.id" >
<div class="UIHorizontalTabs">
<div class="TabsContainer" >
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="DashboardIcon TBIcon" href="<%= portalURI + defaultDashboardPage %>">Dashboard</a>
+ <a class="DashboardIcon TBIcon" href="$link">Dashboard</a>
</div>
- <% renderDashboards(); %>
+ <% renderDashboards(nodeURL, pcontext); %>
</div>
</div>
</div>
Modified: portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl
===================================================================
--- portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarGroupPortlet.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -8,6 +8,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.web.url.ControllerURL;
import org.exoplatform.portal.url.navigation.NavigationResource;
+ import org.exoplatform.portal.config.model.PortalConfig;
def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
@@ -30,14 +31,14 @@
<div class="SubBlock">
""" ;
for(int i = 0; i < nodes.size(); i++) {
- renderPageNode(nodes.get(i), nodeURL) ;
+ renderPageNode(navigation, nodes.get(i), nodeURL) ;
}
print """
</div>
""" ;
}
- void renderPageNode(PageNode node, ControllerURL nodeURL) {
+ void renderPageNode(PageNavigation navigation, PageNode node, ControllerURL nodeURL) {
PageNode selectedNode = uicomponent.getSelectedPageNode();
String tabStyleNavigation = "";
if(selectedNode != null && node.getUri() == selectedNode.getUri()) {
@@ -47,7 +48,7 @@
boolean hasChild = (node.getChildren() != null && node.getChildren().size() > 0);
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String actionLink = nodeURL.setResource(new NavigationResource(node)).toString();
+ String actionLink = nodeURL.setResource(new NavigationResource(navigation.getOwnerType(), navigation.getOwnerId().replaceAll("/", "_"), node)).toString();
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
boolean toolong = (node.resolvedLabel.length() > 60);
@@ -75,7 +76,7 @@
<div class="SubBlock">
""" ;
for(int j = 0; j < node.getChildren().size(); j++) {
- renderPageNode(node.getChildren().get(j), nodeURL);
+ renderPageNode(navigation, node.getChildren().get(j), nodeURL);
}
print """
</div>
@@ -96,7 +97,7 @@
<div class="TabsContainer">
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="GroupIcon TBIcon" href="<%=nodeURL.setResource(new NavigationResource(groupNaviNode)).toString() %>">Group</a>
+ <a class="GroupIcon TBIcon" href="<%=nodeURL.setResource(new NavigationResource(PortalConfig.PORTAL_TYPE, portalNavigation.getOwnerId(), groupNaviNode)).toString() %>">Group</a>
</div>
<% if (!groupNavigations.isEmpty()) { %>
<div style="display:none" class="MenuItemContainer">
Modified: portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl
===================================================================
--- portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/exoadmin/src/main/webapp/groovy/admintoolbar/webui/component/UIUserToolBarSitePortlet.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -8,7 +8,8 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.web.url.ControllerURL;
import org.exoplatform.portal.url.navigation.NavigationResource;
-
+ import org.exoplatform.portal.config.model.PortalConfig;
+
def rcontext = _ctx.getRequestContext() ;
JavascriptManager jsmanager = rcontext.getJavascriptManager();
jsmanager.importJavascript('eXo.portal.UIPortalNavigation') ;
@@ -28,22 +29,22 @@
String clazz = "";
String href = "#";
for(int i = 0; i < uicomponent.getAllPortalNames().size(); i++) {
- String portal = uicomponent.getAllPortalNames().get(i);
- if(portal.equals(pcontext.getPortalOwner())) {
+ String portalName = uicomponent.getAllPortalNames().get(i);
+ if(portalName.equals(pcontext.getPortalOwner())) {
isCurrent = true;
} else isCurrent = false;
- nodeURL.setResource(new NavigationResource(portal, null));
+ nodeURL.setResource(new NavigationResource(PortalConfig.PORTAL_TYPE, portalName, null));
if(isCurrent) clazz = "class='ArrowIcon'";
else clazz = "";
href = nodeURL.toString();
EntityEncoder entityEncoder = EntityEncoder.FULL;
- portal = entityEncoder.encode(portal);
+ portalName = entityEncoder.encode(portalName);
print """
<div class="MenuItem">
<div $clazz>
- <a href="$href" class="ItemIcon SiteIcon">$portal</a>
+ <a href="$href" class="ItemIcon SiteIcon">$portalName</a>
</div>
""";
if(isCurrent) {
@@ -85,7 +86,7 @@
boolean hasChild = (node.getChildren() != null && node.getChildren().size() > 0);
String clazz = "";
if(hasChild) clazz = "ArrowIcon";
- String href = nodeURL.setResource(new NavigationResource(null, node)).toString();
+ String href = nodeURL.setResource(new NavigationResource("portal", null, node)).toString();
String icon = node.getIcon();
if(icon == null) icon = "DefaultPageIcon";
boolean toolong = (node.resolvedLabel.length() > 60);
@@ -134,7 +135,7 @@
<div class="TabsContainer">
<div class="UITab NormalToolbarTab">
<div class="">
- <a class="SitesIcon TBIcon" href="<%= nodeURL.setResource(new NavigationResource(portalNavigationNode)).toString() %>">
+ <a class="SitesIcon TBIcon" href="<%= nodeURL.setResource(new NavigationResource(PortalConfig.PORTAL_TYPE, navigation.getOwnerId(), portalNavigationNode)).toString() %>">
Site
</a>
</div>
Deleted: portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java
===================================================================
--- portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UIPortalNavigationPortlet.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -1,50 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.portal.webui.component;
-
-import org.exoplatform.portal.webui.navigation.UIPortalNavigation2;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.application.portlet.PortletRequestContext;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.ComponentConfigs;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIPortletApplication;
-import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-
-@ComponentConfigs({
- @ComponentConfig(lifecycle = UIApplicationLifecycle.class),
- @ComponentConfig(type = UIPortalNavigation2.class, id = "UIHorizontalNavigation", events = @EventConfig(listeners = UIPortalNavigation2.SelectNodeActionListener.class))})
-public class UIPortalNavigationPortlet extends UIPortletApplication
-{
- public UIPortalNavigationPortlet() throws Exception
- {
- PortletRequestContext context = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
- PortletRequest prequest = context.getRequest();
- PortletPreferences prefers = prequest.getPreferences();
- String template = prefers.getValue("template", "app:/groovy/portal/webui/component/UIPortalNavigation2.gtmpl");
-
- UIPortalNavigation2 portalNavigation = addChild(UIPortalNavigation2.class, "UIHorizontalNavigation", null);
- portalNavigation.setUseAjax(Boolean.valueOf(prefers.getValue("useAJAX", "true")));
- portalNavigation.setTemplate(template);
- }
-}
\ No newline at end of file
Modified: portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java
===================================================================
--- portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapPortlet.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -38,13 +38,18 @@
* Jul 3, 2006
*/
@ComponentConfigs({
- @ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "system:/groovy/webui/core/UISitemap2.gtmpl"),
- @ComponentConfig(type = UIPortalNavigation.class, id = "UISiteMap", events = {
- @EventConfig(listeners = UIPortalNavigation.SelectNodeActionListener.class),
- @EventConfig(listeners = UIPortalNavigation.ExpandAllNodeActionListener.class),
- @EventConfig(listeners = UIPortalNavigation.CollapseAllNodeActionListener.class),
- @EventConfig(listeners = UIPortalNavigation.CollapseNodeActionListener.class),
- @EventConfig(listeners = UIPortalNavigation.ExpandNodeActionListener.class)})})
+ @ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "system:/groovy/webui/core/UISitemap.gtmpl"),
+ @ComponentConfig(
+ type = UISitemapTree.class,
+ events = {
+ @EventConfig(listeners = UIPortalNavigation.SelectNodeActionListener.class),
+ @EventConfig(listeners = UISitemapTree.ExpandAllNodeActionListener.class),
+ @EventConfig(listeners = UISitemapTree.CollapseAllNodeActionListener.class),
+ @EventConfig(listeners = UISitemapTree.CollapseNodeActionListener.class),
+ @EventConfig(listeners = UISitemapTree.ExpandNodeActionListener.class)}
+ )
+ }
+)
public class UISitemapPortlet extends UIPortletApplication
{
@@ -56,9 +61,9 @@
PortletPreferences prefers = prequest.getPreferences();
String template = prefers.getValue("template", "system:/groovy/webui/core/UISitemapTree.gtmpl");
- UIPortalNavigation uiPortalNavigation = addChild(UIPortalNavigation.class, "UISiteMap", null);
- uiPortalNavigation.loadTreeNodes();
- uiPortalNavigation.setTemplate(template);
+ UISitemapTree uiSitemapTree = addChild(UISitemapTree.class, null, null);
+ uiSitemapTree.loadTreeNodes();
+ uiSitemapTree.setTemplate(template);
}
public boolean isUseAjax()
Added: portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapTree.java
===================================================================
--- portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapTree.java (rev 0)
+++ portal/branches/navcontroller/portlet/web/src/main/java/org/exoplatform/portal/webui/component/UISitemapTree.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -0,0 +1,234 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * 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.exoplatform.portal.webui.component;
+
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.portal.webui.navigation.PageNavigationUtils;
+import org.exoplatform.portal.webui.navigation.TreeNode;
+import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
+import org.exoplatform.portal.webui.portal.UIPortal;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="trongtt(a)gmail.com">Trong Tran</a>
+ * @version $Revision$
+ */
+public class UISitemapTree extends UIPortalNavigation
+{
+ private TreeNode treeNode_;
+
+ public void loadTreeNodes() throws Exception
+ {
+ WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ treeNode_ = new TreeNode(new PageNode(), new PageNavigation(), true);
+ List<PageNavigation> listNavigations = Util.getUIPortalApplication().getNavigations();
+
+ for (PageNavigation nav : rearrangeNavigations(listNavigations))
+ {
+ if (!isShowUserNavigation() && nav.getOwnerType().equals("user"))
+ {
+ continue;
+ }
+ PageNavigation filteredNav = PageNavigationUtils.filter(nav, context.getRemoteUser());
+ treeNode_.setChildren(filteredNav.getNodes(), filteredNav);
+ }
+ }
+
+ private List<PageNavigation> rearrangeNavigations(List<PageNavigation> listNavigation)
+ {
+ List<PageNavigation> returnNavs = new ArrayList<PageNavigation>();
+
+ List<PageNavigation> portalNavs = new ArrayList<PageNavigation>();
+ List<PageNavigation> groupNavs = new ArrayList<PageNavigation>();
+ List<PageNavigation> userNavs = new ArrayList<PageNavigation>();
+
+ for (PageNavigation nav : listNavigation)
+ {
+ String ownerType = nav.getOwnerType();
+ if (PortalConfig.PORTAL_TYPE.equals(ownerType))
+ {
+ portalNavs.add(nav);
+ }
+ else if (PortalConfig.GROUP_TYPE.equals(ownerType))
+ {
+ groupNavs.add(nav);
+ }
+ else if (PortalConfig.USER_TYPE.equals(ownerType))
+ {
+ userNavs.add(nav);
+ }
+ }
+
+ returnNavs.addAll(portalNavs);
+ returnNavs.addAll(groupNavs);
+ returnNavs.addAll(userNavs);
+
+ return returnNavs;
+ }
+
+ public TreeNode getTreeNodes()
+ {
+ return treeNode_;
+ }
+
+ static public class ExpandNodeActionListener extends EventListener<UISitemapTree>
+ {
+ public void execute(Event<UISitemapTree> event) throws Exception
+ {
+ UISitemapTree uiNavigation = event.getSource();
+
+ TreeNode treeNode = uiNavigation.getTreeNodes();
+ List<PageNavigation> all_Navigations = Util.getUIPortalApplication().getNavigations();
+
+ // get URI
+ String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+ int index = uri.lastIndexOf("::");
+ String id = uri.substring(index + 2);
+
+ // get PageNavigation by uri
+ PageNavigation selectNav = null;
+
+ String navId = uri.substring(0, index);
+ selectNav = PageNavigationUtils.findNavigationByID(all_Navigations, Integer.parseInt(navId));
+ if(selectNav == null)
+ {
+ return;
+ }
+
+ // get PageNode by uri
+ PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
+
+ TreeNode expandTree = null;
+ if (treeNode.getChildren() != null)
+ {
+ expandTree = treeNode.getChildByPath(uri, treeNode);
+ }
+
+ if(expandTree != null)
+ {
+ expandTree.setChildren(expandNode.getChildren(), selectNav);
+ }
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
+ }
+ }
+
+ static public class CollapseNodeActionListener extends EventListener<UISitemapTree>
+ {
+ public void execute(Event<UISitemapTree> event) throws Exception
+ {
+ UISitemapTree uiNavigation = event.getSource();
+
+ TreeNode treeNode = uiNavigation.getTreeNodes();
+ UIPortal uiPortal = Util.getUIPortal();
+
+ // get URI
+ String uri = event.getRequestContext().getRequestParameter(OBJECTID);
+
+ int index = uri.lastIndexOf("::");
+ String id = uri.substring(index + 2);
+
+ // get PageNavigation by uri
+ PageNavigation selectNav = null;
+
+ String navId = uri.substring(0, index);
+
+ //TODO: Minh Hoang TO
+ //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
+ selectNav = uiPortal.getNavigation();
+
+ // get PageNode by uri
+ PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
+
+ TreeNode expandTree = null;
+ if (treeNode.getChildren() != null)
+ {
+ expandTree = treeNode.getChildByPath(uri, treeNode);
+ }
+
+ if(expandTree != null)
+ {
+ expandTree.setExpanded(false);
+ }
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
+ }
+ }
+
+ static public class CollapseAllNodeActionListener extends EventListener<UISitemapTree>
+ {
+ public void execute(Event<UISitemapTree> event) throws Exception
+ {
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ UISitemapTree uiNavigation = event.getSource();
+
+ uiNavigation.loadTreeNodes();
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
+ }
+ }
+
+ static public class ExpandAllNodeActionListener extends EventListener<UISitemapTree>
+ {
+ public void execute(Event<UISitemapTree> event) throws Exception
+ {
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ UISitemapTree uiNavigation = event.getSource();
+ // reload TreeNodes
+ uiNavigation.loadTreeNodes();
+ TreeNode treeNode = uiNavigation.getTreeNodes();
+
+ expandAllNode(treeNode);
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
+ }
+
+ private void expandAllNode(TreeNode treeNode) throws Exception
+ {
+
+ if (treeNode.getChildren().size() > 0)
+ {
+ for (TreeNode child : treeNode.getChildren())
+ {
+ PageNode expandNode = child.getNode();
+ PageNavigation selectNav = child.getNavigation();
+
+ // set node to child tree
+ if (expandNode.getChildren().size() > 0)
+ {
+ child.setChildren(expandNode.getChildren(), selectNav);
+ }
+
+ // expand child tree
+ expandAllNode(child);
+ }
+ }
+ }
+ }
+}
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/conf/default-router.xml 2010-11-03 11:45:36 UTC (rev 4919)
@@ -23,12 +23,12 @@
-->
<!-- The public access -->
- <route path="/public/{{gtn}sitename}{{gtn}path:.*}">
+ <route path="/public/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}">
<param name="{gtn}access" value="public"/>
</route>
<!-- The private access -->
- <route path="/private/{{gtn}sitename}{{gtn}path:.*}">
+ <route path="/private/{{gtn}sitetype}/{{gtn}sitename}{{gtn}path:.*}">
<param name="{gtn}access" value="private"/>
</route>
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -1,236 +1,7 @@
-<div class="UISitemap">
- <div class="ClearFix">
- <div class="CollapseAll FloatLeft">Collapse All</div>
- <div class="ExpandAll FloatLeft">Expand All</div>
- </div>
- <div class="SitemapContent">
- <div class="UISiteTree">
-
- <div class="Node ClearFix">
- <div class="ExpandIcon FloatLeft">
- <a class="NodeIcon DefaultPageIcon" href="#">Home</a>
- </div>
- </div>
-
- <div class="Node ClearFix">
- <div class="ExpandIcon FloatLeft">
- <a class="NodeIcon DefaultPageIcon" href="#">Web Explorer</a>
- </div>
- </div>
-
- <div class="Node ClearFix">
- <div class="CollapseIcon FloatLeft">
- <a class="NodeIcon DefaultPageIcon" href="#">My Link</a>
- </div>
-
- <div class="ChildrenContainer FloatLeft">
- <div class="Node ClearFix">
- <div class="ExpandIcon FloatLeft">
- <a class="NodeIcon DefaultPageIcon" href="#">Blog</a>
- </div>
- </div>
- <div class="LastNode Node ClearFix">
- <div class="CollapseIcon FloatLeft">
- <a class="NodeIcon DefaultPageIcon" href="#">Facebook</a>
- </div>
-
- <div class="ChildrenContainer FloatLeft">
- <div class="Node ClearFix">
- <div class="NullItem">
- <div class="">
- <a class="NodeIcon DefaultPageIcon" href="#">Samples link</a>
- </div>
- </div>
- </div>
- <div class="LastNode Node ClearFix">
- <div class="NullItem"><a class="NodeIcon DefaultPageIcon" href="#">Samples link</a></div>
- </div>
- </div>
-
- </div>
- </div><!--end ChildrenContainer-->
-
- </div><!--end Node-->
-
- <div class="Node ClearFix">
- <div class="ExpandIcon FloatLeft"><a class="NodeIcon DefaultPageIcon" href="#">Register</a></div>
- </div>
-
- <div class="LastNode Node ClearFix">
- <div class="ExpandIcon"><a class="NodeIcon DefaultPageIcon" href="#">Link</a></div>
- </div>
-
- </div>
- </div>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<!--
-<%
- import org.exoplatform.webui.core.UIPortletApplication;
- import org.exoplatform.portal.config.model.PageNode;
- import org.exoplatform.portal.application.PortalRequestContext;
- import org.exoplatform.portal.webui.util.Util;
-%>
-<%
- def navigations = uicomponent.getNavigations();
- PortalRequestContext pcontext = Util.getPortalRequestContext();
- def String portalURI = pcontext.getPortalURI();
-
- UIPortletApplication siteMapPortlet = uicomponent.getParent();
- def useAJAX = siteMapPortlet.isUseAjax();
-
- public void renderNextLevelNode(nav, children, int intLevel, String portalUri, boolean useAjax) {
- if(intLevel > 4) return;
-
- for(PageNode node in children) {
- String actionLink;
- if(useAjax){
- actionLink = uicomponent.event("SelectNode", nav.getId() + "::" + node.getUri());
- }else{
- actionLink = portalUri + node.getUri();
- }
- String iconType = node.getIcon();
- if(iconType == null) {
- iconType = "DefaultPageIcon";
- }
-
- if(intLevel == 4) {
- println """
- <div class="Item">
- <div class="Level$intLevel">
- <div class="OverflowContainer">
- <a class="IconItem ${iconType}" href="javascript: void(0);">...</a>
- </div>
- </div>
- </div>
- """;
- break;
- }
-
- String label = node.resolvedLabel;
- String title = label;
- if(label.length() > 38) {
- label = label.substring(0,35) + "...";
- }
-
- println """
- <div class="Item">
- <div class="Level$intLevel">
- <div class="OverflowContainer">
- """;
- if(node.pageReference != null) {
- print """<a class="IconItem ${iconType}" href="$actionLink" title="$title">$label</a>""";
- } else {
- print """<a class="IconItem ${iconType}" title="$title">$label</a>""";
- }
- println """
- </div>
- </div>
- </div>
- """;
- if (node.getChildren() != null) {
- renderNextLevelNode(nav, node.getChildren(), intLevel + 1, portalUri, useAjax);
- }
- }
- }
-%>
-<div class="UISitemap">
- <div class="SitemapContainer">
- <div class="SitemapBackground">
- <%
- boolean even = true;
- String cssfloat = "left";
- for(nav in navigations) {
- for(node in nav.getNodes()) {
- String iconType = node.getIcon();
- if(iconType == null) {
- iconType = "DefaultPageIcon";
- }
- if(even)cssfloat = "left";
- else cssfloat = "right";
- String blockFloat = "LeftBlock";
- if(useAJAX){
- actionLink = uicomponent.event("SelectNode", nav.getId() + "::" + node.getUri());
- }else{
- actionLink = portalURI + node.getUri();
- }
-
- String label = node.resolvedLabel;
- String title = "";
- if(label.length() > 35) {
- title = label;
- label = label.substring(0,32) + "...";
- }
- %>
- <div class="SitemapItemBox" style="float:${cssfloat};">
- <div class="SitemapItemContainer">
- <div class="TitleBar">
- <%if(node.pageReference != null) {%>
- <a href="<%=actionLink%>" class="Icon ${iconType}" title="$title">$label</a>
- <%} else {%>
- <a class="Icon ${iconType}" title="$title">$label</a>
- <%}%>
- </div>
- <%if(node.getChildren() == null || node.getChildren().size() < 1) { %>
- <div class="NestedSitemapItemBox">
- <div class="SitemapItemBoxSelector BorderBox">
- <div class="Item">
- <div class="SubItem">
- <div class="Icon BlueInfoBox16x16Icon">
- <%=_ctx.appRes("UISitemap.label.message")%>
- </div>
- </div>
- </div>
- </div>
- </div>
- <%} else { %>
- <div class="NestedSitemapItemBox">
- <div class="SitemapItemBoxSelector">
- <div class="ItemContainer">
- <% renderNextLevelNode(nav, node.getChildren(), 1, portalURI, useAJAX); %>
- </div>
- </div>
- </div>
- <%}%>
- </div>
- </div>
- <%
- if(!even) {
- %>
- <div class="ClearBoth"><span></span></div>
- <%
- }
- even = !even;
- }
- }
- if(!even){
- %>
- <div class="ClearBoth"><span></span></div>
- <% } %>
- </div>
- </div>
-</div>
--->
\ No newline at end of file
+<%
+ import org.exoplatform.portal.webui.component.UISitemapTree;
+
+ def uiSitemapTree = uicomponent.getChild(UISitemapTree.class);
+ uiSitemapTree.loadTreeNodes();
+ uicomponent.renderChildren();
+%>
\ No newline at end of file
Deleted: portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap2.gtmpl
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap2.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemap2.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -1,7 +0,0 @@
-<%
- import org.exoplatform.portal.webui.navigation.UIPortalNavigation;
-
- def uiPortalNavigation = uicomponent.getChild(UIPortalNavigation.class);
- uiPortalNavigation.loadTreeNodes();
- uicomponent.renderChildren();
-%>
\ No newline at end of file
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -23,7 +23,7 @@
nodeURL.setAjax(true);
public void renderNodes(TreeNode rootTree, ControllerURL nodeURL, boolean useAjax) {
- List childrenNodes=rootTree.getChildren();
+ List childrenNodes = rootTree.getChildren();
int childrenSize = childrenNodes.size() ;
int size = 0;
for(treeNode in childrenNodes) {
@@ -37,7 +37,7 @@
actionExpand = uicomponent.event("ExpandNode", nav.getId() + "::" + node.getUri());
def actionCollapse = "ajaxAsyncGetRequest('" + uicomponent.url("CollapseNode",nav.getId() + "::" + node.getUri()) + "', true)";
- String actionLink = nodeURL.setResource(new NavigationResource(node)).toString();
+ String actionLink = nodeURL.setResource(new NavigationResource(nav.getOwnerType(), nav.getOwnerId().replaceAll("/", "_"), node)).toString();
lastNode = '';
@@ -98,7 +98,7 @@
}
%>
-<div id="UISiteMap" class="UISitemap" >
+<div id="$uicomponent.id" class="UISitemap" >
<div class="ClearFix">
<div class="CollapseAll FloatLeft" onclick="eXo.portal.UIPortal.collapseExpand(this);$actionCollapseAll">
<%=_ctx.appRes(siteMapPortlet.getName() + ".label.CollapseAll")%>
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/index.jsp
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/index.jsp 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/index.jsp 2010-11-03 11:45:36 UTC (rev 4919)
@@ -24,13 +24,14 @@
<%@ page import="org.exoplatform.portal.url.PortalURLProvider"%>
<%@ page import="org.exoplatform.portal.url.navigation.NavigationResource"%>
<%@ page import="org.exoplatform.web.url.ControllerURL"%>
+<%@ page import="org.exoplatform.portal.config.model.PortalConfig"%>
<%
PortalContainer manager = PortalContainer.getCurrentInstance(session.getServletContext()) ;
UserPortalConfigService userPortalConfigService = (UserPortalConfigService) manager.getComponentInstanceOfType(UserPortalConfigService.class) ;
PortalURLProvider provider = PortalURLProvider.getCurrentPortalURLProvider();
- ControllerURL portalURL = provider.createPortalURL("public", userPortalConfigService.getDefaultPortal(), org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
+ ControllerURL portalURL = provider.createPortalURL("public", PortalConfig.PORTAL_TYPE, userPortalConfigService.getDefaultPortal(), org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
- response.sendRedirect(portalURL.setResource(new NavigationResource(null, null)).toString());
+ response.sendRedirect(portalURL.setResource(new NavigationResource(null, null, null)).toString());
%>
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-03 11:45:36 UTC (rev 4919)
@@ -1,6 +1,13 @@
<%
- //TODO: nguyenanhkien2a(a)gmail.com
- String initialURI = _ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() + "/private/" + _ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+ import org.exoplatform.portal.webui.util.Util;
+ import org.exoplatform.portal.application.PortalRequestContext;
+ import org.exoplatform.web.url.ControllerURL;
+ import org.exoplatform.portal.url.navigation.NavigationResource;
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ ControllerURL nodeURL = pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
+ nodeURL.setResource(new NavigationResource("private", "portal", pcontext.getPortalOwner(), null));
+ String initialURI = nodeURL.toString();
%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
Modified: portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java
===================================================================
--- portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/core/UIApplication.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -51,11 +51,13 @@
uiPopupMessages_.setId("_" + uiPopupMessages_.hashCode());
}
+ //TODO this looks like not to be used anymore
public String getOwner()
{
return owner;
}
+ //TODO this looks like not to be used anymore
public void setOwner(String s)
{
owner = s;
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -97,9 +97,6 @@
final static public String REQUEST_METADATA = "portal:requestMetadata".intern();
- /** The site name decoded from the request. */
- private final String portalOwner_;
-
/** The path decoded from the request. */
private final String nodePath_;
@@ -116,6 +113,12 @@
private final int accessPath;
/** . */
+ private final String siteType;
+
+ /** The site name decoded from the request. */
+ private final String siteName;
+
+ /** . */
private final HttpServletRequest request_;
/** . */
@@ -165,6 +168,7 @@
public PortalRequestContext(
WebuiApplication app,
ControllerContext controllerContext,
+ String requestSiteType,
String requestSiteName,
String requestPath,
String access) throws Exception
@@ -234,7 +238,8 @@
nodePath_ = pathInfo.substring(colonIndex, pathInfo.length());
*/
//
- this.portalOwner_ = requestSiteName;
+ this.siteType = requestSiteType;
+ this.siteName = requestSiteName.replaceAll("_", "/");
this.nodePath_ = requestPath;
this.access = access;
@@ -242,6 +247,7 @@
Map<QualifiedName, String> tmp = new HashMap<QualifiedName, String>();
tmp.put(WebAppController.HANDLER_PARAM, "portal");
tmp.put(PortalRequestHandler.ACCESS, access);
+ tmp.put(PortalRequestHandler.REQUEST_SITE_TYPE, requestSiteType);
tmp.put(PortalRequestHandler.REQUEST_SITE_NAME, requestSiteName);
tmp.put(PortalRequestHandler.REQUEST_PATH, "/");
portalURI = controllerContext.renderURL(tmp);
@@ -267,7 +273,7 @@
@Override
public <R, L extends ResourceLocator<R>> ControllerURL<R, L> newURL(ResourceType<R, L> resourceType, L locator)
{
- return new PortalURL<R, L>(controllerContext, locator, false, portalOwner_, access);
+ return new PortalURL<R, L>(controllerContext, locator, false, siteType, siteName.replaceAll("/", "_"), access);
}
public ControllerContext getControllerContext()
@@ -400,11 +406,26 @@
return PortalRequestContext.UI_COMPONENT_ID;
}
+ public String getSiteType()
+ {
+ return siteType;
+ }
+
+ public String getSiteName()
+ {
+ return siteName;
+ }
+
+ /**
+ * @deprecated use {@link #getSiteName()} instead
+ *
+ * @return the current site name
+ */
public String getPortalOwner()
{
- return portalOwner_;
+ return getSiteName();
}
-
+
public String getNodePath()
{
return nodePath_;
@@ -420,26 +441,6 @@
return portalURI;
}
- public PageNavigation getTargetNav()
- {
- return targetNav;
- }
-
- public void setTargetNav(PageNavigation targetNav)
- {
- this.targetNav = targetNav;
- }
-
- public PageNode getTargetNode()
- {
- return targetNode_;
- }
-
- public void setTargetNode(PageNode targetNode)
- {
- targetNode_ = targetNode;
- }
-
public URLBuilder<UIComponent> getURLBuilder()
{
return urlBuilder;
@@ -516,6 +517,12 @@
this.forceFullUpdate = forceFullUpdate;
}
+ final public void sendError(int sc) throws IOException
+ {
+ setResponseComplete(true);
+ response_.sendError(sc);
+ }
+
final public void sendRedirect(String url) throws IOException
{
setResponseComplete(true);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -50,11 +50,19 @@
protected static Log log = ExoLogger.getLogger("portal:PortalRequestHandler");
+ /** . */
+ public static final String PUBLIC_ACCESS = "public";
+
+ /** . */
+ public static final String PRIVATE_ACCESS = "private";
/** . */
public static final QualifiedName REQUEST_PATH = new QualifiedName("gtn", "path");
/** . */
+ public static final QualifiedName REQUEST_SITE_TYPE = new QualifiedName("gtn", "sitetype");
+
+ /** . */
public static final QualifiedName REQUEST_SITE_NAME = new QualifiedName("gtn", "sitename");
/** . */
@@ -101,16 +109,17 @@
//
String requestPath = controllerContext.getParameter(REQUEST_PATH);
+ String requestSiteType = controllerContext.getParameter(REQUEST_SITE_TYPE);
String requestSiteName = controllerContext.getParameter(REQUEST_SITE_NAME);
String access = controllerContext.getParameter(ACCESS);
- //
- PortalApplication app = controllerContext.getController().getApplication(PortalApplication.PORTAL_APPLICATION_ID);
- PortalRequestContext context = new PortalRequestContext(app, controllerContext, requestSiteName, requestPath, access);
- if (context.getPortalOwner().length() == 0) {
+ if (requestSiteName == null) {
res.sendRedirect(req.getContextPath());
return;
}
+ //
+ PortalApplication app = controllerContext.getController().getApplication(PortalApplication.PORTAL_APPLICATION_ID);
+ PortalRequestContext context = new PortalRequestContext(app, controllerContext, requestSiteType, requestSiteName, requestPath, access);
WebuiRequestContext.setCurrentInstance(context);
List<ApplicationLifecycle> lifecycles = app.getApplicationLifecycle();
try
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -136,9 +136,7 @@
{
ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
UserPortalConfigService service_ = (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- String remoteUser = context.getRemoteUser();
- String ownerUser = context.getPortalOwner();
- return service_.getUserPortalConfig(ownerUser, remoteUser);
+ return service_.getUserPortalConfig(context.getSiteType(), context.getSiteName(), context.getRemoteUser());
}
private String getKey(WebuiRequestContext webuiRC)
@@ -150,9 +148,7 @@
}
else
{
- PortalRequestContext portalRC = (PortalRequestContext)webuiRC;
- String portalOwner = portalRC.getPortalOwner();
- return "portal_" + portalOwner;
+ return PortalApplication.PORTAL_APPLICATION_ID;
}
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -26,7 +26,9 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.application.PortalStateManager;
import org.exoplatform.portal.application.UserProfileLifecycle;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.organization.OrganizationService;
@@ -121,11 +123,12 @@
localeCtx.setUserProfileLocale(getUserProfileLocale(reqCtx));
localeCtx.setRemoteUser(reqCtx.getRemoteUser());
- UserPortalConfig userPortalConfig = null;
+ DataStorage dataStorage = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ PortalConfig pConfig = null;
try
{
- userPortalConfig = PortalStateManager.getUserPortalConfig(reqCtx);
- if (userPortalConfig == null)
+ pConfig = dataStorage.getPortalConfig(reqCtx.getSiteType(), reqCtx.getSiteName());
+ if (pConfig == null)
log.warn("No UserPortalConfig available! Portal locale set to 'en'");
}
catch(Exception ignored)
@@ -135,8 +138,8 @@
}
String portalLocaleName = "en";
- if (userPortalConfig != null)
- portalLocaleName = userPortalConfig.getPortalConfig().getLocale();
+ if (pConfig != null)
+ portalLocaleName = pConfig.getLocale();
Locale portalLocale = LocaleContextInfo.getLocale(portalLocaleName);
localeCtx.setPortalLocale(portalLocale);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.url;
+import org.exoplatform.Constants;
import org.exoplatform.portal.application.PortalRequestHandler;
import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
@@ -44,6 +45,9 @@
private final String access;
/** . */
+ private final String siteType;
+
+ /** . */
private final String siteName;
/** . */
@@ -52,7 +56,7 @@
/** . */
private SimpleRenderContext renderContext;
- public PortalURL(ControllerContext requestContext, L locator, Boolean ajax, String siteName, String access)
+ public PortalURL(ControllerContext requestContext, L locator, Boolean ajax, String siteType, String siteName, String access)
{
super(locator, ajax);
@@ -63,6 +67,7 @@
}
//
+ this.siteType = siteType;
this.siteName = siteName;
this.controllerContext = requestContext;
this.access = access;
@@ -115,6 +120,7 @@
Map<QualifiedName, String> parameters = new HashMap<QualifiedName, String>();
parameters.put(WebAppController.HANDLER_PARAM, "portal");
parameters.put(PortalRequestHandler.ACCESS, access);
+ parameters.put(PortalRequestHandler.REQUEST_SITE_TYPE, siteType);
parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, siteName);
//
@@ -137,7 +143,7 @@
{
for (Map.Entry<String, String> entry : queryParams.entrySet())
{
- buffer.append(questionMarkDone ? "&" : "?");
+ buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
buffer.append(entry.getKey());
buffer.append('=');
buffer.append(entry.getValue());
@@ -150,7 +156,7 @@
{
for (String value : entry.getValue())
{
- buffer.append(questionMarkDone ? "&" : "?");
+ buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
buffer.append(entry.getKey());
buffer.append("=");
buffer.append(value);
@@ -161,7 +167,7 @@
//
if (ajax)
{
- buffer.append(questionMarkDone ? "&" : "?");
+ buffer.append(questionMarkDone ? Constants.AMPERSAND : org.exoplatform.portal.Constants.QMARK);
buffer.append("ajaxRequest=true");
buffer.append("')");
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLProvider.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLProvider.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURLProvider.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -52,13 +52,13 @@
return currentProvider.get();
}
- public final <R, L extends ResourceLocator<R>> PortalURL<R, L> createPortalURL(String access, String siteName, ResourceType<R, L> resourceType)
+ public final <R, L extends ResourceLocator<R>> PortalURL<R, L> createPortalURL(String access, String siteType, String siteName, ResourceType<R, L> resourceType)
{
PortalURLProvider portalURLProvider = currentProvider.get();
if (portalURLProvider != null)
{
L newLocator = locatorProvider.newLocator(resourceType);
- return new PortalURL<R, L>(controllerContext, newLocator, false, siteName, access);
+ return new PortalURL<R, L>(controllerContext, newLocator, false, siteType, siteName, access);
}
return null;
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -37,9 +37,15 @@
/** . */
public static final QualifiedName PATH = new QualifiedName("gtn", "path");
+
+ /** . */
+ public static final QualifiedName REQUEST_SITE_TYPE = new QualifiedName("gtn", "sitetype");
/** . */
public static final QualifiedName REQUEST_SITE_NAME = new QualifiedName("gtn", "sitename");
+
+ /** . */
+ public static final QualifiedName ACCESS = new QualifiedName("gtn", "access");
/** . */
public static final ResourceType<NavigationResource, NavigationLocator> TYPE = new ResourceType<NavigationResource, NavigationLocator>(){};
@@ -50,7 +56,9 @@
static
{
PARAMETER_NAMES.add(PATH);
+ PARAMETER_NAMES.add(REQUEST_SITE_TYPE);
PARAMETER_NAMES.add(REQUEST_SITE_NAME);
+ PARAMETER_NAMES.add(ACCESS);
}
/** . */
@@ -74,10 +82,18 @@
return "/" + resource.getPageNode().getUri();
}
}
+ else if (REQUEST_SITE_TYPE.equals(parameterName))
+ {
+ return resource.getSiteType();
+ }
else if (REQUEST_SITE_NAME.equals(parameterName))
{
return resource.getSiteName();
}
+ else if (ACCESS.equals(parameterName))
+ {
+ return resource.getAccess();
+ }
return null;
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationResource.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationResource.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationResource.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -30,27 +30,50 @@
public class NavigationResource
{
/** . */
+ private final String access;
+
+ /** . */
+ private final String siteType;
+
+ /** . */
private final String siteName;
/** . */
private final PageNode pageNode;
- public NavigationResource(String portalName)
+ public NavigationResource(String siteName)
{
- this(portalName, null);
+ this(null, siteName, null);
}
public NavigationResource(PageNode node)
{
- this(null, node);
+ this(null, null, node);
}
- public NavigationResource(String portalName, PageNode node)
+ public NavigationResource(String siteType, String siteName, PageNode node)
{
- siteName = portalName;
- pageNode = node;
+ this(null, siteType, siteName, node);
}
+
+ public NavigationResource(String access, String siteType, String portalName, PageNode node)
+ {
+ this.access = access;
+ this.siteType = siteType;
+ this.siteName = portalName;
+ this.pageNode = node;
+ }
+
+ public String getAccess()
+ {
+ return access;
+ }
+ public String getSiteType()
+ {
+ return siteType;
+ }
+
public String getSiteName()
{
return siteName;
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIAddGroupNavigation.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -157,7 +157,6 @@
// create navigation for group
dataService.create(pageNav);
- uiPortalApp.getUserPortalConfig().getNavigations().add(0, pageNav);
uiPortalApp.getNavigations().add(0, pageNav);
uiPortalApp.localizeNavigations();
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationManagement.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -21,8 +21,6 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserPortalConfig;
-import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.page.UIPageNodeForm;
@@ -100,7 +98,6 @@
UINavigationManagement uiManagement = event.getSource();
UINavigationNodeSelector uiNodeSelector = uiManagement.getChild(UINavigationNodeSelector.class);
DataStorage dataService = uiManagement.getApplicationComponent(DataStorage.class);
- UserPortalConfigService portalConfigService = uiManagement.getApplicationComponent(UserPortalConfigService.class);
PageNavigation navigation = uiNodeSelector.getEdittedNavigation();
String editedOwnerType = navigation.getOwnerType();
@@ -122,7 +119,8 @@
if(PortalConfig.PORTAL_TYPE.equals(navigation.getOwnerType()))
{
- UserPortalConfig portalConfig = portalConfigService.getUserPortalConfig(navigation.getOwnerId(), prContext.getRemoteUser());
+ DataStorage dataStorage = uiManagement.getApplicationComponent(DataStorage.class);
+ PortalConfig portalConfig = dataStorage.getPortalConfig(navigation.getOwnerId());
if(portalConfig != null)
{
dataService.save(navigation);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -19,7 +19,6 @@
package org.exoplatform.portal.webui.navigation;
-import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.webui.portal.PageNodeEvent;
@@ -45,20 +44,10 @@
protected PageNode selectedNode_;
- protected Object selectedParent_;
-
- private TreeNode treeNode_;
-
private String cssClassName = "";
private String template;
- private final static String PORTAL_NAV = "portal";
-
- private final static String GROUP_NAV = "group";
-
- private final static String USER_NAV = "user";
-
@Override
public String getTemplate()
{
@@ -126,75 +115,11 @@
return result;
}
- public void loadTreeNodes() throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- treeNode_ = new TreeNode(new PageNode(), new PageNavigation(), true);
- List<PageNavigation> listNavigations = Util.getUIPortalApplication().getNavigations();
-
- for (PageNavigation nav : rearrangeNavigations(listNavigations))
- {
- if (!showUserNavigation && nav.getOwnerType().equals("user"))
- {
- continue;
- }
- PageNavigation filterNav = PageNavigationUtils.filter(nav, context.getRemoteUser());
- treeNode_.setChildren(filterNav.getNodes(), filterNav);
- }
- }
-
- /**
- *
- * @param listNavigation
- * @return
- */
- private List<PageNavigation> rearrangeNavigations(List<PageNavigation> listNavigation)
- {
- List<PageNavigation> returnNavs = new ArrayList<PageNavigation>();
-
- List<PageNavigation> portalNavs = new ArrayList<PageNavigation>();
- List<PageNavigation> groupNavs = new ArrayList<PageNavigation>();
- List<PageNavigation> userNavs = new ArrayList<PageNavigation>();
-
- for (PageNavigation nav : listNavigation)
- {
- String ownerType = nav.getOwnerType();
- if (PORTAL_NAV.equals(ownerType))
- {
- portalNavs.add(nav);
- }
- else if (GROUP_NAV.equals(ownerType))
- {
- groupNavs.add(nav);
- }
- else if (USER_NAV.equals(ownerType))
- {
- userNavs.add(nav);
- }
- }
-
- returnNavs.addAll(portalNavs);
- returnNavs.addAll(groupNavs);
- returnNavs.addAll(userNavs);
-
- return returnNavs;
- }
-
- public TreeNode getTreeNodes()
- {
- return treeNode_;
- }
-
public PageNavigation getSelectedNavigation() throws Exception
{
return Util.getUIPortal().getNavigation();
}
- public Object getSelectedParent()
- {
- return selectedParent_;
- }
-
public PageNode getSelectedPageNode() throws Exception
{
if (selectedNode_ != null)
@@ -203,16 +128,6 @@
return selectedNode_;
}
- public boolean isSelectedNode(PageNode node)
- {
- if (selectedNode_ != null && node.getUri().equals(selectedNode_.getUri()))
- return true;
- if (selectedParent_ == null || selectedParent_ instanceof PageNavigation)
- return false;
- PageNode pageNode = (PageNode)selectedParent_;
- return node.getUri().equals(pageNode.getUri());
- }
-
public void processRender(WebuiRequestContext context) throws Exception
{
UIPortal uiPortal = Util.getUIPortal();
@@ -226,24 +141,6 @@
private void setSelectedPageNode(PageNode selectedNode) throws Exception
{
selectedNode_ = selectedNode;
- selectedParent_ = null;
- String seletctUri = selectedNode.getUri();
- int index = seletctUri.lastIndexOf("/");
- String parentUri = null;
- if (index > 0)
- parentUri = seletctUri.substring(0, seletctUri.lastIndexOf("/"));
- List<PageNavigation> pageNavs = getNavigations();
- for (PageNavigation pageNav : pageNavs)
- {
- if (PageNavigationUtils.searchPageNodeByUri(pageNav, selectedNode.getUri()) != null)
- {
- if (parentUri == null || parentUri.length() < 1)
- selectedParent_ = pageNav;
- else
- selectedParent_ = PageNavigationUtils.searchPageNodeByUri(pageNav, parentUri);
- break;
- }
- }
}
static public class SelectNodeActionListener extends EventListener<UIPortalNavigation>
@@ -262,159 +159,14 @@
}
else
{
- String navId = uri.substring(0, index);
- //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
selectNav = uiPortal.getNavigation();
}
PageNode selectNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
uiNavigation.selectedNode_ = selectNode;
- String parentUri = null;
- index = uri.lastIndexOf("/");
- if (index > 0)
- parentUri = uri.substring(0, index);
- if (parentUri == null || parentUri.length() < 1)
- uiNavigation.selectedParent_ = selectNav;
- else
- uiNavigation.selectedParent_ = PageNavigationUtils.searchPageNodeByUri(selectNav, parentUri);
PageNodeEvent<UIPortal> pnevent;
pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
}
}
-
- static public class ExpandNodeActionListener extends EventListener<UIPortalNavigation>
- {
- public void execute(Event<UIPortalNavigation> event) throws Exception
- {
- UIPortalNavigation uiNavigation = event.getSource();
-
- TreeNode treeNode = uiNavigation.getTreeNodes();
- List<PageNavigation> all_Navigations = Util.getUIPortalApplication().getNavigations();
-
- // get URI
- String uri = event.getRequestContext().getRequestParameter(OBJECTID);
- int index = uri.lastIndexOf("::");
- String id = uri.substring(index + 2);
-
- // get PageNavigation by uri
- PageNavigation selectNav = null;
-
- String navId = uri.substring(0, index);
- selectNav = PageNavigationUtils.findNavigationByID(all_Navigations, Integer.parseInt(navId));
- if(selectNav == null)
- {
- return;
- }
-
- // get PageNode by uri
- PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
-
- TreeNode expandTree = null;
- if (treeNode.getChildren() != null)
- {
- expandTree = treeNode.getChildByPath(uri, treeNode);
- }
-
- if(expandTree != null)
- {
- expandTree.setChildren(expandNode.getChildren(), selectNav);
- }
-
- event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
- }
- }
-
- static public class CollapseNodeActionListener extends EventListener<UIPortalNavigation>
- {
- public void execute(Event<UIPortalNavigation> event) throws Exception
- {
- UIPortalNavigation uiNavigation = event.getSource();
-
- TreeNode treeNode = uiNavigation.getTreeNodes();
- UIPortal uiPortal = Util.getUIPortal();
-
- // get URI
- String uri = event.getRequestContext().getRequestParameter(OBJECTID);
-
- int index = uri.lastIndexOf("::");
- String id = uri.substring(index + 2);
-
- // get PageNavigation by uri
- PageNavigation selectNav = null;
-
- String navId = uri.substring(0, index);
-
- //TODO: Minh Hoang TO
- //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
- selectNav = uiPortal.getNavigation();
-
- // get PageNode by uri
- PageNode expandNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
-
- TreeNode expandTree = null;
- if (treeNode.getChildren() != null)
- {
- expandTree = treeNode.getChildByPath(uri, treeNode);
- }
-
- if(expandTree != null)
- {
- expandTree.setExpanded(false);
- }
-
- event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
- }
- }
-
- static public class CollapseAllNodeActionListener extends EventListener<UIPortalNavigation>
- {
- public void execute(Event<UIPortalNavigation> event) throws Exception
- {
- PortalRequestContext prContext = Util.getPortalRequestContext();
- UIPortalNavigation uiNavigation = event.getSource();
-
- uiNavigation.loadTreeNodes();
-
- event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
- }
- }
-
- static public class ExpandAllNodeActionListener extends EventListener<UIPortalNavigation>
- {
- public void execute(Event<UIPortalNavigation> event) throws Exception
- {
- PortalRequestContext prContext = Util.getPortalRequestContext();
- UIPortalNavigation uiNavigation = event.getSource();
- // reload TreeNodes
- uiNavigation.loadTreeNodes();
- TreeNode treeNode = uiNavigation.getTreeNodes();
-
- expandAllNode(treeNode);
-
- event.getRequestContext().addUIComponentToUpdateByAjax(uiNavigation);
- }
-
- public void expandAllNode(TreeNode treeNode) throws Exception
- {
-
- if (treeNode.getChildren().size() > 0)
- {
- for (TreeNode child : treeNode.getChildren())
- {
- PageNode expandNode = child.getNode();
- PageNavigation selectNav = child.getNavigation();
-
- // set node to child tree
- if (expandNode.getChildren().size() > 0)
- {
- child.setChildren(expandNode.getChildren(), selectNav);
- }
-
- // expand child tree
- expandAllNode(child);
- }
- }
- }
- }
}
Deleted: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation2.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -1,179 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * 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.exoplatform.portal.webui.navigation;
-
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.webui.portal.PageNodeEvent;
-import org.exoplatform.portal.webui.portal.UIPortal;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class UIPortalNavigation2 extends UIComponent
-{
- private boolean useAJAX = true;
-
- protected PageNode selectedNode_;
-
- protected Object selectedParent_;
-
- private String template;
-
- @Override
- public String getTemplate()
- {
- return template != null ? template : super.getTemplate();
- }
-
- public void setTemplate(String template)
- {
- this.template = template;
- }
-
- public UIComponent getViewModeUIComponent()
- {
- return null;
- }
-
- public void setUseAjax(boolean bl)
- {
- useAJAX = bl;
- }
-
- public boolean isUseAjax()
- {
- return useAJAX;
- }
-
- public List<PageNavigation> getNavigations() throws Exception
- {
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- List<PageNavigation> result = new ArrayList<PageNavigation>();
- result.add(PageNavigationUtils.filter(Util.getUIPortal().getNavigation(), context.getRemoteUser()));
- return result;
- }
-
- public PageNavigation getSelectedNavigation() throws Exception
- {
- return Util.getUIPortal().getNavigation();
- }
-
- public Object getSelectedParent()
- {
- return selectedParent_;
- }
-
- public PageNode getSelectedPageNode() throws Exception
- {
- if (selectedNode_ != null)
- return selectedNode_;
- selectedNode_ = Util.getUIPortal().getSelectedNode();
- return selectedNode_;
- }
-
- public boolean isSelectedNode(PageNode node)
- {
- if (selectedNode_ != null && node.getUri().equals(selectedNode_.getUri()))
- return true;
- if (selectedParent_ == null || selectedParent_ instanceof PageNavigation)
- return false;
- PageNode pageNode = (PageNode)selectedParent_;
- return node.getUri().equals(pageNode.getUri());
- }
-
- public void processRender(WebuiRequestContext context) throws Exception
- {
- UIPortal uiPortal = Util.getUIPortal();
- if ((uiPortal.getSelectedNode() != null) && (uiPortal.getSelectedNode() != selectedNode_))
- {
- setSelectedPageNode(uiPortal.getSelectedNode());
- }
- super.processRender(context);
- }
-
- private void setSelectedPageNode(PageNode selectedNode) throws Exception
- {
- selectedNode_ = selectedNode;
- selectedParent_ = null;
- String seletctUri = selectedNode.getUri();
- int index = seletctUri.lastIndexOf("/");
- String parentUri = null;
- if (index > 0)
- parentUri = seletctUri.substring(0, seletctUri.lastIndexOf("/"));
- List<PageNavigation> pageNavs = getNavigations();
- for (PageNavigation pageNav : pageNavs)
- {
- if (PageNavigationUtils.searchPageNodeByUri(pageNav, selectedNode.getUri()) != null)
- {
- if (parentUri == null || parentUri.length() < 1)
- selectedParent_ = pageNav;
- else
- selectedParent_ = PageNavigationUtils.searchPageNodeByUri(pageNav, parentUri);
- break;
- }
- }
- }
-
- static public class SelectNodeActionListener extends EventListener<UIPortalNavigation2>
- {
- public void execute(Event<UIPortalNavigation2> event) throws Exception
- {
- UIPortalNavigation2 uiNavigation = event.getSource();
- UIPortal uiPortal = Util.getUIPortal();
- String uri = event.getRequestContext().getRequestParameter(OBJECTID);
- int index = uri.lastIndexOf("::");
- String id = uri.substring(index + 2);
- PageNavigation selectNav = null;
- if (index <= 0)
- {
- selectNav = uiPortal.getNavigation();
- }
- else
- {
- String navId = uri.substring(0, index);
-
- //TODO: Minh Hoang TO
- //selectNav = uiPortal.getPageNavigation(Integer.parseInt(navId));
- selectNav = uiPortal.getNavigation();
- }
- PageNode selectNode = PageNavigationUtils.searchPageNodeByUri(selectNav, id);
- uiNavigation.selectedNode_ = selectNode;
- String parentUri = null;
- index = uri.lastIndexOf("/");
- if (index > 0)
- parentUri = uri.substring(0, index);
- if (parentUri == null || parentUri.length() < 1)
- uiNavigation.selectedParent_ = selectNav;
- else
- uiNavigation.selectedParent_ = PageNavigationUtils.searchPageNodeByUri(selectNav, parentUri);
-
- PageNodeEvent<UIPortal> pnevent;
- pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, uri);
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
- }
- }
-
-}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.ModelObject;
@@ -29,12 +30,10 @@
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.application.UIGadget;
-import org.exoplatform.portal.webui.portal.PageNodeEvent;
import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
-import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
@@ -44,6 +43,8 @@
import java.util.ArrayList;
import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
/**
* Just a class that contains the Page related action listeners
*
@@ -52,22 +53,28 @@
*/
public class UIPageActionListener
{
- private static UIPortal buildUIPortal(PageNavigation newPageNav, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
+ private static UIPortal buildUIPortal(String siteType, String siteName, UIPortalApplication uiPortalApp, UserPortalConfig userPortalConfig) throws Exception
{
DataStorage storage = uiPortalApp.getApplicationComponent(DataStorage.class);
- if(storage == null){
+ UserACL usrACL = uiPortalApp.getApplicationComponent(UserACL.class);
+
+ PortalConfig pConfig = storage.getPortalConfig(siteType, siteName);
+ if (!usrACL.hasPermission(pConfig))
+ {
return null;
}
- PortalConfig portalConfig = storage.getPortalConfig(newPageNav.getOwnerType(), newPageNav.getOwnerId());
- Container layout = portalConfig.getPortalLayout();
+ Container layout = pConfig.getPortalLayout();
if(layout != null)
{
- userPortalConfig.setPortal(portalConfig);
+ userPortalConfig.setPortal(pConfig);
}
UIPortal uiPortal = uiPortalApp.createUIComponent(UIPortal.class, null, null);
- //Reset selected navigation on userPortalConfig
- userPortalConfig.setSelectedNavigation(newPageNav);
- PortalDataMapper.toUIPortal(uiPortal, userPortalConfig);
+
+
+ PortalDataMapper.toUIPortal(uiPortal, pConfig);
+ PageNavigation nav = storage.getPageNavigation(siteType, siteName);
+ uiPortal.setNavigation(nav);
+ uiPortalApp.getUserPortalConfig().addNavigation(nav);
return uiPortal;
}
@@ -83,56 +90,86 @@
public void execute(Event<UIPortalApplication> event) throws Exception
{
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
- PageNavigation targetNav = pcontext.getTargetNav();
- PageNode newPageNode = pcontext.getTargetNode();
+ String siteType = pcontext.getSiteType();
+ String siteName = pcontext.getSiteName();
+ String nodePath = pcontext.getNodePath();
+
UIPortalApplication uiPortalApp = event.getSource();
- UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
+ UIPortal uiPortal = uiPortalApp.getCurrentSite();
PageNavigation currentNav = uiPortal.getNavigation();
- if(currentNav.getOwnerType().equals(targetNav.getOwnerType()) & currentNav.getOwnerId().equals(targetNav.getOwnerId()))
+
+ if(currentNav.getOwnerType().equals(siteType) && currentNav.getOwnerId().equals(siteName))
{
- if(!uiPortal.getSelectedNode().getUri().equals(newPageNode.getUri()))
+ PageNode newPageNode = Util.findBestMatchNode(currentNav, nodePath);
+ if (newPageNode == null)
{
+ newPageNode = Util.findFirstAvailableNode(currentNav, pcontext);
+ }
+ if (newPageNode == null)
+ {
+ uiPortal.setSelectedNode(null);
+ return;
+ }
+
+ if(uiPortal.getSelectedNode() == null || !uiPortal.getSelectedNode().getUri().equals(newPageNode.getUri()))
+ {
uiPortal.setSelectedNode(newPageNode);
}
}
else
{
- uiPortal = uiPortalApp.getCachedUIPortal(targetNav.getOwnerType(), targetNav.getOwnerId());
+ UserPortalConfig userPortalConfig = uiPortalApp.getUserPortalConfig();
+
+ uiPortal = uiPortalApp.getCachedUIPortal(siteType, siteName);
if(uiPortal == null)
{
- uiPortal = buildUIPortal(targetNav, uiPortalApp, uiPortalApp.getUserPortalConfig());
+ uiPortal = buildUIPortal(siteType, siteName, uiPortalApp, userPortalConfig);
if(uiPortal == null)
{
+ uiPortalApp.setCurrentSite(null);
return;
}
- uiPortal.setSelectedNode(newPageNode);
- uiPortalApp.setShowedUIPortal(uiPortal);
+ uiPortalApp.setCurrentSite(uiPortal);
uiPortalApp.putCachedUIPortal(uiPortal);
}
else
{
- uiPortal.setSelectedNode(newPageNode);
- uiPortalApp.setShowedUIPortal(uiPortal);
+ uiPortalApp.setCurrentSite(uiPortal);
- //Temporary solution to fix edit inline error while switching between navigations
DataStorage storageService = uiPortalApp.getApplicationComponent(DataStorage.class);
- PortalConfig associatedPortalConfig = storageService.getPortalConfig(targetNav.getOwnerType(), targetNav.getOwnerId());
- UserPortalConfig userPortalConfig = uiPortalApp.getUserPortalConfig();
+ //Temporary solution to fix edit inline error while switching between navigations
+ PortalConfig associatedPortalConfig = storageService.getPortalConfig(siteType, siteName);
+
//Update layout-related data on UserPortalConfig
userPortalConfig.setPortal(associatedPortalConfig);
+ }
- //Update selected navigation on UserPortalConfig, that is mandatory as at the moment the PortalConfig
- //does not hold any navigation data.
- userPortalConfig.setSelectedNavigation(targetNav);
+ PageNavigation targetNav = uiPortalApp.getNavigation(siteType, siteName);
+ if (targetNav == null)
+ {
+ return;
}
+ PageNode newPageNode = Util.findBestMatchNode(targetNav, nodePath);
+ if (newPageNode == null)
+ {
+ newPageNode = Util.findFirstAvailableNode(targetNav, pcontext);
+ }
+ if (newPageNode == null)
+ {
+ return;
+ }
+
+ uiPortal.setSelectedNode(newPageNode);
}
uiPortal.refreshUIPage();
pcontext.setFullRender(true);
pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID));
}
}
+
+ //I kept this for reference
/**
* Navigate to a page node in current navigation of UIPortal.
@@ -140,6 +177,7 @@
* @author <a href="mailto:trongtt@gmail.com">Tran The Trong</a>
* @version $Revision$
*/
+ /*
static public class ChangePageNodeActionListener extends EventListener<UIPortal>
{
@Override
@@ -220,7 +258,7 @@
uiPortal.refreshUIPage();
}
}
-
+ */
static public class DeleteGadgetActionListener extends EventListener<UIPage>
{
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -396,7 +396,7 @@
PortalRequestContext pcontext = Util.getPortalRequestContext();
ControllerURL<NavigationResource, NavigationLocator> nodeURL =
pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
- nodeURL.setResource(new NavigationResource(null, selectedNode));
+ nodeURL.setResource(new NavigationResource(null, null, selectedNode));
pcontext.sendRedirect(nodeURL.toString());
}
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -25,7 +25,6 @@
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.NoSuchDataException;
import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
@@ -49,8 +48,8 @@
import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
import org.exoplatform.webui.core.model.SelectItemOption;
import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIFormCheckBoxInput;
import org.exoplatform.webui.form.UIFormInputItemSelector;
import org.exoplatform.webui.form.UIFormInputSet;
@@ -63,8 +62,8 @@
import org.exoplatform.webui.form.validator.StringLengthValidator;
import org.exoplatform.webui.organization.UIGroupMembershipSelector;
import org.exoplatform.webui.organization.UIListPermissionSelector;
-import org.exoplatform.webui.organization.UIPermissionSelector;
import org.exoplatform.webui.organization.UIListPermissionSelector.EmptyIteratorValidator;
+import org.exoplatform.webui.organization.UIPermissionSelector;
import java.util.ArrayList;
import java.util.Collections;
@@ -98,15 +97,14 @@
{
super("UIPageForm");
PortalRequestContext pcontext = Util.getPortalRequestContext();
- UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
+ DataStorage dataStorage = getApplicationComponent(DataStorage.class);
List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
- UserPortalConfig userPortalConfig =
- configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
+ PortalConfig pConfig = dataStorage.getPortalConfig(pcontext.getPortalOwner());
ExoContainer container = ExoContainerContext.getCurrentContainer();
UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
- if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
+ if (pConfig != null && acl.hasEditPermission(pConfig))
{
ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
}
@@ -142,7 +140,8 @@
//TODO: This following line is fixed for bug PORTAL-2127
uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
- List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
+ UserPortalConfigService userPortalConfigService= getApplicationComponent(UserPortalConfigService.class);
+ List<String> groups = userPortalConfigService.getMakableNavigations(pcontext.getRemoteUser(), true);
if (groups.size() > 0)
{
Collections.sort(groups);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -21,17 +21,19 @@
import org.exoplatform.portal.account.UIAccountSetting;
import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.application.PortalRequestHandler;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.config.model.PortalProperties;
import org.exoplatform.portal.config.model.Properties;
+import org.exoplatform.portal.url.navigation.NavigationLocator;
+import org.exoplatform.portal.url.navigation.NavigationResource;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
import org.exoplatform.portal.webui.page.UIPage;
-import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.page.UIPageActionListener.ChangeNodeActionListener;
-import org.exoplatform.portal.webui.page.UIPageActionListener.ChangePageNodeActionListener;
+import org.exoplatform.portal.webui.page.UIPageBody;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeApplicationListActionListener;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeLanguageActionListener;
import org.exoplatform.portal.webui.portal.UIPortalComponentActionListener.ChangeSkinActionListener;
@@ -45,18 +47,18 @@
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.resources.ResourceBundleManager;
+import org.exoplatform.web.application.JavascriptManager;
import org.exoplatform.web.login.InitiateLoginServlet;
import org.exoplatform.web.security.security.AbstractTokenService;
import org.exoplatform.web.security.security.CookieTokenService;
+import org.exoplatform.web.url.ControllerURL;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.web.application.JavascriptManager;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -70,7 +72,6 @@
@ComponentConfig(lifecycle = UIPortalLifecycle.class, template = "system:/groovy/portal/webui/portal/UIPortal.gtmpl", events = {
@EventConfig(listeners = ChangeNodeActionListener.class),
- @EventConfig(listeners = ChangePageNodeActionListener.class),
@EventConfig(listeners = ChangeApplicationListActionListener.class),
@EventConfig(listeners = MoveChildActionListener.class),
@EventConfig(listeners = UIPortal.ChangeWindowStateActionListener.class),
@@ -260,15 +261,7 @@
public PageNode getSelectedNode() throws Exception
{
- if(selectedNode_ != null)
- {
- return selectedNode_;
- }
- if(navigation == null || navigation.getNodes() == null || navigation.getNodes().size() < 1)
- {
- return null;
- }
- return navigation.getNodes().get(0);
+ return selectedNode_;
}
public List<PageNode> getSelectedPath()
@@ -438,11 +431,14 @@
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
prContext.getResponse().addCookie(cookie);
- // String portalName = URLEncoder.encode(Util.getUIPortal().getName(),
- // "UTF-8") ;
- String portalName = URLEncoder.encode(prContext.getPortalOwner(), "UTF-8");
- String redirect = req.getContextPath() + "/public/" + portalName + "/";
- prContext.getResponse().sendRedirect(redirect);
+
+ //TODO: this could be a good portal name
+ String portalName = "classic";
+
+ ControllerURL<NavigationResource, NavigationLocator> createURL =
+ prContext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
+ createURL.setResource(new NavigationResource(PortalRequestHandler.PUBLIC_ACCESS, PortalConfig.PORTAL_TYPE, portalName, null));
+ prContext.getResponse().sendRedirect(createURL.toString());
prContext.setResponseComplete(true);
}
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -23,6 +23,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.StaleModelException;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.Page;
@@ -181,11 +182,11 @@
UIPortal editPortal = (UIPortal)uiEditWS.getUIComponent();
UIPortal uiPortal = Util.getUIPortal();
String remoteUser = prContext.getRemoteUser();
- String ownerUser = prContext.getPortalOwner();
+ String portalName = prContext.getPortalOwner();
PortalConfig portalConfig = (PortalConfig)PortalDataMapper.buildModelObject(editPortal);
- UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
DataStorage dataStorage = getApplicationComponent(DataStorage.class);
+ UserACL acl = getApplicationComponent(UserACL.class);
if (!isPortalExist(editPortal))
{
@@ -205,10 +206,10 @@
rebuildUIPortal(uiPortalApp, editPortal, dataStorage);
}
uiPortalApp.getUserPortalConfig().setPortal(portalConfig);
- UserPortalConfig userPortalConfig = configService.getUserPortalConfig(ownerUser, remoteUser);
- if (userPortalConfig != null)
+ PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
+ if (pConfig != null)
{
- editPortal.setModifiable(userPortalConfig.getPortalConfig().isModifiable());
+ editPortal.setModifiable(acl.hasEditPermission(pConfig));
}
else
{
@@ -477,7 +478,7 @@
//Update the cache of UIPortal from UIPortalApplication
uiPortalApp.putCachedUIPortal(uiPortal);
- uiPortalApp.setShowedUIPortal(uiPortal);
+ uiPortalApp.setCurrentSite(uiPortal);
//To init the UIPage, that fixed a bug on AdminToolbarPortlet when edit the layout. Here is only a
//temporal solution. Complete solution is to avoid mapping UIPortal -- model, that requires
@@ -634,7 +635,7 @@
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
- UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
+ UIPortal uiPortal = uiPortalApp.getCurrentSite();
uiPortal.setRenderSibling(UIPortal.class);
UIPortalComposer composer = uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
composer.setEditted(false);
@@ -660,7 +661,7 @@
public void execute(Event<UIPortalComposer> event) throws Exception
{
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
- UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
+ UIPortal uiPortal = uiPortalApp.getCurrentSite();
UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
UIPortalToolPanel uiToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -23,7 +23,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
-import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfigService;
import org.exoplatform.portal.config.model.PageNavigation;
import org.exoplatform.portal.config.model.PortalConfig;
@@ -53,8 +53,8 @@
import org.exoplatform.webui.core.model.SelectItemCategory;
import org.exoplatform.webui.core.model.SelectItemOption;
import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
+import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.form.UIFormInputItemSelector;
import org.exoplatform.webui.form.UIFormInputSet;
import org.exoplatform.webui.form.UIFormSelectBox;
@@ -64,8 +64,8 @@
import org.exoplatform.webui.form.validator.MandatoryValidator;
import org.exoplatform.webui.form.validator.StringLengthValidator;
import org.exoplatform.webui.organization.UIListPermissionSelector;
-import org.exoplatform.webui.organization.UIPermissionSelector;
import org.exoplatform.webui.organization.UIListPermissionSelector.EmptyIteratorValidator;
+import org.exoplatform.webui.organization.UIPermissionSelector;
import java.util.ArrayList;
import java.util.Collection;
@@ -145,8 +145,7 @@
public void setBindingBean() throws Exception
{
- UserPortalConfigService service = this.getApplicationComponent(UserPortalConfigService.class);
- PortalRequestContext prContext = Util.getPortalRequestContext();
+ DataStorage dataStorage = this.getApplicationComponent(DataStorage.class);
UIPortal editPortal = null;
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
@@ -160,9 +159,9 @@
}
else
{
- UserPortalConfig userConfig = service.getUserPortalConfig(getPortalOwner(), prContext.getRemoteUser());
+ PortalConfig pConfig = dataStorage.getPortalConfig(getPortalOwner());
editPortal = this.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(editPortal, userConfig);
+ PortalDataMapper.toUIPortal(editPortal, pConfig);
}
invokeGetBindingBean(editPortal);
@@ -290,14 +289,14 @@
UIPortalForm uiForm = event.getSource();
DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
- UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+ UserACL acl = uiForm.getApplicationComponent(UserACL.class);
PortalRequestContext prContext = Util.getPortalRequestContext();
- UserPortalConfig userConfig = service.getUserPortalConfig(uiForm.getPortalOwner(), prContext.getRemoteUser());
- if (userConfig != null)
+ PortalConfig pConfig = dataService.getPortalConfig(uiForm.getPortalOwner());
+ if (pConfig != null && acl.hasPermission(pConfig))
{
UIPortal uiPortal = uiForm.createUIComponent(UIPortal.class, null, null);
- PortalDataMapper.toUIPortal(uiPortal, userConfig);
+ PortalDataMapper.toUIPortal(uiPortal, pConfig);
UIPortalApplication uiPortalApp = (UIPortalApplication)prContext.getUIApplication();
uiForm.invokeSetBindingBean(uiPortal);
@@ -305,7 +304,6 @@
if (uiPortalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
{
PortalConfig portalConfig = (PortalConfig)PortalDataMapper.buildModelObject(uiPortal);
- UserPortalConfigService configService = uiForm.getApplicationComponent(UserPortalConfigService.class);
dataService.save(portalConfig);
}
else
@@ -351,8 +349,8 @@
UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
service.createUserPortalConfig(PortalConfig.PORTAL_TYPE, portalName, template);
- UserPortalConfig userPortalConfig = service.getUserPortalConfig(portalName, pcontext.getRemoteUser());
- PortalConfig pconfig = userPortalConfig.getPortalConfig();
+
+ PortalConfig pconfig = dataService.getPortalConfig(portalName);
uiForm.invokeSetBindingBean(pconfig);
PageNavigation navigation = dataService.getPageNavigation(PortalConfig.PORTAL_TYPE, portalName);
dataService.save(pconfig);
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UISkinSelector.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -65,7 +65,7 @@
String currentSkin = uiPortalApp.getSkin();
if (currentSkin == null)
- currentSkin = "Default";
+ currentSkin = SkinService.DEFAULT_SKIN;
for (SelectItemCategory ele : itemCategories)
{
if (ele.getName().equals(currentSkin))
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -334,10 +334,8 @@
}
}
- static public void toUIPortal(UIPortal uiPortal, UserPortalConfig userPortalConfig) throws Exception
+ static public void toUIPortal(UIPortal uiPortal, PortalConfig model) throws Exception
{
- PortalConfig model = userPortalConfig.getPortalConfig();
-
uiPortal.setOwnerType(model.getType());
uiPortal.setStorageId(model.getStorageId());
uiPortal.setName(model.getName());
@@ -360,9 +358,14 @@
buildUIContainer(uiPortal, child, false);
}
}
- //uiPortal.setNavigation(userPortalConfig.getNavigations());
- uiPortal.setNavigation(userPortalConfig.getSelectedNavigation());
}
+
+ static public void toUIPortal(UIPortal uiPortal, UserPortalConfig userPortalConfig) throws Exception
+ {
+ PortalConfig model = userPortalConfig.getPortalConfig();
+ toUIPortal(uiPortal, model);
+ uiPortal.setNavigation(userPortalConfig.getNavigation(model.getType(), model.getName()));
+ }
private static void buildUIContainer(UIContainer uiContainer, Object model, boolean dashboard) throws Exception
{
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/util/Util.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -128,6 +128,35 @@
return node;
}
+ static public PageNode findBestMatchNode(PageNavigation nav, String nodePath)
+ {
+ String[] pathNodes = splitPath(nodePath);
+
+ if (pathNodes.length > 0)
+ {
+ int deepMatchNumber = 0;
+ PageNode currentNode = nav.getNode(pathNodes[deepMatchNumber++]);
+ if (currentNode == null) {
+ return null;
+ }
+ while (deepMatchNumber < pathNodes.length)
+ {
+ PageNode tempNode = currentNode.getChild(pathNodes[deepMatchNumber]);
+ if (tempNode == null)
+ {
+ break;
+ }
+ ++deepMatchNumber;
+ currentNode = tempNode;
+ }
+ return currentNode;
+ }
+ return null;
+ }
+
+ // I kept this for reference, so let remove it if unnecessary anymore.
+
+ /*
static public Object[] findBestMatchNavigationAndNode(List<PageNavigation> navigations, String nodePath_)
{
PageNavigation targetNav = null;
@@ -184,6 +213,7 @@
}
return results;
}
+ */
static public PortalRequestContext getPortalRequestContext()
{
@@ -204,7 +234,7 @@
{
//return getUIPortalApplication().<UIWorkingWorkspace> getChildById(UIPortalApplication.UI_WORKING_WS_ID)
// .findFirstComponentOfType(UIPortal.class);
- return getUIPortalApplication().getShowedUIPortal();
+ return getUIPortalApplication().getCurrentSite();
}
static public UIPortalToolPanel getUIPortalToolPanel()
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMainActionListener.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -154,7 +154,7 @@
{
UIPortalApplication uiApp = Util.getUIPortalApplication();
- UIPortal uiPortal = uiApp.getShowedUIPortal();
+ UIPortal uiPortal = uiApp.getCurrentSite();
UserPortalConfigService service = uiApp.getApplicationComponent(UserPortalConfigService.class);
UserPortalConfig userConfig =
Modified: portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
--- portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-11-03 11:16:20 UTC (rev 4918)
+++ portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-11-03 11:45:36 UTC (rev 4919)
@@ -25,7 +25,6 @@
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.model.Container;
import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.resource.Skin;
import org.exoplatform.portal.resource.SkinConfig;
import org.exoplatform.portal.resource.SkinService;
@@ -69,6 +68,8 @@
import java.util.Map;
import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
+
/**
* This extends the UIApplication and hence is a sibling of UIPortletApplication
* (used by any eXo Portlets as the Parent class to build the portlet component
@@ -78,8 +79,7 @@
* display the normal or webos portal layouts - UIPopupWindow: a popup window
* that display or not
*/
-@ComponentConfig(lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl", events = {
- @EventConfig(listeners = ChangeNodeActionListener.class)})
+@ComponentConfig(lifecycle = UIPortalApplicationLifecycle.class, template = "system:/groovy/portal/webui/workspace/UIPortalApplication.gtmpl", events = {@EventConfig(listeners = ChangeNodeActionListener.class)})
public class UIPortalApplication extends UIApplication
{
public static final int NORMAL_MODE = 0;
@@ -94,7 +94,7 @@
private int modeState = NORMAL_MODE;
- private String lastNodePath;
+ private String lastRequestURI;
private Orientation orientation_ = Orientation.LT;
@@ -106,22 +106,24 @@
final static public String UI_MASK_WS_ID = "UIMaskWorkspace";
- private String skin_ = "Default";
+ private String skin_ = SkinService.DEFAULT_SKIN;
private UserPortalConfig userPortalConfig_;
private boolean isSessionOpen = false;
-
+
private Map<UIPortalKey, UIPortal> all_UIPortals;
-
+
private List<PageNavigation> all_Navigations;
-
- private UIPortal showedUIPortal;
-
+
+ private UIPortal currentSite;
+
private boolean isAjaxInLastRequest;
+
+ private String lastNonAjaxRequestUri;
- private String lastNonAjaxUri;
-
+ private String portalName;
+
/**
* The constructor of this class is used to build the tree of UI components
* that will be aggregated in the portal page.<br/>
@@ -140,11 +142,11 @@
{
log = ExoLogger.getLogger("portal:UIPortalApplication");
PortalRequestContext context = PortalRequestContext.getCurrentInstance();
-
+
userPortalConfig_ = (UserPortalConfig)context.getAttribute(UserPortalConfig.class);
if (userPortalConfig_ == null)
throw new Exception("Can't load user portal config");
-
+
// dang.tung - set portal language by user preference -> browser ->
// default
// ------------------------------------------------------------------------------
@@ -152,14 +154,14 @@
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
String user = context.getRemoteUser();
- String portalSkin = null;
-
+ String userSkin = null;
+
if (user != null)
{
UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user);
if (userProfile != null)
{
- portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
+ userSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
}
else
{
@@ -190,25 +192,29 @@
context.setUIApplication(this);
this.all_UIPortals = new HashMap<UIPortalKey, UIPortal>(5);
-
+
addWorkingWorkspace();
// use the skin from the user profile if available, otherwise use from the portal config
- if (portalSkin != null && portalSkin.trim().length() > 0)
+ if (userSkin != null && userSkin.trim().length() > 0)
{
- skin_ = portalSkin;
+ skin_ = userSkin;
}
else
{
- String userPortalConfigSkin = userPortalConfig_.getPortalConfig().getSkin();
- if (userPortalConfigSkin != null && userPortalConfigSkin.trim().length() > 0)
- skin_ = userPortalConfigSkin;
+ String siteSkin = userPortalConfig_.getPortalConfig().getSkin();
+ if (siteSkin != null && siteSkin.trim().length() > 0)
+ {
+ skin_ = siteSkin;
+ }
+ else
+ // in the case the skin is not specified by site config, the one in default portal will be returned instead
+ {
+ DataStorage dataStorage = getApplicationComponent(DataStorage.class);
+ }
+
}
-
- setOwner(context.getPortalOwner());
-
- //Minh Hoang TO: Localizes navigations, need to put this code snippet below 'setLocale' block
- this.all_Navigations = userPortalConfig_.getNavigations();
+
localizeNavigations();
}
@@ -217,28 +223,28 @@
*
* @param uiPortal
*/
- public void setShowedUIPortal(UIPortal uiPortal)
+ public void setCurrentSite(UIPortal uiPortal)
{
- this.showedUIPortal = uiPortal;
+ this.currentSite = uiPortal;
UISiteBody siteBody = this.findFirstComponentOfType(UISiteBody.class);
- if(siteBody != null)
+ if (siteBody != null)
{
//TODO: Check this part carefully
siteBody.setUIComponent(uiPortal);
}
}
-
+
/**
* Returns current UIPortal which being showed in normal mode
*
* @return
*/
- public UIPortal getShowedUIPortal()
+ public UIPortal getCurrentSite()
{
- return showedUIPortal;
+ return currentSite;
}
-
+
/**
* Returns a cached UIPortal matching to OwnerType and OwnerId if any
*
@@ -248,13 +254,13 @@
*/
public UIPortal getCachedUIPortal(String ownerType, String ownerId)
{
- if(ownerType == null || ownerId == null)
+ if (ownerType == null || ownerId == null)
{
return null;
}
return this.all_UIPortals.get(new UIPortalKey(ownerType, ownerId));
}
-
+
/**
* Associates the specified UIPortal to a cache map with specified key which bases on OwnerType and OwnerId
*
@@ -264,13 +270,13 @@
{
String ownerType = uiPortal.getOwnerType();
String ownerId = uiPortal.getOwner();
-
- if(ownerType != null && ownerId != null)
+
+ if (ownerType != null && ownerId != null)
{
this.all_UIPortals.put(new UIPortalKey(ownerType, ownerId), uiPortal);
}
}
-
+
/**
* Remove the UIPortal from the cache map
*
@@ -279,13 +285,13 @@
*/
public void removeCachedUIPortal(String ownerType, String ownerId)
{
- if(ownerType == null || ownerId == null)
+ if (ownerType == null || ownerId == null)
{
return;
}
this.all_UIPortals.remove(new UIPortalKey(ownerType, ownerId));
}
-
+
public boolean isSessionOpen()
{
return isSessionOpen;
@@ -331,16 +337,6 @@
return (modeState != NORMAL_MODE);
}
- public String getLastNodePath()
- {
- return lastNodePath;
- }
-
- public void setLastNodePath(String lastNodePath)
- {
- this.lastNodePath = lastNodePath;
- }
-
public Collection<String> getJavascriptURLs()
{
JavascriptConfigService service = getApplicationComponent(JavascriptConfigService.class);
@@ -458,14 +454,14 @@
String portletId = portlet.getSkinId();
if (portletId != null)
{
- return getSkin(portletId, "Default");
+ return getSkin(portletId, SkinService.DEFAULT_SKIN);
}
else
{
return null;
}
}
-
+
private SkinConfig getPortletSkinConfig(UIPortlet portlet)
{
String portletId = portlet.getSkinId();
@@ -478,7 +474,7 @@
return null;
}
}
-
+
/**
* The central area is called the WorkingWorkspace. It is composed of: 1) A
* UIPortal child which is filled with portal data using the PortalDataMapper
@@ -497,10 +493,10 @@
Container container = dataStorage.getSharedLayout();
UIPortal uiPortal = createUIComponent(UIPortal.class, null, null);
PortalDataMapper.toUIPortal(uiPortal, userPortalConfig_);
-
+
this.putCachedUIPortal(uiPortal);
- this.showedUIPortal = uiPortal;
-
+ setCurrentSite(uiPortal);
+
uiWorkingWorkspace.addChild(UIEditInlineWorkspace.class, null, UI_EDITTING_WS_ID).setRendered(false);
if (container != null)
{
@@ -509,13 +505,13 @@
uiContainer.setStorageId(container.getStorageId());
PortalDataMapper.toUIContainer(uiContainer, container);
UISiteBody uiSiteBody = uiContainer.findFirstComponentOfType(UISiteBody.class);
- uiSiteBody.setUIComponent(this.showedUIPortal);
+ uiSiteBody.setUIComponent(this.currentSite);
uiContainer.setRendered(true);
uiViewWS.setUIComponent(uiContainer);
}
else
{
- uiViewWS.setUIComponent(this.showedUIPortal);
+ uiViewWS.setUIComponent(this.currentSite);
}
addChild(UIMaskWorkspace.class, UIPortalApplication.UI_MASK_WS_ID, null);
}
@@ -535,68 +531,55 @@
public void processDecode(WebuiRequestContext context) throws Exception
{
PortalRequestContext pcontext = (PortalRequestContext)context;
- String nodePath = pcontext.getNodePath();
+ String requestURI = pcontext.getRequestURI();
boolean isAjax = pcontext.useAjax();
-
+
if (!isAjax)
{
if (isAjaxInLastRequest)
{
isAjaxInLastRequest = false;
- if (nodePath.equals(lastNonAjaxUri) && !nodePath.equals(lastNodePath))
+ if (requestURI.equals(lastNonAjaxRequestUri) && !requestURI.equals(lastRequestURI))
{
ControllerURL<NavigationResource, NavigationLocator> nodeURL =
pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
- nodeURL.setResource(new NavigationResource(null, getShowedUIPortal().getSelectedNode()));
+ nodeURL.setResource(new NavigationResource(getCurrentSite().getOwnerType(), getCurrentSite()
+ .getOwner().replaceAll("/", "_"), getCurrentSite().getSelectedNode()));
pcontext.sendRedirect(nodeURL.toString());
return;
}
}
- lastNonAjaxUri = nodePath;
+ lastNonAjaxRequestUri = requestURI;
}
-
+
isAjaxInLastRequest = isAjax;
-
- if (!nodePath.equals(lastNodePath))
+
+ if (!requestURI.equals(lastRequestURI))
{
- lastNodePath = nodePath;
+ lastRequestURI = requestURI;
- List<PageNavigation> navigations = getNavigations();
-
- Object[] targets = Util.findBestMatchNavigationAndNode(navigations, nodePath);
- PageNavigation targetNav;
- PageNode targetNode;
- if (targets == null)
- {
- targetNav = navigations.get(0);
- targetNode = Util.findFirstAvailableNode(targetNav, pcontext);
- }
- else
- {
- targetNav = (PageNavigation)targets[0];
- targetNode = (PageNode)targets[1];
- }
-
- pcontext.setTargetNav(targetNav);
- pcontext.setTargetNode(targetNode);
-
StringBuilder baseUriInJS = new StringBuilder("eXo.env.server.portalBaseURL=\"");
baseUriInJS.append(pcontext.getRequestURI()).append("\";");
-
+
pcontext.getJavascriptManager().addCustomizedOnLoadScript(baseUriInJS.toString());
-
+
Event<UIComponent> changeNodeEvent = createEvent(PageNodeEvent.CHANGE_NODE, Event.Phase.PROCESS, pcontext);
changeNodeEvent.broadcast();
}
-
+
if (!isAjax)
{
- lastNonAjaxUri = nodePath;
+ lastNonAjaxRequestUri = requestURI;
}
super.processDecode(pcontext);
+
+ if (currentSite == null || currentSite.getSelectedNode() == null)
+ {
+ pcontext.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }
}
-
+
/**
* The processrender() method handles the creation of the returned HTML
* either for a full page render or in the case of an AJAX call The first
@@ -759,23 +742,46 @@
{
ResourceBundleManager i18nManager = getApplicationComponent(ResourceBundleManager.class);
Locale locale = getLocale();
-
- for(PageNavigation nav : this.getNavigations())
+
+ for (PageNavigation nav : this.getNavigations())
{
PageNavigationUtils.localizePageNavigation(nav, locale, i18nManager);
}
}
-
- public void setNavigations(List<PageNavigation> navs)
+
+ public List<PageNavigation> getNavigations()
{
- this.all_Navigations = navs;
+ return this.userPortalConfig_.getNavigations();
}
-
- public List<PageNavigation> getNavigations()
+
+ public PageNavigation getNavigation(String type, String name)
{
- return this.all_Navigations;
+ for (PageNavigation navi : userPortalConfig_.getNavigations())
+ {
+ if (navi.getOwnerType().equals(type) && navi.getOwnerId().equals(name))
+ {
+ return navi;
+ }
+ }
+ return null;
}
-
+
+ /**
+ * @param set current portal name
+ */
+ public void setPortalName(String portalName)
+ {
+ this.portalName = portalName;
+ }
+
+ /**
+ * @return the current portal name
+ */
+ public String getPortalName()
+ {
+ return portalName;
+ }
+
private class UIPortalKey
{
@@ -812,17 +818,17 @@
}
return this.ownerType.equals(((UIPortalKey)obj).ownerType) && this.ownerId.equals(((UIPortalKey)obj).ownerId);
}
-
+
@Override
public int hashCode()
{
return this.ownerType.hashCode() * 2 + this.ownerId.hashCode();
}
-
+
@Override
public String toString()
{
- return "OWNERTYPE: " + ownerType + " OWNERID: " + ownerId;
+ return "OWNERTYPE: " + ownerType + " OWNERID: " + ownerId;
}
}
14 years, 2 months
gatein SVN: r4918 - in portal/trunk/portlet/exoadmin/src/main: webapp/groovy/applicationregistry/webui/component and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-11-03 07:16:20 -0400 (Wed, 03 Nov 2010)
New Revision: 4918
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIPortletInfo.gtmpl
Log:
GTNPORTAL-1627: XSS issues in the application registry related to category display names
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2010-11-03 11:05:24 UTC (rev 4917)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UICategorySelector.java 2010-11-03 11:16:20 UTC (rev 4918)
@@ -19,6 +19,8 @@
import org.exoplatform.webui.form.UIFormInputSet;
import org.exoplatform.webui.form.UIFormPageIterator;
+import org.gatein.common.text.EntityEncoder;
+
import java.util.ArrayList;
import java.util.List;
@@ -77,6 +79,8 @@
UIFormCheckBoxInput<Boolean> checkBoxInput;
UIFormInputInfo uiInfo;
+ EntityEncoder encoder = EntityEncoder.FULL;
+
//
ApplicationRegistryService appRegService = getApplicationComponent(ApplicationRegistryService.class);
List<ApplicationCategory> categories = getAllCategories();
@@ -91,7 +95,7 @@
defaultValue = appRegService.getApplication(category.getName(), definitionName) != null;
}
checkBoxInput = new UIFormCheckBoxInput<Boolean>("category_" + category.getName(), null, defaultValue);
- uiInfo = new UIFormInputInfo("categoryName", null, category.getDisplayName());
+ uiInfo = new UIFormInputInfo("categoryName", null, encoder.encode(category.getDisplayName()));
uiInputSet.addChild(checkBoxInput);
uiInputSet.addChild(uiInfo);
uiTableInputSet.addChild(uiInputSet);
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-03 11:05:24 UTC (rev 4917)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
@@ -1,6 +1,8 @@
<%
import org.exoplatform.applicationregistry.webui.component.UICategorySelector;
-
+ import org.gatein.common.text.EntityEncoder;
+
+ EntityEncoder encoder = EntityEncoder.FULL;
def gadget = uicomponent.getGadget();
boolean selectorRender = uicomponent.getChild(UICategorySelector.class).isRendered();
String srcBGError = "/eXoResources/skin/sharedImages/Icon80x80/DefaultPortlet.png";
@@ -59,7 +61,7 @@
<table>
<tr>
<td class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.categories")%></td>
- <td class="RightLabel">$categoryNames
+ <td class="RightLabel"><%= encoder.encode(categoryNames) %>
<% if (categoryNames.equals("")) { %>
<%=_ctx.appRes("UIGadgetInfo.label.categories.guide")%><br/>
<% if (!selectorRender) { %>
@@ -80,4 +82,4 @@
uicomponent.renderChildren();
} %>
</div>
-</div>
\ No newline at end of file
+</div>
Modified: portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIPortletInfo.gtmpl
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIPortletInfo.gtmpl 2010-11-03 11:05:24 UTC (rev 4917)
+++ portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIPortletInfo.gtmpl 2010-11-03 11:16:20 UTC (rev 4918)
@@ -2,9 +2,11 @@
import java.util.Iterator;
import java.util.Map.Entry;
import org.exoplatform.applicationregistry.webui.component.UICategorySelector;
+ import org.gatein.common.text.EntityEncoder;
- boolean selectorRender = uicomponent.getChild(UICategorySelector.class).isRendered();
- String categoryNames = uicomponent.getCategorieNames();
+ boolean selectorRender = uicomponent.getChild(UICategorySelector.class).isRendered();
+ String categoryNames = uicomponent.getCategorieNames();
+ EntityEncoder encoder = EntityEncoder.FULL;
def portlet = uicomponent.getPortlet();
def portletPreferences = portlet.getPortletPreferences();
String srcBG = "/" + portlet.getPortletGroup() + "/skin/DefaultSkin/portletIcons/" + portlet.getName() + ".png";
@@ -64,7 +66,7 @@
</tr>
<tr>
<td class="LeftLabel"><%= _ctx.appRes("UIPortletInfo.label.categories") %></td>
- <td class="RightLabel">$categoryNames
+ <td class="RightLabel"><%= encoder.encode(categoryNames) %>
<% if (categoryNames.equals("")) { %>
<%=_ctx.appRes("UIPortletInfo.label.categories.guide")%><br/>
<% if (!selectorRender) { %>
@@ -111,4 +113,4 @@
</table>
</div>
<% }%>
-</div>
\ No newline at end of file
+</div>
14 years, 2 months
gatein SVN: r4917 - in portal/branches/branch-GTNPORTAL-1592: webui/portal/src/main/java/org/exoplatform/portal/application and 2 other directories.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-11-03 07:05:24 -0400 (Wed, 03 Nov 2010)
New Revision: 4917
Modified:
portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
GTNPORTAL-1256: When adding a portlet to a page, HTML header is not refreshed
Modified: portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js 2010-11-03 10:48:58 UTC (rev 4916)
+++ portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalHttpRequest.js 2010-11-03 11:05:24 UTC (rev 4917)
@@ -133,6 +133,8 @@
this.blocksToUpdate[j].scripts = eXo.core.DOMUtil.findDescendantsByTagName(dataBlocks[1], "script") ;
}
+ } else if(div[i].className == "MarkupHeadElements") {
+ this.markupHeadElements = new MarkupHeadElements(div[i]);
} else if(div[i].className == "PortalResponseScript") {
this.script = div[i].innerHTML ;
div[i].style.display = "none" ;
@@ -140,6 +142,16 @@
}
};
+function MarkupHeadElements(fragment) {
+ var DOMUtil = eXo.core.DOMUtil ;
+ this.titles = DOMUtil.findDescendantsByTagName(fragment, "title");
+ this.bases = DOMUtil.findDescendantsByTagName(fragment, "base") ;
+ this.links = DOMUtil.findDescendantsByTagName(fragment, "link") ;
+ this.metas = DOMUtil.findDescendantsByTagName(fragment, "meta") ;
+ this.scripts = DOMUtil.findDescendantsByTagName(fragment, "script") ;
+ this.styles = DOMUtil.findDescendantsByTagName(fragment, "style") ;
+}
+
/*
* This function is used to dynamically append a script to the head tag
* of the page
@@ -158,7 +170,7 @@
//check if contains source attribute
if(scriptElement.src) {
- script.src = scriptElement.src
+ script.src = scriptElement.src;
} else {
script.text = scriptElement.innerHTML;
}
@@ -409,6 +421,89 @@
}
}
} ;
+
+ instance.updateHtmlHead = function(response) {
+ cleanHtmlHead(response);
+
+ var DOMUtil = eXo.core.DOMUtil;
+ var head = document.getElementsByTagName("head")[0];
+ var markupHeadElements = response.markupHeadElements;
+
+ if (markupHeadElements.titles.length != 0) {
+ var oldTitle = DOMUtil.getChildrenByTagName(head, "title")[0];
+ var newTitle = markupHeadElements.titles[markupHeadElements.titles.length - 1];
+ if (oldTitle) {
+ head.replaceChild(newTitle, oldTitle);
+ } else {
+ head.appendChild(newTitle);
+ }
+ }
+
+ appendElementsToHead(markupHeadElements.metas);
+ appendElementsToHead(markupHeadElements.bases);
+ appendElementsToHead(markupHeadElements.links);
+ appendElementsToHead(markupHeadElements.styles);
+ appendElementsToHead(markupHeadElements.scripts);
+ };
+
+ function cleanHtmlHead(response) {
+ var DOMUtil = eXo.core.DOMUtil;
+ var head = document.getElementsByTagName("head")[0];
+
+ var portletResponses = response.portletResponses;
+ if (portletResponses != null) {
+ for (var i = 0; i < portletResponses.length; i++) {
+ removeExtraHead(portletResponses[i].portletId);
+ }
+ }
+
+ var portletFragments = DOMUtil.findDescendantsByClass(response.data, "div", "PORTLET-FRAGMENT");
+ for (var i = 0; i < portletFragments.length; i++) {
+ removeExtraHead(portletFragments[i].parentNode.id);
+ }
+
+ var uiWorkingWorkspace = document.getElementById("UIWorkingWorkspace") ;
+ var portletFragsInWS = DOMUtil.findDescendantsByClass(uiWorkingWorkspace, "div", "PORTLET-FRAGMENT");
+ var exHeads = DOMUtil.getElementsBy(function(elem) {
+ return elem.tagName != "TITLE" && elem.className.indexOf("ExHead-") == 0;
+ }, "*", head);
+
+ for (var i = 0; i < exHeads.length; i++) {
+ var portletId = exHeads[i].className.substring(7);
+ var del = true;
+ for (var j = 0; j < portletFragsInWS.length; j++) {
+ if (portletId == portletFragsInWS[j].parentNode.id) {
+ del = false;
+ break;
+ }
+ }
+ if (del) {
+ head.removeChild(exHeads[i]);
+ }
+ }
+ }
+
+ function removeExtraHead(portletId) {
+ var DOMUtil = eXo.core.DOMUtil;
+ var head = document.getElementsByTagName("head")[0];
+
+ var elemsToRemove = DOMUtil.getElementsBy(function(elem) {
+ return elem.tagName != "TITLE" && elem.className == "ExHead-" + portletId;
+ }, "*", head);
+
+ for (var i = 0; i < elemsToRemove.length; i++) {
+ head.removeChild(elemsToRemove[i]);
+ }
+ }
+
+ function appendElementsToHead(elements) {
+ var head = document.getElementsByTagName("head")[0];
+
+ for (var i = 0; i < elements.length; i++) {
+ head.appendChild(elements[i]);
+ }
+ }
+
/*
* This methods will replace some block content by new one.
* This is the important concept in any AJAX call where JS is used to dynamically
@@ -460,7 +555,7 @@
eXo.portal.AjaxRequest.maskLayer = null ;
eXo.portal.CurrentRequest = null ;
window.location.reload() ;
- }
+ };
/*
* This method is called when the AJAX call is completed and that the request.responseText
@@ -520,6 +615,7 @@
}
//Handle the portal responses
instance.updateBlocks(response.blocksToUpdate) ;
+ instance.updateHtmlHead(response);
instance.executeScript(response.script) ;
/**
* Clears the instance.to timeout if the request takes less time than expected to get response
@@ -556,7 +652,7 @@
eXo.core.UIMaskLayer.showAjaxLoading(eXo.portal.AjaxRequest.maskLayer);
}
}, 2000);
- }
+ };
return instance ;
} ;
Modified: portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-11-03 10:48:58 UTC (rev 4916)
+++ portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-11-03 11:05:24 UTC (rev 4917)
@@ -450,9 +450,11 @@
/**
* Add an extra markup to the head of the html page.
* @param element The element to add
+ * @param portletWindowId The ID of portlet window contributing markup header
*/
- public void addExtraMarkupHeader(Element element)
+ public void addExtraMarkupHeader(Element element, String portletWindowId)
{
+ element.setAttribute("class", "ExHead-" + portletWindowId);
if (this.extraMarkupHeaders == null)
{
this.extraMarkupHeaders = new ArrayList<Element>();
Modified: portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-11-03 10:48:58 UTC (rev 4916)
+++ portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-11-03 11:05:24 UTC (rev 4917)
@@ -256,7 +256,7 @@
{
for (Element element : markupElements)
{
- if ("title".equals(element.getNodeName().toLowerCase())
+ if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())
&& element.getFirstChild() != null)
{
String title = element.getFirstChild().getTextContent();
@@ -264,7 +264,7 @@
}
else
{
- prcontext.addExtraMarkupHeader(element);
+ prcontext.addExtraMarkupHeader(element, uicomponent.getId());
}
}
}
Modified: portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-11-03 10:48:58 UTC (rev 4916)
+++ portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-11-03 11:05:24 UTC (rev 4917)
@@ -596,7 +596,13 @@
w.write("</div>");
}
}
-
+ w.write("<div class=\"MarkupHeadElements\">");
+ List<String> headElems = ((PortalRequestContext)context).getExtraMarkupHeadersAsStrings();
+ for (String elem : headElems)
+ {
+ w.write(elem);
+ }
+ w.write("</div>");
w.write("<div class=\"PortalResponseScript\">");
pcontext.getJavascriptManager().writeJavascript(w);
w.write("eXo.core.Browser.onLoad();\n");
14 years, 2 months
gatein SVN: r4916 - in portal/branches/branch-GTNPORTAL-1592/component/common/src: test/java/org/exoplatform/commons/xml and 1 other directory.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-11-03 06:48:58 -0400 (Wed, 03 Nov 2010)
New Revision: 4916
Modified:
portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java
portal/branches/branch-GTNPORTAL-1592/component/common/src/test/java/org/exoplatform/commons/xml/TestDOMSerializer.java
Log:
GTNPORTAL-1626: Text content of XML Element, serialized by DOMSerializer, is always wrapped in a CDATA section
Modified: portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java 2010-11-03 09:06:49 UTC (rev 4915)
+++ portal/branches/branch-GTNPORTAL-1592/component/common/src/main/java/org/exoplatform/commons/xml/DOMSerializer.java 2010-11-03 10:48:58 UTC (rev 4916)
@@ -21,7 +21,9 @@
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.gatein.common.text.EntityEncoder;
import org.w3c.dom.Attr;
+import org.w3c.dom.CDATASection;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -145,10 +147,14 @@
for (int i = 0;i < length;i++)
{
Node child = children.item(i);
- if (child instanceof CharacterData)
+ if(child instanceof CDATASection)
{
- writer.writeCData(((CharacterData)child).getData());
+ writer.writeCData(((CDATASection)child).getData());
}
+ else if (child instanceof CharacterData)
+ {
+ writeTextData(writer, ((CharacterData)child).getData());
+ }
else if (child instanceof Element)
{
serialize((Element)child, writer);
@@ -159,4 +165,22 @@
writer.writeEndElement();
}
}
+
+ private static void writeTextData(XMLStreamWriter writer, String data) throws XMLStreamException
+ {
+ for(int i = 0; i < data.length(); i++)
+ {
+ char c = data.charAt(i);
+ String encodedValue = EntityEncoder.FULL.lookup(c);
+
+ if(encodedValue == null)
+ {
+ writer.writeCharacters("" + c);
+ }
+ else
+ {
+ writer.writeCharacters(encodedValue);
+ }
+ }
+ }
}
Modified: portal/branches/branch-GTNPORTAL-1592/component/common/src/test/java/org/exoplatform/commons/xml/TestDOMSerializer.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/component/common/src/test/java/org/exoplatform/commons/xml/TestDOMSerializer.java 2010-11-03 09:06:49 UTC (rev 4915)
+++ portal/branches/branch-GTNPORTAL-1592/component/common/src/test/java/org/exoplatform/commons/xml/TestDOMSerializer.java 2010-11-03 10:48:58 UTC (rev 4916)
@@ -58,6 +58,16 @@
{
assertSerialization("<meta http-equiv=\"Content-Type\"/>", "<meta http-equiv='Content-Type'></meta>");
}
+
+ public void testOrdinaryTextElement() throws Exception
+ {
+ assertSerialization("<div>Blah Blah</div>", "<div>Blah Blah</div>");
+ }
+
+ public void testCDATaElement() throws Exception
+ {
+ assertSerialization("<div><![CDATA[Test Content]]></div>", "<div><![CDATA[Test Content]]></div>");
+ }
private void assertSerialization(String expectedMarkup, String markup) throws Exception
{
14 years, 2 months
gatein SVN: r4915 - portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal.
by do-not-reply@jboss.org
Author: ndkhoiits
Date: 2010-11-03 05:06:49 -0400 (Wed, 03 Nov 2010)
New Revision: 4915
Modified:
portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
Log:
GTNPORTAL-1254 Error display when DnD some containers does not have portlet
Modified: portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-11-03 07:38:52 UTC (rev 4914)
+++ portal/branches/branch-GTNPORTAL-1592/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-11-03 09:06:49 UTC (rev 4915)
@@ -212,6 +212,10 @@
trContainer.appendChild(previewTD) ;
}
}
+ var dragParent = dragObject.parentNode;
+ if (eXo.core.DOMUtil.getChildrenByTagName(dragParent, "div").length === 1 && !eXo.core.DOMUtil.hasClass(dragParent, "EmptyContainer")) {
+ eXo.core.DOMUtil.addClass(dragParent, "EmptyContainer");
+ }
} ;
DragDrop.dropCallback = function(dndEvent) {
@@ -453,6 +457,8 @@
} else {
uiRowContainer.appendChild(srcElement) ;
}
+
+ eXo.core.DOMUtil.removeClass(uiRowContainer, "EmptyContainer");
if(parentNode.nodeName.toLowerCase() == "td") {
eXo.core.DOMUtil.removeElement(parentNode) ;
14 years, 2 months