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;
}
}