public static List<WidgetSelectOption> getVocabularySelectOptions(String dirName, String lang) { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(dirName)) { String schema = ds.getDirectory(dirName).getSchema(); DocumentModelList entries = session.getEntries(); return convertToSelectOptions(entries, schema, dirName, lang); } catch (DirectoryException e) { log.error("Error while getting content of directory " + dirName, e); return Collections.emptyList(); } }
public DocumentModelList getEntries(String directory) throws ToutaticeException { DocumentModelList entries = null; Session directorySession = null; try { directorySession = getService().open(directory); if (null != directorySession) { entries = directorySession.getEntries(); } else { log.error("Failed to obtain a session to the the directory '" + directory + "'"); } } catch (Exception e) { log.warn("Failed to either get a session to the directory '" + directory + "' or failed to get the entries, error: " + e.getMessage()); throw new ToutaticeException(e); } finally { if (null != directorySession) { try { directorySession.close(); } catch (DirectoryException e) { log.error("Failed to close the session to the directory '" + directory + "', error: " + e.getMessage()); } } } return entries; }
childrenEntries = session.getEntries(); } else { childrenEntries = session.query(filter);
final DocumentModelList entries = dirInfo.getSession().getEntries(); for (DocumentModel entry : entries) { final String id = entry.getId(); final DocumentModelList entries = dirInfo.getSession().getEntries(); Set<String> existingIds = new HashSet<>(); for (DocumentModel entry : entries) {
protected DocumentModelList getChildrenEntries() { if (childrenEntries != null) { // memorized directory lookup since directory content is not // suppose to change // XXX: use the cache manager instead of field caching strategy return childrenEntries; } try (Session session = getDirectorySession()) { if (level == 0) { String schemaName = getDirectorySchema(); SchemaManager schemaManager = Framework.getService(SchemaManager.class); Schema schema = schemaManager.getSchema(schemaName); if (schema.hasField(PARENT_FIELD_ID)) { // filter on empty parent Map<String, Serializable> filter = new HashMap<String, Serializable>(); filter.put(PARENT_FIELD_ID, ""); childrenEntries = session.query(filter); } else { childrenEntries = session.getEntries(); } } else { Map<String, Serializable> filter = new HashMap<String, Serializable>(); String[] bitsOfPath = path.split("/"); filter.put(PARENT_FIELD_ID, bitsOfPath[level - 1]); childrenEntries = session.query(filter); } return childrenEntries; } }
String subSchema = ds.getDirectory(childDirName).getSchema(); DocumentModelList entries = session.getEntries(); for (DocumentModel entry : entries) { String itemValue = entry.getId();