@Test public void testCreateEntry2() throws Exception { assumeTrue(isExternalServer()); try (Session session = groupDir.getSession()) { assertNotNull(session); Map<String, Object> map = new HashMap<>(); map.put("groupname", "group2"); map.put("members", Arrays.asList("user1", "user2")); DocumentModel dm = session.createEntry(map); dm = session.getEntry("group2"); assertNotNull(dm); assertEquals(Arrays.asList("user1", "user2"), dm.getProperty(GROUP_SCHEMANAME, "members")); map = new HashMap<>(); map.put("groupname", "group1"); map.put("members", Arrays.asList("Administrator")); map.put("subGroups", Arrays.asList("group2")); dm = session.createEntry(map); dm = session.getEntry("group1"); assertNotNull(dm); assertEquals(Arrays.asList("Administrator"), dm.getProperty(GROUP_SCHEMANAME, "members")); assertEquals(Arrays.asList("group2"), dm.getProperty(GROUP_SCHEMANAME, "subGroups")); dm = session.getEntry("group2"); assertNotNull(dm); assertEquals(Arrays.asList("group1"), dm.getProperty(GROUP_SCHEMANAME, "parentGroups")); map = new HashMap<>(); map.put("groupname", "emptygroup"); map.put("members", new ArrayList<String>()); dm = session.createEntry(map); dm = session.getEntry("emptygroup"); assertNotNull(dm); assertEquals("emptygroup", dm.getId()); assertEquals("emptygroup", dm.getProperty(GROUP_SCHEMANAME, "groupname")); assertEquals(Arrays.asList(), dm.getProperty(GROUP_SCHEMANAME, "members")); assertEquals(Arrays.asList(), dm.getProperty(GROUP_SCHEMANAME, "subGroups")); assertEquals(Arrays.asList(), dm.getProperty(GROUP_SCHEMANAME, "parentGroups")); } }
@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);  }