Beispiel #1
0
  @Override
  public boolean isSubscribedToFolder(
      long companyId, long groupId, long userId, long folderId, boolean recursive)
      throws PortalException, SystemException {

    List<Long> ancestorFolderIds = new ArrayList<Long>();

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      Folder folder = DLAppLocalServiceUtil.getFolder(folderId);

      if (recursive) {
        ancestorFolderIds = folder.getAncestorFolderIds();

        ancestorFolderIds.add(groupId);
      }

      ancestorFolderIds.add(0, folderId);
    } else {
      ancestorFolderIds.add(groupId);
    }

    long[] folderIdsArray = ArrayUtil.toLongArray(ancestorFolderIds);

    return SubscriptionLocalServiceUtil.isSubscribed(
        companyId, userId, Folder.class.getName(), folderIdsArray);
  }
  @Override
  protected void doReindexDDMStructures(List<Long> ddmStructureIds) throws Exception {

    List<DLFileEntry> dlFileEntries =
        DLFileEntryLocalServiceUtil.getDDMStructureFileEntries(
            ArrayUtil.toLongArray(ddmStructureIds));

    for (DLFileEntry dlFileEntry : dlFileEntries) {
      doReindex(dlFileEntry);
    }
  }
Beispiel #3
0
  protected long[] getAncestorOrganizationIds(long[] organizationIds) throws Exception {

    Set<Long> ancestorOrganizationIds = new HashSet<>();

    for (long organizationId : organizationIds) {
      Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId);

      for (long ancestorOrganizationId : organization.getAncestorOrganizationIds()) {

        ancestorOrganizationIds.add(ancestorOrganizationId);
      }
    }

    return ArrayUtil.toLongArray(ancestorOrganizationIds);
  }
  @Override
  public void postProcessDocument(Document document, Object obj) throws Exception {

    User user = (User) obj;

    List<ProjectsEntry> projectsEntries =
        ProjectsEntryLocalServiceUtil.getUserProjectsEntries(user.getUserId());

    String[] projectTitles = new String[projectsEntries.size()];

    for (int i = 0; i < projectTitles.length; i++) {
      ProjectsEntry projectEntry = projectsEntries.get(i);

      projectTitles[i] = StringUtil.toLowerCase(projectEntry.getTitle());
    }

    document.addKeyword("projectTitles", projectTitles);

    int count =
        UserLocalServiceUtil.getSocialUsersCount(
            user.getUserId(), SocialRelationConstants.TYPE_BI_CONNECTION, StringPool.EQUAL);

    List<Long> socialRelationshipUserIds = new ArrayList<>();

    int pages = count / Indexer.DEFAULT_INTERVAL;

    for (int i = 0; i <= pages; i++) {
      int start = (i * Indexer.DEFAULT_INTERVAL);
      int end = start + Indexer.DEFAULT_INTERVAL;

      List<User> socialRelationshipUsers =
          UserLocalServiceUtil.getSocialUsers(
              user.getUserId(),
              SocialRelationConstants.TYPE_BI_CONNECTION,
              StringPool.EQUAL,
              start,
              end,
              new UserFirstNameComparator(true));

      for (User socialRelationshipUser : socialRelationshipUsers) {
        socialRelationshipUserIds.add(socialRelationshipUser.getUserId());
      }
    }

    document.addKeyword("socialRelationships", ArrayUtil.toLongArray(socialRelationshipUserIds));
  }
  @Override
  public void reindexDDMStructures(List<Long> ddmStructureIds) throws SearchException {

    if (SearchEngineUtil.isIndexReadOnly() || !isIndexerEnabled()) {
      return;
    }

    try {
      List<DLFileEntry> dlFileEntries =
          DLFileEntryLocalServiceUtil.getDDMStructureFileEntries(
              ArrayUtil.toLongArray(ddmStructureIds));

      for (DLFileEntry dlFileEntry : dlFileEntries) {
        doReindex(dlFileEntry);
      }
    } catch (Exception e) {
      throw new SearchException(e);
    }
  }
  @Override
  public void reindexDDMStructures(List<Long> ddmStructureIds) throws SearchException {

    if (IndexWriterHelperUtil.isIndexReadOnly() || !isIndexerEnabled()) {
      return;
    }

    try {
      Indexer<DLFileEntry> indexer = IndexerRegistryUtil.nullSafeGetIndexer(DLFileEntry.class);

      List<DLFileEntry> dlFileEntries =
          DLFileEntryLocalServiceUtil.getDDMStructureFileEntries(
              ArrayUtil.toLongArray(ddmStructureIds));

      for (DLFileEntry dlFileEntry : dlFileEntries) {
        indexer.reindex(dlFileEntry);
      }
    } catch (Exception e) {
      throw new SearchException(e);
    }
  }
  @Override
  public long[] getPooledActorsIds(long companyId, long workflowTaskInstanceId)
      throws WorkflowException {

    try {
      KaleoTaskInstanceToken kaleoTaskInstanceToken =
          KaleoTaskInstanceTokenLocalServiceUtil.getKaleoTaskInstanceToken(workflowTaskInstanceId);

      List<KaleoTaskAssignment> calculatedKaleoTaskAssignments =
          getCalculatedKaleoTaskAssignments(kaleoTaskInstanceToken);

      Map<String, Long> pooledActors = new TreeMap<>(new NaturalOrderStringComparator());

      for (KaleoTaskAssignment calculatedKaleoTaskAssignment : calculatedKaleoTaskAssignments) {

        String assigneeClassName = calculatedKaleoTaskAssignment.getAssigneeClassName();
        long assigneeClassPK = calculatedKaleoTaskAssignment.getAssigneeClassPK();

        if (assigneeClassName.equals(User.class.getName())) {
          User user = UserLocalServiceUtil.fetchUser(assigneeClassPK);

          if (user != null) {
            pooledActors.put(user.getFullName(), user.getUserId());
          }

          continue;
        }

        Role role =
            RoleLocalServiceUtil.getRole(calculatedKaleoTaskAssignment.getAssigneeClassPK());

        if ((role.getType() == RoleConstants.TYPE_SITE)
            || (role.getType() == RoleConstants.TYPE_ORGANIZATION)) {

          List<UserGroupRole> userGroupRoles =
              UserGroupRoleLocalServiceUtil.getUserGroupRolesByGroupAndRole(
                  kaleoTaskInstanceToken.getGroupId(), assigneeClassPK);

          for (UserGroupRole userGroupRole : userGroupRoles) {
            User user = userGroupRole.getUser();

            pooledActors.put(user.getFullName(), user.getUserId());
          }

          List<UserGroupGroupRole> userGroupGroupRoles =
              UserGroupGroupRoleLocalServiceUtil.getUserGroupGroupRolesByGroupAndRole(
                  kaleoTaskInstanceToken.getGroupId(), assigneeClassPK);

          for (UserGroupGroupRole userGroupGroupRole : userGroupGroupRoles) {

            List<User> userGroupUsers =
                UserLocalServiceUtil.getUserGroupUsers(userGroupGroupRole.getUserGroupId());

            for (User user : userGroupUsers) {
              pooledActors.put(user.getFullName(), user.getUserId());
            }
          }
        } else {
          List<User> inheritedRoleUsers =
              UserLocalServiceUtil.getInheritedRoleUsers(
                  assigneeClassPK, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

          for (User user : inheritedRoleUsers) {
            pooledActors.put(user.getFullName(), user.getUserId());
          }
        }
      }

      return ArrayUtil.toLongArray(pooledActors.values());
    } catch (Exception e) {
      throw new WorkflowException(e);
    }
  }