Example #1
0
 /**
  * Gets the viewable node by WCMComposer (depends on site mode)
  *
  * @param repository the repository's name
  * @param workspace the workspace's name
  * @param nodeIdentifier the node's path or node's UUID
  * @param version the base version (e.g. <code>WCMComposer.BASE_VERSION</code> )
  * @param cacheVisibility the visibility of cache
  * @return the viewable node. Return <code>null</code> if <code>nodeIdentifier</code> is invalid
  * @see #getViewableNodeByComposer(String repository, String workspace, String nodeIdentifier)
  *     getViewableNodeByComposer()
  * @see WCMComposer
  */
 public static Node getViewableNodeByComposer(
     String repository,
     String workspace,
     String nodeIdentifier,
     String version,
     String cacheVisibility) {
   try {
     HashMap<String, String> filters = new HashMap<String, String>();
     StringBuffer filterLang =
         new StringBuffer(Util.getPortalRequestContext().getLocale().getLanguage());
     String country = Util.getPortalRequestContext().getLocale().getCountry();
     if (country != null && country.length() > 0) {
       filterLang.append("_").append(country);
     }
     filters.put(WCMComposer.FILTER_LANGUAGE, filterLang.toString());
     filters.put(WCMComposer.FILTER_MODE, Utils.getCurrentMode());
     PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
     PortletMode portletMode = portletRequestContext.getApplicationMode();
     filters.put(WCMComposer.PORTLET_MODE, portletMode.toString());
     if (version != null) filters.put(WCMComposer.FILTER_VERSION, version);
     filters.put(WCMComposer.FILTER_VISIBILITY, cacheVisibility);
     return WCMCoreUtils.getService(WCMComposer.class)
         .getContent(
             workspace,
             Text.escapeIllegalJcrChars(nodeIdentifier),
             filters,
             WCMCoreUtils.getUserSessionProvider());
   } catch (Exception e) {
     return null;
   }
 }
Example #2
0
  /**
   * Creates a restfull compliant link to the editor for editing a content, adding a content or
   * managing contents. Example : Add Content : isEditable = false, isNew = true, itemPath = the
   * parent folder path Edit Content : isEditable = true, isNew = false, itemPath = the content path
   * Manage Contents = isEditable = false, isNew = false, itemPath = the folder path
   *
   * @param itemPath
   * @param isEditable
   * @param isNew
   * @return
   */
  public static String getEditLink(String itemPath, boolean isEditable, boolean isNew) {
    PortalRequestContext pContext = Util.getPortalRequestContext();
    String backto = pContext.getRequestURI();
    WCMConfigurationService configurationService =
        Util.getUIPortalApplication().getApplicationComponent(WCMConfigurationService.class);
    String editorPageURI =
        configurationService.getRuntimeContextParam(
            isEditable || isNew
                ? WCMConfigurationService.EDITOR_PAGE_URI
                : WCMConfigurationService.SITE_EXPLORER_URI);
    UserNode editorNode = getEditorNode(editorPageURI);

    if (editorNode == null) {
      return "";
    }

    NodeURL nodeURL = pContext.createURL(NodeURL.TYPE);
    nodeURL.setNode(editorNode).setQueryParameterValue("path", itemPath);
    if (isEditable) {
      nodeURL.setQueryParameterValue("edit", "true");
    }
    if (isNew) {
      nodeURL.setQueryParameterValue("addNew", "true");
    }
    nodeURL.setQueryParameterValue(org.exoplatform.ecm.webui.utils.Utils.URL_BACKTO, backto);

    return nodeURL.toString();
  }
Example #3
0
  /**
   * Checks if is node content published to page node.
   *
   * @param contentNode the content node
   * @param navNodeURI the nav node uri
   * @return true, if is node content published to page node
   * @throws Exception the exception
   */
  public static boolean isNodeContentPublishedToPageNode(Node contentNode, String navNodeURI)
      throws Exception {

    UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal();

    // make filter
    UserNodeFilterConfig.Builder filterConfigBuilder = UserNodeFilterConfig.builder();
    filterConfigBuilder
        .withReadWriteCheck()
        .withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
    filterConfigBuilder.withTemporalCheck();
    UserNodeFilterConfig filterConfig = filterConfigBuilder.build();

    // get user node
    String nodeURI =
        navNodeURI.replace("/" + Util.getPortalRequestContext().getPortalOwner() + "/", "");
    UserNode userNode;
    UserNavigation userNavigation =
        NavigationUtils.getUserNavigationOfPortal(
            userPortal, Util.getUIPortal().getSiteKey().getName());
    if (userNavigation != null) {
      userNode = userPortal.resolvePath(userNavigation, filterConfig, nodeURI);
    } else {
      userNode = userPortal.resolvePath(filterConfig, nodeURI);
    }

    if (userNode == null || userNode.getPageRef() == null) return false;

    return PublicationUtil.getValuesAsString(contentNode, "publication:webPageIDs")
        .contains(userNode.getPageRef());
  }
 public void execute(Event<UIComponent> event) throws Exception {
   PortalRequestContext prContext = Util.getPortalRequestContext();
   prContext.getRequest().getSession().invalidate();
   HttpServletRequest request = prContext.getRequest();
   String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");
   String redirect = request.getContextPath() + "/public/" + portalName + "/";
   prContext.getResponse().sendRedirect(redirect);
   prContext.setResponseComplete(true);
 }
Example #5
0
 /**
  * Get question uri by question id of question relative path.
  *
  * @param: param the question id or question relative path.
  * @param: isAnswer is display form answer question or not.
  * @return: the link go to the question and show form answer or not.
  * @throws Exception
  */
 public static String getQuestionURI(String param, boolean isAnswer) throws Exception {
   PortalRequestContext portalContext = Util.getPortalRequestContext();
   String selectedNode = Util.getUIPortal().getSelectedUserNode().getURI();
   return portalContext
       .getPortalURI()
       .concat(selectedNode)
       .concat(Utils.QUESTION_ID)
       .concat(param)
       .concat((isAnswer) ? Utils.ANSWER_NOW.concat("true") : "");
 }
Example #6
0
 /**
  * Can edit current portal.
  *
  * @param remoteUser the remote user
  * @return true, if successful
  * @throws Exception the exception
  */
 public static boolean canEditCurrentPortal(String remoteUser) throws Exception {
   if (remoteUser == null) return false;
   IdentityRegistry identityRegistry =
       Util.getUIPortalApplication().getApplicationComponent(IdentityRegistry.class);
   Identity identity = identityRegistry.getIdentity(remoteUser);
   if (identity == null) return false;
   UIPortal uiPortal = Util.getUIPortal();
   // this code only work for single edit permission
   String editPermission = uiPortal.getEditPermission();
   MembershipEntry membershipEntry = MembershipEntry.parse(editPermission);
   return identity.isMemberOf(membershipEntry);
 }
  public UISearchBasisPortlet() throws Exception {
    HttpServletResponse response = Util.getPortalRequestContext().getResponse();
    String url[] = Util.getPortalRequestContext().getRequestURI().split("BO:");
    String nameBO[] = url[1].split("/");
    Cookie cookie = new Cookie("dayCheck", "No");
    response.addCookie(cookie);
    cookie = new Cookie("boName", nameBO[0]);
    response.addCookie(cookie);

    addChild(UISimpleSearchForm.class, null, "simpleSearch");
    addChild(UIAdvancedSearchForm.class, null, "advancedSearch");
    addChild(UIResultForm.class, null, "Result");
    setRenderedChild("simpleSearch");
  }
Example #8
0
  /**
   * @return the base URL to the current calendar application
   * @throws Exception
   */
  public static String getCalendarURL() throws Exception {
    PortalRequestContext pContext = Util.getPortalRequestContext();
    String url = pContext.getRequest().getRequestURL().toString();
    String selectedNode = Util.getUIPortal().getSelectedUserNode().getURI();
    String portalName = pContext.getPortalOwner();
    if (url.indexOf(portalName) > 0) {
      String s = new StringBuilder().append(portalName).append("/").append(selectedNode).toString();
      if (url.indexOf(s) < 0) {
        url = url.replaceFirst(portalName, s);
      }
      selectedNode = s;
      url = url.substring(0, url.lastIndexOf(selectedNode) + selectedNode.length());
    }

    return url;
  }
Example #9
0
 public static String getCurrentUser() throws Exception {
   try {
     return Util.getPortalRequestContext().getRemoteUser();
   } catch (Exception e) {
     return null;
   }
 }
Example #10
0
  public static boolean hasEditPermissionOnPage() throws Exception {
    UIPortalApplication portalApp = Util.getUIPortalApplication();
    UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
    UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
    UIPage uiPage = (UIPage) pageBody.getUIComponent();
    UserACL userACL = portalApp.getApplicationComponent(UserACL.class);

    if (uiPage != null) {
      return userACL.hasEditPermissionOnPage(
          uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
    }
    UIPortal currentUIPortal =
        portalApp
            .<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID)
            .findFirstComponentOfType(UIPortal.class);
    UserNode currentNode = currentUIPortal.getSelectedUserNode();
    String pageReference = currentNode.getPageRef();
    if (pageReference == null) {
      return false;
    }
    DataStorage dataStorage = portalApp.getApplicationComponent(DataStorage.class);
    Page page = dataStorage.getPage(pageReference);
    if (page == null) {
      return false;
    }
    return userACL.hasEditPermission(page);
  }
Example #11
0
 /**
  * Gets the current mode of the site
  *
  * @return the current mode (e.g. <code>WCMComposer.MODE_EDIT</code>)
  * @see WCMComposer
  */
 public static String getCurrentMode() {
   Object isQuickEditable =
       Util.getPortalRequestContext().getRequest().getSession().getAttribute(TURN_ON_QUICK_EDIT);
   if (isQuickEditable == null) return WCMComposer.MODE_LIVE;
   boolean turnOnQuickEdit = Boolean.parseBoolean(isQuickEditable.toString());
   return turnOnQuickEdit ? WCMComposer.MODE_EDIT : WCMComposer.MODE_LIVE;
 }
Example #12
0
 /**
  * Checks if is edits the portlet in create page wizard.
  *
  * @return true, if is edits the portlet in create page wizard
  */
 public static boolean isEditPortletInCreatePageWizard() {
   UIPortalApplication portalApplication = Util.getUIPortalApplication();
   UIMaskWorkspace uiMaskWS = portalApplication.getChildById(UIPortalApplication.UI_MASK_WS_ID);
   // show maskworkpace is being in Portal page edit mode
   if (uiMaskWS.getWindowWidth() > 0 && uiMaskWS.getWindowHeight() < 0) return true;
   return false;
 }
Example #13
0
    @Override
    public ResultNode createData(Node node, Row row) {
      try {
        PortalRequestContext portalRequestContext = Util.getPortalRequestContext();
        PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance();
        PortletRequest portletRequest = portletRequestContext.getRequest();

        StringBuffer baseURI = new StringBuffer();
        baseURI
            .append(portletRequest.getScheme())
            .append("://")
            .append(portletRequest.getServerName());
        if (portletRequest.getServerPort() != 80) {
          baseURI.append(":").append(String.format("%s", portletRequest.getServerPort()));
        }
        baseURI.append(portalRequestContext.getPortalContextPath());
        if (node.isNodeType("mop:pagelink")) {
          node = node.getParent();
        }

        if (node.isNodeType("gtn:language")) {
          node = node.getParent().getParent();
        }
        String userNaviUri =
            baseURI.toString() + "/" + PageDataCreator.getUserNavigationURI(node).toString();
        if (userNavigationUriList.contains(userNaviUri)) {
          return null;
        }
        userNavigationUriList.add(userNaviUri);
        return new ResultNode(node, row, userNaviUri);
      } catch (Exception e) {
        return null;
      }
    }
  public String getTitle() throws Exception {
    String title = (String) request_.getAttribute(REQUEST_TITLE);

    //
    if (title == null) {
      UIPortal uiportal = Util.getUIPortal();

      //
      UserNode node = uiportal.getSelectedUserNode();
      if (node != null) {
        ExoContainer container = getApplication().getApplicationServiceContainer();
        container.getComponentInstanceOfType(UserPortalConfigService.class);
        UserPortalConfigService configService =
            (UserPortalConfigService)
                container.getComponentInstanceOfType(UserPortalConfigService.class);
        Page page = configService.getPage(node.getPageRef(), getRemoteUser());

        //
        if (page != null) {
          title = page.getTitle();
          return ExpressionUtil.getExpressionValue(this.getApplicationResourceBundle(), title);
        } else {
          title = node.getResolvedLabel();
        }
      }
    }

    //
    return title;
  }
Example #15
0
 public static Node findNodeByUUID(String uuid) throws Exception {
   RepositoryService repositoryService =
       Util.getUIPortal().getApplicationComponent(RepositoryService.class);
   SessionProviderService sessionProviderService =
       Util.getUIPortal().getApplicationComponent(SessionProviderService.class);
   SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
   ManageableRepository manageableRepository = repositoryService.getCurrentRepository();
   Node node = null;
   for (String wsName : manageableRepository.getWorkspaceNames()) {
     try {
       node = sessionProvider.getSession(wsName, manageableRepository).getNodeByUUID(uuid);
     } catch (ItemNotFoundException e) {
       continue;
     }
   }
   return node;
 }
Example #16
0
 /**
  * Refresh whole portal by AJAX.
  *
  * @param context the portlet request context
  */
 public static void updatePortal(PortletRequestContext context) {
   UIPortalApplication portalApplication = Util.getUIPortalApplication();
   PortalRequestContext portalRequestContext =
       (PortalRequestContext) context.getParentAppRequestContext();
   UIWorkingWorkspace uiWorkingWS =
       portalApplication.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
   portalRequestContext.addUIComponentToUpdateByAjax(uiWorkingWS);
   portalRequestContext.ignoreAJAXUpdateOnPortlets(true);
 }
 /**
  * Gets the full URL of a space.
  *
  * @return the full URL or an empty String
  */
 public String getSpaceFullURL() {
   SpaceService spaceService = getSpaceService();
   Space space = spaceService.getSpaceByUrl(SpaceUtils.getSpaceUrl());
   if (space != null) {
     return Util.getPortalRequestContext().getPortalURI() + space.getUrl();
   } else {
     return "";
   }
 }
Example #18
0
 /**
  * Get login User
  *
  * @return user name
  */
 private String getRemoteUser() {
   String remoteUser = null;
   try {
     remoteUser = Util.getPortalRequestContext().getRemoteUser();
   } catch (Exception e) {
     remoteUser = null;
   }
   return remoteUser;
 }
    public void execute(Event<UIAdminToolbarContainer> event) throws Exception {
      UIAdminToolbarContainer uicomp = event.getSource();
      UserNavigation edittedNavigation = Utils.getSelectedNavigation();

      WebuiRequestContext context = event.getRequestContext();
      UIApplication uiApplication = context.getUIApplication();

      if (edittedNavigation == null) {
        uiApplication.addMessage(
            new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
        return;
      }

      UserACL userACL = uicomp.getApplicationComponent(UserACL.class);
      if (edittedNavigation.getKey().getType().equals(SiteType.PORTAL)) {
        String portalName = Util.getPortalRequestContext().getPortalOwner();
        UserPortalConfigService configService =
            uicomp.getApplicationComponent(UserPortalConfigService.class);
        UserPortalConfig userPortalConfig =
            configService.getUserPortalConfig(
                portalName, context.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT);
        if (userPortalConfig == null) {
          uiApplication.addMessage(
              new ApplicationMessage(
                  "UISiteManagement.msg.portal-not-exist", new String[] {portalName}));
          return;
        }
        if (!userACL.hasEditPermission(userPortalConfig.getPortalConfig())) {
          uiApplication.addMessage(
              new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
          return;
        }
      } else if (edittedNavigation.getKey().getType().equals(PortalConfig.GROUP_TYPE)) {
        if (!userACL.hasEditPermissionOnNavigation(
            SiteKey.group(edittedNavigation.getKey().getTypeName()))) {
          uiApplication.addMessage(
              new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null));
          return;
        }
      }

      if (uicomp.naviManager == null) {
        uicomp.naviManager = uicomp.createUIComponent(UINavigationManagement.class, null, null);
      }
      Utils.createPopupWindow(
          uicomp, uicomp.naviManager, EDIT_NAVIGATION_POPUP_CONTAINER_ID, 400, -1, -1);

      uicomp.naviManager.setSiteKey(edittedNavigation.getKey());
      UserPortal userPortal = getUserPortal();
      UINavigationNodeSelector selector =
          uicomp.naviManager.getChild(UINavigationNodeSelector.class);
      selector.setEdittedNavigation(edittedNavigation);
      selector.setUserPortal(userPortal);
      selector.initTreeData();

      context.addUIComponentToUpdateByAjax(uicomp);
    }
Example #20
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());
 }
    public void execute(Event<UIAccountChangePass> event) throws Exception {
      UIAccountChangePass uiForm = event.getSource();
      OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
      WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
      UIApplication uiApp = context.getUIApplication();
      String username = Util.getPortalRequestContext().getRemoteUser();
      User user = service.getUserHandler().findUserByName(username);
      String currentPass = uiForm.getUIStringInput("currentpass").getValue();
      String newPass = uiForm.getUIStringInput("newpass").getValue();
      String confirmnewPass = uiForm.getUIStringInput("confirmnewpass").getValue();

      Authenticator authenticator = uiForm.getApplicationComponent(Authenticator.class);
      boolean authenticated;
      try {
        UsernameCredential usernameCred = new UsernameCredential(username);
        PasswordCredential passwordCred = new PasswordCredential(currentPass);
        authenticator.validateUser(new Credential[] {usernameCred, passwordCred});
        authenticated = true;
      } catch (Exception ex) {
        authenticated = false;
      }

      if (!authenticated) {
        uiApp.addMessage(
            new ApplicationMessage(
                "UIAccountChangePass.msg.currentpassword-is-not-match", null, 1));
        uiForm.reset();
        event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
        return;
      }

      if (!newPass.equals(confirmnewPass)) {
        uiApp.addMessage(
            new ApplicationMessage("UIAccountChangePass.msg.password-is-not-match", null, 1));
        uiForm.reset();
        event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
        return;
      }
      try {
        user.setPassword(newPass);
        service.getUserHandler().saveUser(user, true);
        uiApp.addMessage(
            new ApplicationMessage("UIAccountChangePass.msg.change.pass.success", null));
        UIAccountSetting ui = uiForm.getParent();
        ui.getChild(UIAccountProfiles.class).setRendered(true);
        ui.getChild(UIAccountChangePass.class).setRendered(false);
        event.getRequestContext().addUIComponentToUpdateByAjax(ui);
      } catch (Exception e) {
        uiApp.addMessage(
            new ApplicationMessage(
                "UIAccountChangePass.msg.change.pass.fail", null, ApplicationMessage.ERROR));
      }
      uiForm.reset();
      event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
      return;
    }
Example #22
0
 /**
  * Gets portal owner, if parameter is null or "", the method return default portal owner.
  *
  * @param portalOwner The portal owner (classic, public..)
  * @return portalOwner
  */
 private static String getPortalOwner(String portalOwner) {
   if (portalOwner == null || portalOwner.trim().length() == 0) {
     try {
       return Util.getPortalRequestContext().getPortalOwner();
     } catch (Exception e) {
       return DEFAULT_PORTAL_OWNER;
     }
   }
   return portalOwner;
 }
Example #23
0
 public String generateLoginLink() {
   if (ssoHelper != null && ssoHelper.isSSOEnabled()) {
     PortalRequestContext pContext = Util.getPortalRequestContext();
     String ssoRedirectURL =
         pContext.getRequest().getContextPath() + ssoHelper.getSSORedirectURLSuffix();
     return ssoRedirectURL;
   } else {
     return "#";
   }
 }
Example #24
0
 public void onEvent(Event<UICategoryForm> event, UICategoryForm uiForm, String id)
     throws Exception {
   uiForm.id = Integer.parseInt(id);
   UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class);
   if (uiForm.id == 1) {
     popupWindow.setWindowSize(550, 440);
   } else {
     popupWindow.setWindowSize(550, 380);
   }
   Util.getPortalRequestContext().setResponseComplete(true);
 }
 public UIAdminToolbarContainer() throws Exception {
   PortalRequestContext context = Util.getPortalRequestContext();
   Boolean quickEdit =
       (Boolean) context.getRequest().getSession().getAttribute(Utils.TURN_ON_QUICK_EDIT);
   if (quickEdit == null) {
     context.getRequest().getSession().setAttribute(Utils.TURN_ON_QUICK_EDIT, false);
   }
   addChild(UIPopupContainer.class, null, SEO_TOOLBAR_FORM_POPUP_CONTAINER_ID);
   addChild(UISEOToolbarForm.class, null, null);
   spaceService = getApplicationComponent(SpaceService.class);
 }
 public ResourceBundle getBundle(UserNavigation navigation) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   ResourceBundleManager rbMgr =
       (ResourceBundleManager)
           container.getComponentInstanceOfType(ResourceBundleManager.class);
   Locale locale = Util.getPortalRequestContext().getLocale();
   return rbMgr.getNavigationResourceBundle(
       locale.getLanguage(),
       navigation.getKey().getTypeName(),
       navigation.getKey().getName());
 }
Example #27
0
 /**
  * Get a cookie value with given name
  *
  * @param cookieName cookies
  * @return a cookies value
  */
 public static String getCookieByCookieName(String cookieName) {
   HttpServletRequest request = Util.getPortalRequestContext().getRequest();
   Cookie[] cookies = request.getCookies();
   if (cookies == null) {
     return null;
   }
   for (int loopIndex = 0; loopIndex < cookies.length; loopIndex++) {
     Cookie cookie1 = cookies[loopIndex];
     if (cookie1.getName().equals(cookieName)) return cookie1.getValue();
   }
   return null;
 }
Example #28
0
 public static Node getNodeSymLink(Node node) throws Exception {
   LinkManager linkManager = Util.getUIPortal().getApplicationComponent(LinkManager.class);
   Node realNode = null;
   if (linkManager.isLink(node)) {
     if (linkManager.isTargetReachable(node)) {
       realNode = linkManager.getTarget(node);
     }
   } else {
     realNode = node;
   }
   return realNode;
 }
 /*
  * (non-Javadoc)
  * @see
  * org.exoplatform.webui.event.EventListener#execute(org.exoplatform
  * .webui.event.Event)
  */
 public void execute(Event<UIAdminToolbarContainer> event) throws Exception {
   PortalRequestContext context = Util.getPortalRequestContext();
   Boolean quickEdit =
       (Boolean) context.getRequest().getSession().getAttribute(Utils.TURN_ON_QUICK_EDIT);
   if (quickEdit == null || !quickEdit) {
     context.getRequest().getSession().setAttribute(Utils.TURN_ON_QUICK_EDIT, true);
     Utils.updatePortal((PortletRequestContext) event.getRequestContext());
   } else {
     context.getRequest().getSession().setAttribute(Utils.TURN_ON_QUICK_EDIT, false);
     Utils.updatePortal((PortletRequestContext) event.getRequestContext());
   }
 }
Example #30
0
 public static boolean hasEditPermissionOnPortal() throws Exception {
   UIPortalApplication portalApp = Util.getUIPortalApplication();
   UIPortal currentUIPortal =
       portalApp
           .<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID)
           .findFirstComponentOfType(UIPortal.class);
   UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
   return userACL.hasEditPermissionOnPortal(
       currentUIPortal.getSiteKey().getTypeName(),
       currentUIPortal.getSiteKey().getName(),
       currentUIPortal.getEditPermission());
 }