Ejemplo n.º 1
0
 public void execute(Event<UIPageForm> event) throws Exception {
   UIPageForm uiForm = event.getSource();
   UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE);
   String ownerType = uiSelectBox.getValue();
   PortalRequestContext prContext = Util.getPortalRequestContext();
   UIFormInputSet uiSettingSet = uiForm.getChildById("PageSetting");
   uiForm.setSelectedTab("PageSetting");
   List<UIComponent> list = uiSettingSet.getChildren();
   if (PortalConfig.USER_TYPE.equals(ownerType)) {
     uiForm.removeChildById("PermissionSetting");
     list.remove(2);
     list.add(2, uiForm.ownerIdInput);
     uiForm.ownerIdInput.setValue(prContext.getRemoteUser());
   } else {
     if (uiForm.getChildById("PermissionSetting") == null) {
       uiForm.addUIComponentInput(uiForm.uiPermissionSetting);
     }
     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());
     } else {
       list.remove(2);
       list.add(2, uiForm.groupIdSelectBox);
       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);
     }
   }
   prContext.addUIComponentToUpdateByAjax(uiForm.getParent());
 }