@Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long classTypeId)
      throws PortalException {

    ThemeDisplay themeDisplay =
        (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    CalendarResource calendarResource =
        CalendarResourceUtil.getScopeGroupCalendarResource(
            liferayPortletRequest, themeDisplay.getScopeGroupId());

    if (calendarResource == null) {
      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(
            liferayPortletRequest, CalendarPortletKeys.CALENDAR, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_calendar_booking.jsp");

    Calendar calendar = calendarResource.getDefaultCalendar();

    portletURL.setParameter("calendarId", String.valueOf(calendar.getCalendarId()));

    return portletURL;
  }
  public void deleteLayout(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    long selPlid = ParamUtil.getLong(actionRequest, "selPlid");

    if (selPlid <= 0) {
      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long layoutId = ParamUtil.getLong(actionRequest, "layoutId");

      Layout layout = layoutLocalService.getLayout(groupId, privateLayout, layoutId);

      selPlid = layout.getPlid();
    }

    Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse);

    if (selPlid == themeDisplay.getRefererPlid()) {
      long newRefererPlid = (Long) returnValue[2];

      redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);
      redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid", 0);
    }

    actionRequest.setAttribute(WebKeys.REDIRECT, redirect);
  }
  protected String getGroupURL(
      Group group, PortletRequest portletRequest, boolean includeStagingGroup) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String groupDisplayURL = group.getDisplayURL(themeDisplay, false);

    if (Validator.isNotNull(groupDisplayURL)) {
      return HttpUtil.removeParameter(groupDisplayURL, "p_p_id");
    }

    groupDisplayURL = group.getDisplayURL(themeDisplay, true);

    if (Validator.isNotNull(groupDisplayURL)) {
      return HttpUtil.removeParameter(groupDisplayURL, "p_p_id");
    }

    if (includeStagingGroup && group.hasStagingGroup()) {
      try {
        if (GroupPermissionUtil.contains(
            themeDisplay.getPermissionChecker(), group, ActionKeys.VIEW_STAGING)) {

          return getGroupURL(group.getStagingGroup(), portletRequest);
        }
      } catch (PortalException pe) {
        _log.error("Unable to check permission on group " + group.getGroupId(), pe);
      }
    }

    return getGroupAdministrationURL(group, portletRequest);
  }
  public AssetEntryQuery(long[] classNameIds, SearchContainer<?> searchContainer) {

    this();

    setClassNameIds(classNameIds);
    _start = searchContainer.getStart();
    _end = searchContainer.getEnd();

    if (Validator.isNotNull(searchContainer.getOrderByCol())) {
      setOrderByCol1(searchContainer.getOrderByCol());
      setOrderByType1(searchContainer.getOrderByType());
    }

    PortletRequest portletRequest = searchContainer.getPortletRequest();

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    _groupIds = new long[] {themeDisplay.getScopeGroupId()};

    long categoryId = ParamUtil.getLong(portletRequest, "categoryId");

    if (categoryId > 0) {
      _allCategoryIds = new long[] {categoryId};
    }

    String tagName = ParamUtil.getString(portletRequest, "tag");

    if (Validator.isNotNull(tagName)) {
      _allTagIds =
          AssetTagLocalServiceUtil.getTagIds(themeDisplay.getSiteGroupId(), new String[] {tagName});

      _allTagIdsArray = new long[][] {_allTagIds};
    }
  }
  @Override
  public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    Portlet portlet = _portletLocalService.getPortletById(portletDisplay.getId());

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            portletRequest,
            PortletProviderUtil.getPortletId(
                DDMStructure.class.getName(), PortletProvider.Action.VIEW),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/view.jsp");
    portletURL.setParameter("backURL", themeDisplay.getURLCurrent());
    portletURL.setParameter("groupId", String.valueOf(themeDisplay.getScopeGroupId()));
    portletURL.setParameter("refererPortletName", DLPortletKeys.DOCUMENT_LIBRARY);
    portletURL.setParameter("refererWebDAVToken", WebDAVUtil.getStorageToken(portlet));
    portletURL.setParameter("showAncestorScopes", Boolean.TRUE.toString());
    portletURL.setParameter("showManageTemplates", Boolean.FALSE.toString());

    return portletURL.toString();
  }
  protected void remoteServeResource(
      ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, getServerPortletURL());

    setRequestParameters(resourceRequest, resourceResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "2");
    addOAuthParameter(oAuthRequest, "p_p_resource_id", resourceRequest.getResourceID());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    String contentType = response.getHeader(HttpHeaders.CONTENT_TYPE);

    if (contentType.startsWith(ContentTypes.APPLICATION_OCTET_STREAM)) {
      String contentDisposition = response.getHeader(HttpHeaders.CONTENT_DISPOSITION);
      int contentLength = GetterUtil.getInteger(response.getHeader(HttpHeaders.CONTENT_LENGTH));

      PortletResponseUtil.sendFile(
          resourceRequest,
          resourceResponse,
          getFileName(contentDisposition),
          response.getStream(),
          contentLength,
          contentType,
          HttpHeaders.CONTENT_DISPOSITION_ATTACHMENT);
    } else {
      PortletResponseUtil.write(resourceResponse, response.getStream());
    }
  }
  protected void remoteProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, getServerPortletURL());

    setRequestParameters(actionRequest, actionResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "1");
    addOAuthParameter(oAuthRequest, "p_p_state", WindowState.NORMAL.toString());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    if (response.getCode() == HttpServletResponse.SC_FOUND) {
      String redirectLocation = response.getHeader(HttpHeaders.LOCATION);

      actionResponse.sendRedirect(redirectLocation);
    } else {
      HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse);

      httpServletResponse.setContentType(response.getHeader(HttpHeaders.CONTENT_TYPE));

      ServletResponseUtil.write(httpServletResponse, response.getStream());
    }
  }
  protected void deleteCategories(ActionRequest actionRequest, boolean moveToTrash)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long[] deleteCategoryIds = null;

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

    if (categoryId > 0) {
      deleteCategoryIds = new long[] {categoryId};
    } else {
      deleteCategoryIds =
          StringUtil.split(ParamUtil.getString(actionRequest, "deleteCategoryIds"), 0L);
    }

    List<TrashedModel> trashedModels = new ArrayList<>();

    for (long deleteCategoryId : deleteCategoryIds) {
      if (moveToTrash) {
        MBCategory category = _mbCategoryService.moveCategoryToTrash(deleteCategoryId);

        trashedModels.add(category);
      } else {
        _mbCategoryService.deleteCategory(themeDisplay.getScopeGroupId(), deleteCategoryId);
      }
    }

    if (moveToTrash && !trashedModels.isEmpty()) {
      TrashUtil.addTrashSessionMessages(actionRequest, trashedModels);

      hideDefaultSuccessMessage(actionRequest);
    }
  }
  protected boolean isSharedURL() {
    ThemeDisplay themeDisplay = getThemeDisplay();

    String urlCurrent = themeDisplay.getURLCurrent();

    return urlCurrent.contains("/shared");
  }
  protected String getPortletResource() {
    ThemeDisplay themeDisplay = getThemeDisplay();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.getPortletResource();
  }
Example #11
0
  @Override
  public String getNewName(
      ThemeDisplay themeDisplay, String className, long classPK, String oldName)
      throws PortalException {

    TrashRenderer trashRenderer = null;

    if (Validator.isNotNull(className) && (classPK > 0)) {
      TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

      trashRenderer = trashHandler.getTrashRenderer(classPK);
    }

    Format dateFormatDateTime =
        FastDateFormatFactoryUtil.getDateTime(themeDisplay.getLocale(), themeDisplay.getTimeZone());

    StringBundler sb = new StringBundler(3);

    sb.append(StringPool.OPEN_PARENTHESIS);
    sb.append(
        StringUtil.replace(
            dateFormatDateTime.format(new Date()),
            new String[] {StringPool.SLASH, StringPool.COLON},
            new String[] {StringPool.PERIOD, StringPool.PERIOD}));
    sb.append(StringPool.CLOSE_PARENTHESIS);

    if (trashRenderer != null) {
      return trashRenderer.getNewName(oldName, sb.toString());
    } else {
      return getNewName(oldName, sb.toString());
    }
  }
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "hello_soy_description");

    template.put("descriptionURL", portletURL.toString());

    String path = getPath(renderRequest, renderResponse);

    if (Validator.equals(path, "hello_soy_edit")) {
      portletURL.setParameter("mvcPath", "hello_soy_view");
    } else {
      portletURL.setParameter("mvcPath", "hello_soy_edit");
    }

    template.put("portletURL", portletURL.toString());

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();

    template.put("userName", user.getFirstName());

    super.render(renderRequest, renderResponse);
  }
  public void editLayoutSet(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long layoutSetId = ParamUtil.getLong(actionRequest, "layoutSetId");

    long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId");
    long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId");
    boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");

    LayoutSet layoutSet = layoutSetLocalService.getLayoutSet(layoutSetId);

    updateLogo(actionRequest, liveGroupId, stagingGroupId, privateLayout);

    updateLookAndFeel(
        actionRequest,
        themeDisplay.getCompanyId(),
        liveGroupId,
        stagingGroupId,
        privateLayout,
        layoutSet.getSettingsProperties());

    updateMergePages(actionRequest, liveGroupId);

    updateRobots(actionRequest, liveGroupId, privateLayout);

    updateSettings(
        actionRequest,
        liveGroupId,
        stagingGroupId,
        privateLayout,
        layoutSet.getSettingsProperties());
  }
  public void deleteArchivedSetups(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String[] names = null;

    String name = ParamUtil.getString(actionRequest, "name");

    if (Validator.isNotNull(name)) {
      names = new String[] {name};
    } else {
      names = ParamUtil.getStringValues(actionRequest, "rowIds");
    }

    for (String curName : names) {
      ArchivedSettings archivedSettings =
          SettingsFactoryUtil.getPortletInstanceArchivedSettings(
              themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), curName);

      archivedSettings.delete();
    }
  }
  protected String getWindowJS(PortletRequest portletRequest, JournalArticle article) {

    StringBundler sb = new StringBundler(13);

    sb.append("Liferay.Util.Window.getWindow({bodyCssClass: ");
    sb.append("'dialog-with-footer', destroyOnHide: true, dialog: ");
    sb.append(getDialogJS(article));
    sb.append(", id: '");

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    sb.append(HtmlUtil.escape(portletDisplay.getNamespace()));
    sb.append("viewSource', namespace: '");
    sb.append(portletDisplay.getNamespace());
    sb.append("', portlet: '#p_p_id_");
    sb.append(portletDisplay.getId());
    sb.append("_', portletId: '");
    sb.append(portletDisplay.getId());
    sb.append("', title: '");
    sb.append(HtmlUtil.escapeJS(HtmlUtil.escape(article.getTitle(themeDisplay.getLocale()))));
    sb.append("'});");

    return sb.toString();
  }
  protected JournalArticle getArticle(HttpServletRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(request, "groupId", themeDisplay.getScopeGroupId());
    long classNameId = ParamUtil.getLong(request, "classNameId");
    long classPK = ParamUtil.getLong(request, "classPK");
    String articleId = ParamUtil.getString(request, "articleId");
    int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_ANY);

    JournalArticle article = null;

    if (Validator.isNotNull(articleId)) {
      article = _journalArticleLocalService.fetchLatestArticle(groupId, articleId, status);
    } else if ((classNameId > 0) && (classPK > JournalArticleConstants.CLASSNAME_ID_DEFAULT)) {

      String className = PortalUtil.getClassName(classNameId);

      try {
        article = _journalArticleLocalService.getLatestArticle(groupId, className, classPK);
      } catch (PortalException pe) {
        return null;
      }
    }

    return article;
  }
Example #17
0
  public static ExportImportConfiguration buildDefaultRemotePublishingExportImportConfiguration(
      PortletRequest portletRequest) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long sourceGroupId = ParamUtil.getLong(portletRequest, "sourceGroupId");
    boolean privateLayout = ParamUtil.getBoolean(portletRequest, "privateLayout");
    String remoteAddress = ParamUtil.getString(portletRequest, "remoteAddress");
    int remotePort = ParamUtil.getInteger(portletRequest, "remotePort");
    String remotePathContext = ParamUtil.getString(portletRequest, "remotePathContext");
    boolean secureConnection = ParamUtil.getBoolean(portletRequest, "secureConnection");
    long remoteGroupId = ParamUtil.getLong(portletRequest, "remoteGroupId");

    Map<String, String[]> parameterMap = getDefaultPublishingParameters(portletRequest);

    return buildDefaultRemotePublishingExportImportConfiguration(
        themeDisplay.getUser(),
        sourceGroupId,
        privateLayout,
        remoteAddress,
        remotePort,
        remotePathContext,
        secureConnection,
        remoteGroupId,
        parameterMap);
  }
  public boolean isShowIconsActions() throws PortalException {
    if (isSpreadsheet()) {
      return false;
    }

    if (_hasShowIconsActionPermission != null) {
      return _hasShowIconsActionPermission;
    }

    _hasShowIconsActionPermission = Boolean.FALSE;

    ThemeDisplay themeDisplay = getThemeDisplay();

    if (!themeDisplay.isSignedIn()) {
      return _hasShowIconsActionPermission;
    }

    Layout layout = themeDisplay.getLayout();

    if (layout.isLayoutPrototypeLinkActive()) {
      return _hasShowIconsActionPermission;
    }

    if (isShowConfigurationIcon()
        || isShowAddDDMDisplayTemplateIcon()
        || isShowAddDDMFormTemplateIcon()
        || isShowEditDisplayDDMTemplateIcon()
        || isShowEditFormDDMTemplateIcon()) {

      _hasShowIconsActionPermission = Boolean.TRUE;
    }

    return _hasShowIconsActionPermission;
  }
  @Override
  public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    String url = StringPool.BLANK;

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {
      long roleId = _getRoleId(portletRequest);

      Role role = _roleService.fetchRole(roleId);

      int[] roleTypes = {role.getType()};

      if (role.getType() != RoleConstants.TYPE_REGULAR) {
        roleTypes = new int[] {RoleConstants.TYPE_REGULAR, role.getType()};
      }

      url =
          PermissionsURLTag.doTag(
              StringPool.BLANK,
              Role.class.getName(),
              themeDisplay.getScopeGroupName(),
              null,
              String.valueOf(_getRoleId(portletRequest)),
              LiferayWindowState.POP_UP.toString(),
              roleTypes,
              themeDisplay.getRequest());
    } catch (Exception e) {
    }

    return url;
  }
  public LinkedHashMap<String, Object> getGroupParams() throws PortalException {

    if (_groupParams != null) {
      return _groupParams;
    }

    long groupId = ParamUtil.getLong(_request, "groupId");
    boolean includeCurrentGroup = ParamUtil.getBoolean(_request, "includeCurrentGroup", true);

    String type = getType();

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    User user = themeDisplay.getUser();

    boolean filterManageableGroups = true;

    if (permissionChecker.isCompanyAdmin()) {
      filterManageableGroups = false;
    }

    _groupParams = new LinkedHashMap<>();

    _groupParams.put("active", Boolean.TRUE);

    if (isManualMembership()) {
      _groupParams.put("manualMembership", Boolean.TRUE);
    }

    if (type.equals("child-sites")) {
      Group parentGroup = GroupLocalServiceUtil.getGroup(groupId);

      List<Group> parentGroups = new ArrayList<>();

      parentGroups.add(parentGroup);

      _groupParams.put("groupsTree", parentGroups);
    } else if (filterManageableGroups) {
      _groupParams.put("usersGroups", user.getUserId());
    }

    _groupParams.put("site", Boolean.TRUE);

    if (!includeCurrentGroup && (groupId > 0)) {
      List<Long> excludedGroupIds = new ArrayList<>();

      Group group = GroupLocalServiceUtil.getGroup(groupId);

      if (group.isStagingGroup()) {
        excludedGroupIds.add(group.getLiveGroupId());
      } else {
        excludedGroupIds.add(groupId);
      }

      _groupParams.put("excludedGroupIds", excludedGroupIds);
    }

    return _groupParams;
  }
  public String getDDMStructureName() throws PortalException {
    if (_ddmStructureName != null) {
      return _ddmStructureName;
    }

    _ddmStructureName = LanguageUtil.get(_request, "basic-web-content");

    if (Validator.isNull(getDDMStructureKey())) {
      return _ddmStructureName;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    DDMStructure ddmStructure =
        DDMStructureLocalServiceUtil.fetchStructure(
            themeDisplay.getSiteGroupId(),
            PortalUtil.getClassNameId(JournalArticle.class),
            getDDMStructureKey(),
            true);

    if (ddmStructure != null) {
      _ddmStructureName = ddmStructure.getName(themeDisplay.getLocale());
    }

    return _ddmStructureName;
  }
  public List<ManagementBarFilterItem> getManagementBarStatusFilterItems()
      throws PortalException, PortletException {

    List<ManagementBarFilterItem> managementBarFilterItems = new ArrayList<>();

    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_ANY));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DRAFT));

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    int workflowDefinitionLinksCount =
        WorkflowDefinitionLinkLocalServiceUtil.getWorkflowDefinitionLinksCount(
            themeDisplay.getCompanyId(),
            themeDisplay.getScopeGroupId(),
            JournalFolder.class.getName());

    if (workflowDefinitionLinksCount > 0) {
      managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_PENDING));
      managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DENIED));
    }

    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_SCHEDULED));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_APPROVED));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_EXPIRED));

    return managementBarFilterItems;
  }
  protected PortletPreferences getPortletPreferences(
      ThemeDisplay themeDisplay, String portletId, String settingsScope) {

    Layout layout = themeDisplay.getLayout();

    if (!layout.isSupportsEmbeddedPortlets()) {
      return null;
    }

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    if (!layoutTypePortlet.isPortletEmbedded(portletId)) {
      return null;
    }

    PortletPreferencesIds portletPreferencesIds =
        new PortletPreferencesIds(
            themeDisplay.getCompanyId(),
            layout.getGroupId(),
            PortletKeys.PREFS_OWNER_TYPE_LAYOUT,
            PortletKeys.PREFS_PLID_SHARED,
            portletId);

    return _portletPreferencesLocalService.getPreferences(portletPreferencesIds);
  }
  public static BreadcrumbEntry getGuestGroupBreadcrumbEntry(ThemeDisplay themeDisplay)
      throws Exception {

    Group group = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), GroupConstants.GUEST);

    if (group.getPublicLayoutsPageCount() == 0) {
      return null;
    }

    LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(group.getGroupId(), false);

    BreadcrumbEntry breadcrumbEntry = new BreadcrumbEntry();

    Account account = themeDisplay.getAccount();

    breadcrumbEntry.setTitle(account.getName());

    String layoutSetFriendlyURL = PortalUtil.getLayoutSetFriendlyURL(layoutSet, themeDisplay);

    if (themeDisplay.isAddSessionIdToURL()) {
      layoutSetFriendlyURL =
          PortalUtil.getURLWithSessionId(layoutSetFriendlyURL, themeDisplay.getSessionId());
    }

    breadcrumbEntry.setURL(layoutSetFriendlyURL);

    return breadcrumbEntry;
  }
  protected String getOldScopeName(ActionRequest actionRequest, Portlet portlet) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();

    PortletPreferences portletPreferences = actionRequest.getPreferences();

    String scopeType = GetterUtil.getString(portletPreferences.getValue("lfrScopeType", null));

    if (Validator.isNull(scopeType)) {
      return null;
    }

    String scopeName = null;

    if (scopeType.equals("company")) {
      scopeName = themeDisplay.translate("global");
    } else if (scopeType.equals("layout")) {
      String scopeLayoutUuid =
          GetterUtil.getString(portletPreferences.getValue("lfrScopeLayoutUuid", null));

      Layout scopeLayout =
          _layoutLocalService.fetchLayoutByUuidAndGroupId(
              scopeLayoutUuid, layout.getGroupId(), layout.isPrivateLayout());

      if (scopeLayout != null) {
        scopeName = scopeLayout.getName(themeDisplay.getLocale());
      }
    } else {
      throw new IllegalArgumentException("Scope type " + scopeType + " is invalid");
    }

    return scopeName;
  }
  protected void checkEditPermissionsJSP(PortletRequest request) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String modelResource = ParamUtil.getString(request, "modelResource");

    long resourceGroupId =
        ParamUtil.getLong(request, "resourceGroupId", themeDisplay.getScopeGroupId());

    if (Validator.isNotNull(modelResource)) {
      String resourcePrimKey = ParamUtil.getString(request, "resourcePrimKey");

      _permissionService.checkPermission(resourceGroupId, modelResource, resourcePrimKey);

      return;
    }

    String portletResource = ParamUtil.getString(request, "portletResource");

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    Layout layout = PortletConfigurationLayoutUtil.getLayout(themeDisplay);

    _portletPermission.check(
        permissionChecker, resourceGroupId, layout, portletResource, ActionKeys.PERMISSIONS);
  }
  public void restoreArchivedSetup(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Settings portletInstanceSettings =
        SettingsFactoryUtil.getSettings(
            new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portlet.getPortletId()));

    ModifiableSettings portletInstanceModifiableSettings =
        portletInstanceSettings.getModifiableSettings();

    String name = ParamUtil.getString(actionRequest, "name");

    ArchivedSettings archivedSettings =
        SettingsFactoryUtil.getPortletInstanceArchivedSettings(
            themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), name);

    portletInstanceModifiableSettings.reset();

    portletInstanceModifiableSettings.setValues(archivedSettings);

    portletInstanceModifiableSettings.store();

    String portletResource = ParamUtil.getString(actionRequest, "portletResource");

    SessionMessages.add(
        actionRequest,
        PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET,
        portletResource);
  }
  public void editConfiguration(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String settingsScope = ParamUtil.getString(actionRequest, "settingsScope");

    PortletPreferences portletPreferences =
        getPortletPreferences(themeDisplay, portlet.getPortletId(), settingsScope);

    actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences);

    ConfigurationAction configurationAction = getConfigurationAction(portlet);

    if (configurationAction == null) {
      return;
    }

    configurationAction.processAction(portletConfig, actionRequest, actionResponse);

    Layout layout = themeDisplay.getLayout();

    PortletLayoutListener portletLayoutListener = portlet.getPortletLayoutListenerInstance();

    if (portletLayoutListener != null) {
      portletLayoutListener.onSetup(portlet.getPortletId(), layout.getPlid());
    }
  }
  protected void unsubscribeFolder(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long folderId = ParamUtil.getLong(actionRequest, "folderId");

    _bookmarksFolderService.unsubscribeFolder(themeDisplay.getScopeGroupId(), folderId);
  }
  protected void unsubscribeCategory(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId");

    _mbCategoryService.unsubscribeCategory(themeDisplay.getScopeGroupId(), categoryId);
  }