public List<DocumentModel> getGroupsSuggestions(Object input) { try { Map<String, DocumentModel> uniqueGroups = new HashMap<String, DocumentModel>(); String pattern = (String) input; for (String field : userManager.getGroupSearchFields()) { // XXX: this doesn't fetch group members (references) Map<String, Serializable> filter = new HashMap<String, Serializable>(); if (StringUtils.isNotEmpty(pattern)) { filter.put(field, pattern); } if (Boolean.TRUE.equals(hideVirtualGroups)) { filter.put(UserManagerWithComputedGroups.VIRTUAL_GROUP_MARKER, false); } for (DocumentModel group : userManager.searchGroups(filter, filter.keySet())) { uniqueGroups.put(group.getId(), group); } } DocumentModelList groups = new DocumentModelListImpl(); groups.addAll(uniqueGroups.values()); Collections.sort(groups, new DocumentModelComparator(userManager.getGroupSchemaName(), getGroupsOrderBy())); return groups; } catch (SizeLimitExceededException e) { addSearchOverflowMessage(); return Collections.emptyList(); } }
public DocumentModelList getCurrentDirectoryEntries() { if (currentDirectoryEntries == null) { currentDirectoryEntries = new DocumentModelListImpl(); String dirName = currentDirectoryInfo.getName(); try (Session dirSession = dirService.open(dirName)) { Map<String, Serializable> emptyMap = Collections.emptyMap(); Set<String> emptySet = Collections.emptySet(); DocumentModelList entries = dirSession.query(emptyMap, emptySet, null, true); if (entries != null && !entries.isEmpty()) { currentDirectoryEntries.addAll(entries); } // sort String sortField = currentDirectoryInfo.getSortField(); if (sortField == null) { sortField = dirService.getDirectoryIdField(dirName); } // sort Map<String, String> orderBy = new HashMap<String, String>(); orderBy.put(sortField, DocumentModelComparator.ORDER_ASC); Collections.sort(currentDirectoryEntries, new DocumentModelComparator(dirService.getDirectorySchema(dirName), orderBy)); } } return currentDirectoryEntries; }