@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());
    }
  }
  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 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 SocialActivityFeedEntry doInterpret(SocialActivity activity, ThemeDisplay themeDisplay)
      throws Exception {

    String creatorUserName = getUserName(activity.getUserId(), themeDisplay);
    String receiverUserName = getUserName(activity.getReceiverUserId(), themeDisplay);

    User receiverUser = UserLocalServiceUtil.getUserById(activity.getReceiverUserId());

    if (!SocialRelationLocalServiceUtil.hasRelation(
            themeDisplay.getUserId(),
            activity.getReceiverUserId(),
            SocialRelationConstants.TYPE_BI_FRIEND)
        && (themeDisplay.getUserId() != activity.getReceiverUserId())) {

      return null;
    }

    int activityType = activity.getType();

    // Link

    WallEntry wallEntry = WallEntryLocalServiceUtil.getWallEntry(activity.getClassPK());

    String link =
        themeDisplay.getPortalURL()
            + themeDisplay.getPathFriendlyURLPublic()
            + StringPool.SLASH
            + HtmlUtil.escapeURL(receiverUser.getScreenName())
            + "/profile/-/wall/"
            + activity.getClassPK();

    // Title

    String title = StringPool.BLANK;

    if (activityType == WallActivityKeys.ADD_ENTRY) {
      title =
          themeDisplay.translate(
              "activity-social-networking-wall-add-entry",
              new Object[] {creatorUserName, receiverUserName});
    }

    // Body

    StringBuilder sb = new StringBuilder();

    sb.append("<a href=\"");
    sb.append(link);
    sb.append("\">");
    sb.append(HtmlUtil.escape(cleanContent(wallEntry.getComments())));
    sb.append("</a>");

    String body = sb.toString();

    return new SocialActivityFeedEntry(link, title, body);
  }
  protected Activity getActivity(ThemeDisplay themeDisplay, SocialActivity socialActivity)
      throws Exception {

    Activity activity = null;

    String className = socialActivity.getClassName();

    if (className.equals(Activity.class.getName())) {
      activity = getExternalActivity(socialActivity);
    } else {
      activity =
          new ActivityImpl(
              String.valueOf(socialActivity.getClassPK()),
              String.valueOf(socialActivity.getUserId()));

      HttpServletRequest request = HttpServletRequestThreadLocal.getHttpServletRequest();

      request.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay);

      ServiceContext serviceContext = ServiceContextFactory.getInstance(request);

      serviceContext.setCompanyId(themeDisplay.getCompanyId());
      serviceContext.setUserId(themeDisplay.getUserId());

      SocialActivityFeedEntry socialActivityFeedEntry = null;
      SocialActivityInterpreterLocalServiceUtil.interpret(
          StringPool.BLANK, socialActivity, serviceContext);

      activity.setBody(socialActivityFeedEntry.getBody());
      activity.setTitle(socialActivityFeedEntry.getTitle());
      activity.setUrl(socialActivityFeedEntry.getLink());
    }

    return activity;
  }
  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);
    }
  }
  @Override
  public PortalPreferences getPortalPreferences(HttpServletRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    return getPortalPreferences(
        request.getSession(), themeDisplay.getUserId(), themeDisplay.isSignedIn());
  }
Example #9
0
  /** @deprecated As of 6.2.0, replaced by {@link #getUserName(long, ServiceContext)} */
  protected String getUserName(long userId, ThemeDisplay themeDisplay) {
    try {
      if (userId <= 0) {
        return StringPool.BLANK;
      }

      User user = UserLocalServiceUtil.getUserById(userId);

      if (user.getUserId() == themeDisplay.getUserId()) {
        return HtmlUtil.escape(user.getFirstName());
      }

      String userName = user.getFullName();

      Group group = user.getGroup();

      if (group.getGroupId() == themeDisplay.getScopeGroupId()) {
        return HtmlUtil.escape(userName);
      }

      String userDisplayURL = user.getDisplayURL(themeDisplay);

      userName =
          "******"user\" href=\"" + userDisplayURL + "\">" + HtmlUtil.escape(userName) + "</a>";

      return userName;
    } catch (Exception e) {
      return StringPool.BLANK;
    }
  }
Example #10
0
  public static boolean isViewableMessage(
      ThemeDisplay themeDisplay, MBMessage message, MBMessage parentMessage) throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!MBMessagePermission.contains(permissionChecker, parentMessage, ActionKeys.VIEW)) {

      return false;
    }

    if ((message.getMessageId() != parentMessage.getMessageId())
        && !MBMessagePermission.contains(permissionChecker, message, ActionKeys.VIEW)) {

      return false;
    }

    if (!message.isApproved()
        && !Validator.equals(message.getUserId(), themeDisplay.getUserId())
        && !permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) {

      return false;
    }

    return true;
  }
Example #11
0
  @Override
  protected void doProcessCommand(PortletRequest portletRequest, PortletResponse portletResponse)
      throws Exception {

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

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

    String comment = ParamUtil.getString(portletRequest, "comment");

    int dueDateMonth = ParamUtil.getInteger(portletRequest, "dueDateMonth");
    int dueDateDay = ParamUtil.getInteger(portletRequest, "dueDateDay");
    int dueDateYear = ParamUtil.getInteger(portletRequest, "dueDateYear");
    int dueDateHour = ParamUtil.getInteger(portletRequest, "dueDateHour");
    int dueDateMinute = ParamUtil.getInteger(portletRequest, "dueDateMinute");
    int dueDateAmPm = ParamUtil.getInteger(portletRequest, "dueDateAmPm");

    if (dueDateAmPm == Calendar.PM) {
      dueDateHour += 12;
    }

    Date dueDate =
        PortalUtil.getDate(
            dueDateMonth,
            dueDateDay,
            dueDateYear,
            dueDateHour,
            dueDateMinute,
            WorkflowTaskDueDateException.class);

    WorkflowTaskManagerUtil.updateDueDate(
        themeDisplay.getCompanyId(), themeDisplay.getUserId(), workflowTaskId, comment, dueDate);
  }
Example #12
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);
    }
  }
  /**
   * Takes a submitted contact and adds it to the database if it passes validation.
   *
   * @param request
   * @param response
   */
  public void registerContact(ActionRequest request, ActionResponse response) throws Exception {

    _log.debug("registerContact");

    Contact contact = ActionUtil.contactFromRequest(request);
    ArrayList<String> errors = new ArrayList();
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    String community = "";
    try {
      community = themeDisplay.getScopeGroupName();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    boolean regValid = ContactMeRegValidator.validateRegistration(contact, errors);

    if (regValid) {

      long userId = themeDisplay.getUserId();

      contact.setCreateDate(new Date(System.currentTimeMillis()));
      contact.setUserId(userId);
      contact.setStatus(Constants.CONTACT_RECEIVED);
      contact.setCommunity(community);

      ContactLocalServiceUtil.addContact(contact);
      SessionMessages.add(request, "thank-you-message");

      PortletPreferences preferences = request.getPreferences();

      long companyId = PortalUtil.getCompanyId(request);

      Message message = new Message();

      message.put("from-name", preferences.getValue("fromName", ""));
      message.put("from-address", preferences.getValue("fromEMail", ""));
      message.put("subject", preferences.getValue("subject", ""));
      message.put("body", preferences.getValue("body", ""));
      message.put("signature", preferences.getValue("signature", ""));
      message.put("to-name", contact.getFullname());
      message.put("to-address", contact.getEmail());
      message.put("community", contact.getCommunity());
      message.put("companyId", companyId);

      MessageBusUtil.sendMessage("liferay/contactme", message);

      response.setRenderParameter("jspPage", viewThankYouJSP);

    } else {
      for (String error : errors) {
        SessionErrors.add(request, error);
      }
      SessionErrors.add(request, "error-saving-contact");
      response.setRenderParameter("jspPage", viewAddContactJSP);
      request.setAttribute("cmContact", contact);
    }
  }
  protected void checkout(ActionRequest actionRequest) throws Exception {
    if (!hasLatestOrder(actionRequest)) {
      ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

      ShoppingOrderLocalServiceUtil.addLatestOrder(
          themeDisplay.getUserId(), themeDisplay.getScopeGroupId());
    }
  }
  protected FileEntry getTempImageFileEntry(PortletRequest portletRequest) throws PortalException {

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

    return TempFileEntryUtil.getTempFileEntry(
        themeDisplay.getScopeGroupId(), themeDisplay.getUserId(),
        getTempImageFolderName(), getTempImageFileName(portletRequest));
  }
  public void joinOrganization(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId());

    Organization organization = _organizationLocalService.getOrganization(group.getClassPK());

    Role role =
        _roleLocalService.getRole(themeDisplay.getCompanyId(), "Organization Administrator");

    LinkedHashMap<String, Object> userParams = new LinkedHashMap<>();

    userParams.put("userGroupRole", new Long[] {group.getGroupId(), role.getRoleId()});

    List<User> users =
        _userLocalService.search(
            themeDisplay.getCompanyId(),
            null,
            WorkflowConstants.STATUS_APPROVED,
            userParams,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            (OrderByComparator<User>) null);

    if (users.isEmpty()) {
      Role adminRole =
          _roleLocalService.getRole(themeDisplay.getCompanyId(), RoleConstants.ADMINISTRATOR);

      userParams.clear();

      userParams.put("usersRoles", adminRole.getRoleId());

      users =
          _userLocalService.search(
              themeDisplay.getCompanyId(),
              null,
              WorkflowConstants.STATUS_APPROVED,
              userParams,
              QueryUtil.ALL_POS,
              QueryUtil.ALL_POS,
              (OrderByComparator<User>) null);
    }

    JSONObject extraDataJSONObject = getExtraDataJSONObject(actionRequest);

    for (User user : users) {
      _socialRequestLocalService.addRequest(
          themeDisplay.getUserId(),
          0,
          Organization.class.getName(),
          organization.getOrganizationId(),
          MembersRequestKeys.ADD_MEMBER,
          extraDataJSONObject.toString(),
          user.getUserId());
    }
  }
  /**
   * This method inserts new TerminationReason record into the database table
   *
   * @param actionRequest
   * @param actionResponse
   * @throws IOException
   * @throws PortletException
   * @throws SystemException
   */
  public void saveTerminationReasons(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    try {
      TerminationReasons terminationReasons =
          TerminationReasonsLocalServiceUtil.createTerminationReasons(
              CounterLocalServiceUtil.increment());

      String id = ParamUtil.getString(actionRequest, "terminationreasonsId");
      String name = ParamUtil.getString(actionRequest, "terminationreasonsName");
      String terminationReason = name.trim();
      if (terminationReason.equals("") || terminationReason == null) {

        System.out.println("Empty value in TerminationReason...");
        SessionMessages.add(actionRequest.getPortletSession(), "termination-form-error");
        actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp");
      } else {

        System.out.println("id == " + id + "Name = " + name);
        if (id == "" || id == null) {

          DynamicQuery dynamicQuery =
              DynamicQueryFactoryUtil.forClass(
                  TerminationReasons.class, PortalClassLoaderUtil.getClassLoader());

          dynamicQuery.add(RestrictionsFactoryUtil.eq("terminationreasonsName", name));
          List<TerminationReasons> list =
              TerminationReasonsLocalServiceUtil.dynamicQuery(dynamicQuery);

          if (list.size() > 0) {
            TerminationReasons terminationReasons2 = list.get(0);

            if (terminationReasons2 != null) {

              SessionMessages.add(
                  actionRequest.getPortletSession(), "termination-form-duplicate-error");
              actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp");
            }
          } else {

            terminationReasons.setTerminationreasonsName(
                ParamUtil.getString(actionRequest, "terminationreasonsName"));
            terminationReasons.setCreateDate(date);
            terminationReasons.setModifiedDate(date);
            terminationReasons.setCompanyId(themeDisplay.getCompanyId());
            terminationReasons.setGroupId(themeDisplay.getCompanyGroupId());
            terminationReasons.setUserId(themeDisplay.getUserId());
            terminationReasons =
                TerminationReasonsLocalServiceUtil.addTerminationReasons(terminationReasons);
          }
        }
      }
    } catch (SystemException e) {

      e.printStackTrace();
    }
  }
  protected void getLatestOrder(ActionRequest actionRequest) throws Exception {

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

    ShoppingOrder order =
        ShoppingOrderLocalServiceUtil.getLatestOrder(
            themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

    actionRequest.setAttribute(WebKeys.SHOPPING_ORDER, order);
  }
  protected void deleteWorkflowDefinition(ActionRequest actionRequest) throws Exception {

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

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

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

    if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {
      boolean active = !cmd.equals(Constants.DEACTIVATE);

      WorkflowDefinitionManagerUtil.updateActive(
          themeDisplay.getCompanyId(), themeDisplay.getUserId(), name, version, active);
    } else {
      WorkflowDefinitionManagerUtil.undeployWorkflowDefinition(
          themeDisplay.getCompanyId(), themeDisplay.getUserId(), name, version);
    }
  }
  public void leaveOrganization(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId());

    _userLocalService.unsetOrganizationUsers(
        group.getClassPK(), new long[] {themeDisplay.getUserId()});
  }
  public void leaveGroup(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    _userLocalService.unsetGroupUsers(
        themeDisplay.getScopeGroupId(), new long[] {themeDisplay.getUserId()}, serviceContext);
  }
  protected void updateQueryLogic(ActionRequest actionRequest, PortletPreferences preferences)
      throws Exception {

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

    long userId = themeDisplay.getUserId();
    long groupId = themeDisplay.getScopeGroupId();

    int[] queryRulesIndexes =
        StringUtil.split(ParamUtil.getString(actionRequest, "queryLogicIndexes"), 0);

    int i = 0;

    for (int queryRulesIndex : queryRulesIndexes) {
      boolean contains = ParamUtil.getBoolean(actionRequest, "queryContains" + queryRulesIndex);
      boolean andOperator =
          ParamUtil.getBoolean(actionRequest, "queryAndOperator" + queryRulesIndex);
      String name = ParamUtil.getString(actionRequest, "queryName" + queryRulesIndex);

      String[] values = null;

      if (name.equals("assetTags")) {
        values =
            StringUtil.split(ParamUtil.getString(actionRequest, "queryTagNames" + queryRulesIndex));

        AssetTagLocalServiceUtil.checkTags(userId, groupId, values);
      } else {
        values =
            StringUtil.split(
                ParamUtil.getString(actionRequest, "queryCategoryIds" + queryRulesIndex));
      }

      preferences.setValue("queryContains" + i, String.valueOf(contains));
      preferences.setValue("queryAndOperator" + i, String.valueOf(andOperator));
      preferences.setValue("queryName" + i, name);
      preferences.setValues("queryValues" + i, values);

      i++;
    }

    // Clear previous preferences that are now blank

    String[] values = preferences.getValues("queryValues" + i, new String[0]);

    while (values.length > 0) {
      preferences.setValue("queryContains" + i, StringPool.BLANK);
      preferences.setValue("queryAndOperator" + i, StringPool.BLANK);
      preferences.setValue("queryName" + i, StringPool.BLANK);
      preferences.setValues("queryValues" + i, new String[0]);

      i++;

      values = preferences.getValues("queryValues" + i, new String[0]);
    }
  }
  public void unsubscribeStructure(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

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

    _journalArticleService.unsubscribeStructure(
        themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), ddmStructureId);

    sendEditArticleRedirect(actionRequest, actionResponse);
  }
Example #24
0
  public void updateMeetupsRegistration(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    long meetupsEntryId = ParamUtil.getLong(actionRequest, "meetupsEntryId");
    int status = ParamUtil.getInteger(actionRequest, "status");
    String comments = ParamUtil.getString(actionRequest, "comments");

    MeetupsRegistrationLocalServiceUtil.updateMeetupsRegistration(
        themeDisplay.getUserId(), meetupsEntryId, status, comments);
  }
  public void deleteFriend(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Group group = _groupLocalService.getGroup(themeDisplay.getScopeGroupId());

    User user = _userLocalService.getUserById(group.getClassPK());

    _socialRelationLocalService.deleteRelation(
        themeDisplay.getUserId(), user.getUserId(), SocialRelationConstants.TYPE_BI_FRIEND);
  }
  protected boolean hasLatestOrder(ActionRequest actionRequest) throws Exception {

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

      ShoppingOrderLocalServiceUtil.getLatestOrder(
          themeDisplay.getUserId(), themeDisplay.getScopeGroupId());

      return true;
    } catch (NoSuchOrderException nsoe) {
      return false;
    }
  }
  protected FileEntry addTempImageFileEntry(PortletRequest portletRequest) throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(portletRequest);

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

    String contentType = uploadPortletRequest.getContentType("fileName");

    if (!MimeTypesUtil.isWebImage(contentType)) {
      throw new ImageTypeException();
    }

    String fileName = uploadPortletRequest.getFileName("fileName");

    try {
      TempFileEntryUtil.deleteTempFileEntry(
          themeDisplay.getScopeGroupId(),
          themeDisplay.getUserId(),
          getTempImageFolderName(),
          fileName);
    } catch (Exception e) {
    }

    InputStream inputStream = null;

    try {
      inputStream = uploadPortletRequest.getFileAsStream("fileName");

      return TempFileEntryUtil.addTempFileEntry(
          themeDisplay.getScopeGroupId(),
          themeDisplay.getUserId(),
          getTempImageFolderName(),
          fileName,
          inputStream,
          contentType);
    } finally {
      StreamUtil.cleanUp(inputStream);
    }
  }
  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;
  }
  public static boolean hasSubmitted(HttpServletRequest request, long recordSetId)
      throws PortalException, SystemException {

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

    List<DDLRecord> records =
        DDLRecordLocalServiceUtil.getRecords(recordSetId, themeDisplay.getUserId());

    if (records.isEmpty()) {
      return false;
    }

    return true;
  }
  protected void signalInstance(ActionRequest actionRequest) throws Exception {

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

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

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

    WorkflowInstanceManagerUtil.signalWorkflowInstance(
        themeDisplay.getCompanyId(),
        themeDisplay.getUserId(),
        workflowInstanceId,
        transitionName,
        null);
  }