本文整理了Java中org.nuxeo.ecm.directory.Directory
类的一些代码示例,展示了Directory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Directory
类的具体详情如下:
包路径:org.nuxeo.ecm.directory.Directory
类名称:Directory
[英]The directory interface.
This interface is implemented in order to create an NXDirectory. One should implement this interface in order to create either a new Directory implementation or a new Directory Source.
[中]目录接口。
实现此接口是为了创建一个NXDirectory。为了创建新的目录实现或新的目录源,应该实现这个接口。
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-rest-api-server
public static <T> T withDirectorySession(Directory directory, DirectorySessionRunner<T> runner) {
try (Session session = directory.getSession()) {
return runner.run(session);
}
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
protected BaseSession(Directory directory, Class<? extends Reference> referenceClass) {
this.directory = directory;
schemaName = directory.getSchema();
directoryName = directory.getName();
BaseDirectoryDescriptor desc = directory.getDescriptor();
substringMatchType = desc.getSubstringMatchType();
autoincrementId = desc.isAutoincrementIdField();
permissions = desc.permissions;
passwordHashAlgorithm = desc.passwordHashAlgorithm;
this.referenceClass = referenceClass;
computeMultiTenantId = desc.isComputeMultiTenantId();
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
@Override
public boolean isAuthenticating() {
return directory.getSchemaFieldMap().containsKey(getPasswordField());
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@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());
}
}
}
代码示例来源:origin: org.nuxeo.template.rendering/nuxeo-template-rendering-core
if (ds.getDirectoryNames().contains(voc)) {
Directory dir = ds.getDirectory(voc);
String schema = dir.getSchema();
if ("vocabulary".equals(schema) || "xvocabulary".equals(schema)) {
try (Session session = dir.getSession()) {
DocumentModel entry = session.getEntry(keyValue);
if (entry != null) {
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
@SuppressWarnings("unchecked")
protected Attribute getAttributeValue(String fieldName, Object value) {
Attribute attribute = new BasicAttribute(getDirectory().getFieldMapper().getBackendField(fieldName));
Field field = directory.getSchemaFieldMap().get(fieldName);
if (field == null) {
String message = String.format("Invalid field name '%s' for directory '%s' with schema '%s'", fieldName,
directory.getName(), directory.getSchema());
throw new DirectoryException(message);
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@Override
public DocumentModel adapt(Directory directory, DocumentModel entry) {
if (fieldName == null || pattern == null) {
log.warn(getClass().getName() + " is missing configuration parameters");
return entry;
}
if (BaseSession.isReadOnlyEntry(entry)) {
// keep already existing flag
return entry;
}
try {
Object fieldValue = entry.getProperty(directory.getSchema(), fieldName);
String value = fieldValue != null ? fieldValue.toString() : "";
if (pattern.matcher(value).matches()) {
BaseSession.setReadWriteEntry(entry);
} else {
BaseSession.setReadOnlyEntry(entry);
}
} catch (PropertyException e) {
throw new DirectoryException(
String.format(
"The field '%s' of entry '%s' could not be adapt and map on directory '%s', check that the field exist in the schema",
fieldName, entry.getId(), directory.getName()), e);
}
return entry;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-sql
@Override
public String toString() {
return "SQLSession [directory=" + directory.getName() + ", sid=" + sid + "]";
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
@Override
public DocumentModel createEntry(DocumentModel entry) {
Map<String, Object> fieldMap = entry.getProperties(directory.getSchema());
Map<String, Object> simpleNameFieldMap = new HashMap<>();
for (Map.Entry<String, Object> fieldEntry : fieldMap.entrySet()) {
String fieldKey = fieldEntry.getKey();
if (fieldKey.contains(":")) {
fieldKey = fieldKey.split(":")[1];
}
simpleNameFieldMap.put(fieldKey, fieldEntry.getValue());
}
return createEntry(simpleNameFieldMap);
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-multi
protected List<String> doCollect(Collector extractor) {
DirectoryService dirService = Framework.getService(DirectoryService.class);
Set<String> ids = new HashSet<>();
for (SourceDescriptor src : dir.getDescriptor().sources) {
for (SubDirectoryDescriptor sub : src.subDirectories) {
Directory dir = dirService.getDirectory(sub.name);
if (dir == null) {
continue;
}
List<Reference> ref = dir.getReferences(fieldName);
if (ref == null) {
continue;
}
try {
ids.addAll(extractor.collect(ref));
} catch (DirectoryEntryNotFoundException e) {
log.debug(e.getMessage());
}
}
}
List<String> x = new ArrayList<>(ids.size());
x.addAll(ids);
return x;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
List<Reference> references = directory.getReferences(referenceFieldName);
if (references.size() > 1) {
log.warn("Directory " + getDirectory().getName() + " cannot update field " + referenceFieldName
+ " for entry " + docModel.getId()
+ ": this field is associated with more than one reference");
getDirectory().invalidateCaches();
代码示例来源:origin: toutatice-services.carto-nat/toutatice-carto-nat-ecm
String schema = directory.getSchema();
DocumentModel entry = session.getEntry(entryId);
} else {
if(entryId != null){
DirectoryCache cache = directory.getCache();
log.error("Session: " + session + "Vocabulary " + directoryName + " entry: " + entryId + " == Entry KO: directoryCache" + directory.getCache() + " / entryCache: " + directory.getCache().getEntryCache()
+ " / entryCacheWithoutReferences: " + directory.getCache().getEntryCacheWithoutReferences());
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@Override
public DocumentModel createEntry(Map<String, Object> fieldMap) {
checkPermission(SecurityConstants.WRITE);
DocumentModel docModel = createEntryWithoutReferences(fieldMap);
// Add references fields
Map<String, Field> schemaFieldMap = directory.getSchemaFieldMap();
String idFieldName = schemaFieldMap.get(getIdField()).getName().getPrefixedName();
Object entry = fieldMap.get(idFieldName);
String sourceId = docModel.getId();
for (Reference reference : getDirectory().getReferences()) {
String referenceFieldName = schemaFieldMap.get(reference.getFieldName()).getName().getPrefixedName();
if (getDirectory().getReferences(reference.getFieldName()).size() > 1) {
if (log.isWarnEnabled()) {
log.warn("Directory " + directoryName + " cannot create field " + reference.getFieldName()
+ " for entry " + entry + ": this field is associated with more than one reference");
}
continue;
}
List<String> targetIds = toStringList(fieldMap.get(referenceFieldName));
if (reference.getClass() == referenceClass) {
reference.addLinks(sourceId, targetIds, this);
} else {
reference.addLinks(sourceId, targetIds);
}
}
getDirectory().invalidateCaches();
return docModel;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
for (String fieldName : directory.getSchemaFieldMap().keySet()) {
List<org.nuxeo.ecm.directory.Reference> references = directory.getReferences(fieldName);
if (references != null && references.size() > 0) {
if (fetchReferences) {
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@Override
public void deleteEntry(String id) {
if (!canDeleteMultiTenantEntry(id)) {
throw new OperationNotAllowedException("Operation not allowed in the current tenant context",
"label.directory.error.multi.tenant.operationNotAllowed", null);
}
checkPermission(SecurityConstants.WRITE);
checkDeleteConstraints(id);
for (Reference reference : getDirectory().getReferences()) {
if (reference.getClass() == referenceClass) {
reference.removeLinksForSource(id, this);
} else {
reference.removeLinksForSource(id);
}
}
deleteEntryWithoutReferences(id);
getDirectory().invalidateCaches();
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@Override
public String getPasswordField() {
return directory.getPasswordField();
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-api
@Override
public DocumentModel getEntry(String id, boolean fetchReferences) {
if (!hasPermission(SecurityConstants.READ)) {
return null;
}
if (readAllColumns) {
// bypass cache when reading all columns
return getEntryFromSource(id, fetchReferences);
}
return directory.getCache().getEntry(id, this, fetchReferences);
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-ui-select2
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;
}
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-ldap
String dirName = null;
try {
Session dirSession = dir.getSession();
dirSession.close();
dirName = dir.getName();
} catch (DirectoryException e) {
success = false;
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-multi
public String getName() {
return directory.getName();
}
内容来源于网络,如有侵权,请联系作者删除!