@SuppressWarnings("unchecked") @Test public void testCreateEntry() throws Exception { Session session = getSession(); assertNotNull(session); try { Map<String, Object> map = new HashMap<String, Object>(); map.put("username", "user_0"); map.put("password", "pass_0"); map.put("intField", Long.valueOf(5)); map.put("dateField", getCalendar(1982, 3, 25, 16, 30, 47, 0)); map.put("groups", Arrays.asList("members", "administrators")); DocumentModel dm = session.createEntry(map); assertNotNull(dm); assertEquals("user_0", dm.getId()); String[] schemaNames = dm.getSchemas(); assertEquals(1, schemaNames.length); assertEquals(SCHEMA, schemaNames[0]); assertEquals("user_0", dm.getProperty(SCHEMA, "username")); assertEquals("pass_0", dm.getProperty(SCHEMA, "password")); assertEquals(Long.valueOf(5), dm.getProperty(SCHEMA, "intField")); assertCalendarEquals(getCalendar(1982, 3, 25, 16, 30, 47, 0), (Calendar) dm.getProperty(SCHEMA, "dateField")); List<String> groups = (List<String>) dm.getProperty(SCHEMA, "groups"); assertEquals(2, groups.size()); assertTrue(groups.contains("administrators")); assertTrue(groups.contains("members")); } finally { session.close(); } session = getSession(); assertNotNull(session); try { DocumentModel dm = session.getEntry("user_0"); assertNotNull(dm); assertEquals("user_0", dm.getId()); String[] schemaNames = dm.getSchemas(); assertEquals(1, schemaNames.length); assertEquals(SCHEMA, schemaNames[0]); assertEquals("user_0", dm.getProperty(SCHEMA, "username")); String password = (String) dm.getProperty(SCHEMA, "password"); assertFalse("pass_0".equals(password)); assertTrue(PasswordHelper.verifyPassword("pass_0", password)); assertEquals(Long.valueOf(5), dm.getProperty(SCHEMA, "intField")); assertCalendarEquals(getCalendar(1982, 3, 25, 16, 30, 47, 0), (Calendar) dm.getProperty(SCHEMA, "dateField")); List<String> groups = (List<String>) dm.getProperty(SCHEMA, "groups"); assertEquals(2, groups.size()); assertTrue(groups.contains("administrators")); assertTrue(groups.contains("members")); } finally { session.close(); } }
@Override public synchronized Session getSession() throws DirectoryException { if (dialect == null) { initConnection(); } SQLSession session = new SQLSession(this, config, managedSQLSession); addSession(session); return session; }
SQLDirectory extends AbstractDirectory { @Override public synchronized Session getSession() throws DirectoryException { if (dialect == null) { initConnection(); } SQLSession session = new SQLSession(this, config, managedSQLSession); addSession(session); return session; } }
SQLDirectory extends AbstractDirectory { @Override public synchronized Session getSession() throws DirectoryException { if (dialect == null) { initConnection(); } SQLSession session = new SQLSession(this, config, managedSQLSession); addSession(session); return session; } SQLDirectory(SQLDirectoryDescriptor config); }
SQLDirectory extends AbstractDirectory { @Override public synchronized Session getSession() throws DirectoryException { if (dialect == null) { initConnection(); } SQLSession session = new SQLSession(this, config, managedSQLSession); addSession(session); return session; } SQLDirectory(SQLDirectoryDescriptor config); SQLDirectoryDescriptor getConfig(); Connection getConnection(); @Override String getName(); @Override String getSchema(); @Override String getParentDirectory(); @Override String getIdField(); @Override String getPasswordField(); @Override synchronized Session getSession(); Map<String, Field> getSchemaFieldMap(); List<String> getStoredFieldNames(); Table getTable(); Dialect getDialect(); boolean useNativeCase(); @Override boolean isMultiTenant(); @Override String toString(); }
SQLDirectory extends AbstractDirectory { @Override public synchronized Session getSession() throws DirectoryException { if (dialect == null) { initConnection(); } SQLSession session = new SQLSession(this, config, managedSQLSession); addSession(session); return session; } SQLDirectory(SQLDirectoryDescriptor config); SQLDirectoryDescriptor getConfig(); Connection getConnection(); @Override String getName(); @Override String getSchema(); @Override String getParentDirectory(); @Override String getIdField(); @Override String getPasswordField(); @Override synchronized Session getSession(); Map<String, Field> getSchemaFieldMap(); List<String> getStoredFieldNames(); Table getTable(); Dialect getDialect(); boolean useNativeCase(); @Override boolean isMultiTenant(); @Override String toString(); static final Log log; static final String TENANT_ID_FIELD; static final int MAX_CONNECTION_TRIES; }