Author: truong.le
Date: 2009-11-05 02:43:12 -0500 (Thu, 05 Nov 2009)
New Revision: 500
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
Log:
GTNPORTAL-197: Refresh navigation after a navigation is saved in datastorage
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2009-11-05
07:41:43 UTC (rev 499)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2009-11-05
07:43:12 UTC (rev 500)
@@ -201,13 +201,15 @@
/**
* Compute and returns the list that the specified user can manage. If the
* user is root then all existing groups are returned otherwise the list is
- * computed from the groups in which the user has a configured membership. The
- * membership is configured from the value returned by
+ * computed from the groups in which the user has a configured membership.
+ * The membership is configured from the value returned by
* {@link org.exoplatform.portal.config.UserACL#getMakableMT()}
*
- * @param remoteUser the user to get the makable navigations
+ * @param remoteUser
+ * the user to get the makable navigations
* @return the list of groups
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public List<String> getMakableNavigations(String remoteUser) throws Exception
{
@@ -233,9 +235,12 @@
* This method should create a the portal config, pages and navigation
* according to the template name.
*
- * @param portalName the portal name
- * @param template the template to use
- * @throws Exception any exception
+ * @param portalName
+ * the portal name
+ * @param template
+ * the template to use
+ * @throws Exception
+ * any exception
*/
public void createUserPortalConfig(String ownerType, String portalName, String
template) throws Exception
{
@@ -257,8 +262,10 @@
* This method removes the PortalConfig, Page and PageNavigation that belong
* to the portal in the database.
*
- * @param portalName the portal name
- * @throws Exception any exception
+ * @param portalName
+ * the portal name
+ * @throws Exception
+ * any exception
*/
public void removeUserPortalConfig(String portalName) throws Exception
{
@@ -268,10 +275,13 @@
/**
* This method removes the PortalConfig, Page and PageNavigation that belong
* to the portal in the database.
- *
- * @param ownerType the owner type
- * @param ownerId the portal name
- * @throws Exception any exception
+ *
+ * @param ownerType
+ * the owner type
+ * @param ownerId
+ * the portal name
+ * @throws Exception
+ * any exception
*/
public void removeUserPortalConfig(String ownerType, String ownerId) throws Exception
{
@@ -301,9 +311,11 @@
/**
* This method load the page according to the pageId and returns.
*
- * @param pageId the page id
+ * @param pageId
+ * the page id
* @return the page
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public Page getPage(String pageId) throws Exception
{
@@ -323,10 +335,13 @@
* {@link UserACL#hasPermission(org.exoplatform.portal.config.model.Page)}
* method.
*
- * @param pageId the page id
- * @param accessUser never used
+ * @param pageId
+ * the page id
+ * @param accessUser
+ * never used
* @return the page
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public Page getPage(String pageId, String accessUser) throws Exception
{
@@ -348,8 +363,10 @@
* {@link org.exoplatform.portal.config.UserPortalConfigService#REMOVE_PAGE_EVENT}
* when the removal is successful.
*
- * @param page the page to remove
- * @throws Exception any exception
+ * @param page
+ * the page to remove
+ * @throws Exception
+ * any exception
*/
public void remove(Page page) throws Exception
{
@@ -363,8 +380,10 @@
* {@link org.exoplatform.portal.config.UserPortalConfigService#CREATE_PAGE_EVENT}
* when the creation is successful.
*
- * @param page the page to create
- * @throws Exception any exception
+ * @param page
+ * the page to create
+ * @throws Exception
+ * any exception
*/
public void create(Page page) throws Exception
{
@@ -382,9 +401,11 @@
* {@link org.exoplatform.portal.config.UserPortalConfigService#UPDATE_PAGE_EVENT}
* when the creation is successful.
*
- * @param page the page to update
+ * @param page
+ * the page to update
* @return the list of model changes that occured
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public List<ModelChange> update(Page page) throws Exception
{
@@ -403,12 +424,15 @@
* {@link
org.exoplatform.portal.config.UserPortalConfigService#CREATE_NAVIGATION_EVENT}
* when the creation is successful.
*
- * @param navigation the navigation to create
- * @throws Exception any exception
+ * @param navigation
+ * the navigation to create
+ * @throws Exception
+ * any exception
*/
public void create(PageNavigation navigation) throws Exception
{
storage_.create(navigation);
+ navigation.setSerialMark(System.currentTimeMillis());
pageNavigationCache_.put(navigation.getOwner(), navigation);
listenerService.broadcast(CREATE_NAVIGATION_EVENT, this, navigation);
}
@@ -418,8 +442,10 @@
* {@link
org.exoplatform.portal.config.UserPortalConfigService#UPDATE_NAVIGATION_EVENT}
* when the creation is successful.
*
- * @param navigation the navigation to update
- * @throws Exception any exception
+ * @param navigation
+ * the navigation to update
+ * @throws Exception
+ * any exception
*/
public void update(PageNavigation navigation) throws Exception
{
@@ -433,8 +459,10 @@
* {@link
org.exoplatform.portal.config.UserPortalConfigService#REMOVE_NAVIGATION_EVENT}
* when the removal is successful.
*
- * @param navigation the navigation to remove
- * @throws Exception any exception
+ * @param navigation
+ * the navigation to remove
+ * @throws Exception
+ * any exception
*/
public void remove(PageNavigation navigation) throws Exception
{
@@ -445,9 +473,16 @@
public PageNavigation getPageNavigation(String ownerType, String id) throws Exception
{
- PageNavigation navigation = pageNavigationCache_.get(ownerType + "::" +
id);
+ PageNavigation navigation = (PageNavigation)pageNavigationCache_.get(ownerType +
"::" + id);
if (navigation == null)
+ {
navigation = storage_.getPageNavigation(ownerType, id);
+ if (navigation != null)
+ {
+ navigation.setSerialMark(System.currentTimeMillis());
+ pageNavigationCache_.put(navigation.getOwner(), navigation);
+ }
+ }
return navigation;
}
@@ -479,12 +514,17 @@
/**
* Clones a page.
*
- * @param pageId the id of the page to clone
- * @param pageName the new page name
- * @param ownerType the new page owner type
- * @param ownerId the new page owner id
+ * @param pageId
+ * the id of the page to clone
+ * @param pageName
+ * the new page name
+ * @param ownerType
+ * the new page owner type
+ * @param ownerId
+ * the new page owner id
* @return the newly created page
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public Page renewPage(String pageId, String pageName, String ownerType, String
ownerId) throws Exception
{
@@ -493,12 +533,16 @@
/**
* Creates a page from an existing template.
- *
- * @param temp the template name
- * @param ownerType the new owner type
- * @param ownerId the new owner id
+ *
+ * @param temp
+ * the template name
+ * @param ownerType
+ * the new owner type
+ * @param ownerId
+ * the new owner id
* @return the page
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public Page createPageTemplate(String temp, String ownerType, String ownerId) throws
Exception
{
@@ -509,9 +553,10 @@
/**
* Load all navigation that user has edit permission.
- *
+ *
* @return the navigation the user can edit
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public List<PageNavigation> loadEditableNavigations() throws Exception
{
@@ -538,9 +583,10 @@
/**
* Returns the list of group ids that do not have an existing navigation.
- *
+ *
* @return the group id with no navigation
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public Set<String> findGroupWithoutNavigation() throws Exception
{
@@ -556,9 +602,10 @@
/**
* Returns the list of all portal names.
- *
+ *
* @return the list of all portal names
- * @throws Exception any exception
+ * @throws Exception
+ * any exception
*/
public List<String> getAllPortalNames() throws Exception
{
@@ -578,10 +625,13 @@
/**
* Update the ownership recursively on the model graph.
- *
- * @param object the model object graph root
- * @param ownerType the new owner type
- * @param ownerId the new owner id
+ *
+ * @param object
+ * the model object graph root
+ * @param ownerType
+ * the new owner type
+ * @param ownerId
+ * the new owner id
*/
private void updateOwnership(ModelObject object, String ownerType, String ownerId)
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java 2009-11-05
07:41:43 UTC (rev 499)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/PageNavigation.java 2009-11-05
07:43:12 UTC (rev 500)
@@ -47,6 +47,8 @@
private int priority = 1;
+ private long serialMark;
+
PageNavigation(String storageId)
{
super(storageId);
@@ -188,16 +190,26 @@
return null;
}
+ public long getSerialMark()
+ {
+ return serialMark;
+ }
+
+ public void setSerialMark(long serialModifiedKey)
+ {
+ this.serialMark = serialModifiedKey;
+ }
+
public PageNavigation clone()
{
PageNavigation newNav = new PageNavigation();
newNav.setOwnerId(ownerId);
newNav.setOwnerType(ownerType);
newNav.setPriority(priority);
- // newNav.setAccessPermissions(accessPermissions);
- // newNav.setEditPermission(editPermission);
+ // newNav.setAccessPermissions(accessPermissions);
+ // newNav.setEditPermission(editPermission);
newNav.setModifiable(modifiable);
- // newNav.setDescription(description);
+ // newNav.setDescription(description);
newNav.setCreator(creator);
newNav.setModifier(modifier);
@@ -261,15 +273,6 @@
public NavigationData build()
{
List<NavigationNodeData> children = buildNavigationChildren();
- return new NavigationData(
- storageId,
- ownerType,
- ownerId,
- description,
- creator,
- modifier,
- priority,
- children
- );
+ return new NavigationData(storageId, ownerType, ownerId, description, creator,
modifier, priority, children);
}
}
\ No newline at end of file
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2009-11-05
07:41:43 UTC (rev 499)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2009-11-05
07:43:12 UTC (rev 500)
@@ -152,7 +152,7 @@
appRes_ = getApplication().getResourceBundle(getLocale());
}
- public String getTitle()
+ public String getTitle() throws Exception
{
String title = (String)request_.getAttribute(REQUEST_TITLE);
if (title != null)
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2009-11-05
07:41:43 UTC (rev 499)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2009-11-05
07:43:12 UTC (rev 500)
@@ -128,7 +128,7 @@
return treeNode_;
}
- public PageNavigation getSelectedNavigation()
+ public PageNavigation getSelectedNavigation() throws Exception
{
PageNavigation nav = Util.getUIPortal().getSelectedNavigation();
if (nav != null)
@@ -143,7 +143,7 @@
return selectedParent_;
}
- public PageNode getSelectedPageNode()
+ public PageNode getSelectedPageNode() throws Exception
{
if (selectedNode_ != null)
return selectedNode_;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2009-11-05
07:41:43 UTC (rev 499)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2009-11-05
07:43:12 UTC (rev 500)
@@ -21,6 +21,7 @@
import org.exoplatform.portal.account.UIAccountSetting;
import org.exoplatform.portal.application.PortalRequestContext;
+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;
@@ -64,7 +65,8 @@
@EventConfig(listeners = ChangePageNodeActionListener.class),
@EventConfig(listeners = ChangeApplicationListActionListener.class),
@EventConfig(listeners = MoveChildActionListener.class),
- // @EventConfig(listeners = RemoveJSApplicationToDesktopActionListener.class),
+ // @EventConfig(listeners =
+ // RemoveJSApplicationToDesktopActionListener.class),
@EventConfig(listeners = UIPortal.ChangeWindowStateActionListener.class),
@EventConfig(listeners = UIPortal.LogoutActionListener.class),
@EventConfig(listeners = ShowLoginFormActionListener.class),
@@ -186,8 +188,29 @@
publicParameters_ = publicParams;
}
- public List<PageNavigation> getNavigations()
+ public List<PageNavigation> getNavigations() throws Exception
{
+ UserPortalConfigService serv =
getApplicationComponent(UserPortalConfigService.class);
+ for (int i = 0; i < navigations.size(); i++)
+ {
+ PageNavigation ele = navigations.get(i);
+ PageNavigation temp = serv.getPageNavigation(ele.getOwnerType(),
ele.getOwnerId());
+ if (temp != null)
+ {
+ if (temp.getSerialMark() != ele.getSerialMark())
+ {
+ temp.setModifiable(ele.isModifiable());
+ localizePageNavigation(temp);
+ navigations.set(i, temp);
+ }
+ }
+ else
+ {
+ navigations.remove(i);
+ --i;
+ }
+ }
+
return navigations;
}
@@ -197,11 +220,11 @@
selectedPaths_ = new ArrayList<PageNode>();
if (navigations == null || navigations.size() < 1)
return;
- // PageNavigation pNav = navigations.get(0);
- // if(pNav.getNodes() == null || pNav.getNodes().size() < 1) return;
+ // PageNavigation pNav = navigations.get(0);
+ // if(pNav.getNodes() == null || pNav.getNodes().size() < 1) return;
- //TODO dang.tung: get suitable navigation
- //----------------------------------------------------------
+ // TODO dang.tung: get suitable navigation
+ // ----------------------------------------------------------
PageNavigation pNav = null;
for (PageNavigation nav : navs)
{
@@ -213,7 +236,7 @@
}
if (pNav == null)
return;
- //----------------------------------------------------------
+ // ----------------------------------------------------------
selectedNode_ = pNav.getNodes().get(0);
selectedPaths_.add(selectedNode_);
UIPageBody uiPageBody = findFirstComponentOfType(UIPageBody.class);
@@ -229,7 +252,7 @@
selectedNode_ = node;
}
- public PageNode getSelectedNode()
+ public PageNode getSelectedNode() throws Exception
{
if (selectedNode_ != null)
return selectedNode_;
@@ -250,7 +273,7 @@
selectedPaths_ = nodes;
}
- public PageNavigation getSelectedNavigation()
+ public PageNavigation getSelectedNavigation() throws Exception
{
if (selectedNavigation_ != null && selectedNavigation_.getNodes() != null
&& selectedNavigation_.getNodes().size() > 0)
@@ -259,8 +282,8 @@
}
if (getNavigations().size() < 1)
return null;
- //TODO dang.tung: get right selectedNavigation
- //-------------------------------------------
+ // TODO dang.tung: get right selectedNavigation
+ // -------------------------------------------
List<PageNavigation> navs = getNavigations();
PageNavigation pNav = navs.get(0);
for (PageNavigation nav : navs)
@@ -271,7 +294,7 @@
break;
}
}
- //-------------------------------------------
+ // -------------------------------------------
setSelectedNavigation(pNav);
return pNav;
}
@@ -373,20 +396,24 @@
public void refreshNavigation(Locale locale)
{
- ResourceBundleManager mgr = getApplicationComponent(ResourceBundleManager.class);
for (PageNavigation nav : navigations)
{
- if (nav.getOwnerType().equals(PortalConfig.USER_TYPE))
- continue;
- ResourceBundle res =
- mgr.getNavigationResourceBundle(locale.getLanguage(), nav.getOwnerType(),
nav.getOwnerId());
- for (PageNode node : nav.getNodes())
- {
- resolveLabel(res, node);
- }
+ localizePageNavigation(nav);
}
}
+ private void localizePageNavigation(PageNavigation nav)
+ {
+ ResourceBundleManager mgr = getApplicationComponent(ResourceBundleManager.class);
+ if (nav.getOwnerType().equals(PortalConfig.USER_TYPE))
+ return;
+ ResourceBundle res = mgr.getNavigationResourceBundle(locale, nav.getOwnerType(),
nav.getOwnerId());
+ for (PageNode node : nav.getNodes())
+ {
+ resolveLabel(res, node);
+ }
+ }
+
private void resolveLabel(ResourceBundle res, PageNode node)
{
node.setResolvedLabel(res);
@@ -409,7 +436,8 @@
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
prContext.getResponse().addCookie(cookie);
- //String portalName = URLEncoder.encode(Util.getUIPortal().getName(),
"UTF-8") ;
+ // 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);