public DocumentModel getCreationEntry() throws PropertyException { if (creationEntry == null) { creationEntry = BaseSession.createEntryModel(null, getSchemaName(), null, null); } return creationEntry; }
public boolean getAllowDeleteUser() { return selectedUser != null && getCanEditUsers(false) && !BaseSession.isReadOnlyEntry(selectedUser); }
@Override @Deprecated public void deleteEntry(String id, Map<String, String> map) { deleteEntry(id); }
/** * Returns a bare document model suitable for directory implementations. * <p> * Allow setting the readonly entry flag to {@code Boolean.TRUE}. See {@code Session#isReadOnlyEntry(DocumentModel)} * * @since 5.3.1 */ public static DocumentModel createEntryModel(String sessionId, String schema, String id, Map<String, Object> values, boolean readOnly) throws PropertyException { DocumentModel entry = createEntryModel(sessionId, schema, id, values); if (readOnly) { setReadOnlyEntry(entry); } return entry; }
@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(); }
@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; }
map.put(e.getValue(), entry.getProperty(dirInfo.dirSchemaName, e.getKey())); if (BaseSession.isReadOnlyEntry(entry)) { readOnlyEntries.add(id); final DocumentModel entry = BaseSession.createEntryModel(null, schemaName, id, map, readOnlyEntries.contains(id)); results.add(entry);
@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; }
if (BaseSession.isReadOnlyEntry(dm)) { BaseSession.setReadOnlyEntry(clone);
@Override public void updateEntry(DocumentModel docModel) { checkPermission(SecurityConstants.WRITE); List<String> referenceFieldList = updateEntryWithoutReferences(docModel); log.warn("Directory " + getDirectory().getName() + " cannot update field " + referenceFieldName + " for entry " + docModel.getId() + ": this field is associated with more than one reference"); List<String> targetIds = toStringList(docModel.getProperty(schemaName, referenceFieldName)); if (reference.getClass() == referenceClass) { reference.setTargetIdsForSource(docModel.getId(), targetIds, this); getDirectory().invalidateCaches();
/** * 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); } } }
map.put(e.getValue(), entry.getProperty(dirInfo.dirSchemaName, e.getKey())); if (BaseSession.isReadOnlyEntry(entry)) { readOnlyEntries.add(id); final DocumentModel entry = BaseSession.createEntryModel(null, schemaName, id, map, readOnlyEntries.contains(id)); results.add(entry);
public DocumentModel getCreationDirectoryEntry() { if (creationDirectoryEntry == null) { String dirName = currentDirectoryInfo.getName(); String schema = dirService.getDirectorySchema(dirName); creationDirectoryEntry = BaseSession.createEntryModel(null, schema, null, null); } return creationDirectoryEntry; }
public boolean getAllowEditUser() { return selectedUser != null && getCanEditUsers(true) && !BaseSession.isReadOnlyEntry(selectedUser); }
@Override public void deleteEntry(DocumentModel docModel) { deleteEntry(docModel.getId()); }
protected DocumentModel fieldMapToDocumentModel(Map<String, Object> fieldMap) { String idFieldName = directory.getSchemaFieldMap().get(getIdField()).getName().getPrefixedName(); // If the prefixed id is not here, try to get without prefix // It may happen when we gentry from sql if (!fieldMap.containsKey(idFieldName)) { idFieldName = getIdField(); } String id = String.valueOf(fieldMap.get(idFieldName)); try { DocumentModel docModel = BaseSession.createEntryModel(sid, schemaName, id, fieldMap, isReadOnly()); return docModel; } catch (PropertyException e) { log.error(e, e); return null; } }
public boolean getAllowChangePassword() { return selectedUser != null && getCanEditUsers(true) && !BaseSession.isReadOnlyEntry(selectedUser); }
@Override public void deleteEntry(String id) { acquireConnection(); if (!canDeleteMultiTenantEntry(id)) { throw new OperationNotAllowedException("Operation not allowed in the current tenant context", "label.directory.error.multi.tenant.operationNotAllowed", null); } super.deleteEntry(id); }
public DocumentModel getCreationDirectoryEntry(String directoryName) { if (newDirectoryEntry == null || (directoryName != null && !directoryName.equals(getDirectoryName()))) { setDirectoryName(directoryName); DirectoryService dirService = DirectoryHelper.getDirectoryService(); String schema = dirService.getDirectorySchema(directoryName); newDirectoryEntry = BaseSession.createEntryModel(null, schema, null, null); } return newDirectoryEntry; }
public boolean getAllowDeleteGroup() { if (getAllAdminGroups().contains(selectedGroup.getId())) { return currentUser.isAdministrator(); } return getCanEditGroups() && !BaseSession.isReadOnlyEntry(selectedGroup); }