Author: chris.laprun(a)jboss.com
Date: 2010-01-15 05:55:37 -0500 (Fri, 15 Jan 2010)
New Revision: 1311
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
Log:
- Remove System.out output.
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 2010-01-15
10:45:53 UTC (rev 1310)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-01-15
10:55:37 UTC (rev 1311)
@@ -1,16 +1,16 @@
/**
* 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
@@ -26,13 +26,13 @@
import org.exoplatform.container.component.RequestLifeCycle;
import org.exoplatform.portal.config.model.Application;
import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.portal.config.model.ModelObject;
import org.exoplatform.portal.config.model.Page;
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.TransientApplicationState;
+import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.services.listener.ListenerService;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -49,8 +49,8 @@
import java.util.Set;
/**
- * Created by The eXo Platform SAS Apr 19, 2007 This service is used to load the
- * PortalConfig, Page config and Navigation config for a given user.
+ * Created by The eXo Platform SAS Apr 19, 2007 This service is used to load the
PortalConfig, Page config and
+ * Navigation config for a given user.
*/
public class UserPortalConfigService implements Startable
{
@@ -93,32 +93,22 @@
}
/**
- * <p>
- * Build and returns an instance of <tt>UserPortalConfig</tt>.
- * </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>
- * The navigation loaded on the
- * <tt>UserPortalConfig<tt> object are obtained according to the specified
user
+ * <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:
- *
- * <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/>
+ * <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>
*
@@ -131,7 +121,9 @@
{
PortalConfig portal = storage_.getPortalConfig(portalName);
if (portal == null || !userACL_.hasPermission(portal))
+ {
return null;
+ }
List<PageNavigation> navigations = new ArrayList<PageNavigation>();
PageNavigation navigation = getPageNavigation(PortalConfig.PORTAL_TYPE,
portalName);
@@ -159,18 +151,26 @@
Collection<?> groups = null;
if (userACL_.getSuperUser().equals(accessUser))
+ {
groups = orgService_.getGroupHandler().getAllGroups();
+ }
else
+ {
groups = orgService_.getGroupHandler().findGroupsOfUser(accessUser);
+ }
for (Object group : groups)
{
Group m = (Group)group;
String groupId = m.getId().trim();
if (groupId.equals(userACL_.getGuestsGroup()))
+ {
continue;
+ }
navigation = getPageNavigation(PortalConfig.GROUP_TYPE, groupId);
if (navigation == null)
+ {
continue;
+ }
navigation.setModifiable(userACL_.hasEditPermission(navigation));
navigations.add(navigation);
}
@@ -187,26 +187,26 @@
}
/**
- * 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
- * {@link org.exoplatform.portal.config.UserACL#getMakableMT()}
- *
- * @param remoteUser
- * the user to get the makable navigations
+ * 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 {@link
org.exoplatform.portal.config.UserACL#getMakableMT()}
+ *
+ * @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
{
List<String> list = new ArrayList<String>();
Collection<?> groups = null;
if (remoteUser.equals(userACL_.getSuperUser()))
+ {
groups = orgService_.getGroupHandler().getAllGroups();
+ }
else
+ {
groups = orgService_.getGroupHandler().findGroupByMembership(remoteUser,
userACL_.getMakableMT());
+ }
if (groups != null)
{
for (Object group : groups)
@@ -220,15 +220,11 @@
}
/**
- * 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
+ * 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
*/
public void createUserPortalConfig(String ownerType, String portalName, String
template) throws Exception
{
@@ -247,13 +243,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
+ * 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
*/
public void removeUserPortalConfig(String portalName) throws Exception
{
@@ -261,15 +254,11 @@
}
/**
- * 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
+ * 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
*/
public void removeUserPortalConfig(String ownerType, String ownerId) throws Exception
{
@@ -282,7 +271,7 @@
/**
* This method should update the PortalConfig object
- *
+ *
* @param portal
* @throws Exception
*/
@@ -293,34 +282,29 @@
/**
* 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
{
if (pageId == null)
+ {
return null;
+ }
return storage_.getPage(pageId); // TODO: pageConfigCache_ needs to be
}
/**
- * This method load the page according to the pageId and returns it if the
- * current thread is associated with an identity that allows to view the page
- * according to the
- * {@link UserACL#hasPermission(org.exoplatform.portal.config.model.Page)}
+ * This method load the page according to the pageId and returns it if the current
thread is associated with an
+ * identity that allows to view the page according to the {@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
{
@@ -333,14 +317,11 @@
}
/**
- * Removes a page and broadcast an event labelled as
- * {@link org.exoplatform.portal.config.UserPortalConfigService#REMOVE_PAGE_EVENT}
+ * Removes a page and broadcast an event labelled as {@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
{
@@ -349,14 +330,11 @@
}
/**
- * Creates a page and broadcast an event labelled as
- * {@link org.exoplatform.portal.config.UserPortalConfigService#CREATE_PAGE_EVENT}
+ * Creates a page and broadcast an event labelled as {@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
{
@@ -367,19 +345,15 @@
}
/**
- * Updates a page and broadcast an event labelled as
- * {@link org.exoplatform.portal.config.UserPortalConfigService#UPDATE_PAGE_EVENT}
+ * Updates a page and broadcast an event labelled as {@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
{
- System.out.println("\n\n\n show max window : " + page.isShowMaxWindow() +
"\n\n");
List<ModelChange> changes = storage_.save(page);
//
@@ -388,14 +362,11 @@
}
/**
- * Creates a navigation and broadcast an event labelled as
- * {@link
org.exoplatform.portal.config.UserPortalConfigService#CREATE_NAVIGATION_EVENT}
+ * Creates a navigation and broadcast an event labelled as {@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
{
@@ -404,14 +375,11 @@
}
/**
- * Updates a page navigation broadcast an event labelled as
- * {@link
org.exoplatform.portal.config.UserPortalConfigService#UPDATE_NAVIGATION_EVENT}
+ * Updates a page navigation broadcast an event labelled as {@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
{
@@ -420,14 +388,11 @@
}
/**
- * Removes a navigation and broadcast an event labelled as
- * {@link
org.exoplatform.portal.config.UserPortalConfigService#REMOVE_NAVIGATION_EVENT}
+ * Removes a navigation and broadcast an event labelled as {@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
{
@@ -442,9 +407,8 @@
}
/**
- * This method creates new page from an existing page and links new page to a
- * PageNode.
- *
+ * This method creates new page from an existing page and links new page to a
PageNode.
+ *
* @param nodeName
* @param nodeLabel
* @param pageId
@@ -454,12 +418,14 @@
* @throws Exception
*/
public PageNode createNodeFromPageTemplate(String nodeName, String nodeLabel, String
pageId, String ownerType,
- String ownerId) throws Exception
+ String ownerId) throws Exception
{
Page page = renewPage(pageId, nodeName, ownerType, ownerId);
PageNode pageNode = new PageNode();
if (nodeLabel == null || nodeLabel.trim().length() < 1)
+ {
nodeLabel = nodeName;
+ }
pageNode.setName(nodeName);
pageNode.setLabel(nodeLabel);
pageNode.setPageReference(page.getPageId());
@@ -468,18 +434,13 @@
/**
* 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
{
@@ -488,16 +449,12 @@
/**
* 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
{
@@ -508,10 +465,9 @@
/**
* 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,10 +494,9 @@
/**
* Returns the list of group ids having navigation.
- *
+ *
* @return the group id having navigation
- * @throws Exception
- * any exception
+ * @throws Exception any exception
*/
public Set<String> findGroupHavingNavigation() throws Exception
{
@@ -557,10 +512,9 @@
/**
* 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
{
@@ -580,13 +534,10 @@
/**
* 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)
{
@@ -640,7 +591,9 @@
try
{
if (newPortalConfigListener_ == null)
+ {
return;
+ }
//
RequestLifeCycle.begin(PortalContainer.getInstance());