-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix RDBS export entry and DeleteNotifier (#864)
Co-authored-by: yurem <Yuriy.Movchan@gmail.com>
- Loading branch information
Showing
10 changed files
with
203 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
jans-orm/sql-sample/src/main/java/io/jans/orm/sql/SqlSimpleClientSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.jans.orm.sql; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.jans.orm.search.filter.Filter; | ||
import io.jans.orm.sql.impl.SqlEntryManager; | ||
import io.jans.orm.sql.model.SimpleClient; | ||
import io.jans.orm.sql.operation.impl.SqlConnectionProvider; | ||
import io.jans.orm.sql.persistence.SqlEntryManagerSample; | ||
import io.jans.orm.util.ArrayHelper; | ||
|
||
/** | ||
* @author Yuriy Movchan Date: 05/26/2021 | ||
*/ | ||
public class SqlSimpleClientSample { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(SqlConnectionProvider.class); | ||
|
||
private SqlSimpleClientSample() { | ||
} | ||
|
||
public static void main(String[] args) { | ||
// Prepare sample connection details | ||
SqlEntryManagerSample sqlEntryManagerSample = new SqlEntryManagerSample(); | ||
|
||
// Create SQL entry manager | ||
SqlEntryManager sqlEntryManager = sqlEntryManagerSample.createSqlEntryManager(); | ||
|
||
SimpleClient newClient = new SimpleClient(); | ||
newClient.setDn("inum=test_clnt2,ou=client,o=gluu"); | ||
newClient.setDefaultAcrValues(new String[] { "test_clnt2_acr" }); | ||
newClient.setClientName("test_clnt2"); | ||
|
||
sqlEntryManager.persist(newClient); | ||
|
||
Filter presenceFilter = Filter.createEqualityFilter("displayName", "test_clnt2"); | ||
List<SimpleClient> results = sqlEntryManager.findEntries("ou=test_clnt2,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); | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
...orm/sql-sample/src/main/java/io/jans/orm/sql/SqlSimpleClientWithDeleteNotifierSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.jans.orm.sql; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.jans.orm.event.DeleteNotifier; | ||
import io.jans.orm.search.filter.Filter; | ||
import io.jans.orm.sql.impl.SqlEntryManager; | ||
import io.jans.orm.sql.model.SimpleClient; | ||
import io.jans.orm.sql.operation.impl.SqlConnectionProvider; | ||
import io.jans.orm.sql.persistence.SqlEntryManagerSample; | ||
import io.jans.orm.util.ArrayHelper; | ||
|
||
/** | ||
* @author Yuriy Movchan Date: 05/26/2021 | ||
*/ | ||
public class SqlSimpleClientWithDeleteNotifierSample { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(SqlConnectionProvider.class); | ||
|
||
private SqlSimpleClientWithDeleteNotifierSample() { | ||
} | ||
|
||
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.