/** * Enable connection status checking on SQL directory connections * * @since 5.7.2 */ public boolean isLive() { try { return !sqlConnection.isClosed(); } catch (SQLException e) { throw new DirectoryException("Cannot check connection status of " + this, e); } }
private boolean initPersistentService() { if (dirSession != null) { return true; } if (directoryService == null) { directoryService = DirectoryHelper.getDirectoryService(); if (directoryService == null) { return false; } } try { dirSession = directoryService.open(DIR_NAME); directorySchema = directoryService.getDirectorySchema(DIR_NAME); } catch (DirectoryException e) { dirSession = null; log.error("Unable to open directory " + DIR_NAME + " : " + e.getMessage()); return false; } return true; }
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; }
public String getCreateTablePolicy() { if (StringUtils.isBlank(createTablePolicy)) { return CREATE_TABLE_POLICY_DEFAULT; } String ctp = createTablePolicy.toLowerCase(); if (!CREATE_TABLE_POLICIES.contains(ctp)) { throw new DirectoryException("Invalid createTablePolicy: " + createTablePolicy + ", it should be one of: " + CREATE_TABLE_POLICIES); } return ctp; }
directorySession.close(); } catch (DirectoryException e) { log.error("Failed to close the session to the directory '" + directory + "', error: " + e.getMessage());
public DirectoryDeleteConstraint getDeleteConstraint() { try { DirectoryDeleteConstraint instance = klass.newInstance(); if (properties != null) { instance.setProperties(properties); } return instance; } catch (InstantiationException e) { throw new DirectoryException(e); } catch (IllegalAccessException e) { throw new DirectoryException(e); } }
if (virtualGroups.contains(groupName)) { log.warn("Failed to get group '" + groupName + "' due to '" + de.getMessage() + "': permission resolution involving groups may not be correct"); nxGroup = null;
@Override public void accept(Map<String, Object> map) { try { ps.setString(1, (String) map.get(sourceColumn)); ps.setString(2, (String) map.get(targetColumn)); ps.execute(); } catch (SQLException e) { throw new DirectoryException(e); } } };
public DocumentModelList getItems(String directoryName, Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy) throws ToutaticeException { DocumentModelList items = null; Session session = null; try { session = getService().open(directoryName); } catch (DirectoryException e) { throw new ToutaticeException("could not open session on directory '" + directoryName + "', error: " + e.getMessage()); } if (null != session) { try { items = session.query(filter, fulltext, orderBy); } catch (Exception e) { throw new ToutaticeException("could not query on directory '" + directoryName + "', error: " + e.getMessage()); } finally { try { if (null != session) { session.close(); } } catch (DirectoryException ce) { log.error("Could not close directory session", ce); } } } else { throw new ToutaticeException("could not open session on directory: " + directoryName); } return items; }
@Override public void setProperties(Map<String, String> properties) { String targetDirKey = "targetDirectory"; String targetDirFieldKey = "targetDirectoryField"; if (properties == null) { throw new DirectoryException(String.format("This delete constraint requires properties '%s' and '%s'", targetDirKey, targetDirFieldKey)); } if (!properties.containsKey(targetDirKey)) { throw new DirectoryException(String.format("This delete constraint requires property '%s'", targetDirKey)); } if (!properties.containsKey(targetDirFieldKey)) { throw new DirectoryException(String.format("This delete constraint requires property '%s'", targetDirFieldKey)); } targetDirectory = properties.get(targetDirKey); targetDirectoryField = properties.get(targetDirFieldKey); }
@Override DirectoryEntry run(Session session) { try { DocumentModel docEntry = entry.getDocumentModel(); session.updateEntry(docEntry); return new DirectoryEntry(directory.getName(), session.getEntry(docEntry.getId())); } catch (DirectoryException e) { throw new NuxeoException(e.getMessage(), SC_BAD_REQUEST); } } });
@Override public Directory getSourceDirectory() { Directory sourceDir = super.getSourceDirectory(); if (sourceDir instanceof LDAPDirectory) { return sourceDir; } else { throw new DirectoryException(sourceDirectoryName + " is not a LDAPDirectory and thus cannot be used in a reference for " + fieldName); } }
@Override public Directory getTargetDirectory() { Directory targetDir = super.getTargetDirectory(); if (targetDir instanceof LDAPDirectory) { return targetDir; } else { throw new DirectoryException(targetDirectoryName + " is not a LDAPDirectory and thus cannot be referenced as target by " + fieldName); } }
@Override public Directory getSourceDirectory() { Directory sourceDir = super.getSourceDirectory(); if (sourceDir instanceof LDAPDirectory) { return sourceDir; } else { throw new DirectoryException(sourceDirectoryName + " is not a LDAPDirectory and thus cannot be used in a reference for " + fieldName); } }
@Override public boolean hasEntry(String id) { try { // TODO: check directory cache first return getLdapEntry(id) != null; } catch (NamingException e) { throw new DirectoryException("hasEntry failed: " + e.getMessage(), e); } }
public int setFieldValue(PreparedStatement ps, int index, Column column) { try { return doSetFieldValue(ps, index, column); } catch (SQLException e) { throw new DirectoryException("SQLComplexFilter setFieldValue failed", e); } }
@Override public Directory getTargetDirectory() { Directory targetDir = super.getTargetDirectory(); if (targetDir instanceof LDAPDirectory) { return targetDir; } else { throw new DirectoryException(targetDirectoryName + " is not a LDAPDirectory and thus cannot be referenced as target by " + fieldName); } }
@Override public void close() { try { if (!sqlConnection.isClosed()) { sqlConnection.close(); } } catch (SQLException e) { throw new DirectoryException("close failed", e); } finally { getDirectory().removeSession(this); } }
@Override public void addLinks(List<String> sourceIds, String targetId) { if (sourceIds == null || sourceIds.isEmpty()) { return; } try (MongoDBSession session = getMongoDBSession()) { addLinks(sourceIds, targetId, session); } catch (MongoWriteException e) { throw new DirectoryException(e); } }
private Object getFieldValue(ResultSet rs, Column column) { try { int index = rs.findColumn(column.getPhysicalName()); return column.getFromResultSet(rs, index); } catch (SQLException e) { throw new DirectoryException("getFieldValue failed", e); } }