fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-provisioner] 35/50: Re-ordering initialization calls.
Date Mon, 22 Jan 2018 15:16:33 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-provisioner.git

commit d3679115b96aadb1627b20c31c367f3ec9ccff97
Author: myrle-krantz <mkrantz@mifos.org>
AuthorDate: Thu Jun 8 18:52:23 2017 +0200

    Re-ordering initialization calls.
---
 .../internal/service/TenantApplicationService.java | 12 +++++------
 .../service/applications/AnubisInitializer.java    | 23 +++++++++++++++-------
 .../applications/IdentityServiceInitializer.java   |  3 +++
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/service/src/main/java/io/mifos/provisioner/internal/service/TenantApplicationService.java
b/service/src/main/java/io/mifos/provisioner/internal/service/TenantApplicationService.java
index cc073b4..2e45d9c 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/service/TenantApplicationService.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/service/TenantApplicationService.java
@@ -126,12 +126,7 @@ public class TenantApplicationService {
 
 
     applicationNameToUriPairs.forEach(x -> {
-      final ApplicationSignatureSet applicationSignatureSet = anubisInitializer.initializeAnubis(
-              tenantIdentifier,
-              x.name,
-              x.uri,
-              identityManagerSignatureSet.getTimestamp(),
-              identityManagerSignatureSet.getIdentityManagerSignature());
+      final ApplicationSignatureSet applicationSignatureSet = anubisInitializer.createSignatureSet(tenantIdentifier,
x.name, x.uri, identityManagerSignatureSet.getTimestamp(), identityManagerSignatureSet.getIdentityManagerSignature());
 
       identityServiceInitializer.postApplicationDetails(
               tenantIdentifier,
@@ -140,6 +135,11 @@ public class TenantApplicationService {
               x.name,
               x.uri,
               applicationSignatureSet);
+
+      //InitializeResources on the service being added should occur last, for two reasons:
+      // 1.) When the initialization event is put on the queue for this app/tenant combo,
the app is fully ready for business.
+      // 2.) If the app depeneds on the provisioning of identitypermissions in its initialization,
those resources will be there.
+      anubisInitializer.initializeResources(tenantIdentifier, x.name, x.uri);
     });
   }
 
diff --git a/service/src/main/java/io/mifos/provisioner/internal/service/applications/AnubisInitializer.java
b/service/src/main/java/io/mifos/provisioner/internal/service/applications/AnubisInitializer.java
index 657923d..cde9c5d 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/service/applications/AnubisInitializer.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/service/applications/AnubisInitializer.java
@@ -42,18 +42,27 @@ public class AnubisInitializer {
     this.logger = logger;
   }
 
-  public ApplicationSignatureSet initializeAnubis(final @Nonnull String tenantIdentifier,
-                                                  final @Nonnull String applicationName,
-                                                  final @Nonnull String uri,
-                                                  final @Nonnull String keyTimestamp,
-                                                  final @Nonnull Signature signature) {
+  public void initializeResources(@Nonnull String tenantIdentifier, @Nonnull String applicationName,
@Nonnull String uri) {
     try (final AutoCloseable ignored
-                 = this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier,
applicationName))
+                  = this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier,
applicationName))
     {
       final Anubis anubis = this.applicationCallContextProvider.getApplication(Anubis.class,
uri);
       anubis.initializeResources();
+      logger.info("Anubis initializeResources for tenant '{}' and application '{}' succeeded.",
+              tenantIdentifier, applicationName);
+
+    } catch (final Exception e) {
+      throw new IllegalStateException(e);
+    }
+  }
+
+  public ApplicationSignatureSet createSignatureSet(@Nonnull String tenantIdentifier, @Nonnull
String applicationName, @Nonnull String uri, @Nonnull String keyTimestamp, @Nonnull Signature
signature) {
+    try (final AutoCloseable ignored
+                 = this.applicationCallContextProvider.getApplicationCallContext(tenantIdentifier,
applicationName))
+    {
+      final Anubis anubis = this.applicationCallContextProvider.getApplication(Anubis.class,
uri);
       final ApplicationSignatureSet applicationSignatureSet = anubis.createSignatureSet(keyTimestamp,
signature);
-      logger.info("Anubis initialization for io.mifos.provisioner.tenant '{}' and application
'{}' succeeded with signature set '{}'.",
+      logger.info("Anubis createSignatureSet for tenant '{}' and application '{}' succeeded
with signature set '{}'.",
               tenantIdentifier, applicationName, applicationSignatureSet);
       return applicationSignatureSet;
 
diff --git a/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
b/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
index bca9b4e..8c62879 100644
--- a/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
+++ b/service/src/main/java/io/mifos/provisioner/internal/service/applications/IdentityServiceInitializer.java
@@ -170,6 +170,7 @@ public class IdentityServiceInitializer {
     final List<ApplicationPermission> applicationPermissionRequirements;
     try (final AutoCloseable ignored = applicationCallContextProvider.getApplicationCallGuestContext(tenantIdentifier))
{
       applicationPermissionRequirements = getApplicationPermissionRequirements(applicationName,
applicationUri);
+      logger.info("Application permission requirements for {} contain {}.", applicationName,
applicationPermissionRequirements);
 
     } catch (final Exception e) {
       throw new IllegalStateException(e);
@@ -286,6 +287,8 @@ public class IdentityServiceInitializer {
           final @Nonnull ApplicationPermission applicationPermission) {
     try {
       identityService.createApplicationPermission(applicationName, applicationPermission.getPermission());
+      logger.info("Application permission '{}.{}' created.",
+              applicationName, applicationPermission.getPermission().getPermittableEndpointGroupIdentifier());
     }
     catch (final ApplicationPermissionAlreadyExistsException alreadyExistsException)
     {

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message