public static <T> T withDirectorySession(Directory directory, DirectorySessionRunner<T> runner) { try (Session session = directory.getSession()) { return runner.run(session); } }
@Override protected ContentProvider getProvider(WebContext ctx) { return new DirectoryContentProvider(dir.getSession()); }
protected MongoDBSession getMongoDBSession() { return (MongoDBSession) getSourceDirectory().getSession(); }
protected SQLSession getSQLSession() { return (SQLSession) getSourceDirectory().getSession(); }
@Override public List<DirectoryEntry> getCurrentPage() { Object[] parameters = getParameters(); if (parameters == null || parameters.length > 1) { throw new IllegalStateException("Invalid parameters: " + Arrays.toString(parameters)); } if (!(parameters[0] instanceof Directory)) { throw new IllegalStateException("Provided parameter is not a Directory: " + parameters[0]); } Directory directory = (Directory) parameters[0]; try (Session session = directory.getSession()) { return session.query(Collections.emptyMap(), Collections.emptySet(), Collections.emptyMap(), false, (int) getPageSize(), (int) getCurrentPageOffset()) .stream() .map(dir -> new DirectoryEntry(directory.getName(), dir)) .collect(Collectors.toList()); } } }
String schema = dir.getSchema(); if ("vocabulary".equals(schema) || "xvocabulary".equals(schema)) { try (Session session = dir.getSession()) { DocumentModel entry = session.getEntry(keyValue); if (entry != null) {
String dirName = null; try { Session dirSession = dir.getSession(); dirSession.close(); dirName = dir.getName();
protected JSONObject getSingleDirectoryEntry(final String storedReference, final String directoryName, final boolean localize, String keySeparator, final boolean dbl10n, final String labelFieldName) { if (storedReference == null || storedReference.isEmpty()) { return null; } DirectoryService directoryService = Framework.getService(DirectoryService.class); try { Directory directory = directoryService.getDirectory(directoryName); if (directory == null) { log.error("Could not find directory with name " + directoryName); return null; } try (Session session = directory.getSession()) { String schemaName = directory.getSchema(); SchemaManager schemaManager = Framework.getService(SchemaManager.class); Schema schema = schemaManager.getSchema(schemaName); final Locale locale = org.jboss.seam.core.Locale.instance(); final String label = SuggestConstants.getLabelFieldName(schema, dbl10n, labelFieldName, locale.getLanguage()); JSONObject obj = resolveDirectoryEntry(storedReference, keySeparator, session, schema, label, localize, dbl10n); return obj; } } catch (DirectoryException de) { log.error("An error occured while obtaining directory " + directoryName, de); return null; } }
try (Session session = directory.getSession()) { String schemaName = directory.getSchema(); SchemaManager schemaManager = Framework.getService(SchemaManager.class);
/** * Fetches both statically and dynamically defined references and merges the results. * * @see org.nuxeo.ecm.directory.Reference#getSourceIdsForTarget(String) */ @Override // XXX: broken, use getLdapTargetIds for a proper implementation public List<String> getTargetIdsForSource(String sourceId) { String schemaName = getSourceDirectory().getSchema(); try (Session session = getSourceDirectory().getSession()) { try { return BaseSession.toStringList(session.getEntry(sourceId).getProperty(schemaName, fieldName)); } catch (PropertyException e) { throw new DirectoryException(e); } } }
Session session = null; try { session = directory.getSession(); if (session != null) { if (value.isList()) {