[gatein-commits] gatein SVN: r4931 - portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/page.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 4 00:58:01 EDT 2010


Author: kien_nguyen
Date: 2010-11-04 00:58:01 -0400 (Thu, 04 Nov 2010)
New Revision: 4931

Modified:
   portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
Log:
GTNPORTAL-633 Use list instead of textfield in page management when adding a page

Modified: portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java	2010-11-04 00:19:02 UTC (rev 4930)
+++ portal/branches/branch-GTNPORTAL-1592/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java	2010-11-04 04:58:01 UTC (rev 4931)
@@ -32,6 +32,7 @@
 import org.exoplatform.portal.config.model.PortalConfig;
 import org.exoplatform.portal.webui.application.UIPortlet;
 import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.portal.UIPortal;
 import org.exoplatform.portal.webui.portal.UIPortalComponent;
 import org.exoplatform.portal.webui.portal.UIPortalComposer;
 import org.exoplatform.portal.webui.util.PortalDataMapper;
@@ -90,6 +91,8 @@
    protected UIFormInputSet uiPermissionSetting;
 
    protected UIFormSelectBox groupIdSelectBox = null;
+   
+   protected UIFormSelectBox portalIdSelectBox = null;
 
    protected UIFormStringInput ownerIdInput = null;
 
@@ -106,14 +109,6 @@
       List<SelectItemOption<String>> ownerTypes = new ArrayList<SelectItemOption<String>>();
       ownerTypes.add(new SelectItemOption<String>(PortalConfig.USER_TYPE));
 
-      UserPortalConfig userPortalConfig =
-         configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
-      ExoContainer container = ExoContainerContext.getCurrentContainer();
-      UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
-      if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
-      {
-         ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
-      }
       ownerIdInput = new UIFormStringInput(OWNER_ID, OWNER_ID, null);
       ownerIdInput.setEditable(false).setValue(pcontext.getRemoteUser());
 
@@ -153,6 +148,28 @@
       //TODO: This following line is fixed for bug PORTAL-2127
       uiListPermissionSelector.getChild(UIFormPopupWindow.class).setId("UIPageFormPopupGroupMembershipSelector");
 
+      UserPortalConfig userPortalConfig =
+         configService.getUserPortalConfig(pcontext.getPortalOwner(), pcontext.getRemoteUser());
+      ExoContainer container = ExoContainerContext.getCurrentContainer();
+      UserACL acl = (UserACL)container.getComponentInstanceOfType(UserACL.class);
+      if (acl.hasEditPermission(userPortalConfig.getPortalConfig()))
+      {
+         ownerTypes.add(new SelectItemOption<String>(PortalConfig.PORTAL_TYPE));
+         List<String> portals = configService.getAllPortalNames();
+         if (portals.size() > 0)
+         {
+            Collections.sort(portals);
+            List<SelectItemOption<String>> portalsItem = new ArrayList<SelectItemOption<String>>();
+            for (String p : portals)
+            {
+               portalsItem.add(new SelectItemOption<String>(p));
+            }
+            portalIdSelectBox = new UIFormSelectBox(OWNER_ID, OWNER_ID, portalsItem);
+            portalIdSelectBox.setOnChange("ChangeOwnerId");
+            portalIdSelectBox.setParent(uiSettingSet);
+         }
+      }
+      
       List<String> groups = configService.getMakableNavigations(pcontext.getRemoteUser(), true);
       if (groups.size() > 0)
       {
@@ -167,6 +184,7 @@
          groupIdSelectBox.setOnChange("ChangeOwnerId");
          groupIdSelectBox.setParent(uiSettingSet);
       }
+
       setActions(new String[]{"Save", "Close"});
    }
 
@@ -208,11 +226,6 @@
       uiTemplate.setValue(uiPage.getFactoryId());
    }
 
-   public void setEditPermission(String per)
-   {
-
-   }
-
    public void invokeSetBindingBean(Object bean) throws Exception
    {
       String ownerType = getUIFormSelectBox("ownerType").getValue();
@@ -418,12 +431,28 @@
             if (PortalConfig.PORTAL_TYPE.equals(ownerType))
             {
                list.remove(2);
-               list.add(2, uiForm.ownerIdInput);
-               uiForm.ownerIdInput.setValue(prContext.getPortalOwner());
-               uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(
-                  Util.getUIPortal().getAccessPermissions());
-               uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(
-                  Util.getUIPortal().getEditPermission());
+               list.add(2, uiForm.portalIdSelectBox);
+               String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+               String[] accessPermissions = {};
+               String editPermission = "";
+               
+               UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+               UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, prContext.getRemoteUser());
+               if (userConfig != null)
+               {
+                  PortalConfig config = userConfig.getPortalConfig();
+                  accessPermissions = config.getAccessPermissions();
+                  editPermission = config.getEditPermission();
+               }
+               else
+               {
+                  UIPortal uiPortal = Util.getUIPortalApplication().getCachedUIPortal(ownerType, portalIdSelected);
+                  accessPermissions = uiPortal.getAccessPermissions();
+                  editPermission = uiPortal.getEditPermission();
+               }
+               
+               uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+               uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
             }
             else
             {
@@ -447,13 +476,33 @@
       public void execute(Event<UIPageForm> event) throws Exception
       {
          UIPageForm uiForm = event.getSource();
-         String groupIdSelected = uiForm.groupIdSelectBox.getValue();
-         groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
-         String permission = "*:" + groupIdSelected;
-         uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
-         UserACL userACL = uiForm.getApplicationComponent(UserACL.class);         
-         permission = userACL.getMakableMT() + ":" + groupIdSelected;
-         uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+         UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
+         String ownerType = uiSelectBox.getValue();
+         if(PortalConfig.PORTAL_TYPE.equals(ownerType)) {
+            String[] accessPermissions = {};
+            String editPermission = "";
+            String portalIdSelected = uiForm.portalIdSelectBox.getValue();
+            UserPortalConfigService service = uiForm.getApplicationComponent(UserPortalConfigService.class);
+            UserPortalConfig userConfig = service.getUserPortalConfig(portalIdSelected, Util.getPortalRequestContext().getRemoteUser());
+            if (userConfig != null)
+            {
+               PortalConfig config = userConfig.getPortalConfig();
+               accessPermissions = config.getAccessPermissions();
+               editPermission = config.getEditPermission();
+               uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(accessPermissions);
+               uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(editPermission);
+            }
+         }
+         else
+         {
+            String groupIdSelected = uiForm.groupIdSelectBox.getValue();
+            groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected;
+            String permission = "*:" + groupIdSelected;
+            uiForm.findFirstComponentOfType(UIListPermissionSelector.class).setValue(new String[]{permission});
+            UserACL userACL = uiForm.getApplicationComponent(UserACL.class);         
+            permission = userACL.getMakableMT() + ":" + groupIdSelected;
+            uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission);
+         }
          event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
       }
    }



More information about the gatein-commits mailing list