@SuppressWarnings("unchecked") @Test public void testGetEntry() throws Exception { Session session = getLDAPDirectory("userDirectory").getSession(); try { DocumentModel entry = session.getEntry("Administrator"); assertNotNull(entry); assertEquals("Administrator", entry.getId()); assertEquals("Manager", entry.getProperty(USER_SCHEMANAME, "lastName")); if (USE_EXTERNAL_TEST_LDAP_SERVER) { assertEquals(Long.valueOf(1), entry.getProperty(USER_SCHEMANAME, "intField")); assertEquals("uid=Administrator,ou=people,dc=example,dc=com", entry.getProperty(USER_SCHEMANAME, "dn")); } assertEquals("Administrator", entry.getProperty(USER_SCHEMANAME, "firstName")); assertNull(entry.getProperty(USER_SCHEMANAME, "password")); List<String> val = (List<String>) entry.getProperty( USER_SCHEMANAME, "employeeType"); assertTrue(val.isEmpty()); if (USE_EXTERNAL_TEST_LDAP_SERVER) { List<String> groups = (List<String>) entry.getProperty( USER_SCHEMANAME, "groups"); assertEquals(2, groups.size()); assertTrue(groups.contains("members")); assertTrue(groups.contains("administrators")); } DocumentModel entry2 = session.getEntry("user1"); assertNotNull(entry2); assertEquals("user1", entry2.getId()); assertEquals("One", entry2.getProperty(USER_SCHEMANAME, "lastName")); assertEquals("User", entry2.getProperty(USER_SCHEMANAME, "firstName")); assertNull(entry2.getProperty(USER_SCHEMANAME, "password")); try { entry2.getProperty(USER_SCHEMANAME, "userPassword"); fail(); } catch (ClientException ce) { } assertEquals(Arrays.asList("Boss"), entry2.getProperty(USER_SCHEMANAME, "employeeType")); if (USE_EXTERNAL_TEST_LDAP_SERVER) { assertEquals(Long.valueOf(0), entry2.getProperty(USER_SCHEMANAME, "intField")); if (HAS_DYNGROUP_SCHEMA) { assertEquals(Arrays.asList("dyngroup1", "dyngroup2", "dyngroup3", "members", "subgroup"), entry2.getProperty(USER_SCHEMANAME, "groups")); } else { assertEquals(Arrays.asList("members", "subgroup"), entry2.getProperty(USER_SCHEMANAME, "groups")); } if (!(this instanceof TestLDAPPOSIXSession)) { Blob avatar = (Blob) entry2.getProperty(USER_SCHEMANAME, "avatar"); assertNotNull(avatar); File file = FileUtils.getResourceFileFromContext("sample.jpg"); assertNotNull(file); FileBlob expectedBlob = new FileBlob(file); assertTrue(Arrays.equals(expectedBlob.getByteArray(), avatar.getByteArray())); } } DocumentModel entry3 = session.getEntry("UnexistingEntry"); assertNull(entry3); if (USE_EXTERNAL_TEST_LDAP_SERVER) { DocumentModel entry4 = session.getEntry("Admi*"); assertNull(entry4); DocumentModel entry5 = session.getEntry(""); assertNull(entry5); DocumentModel entry6 = session.getEntry("(objectClass=*)"); assertNull(entry6); } } finally { session.close(); } }
@Override public DocumentModel getEntry(String id) throws DirectoryException { return getEntry(id, true); }
LDAPSession extends BaseSession implements EntrySource { @Override public DocumentModel getEntry(String id) throws DirectoryException { return getEntry(id, true); } }
LDAPSession extends BaseSession implements EntrySource { @Override public DocumentModel getEntry(String id) throws DirectoryException { return getEntry(id, true); } LDAPSession(LDAPDirectory directory, DirContext dirContext); }
LDAPSession extends BaseSession implements EntrySource { @Override public DocumentModel getEntry(String id) throws DirectoryException { return getEntry(id, true); } LDAPSession(LDAPDirectory directory, DirContext dirContext); void setSubStringMatchType(String type); Directory getDirectory(); DirContext getContext(); @Override @SuppressWarnings("unchecked") DocumentModel createEntry(Map<String, Object> fieldMap); @Override DocumentModel getEntry(String id); @Override DocumentModel getEntry(String id, boolean fetchReferences); @Override DocumentModel getEntryFromSource(String id, boolean fetchReferences); @Override boolean hasEntry(String id); @Override DocumentModelList getEntries(); @Override @SuppressWarnings("unchecked") void updateEntry(DocumentModel docModel); @Override void deleteEntry(DocumentModel dm); @Override void deleteEntry(String id); @Override void deleteEntry(String id, Map<String, String> map); DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, boolean fetchReferences,
            Map<String, String> orderBy); @Override DocumentModelList query(Map<String, Serializable> filter); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, Map<String, String> orderBy); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, Map<String, String> orderBy,
            boolean fetchReferences); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext); @Override void close(); @Override List<String> getProjection(Map<String, Serializable> filter,
            String columnName); @Override List<String> getProjection(Map<String, Serializable> filter,
            Set<String> fulltext, String columnName); @Override boolean authenticate(String username, String password); @Override String getIdField(); @Override String getPasswordField(); @Override boolean isAuthenticating(); @Override boolean isReadOnly(); boolean rdnMatchesIdField(); @Override // useful for the log function String toString(); @Override DocumentModel createEntry(DocumentModel entry); }
LDAPSession extends BaseSession implements EntrySource { @Override public DocumentModel getEntry(String id) throws DirectoryException { return getEntry(id, true); } LDAPSession(LDAPDirectory directory, DirContext dirContext); void setSubStringMatchType(String type); Directory getDirectory(); DirContext getContext(); @Override @SuppressWarnings("unchecked") DocumentModel createEntry(Map<String, Object> fieldMap); @Override DocumentModel getEntry(String id); @Override DocumentModel getEntry(String id, boolean fetchReferences); @Override DocumentModel getEntryFromSource(String id, boolean fetchReferences); @Override boolean hasEntry(String id); @Override DocumentModelList getEntries(); @Override @SuppressWarnings("unchecked") void updateEntry(DocumentModel docModel); @Override void deleteEntry(DocumentModel dm); @Override void deleteEntry(String id); @Override void deleteEntry(String id, Map<String, String> map); DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, boolean fetchReferences,
            Map<String, String> orderBy); @Override DocumentModelList query(Map<String, Serializable> filter); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, Map<String, String> orderBy); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext, Map<String, String> orderBy,
            boolean fetchReferences); @Override DocumentModelList query(Map<String, Serializable> filter,
            Set<String> fulltext); @Override void close(); @Override List<String> getProjection(Map<String, Serializable> filter,
            String columnName); @Override List<String> getProjection(Map<String, Serializable> filter,
            Set<String> fulltext, String columnName); @Override boolean authenticate(String username, String password); @Override String getIdField(); @Override String getPasswordField(); @Override boolean isAuthenticating(); @Override boolean isReadOnly(); boolean rdnMatchesIdField(); @Override // useful for the log function String toString(); @Override DocumentModel createEntry(DocumentModel entry);  }