public DocumentModel getCreationEntry() throws PropertyException { if (creationEntry == null) { creationEntry = BaseSession.createEntryModel(null, getSchemaName(), null, null); } return creationEntry; }
/** * 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; }
public DocumentModel getCreationDirectoryEntry() { if (creationDirectoryEntry == null) { String dirName = currentDirectoryInfo.getName(); String schema = dirService.getDirectorySchema(dirName); creationDirectoryEntry = BaseSession.createEntryModel(null, schema, null, null); } return creationDirectoryEntry; }
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 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; }
protected DocumentModel fieldMapToDocumentModel(Map<String, Object> fieldMap) { String id = String.valueOf(fieldMap.get(getIdField())); try { DocumentModel docModel = BaseSession.createEntryModel(sid, schemaName, id, fieldMap, isReadOnly()); EntryAdaptor adaptor = getDirectory().getDescriptor().getEntryAdaptor(); if (adaptor != null) { docModel = adaptor.adapt(directory, docModel); } return docModel; } catch (PropertyException e) { log.error(e, e); return null; } }
final DocumentModel entry = BaseSession.createEntryModel(null, schemaName, id, map, readOnlyEntries.contains(id)); results.add(entry);
final DocumentModel entry = BaseSession.createEntryModel(null, schemaName, id, map, readOnlyEntries.contains(id)); results.add(entry);
private static void updateSubDirectoryEntry(SubDirectoryInfo dirInfo, Map<String, Object> fieldMap, String id, boolean canCreateIfOptional) { DocumentModel dirEntry = dirInfo.getSession().getEntry(id); if (dirInfo.getSession().isReadOnly() || (dirEntry != null && isReadOnlyEntry(dirEntry))) { return; } if (dirEntry == null && !canCreateIfOptional) { // entry to update doesn't belong to this directory return; } Map<String, Object> map = new HashMap<>(); map.put(dirInfo.idField, id); for (Entry<String, String> e : dirInfo.fromSource.entrySet()) { map.put(e.getValue(), fieldMap.get(e.getKey())); } if (map.size() > 1) { if (canCreateIfOptional && dirInfo.isOptional && dirEntry == null) { // if entry does not exist, create it dirInfo.getSession().createEntry(map); } else { final DocumentModel entry = BaseSession.createEntryModel(null, dirInfo.dirSchemaName, id, null); entry.setProperties(dirInfo.dirSchemaName, map); dirInfo.getSession().updateEntry(entry); } } }
return BaseSession.createEntryModel(null, schemaName, entryId, map, isReadOnlyEntry); } catch (PropertyException e) { throw new DirectoryException(e);
DocumentModel deprecatedEntry = BaseSession.createEntryModel(null, schema, entryId, null, true); entryCache.put(entryId, deprecatedEntry);
@Override public OAuth2ServiceProvider addProvider(String serviceName, String description, String tokenServerURL, String authorizationServerURL, String userAuthorizationURL, String clientId, String clientSecret, List<String> scopes, Boolean isEnabled) { DirectoryService ds = Framework.getService(DirectoryService.class); try (Session session = ds.open(DIRECTORY_NAME)) { DocumentModel creationEntry = BaseSession.createEntryModel(null, SCHEMA, null, null); DocumentModel entry = Framework.doPrivileged(() -> session.createEntry(creationEntry)); entry.setProperty(SCHEMA, "serviceName", serviceName); entry.setProperty(SCHEMA, "description", description); entry.setProperty(SCHEMA, "authorizationServerURL", authorizationServerURL); entry.setProperty(SCHEMA, "tokenServerURL", tokenServerURL); entry.setProperty(SCHEMA, "userAuthorizationURL", userAuthorizationURL); entry.setProperty(SCHEMA, "clientId", clientId); entry.setProperty(SCHEMA, "clientSecret", clientSecret); entry.setProperty(SCHEMA, "scopes", String.join(",", scopes)); boolean enabled = (clientId != null && clientSecret != null); entry.setProperty(SCHEMA, "enabled", Boolean.valueOf(enabled && (isEnabled == null ? false : isEnabled))); if (!enabled) { log.info("OAuth2 provider for " + serviceName + " is disabled because clientId and/or clientSecret are empty"); } Framework.doPrivileged(() -> session.updateEntry(entry)); return getProvider(serviceName); } }