Skip to content

Commit

Permalink
fix(jans-client-api):minor observations PR13119 - typo transalation c…
Browse files Browse the repository at this point in the history
…ode-improvement (#1806)
  • Loading branch information
jmunozherbas authored Jul 15, 2022
1 parent 982cab3 commit 6df2e42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public PersistenceEntryManager createPersistenceEntryManager() throws Interrupte
logger.info("Read backend properties: {}", backendProperties);
i++;
entryManager = factory.createEntryManager(backendProperties);
logger.info("Trató de leer: {}", entryManager);
logger.info("PersistenceEntryManager read: {}", entryManager);
} catch (Exception e) {
logger.warn("Unable to create persistence entry manager, retrying in {} seconds", RETRY_INTERVAL);
Thread.sleep(RETRY_INTERVAL * 1000L);
Expand Down Expand Up @@ -225,16 +225,13 @@ protected void initSchedulerService() {
private void clearRPTestData() {
try {
String val = System.getProperty("clearTestData");
if (val != null && !val.isEmpty() && Boolean.valueOf(val).booleanValue()) {
if (val != null && !val.isEmpty() && Boolean.parseBoolean(val)) {
persistenceService.create();
rpService.removeAllRps();
rpService.load();
logger.info("Finished removeExistingRps successfullly.");
} else {
logger.info("Invalid value clearTestData.");
}
} catch (Exception e) {
logger.error("Failed to remove existing RPs.", e);
logger.error("Failed to execute clearTestData action", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,28 @@ public void prepareBranch() {
addOrganizationBranch(BASE_DN, null);
}
//create `ou=configuration,o=jans` if not present
if (!containsBranch(joinWithComa(ou(OU_CONFIGURATION), BASE_DN))) {
addBranch(joinWithComa(ou(OU_CONFIGURATION), BASE_DN), OU_CONFIGURATION);
if (!containsBranch(joinWithComma(ou(OU_CONFIGURATION), BASE_DN))) {
addBranch(joinWithComma(ou(OU_CONFIGURATION), BASE_DN), OU_CONFIGURATION);
}
//create `ou=client-api,ou=configuration,o=jans` if not present
if (!containsBranch(joinWithComa(ou(OU_JANS_CLIENT_API), ou(OU_CONFIGURATION), BASE_DN))) {
addBranch(joinWithComa(ou(OU_JANS_CLIENT_API), ou(OU_CONFIGURATION), BASE_DN), OU_JANS_CLIENT_API);
if (!containsBranch(joinWithComma(ou(OU_JANS_CLIENT_API), ou(OU_CONFIGURATION), BASE_DN))) {
addBranch(joinWithComma(ou(OU_JANS_CLIENT_API), ou(OU_CONFIGURATION), BASE_DN), OU_JANS_CLIENT_API);
}
//create `ou=client-api,o=jans` if not present
if (!containsBranch(getClientApiDn())) {
addBranch(getClientApiDn(), "client-api");
}
//create `ou=rp,ou=client-api,o=jans` if not present
if (!containsBranch(joinWithComa(getRpOu(), getClientApiDn()))) {
addBranch(joinWithComa(getRpOu(), getClientApiDn()), "rp");
if (!containsBranch(joinWithComma(getRpOu(), getClientApiDn()))) {
addBranch(joinWithComma(getRpOu(), getClientApiDn()), "rp");
}
//create `ou=expiredObjects,ou=client-api,o=jans` if not present
if (!containsBranch(joinWithComa(getExpiredObjOu(), getClientApiDn()))) {
addBranch(joinWithComa(getExpiredObjOu(), getClientApiDn()), "expiredObjects");
if (!containsBranch(joinWithComma(getExpiredObjOu(), getClientApiDn()))) {
addBranch(joinWithComma(getExpiredObjOu(), getClientApiDn()), "expiredObjects");
}
}

private String joinWithComa(String... words) {
private String joinWithComma(String... words) {
StringBuilder stringBuilder = new StringBuilder();
String coma = "";
for (String word : words) {
Expand Down Expand Up @@ -244,7 +244,7 @@ public boolean isExpiredObjectPresent(String key) {

public boolean removeAllRps() {
try {
this.persistenceManager.remove(joinWithComa(getRpOu(), getClientApiDn()), RpObject.class, null, this.configuration.getPersistenceManagerRemoveCount());
this.persistenceManager.remove(joinWithComma(getRpOu(), getClientApiDn()), RpObject.class, null, this.configuration.getPersistenceManagerRemoveCount());
logger.debug("Removed all Rps successfully. ");
return true;
} catch (Exception e) {
Expand All @@ -256,7 +256,7 @@ public boolean removeAllRps() {
public Set<Rp> getRps() {
Set<Rp> result = new HashSet<>();
try {
List<RpObject> rpObjects = this.persistenceManager.findEntries(joinWithComa(getRpOu(), getClientApiDn()), RpObject.class, null);
List<RpObject> rpObjects = this.persistenceManager.findEntries(joinWithComma(getRpOu(), getClientApiDn()), RpObject.class, null);
for (RpObject ele : rpObjects) {
Rp rp = MigrationService.parseRp(ele.getData());
if (rp != null) {
Expand Down Expand Up @@ -309,7 +309,7 @@ public boolean deleteAllExpiredObjects() {
final Date currentTime = cal.getTime();
Filter exirationDateFilter = Filter.createLessOrEqualFilter("exp", this.persistenceManager.encodeTime(BASE_DN, currentTime));

this.persistenceManager.remove(joinWithComa(getExpiredObjOu(), getClientApiDn()), ExpiredObject.class, exirationDateFilter, this.configuration.getPersistenceManagerRemoveCount());
this.persistenceManager.remove(joinWithComma(getExpiredObjOu(), getClientApiDn()), ExpiredObject.class, exirationDateFilter, this.configuration.getPersistenceManagerRemoveCount());
logger.debug("Removed all expired_objects successfully. ");
return true;
} catch (Exception e) {
Expand All @@ -319,19 +319,19 @@ public boolean deleteAllExpiredObjects() {
}

public String getDnForRp(String rpId) {
return "jansId=" + joinWithComa(rpId, getRpOu(), getClientApiDn());
return "jansId=" + joinWithComma(rpId, getRpOu(), getClientApiDn());
}

public String getDnForExpiredObj(String rpId) {
return "rpId=" + joinWithComa(rpId, getExpiredObjOu(), getClientApiDn());
return "rpId=" + joinWithComma(rpId, getExpiredObjOu(), getClientApiDn());
}

public String ou(String ouName) {
return String.format("ou=%s", ouName);
}

private String getClientApiDn() {
return joinWithComa(ou("client-api"), BASE_DN);
return joinWithComma(ou("client-api"), BASE_DN);
}

private String getRpOu() {
Expand Down

0 comments on commit 6df2e42

Please sign in to comment.