コード例 #1
0
  public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
    _log.info("***processAction****");

    boolean error = false;

    String saveButton = (String) request.getParameter("saveButton");
    String resetButton = (String) request.getParameter("resetButton");

    _log.info("saveButton: " + saveButton);
    _log.info("resetButton: " + resetButton);

    String nameTelescope = (String) request.getParameter("nameTelescope");
    String nameObservatory = (String) request.getParameter("nameObservatory");
    String briefDescription = (String) request.getParameter("briefDescription");
    String nameCountry = (String) request.getParameter("nameCountry");
    String nameCity = (String) request.getParameter("nameCity");
    String latitude = (String) request.getParameter("latitude");
    String longitude = (String) request.getParameter("longitude");
    String urlTelescope = (String) request.getParameter("urlTelescope");

    _log.info("nameTelescope: " + nameTelescope);
    _log.info("nameObservatory: " + nameObservatory);
    _log.info("briefDescription: " + briefDescription);
    _log.info("nameCountry: " + nameCountry);
    _log.info("nameCity: " + nameCity);
    _log.info("latitude: " + latitude);
    _log.info("longitude: " + longitude);
    _log.info("urlTelescope: " + urlTelescope);

    ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    User user = td.getUser();
    _log.info("user: "******"error01");
    }

    try {
      repository.registerObservatory(nameObservatory, nameCity, nameCountry);
    } catch (RTRepositoryException_Exception e) {
      error = true;
      _log.error(e.getMessage());
    } catch (Exception e) {
      _log.error(e.getMessage());
    } finally {
      SessionErrors.add(request, "error01");
    }

    if (!error) SessionMessages.add(request, "success");
  }
コード例 #2
0
  public Books updateStatus(
      long userId, long resourcePrimKey, int status, ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userLocalService.getUser(userId);
    Books book = getBooks(resourcePrimKey);

    book.setStatus(status);
    book.setStatusByUserId(userId);
    book.setStatusByUserName(user.getFullName());
    book.setStatusDate(serviceContext.getModifiedDate());

    booksPersistence.update(book, false);

    if (status == WorkflowConstants.STATUS_APPROVED) {
      assetEntryLocalService.updateVisible(Books.class.getName(), resourcePrimKey, true);
    } else {
      assetEntryLocalService.updateVisible(Books.class.getName(), resourcePrimKey, false);
    }

    // Indexer
    Indexer indexer = IndexerRegistryUtil.getIndexer(Books.class);
    indexer.reindex(book);
    return book;
  }
コード例 #3
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;
    }
  }
  @Override
  public AnonymousUser updateAnonymousUser(
      long anonymousUserId,
      long userId,
      String lastIp,
      String typeSettings,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    Date now = new Date();

    AnonymousUser anonymousUser = anonymousUserPersistence.findByPrimaryKey(anonymousUserId);

    User user = UserLocalServiceUtil.fetchUser(userId);

    if (user != null) {
      anonymousUser.setUserId(user.getUserId());
      anonymousUser.setUserName(user.getFullName());
    }

    anonymousUser.setModifiedDate(serviceContext.getModifiedDate(now));
    anonymousUser.setLastIp(lastIp);
    anonymousUser.setTypeSettings(typeSettings);

    anonymousUserPersistence.update(anonymousUser);

    return anonymousUser;
  }
  @Override
  public AssetEntry getAssetEntry(String className, long classPK)
      throws PortalException, SystemException {

    LayoutRevision layoutRevision = LayoutRevisionLocalServiceUtil.getLayoutRevision(classPK);

    LayoutSetBranch layoutSetBranch =
        LayoutSetBranchLocalServiceUtil.getLayoutSetBranch(layoutRevision.getLayoutSetBranchId());

    User user = UserLocalServiceUtil.getUserById(layoutRevision.getUserId());

    AssetEntry assetEntry = AssetEntryLocalServiceUtil.createAssetEntry(classPK);

    assetEntry.setGroupId(layoutRevision.getGroupId());
    assetEntry.setCompanyId(user.getCompanyId());
    assetEntry.setUserId(user.getUserId());
    assetEntry.setUserName(user.getFullName());
    assetEntry.setCreateDate(layoutRevision.getCreateDate());
    assetEntry.setClassNameId(PortalUtil.getClassNameId(LayoutRevision.class.getName()));
    assetEntry.setClassPK(layoutRevision.getLayoutRevisionId());

    StringBundler sb = new StringBundler(4);

    sb.append(layoutRevision.getHTMLTitle(LocaleUtil.getSiteDefault()));
    sb.append(" [");
    sb.append(layoutSetBranch.getName());
    sb.append("]");

    assetEntry.setTitle(sb.toString());

    return assetEntry;
  }
  public KaleoTaskInstanceToken addKaleoTaskInstanceToken(
      long kaleoInstanceTokenId,
      long kaleoTaskId,
      String kaleoTaskName,
      Collection<KaleoTaskAssignment> kaleoTaskAssignments,
      Date dueDate,
      Map<String, Serializable> workflowContext,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    KaleoInstanceToken kaleoInstanceToken =
        kaleoInstanceTokenPersistence.findByPrimaryKey(kaleoInstanceTokenId);

    User user = userPersistence.findByPrimaryKey(serviceContext.getGuestOrUserId());
    Date now = new Date();

    long kaleoTaskInstanceTokenId = counterLocalService.increment();

    KaleoTaskInstanceToken kaleoTaskInstanceToken =
        kaleoTaskInstanceTokenPersistence.create(kaleoTaskInstanceTokenId);

    long groupId = StagingUtil.getLiveGroupId(serviceContext.getScopeGroupId());

    kaleoTaskInstanceToken.setGroupId(groupId);

    kaleoTaskInstanceToken.setCompanyId(user.getCompanyId());
    kaleoTaskInstanceToken.setUserId(user.getUserId());
    kaleoTaskInstanceToken.setUserName(user.getFullName());
    kaleoTaskInstanceToken.setCreateDate(now);
    kaleoTaskInstanceToken.setModifiedDate(now);
    kaleoTaskInstanceToken.setDueDate(dueDate);
    kaleoTaskInstanceToken.setKaleoDefinitionId(kaleoInstanceToken.getKaleoDefinitionId());
    kaleoTaskInstanceToken.setKaleoInstanceId(kaleoInstanceToken.getKaleoInstanceId());
    kaleoTaskInstanceToken.setKaleoInstanceTokenId(kaleoInstanceTokenId);

    kaleoTaskInstanceToken.setKaleoTaskId(kaleoTaskId);
    kaleoTaskInstanceToken.setKaleoTaskName(kaleoTaskName);

    if (workflowContext != null) {
      kaleoTaskInstanceToken.setClassName(
          (String) workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME));

      if (workflowContext.containsKey(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK)) {

        kaleoTaskInstanceToken.setClassPK(
            GetterUtil.getLong(
                (String) workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK)));
      }
    }

    kaleoTaskInstanceToken.setCompleted(false);
    kaleoTaskInstanceToken.setWorkflowContext(WorkflowContextUtil.convert(workflowContext));

    kaleoTaskInstanceTokenPersistence.update(kaleoTaskInstanceToken, false);

    kaleoTaskAssignmentInstanceLocalService.addTaskAssignmentInstances(
        kaleoTaskInstanceToken, kaleoTaskAssignments, workflowContext, serviceContext);

    return kaleoTaskInstanceToken;
  }
コード例 #7
0
 public NotificationRecipient(User user) {
   _companyId = user.getCompanyId();
   _emailAddress = user.getEmailAddress();
   _fullName = user.getFullName();
   _screenName = user.getScreenName();
   _userId = user.getUserId();
 }
コード例 #8
0
  @Override
  public MDRRuleGroup addRuleGroup(
      long groupId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(serviceContext.getUserId());
    Date now = new Date();

    long ruleGroupId = counterLocalService.increment();

    MDRRuleGroup ruleGroup = createMDRRuleGroup(ruleGroupId);

    ruleGroup.setUuid(serviceContext.getUuid());
    ruleGroup.setGroupId(groupId);
    ruleGroup.setCompanyId(serviceContext.getCompanyId());
    ruleGroup.setCreateDate(serviceContext.getCreateDate(now));
    ruleGroup.setModifiedDate(serviceContext.getModifiedDate(now));
    ruleGroup.setUserId(user.getUserId());
    ruleGroup.setUserName(user.getFullName());
    ruleGroup.setNameMap(nameMap);
    ruleGroup.setDescriptionMap(descriptionMap);

    return updateMDRRuleGroup(ruleGroup);
  }
コード例 #9
0
  public KaleoTaskAssignment addKaleoTaskAssignment(
      String kaleoClassName,
      long kaleoClassPK,
      long kaleoDefinitionId,
      Assignment assignment,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(serviceContext.getGuestOrUserId());
    Date now = new Date();

    long kaleoTaskAssignmentId = counterLocalService.increment();

    KaleoTaskAssignment kaleoTaskAssignment =
        kaleoTaskAssignmentPersistence.create(kaleoTaskAssignmentId);

    kaleoTaskAssignment.setCompanyId(user.getCompanyId());
    kaleoTaskAssignment.setUserId(user.getUserId());
    kaleoTaskAssignment.setUserName(user.getFullName());
    kaleoTaskAssignment.setCreateDate(now);
    kaleoTaskAssignment.setModifiedDate(now);
    kaleoTaskAssignment.setKaleoClassName(kaleoClassName);
    kaleoTaskAssignment.setKaleoClassPK(kaleoClassPK);
    kaleoTaskAssignment.setKaleoDefinitionId(kaleoDefinitionId);
    setAssignee(kaleoTaskAssignment, assignment, serviceContext);

    kaleoTaskAssignmentPersistence.update(kaleoTaskAssignment);

    return kaleoTaskAssignment;
  }
コード例 #10
0
  protected void addComment(ClassedModel classedModel, String body, ServiceContext serviceContext)
      throws Exception {

    User user = TestPropsValues.getUser();

    List<MBMessage> messages =
        MBMessageLocalServiceUtil.getMessages(
            getBaseModelClassName(),
            getBaseModelClassPK(classedModel),
            WorkflowConstants.STATUS_ANY);

    MBMessage message = messages.get(0);

    MBMessageLocalServiceUtil.addDiscussionMessage(
        user.getUserId(),
        user.getFullName(),
        serviceContext.getScopeGroupId(),
        getBaseModelClassName(),
        getBaseModelClassPK(classedModel),
        message.getThreadId(),
        message.getMessageId(),
        message.getSubject(),
        body,
        serviceContext);
  }
  @Override
  public AnonymousUser addAnonymousUser(
      long userId, String lastIp, String typeSettings, ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = UserLocalServiceUtil.fetchUser(userId);

    Date now = new Date();

    long anonymousUserId = CounterLocalServiceUtil.increment();

    AnonymousUser anonymousUser = anonymousUserPersistence.create(anonymousUserId);

    anonymousUser.setCompanyId(serviceContext.getCompanyId());

    if (user != null) {
      anonymousUser.setUserId(user.getUserId());
      anonymousUser.setUserName(user.getFullName());
    }

    anonymousUser.setCreateDate(serviceContext.getCreateDate(now));
    anonymousUser.setModifiedDate(serviceContext.getModifiedDate(now));
    anonymousUser.setLastIp(lastIp);
    anonymousUser.setTypeSettings(typeSettings);

    anonymousUserPersistence.update(anonymousUser);

    return anonymousUser;
  }
コード例 #12
0
  @Override
  public PollsChoice addChoice(
      long userId, long questionId, String name, String description, ServiceContext serviceContext)
      throws PortalException {

    validate(name, description);

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    long choiceId = counterLocalService.increment();

    PollsChoice choice = pollsChoicePersistence.create(choiceId);

    choice.setUuid(serviceContext.getUuid());
    choice.setGroupId(serviceContext.getScopeGroupId());
    choice.setCompanyId(user.getCompanyId());
    choice.setUserId(user.getUserId());
    choice.setUserName(user.getFullName());
    choice.setCreateDate(serviceContext.getCreateDate(now));
    choice.setModifiedDate(serviceContext.getModifiedDate(now));
    choice.setQuestionId(questionId);
    choice.setName(name);
    choice.setDescription(description);

    pollsChoicePersistence.update(choice);

    return choice;
  }
コード例 #13
0
  public Entry addEntry(long userId, String fullName, String emailAddress, String comments)
      throws PortalException {

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    validate(0, userId, fullName, emailAddress);

    long contactId = counterLocalService.increment();

    Entry entry = entryPersistence.create(contactId);

    entry.setCompanyId(user.getCompanyId());
    entry.setUserId(user.getUserId());
    entry.setUserName(user.getFullName());
    entry.setCreateDate(now);
    entry.setModifiedDate(now);
    entry.setFullName(fullName);
    entry.setEmailAddress(emailAddress);
    entry.setComments(comments);

    entryPersistence.update(entry);

    return entry;
  }
コード例 #14
0
  public Website addWebsite(
      long userId, String className, long classPK, String url, int typeId, boolean primary)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(userId);
    long classNameId = PortalUtil.getClassNameId(className);
    Date now = new Date();

    validate(0, user.getCompanyId(), classNameId, classPK, url, typeId, primary);

    long websiteId = counterLocalService.increment();

    Website website = websitePersistence.create(websiteId);

    website.setCompanyId(user.getCompanyId());
    website.setUserId(user.getUserId());
    website.setUserName(user.getFullName());
    website.setCreateDate(now);
    website.setModifiedDate(now);
    website.setClassNameId(classNameId);
    website.setClassPK(classPK);
    website.setUrl(url);
    website.setTypeId(typeId);
    website.setPrimary(primary);

    websitePersistence.update(website);

    return website;
  }
コード例 #15
0
  protected String getUserCSV(User user) {
    StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2);

    for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) {
      String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i];

      if (field.equals("fullName")) {
        sb.append(CSVUtil.encode(user.getFullName()));
      } else if (field.startsWith("expando:")) {
        String attributeName = field.substring(8);

        ExpandoBridge expandoBridge = user.getExpandoBridge();

        sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName)));
      } else {
        sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field)));
      }

      if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) {
        sb.append(StringPool.COMMA);
      }
    }

    sb.append(StringPool.NEW_LINE);

    return sb.toString();
  }
コード例 #16
0
  public DLFileShortcut addFileShortcut(
      String uuid,
      long userId,
      long folderId,
      long toFolderId,
      String toName,
      Boolean addCommunityPermissions,
      Boolean addGuestPermissions,
      String[] communityPermissions,
      String[] guestPermissions)
      throws PortalException, SystemException {

    // File shortcut

    User user = userPersistence.findByPrimaryKey(userId);
    folderId = getFolderId(user.getCompanyId(), folderId);
    DLFolder folder = dlFolderPersistence.findByPrimaryKey(folderId);
    Date now = new Date();

    validate(user, toFolderId, toName);

    long fileShortcutId = counterLocalService.increment();

    DLFileShortcut fileShortcut = dlFileShortcutPersistence.create(fileShortcutId);

    fileShortcut.setUuid(uuid);
    fileShortcut.setCompanyId(user.getCompanyId());
    fileShortcut.setUserId(user.getUserId());
    fileShortcut.setUserName(user.getFullName());
    fileShortcut.setCreateDate(now);
    fileShortcut.setModifiedDate(now);
    fileShortcut.setFolderId(folderId);
    fileShortcut.setToFolderId(toFolderId);
    fileShortcut.setToName(toName);

    dlFileShortcutPersistence.update(fileShortcut);

    // Resources

    if ((addCommunityPermissions != null) && (addGuestPermissions != null)) {

      addFileShortcutResources(
          folder,
          fileShortcut,
          addCommunityPermissions.booleanValue(),
          addGuestPermissions.booleanValue());
    } else {
      addFileShortcutResources(folder, fileShortcut, communityPermissions, guestPermissions);
    }

    // Folder

    folder.setLastPostDate(fileShortcut.getModifiedDate());

    dlFolderPersistence.update(folder);

    return fileShortcut;
  }
コード例 #17
0
  @Override
  public KBComment addKBComment(
      long userId,
      long classNameId,
      long classPK,
      String content,
      boolean helpful,
      ServiceContext serviceContext)
      throws PortalException {

    // KB comment

    User user = userPersistence.findByPrimaryKey(userId);
    long groupId = serviceContext.getScopeGroupId();
    Date now = new Date();

    validate(content);

    long kbCommentId = counterLocalService.increment();

    KBComment kbComment = kbCommentPersistence.create(kbCommentId);

    kbComment.setUuid(serviceContext.getUuid());
    kbComment.setGroupId(groupId);
    kbComment.setCompanyId(user.getCompanyId());
    kbComment.setUserId(user.getUserId());
    kbComment.setUserName(user.getFullName());
    kbComment.setCreateDate(serviceContext.getCreateDate(now));
    kbComment.setModifiedDate(serviceContext.getModifiedDate(now));
    kbComment.setClassNameId(classNameId);
    kbComment.setClassPK(classPK);
    kbComment.setContent(content);
    kbComment.setHelpful(helpful);
    kbComment.setStatus(KBCommentConstants.STATUS_NEW);

    kbCommentPersistence.update(kbComment);

    // Social

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    putTitle(extraDataJSONObject, kbComment);

    socialActivityLocalService.addActivity(
        userId,
        kbComment.getGroupId(),
        KBComment.class.getName(),
        kbCommentId,
        AdminActivityKeys.ADD_KB_COMMENT,
        extraDataJSONObject.toString(),
        0);

    // Subscriptions

    notifySubscribers(kbComment, serviceContext);

    return kbComment;
  }
コード例 #18
0
  public String getUserName() {
    User user = getUser(_document.getCreatedBy());

    if (user == null) {
      return StringPool.BLANK;
    } else {
      return user.getFullName();
    }
  }
コード例 #19
0
  public ProjectsEntry addProjectsEntry(
      long userId,
      String title,
      String description,
      int startDateMonth,
      int startDateDay,
      int startDateYear,
      int endDateMonth,
      int endDateDay,
      int endDateYear,
      boolean current,
      String data)
      throws PortalException, SystemException {

    User user = userLocalService.getUserById(userId);

    Date startDate =
        PortalUtil.getDate(
            startDateMonth,
            startDateDay,
            startDateYear,
            user.getTimeZone(),
            new ProjectsEntryStartDateException());

    Date endDate = null;

    if (!current) {
      endDate =
          PortalUtil.getDate(
              endDateMonth,
              endDateDay,
              endDateYear,
              user.getTimeZone(),
              new ProjectsEntryEndDateException());
    }

    Date now = new Date();

    long projectsEntryId = counterLocalService.increment();

    ProjectsEntry projectsEntry = projectsEntryPersistence.create(projectsEntryId);

    projectsEntry.setCompanyId(user.getCompanyId());
    projectsEntry.setUserId(user.getUserId());
    projectsEntry.setUserName(user.getFullName());
    projectsEntry.setCreateDate(now);
    projectsEntry.setModifiedDate(now);
    projectsEntry.setTitle(title);
    projectsEntry.setDescription(description);
    projectsEntry.setStartDate(startDate);
    projectsEntry.setEndDate(endDate);
    projectsEntry.setData(data);

    projectsEntryPersistence.update(projectsEntry, false);

    return projectsEntry;
  }
コード例 #20
0
 public MemberResponseElement(User user, boolean member) {
   _id = user.getScreenName();
   _name = user.getFullName();
   _loginName = user.getScreenName();
   _email = user.getEmailAddress();
   _domainGroup = false;
   _member = member;
   _siteAdmin = false;
 }
コード例 #21
0
  /**
   * Create a work flow task for the new content created and send a email to the corresponding role
   * moderator users
   *
   * @param contentlet The content
   * @param user The user that add the content
   * @param moderatorRole The role to assign the work flow
   * @throws DotDataException
   * @throws DotDataException
   */
  public static void createWorkFlowTask(Contentlet contentlet, String userId, String moderatorRole)
      throws DotDataException {

    User user = getUserFromId(userId);
    StringBuffer changeHist = new StringBuffer("Task Added<br>");
    WorkflowTask task = new WorkflowTask();

    changeHist.append("Title: " + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle()) + "<br>");
    task.setTitle(
        "A new content titled: "
            + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle())
            + " has been posted.");
    task.setDescription(
        "A new content titled \""
            + UtilHTML.escapeHTMLSpecialChars(contentlet.getTitle().trim())
            + "\" has been posted by "
            + UtilHTML.escapeHTMLSpecialChars(user.getFullName())
            + " ("
            + user.getEmailAddress()
            + ")");
    changeHist.append(
        "Description: " + UtilHTML.escapeHTMLSpecialChars(task.getDescription()) + "<br>");

    Role role = roleAPI.loadRoleByKey(moderatorRole);
    task.setBelongsTo(role.getId());
    task.setAssignedTo("Nobody");
    task.setModDate(new Date());
    task.setCreationDate(new Date());
    task.setCreatedBy(user.getUserId());

    task.setStatus(WorkflowStatuses.OPEN.toString());
    changeHist.append("Due Date: " + UtilMethods.dateToHTMLDate(task.getDueDate()) + " -> <br>");
    task.setDueDate(null);
    task.setWebasset(contentlet.getInode());

    // HibernateUtil.saveOrUpdate(task);

    // Save the work flow comment
    WorkflowComment taskComment = new WorkflowComment();
    taskComment.setComment(task.getDescription());
    taskComment.setCreationDate(new Date());
    taskComment.setPostedBy(user.getUserId());
    HibernateUtil.saveOrUpdate(taskComment);
    relAPI.addRelationship(task.getInode(), taskComment.getInode(), "child");

    // Save the work flow history
    WorkflowHistory hist = new WorkflowHistory();
    hist.setChangeDescription("Task Creation");
    hist.setCreationDate(new Date());
    hist.setMadeBy(user.getUserId());
    HibernateUtil.saveOrUpdate(hist);
    relAPI.addRelationship(task.getInode(), hist.getInode(), "child");

    // WorkflowEmailUtil.sendWorkflowChangeEmails (task, "New user content has been submitted", "New
    // Task", null);

  }
コード例 #22
0
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public AssetVocabulary addVocabulary(
      long userId,
      long groupId,
      String title,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String settings,
      ServiceContext serviceContext)
      throws PortalException {

    // Vocabulary

    User user = userPersistence.findByPrimaryKey(userId);
    String name = titleMap.get(LocaleUtil.getSiteDefault());

    validate(groupId, name);

    long vocabularyId = counterLocalService.increment();

    AssetVocabulary vocabulary = assetVocabularyPersistence.create(vocabularyId);

    vocabulary.setUuid(serviceContext.getUuid());
    vocabulary.setGroupId(groupId);
    vocabulary.setCompanyId(user.getCompanyId());
    vocabulary.setUserId(user.getUserId());
    vocabulary.setUserName(user.getFullName());
    vocabulary.setName(name);

    if (Validator.isNotNull(title)) {
      vocabulary.setTitle(title);
    } else {
      vocabulary.setTitleMap(titleMap);
    }

    vocabulary.setDescriptionMap(descriptionMap);
    vocabulary.setSettings(settings);

    assetVocabularyPersistence.update(vocabulary);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

      addVocabularyResources(
          vocabulary,
          serviceContext.isAddGroupPermissions(),
          serviceContext.isAddGuestPermissions());
    } else {
      addVocabularyResources(
          vocabulary, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }

    return vocabulary;
  }
コード例 #23
0
  public PollsVote addVote(
      long userId, long questionId, long choiceId, ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Choice

    Date now = new Date();

    PollsChoice choice = pollsChoicePersistence.findByPrimaryKey(choiceId);

    if (choice.getQuestionId() != questionId) {
      throw new NoSuchQuestionException();
    }

    // Question

    PollsQuestion question = pollsQuestionPersistence.findByPrimaryKey(questionId);

    if (question.isExpired(serviceContext, now)) {
      throw new QuestionExpiredException();
    }

    question.setLastVoteDate(serviceContext.getCreateDate(now));

    pollsQuestionPersistence.update(question, false);

    // Vote

    PollsVote vote = pollsVotePersistence.fetchByQ_U(questionId, userId);

    if (vote != null) {
      throw new DuplicateVoteException();
    } else {
      User user = userPersistence.findByPrimaryKey(userId);

      long voteId = counterLocalService.increment();

      vote = pollsVotePersistence.create(voteId);

      vote.setCompanyId(user.getCompanyId());
      vote.setUserId(user.getUserId());
      vote.setUserName(user.getFullName());
      vote.setCreateDate(serviceContext.getCreateDate(now));
      vote.setModifiedDate(serviceContext.getModifiedDate(now));
      vote.setQuestionId(questionId);
      vote.setChoiceId(choiceId);
      vote.setVoteDate(serviceContext.getCreateDate(now));

      pollsVotePersistence.update(vote, false);
    }

    return vote;
  }
コード例 #24
0
  public Message addMessage(
      long userId,
      long folderId,
      String sender,
      String to,
      String cc,
      String bcc,
      Date sentDate,
      String subject,
      String body,
      String flags,
      long remoteMessageId)
      throws PortalException, SystemException {

    // Message

    User user = userPersistence.findByPrimaryKey(userId);
    Folder folder = folderPersistence.findByPrimaryKey(folderId);
    Date now = new Date();

    long messageId = counterLocalService.increment();

    Message message = messagePersistence.create(messageId);

    message.setCompanyId(user.getCompanyId());
    message.setUserId(user.getUserId());
    message.setUserName(user.getFullName());
    message.setCreateDate(now);
    message.setModifiedDate(now);
    message.setAccountId(folder.getAccountId());
    message.setFolderId(folderId);
    message.setSender(sender);
    message.setTo(to);
    message.setCc(cc);
    message.setBcc(bcc);
    message.setSentDate(sentDate);
    message.setSubject(subject);
    message.setPreview(getPreview(body));
    message.setBody(getBody(body));
    message.setFlags(flags);
    message.setSize(getSize(messageId, body));
    message.setRemoteMessageId(remoteMessageId);

    messagePersistence.update(message, false);

    // Indexer

    Indexer indexer = IndexerRegistryUtil.getIndexer(Message.class);

    indexer.reindex(message);

    return message;
  }
コード例 #25
0
  @Override
  public MicroblogsEntry addMicroblogsEntry(
      long userId,
      long creatorClassNameId,
      long creatorClassPK,
      String content,
      int type,
      long parentMicroblogsEntryId,
      int socialRelationType,
      ServiceContext serviceContext)
      throws PortalException {

    // Microblogs entry

    User user = userPersistence.findByPrimaryKey(userId);

    Date now = new Date();

    validate(type, parentMicroblogsEntryId);

    long microblogsEntryId = counterLocalService.increment();

    if (parentMicroblogsEntryId == 0) {
      parentMicroblogsEntryId = microblogsEntryId;
    }

    MicroblogsEntry microblogsEntry = microblogsEntryPersistence.create(microblogsEntryId);

    microblogsEntry.setCompanyId(user.getCompanyId());
    microblogsEntry.setUserId(user.getUserId());
    microblogsEntry.setUserName(user.getFullName());
    microblogsEntry.setCreateDate(now);
    microblogsEntry.setModifiedDate(now);
    microblogsEntry.setCreatorClassNameId(creatorClassNameId);
    microblogsEntry.setCreatorClassPK(creatorClassPK);
    microblogsEntry.setContent(content);
    microblogsEntry.setType(type);
    microblogsEntry.setParentMicroblogsEntryId(parentMicroblogsEntryId);
    microblogsEntry.setSocialRelationType(socialRelationType);

    microblogsEntryPersistence.update(microblogsEntry);

    // Resources

    resourceLocalService.addModelResources(microblogsEntry, serviceContext);

    // Asset

    updateAsset(
        microblogsEntry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());

    return microblogsEntry;
  }
コード例 #26
0
  public JournalStructure copyStructure(
      long userId,
      long groupId,
      String oldStructureId,
      String newStructureId,
      boolean autoStructureId)
      throws PortalException, SystemException {

    // Structure

    User user = userPersistence.findByPrimaryKey(userId);
    oldStructureId = oldStructureId.trim().toUpperCase();
    newStructureId = newStructureId.trim().toUpperCase();
    Date now = new Date();

    JournalStructure oldStructure = journalStructurePersistence.findByG_S(groupId, oldStructureId);

    if (autoStructureId) {
      newStructureId = String.valueOf(counterLocalService.increment());
    } else {
      validateStructureId(newStructureId);

      JournalStructure newStructure =
          journalStructurePersistence.fetchByG_S(groupId, newStructureId);

      if (newStructure != null) {
        throw new DuplicateStructureIdException();
      }
    }

    long id = counterLocalService.increment();

    JournalStructure newStructure = journalStructurePersistence.create(id);

    newStructure.setGroupId(groupId);
    newStructure.setCompanyId(user.getCompanyId());
    newStructure.setUserId(user.getUserId());
    newStructure.setUserName(user.getFullName());
    newStructure.setCreateDate(now);
    newStructure.setModifiedDate(now);
    newStructure.setStructureId(newStructureId);
    newStructure.setName(oldStructure.getName());
    newStructure.setDescription(oldStructure.getDescription());
    newStructure.setXsd(oldStructure.getXsd());

    journalStructurePersistence.update(newStructure, false);

    // Resources

    addStructureResources(newStructure, true, true);

    return newStructure;
  }
コード例 #27
0
  public void updateUserName(User user) {
    String userName = user.getFullName();

    List<UserThread> userThreads = userThreadPersistence.findByUserId(user.getUserId());

    for (UserThread userThread : userThreads) {
      if (!userName.equals(userThread.getUserName())) {
        userThread.setUserName(userName);

        userThreadPersistence.update(userThread);
      }
    }
  }
コード例 #28
0
  public MBCategory addCategory(
      String uuid,
      long userId,
      long plid,
      long parentCategoryId,
      String name,
      String description,
      Boolean addCommunityPermissions,
      Boolean addGuestPermissions,
      String[] communityPermissions,
      String[] guestPermissions)
      throws PortalException, SystemException {

    // Category

    User user = userPersistence.findByPrimaryKey(userId);
    long groupId = PortalUtil.getPortletGroupId(plid);
    parentCategoryId = getParentCategoryId(groupId, parentCategoryId);
    Date now = new Date();

    validate(name);

    long categoryId = counterLocalService.increment();

    MBCategory category = mbCategoryPersistence.create(categoryId);

    category.setUuid(uuid);
    category.setGroupId(groupId);
    category.setCompanyId(user.getCompanyId());
    category.setUserId(user.getUserId());
    category.setUserName(user.getFullName());
    category.setCreateDate(now);
    category.setModifiedDate(now);
    category.setParentCategoryId(parentCategoryId);
    category.setName(name);
    category.setDescription(description);

    mbCategoryPersistence.update(category);

    // Resources

    if ((addCommunityPermissions != null) && (addGuestPermissions != null)) {

      addCategoryResources(
          category, addCommunityPermissions.booleanValue(), addGuestPermissions.booleanValue());
    } else {
      addCategoryResources(category, communityPermissions, guestPermissions);
    }

    return category;
  }
コード例 #29
0
  @Override
  public BackgroundTask addBackgroundTask(
      long userId,
      long groupId,
      String name,
      String[] servletContextNames,
      Class<?> taskExecutorClass,
      Map<String, Serializable> taskContextMap,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    final long backgroundTaskId = counterLocalService.increment();

    BackgroundTask backgroundTask = backgroundTaskPersistence.create(backgroundTaskId);

    backgroundTask.setCompanyId(user.getCompanyId());
    backgroundTask.setCreateDate(serviceContext.getCreateDate(now));
    backgroundTask.setGroupId(groupId);
    backgroundTask.setModifiedDate(serviceContext.getModifiedDate(now));
    backgroundTask.setUserId(userId);
    backgroundTask.setUserName(user.getFullName());
    backgroundTask.setName(name);
    backgroundTask.setServletContextNames(StringUtil.merge(servletContextNames));
    backgroundTask.setTaskExecutorClassName(taskExecutorClass.getName());

    if (taskContextMap != null) {
      String taskContext = JSONFactoryUtil.serialize(taskContextMap);

      backgroundTask.setTaskContext(taskContext);
    }

    backgroundTask.setStatus(BackgroundTaskConstants.STATUS_NEW);

    backgroundTaskPersistence.update(backgroundTask);

    TransactionCommitCallbackRegistryUtil.registerCallback(
        new Callable<Void>() {

          @Override
          public Void call() throws Exception {
            backgroundTaskLocalService.triggerBackgroundTask(backgroundTaskId);

            return null;
          }
        });

    return backgroundTask;
  }
コード例 #30
0
  @Override
  public KBTemplate addKBTemplate(
      long userId, String title, String content, ServiceContext serviceContext)
      throws PortalException {

    // KB template

    User user = userPersistence.findByPrimaryKey(userId);
    long groupId = serviceContext.getScopeGroupId();
    Date now = new Date();

    validate(title, content);

    long kbTemplateId = counterLocalService.increment();

    KBTemplate kbTemplate = kbTemplatePersistence.create(kbTemplateId);

    kbTemplate.setUuid(serviceContext.getUuid());
    kbTemplate.setGroupId(groupId);
    kbTemplate.setCompanyId(user.getCompanyId());
    kbTemplate.setUserId(user.getUserId());
    kbTemplate.setUserName(user.getFullName());
    kbTemplate.setCreateDate(serviceContext.getCreateDate(now));
    kbTemplate.setModifiedDate(serviceContext.getModifiedDate(now));
    kbTemplate.setTitle(title);
    kbTemplate.setContent(content);

    kbTemplatePersistence.update(kbTemplate);

    // Resources

    resourceLocalService.addModelResources(kbTemplate, serviceContext);

    // Social

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("title", kbTemplate.getTitle());

    socialActivityLocalService.addActivity(
        userId,
        groupId,
        KBTemplate.class.getName(),
        kbTemplateId,
        AdminActivityKeys.ADD_KB_TEMPLATE,
        extraDataJSONObject.toString(),
        0);

    return kbTemplate;
  }