@Override
  public String getPortletFileEntryURL(
      ThemeDisplay themeDisplay, FileEntry fileEntry, String queryString, boolean absoluteURL) {

    StringBundler sb = new StringBundler(10);

    if (themeDisplay != null) {
      if (absoluteURL) {
        sb.append(themeDisplay.getPortalURL());
      }
    }

    sb.append(PortalUtil.getPathContext());
    sb.append("/documents/");
    sb.append(WebServerServlet.PATH_PORTLET_FILE_ENTRY);
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getGroupId());
    sb.append(StringPool.SLASH);

    String title = fileEntry.getTitle();

    if (fileEntry.isInTrash()) {
      title = TrashUtil.getOriginalTitle(fileEntry.getTitle());
    }

    sb.append(HttpUtil.encodeURL(HtmlUtil.unescape(title)));

    sb.append(StringPool.SLASH);
    sb.append(HttpUtil.encodeURL(fileEntry.getUuid()));

    if (themeDisplay != null) {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      if (portletDisplay != null) {
        String portletId = portletDisplay.getId();

        if (portletId.equals(PortletKeys.TRASH) && !queryString.contains("status=")) {

          if (Validator.isNotNull(queryString)) {
            queryString += StringPool.AMPERSAND;
          }

          queryString += "status=" + WorkflowConstants.STATUS_IN_TRASH;
        }
      }
    }

    if (Validator.isNotNull(queryString)) {
      sb.append(StringPool.QUESTION);
      sb.append(queryString);
    }

    String portletFileEntryURL = sb.toString();

    if ((themeDisplay != null) && themeDisplay.isAddSessionIdToURL()) {
      return PortalUtil.getURLWithSessionId(portletFileEntryURL, themeDisplay.getSessionId());
    }

    return portletFileEntryURL;
  }
  @Override
  protected String getPage() {
    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
      return _PAGE;
    }

    PortletDisplay portletDisplay = (PortletDisplay) pageContext.getAttribute("portletDisplay");

    if (!portletDisplay.isShowMaxIcon()) {
      return null;
    }

    setCssClass("portlet-maximize portlet-maximize-icon");
    setImage("../aui/plus");
    setMessage("maximize");
    setMethod("get");

    String onClick =
        "submitForm(document.hrefFm, '"
            .concat(portletDisplay.getURLMax())
            .concat("'); return false;");

    setOnClick(onClick);

    setToolTip(false);
    setUrl(portletDisplay.getURLMax());

    return super.getPage();
  }
  private void _init(
      HttpServletRequest request, DLFileEntryType dlFileEntryType, FileEntry fileEntry)
      throws PortalException {

    _request = request;
    _dlFileEntryType = dlFileEntryType;
    _fileEntry = fileEntry;

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _dlPortletInstanceSettings =
        DLPortletInstanceSettings.getInstance(themeDisplay.getLayout(), portletDisplay.getId());
    _fileEntryDisplayContextHelper =
        new FileEntryDisplayContextHelper(themeDisplay.getPermissionChecker(), _fileEntry);

    if ((_dlFileEntryType == null) && (_fileEntry != null)) {
      _dlFileEntryType = _fileEntryDisplayContextHelper.getDLFileEntryType();
    }

    if (fileEntry != null) {
      _fileVersion = fileEntry.getFileVersion();
    }

    _fileVersionDisplayContextHelper = new FileVersionDisplayContextHelper(_fileVersion);
  }
Esempio n. 4
0
  protected String getAssetPublisherURL(PortletRequest portletRequest) throws Exception {

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

    Layout layout = themeDisplay.getLayout();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    StringBundler sb = new StringBundler(7);

    String layoutFriendlyURL =
        GetterUtil.getString(PortalUtil.getLayoutFriendlyURL(layout, themeDisplay));

    if (!layoutFriendlyURL.startsWith(Http.HTTP_WITH_SLASH)
        && !layoutFriendlyURL.startsWith(Http.HTTPS_WITH_SLASH)) {

      sb.append(themeDisplay.getPortalURL());
    }

    sb.append(layoutFriendlyURL);
    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("asset_publisher/");
    sb.append(portletDisplay.getInstanceId());
    sb.append(StringPool.SLASH);

    return sb.toString();
  }
  protected String[] getAllowedFileExtensions(
      PortletConfig portletConfig, PortletRequest portletRequest, PortletResponse portletResponse)
      throws PortalException {

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) {
      return PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA);
    } else {
      ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      DLPortletInstanceSettings dlPortletInstanceSettings =
          DLPortletInstanceSettings.getInstance(themeDisplay.getLayout(), portletDisplay.getId());

      Set<String> extensions = new HashSet<>();

      String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes();

      for (String mimeType : mimeTypes) {
        extensions.addAll(MimeTypesUtil.getExtensions(mimeType));
      }

      return extensions.toArray(new String[extensions.size()]);
    }
  }
  public String getRSSName() {
    if (_rssName == null) {
      ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      _rssName = _portletPreferences.getValue("rssName", portletDisplay.getTitle());
    }

    return _rssName;
  }
  @Override
  public void setTitle(String title) {
    _title = title;

    // See LEP-2188

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    portletDisplay.setTitle(_title);
  }
  public AssetCategoriesNavigationDisplayContext(HttpServletRequest request)
      throws SettingsException {

    _request = request;

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _assetCategoriesNavigationPortletInstanceConfiguration =
        portletDisplay.getPortletInstanceConfiguration(
            AssetCategoriesNavigationPortletInstanceConfiguration.class);
  }
Esempio n. 9
0
  @Override
  public Object clone() throws CloneNotSupportedException {
    ThemeDisplay themeDisplay = (ThemeDisplay) super.clone();

    PortletDisplay portletDisplay = new PortletDisplay();

    _portletDisplay.copyTo(portletDisplay);

    themeDisplay._portletDisplay = portletDisplay;

    portletDisplay.setThemeDisplay(themeDisplay);

    return themeDisplay;
  }
  @Override
  public boolean isVisible(User user, User selUser) {
    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    ThemeDisplay themeDisplay = serviceContext.getThemeDisplay();

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    String portletName = portletDisplay.getPortletName();

    if ((selUser != null) && portletName.equals(PortletKeys.MY_ACCOUNT)) {
      return false;
    }

    return true;
  }
  @Override
  public boolean isShow() {
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletPreferences portletSetup =
        PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(
            themeDisplay.getLayout(), portletDisplay.getId());

    boolean lfrNetvibesShowAddAppLink =
        GetterUtil.getBoolean(portletSetup.getValue("lfrNetvibesShowAddAppLink", StringPool.BLANK));

    if (lfrNetvibesShowAddAppLink) {
      return true;
    }

    return false;
  }
Esempio n. 12
0
  @Override
  protected void overrideConfiguration(
      GadgetSpec gadgetSpec, Portlet portlet, PortletDisplay portletDisplay) throws Exception {

    String urlConfiguration = portletDisplay.getURLConfiguration();

    if (ShindigUtil.hasUserPrefs(gadgetSpec)) {
      portlet.setConfigurationActionClass(ConfigurationActionImpl.class.getName());

      urlConfiguration = urlConfiguration.replaceAll("edit_permissions", "edit_configuration");
    } else {
      portlet.setConfigurationActionClass(null);

      urlConfiguration = urlConfiguration.replaceAll("edit_configuration", "edit_permissions");
    }

    portletDisplay.setURLConfiguration(urlConfiguration);
  }
Esempio n. 13
0
  public static Map<String, String> getEmailFromDefinitionTerms(PortletRequest portletRequest) {

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

    Map<String, String> definitionTerms = new LinkedHashMap<>();

    definitionTerms.put(
        "[$COMPANY_ID$]",
        LanguageUtil.get(
            themeDisplay.getLocale(), "the-company-id-associated-with-the-message-board"));
    definitionTerms.put(
        "[$COMPANY_MX$]",
        LanguageUtil.get(
            themeDisplay.getLocale(), "the-company-mx-associated-with-the-message-board"));
    definitionTerms.put(
        "[$COMPANY_NAME$]",
        LanguageUtil.get(
            themeDisplay.getLocale(), "the-company-name-associated-with-the-message-board"));

    if (PropsValues.POP_SERVER_NOTIFICATIONS_ENABLED) {
      definitionTerms.put(
          "[$MAILING_LIST_ADDRESS$]",
          LanguageUtil.get(themeDisplay.getLocale(), "the-email-address-of-the-mailing-list"));
    }

    definitionTerms.put(
        "[$MESSAGE_USER_ADDRESS$]",
        LanguageUtil.get(
            themeDisplay.getLocale(), "the-email-address-of-the-user-who-added-the-message"));
    definitionTerms.put(
        "[$MESSAGE_USER_NAME$]",
        LanguageUtil.get(themeDisplay.getLocale(), "the-user-who-added-the-message"));

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    definitionTerms.put("[$PORTLET_NAME$]", HtmlUtil.escape(portletDisplay.getTitle()));

    definitionTerms.put(
        "[$SITE_NAME$]",
        LanguageUtil.get(
            themeDisplay.getLocale(), "the-site-name-associated-with-the-message-board"));

    return definitionTerms;
  }
  protected void addPortletTitleAddCategoryMenuItem(
      List<MenuItem> menuItems,
      long categoryId,
      ThemeDisplay themeDisplay,
      PortletRequest portletRequest)
      throws PortalException {

    if (!containsPermission(
        themeDisplay.getPermissionChecker(),
        themeDisplay.getScopeGroupId(),
        categoryId,
        ActionKeys.ADD_CATEGORY)) {

      return;
    }

    URLMenuItem urlMenuItem = new URLMenuItem();

    String key = "category[message-board]";

    if (categoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {
      key = "subcategory[message-board]";
    }

    urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), key));

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            portletRequest,
            portletDisplay.getId(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_category");
    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("parentCategoryId", String.valueOf(categoryId));

    urlMenuItem.setURL(portletURL.toString());

    menuItems.add(urlMenuItem);
  }
  protected WikiPortletInstanceSettings getWikiPortletInstanceSettings(ActionRequest actionRequest)
      throws PortalException {

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    WikiWebSettingsProvider wikiWebSettingsProvider =
        WikiWebSettingsProvider.getWikiWebSettingsProvider();

    PortletInstanceSettingsProvider<WikiPortletInstanceSettings> portletIntanceSettingsProvider =
        wikiWebSettingsProvider.getPortletInstanceSettingsProvider();

    WikiPortletInstanceSettings wikiPortletInstanceSettings =
        portletIntanceSettingsProvider.getPortletInstanceSettings(
            themeDisplay.getLayout(), portletDisplay.getId());

    return wikiPortletInstanceSettings;
  }
  @Override
  public String getOnClick() {
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    StringBuilder sb = new StringBuilder(11);

    sb.append("Liferay.Portlet.openWindow('#p_p_id_");
    sb.append(portletDisplay.getId());
    sb.append("_', '");
    sb.append(portletDisplay.getId());
    sb.append("', '");
    sb.append(HtmlUtil.escapeJS(portletDisplay.getURLConfiguration()));
    sb.append("', '");
    sb.append(portletDisplay.getNamespace());
    sb.append("', '");
    sb.append(LanguageUtil.get(themeDisplay.getLocale(), "configuration"));
    sb.append("'); return false;");

    return sb.toString();
  }
  @Override
  protected String getPage() {
    if (FileAvailabilityUtil.isAvailable(servletContext, _PAGE)) {
      return _PAGE;
    }

    PortletDisplay portletDisplay = (PortletDisplay) pageContext.getAttribute("portletDisplay");

    if (!portletDisplay.isShowBackIcon()) {
      return null;
    }

    setCssClass("portlet-back portlet-back-icon");
    setImage("../portlet/back");
    setMessage("back");
    setToolTip(false);
    setUrl(portletDisplay.getURLBack());

    return super.getPage();
  }
Esempio n. 18
0
  @Override
  protected String getPage() {
    if (FileAvailabilityUtil.isAvailable(getServletContext(), _PAGE)) {
      return _PAGE;
    }

    PortletDisplay portletDisplay = (PortletDisplay) pageContext.getAttribute("portletDisplay");

    if (!portletDisplay.isShowExportImportIcon()) {
      return null;
    }

    setCssClass("portlet-export-import portlet-export-import-icon");
    setImage("download");
    setMessage("export-import");
    setMethod("get");
    setToolTip(false);
    setUrl(portletDisplay.getURLExportImport());

    return super.getPage();
  }
  protected JSONArray getJSONArray(HttpServletRequest request) throws PortalException {

    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    SocialInteractionsConfiguration socialInteractionsConfiguration =
        SocialInteractionsConfigurationUtil.getSocialInteractionsConfiguration(
            themeDisplay.getCompanyId(), portletDisplay.getId());

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

    List<User> users =
        MentionsUserFinderUtil.getUsers(
            themeDisplay.getCompanyId(),
            themeDisplay.getUserId(),
            query,
            socialInteractionsConfiguration);

    for (User user : users) {
      if (user.isDefaultUser() || (themeDisplay.getUserId() == user.getUserId())) {

        continue;
      }

      JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

      jsonObject.put("fullName", user.getFullName());
      jsonObject.put("portraitURL", user.getPortraitURL(themeDisplay));
      jsonObject.put("profileURL", user.getDisplayURL(themeDisplay));
      jsonObject.put("screenName", user.getScreenName());

      jsonArray.put(jsonObject);
    }

    return jsonArray;
  }
  protected void addPortletTitleAddMessageMenuItem(
      List<MenuItem> menuItems,
      long categoryId,
      ThemeDisplay themeDisplay,
      PortletRequest portletRequest)
      throws PortalException {

    if (!containsPermission(
        themeDisplay.getPermissionChecker(),
        themeDisplay.getScopeGroupId(),
        categoryId,
        ActionKeys.ADD_MESSAGE)) {

      return;
    }

    URLMenuItem urlMenuItem = new URLMenuItem();

    urlMenuItem.setLabel(
        LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "thread"));

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            portletRequest,
            portletDisplay.getId(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/message_boards/edit_message");
    portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest));
    portletURL.setParameter("mbCategoryId", String.valueOf(categoryId));

    urlMenuItem.setURL(portletURL.toString());

    menuItems.add(urlMenuItem);
  }
Esempio n. 21
0
  @Override
  public int doStartTag() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

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

    if (_direction == null) {
      if (_align.equals("left")) {
        _direction = "right";
      } else {
        _direction = "left";
      }
    }

    if (_icon == null) {
      _icon = themeDisplay.getPathThemeImages() + "/common/tool.png";
    }

    if (Validator.isNull(_id)) {
      String randomKey = PortalUtil.generateRandomKey(request, IconMenuTag.class.getName());

      _id = randomKey + StringPool.UNDERLINE + "menu";
    } else {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      String namespace = portletDisplay.getNamespace();

      _id = namespace.concat(_id);
    }

    request.setAttribute("liferay-ui:icon-menu:icon-count", new IntegerWrapper());
    request.setAttribute(
        "liferay-ui:icon-menu:showWhenSingleIcon", String.valueOf(_showWhenSingleIcon));

    return EVAL_BODY_BUFFERED;
  }
  public void copyTo(PortletDisplay slave) {
    slave.setActive(_active);
    slave.setColumnCount(_columnCount);
    slave.setColumnId(_columnId);
    slave.setColumnPos(_columnPos);
    slave.setContent(_content);
    slave.setControlPanelCategory(_controlPanelCategory);
    slave.setCustomCSSClassName(_customCSSClassName);
    slave.setDescription(_description);
    slave.setId(_id);
    slave.setInstanceId(_instanceId);
    slave.setModeAbout(_modeAbout);
    slave.setModeConfig(_modeConfig);
    slave.setModeEdit(_modeEdit);
    slave.setModeEditDefaults(_modeEditDefaults);
    slave.setModeEditGuest(_modeEditGuest);
    slave.setModeHelp(_modeHelp);
    slave.setModePreview(_modePreview);
    slave.setModePrint(_modePrint);
    slave.setModeView(_modeView);
    slave.setNamespace(_namespace);
    slave.setPortletName(_portletName);
    slave.setPortletResource(_portletResource);
    slave.setPortletSetup(_portletSetup);
    slave.setResourcePK(_resourcePK);
    slave.setRestoreCurrentView(_restoreCurrentView);
    slave.setRootPortletId(_rootPortletId);
    slave.setShowBackIcon(_showBackIcon);
    slave.setShowCloseIcon(_showCloseIcon);
    slave.setShowConfigurationIcon(_showConfigurationIcon);
    slave.setShowEditDefaultsIcon(_showEditDefaultsIcon);
    slave.setShowEditGuestIcon(_showEditGuestIcon);
    slave.setShowEditIcon(_showEditIcon);
    slave.setShowExportImportIcon(_showExportImportIcon);
    slave.setShowHelpIcon(_showHelpIcon);
    slave.setShowMaxIcon(_showMaxIcon);
    slave.setShowMinIcon(_showMinIcon);
    slave.setShowMoveIcon(_showMoveIcon);
    slave.setShowPortletCssIcon(_showPortletCssIcon);
    slave.setShowPortletIcon(_showPortletIcon);
    slave.setShowPrintIcon(_showPrintIcon);
    slave.setShowRefreshIcon(_showRefreshIcon);
    slave.setStateExclusive(_stateExclusive);
    slave.setStateMax(_stateMax);
    slave.setStateMin(_stateMin);
    slave.setStateNormal(_stateNormal);
    slave.setStatePopUp(_statePopUp);
    slave.setThemeDisplay(_themeDisplay);
    slave.setURLBack(_urlBack);
    slave.setURLClose(_urlClose);
    slave.setURLConfiguration(_urlConfiguration);
    slave.setURLEdit(_urlEdit);
    slave.setURLEditDefaults(_urlEditDefaults);
    slave.setURLEditGuest(_urlEditGuest);
    slave.setURLExportImport(_urlExportImport);
    slave.setURLHelp(_urlHelp);
    slave.setURLMax(_urlMax);
    slave.setURLMin(_urlMin);
    slave.setURLPortlet(_urlPortlet);
    slave.setURLPortletCss(_urlPortletCss);
    slave.setURLPrint(_urlPrint);
    slave.setURLRefresh(_urlRefresh);
    slave.setWebDAVEnabled(_webDAVEnabled);

    slave._title = _title;
  }
 public void copyFrom(PortletDisplay master) {
   _active = master.isActive();
   _columnCount = master.getColumnCount();
   _columnId = master.getColumnId();
   _columnPos = master.getColumnPos();
   _content = master.getContent();
   _controlPanelCategory = master.getControlPanelCategory();
   _customCSSClassName = master.getCustomCSSClassName();
   _description = master.getDescription();
   _id = master.getId();
   _instanceId = master.getInstanceId();
   _modeAbout = master.isModeAbout();
   _modeConfig = master.isModeConfig();
   _modeEdit = master.isModeEdit();
   _modeEditDefaults = master.isModeEditDefaults();
   _modeEditGuest = master.isModeEditGuest();
   _modeHelp = master.isModeHelp();
   _modePreview = master.isModePreview();
   _modePrint = master.isModePrint();
   _modeView = master.isModeView();
   _namespace = master.getNamespace();
   _portletName = master.getPortletName();
   _portletSetup = master.getPortletSetup();
   _resourcePK = master.getResourcePK();
   _restoreCurrentView = master.isRestoreCurrentView();
   _rootPortletId = master.getRootPortletId();
   _showBackIcon = master.isShowBackIcon();
   _showCloseIcon = master.isShowCloseIcon();
   _showConfigurationIcon = master.isShowConfigurationIcon();
   _showEditDefaultsIcon = master.isShowEditDefaultsIcon();
   _showEditGuestIcon = master.isShowEditGuestIcon();
   _showEditIcon = master.isShowEditIcon();
   _showExportImportIcon = master.isShowExportImportIcon();
   _showHelpIcon = master.isShowHelpIcon();
   _showMaxIcon = master.isShowMaxIcon();
   _showMinIcon = master.isShowMinIcon();
   _showMoveIcon = master.isShowMoveIcon();
   _showPortletCssIcon = master.isShowPortletCssIcon();
   _showPortletIcon = master.isShowPortletIcon();
   _showPrintIcon = master.isShowPrintIcon();
   _showRefreshIcon = master.isShowRefreshIcon();
   _stateExclusive = master.isStateExclusive();
   _stateMax = master.isStateMax();
   _stateMin = master.isStateMin();
   _stateNormal = master.isStateNormal();
   _statePopUp = master.isStatePopUp();
   _themeDisplay = master.getThemeDisplay();
   _title = master.getTitle();
   _urlBack = master.getURLBack();
   _urlClose = master.getURLClose();
   _urlConfiguration = master.getURLConfiguration();
   _urlEdit = master.getURLEdit();
   _urlEditDefaults = master.getURLEditDefaults();
   _urlEditGuest = master.getURLEditGuest();
   _urlExportImport = master.getURLExportImport();
   _urlHelp = master.getURLHelp();
   _urlMax = master.getURLMax();
   _urlMin = master.getURLMin();
   _urlPortlet = master.getURLPortlet();
   _urlPortletCss = master.getURLPortletCss();
   _urlPrint = master.getURLPrint();
   _urlRefresh = master.getURLRefresh();
   _webDAVEnabled = master.isWebDAVEnabled();
 }
  private void _doRender(HttpServletRequest request, HttpServletResponse response, Portlet portlet)
      throws Exception {

    if ((portlet != null) && portlet.isInstanceable() && !portlet.isAddDefaultResource()) {

      String instanceId = portlet.getInstanceId();

      if (!Validator.isPassword(instanceId)) {
        if (_log.isDebugEnabled()) {
          _log.debug(
              "Portlet "
                  + portlet.getPortletId()
                  + " is instanceable but does not have a valid "
                  + "instance id");
        }

        portlet = null;
      }
    }

    if (portlet == null) {
      return;
    }

    // Capture the current portlet's settings to reset them once the child
    // portlet is rendered

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    PortletDisplay portletDisplayClone = PortletDisplayFactory.create();

    portletDisplay.copyTo(portletDisplayClone);

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

    PortletRequest portletRequest =
        (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    if (!(portletRequest instanceof RenderRequest)) {
      portletRequest = null;
    }

    PortletResponse portletResponse =
        (PortletResponse) request.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

    if (!(portletResponse instanceof RenderResponse)) {
      portletResponse = null;
    }

    String lifecycle = (String) request.getAttribute(PortletRequest.LIFECYCLE_PHASE);

    request.setAttribute(WebKeys.RENDER_PORTLET, portlet);

    String path = (String) request.getAttribute(WebKeys.RENDER_PATH);

    if (path == null) {
      path = "/html/portal/render_portlet.jsp";
    }

    RequestDispatcher requestDispatcher =
        DirectRequestDispatcherFactoryUtil.getRequestDispatcher(request, path);

    BufferCacheServletResponse bufferCacheServletResponse = null;

    boolean writeOutput = false;

    if (response instanceof BufferCacheServletResponse) {
      bufferCacheServletResponse = (BufferCacheServletResponse) response;
    } else {
      writeOutput = true;
      bufferCacheServletResponse = new BufferCacheServletResponse(response);
    }

    try {
      requestDispatcher.include(request, bufferCacheServletResponse);

      Boolean portletConfiguratorVisibility =
          (Boolean) request.getAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY);

      if (portletConfiguratorVisibility != null) {
        request.removeAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY);

        Layout layout = themeDisplay.getLayout();

        if (!layout.isTypeControlPanel()
            && !LayoutPermissionUtil.contains(
                themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)
            && !PortletPermissionUtil.contains(
                themeDisplay.getPermissionChecker(),
                layout,
                portlet.getPortletId(),
                ActionKeys.CONFIGURATION)) {

          bufferCacheServletResponse.setCharBuffer(null);

          return;
        }
      }

      if (writeOutput) {
        Writer writer = response.getWriter();

        writer.write(bufferCacheServletResponse.getString());
      }
    } finally {
      portletDisplay.copyFrom(portletDisplayClone);

      portletDisplayClone.recycle();

      if (portletConfig != null) {
        request.setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, portletConfig);
      }

      if (portletRequest != null) {
        request.setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, portletRequest);
      }

      if (portletResponse != null) {
        request.setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse);
      }

      if (lifecycle != null) {
        request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle);
      }

      request.removeAttribute(WebKeys.RENDER_PORTLET);
    }
  }
  private void _doServeResource(
      HttpServletRequest request, HttpServletResponse response, Portlet portlet) throws Exception {

    HttpServletRequest ownerLayoutRequest = getOwnerLayoutRequestWrapper(request, portlet);

    Layout ownerLayout = (Layout) ownerLayoutRequest.getAttribute(WebKeys.LAYOUT);

    boolean allowAddPortletDefaultResource =
        PortalUtil.isAllowAddPortletDefaultResource(ownerLayoutRequest, portlet);

    if (!allowAddPortletDefaultResource) {
      String url = null;

      LastPath lastPath = (LastPath) request.getAttribute(WebKeys.LAST_PATH);

      if (lastPath != null) {
        StringBundler sb = new StringBundler(3);

        sb.append(PortalUtil.getPortalURL(request));
        sb.append(lastPath.getContextPath());
        sb.append(lastPath.getPath());

        url = sb.toString();
      } else {
        url = String.valueOf(request.getRequestURI());
      }

      response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);

      _log.error("Reject serveResource for " + url + " on " + portlet.getPortletId());

      return;
    }

    WindowState windowState = (WindowState) request.getAttribute(WebKeys.WINDOW_STATE);

    PortletMode portletMode =
        PortletModeFactory.getPortletMode(ParamUtil.getString(request, "p_p_mode"));

    PortletPreferencesIds portletPreferencesIds =
        PortletPreferencesFactoryUtil.getPortletPreferencesIds(request, portlet.getPortletId());

    PortletPreferences portletPreferences =
        PortletPreferencesLocalServiceUtil.getPreferences(portletPreferencesIds);

    ServletContext servletContext = (ServletContext) request.getAttribute(WebKeys.CTX);

    InvokerPortlet invokerPortlet = PortletInstanceFactoryUtil.create(portlet, servletContext);

    PortletConfig portletConfig = PortletConfigFactoryUtil.create(portlet, servletContext);
    PortletContext portletContext = portletConfig.getPortletContext();

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT);

    String portletPrimaryKey =
        PortletPermissionUtil.getPrimaryKey(layout.getPlid(), portlet.getPortletId());

    portletDisplay.setId(portlet.getPortletId());
    portletDisplay.setRootPortletId(portlet.getRootPortletId());
    portletDisplay.setInstanceId(portlet.getInstanceId());
    portletDisplay.setResourcePK(portletPrimaryKey);
    portletDisplay.setPortletName(portletConfig.getPortletName());
    portletDisplay.setNamespace(PortalUtil.getPortletNamespace(portlet.getPortletId()));

    WebDAVStorage webDAVStorage = portlet.getWebDAVStorageInstance();

    if (webDAVStorage != null) {
      portletDisplay.setWebDAVEnabled(true);
    } else {
      portletDisplay.setWebDAVEnabled(false);
    }

    ResourceRequestImpl resourceRequestImpl =
        ResourceRequestFactory.create(
            request,
            portlet,
            invokerPortlet,
            portletContext,
            windowState,
            portletMode,
            portletPreferences,
            layout.getPlid());

    long companyId = PortalUtil.getCompanyId(request);

    ResourceResponseImpl resourceResponseImpl =
        ResourceResponseFactory.create(
            resourceRequestImpl, response, portlet.getPortletId(), companyId);

    resourceRequestImpl.defineObjects(portletConfig, resourceResponseImpl);

    try {
      ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequestImpl);

      ServiceContextThreadLocal.pushServiceContext(serviceContext);

      PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

      long scopeGroupId = themeDisplay.getScopeGroupId();

      boolean access =
          PortletPermissionUtil.hasAccessPermission(
              permissionChecker, scopeGroupId, ownerLayout, portlet, portletMode);

      if (access) {
        invokerPortlet.serveResource(resourceRequestImpl, resourceResponseImpl);

        resourceResponseImpl.transferHeaders(response);
      }
    } finally {
      ServiceContextThreadLocal.popServiceContext();
    }
  }
  protected FileEntry updateFileEntry(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);

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

    String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD);

    long fileEntryId = ParamUtil.getLong(uploadPortletRequest, "fileEntryId");

    long repositoryId = ParamUtil.getLong(uploadPortletRequest, "repositoryId");
    long folderId = ParamUtil.getLong(uploadPortletRequest, "folderId");
    String sourceFileName = uploadPortletRequest.getFileName("file");
    String title = ParamUtil.getString(uploadPortletRequest, "title");
    String description = ParamUtil.getString(uploadPortletRequest, "description");
    String changeLog = ParamUtil.getString(uploadPortletRequest, "changeLog");
    boolean majorVersion = ParamUtil.getBoolean(uploadPortletRequest, "majorVersion");

    if (folderId > 0) {
      Folder folder = _dlAppService.getFolder(folderId);

      if (folder.getGroupId() != themeDisplay.getScopeGroupId()) {
        throw new NoSuchFolderException("{folderId=" + folderId + "}");
      }
    }

    InputStream inputStream = null;

    try {
      String contentType = uploadPortletRequest.getContentType("file");
      long size = uploadPortletRequest.getSize("file");

      if ((cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) && (size == 0)) {

        contentType = MimeTypesUtil.getContentType(title);
      }

      if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC) || (size > 0)) {

        String portletName = portletConfig.getPortletName();

        if (portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) {
          PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

          DLPortletInstanceSettings dlPortletInstanceSettings =
              DLPortletInstanceSettings.getInstance(
                  themeDisplay.getLayout(), portletDisplay.getId());

          String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes();

          if (Arrays.binarySearch(mimeTypes, contentType) < 0) {
            throw new FileMimeTypeException(contentType);
          }
        }
      }

      inputStream = uploadPortletRequest.getFileAsStream("file");

      ServiceContext serviceContext =
          ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest);

      FileEntry fileEntry = null;

      if (cmd.equals(Constants.ADD) || cmd.equals(Constants.ADD_DYNAMIC)) {

        // Add file entry

        fileEntry =
            _dlAppService.addFileEntry(
                repositoryId,
                folderId,
                sourceFileName,
                contentType,
                title,
                description,
                changeLog,
                inputStream,
                size,
                serviceContext);

        if (cmd.equals(Constants.ADD_DYNAMIC)) {
          JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

          jsonObject.put("fileEntryId", fileEntry.getFileEntryId());

          JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
        }
      } else if (cmd.equals(Constants.UPDATE_AND_CHECKIN)) {

        // Update file entry and checkin

        fileEntry =
            _dlAppService.updateFileEntryAndCheckIn(
                fileEntryId,
                sourceFileName,
                contentType,
                title,
                description,
                changeLog,
                majorVersion,
                inputStream,
                size,
                serviceContext);
      } else {

        // Update file entry

        fileEntry =
            _dlAppService.updateFileEntry(
                fileEntryId,
                sourceFileName,
                contentType,
                title,
                description,
                changeLog,
                majorVersion,
                inputStream,
                size,
                serviceContext);
      }

      return fileEntry;
    } catch (Exception e) {
      UploadException uploadException =
          (UploadException) actionRequest.getAttribute(WebKeys.UPLOAD_EXCEPTION);

      if (uploadException != null) {
        if (uploadException.isExceededLiferayFileItemSizeLimit()) {
          throw new LiferayFileItemException();
        } else if (uploadException.isExceededSizeLimit()) {
          throw new FileSizeException(uploadException.getCause());
        }
      }

      throw e;
    } finally {
      StreamUtil.cleanUp(inputStream);
    }
  }
  @Override
  public boolean isShow() {
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.isShowConfigurationIcon();
  }
  @Override
  public String getURL() {
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    return portletDisplay.getURLConfiguration();
  }
Esempio n. 29
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      /**
       * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
       *
       * <p>This library 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.
       *
       * <p>This library 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.
       */
      out.write('\n');
      out.write('\n');

      /**
       * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
       *
       * <p>This library 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.
       *
       * <p>This library 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.
       */
      out.write('\n');
      out.write('\n');

      /**
       * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
       *
       * <p>This library 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.
       *
       * <p>This library 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.
       */
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      //  liferay-theme:defineObjects
      com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 =
          (com.liferay.taglib.theme.DefineObjectsTag)
              _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody.get(
                  com.liferay.taglib.theme.DefineObjectsTag.class);
      _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context);
      _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null);
      int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 =
          _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.doStartTag();
      if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0.doEndTag()
          == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody.reuse(
            _jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
        return;
      }
      _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody.reuse(
          _jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
      com.liferay.portal.theme.ThemeDisplay themeDisplay = null;
      com.liferay.portal.model.Company company = null;
      com.liferay.portal.model.Account account = null;
      com.liferay.portal.model.User user = null;
      com.liferay.portal.model.User realUser = null;
      com.liferay.portal.model.Contact contact = null;
      com.liferay.portal.model.Layout layout = null;
      java.util.List layouts = null;
      java.lang.Long plid = null;
      com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null;
      java.lang.Long scopeGroupId = null;
      com.liferay.portal.security.permission.PermissionChecker permissionChecker = null;
      java.util.Locale locale = null;
      java.util.TimeZone timeZone = null;
      com.liferay.portal.model.Theme theme = null;
      com.liferay.portal.model.ColorScheme colorScheme = null;
      com.liferay.portal.theme.PortletDisplay portletDisplay = null;
      java.lang.Long portletGroupId = null;
      themeDisplay =
          (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay");
      company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company");
      account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account");
      user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user");
      realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser");
      contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact");
      layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout");
      layouts = (java.util.List) _jspx_page_context.findAttribute("layouts");
      plid = (java.lang.Long) _jspx_page_context.findAttribute("plid");
      layoutTypePortlet =
          (com.liferay.portal.model.LayoutTypePortlet)
              _jspx_page_context.findAttribute("layoutTypePortlet");
      scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId");
      permissionChecker =
          (com.liferay.portal.security.permission.PermissionChecker)
              _jspx_page_context.findAttribute("permissionChecker");
      locale = (java.util.Locale) _jspx_page_context.findAttribute("locale");
      timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone");
      theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme");
      colorScheme =
          (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme");
      portletDisplay =
          (com.liferay.portal.theme.PortletDisplay)
              _jspx_page_context.findAttribute("portletDisplay");
      portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId");
      out.write('\n');
      out.write('\n');

      /**
       * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
       *
       * <p>This library 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.
       *
       * <p>This library 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.
       */
      out.write('\n');
      out.write('\n');

      PortletRequest portletRequest =
          (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

      PortletResponse portletResponse =
          (PortletResponse) request.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

      String namespace = StringPool.BLANK;

      boolean useNamespace =
          GetterUtil.getBoolean((String) request.getAttribute("aui:form:useNamespace"), true);

      if ((portletResponse != null) && useNamespace) {
        namespace = portletResponse.getNamespace();
      }

      String currentURL = PortalUtil.getCurrentURL(request);

      out.write('\n');
      out.write('\n');

      /**
       * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
       *
       * <p>This library 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.
       *
       * <p>This library 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.
       */
      out.write('\n');
      out.write('\n');
      out.write('\n');
      out.write('\n');
      //  c:if
      org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_005fif_005f0 =
          (org.apache.taglibs.standard.tag.rt.core.IfTag)
              _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.get(
                  org.apache.taglibs.standard.tag.rt.core.IfTag.class);
      _jspx_th_c_005fif_005f0.setPageContext(_jspx_page_context);
      _jspx_th_c_005fif_005f0.setParent(null);
      // /html/taglib/portlet/icon_edit_defaults/page.jsp(19,0) name = test type = boolean reqTime =
      // true required = true fragment = false deferredValue = false expectedTypeName = null
      // deferredMethod = false methodSignature = null
      _jspx_th_c_005fif_005f0.setTest(portletDisplay.isShowEditDefaultsIcon());
      int _jspx_eval_c_005fif_005f0 = _jspx_th_c_005fif_005f0.doStartTag();
      if (_jspx_eval_c_005fif_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
        do {
          out.write('\n');
          out.write('	');
          //  liferay-ui:icon
          com.liferay.taglib.ui.IconTag _jspx_th_liferay_002dui_005ficon_005f0 =
              (com.liferay.taglib.ui.IconTag)
                  _005fjspx_005ftagPool_005fliferay_002dui_005ficon_0026_005furl_005ftoolTip_005fmessage_005fimage_005fnobody
                      .get(com.liferay.taglib.ui.IconTag.class);
          _jspx_th_liferay_002dui_005ficon_005f0.setPageContext(_jspx_page_context);
          _jspx_th_liferay_002dui_005ficon_005f0.setParent(
              (javax.servlet.jsp.tagext.Tag) _jspx_th_c_005fif_005f0);
          // /html/taglib/portlet/icon_edit_defaults/page.jsp(20,1) name = image type = null reqTime
          // = true required = false fragment = false deferredValue = false expectedTypeName = null
          // deferredMethod = false methodSignature = null
          _jspx_th_liferay_002dui_005ficon_005f0.setImage("../portlet/edit_defaults");
          // /html/taglib/portlet/icon_edit_defaults/page.jsp(20,1) name = message type = null
          // reqTime = true required = false fragment = false deferredValue = false expectedTypeName
          // = null deferredMethod = false methodSignature = null
          _jspx_th_liferay_002dui_005ficon_005f0.setMessage("default-preferences");
          // /html/taglib/portlet/icon_edit_defaults/page.jsp(20,1) name = toolTip type = null
          // reqTime = true required = false fragment = false deferredValue = false expectedTypeName
          // = null deferredMethod = false methodSignature = null
          _jspx_th_liferay_002dui_005ficon_005f0.setToolTip(false);
          // /html/taglib/portlet/icon_edit_defaults/page.jsp(20,1) name = url type = null reqTime =
          // true required = false fragment = false deferredValue = false expectedTypeName = null
          // deferredMethod = false methodSignature = null
          _jspx_th_liferay_002dui_005ficon_005f0.setUrl(portletDisplay.getURLEditDefaults());
          int _jspx_eval_liferay_002dui_005ficon_005f0 =
              _jspx_th_liferay_002dui_005ficon_005f0.doStartTag();
          if (_jspx_th_liferay_002dui_005ficon_005f0.doEndTag()
              == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fliferay_002dui_005ficon_0026_005furl_005ftoolTip_005fmessage_005fimage_005fnobody
                .reuse(_jspx_th_liferay_002dui_005ficon_005f0);
            return;
          }
          _005fjspx_005ftagPool_005fliferay_002dui_005ficon_0026_005furl_005ftoolTip_005fmessage_005fimage_005fnobody
              .reuse(_jspx_th_liferay_002dui_005ficon_005f0);
          out.write('\n');
          int evalDoAfterBody = _jspx_th_c_005fif_005f0.doAfterBody();
          if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break;
        } while (true);
      }
      if (_jspx_th_c_005fif_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
        _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0);
        return;
      }
      _005fjspx_005ftagPool_005fc_005fif_0026_005ftest.reuse(_jspx_th_c_005fif_005f0);
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Esempio n. 30
0
  public static PortletURL getAddPortletURL(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long groupId,
      String className,
      long classTypeId,
      long[] allAssetCategoryIds,
      String[] allAssetTagNames,
      String redirect)
      throws Exception {

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

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className);

    if ((assetRendererFactory == null)
        || !assetRendererFactory.hasAddPermission(
            themeDisplay.getPermissionChecker(), groupId, classTypeId)) {

      return null;
    }

    PortletURL addPortletURL =
        assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId);

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

    if (redirect != null) {
      addPortletURL.setParameter("redirect", redirect);
    }

    String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource");

    if (Validator.isNotNull(referringPortletResource)) {
      addPortletURL.setParameter("referringPortletResource", referringPortletResource);
    } else {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      addPortletURL.setParameter("referringPortletResource", portletDisplay.getId());

      if (allAssetCategoryIds != null) {
        Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>();

        for (long assetCategoryId : allAssetCategoryIds) {
          AssetCategory assetCategory =
              AssetCategoryLocalServiceUtil.fetchAssetCategory(assetCategoryId);

          if (assetCategory == null) {
            continue;
          }

          long assetVocabularyId = assetCategory.getVocabularyId();

          if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) {

            String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId);

            assetVocabularyAssetCategoryIds.put(
                assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId);
          } else {
            assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId));
          }
        }

        for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) {

          long assetVocabularyId = entry.getKey();
          String assetCategoryIds = entry.getValue();

          addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds);
        }
      }

      if (allAssetTagNames != null) {
        addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames));
      }
    }

    addPortletURL.setPortletMode(PortletMode.VIEW);
    addPortletURL.setWindowState(LiferayWindowState.POP_UP);

    return addPortletURL;
  }