protected String getSaveAndContinueRedirect(
      ActionRequest actionRequest, BlogsEntry entry, String redirect) throws Exception {

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

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

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/blogs/edit_entry");

    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("backURL", backURL, false);
    portletURL.setParameter("groupId", String.valueOf(entry.getGroupId()), false);
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
  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());
    }
  }
Пример #3
0
  @ActionMapping(params = "action=dettaglio")
  public void actionDettaglio(
      ActionRequest aRequest,
      ActionResponse aResponse,
      Model model,
      @ModelAttribute("navigaProgetti") NavigaProgetti navigaProgetti,
      @RequestParam(value = "idProgettoDettaglio") String idProgettoDettaglio,
      @RequestParam(value = "currentAction") String currentAction,
      @RequestParam(required = false, value = "cercaPerKeyword") String cercaPerKeyword) {

    navigaProgetti.setIdProgetto(idProgettoDettaglio);
    LiferayPortletURL renderURL =
        createLiferayPortletURL(aRequest, paginaDettaglioProgetto, dettaglioProgettoInstanceId);

    renderURL.setParameter("idPj", idProgettoDettaglio);

    try {

      ThemeDisplay themeDisplay = (ThemeDisplay) aRequest.getAttribute(WebKeys.THEME_DISPLAY);
      PortletURL returnURL =
          PortletURLFactoryUtil.create(
              aRequest,
              (String) aRequest.getAttribute(WebKeys.PORTLET_ID),
              themeDisplay.getLayout().getPlid(),
              PortletRequest.RENDER_PHASE);
      returnURL.setWindowState(WindowState.NORMAL);
      returnURL.setPortletMode(PortletMode.VIEW);
      // returnURL.setParameter("jsonnavigaprogetti",
      // createJsonStringFromModelAttribute(navigaProgetti));
      returnURL.setParameter("action", currentAction);
      if (!StringUtils.isEmpty(cercaPerKeyword)) {
        returnURL.setParameter("cercaPerKeyword", cercaPerKeyword);
      }

      renderURL.setParameter("returnUrl", returnURL.toString());

    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      aResponse.sendRedirect(
          HttpUtil.encodeParameters(
              renderURL.toString())); //  + "&idPj="+navigaProgetti.getIdProgetto() ) );
      return;
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig, ActionRequest actionRequest, DDMStructure structure)
      throws Exception {

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/dynamic_data_mapping/copy_structure");

    long classNameId = PortalUtil.getClassNameId(DDMStructure.class);

    portletURL.setParameter("classNameId", String.valueOf(classNameId), false);

    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()), false);
    portletURL.setParameter(
        "copyFormTemplates", ParamUtil.getString(actionRequest, "copyFormTemplates"), false);
    portletURL.setParameter(
        "copyDisplayTemplates", ParamUtil.getString(actionRequest, "copyDisplayTemplates"), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
Пример #5
0
  public void updateKBComment(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

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

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

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

    long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
    long classPK = ParamUtil.getLong(actionRequest, "classPK");
    String content = ParamUtil.getString(actionRequest, "content");
    boolean helpful = ParamUtil.getBoolean(actionRequest, "helpful");

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(KBComment.class.getName(), actionRequest);

    if (cmd.equals(Constants.ADD)) {
      KBCommentLocalServiceUtil.addKBComment(
          themeDisplay.getUserId(), classNameId, classPK, content, helpful, serviceContext);
    } else if (cmd.equals(Constants.UPDATE)) {
      KBCommentLocalServiceUtil.updateKBComment(
          kbCommentId, classNameId, classPK, content, helpful, serviceContext);
    }
  }
  protected void deleteImages(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long[] deleteFileEntryIds = null;

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

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

    Folder folder =
        _blogsEntryLocalService.addAttachmentsFolder(
            themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

    for (long deleteFileEntryId : deleteFileEntryIds) {
      FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(deleteFileEntryId);

      if (fileEntry.getFolderId() != folder.getFolderId()) {
        continue;
      }

      if ((fileEntry.getUserId() == themeDisplay.getUserId())
          || BlogsPermission.contains(
              themeDisplay.getPermissionChecker(),
              themeDisplay.getScopeGroupId(),
              ActionKeys.UPDATE)) {

        PortletFileRepositoryUtil.deletePortletFileEntry(deleteFileEntryId);
      }
    }
  }
  protected String getSaveAndContinueRedirect(
      ActionRequest actionRequest, JournalArticle article, String redirect) throws Exception {

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

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            JournalPortletKeys.JOURNAL,
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_article.jsp");
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("referringPortletResource", referringPortletResource, false);
    portletURL.setParameter("resourcePrimKey", String.valueOf(article.getResourcePrimKey()), false);
    portletURL.setParameter("groupId", String.valueOf(article.getGroupId()), false);
    portletURL.setParameter("folderId", String.valueOf(article.getFolderId()), false);
    portletURL.setParameter("articleId", article.getArticleId(), false);
    portletURL.setParameter("version", String.valueOf(article.getVersion()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
  protected void deleteTempFileEntry(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

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

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    try {
      _dlAppService.deleteTempFileEntry(
          themeDisplay.getScopeGroupId(), folderId, TEMP_FOLDER_NAME, fileName);

      jsonObject.put("deleted", Boolean.TRUE);
    } catch (Exception e) {
      String errorMessage =
          themeDisplay.translate("an-unexpected-error-occurred-while-deleting-the-file");

      jsonObject.put("deleted", Boolean.FALSE);
      jsonObject.put("errorMessage", errorMessage);
    }

    JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
  }
  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;
  }
Пример #10
0
  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());
    }
  }
 @SuppressWarnings("unchecked")
 @ProcessAction(name = "addBookAction")
 public void addBook(ActionRequest request, ActionResponse response)
     throws PortletException, IOException {
   logger.info("addBook action invoked");
   if (!request.isUserInRole("administrator")) {
     response.setRenderParameter("myaction", "error");
     response.setRenderParameter(
         "exceptionMsg",
         "You are not authorized for this action. You must have Administrator role.");
     return;
   }
   request.setAttribute("myaction", "addBookAction");
   PortletRequestDispatcher dispatcher =
       request
           .getPortletSession()
           .getPortletContext()
           .getRequestDispatcher(response.encodeURL("/myservlet/bookServlet"));
   dispatcher.include(request, response);
   Map<String, String> map = (Map<String, String>) request.getAttribute("errors");
   if (map != null && !map.isEmpty()) {
     response.setRenderParameter("myaction", "addBookAction");
   } else {
     response.setRenderParameter("myaction", "showCatalog");
   }
 }
  @ProcessAction(name = "searchBookAction")
  public void searchBook(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
    logger.info("Inside search Book action");
    request.setAttribute("myaction", "searchBookAction");
    PortletRequestDispatcher dispatcher =
        request
            .getPortletSession()
            .getPortletContext()
            .getRequestDispatcher(response.encodeURL("/myservlet/bookServlet"));
    dispatcher.include(request, response);
    response.setRenderParameter("myaction", "showSearchResults");

    // --store the search criteria in session
    request
        .getPortletSession()
        .setAttribute(
            "authorNameSearchField",
            request.getParameter("authorNameSearchField"),
            PortletSession.APPLICATION_SCOPE);
    request
        .getPortletSession()
        .setAttribute(
            "bookNameSearchField",
            request.getParameter("bookNameSearchField"),
            PortletSession.APPLICATION_SCOPE);
    // retrieving the matchingBooks request attribute set by BookServlet and
    // store it in session
    request
        .getPortletSession()
        .setAttribute("matchingBooks", request.getAttribute("matchingBooks"));
  }
  public void savePreferences(ActionRequest request, ActionResponse response) {

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

    String categoryIds = ParamUtil.getString(request, "assetCategoryIds");
    long resourcePrimKey = ParamUtil.getLong(request, "tipsCategoriesId");

    TipsOfTheDayCategories categories = new TipsOfTheDayCategoriesImpl();

    categories.setPrimaryKey(resourcePrimKey);
    categories.setGroupId(themeDisplay.getScopeGroupId());
    categories.setCategories(categoryIds);

    try {
      if (Validator.isNotNull(resourcePrimKey)) {
        TipsOfTheDayCategoriesLocalServiceUtil.updateTipsOfTheDayCategories(categories);

      } else {
        TipsOfTheDayCategoriesLocalServiceUtil.addTipsOfTheDayCategories(categories);
      }

    } catch (SystemException e) {
      logger.error("Error setting categories", e);
    }
  }
  protected void updateWorkflowDefinition(ActionRequest actionRequest) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);

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

    Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title");

    File file = uploadPortletRequest.getFile("file");

    WorkflowDefinition workflowDefinition = null;

    if (file == null) {
      String name = ParamUtil.getString(actionRequest, "name");
      int version = ParamUtil.getInteger(actionRequest, "version");

      workflowDefinition =
          WorkflowDefinitionManagerUtil.getWorkflowDefinition(
              themeDisplay.getCompanyId(), name, version);

      WorkflowDefinitionManagerUtil.updateTitle(
          themeDisplay.getCompanyId(), themeDisplay.getUserId(), name, version, getTitle(titleMap));
    } else {
      workflowDefinition =
          WorkflowDefinitionManagerUtil.deployWorkflowDefinition(
              themeDisplay.getCompanyId(), themeDisplay.getUserId(),
              getTitle(titleMap), FileUtil.getBytes(file));
    }

    actionRequest.setAttribute(WebKeys.WORKFLOW_DEFINITION, workflowDefinition);
  }
  protected void updateInstance(ActionRequest actionRequest) throws Exception {

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

    String webId = ParamUtil.getString(actionRequest, "webId");
    String virtualHostname = ParamUtil.getString(actionRequest, "virtualHostname");
    String mx = ParamUtil.getString(actionRequest, "mx");
    String shardName =
        ParamUtil.getString(actionRequest, "shardName", PropsValues.SHARD_DEFAULT_NAME);
    boolean system = false;
    int maxUsers = ParamUtil.getInteger(actionRequest, "maxUsers", 0);
    boolean active = ParamUtil.getBoolean(actionRequest, "active");

    if (companyId <= 0) {

      // Add instance

      Company company =
          CompanyServiceUtil.addCompany(
              webId, virtualHostname, mx, shardName, system, maxUsers, active);

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

      PortalInstances.initCompany(servletContext, company.getWebId());
    } else {

      // Update instance

      CompanyServiceUtil.updateCompany(companyId, virtualHostname, mx, maxUsers, active);
    }
  }
  protected void deleteInstance(ActionRequest actionRequest) throws Exception {

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

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

    WorkflowInstance workflowInstance =
        WorkflowInstanceManagerUtil.getWorkflowInstance(
            themeDisplay.getCompanyId(), workflowInstanceId);

    Map<String, Serializable> workflowContext = workflowInstance.getWorkflowContext();

    long companyId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
    long groupId = GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_GROUP_ID));
    String className =
        GetterUtil.getString(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME));
    long classPK =
        GetterUtil.getLong(workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));

    WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil.getWorkflowHandler(className);

    workflowHandler.updateStatus(WorkflowConstants.STATUS_DRAFT, workflowContext);

    WorkflowInstanceLinkLocalServiceUtil.deleteWorkflowInstanceLink(
        companyId, groupId, className, classPK);
  }
  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);
  }
  @Override
  protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    hideDefaultSuccessMessage(actionRequest);

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

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

    try {
      long exportImportConfigurationId =
          ParamUtil.getLong(actionRequest, "exportImportConfigurationId");

      if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
        updatePublishConfiguration(actionRequest);
      } else if (cmd.equals(Constants.PUBLISH_TO_LIVE)) {
        StagingUtil.publishLayouts(themeDisplay.getUserId(), exportImportConfigurationId);
      } else if (cmd.equals(Constants.PUBLISH_TO_REMOTE)) {
        StagingUtil.copyRemoteLayouts(exportImportConfigurationId);
      } else if (cmd.equals(Constants.RELAUNCH)) {
        relaunchPublishLayoutConfiguration(themeDisplay.getUserId(), actionRequest);
      }

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

      sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
      _log.error(e, e);

      SessionErrors.add(actionRequest, e.getClass());
    }
  }
Пример #19
0
  protected void updateActive(ActionRequest actionRequest, String cmd) throws Exception {

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

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

    if ((groupId == themeDisplay.getDoAsGroupId())
        || (groupId == themeDisplay.getScopeGroupId())
        || (groupId == getRefererGroupId(themeDisplay))) {

      throw new RequiredGroupException(
          String.valueOf(groupId), RequiredGroupException.CURRENT_GROUP);
    }

    Group group = GroupServiceUtil.getGroup(groupId);

    boolean active = false;

    if (cmd.equals(Constants.RESTORE)) {
      active = true;
    }

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(Group.class.getName(), actionRequest);

    GroupServiceUtil.updateGroup(
        groupId,
        group.getParentGroupId(),
        group.getName(),
        group.getDescription(),
        group.getType(),
        group.getFriendlyURL(),
        active,
        serviceContext);
  }
  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 String getSaveAndContinueRedirect(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      FileEntry fileEntry,
      String redirect)
      throws Exception {

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/document_library/edit_file_entry");
    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("groupId", String.valueOf(fileEntry.getGroupId()), false);
    portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()), false);
    portletURL.setParameter("version", String.valueOf(fileEntry.getVersion()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
Пример #22
0
  @SuppressWarnings("deprecation")
  private void _loadForm(ActionForm form, ActionRequest req, ActionResponse res) {
    try {
      StructureForm structureForm = (StructureForm) form;
      Structure structure = (Structure) req.getAttribute(WebKeys.Structure.STRUCTURE);
      BeanUtils.copyProperties(structureForm, structure);
      structureForm.setFields(structure.getFields());

      if (structure.getReviewInterval() != null) {
        String interval = structure.getReviewInterval();
        Pattern p = Pattern.compile("(\\d+)([dmy])");
        Matcher m = p.matcher(interval);
        boolean b = m.matches();
        if (b) {
          structureForm.setReviewContent(true);
          String g1 = m.group(1);
          String g2 = m.group(2);
          structureForm.setReviewIntervalNum(g1);
          structureForm.setReviewIntervalSelect(g2);
        }
      }
      if (UtilMethods.isSet(structure.getDetailPage())) {
        Identifier ident = APILocator.getIdentifierAPI().find(structure.getDetailPage());
        HTMLPage page = HTMLPageFactory.getLiveHTMLPageByIdentifier(ident);
        if (InodeUtils.isSet(page.getInode())) {
          structureForm.setDetailPage(page.getIdentifier());
        }
      }

    } catch (Exception ex) {
      Logger.debug(EditStructureAction.class, ex.toString());
    }
  }
  protected void deleteLDAPServer(ActionRequest actionRequest) throws Exception {

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

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

    // Remove preferences

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = new String[_KEYS.length];

    for (int i = 0; i < _KEYS.length; i++) {
      keys[i] = _KEYS[i] + postfix;
    }

    CompanyServiceUtil.removePreferences(themeDisplay.getCompanyId(), keys);

    // Update preferences

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(themeDisplay.getCompanyId());

    UnicodeProperties properties = new UnicodeProperties();

    String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK);

    ldapServerIds = StringUtil.remove(ldapServerIds, String.valueOf(ldapServerId));

    properties.put("ldap.server.ids", ldapServerIds);

    CompanyServiceUtil.updatePreferences(themeDisplay.getCompanyId(), properties);
  }
  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);
  }
Пример #25
0
  public void updateKBArticlesPriorities(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Enumeration<String> enu = actionRequest.getParameterNames();

    Map<Long, Double> resourcePrimKeyToPriorityMap = new HashMap<Long, Double>();

    while (enu.hasMoreElements()) {
      String name = enu.nextElement();

      if (!name.startsWith("priority")) {
        continue;
      }

      double priority = ParamUtil.getDouble(actionRequest, name);

      long resourcePrimKey = GetterUtil.getLong(name.substring(8));

      resourcePrimKeyToPriorityMap.put(resourcePrimKey, priority);
    }

    KBArticleServiceUtil.updateKBArticlesPriorities(
        themeDisplay.getScopeGroupId(), resourcePrimKeyToPriorityMap);
  }
  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());
  }
  @Override
  public void processAction(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    try {
      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 new PortalException(uploadException.getCause());
      } else {
        addFileEntry(actionRequest);
      }

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

      if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
      }
    } catch (Exception e) {
      handleUploadException(actionRequest, actionResponse, e);
    }
  }
  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();
    }
  }
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    Set<Long> messages = new HashSet<Long>();
    ThemeDisplay themedisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long userId = themedisplay.getUserId();
    String redirect = ParamUtil.getString(actionRequest, MessageConstants.REDIRECT);
    String[] msgs =
        ParamUtil.getString(actionRequest, MessageConstants.MOVE_MESSAGE_IDS, "").split(",");

    for (String s : msgs) {
      if (s.trim().length() == 0) continue;
      long messageId = Long.parseLong(s);
      Message m = MessageLocalServiceUtil.getMessage(messageId);
      if (!m.isArchived(userId)) {
        m.setArchived(userId);
      }
    }
    actionResponse.sendRedirect(redirect);
  }
  public void unsubscribe(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

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

    long[] subscriptionIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "subscriptionIds"), 0L);

    for (long subscriptionId : subscriptionIds) {
      if (subscriptionId <= 0) {
        continue;
      }

      Subscription subscription = SubscriptionLocalServiceUtil.getSubscription(subscriptionId);

      if (themeDisplay.getUserId() != subscription.getUserId()) {
        throw new PrincipalException();
      }

      SubscriptionLocalServiceUtil.deleteSubscription(subscription);
    }
  }