You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by am...@apache.org on 2017/07/07 14:54:29 UTC

incubator-unomi git commit: UNOMI-102 : Recurrent to Oneshot export update

Repository: incubator-unomi
Updated Branches:
  refs/heads/master efc4a9ce3 -> cf27900b9


UNOMI-102 : Recurrent to Oneshot export update


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/cf27900b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/cf27900b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/cf27900b

Branch: refs/heads/master
Commit: cf27900b9dd0d946d2a05fbfe970cc147a736014
Parents: efc4a9c
Author: Abdelkader Midani <am...@apache.org>
Authored: Fri Jul 7 16:53:41 2017 +0200
Committer: Abdelkader Midani <am...@apache.org>
Committed: Fri Jul 7 16:54:04 2017 +0200

----------------------------------------------------------------------
 .../ExportConfigurationServiceEndPoint.java     | 38 +++++++++-----------
 .../ImportConfigurationServiceEndPoint.java     | 35 +++++++++---------
 2 files changed, 34 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cf27900b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
index 35d4f34..9e52c05 100644
--- a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
+++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java
@@ -24,7 +24,6 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.unomi.router.api.ExportConfiguration;
-import org.apache.unomi.router.api.RouterConstants;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.apache.unomi.router.api.services.ProfileExportService;
 import org.slf4j.Logger;
@@ -76,28 +75,26 @@ public class ExportConfigurationServiceEndPoint extends AbstractConfigurationSer
      */
     public ExportConfiguration saveConfiguration(ExportConfiguration exportConfiguration) {
         ExportConfiguration exportConfigSaved = configurationService.save(exportConfiguration);
-        if (RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT.equals(exportConfigSaved.getConfigType())) {
-            CloseableHttpClient httpClient = HttpClients.createDefault();
-            try {
-                HttpPut httpPut = new HttpPut("http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/exportConfigAdmin");
-                StringEntity input = new StringEntity(new ObjectMapper().writeValueAsString(exportConfigSaved));
-                input.setContentType(MediaType.APPLICATION_JSON);
-                httpPut.setEntity(input);
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        try {
+            HttpPut httpPut = new HttpPut("http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/exportConfigAdmin");
+            StringEntity input = new StringEntity(new ObjectMapper().writeValueAsString(exportConfigSaved));
+            input.setContentType(MediaType.APPLICATION_JSON);
+            httpPut.setEntity(input);
 
-                HttpResponse response = httpClient.execute(httpPut);
+            HttpResponse response = httpClient.execute(httpPut);
 
-                if (response.getStatusLine().getStatusCode() != 200) {
-                    logger.error("Failed to update the running config: Please check the acceccibilty to the URI: \n{}",
-                            "http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
-                    logger.error("HTTP Status code returned {}", response.getStatusLine().getStatusCode());
-                    throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
-                }
-            } catch (Exception e) {
-                logger.warn("Unable to update Camel route [{}]", exportConfiguration.getItemId());
-                e.printStackTrace();
+            if (response.getStatusLine().getStatusCode() != 200) {
+                logger.error("Failed to update the running config: Please check the acceccibilty to the URI: \n{}",
+                        "http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
+                logger.error("HTTP Status code returned {}", response.getStatusLine().getStatusCode());
                 throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
-
             }
+        } catch (Exception e) {
+            logger.warn("Unable to update Camel route [{}]", exportConfiguration.getItemId());
+            e.printStackTrace();
+            throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
+
         }
 
         return exportConfigSaved;
@@ -114,8 +111,7 @@ public class ExportConfigurationServiceEndPoint extends AbstractConfigurationSer
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces("text/csv")
     public Response processOneshotImportConfigurationCSV(ExportConfiguration exportConfiguration) {
-        ExportConfiguration exportConfigSaved = configurationService.save(exportConfiguration);
-        String csvContent = profileExportService.extractProfilesBySegment(exportConfigSaved);
+        String csvContent = profileExportService.extractProfilesBySegment(exportConfiguration);
         Response.ResponseBuilder response = Response.ok(csvContent);
         response.header("Content-Disposition",
                 "attachment; filename=Profiles_export_" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date()) + ".csv");

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cf27900b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
----------------------------------------------------------------------
diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
index dec61e0..0f8c633 100644
--- a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
+++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ImportConfigurationServiceEndPoint.java
@@ -72,29 +72,28 @@ public class ImportConfigurationServiceEndPoint extends AbstractConfigurationSer
      */
     public ImportConfiguration saveConfiguration(ImportConfiguration importConfiguration) {
         ImportConfiguration importConfigSaved = configurationService.save(importConfiguration);
-        if (RouterConstants.IMPORT_EXPORT_CONFIG_TYPE_RECURRENT.equals(importConfigSaved.getConfigType())) {
-            CloseableHttpClient httpClient = HttpClients.createDefault();
-            try {
-                HttpPut httpPut = new HttpPut("http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
-                StringEntity input = new StringEntity(new ObjectMapper().writeValueAsString(importConfigSaved));
-                input.setContentType(MediaType.APPLICATION_JSON);
-                httpPut.setEntity(input);
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        try {
+            HttpPut httpPut = new HttpPut("http://localhost:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
+            StringEntity input = new StringEntity(new ObjectMapper().writeValueAsString(importConfigSaved));
+            input.setContentType(MediaType.APPLICATION_JSON);
+            httpPut.setEntity(input);
 
-                HttpResponse response = httpClient.execute(httpPut);
+            HttpResponse response = httpClient.execute(httpPut);
 
-                if (response.getStatusLine().getStatusCode() != 200) {
-                    logger.error("Failed to update the running config: Please check the acceccibilty to the URI: \n{}",
-                            "http://localhost234:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
-                    logger.error("HTTP Status code returned {}", response.getStatusLine().getStatusCode());
-                    throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
-                }
-            } catch (Exception e) {
-                logger.warn("Unable to update Camel route [{}]", importConfiguration.getItemId());
-                e.printStackTrace();
+            if (response.getStatusLine().getStatusCode() != 200) {
+                logger.error("Failed to update the running config: Please check the acceccibilty to the URI: \n{}",
+                        "http://localhost234:" + configSharingService.getProperty("internalServerPort") + "/configUpdate/importConfigAdmin");
+                logger.error("HTTP Status code returned {}", response.getStatusLine().getStatusCode());
                 throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
-
             }
+        } catch (Exception e) {
+            logger.warn("Unable to update Camel route [{}]", importConfiguration.getItemId());
+            e.printStackTrace();
+            throw new PartialContentException("RUNNING_CONFIG_UPDATE_FAILED");
+
         }
+
         return importConfigSaved;
     }