This is an automated email from the ASF dual-hosted git repository.

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

commit 73acc99fd211585939a89555c02795f24887ecbe
Author: mgeiss <[email protected]>
AuthorDate: Thu Jul 6 12:01:16 2017 +0200

    added message for MQ
---
 .../io/mifos/reporting/api/v1/EventConstants.java  |  2 ++
 .../reporting/service/ReportingConfiguration.java  |  4 +++
 .../service/rest/ReportingRestController.java      | 32 +++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/api/src/main/java/io/mifos/reporting/api/v1/EventConstants.java 
b/api/src/main/java/io/mifos/reporting/api/v1/EventConstants.java
index a2bbc3f..a80adec 100644
--- a/api/src/main/java/io/mifos/reporting/api/v1/EventConstants.java
+++ b/api/src/main/java/io/mifos/reporting/api/v1/EventConstants.java
@@ -21,4 +21,6 @@ public interface EventConstants {
   String DESTINATION = "reporting-v1";
   String SELECTOR_NAME = "operation";
 
+  String INITIALIZE = "initialize";
+  String SELECTOR_INITIALIZE = SELECTOR_NAME + " = '" + INITIALIZE + "'";
 }
diff --git 
a/service/src/main/java/io/mifos/reporting/service/ReportingConfiguration.java 
b/service/src/main/java/io/mifos/reporting/service/ReportingConfiguration.java
index 6bf4fed..e3b03c9 100644
--- 
a/service/src/main/java/io/mifos/reporting/service/ReportingConfiguration.java
+++ 
b/service/src/main/java/io/mifos/reporting/service/ReportingConfiguration.java
@@ -17,6 +17,8 @@ package io.mifos.reporting.service;
 
 import io.mifos.anubis.config.EnableAnubis;
 import io.mifos.core.cassandra.config.EnableCassandra;
+import io.mifos.core.command.config.EnableCommandProcessing;
+import io.mifos.core.lang.config.EnableApplicationName;
 import io.mifos.core.lang.config.EnableServiceException;
 import io.mifos.core.lang.config.EnableTenantContext;
 import io.mifos.core.mariadb.config.EnableMariaDB;
@@ -34,6 +36,8 @@ import 
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 @Configuration
 @EnableAutoConfiguration
 @EnableDiscoveryClient
+@EnableApplicationName
+@EnableCommandProcessing
 @EnableTenantContext
 @EnableCassandra
 @EnableMariaDB
diff --git 
a/service/src/main/java/io/mifos/reporting/service/rest/ReportingRestController.java
 
b/service/src/main/java/io/mifos/reporting/service/rest/ReportingRestController.java
index a23e355..dc5c02f 100644
--- 
a/service/src/main/java/io/mifos/reporting/service/rest/ReportingRestController.java
+++ 
b/service/src/main/java/io/mifos/reporting/service/rest/ReportingRestController.java
@@ -15,9 +15,15 @@
  */
 package io.mifos.reporting.service.rest;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
 import io.mifos.anubis.annotation.AcceptedTokenType;
 import io.mifos.anubis.annotation.Permittable;
+import io.mifos.core.lang.ApplicationName;
 import io.mifos.core.lang.ServiceException;
+import io.mifos.core.lang.TenantContextHolder;
+import io.mifos.core.lang.config.TenantHeaderFilter;
+import io.mifos.reporting.api.v1.EventConstants;
 import io.mifos.reporting.api.v1.PermittableGroupIds;
 import io.mifos.reporting.api.v1.domain.ReportDefinition;
 import io.mifos.reporting.api.v1.domain.ReportPage;
@@ -30,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.jms.core.JmsTemplate;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -48,13 +55,19 @@ public class ReportingRestController {
 
   private final Logger logger;
   private final ReportSpecificationProvider reportSpecificationProvider;
+  private final ApplicationName applicationName;
+  private final JmsTemplate jmsTemplate;
 
   @Autowired
   public ReportingRestController(@Qualifier(ServiceConstants.LOGGER_NAME) 
final Logger logger,
-                                 final ReportSpecificationProvider 
reportSpecificationProvider) {
+                                 final ReportSpecificationProvider 
reportSpecificationProvider,
+                                 final ApplicationName applicationName,
+                                 final JmsTemplate jmsTemplate) {
     super();
     this.logger = logger;
     this.reportSpecificationProvider = reportSpecificationProvider;
+    this.applicationName = applicationName;
+    this.jmsTemplate = jmsTemplate;
   }
 
   @Permittable(value = AcceptedTokenType.SYSTEM)
@@ -67,6 +80,23 @@ public class ReportingRestController {
   public
   @ResponseBody
   ResponseEntity<Void> initialize() {
+    final Gson gson = new GsonBuilder().create();
+    this.jmsTemplate.convertAndSend(
+        gson.toJson(this.applicationName.getVersionString()),
+        message -> {
+          if (TenantContextHolder.identifier().isPresent()) {
+            message.setStringProperty(
+                TenantHeaderFilter.TENANT_HEADER,
+                TenantContextHolder.checkedGetIdentifier());
+          }
+          message.setStringProperty(
+              EventConstants.SELECTOR_NAME,
+              EventConstants.INITIALIZE
+          );
+          return message;
+        }
+    );
+
     return ResponseEntity.ok().build();
   }
 

Reply via email to