use of io.jans.orm.event.DeleteNotifier in project jans by JanssenProject.
the class SqlSimpleClientWithDeleteNotifierSample method main.
public static void main(String[] args) {
// Prepare sample connection details
SqlEntryManagerSample sqlEntryManagerSample = new SqlEntryManagerSample();
// Create SQL entry manager
SqlEntryManager sqlEntryManager = sqlEntryManagerSample.createSqlEntryManager();
sqlEntryManager.addDeleteSubscriber(new DeleteNotifier() {
@Override
public void onBeforeRemove(String dn, String[] objectClasses) {
System.out.println(Arrays.asList(objectClasses));
System.out.println(sqlEntryManager.exportEntry(dn, objectClasses[0]));
}
@Override
public void onAfterRemove(String dn, String[] objectClasses) {
System.out.println(Arrays.asList(objectClasses));
}
});
SimpleClient newClient = new SimpleClient();
newClient.setDn("inum=test_clnt3,ou=client,o=gluu");
newClient.setDefaultAcrValues(new String[] { "test_clnt3_acr" });
newClient.setClientName("test_clnt3");
sqlEntryManager.persist(newClient);
Filter presenceFilter = Filter.createEqualityFilter("displayName", "test_clnt3");
List<SimpleClient> results = sqlEntryManager.findEntries("ou=test_clnt3,o=gluu", SimpleClient.class, presenceFilter);
for (SimpleClient client : results) {
String[] acrs = client.getDefaultAcrValues();
if (ArrayHelper.isNotEmpty(acrs)) {
System.out.println(Arrays.toString(acrs));
}
}
sqlEntryManager.remove(newClient.getDn(), SimpleClient.class);
}
Aggregations