Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-client-api):minor observations PR1319 - typo transalation code-improvement #1806

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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 @@ -199,16 +199,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