@Test public void testCreateFromModel() throws Exception { assumeTrue(isExternalServer()); try (Session dir = userDir.getSession()) { String schema = "user"; DocumentModel entry = BaseSession.createEntryModel(null, schema, null, null); entry.setProperty(schema, "username", "omar"); entry.setProperty(schema, "password", "sesame"); entry.setProperty(schema, "employeeType", new String[] { "Slave" }); assertNull(dir.getEntry("omar")); dir.createEntry(entry); assertNotNull(dir.getEntry("omar")); entry.setProperty(schema, "username", "Administrator"); try { entry = dir.createEntry(entry); fail("Should raise an error, entry already exists"); } catch (DirectoryException e) { } } }
@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); }
LDAPSession extends BaseSession { @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); } }
LDAPSession extends BaseSession { @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); } LDAPSession(LDAPDirectory directory); }
LDAPSession extends BaseSession { @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); } LDAPSession(LDAPDirectory directory); @Override LDAPDirectory getDirectory(); DirContext getContext(); @Override void deleteEntryWithoutReferences(String id); @Override boolean hasEntry(String id); @Override void deleteEntry(String id, Map<String, String> map); @Override DocumentModel getEntryFromSource(String id, boolean fetchReferences); @Override DocumentModelList query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy,
            boolean fetchReferences, int limit, int offset); @Override DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences); @Override List<String> queryIds(QueryBuilder queryBuilder); @Override void close(); @Override boolean authenticate(String username, String password); @Override boolean isAuthenticating(); boolean rdnMatchesIdField(); @Override // useful for the log function String toString(); @Override DocumentModel createEntry(DocumentModel entry); }
LDAPSession extends BaseSession { @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); } LDAPSession(LDAPDirectory directory); @Override LDAPDirectory getDirectory(); DirContext getContext(); @Override void deleteEntryWithoutReferences(String id); @Override boolean hasEntry(String id); @Override void deleteEntry(String id, Map<String, String> map); @Override DocumentModel getEntryFromSource(String id, boolean fetchReferences); @Override DocumentModelList query(Map<String, Serializable> filter, Set<String> fulltext, Map<String, String> orderBy,
            boolean fetchReferences, int limit, int offset); @Override DocumentModelList query(QueryBuilder queryBuilder, boolean fetchReferences); @Override List<String> queryIds(QueryBuilder queryBuilder); @Override void close(); @Override boolean authenticate(String username, String password); @Override boolean isAuthenticating(); boolean rdnMatchesIdField(); @Override // useful for the log function String toString(); @Override DocumentModel createEntry(DocumentModel entry);  }