Skip to content
Snippets Groups Projects
Commit b23dbc44 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6495 reorder methods

parent 92d356f0
No related branches found
No related tags found
No related merge requests found
...@@ -43,14 +43,6 @@ class KeycloakRealmService { ...@@ -43,14 +43,6 @@ class KeycloakRealmService {
private final KeycloakGenericRemoteService keycloakGenericRemoteService; private final KeycloakGenericRemoteService keycloakGenericRemoteService;
void createRealm(OzgCloudKeycloakRealmSpec realm, String realmName) {
Optional.of(realm)
.map(mapper::map)
.map(realmRepresentation -> addRealmName(realmRepresentation, realmName))
.filter(realmRepresentation -> !keycloakGenericRemoteService.realmExists(realmName))
.ifPresent(remoteService::createRealm);
}
public void createOrUpdateRealm(OzgCloudKeycloakRealmSpec realm, String realmName) { public void createOrUpdateRealm(OzgCloudKeycloakRealmSpec realm, String realmName) {
keycloakGenericRemoteService.getRealmRepresentation(realmName) keycloakGenericRemoteService.getRealmRepresentation(realmName)
.ifPresentOrElse(existingRealm -> updateRealm(existingRealm, realm), .ifPresentOrElse(existingRealm -> updateRealm(existingRealm, realm),
...@@ -59,7 +51,6 @@ class KeycloakRealmService { ...@@ -59,7 +51,6 @@ class KeycloakRealmService {
} }
void updateRealm(RealmRepresentation existingRealm, OzgCloudKeycloakRealmSpec spec) { void updateRealm(RealmRepresentation existingRealm, OzgCloudKeycloakRealmSpec spec) {
try { try {
LOG.debug("{}: Updating existing realm...", existingRealm); LOG.debug("{}: Updating existing realm...", existingRealm);
var realmRepresentation = mapper.update(existingRealm, spec); var realmRepresentation = mapper.update(existingRealm, spec);
...@@ -68,7 +59,14 @@ class KeycloakRealmService { ...@@ -68,7 +59,14 @@ class KeycloakRealmService {
LOG.warn(existingRealm + ": Updating existing realm failed: ", e); LOG.warn(existingRealm + ": Updating existing realm failed: ", e);
throw e; throw e;
} }
}
void createRealm(OzgCloudKeycloakRealmSpec realm, String realmName) {
Optional.of(realm)
.map(mapper::map)
.map(realmRepresentation -> addRealmName(realmRepresentation, realmName))
.filter(realmRepresentation -> !keycloakGenericRemoteService.realmExists(realmName))
.ifPresent(remoteService::createRealm);
} }
void addOrUpdateRealmRoles(OzgCloudKeycloakRealmSpec spec, String realm) { void addOrUpdateRealmRoles(OzgCloudKeycloakRealmSpec spec, String realm) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment