javadoc related cleanup, pom fixes 88/488/1
authorSerban Jora <sj2381@att.com>
Fri, 12 Jan 2018 17:29:50 +0000 (12:29 -0500)
committerSerban Jora <sj2381@att.com>
Fri, 12 Jan 2018 17:43:06 +0000 (12:43 -0500)
Change-Id: I2a53aa01fd97ac67be05bb92142be011e760ba4f
Signed-off-by: Serban Jora <sj2381@att.com>
12 files changed:
.mvn/jvm.config [deleted file]
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/adapter/onap/ONAP.java
gateway/src/main/java/org/acumos/federation/gateway/common/API.java
gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/service/CatalogService.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationClient.java
gateway/src/main/java/org/acumos/federation/gateway/util/Errors.java
gateway/src/main/java/org/acumos/federation/gateway/util/Utils.java
gateway/src/test/java/org/acumos/federation/gateway/test/PeerGatewayTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/TaskTest.java [new file with mode: 0644]
pom.xml

diff --git a/.mvn/jvm.config b/.mvn/jvm.config
deleted file mode 100644 (file)
index 3311ef1..0000000
+++ /dev/null
@@ -1 +0,0 @@
- -Djavax.net.ssl.trustStore=gateway/src/test/resources/acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom
index 3e7404e..3acfd2f 100644 (file)
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.5.4.RELEASE</version>
+    <!-- silence warning about parent relative path -->
+    <relativePath />
        </parent>
-       <!--
-       <parent>
-               <groupId>org.springframework.boot</groupId>
-               <artifactId>spring-boot-starter-parent</artifactId>
-               <version>1.5.4.RELEASE</version>
-       </parent>
-       -->
 
        <properties>
                <encoding>UTF-8</encoding>
        </repositories>
 
        <dependencies>
+               <dependency>
+                       <groupId>org.acumos</groupId>
+                       <artifactId>acumos-nexus-client</artifactId>
+                       <version>1.0.0-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.acumos.common-dataservice</groupId>
+                       <artifactId>cmn-data-svc-client</artifactId>
+                       <version>1.10.1-SNAPSHOT</version>
+                       <!-- <version>1.12.0-SNAPSHOT</version> -->
+               </dependency>
                <dependency>
              <groupId>org.json</groupId>
              <artifactId>json</artifactId>
                        <artifactId>logback-core</artifactId>
                        <version>${logback.version}</version>
                </dependency>
-               <!--
-               <dependency>
-                       <groupId>org.acumos</groupId>
-                       <artifactId>acumos-docker-client</artifactId>
-                       <version>1.0.0-SNAPSHOT</version>
-               </dependency>
-               -->
-               <dependency>
-                       <groupId>org.acumos</groupId>
-                       <artifactId>acumos-nexus-client</artifactId>
-                       <version>1.10.9</version>
-               </dependency>
                <dependency>
        <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
                        <artifactId>spring-boot-starter-web</artifactId>
                        <version>${spring.boot.starter.web.version}</version>
                </dependency>
-               
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-test</artifactId>
-                       <version>${spring.boot.starter.test.version}</version>
-                       <scope>test</scope>
-               </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-configuration-processor</artifactId>
        <artifactId>spring-shell</artifactId>
        <version>1.2.0.RELEASE</version>
                </dependency>
-               <dependency>
-                       <groupId>org.acumos.common-dataservice</groupId>
-                       <artifactId>cmn-data-svc-client</artifactId>
-                       <version>1.9.0-SNAPSHOT</version>
-               </dependency>
                <dependency>
                        <groupId>io.springfox</groupId>
                        <artifactId>springfox-swagger2</artifactId>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
-                       <version>1.5.3.RELEASE</version>
+                       <version>${spring.boot.starter.test.version}</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>
+       <groupId>org.aspectj</groupId>
+       <artifactId>aspectjweaver</artifactId>
+       <version>1.8.13</version>
+                       <scope>test</scope>
+               </dependency>
+
        </dependencies>
        
        <build>
                                                                </assembly>
                                                                <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
-                                                                       <shell>cd /maven; java -Djavax.net.debug=ssl -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}</shell>
+                                                                       <shell><![CDATA[        cd /maven; java -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}]]></shell>
                                                                </cmd>
                                                        </build>
                                                </image>
                                                                </assembly>
                                                                <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
-                                                                       <shell>cd /maven; java -cp ${project.artifactId}-${project.version}.${project.packaging}:${project.artifactId}-${project.version}-tests.${project.packaging}:/libs/* -Djavax.net.debug=ssl:handshake -Djavax.net.ssl.trustStore=/app/certs/acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.PropertiesLauncher</shell>
+                                                                       <shell><![CDATA[        cd /maven; java -cp ${project.artifactId}-${project.version}.${project.packaging}:${project.artifactId}-${project.version}-tests.${project.packaging}:/libs/* -Djavax.net.ssl.trustStore=/app/certs/acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.PropertiesLauncher]]></shell>
 
 <!--
-                                                                       <shell>cd /maven; java -cp ${project.artifactId}-${project.version}.${project.packaging}:${project.artifactId}-${project.version}-tests.${project.packaging}:/libs/* -Djavax.net.debug=ssl:handshake -Djavax.net.ssl.trustStore=acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.PropertiesLauncher</shell>
+                                                                       <shell><![CDATA[        cd /maven; java -cp ${project.artifactId}-${project.version}.${project.packaging}:${project.artifactId}-${project.version}-tests.${project.packaging}:/libs/* -Djavax.net.ssl.trustStore=acumosTrustStore.jks -Djavax.net.ssl.trustStorePassword=acumos -Djava.security.egd=file:/dev/./urandom org.springframework.boot.loader.PropertiesLauncher]]></shell>
 -->
                                                                </cmd>
                                                        </build>
index 10255a0..ae29c40 100644 (file)
 package org.acumos.federation.gateway.adapter.onap;
 
 import java.net.URI;
-
-import java.util.List;
+import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.UUID;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpClientErrorException;
-
-import org.springframework.stereotype.Component;
-import org.springframework.context.annotation.Scope;
-import org.springframework.context.annotation.Conditional;
-import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.beans.factory.BeanInitializationException;
-import org.springframework.context.event.EventListener;
-import org.springframework.core.task.TaskExecutor;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import org.acumos.federation.gateway.adapter.onap.ONAPAdapterCondition;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
-import org.acumos.federation.gateway.service.impl.Clients;
-import org.acumos.federation.gateway.service.impl.FederationClient;
-
-import org.acumos.cds.domain.MLPPeer;
 import org.acumos.cds.domain.MLPArtifact;
+import org.acumos.cds.domain.MLPPeer;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
-
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC;
-import org.acumos.federation.gateway.adapter.onap.sdc.ASDCException;
-import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.AssetType;
-import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.ArtifactType;
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.ArtifactGroupType;
+import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.ArtifactType;
+import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.AssetType;
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.LifecycleState;
-import org.acumos.federation.gateway.util.MapBuilder;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-
+import org.acumos.federation.gateway.adapter.onap.sdc.ASDCException;
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
+import org.acumos.federation.gateway.service.impl.Clients;
+import org.acumos.federation.gateway.service.impl.FederationClient;
 import org.apache.commons.io.IOUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.http.HttpStatus;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpClientErrorException;
 
 
 @Component("onap")
@@ -225,9 +214,16 @@ public class ONAP {
                }
                
                /**
-                * There is no such thing as updating an asset in the ASDC REST API, we can only update the artifacts ..
+                * There is no such thing as updating an asset in the ASDC REST API, we can only
+                * update the artifacts ..
+                * 
+                * @param theAssetInfo
+                * Asset info
+                * @param theSolution
+                * solution
+                * @return SDC Asset info
                 */
-               public JSONObject updateSdcAsset(JSONObject theAssetInfo, MLPSolution theSolution) throws Exception {
+               public JSONObject updateSdcAsset(JSONObject theAssetInfo, MLPSolution theSolution) 
                        logger.info(EELFLoggerDelegate.debugLogger, "Updating ONAP SDC VF " + theAssetInfo.optString("uuid") + " for Acumosb solution " + theSolution);
                        return theAssetInfo;
                }
@@ -276,7 +272,7 @@ public class ONAP {
                        //acumos artifacts that do not exist locally need to be added
                        List<MLPArtifact>                                               newArtifacts = new LinkedList<MLPArtifact>();
                        Map<MLPArtifact, JSONObject>    updatedArtifacts = new HashMap<MLPArtifact, JSONObject>();
-                       List<JSONObject>                                                        oldArtifacts = new LinkedList<JSONObject>();
+                       //List<JSONObject> oldArtifacts = new LinkedList<JSONObject>();
 
                        logger.info(EELFLoggerDelegate.debugLogger, "Acumos artifacts: " + acumosArtifacts);
                        logger.info(EELFLoggerDelegate.debugLogger, "ONAP SDC artifacts: " + sdcArtifacts);
@@ -404,9 +400,11 @@ public class ONAP {
                }
 
                //only safe to call if 'same' returned true
+               /*
                private boolean sameVersion(MLPArtifact theAcumosArtifact, JSONObject theSDCArtifact) {
                        return theSDCArtifact.optString("artifactDescription","@").split("@")[1].equals(theAcumosArtifact.getVersion());
                }
+               */
 
                private boolean isAcumosOriginated(JSONObject theSDCArtifact) {
                        boolean isAcumos = theSDCArtifact.optString("artifactType").equals(ArtifactType.OTHER.toString()) &&
index 19e372c..7d30a4b 100644 (file)
@@ -26,29 +26,25 @@ import java.util.Collection;
 import org.springframework.web.util.UriComponentsBuilder;
 
 /**
- * Specifies the REST API that makes up the federation interface.
- * I could add the expected return type and the doc here too.
+ * Specifies the REST API that makes up the federation interface. I could add
+ * the expected return type and the doc here too.
  */
 public enum API {
 
-       SOLUTIONS(Paths.SOLUTIONS, Queries.SOLUTIONS),
-       SOLUTION_DETAIL(Paths.SOLUTION_DETAILS),
-       SOLUTION_REVISIONS(Paths.SOLUTION_REVISIONS),
-       SOLUTION_REVISION_DETAILS(Paths.SOLUTION_REVISION_DETAILS),
-       SOLUTION_REVISION_ARTIFACTS(Paths.SOLUTION_REVISION_ARTIFACTS),
-       ARTIFACT_DETAILS(Paths.ARTIFACT_DETAILS),
-       ARTIFACT_DOWNLOAD(Paths.ARTIFACT_DOWNLOAD),
-       PEERS(Paths.PEERS);
+       SOLUTIONS(Paths.SOLUTIONS, Queries.SOLUTIONS), SOLUTION_DETAIL(Paths.SOLUTION_DETAILS), SOLUTION_REVISIONS(
+                       Paths.SOLUTION_REVISIONS), SOLUTION_REVISION_DETAILS(
+                                       Paths.SOLUTION_REVISION_DETAILS), SOLUTION_REVISION_ARTIFACTS(
+                                                       Paths.SOLUTION_REVISION_ARTIFACTS), ARTIFACT_DETAILS(
+                                                                       Paths.ARTIFACT_DETAILS), ARTIFACT_DOWNLOAD(
+                                                                                       Paths.ARTIFACT_DOWNLOAD), PEERS(Paths.PEERS);
 
-
-       private String          path;
-       private String[]        query;
-       
+       private String path;
+       private String[] query;
 
        API(String thePath) {
                this.path = thePath;
        }
-       
+
        API(String thePath, String[] theQueryParams) {
                this.path = thePath;
                this.query = theQueryParams;
@@ -62,15 +58,15 @@ public enum API {
                return this.query;
        }
 
-       public Map<String,?> queryParams(Map<String,?> theParams) {
-               for (String queryParam: this.query) {
+       public Map<String, ?> queryParams(Map<String, ?> theParams) {
+               for (String queryParam : this.query) {
                        if (!theParams.containsKey(queryParam)) {
                                theParams.put(queryParam, null);
                        }
                }
                return theParams;
        }
-       
+
        public String toString() {
                return this.path;
        }
@@ -78,11 +74,13 @@ public enum API {
        /**
         * Prepares a 'full' URI for this API call. It will contain all query
         * parameters.
+        * 
+        * @param theHttpUrl
+        *            URL
+        * @return URI
         */
        public UriComponentsBuilder buildUri(String theHttpUrl) {
-               UriComponentsBuilder builder =
-                               UriComponentsBuilder.fromHttpUrl(theHttpUrl)
-                                                                                                               .path(this.path);
+               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(theHttpUrl).path(this.path);
                if (this.query != null) {
                        for (String queryParam : this.query) {
                                builder.queryParam(queryParam, "{" + queryParam + "}");
@@ -94,11 +92,15 @@ public enum API {
        /**
         * Prepares a URI containing only the query param present in the given
         * collection.
+        * 
+        * @param theHttpUrl
+        *            URL
+        * @param theParams
+        *            parameters
+        * @return URI
         */
        public UriComponentsBuilder buildUri(String theHttpUrl, Collection<String> theParams) {
-               UriComponentsBuilder builder =
-                               UriComponentsBuilder.fromHttpUrl(theHttpUrl)
-                                                                                                               .path(this.path);
+               UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(theHttpUrl).path(this.path);
                if (this.query != null) {
                        for (String queryParam : this.query) {
                                if (theParams.contains(queryParam)) {
@@ -108,45 +110,52 @@ public enum API {
                }
                return builder;
        }
-       /* the params include both path and query params.
+
+       /*
+        * the params include both path and query params.
         */
-       public URI buildUri(String theHttpUrl, Map<String,?> theParams) {
+       public URI buildUri(String theHttpUrl, Map<String, ?> theParams) {
                return buildUri(theHttpUrl, theParams.keySet()).buildAndExpand(theParams).encode().toUri();
        }
 
        /**
         * Order based version. All query params must be present.
+        * 
+        * @param theHttpUrl
+        *            URL
+        * @param theParams
+        *            Parameters
+        * @return URI
         */
        public URI buildUri(String theHttpUrl, String... theParams) {
                return buildUri(theHttpUrl).buildAndExpand(theParams).encode().toUri();
        }
 
        public static class Paths {
-               
-    public static final String SOLUTIONS = "/solutions";
-    public static final String SOLUTION_DETAILS = "/solutions/{solutionId}";
-    
-    public static final String SOLUTION_REVISIONS = "/solutions/{solutionId}/revisions";
-    public static final String SOLUTION_REVISION_DETAILS = "/solutions/{solutionId}/revisions/{revisionId}";
-    
-    public static final String SOLUTION_REVISION_ARTIFACTS = "/solutions/{solutionId}/revisions/{revisionId}/artifacts";
-    public static final String ARTIFACT_DETAILS = "/artifacts/{artifactId}";
-    public static final String ARTIFACT_DOWNLOAD = "/artifacts/{artifactId}/download";
-    
+
+               public static final String SOLUTIONS = "/solutions";
+               public static final String SOLUTION_DETAILS = "/solutions/{solutionId}";
+
+               public static final String SOLUTION_REVISIONS = "/solutions/{solutionId}/revisions";
+               public static final String SOLUTION_REVISION_DETAILS = "/solutions/{solutionId}/revisions/{revisionId}";
+
+               public static final String SOLUTION_REVISION_ARTIFACTS = "/solutions/{solutionId}/revisions/{revisionId}/artifacts";
+               public static final String ARTIFACT_DETAILS = "/artifacts/{artifactId}";
+               public static final String ARTIFACT_DOWNLOAD = "/artifacts/{artifactId}/download";
+
                public static final String PEERS = "/peers";
-               
-               //public static final String PEER_SUBSCRIBE = "/peer/subscribe";
-               //public static final String PEER_UNSUBSCRIBE = "/peer/unsubscribe";
-       }
 
+               // public static final String PEER_SUBSCRIBE = "/peer/subscribe";
+               // public static final String PEER_UNSUBSCRIBE = "/peer/unsubscribe";
+       }
 
        public static class QueryParameters {
 
-    public static final String SOLUTIONS_SELECTOR = "selector";
+               public static final String SOLUTIONS_SELECTOR = "selector";
        }
 
        public static class Queries {
 
-    public static final String[] SOLUTIONS = { QueryParameters.SOLUTIONS_SELECTOR };
+               public static final String[] SOLUTIONS = { QueryParameters.SOLUTIONS_SELECTOR };
        }
 }
index 2e846df..3b86753 100644 (file)
 package org.acumos.federation.gateway.controller;
 
 import java.net.URI;
-
-import java.util.Map;
 import java.util.List;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.acumos.cds.domain.MLPArtifact;
+import org.acumos.cds.domain.MLPSolution;
+import org.acumos.cds.domain.MLPSolutionRevision;
+import org.acumos.federation.gateway.common.API;
+import org.acumos.federation.gateway.common.JSONTags;
+import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.acumos.federation.gateway.security.Peer;
+import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.ServiceContext;
+import org.acumos.federation.gateway.util.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.Resource;
 import org.springframework.core.io.InputStreamResource;
-import org.springframework.http.HttpEntity;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.util.UriComponentsBuilder;
+import org.springframework.util.Base64Utils;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.util.Base64Utils;
-
-import org.acumos.cds.domain.MLPArtifact;
-import org.acumos.cds.domain.MLPSolution;
-import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.federation.gateway.util.Utils;
-import org.acumos.federation.gateway.common.API;
-import org.acumos.federation.gateway.common.JSONTags;
-import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.CatalogService;
-import org.acumos.federation.gateway.service.ServiceContext;
-import org.acumos.federation.gateway.security.Peer;
 
 import io.swagger.annotations.ApiOperation;
 
@@ -67,72 +61,78 @@ import io.swagger.annotations.ApiOperation;
 @Controller
 @RequestMapping("/")
 public class CatalogController extends AbstractController {
-       
-       
+
        @Autowired
        CatalogService catalogService;
-       
-       
-//     /**
-//      * @param request
-//      *            HttpServletRequest
-//      * @param response
-//      *                      HttpServletResponse
-//      * @return List of Published ML Solutions in JSON format.
-//      */
-//     @CrossOrigin
-//     @ApiOperation(value = "Invoked by Peer Acumos to get a Paginated list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "Page")
-//     @RequestMapping(value = {API.Paths.SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
-//     @ResponseBody
-//     public JsonResponse<RestPageResponse<MLPSolution>> getSolutionsListFromPeer(HttpServletRequest request, HttpServletResponse response,
-//                     @RequestParam("pageNumber") Integer pageNumber, @RequestParam("maxSize") Integer maxSize, 
-//                     @RequestParam(required = false) String sortingOrder, @RequestParam(required = false) String mlpModelTypes) {
-//             JsonResponse<RestPageResponse<MLPSolution>> data = null;
-//             RestPageResponse<MLPSolution> peerCatalogSolutions = null;
-//             try {
-//                     data = new JsonResponse<RestPageResponse<MLPSolution>>();
-//                     peerCatalogSolutions = federationGatewayService.getPeerCatalogSolutions(pageNumber, maxSize, sortingOrder, null);
-//                     if(peerCatalogSolutions != null) {
-//                             data.setResponseBody(peerCatalogSolutions);
-//                             logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: size is {} ");
-//                     }
-//             } catch (Exception e) {
-//                     logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching Solutions for Market Place Catalog", e);
-//             }
-//             return data;
-//     }
-       
+
+       // /**
+       // * @param request
+       // * HttpServletRequest
+       // * @param response
+       // * HttpServletResponse
+       // * @return List of Published ML Solutions in JSON format.
+       // */
+       // @CrossOrigin
+       // @ApiOperation(value = "Invoked by Peer Acumos to get a Paginated list of
+       // Published Solutions from the Catalog of the local Acumos Instance .",
+       // response = MLPSolution.class, responseContainer = "Page")
+       // @RequestMapping(value = {API.Paths.SOLUTIONS}, method = RequestMethod.GET,
+       // produces = APPLICATION_JSON)
+       // @ResponseBody
+       // public JsonResponse<RestPageResponse<MLPSolution>>
+       // getSolutionsListFromPeer(HttpServletRequest request, HttpServletResponse
+       // response,
+       // @RequestParam("pageNumber") Integer pageNumber, @RequestParam("maxSize")
+       // Integer maxSize,
+       // @RequestParam(required = false) String sortingOrder, @RequestParam(required =
+       // false) String mlpModelTypes) {
+       // JsonResponse<RestPageResponse<MLPSolution>> data = null;
+       // RestPageResponse<MLPSolution> peerCatalogSolutions = null;
+       // try {
+       // data = new JsonResponse<RestPageResponse<MLPSolution>>();
+       // peerCatalogSolutions =
+       // federationGatewayService.getPeerCatalogSolutions(pageNumber, maxSize,
+       // sortingOrder, null);
+       // if(peerCatalogSolutions != null) {
+       // data.setResponseBody(peerCatalogSolutions);
+       // logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: size
+       // is {} ");
+       // }
+       // } catch (Exception e) {
+       // logger.error(EELFLoggerDelegate.errorLogger, "Exception Occurred Fetching
+       // Solutions for Market Place Catalog", e);
+       // }
+       // return data;
+       // }
+
        /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+        * @param theHttpResponse
+        *            HttpServletResponse
+        * @param theSelector
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
-//@PreAuthorize("hasAuthority('PEER')"
+       // @PreAuthorize("hasAuthority('PEER')"
        @PreAuthorize("hasAuthority(T(org.acumos.federation.gateway.security.Priviledge).CATALOG_ACCESS)")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "List")
-       @RequestMapping(value = {API.Paths.SOLUTIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = { API.Paths.SOLUTIONS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
        public JsonResponse<List<MLPSolution>> getSolutions(
-                       /* HttpServletRequest theHttpRequest,*/
+                       /* HttpServletRequest theHttpRequest, */
                        HttpServletResponse theHttpResponse,
-                       @RequestParam(value = API.QueryParameters.SOLUTIONS_SELECTOR,
-                                                                               required = false) String theSelector) {
+                       @RequestParam(value = API.QueryParameters.SOLUTIONS_SELECTOR, required = false) String theSelector) {
                JsonResponse<List<MLPSolution>> response = null;
                List<MLPSolution> peerCatalogSolutions = null;
                log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTIONS);
                try {
                        response = new JsonResponse<List<MLPSolution>>();
                        log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: selector " + theSelector);
-                       Map<String,?> selector = null;
-                       if (theSelector != null) 
+                       Map<String, ?> selector = null;
+                       if (theSelector != null)
                                selector = Utils.jsonStringToMap(new String(Base64Utils.decodeFromString(theSelector), "UTF-8"));
-                               
-                       peerCatalogSolutions =
-                                       catalogService.getSolutions(selector, new ControllerContext());
-                       if(peerCatalogSolutions != null) {
+
+                       peerCatalogSolutions = catalogService.getSolutions(selector, new ControllerContext());
+                       if (peerCatalogSolutions != null) {
                                response.setResponseBody(peerCatalogSolutions);
                                response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
@@ -145,7 +145,8 @@ public class CatalogController extends AbstractController {
                        response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
                        response.setStatus(false);
                        theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred fetching Solutions for Market Place Catalog", e);
+                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred fetching Solutions for Market Place Catalog",
+                                       e);
                }
                return response;
        }
@@ -153,26 +154,24 @@ public class CatalogController extends AbstractController {
        @CrossOrigin
        @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list detailed solution information from the Catalog of the local Acumos Instance .", response = MLPSolution.class)
-       @RequestMapping(value = {API.Paths.SOLUTION_DETAILS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = { API.Paths.SOLUTION_DETAILS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
-       public JsonResponse<MLPSolution> getSolutionDetails(
-                       HttpServletResponse theHttpResponse,
-                       @PathVariable(value="solutionId") String theSolutionId) {
+       public JsonResponse<MLPSolution> getSolutionDetails(HttpServletResponse theHttpResponse,
+                       @PathVariable(value = "solutionId") String theSolutionId) {
                JsonResponse<MLPSolution> response = null;
                MLPSolution solution = null;
                log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_DETAILS + ": " + theSolutionId);
                try {
                        response = new JsonResponse<MLPSolution>();
                        solution = catalogService.getSolution(theSolutionId, new ControllerContext());
-                       if(solution != null) {
+                       if (solution != null) {
                                response.setResponseBody(solution);
                                response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
                                response.setStatus(true);
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
                        }
-               }
-               catch (Exception e) {
+               } catch (Exception e) {
                        response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
                        response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
                        response.setStatus(false);
@@ -182,39 +181,35 @@ public class CatalogController extends AbstractController {
                return response;
        }
 
-
-       
        /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+        * @param theSolutionId
+        * @param theHttpResponse
+        *            HttpServletResponse
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
        @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision from the Catalog of the local Acumos Instance .", response = MLPSolutionRevision.class, responseContainer = "List")
-       @RequestMapping(value = {API.Paths.SOLUTION_REVISIONS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = { API.Paths.SOLUTION_REVISIONS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
-       public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(
-                       HttpServletResponse theHttpResponse,
+       public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(HttpServletResponse theHttpResponse,
                        @PathVariable("solutionId") String theSolutionId) {
                JsonResponse<List<MLPSolutionRevision>> response = null;
-               List<MLPSolutionRevision> solutionRevisions= null;
+               List<MLPSolutionRevision> solutionRevisions = null;
                log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_REVISIONS);
                try {
                        response = new JsonResponse<List<MLPSolutionRevision>>();
                        solutionRevisions = catalogService.getSolutionRevisions(theSolutionId, new ControllerContext());
-                       if(solutionRevisions != null) {
+                       if (solutionRevisions != null) {
                                response.setResponseBody(solutionRevisions);
                                response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
                                response.setStatus(true);
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisions: size is {} ", solutionRevisions.size());
+                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisions: size is {} ",
+                                               solutionRevisions.size());
                        }
-               }
-               catch (Exception e) {
+               } catch (Exception e) {
                        response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
                        response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
                        response.setStatus(false);
@@ -224,37 +219,38 @@ public class CatalogController extends AbstractController {
                return response;
        }
 
- /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+       /**
+        * 
+        * @param theSolutionId
+        * @param theRevisionId
+        * @param theHttpResponse
+        *            HttpServletResponse
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
        @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "Invoked by Peer Acumos to get Solution Revision details from the Catalog of the local Acumos Instance .", response = MLPSolutionRevision.class)
-       @RequestMapping(value = {API.Paths.SOLUTION_REVISION_DETAILS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = {
+                       API.Paths.SOLUTION_REVISION_DETAILS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
-       public JsonResponse<MLPSolutionRevision> getSolutionRevisionDetails(
-                       HttpServletResponse theHttpResponse,
-                       @PathVariable("solutionId") String theSolutionId,
-                       @PathVariable("revisionId") String theRevisionId) {
+       public JsonResponse<MLPSolutionRevision> getSolutionRevisionDetails(HttpServletResponse theHttpResponse,
+                       @PathVariable("solutionId") String theSolutionId, @PathVariable("revisionId") String theRevisionId) {
                JsonResponse<MLPSolutionRevision> response = null;
-               MLPSolutionRevision solutionRevision= null;
-               log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_REVISION_DETAILS + "(" + theSolutionId + "," + theRevisionId + ")");
+               MLPSolutionRevision solutionRevision = null;
+               log.debug(EELFLoggerDelegate.debugLogger,
+                               API.Paths.SOLUTION_REVISION_DETAILS + "(" + theSolutionId + "," + theRevisionId + ")");
                try {
                        response = new JsonResponse<MLPSolutionRevision>();
-                       solutionRevision = catalogService.getSolutionRevision(theSolutionId, theRevisionId, new ControllerContext());
-                       if(solutionRevision != null) {
+                       solutionRevision = catalogService.getSolutionRevision(theSolutionId, theRevisionId,
+                                       new ControllerContext());
+                       if (solutionRevision != null) {
                                response.setResponseBody(solutionRevision);
                                response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
                                response.setStatus(true);
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
                        }
-               }
-               catch (Exception e) {
+               } catch (Exception e) {
                        response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
                        response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
                        response.setStatus(false);
@@ -263,41 +259,46 @@ public class CatalogController extends AbstractController {
                }
                return response;
        }
-       
+
        /**
-        * @param request
+        * @param theHttpRequest
         *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+        * @param theHttpResponse
+        *            HttpServletResponse
+        * @param theSolutionId
+        * @param theRevisionId
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
        @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list of Solution Revision Artifacts from the Catalog of the local Acumos Instance .", response = MLPArtifact.class, responseContainer = "List")
-       @RequestMapping(value = {API.Paths.SOLUTION_REVISION_ARTIFACTS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = {
+                       API.Paths.SOLUTION_REVISION_ARTIFACTS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
-       public JsonResponse<List<MLPArtifact>> getSolutionRevisionArtifacts (
-                       HttpServletRequest theHttpRequest,
-                       HttpServletResponse theHttpResponse,
-                       @PathVariable("solutionId") String theSolutionId,
+       public JsonResponse<List<MLPArtifact>> getSolutionRevisionArtifacts(HttpServletRequest theHttpRequest,
+                       HttpServletResponse theHttpResponse, @PathVariable("solutionId") String theSolutionId,
                        @PathVariable("revisionId") String theRevisionId) {
                JsonResponse<List<MLPArtifact>> response = null;
-               List<MLPArtifact> solutionRevisionArtifacts= null;
-               log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_REVISION_ARTIFACTS + "(" + theSolutionId + "," + theRevisionId + ")");
+               List<MLPArtifact> solutionRevisionArtifacts = null;
+               log.debug(EELFLoggerDelegate.debugLogger,
+                               API.Paths.SOLUTION_REVISION_ARTIFACTS + "(" + theSolutionId + "," + theRevisionId + ")");
                try {
                        response = new JsonResponse<List<MLPArtifact>>();
-                       solutionRevisionArtifacts = catalogService.getSolutionRevisionArtifacts(theSolutionId, theRevisionId, new ControllerContext());
-                       if(solutionRevisionArtifacts != null) {
-                               //re-encode the artifact uri
+                       solutionRevisionArtifacts = catalogService.getSolutionRevisionArtifacts(theSolutionId, theRevisionId,
+                                       new ControllerContext());
+                       if (solutionRevisionArtifacts != null) {
+                               // re-encode the artifact uri
                                {
-                                       for (MLPArtifact artifact: solutionRevisionArtifacts) {
-                                               //sooo cumbersome
+                                       for (MLPArtifact artifact : solutionRevisionArtifacts) {
+                                               // sooo cumbersome
                                                URI requestUri = new URI(theHttpRequest.getRequestURL().toString());
-                                               URI artifactUri = 
-                                                       API.ARTIFACT_DOWNLOAD.buildUri(
-                                                               new URI(requestUri.getScheme(), null, requestUri.getHost(), requestUri.getPort(), null, null, null).toString(),
-                                                               artifact.getArtifactId());
-                                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts: content uri " + artifactUri);
+                                               URI artifactUri = API.ARTIFACT_DOWNLOAD
+                                                               .buildUri(
+                                                                               new URI(requestUri.getScheme(), null, requestUri.getHost(),
+                                                                                               requestUri.getPort(), null, null, null).toString(),
+                                                                               artifact.getArtifactId());
+                                               log.debug(EELFLoggerDelegate.debugLogger,
+                                                               "getSolutionRevisionArtifacts: content uri " + artifactUri);
                                                artifact.setUri(artifactUri.toString());
                                        }
                                }
@@ -306,10 +307,10 @@ public class CatalogController extends AbstractController {
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
                                response.setStatus(true);
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts: size is {} ", solutionRevisionArtifacts.size());
+                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts: size is {} ",
+                                               solutionRevisionArtifacts.size());
                        }
-               }
-               catch (Exception e) {
+               } catch (Exception e) {
                        response.setResponseCode(String.valueOf(HttpServletResponse.SC_BAD_REQUEST));
                        response.setResponseDetail(JSONTags.TAG_STATUS_FAILURE);
                        response.setStatus(false);
@@ -318,34 +319,35 @@ public class CatalogController extends AbstractController {
                }
                return response;
        }
-       
+
        /**
-        * @param request
+        * @param theHttpRequest
         *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+        * @param theHttpResponse
+        *            HttpServletResponse
+        * @param theArtifactId
         * @return Archive file of the Artifact for the Solution.
         */
        @CrossOrigin
        @PreAuthorize("hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "API to download the Machine Learning Artifact of the Machine Learning Solution", response = InputStreamResource.class, code = 200)
-       @RequestMapping(value = {API.Paths.ARTIFACT_DOWNLOAD}, method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+       @RequestMapping(value = {
+                       API.Paths.ARTIFACT_DOWNLOAD }, method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
        @ResponseBody
-       public InputStreamResource downloadSolutionArtifact(
-                       HttpServletRequest theHttpRequest,
-                       HttpServletResponse theHttpResponse,
-                       @PathVariable("artifactId") String theArtifactId) {
+       public InputStreamResource downloadSolutionArtifact(HttpServletRequest theHttpRequest,
+                       HttpServletResponse theHttpResponse, @PathVariable("artifactId") String theArtifactId) {
                InputStreamResource inputStreamResource = null;
                try {
-                       inputStreamResource = catalogService.getSolutionRevisionArtifactContent(theArtifactId, new ControllerContext());
+                       inputStreamResource = catalogService.getSolutionRevisionArtifactContent(theArtifactId,
+                                       new ControllerContext());
                        theHttpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
                        theHttpResponse.setHeader("Pragma", "no-cache");
                        theHttpResponse.setHeader("Expires", "0");
                        theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-               }
-               catch (Exception e) {
+               } catch (Exception e) {
                        theHttpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
-                       log.error(EELFLoggerDelegate.errorLogger, "Exception Occurred downloading a artifact for a Solution in Market Place Catalog", e);
+                       log.error(EELFLoggerDelegate.errorLogger,
+                                       "Exception Occurred downloading a artifact for a Solution in Market Place Catalog", e);
                }
                return inputStreamResource;
        }
@@ -353,8 +355,7 @@ public class CatalogController extends AbstractController {
        protected class ControllerContext implements ServiceContext {
 
                public Peer getPeer() {
-                       return (Peer)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+                       return (Peer) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                }
        }
 }
-
index 95747c2..504fe24 100644 (file)
@@ -26,24 +26,21 @@ package org.acumos.federation.gateway.service;
 import java.util.List;
 import java.util.Map;
 
-import org.springframework.core.io.InputStreamResource;
-
 import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.cds.transport.RestPageResponse;
-
+import org.springframework.core.io.InputStreamResource;
 
 /**
- * Handles access to the solutions catalog 
+ * Handles access to the solutions catalog
  */
 public interface CatalogService {
-       
-       
-       /**
+
+       /*
         * 
-        *  API to be invoked by Peer Acumos to fetch the Catalog Solutions Information.
-        *  Pageable Response allowing Peer Acumos's to Specify the Page Numb\er and the maximum results of the Solutions list.
+        * API to be invoked by Peer Acumos to fetch the Catalog Solutions Information.
+        * Pageable Response allowing Peer Acumos's to Specify the Page Numb\er and the
+        * maximum results of the Solutions list.
         * 
         * @param pageNumber : Page Number for the a specific set of the Solution List
         * 
@@ -51,57 +48,79 @@ public interface CatalogService {
         * 
         * @param sortingOrder : Sorting Order Type for the Response
         * 
-        * @param mlpModelTypes : List of the ML Model Types for which Catalog Solutions needs to be returned
+        * @param mlpModelTypes : List of the ML Model Types for which Catalog Solutions
+        * needs to be returned
         * 
         * @return Pageable List of the Catalog Solutions
         */
        /*
-       RestPageResponse<MLPSolution>  getPeerCatalogSolutions(Integer pageNumber, Integer maxSize, String sortingOrder, 
-                       List<String> mlpModelTypes);
-       */
+        * RestPageResponse<MLPSolution> getPeerCatalogSolutions(Integer pageNumber,
+        * Integer maxSize, String sortingOrder, List<String> mlpModelTypes);
+        */
 
        /**
+        * API to be invoked by Peer Acumos to fetch the Catalog Solutions List.
         * 
-        *  API to be invoked by Peer Acumos to fetch the Catalog Solutions List.
-        * 
-        * @param mlpModelTypes : Comma Separate value of the ML Model Types for which Catalog Solutions needs to be returned
-        * 
-        * @return List of the Catalog Solutions for the specified list of query parameters
+        * @param theSelector
+        *            Comma Separate value of the ML Model Types for which Catalog
+        *            Solutions needs to be returned
+        * @param theContext
+        *            ServiceContext
+        * @return List of the Catalog Solutions for the specified list of query
+        *         parameters
         */
-       List<MLPSolution> getSolutions(Map<String,?> theSelector, ServiceContext theContext);
-       
+       List<MLPSolution> getSolutions(Map<String, ?> theSelector, ServiceContext theContext);
 
        /**
+        * @param theSolutionId
+        *            SolutionId for which Solution Needs to be returned
+        * @param theContext
+        *            ServiceContext
+        * @return MLPSolution
         */
        MLPSolution getSolution(String theSolutionId, ServiceContext theContext);
-       
-       
+
        /**
-        * @param solutionId : SolutionId for which Solution Revision Needs to be returned
-        * 
+        * @param theSolutionId
+        *            SolutionId for which Solution Revision Needs to be returned
+        * @param theContext
+        *            ServiceContext
         * @return List of the Solution Revision for the specified solution Id
         */
        List<MLPSolutionRevision> getSolutionRevisions(String theSolutionId, ServiceContext theContext);
-       
+
        /**
+        * @param theSolutionId
+        *            SolutionId for which Solution Revision Needs to be returned
+        * @param theRevisionId
+        *            RevisionId of the Solution
+        * @param theContext
+        *            ServiceContext
+        * @return MLPSolutionRevision
         */
        MLPSolutionRevision getSolutionRevision(String theSolutionId, String theRevisionId, ServiceContext theContext);
 
        /**
-        * @param solutionId : SolutionId for which Solution Revision Artifacts Needs to be returned
-        * 
-        * @param revisionid : RevisionId of the Solution for which List of Artifacts are needed.
-        * 
-        * @return List of the Solution Artifacts for the specified solution Id & revisionId
+        * @param theSolutionId
+        *            SolutionId for which Solution Revision Artifacts Needs to be
+        *            returned
+        * @param theRevisionId
+        *            RevisionId of the Solution for which List of Artifacts are needed.
+        * @param theContext
+        *            ServiceContext
+        * @return List of the Solution Artifacts for the specified solution Id and
+        *         revisionId
         */
-       List<MLPArtifact> getSolutionRevisionArtifacts(String theSolutionId, String theRevisionId, ServiceContext theContext);
-       
-       
-       
+       List<MLPArtifact> getSolutionRevisionArtifacts(String theSolutionId, String theRevisionId,
+                       ServiceContext theContext);
+
        /**
-        * @param artifactId of the File stored in Nexus repository
-        * @return Artifact File for the Machine Learning Solution 
+        * @param theArtifactId
+        *            of the File stored in Nexus repository
+        * @param theContext
+        *            ServiceContext
+        * @return Artifact File for the Machine Learning Solution
         */
        InputStreamResource getSolutionRevisionArtifactContent(String theArtifactId, ServiceContext theContext);
-       
+
 }
index f6a8b85..616b1f7 100644 (file)
 
 package org.acumos.federation.gateway.service.impl;
 
-import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URL;
-import java.util.Date;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
 
-import org.apache.http.client.HttpClient;
-
-import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.cds.domain.MLPArtifact;
+import org.acumos.cds.domain.MLPSolution;
+import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.federation.gateway.common.API;
+import org.acumos.federation.gateway.common.JsonResponse;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.util.Utils;
-
+import org.apache.http.client.HttpClient;
 import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.core.io.Resource;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.core.io.Resource;
-
-//import org.springframework.web.util.UriComponentsBuilder;
-import org.springframework.web.util.UriUtils;
 import org.springframework.util.Base64Utils;
-
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-
-import org.acumos.cds.CCDSConstants;
-import org.acumos.cds.client.HttpComponentsClientHttpRequestFactoryBasicAuth;
-import org.acumos.cds.domain.MLPArtifact;
-import org.acumos.cds.domain.MLPPeerSubscription;
-import org.acumos.cds.domain.MLPSolution;
-import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.cds.domain.MLPUser;
-import org.acumos.cds.transport.LoginTransport;
-import org.acumos.cds.transport.RestPageRequest;
-import org.acumos.cds.transport.RestPageResponse;
+import org.springframework.web.client.HttpStatusCodeException;
 
 /**
  * 
  * 
  * 
- *         Temporary Client until we have login functions available in Common
- *         Data MicroService
+ * Temporary Client until we have login functions available in Common Data
+ * MicroService
  */
 public class FederationClient extends AbstractClient {
 
-
        /**
+        * @param theTarget 
+        * @param theClient 
         */
-       public FederationClient(String theTarget,
-                                                                                                       HttpClient theClient) {
+       public FederationClient(String theTarget, HttpClient theClient) {
                super(theTarget, theClient);
        }
 
        /**
         * 
-        * @param queryParameters
-        *                      key-value pairs; ignored if null or empty. Gives special
-        *            treatment to Date-type values.
+        * @param theSelection
+        *            key-value pairs; ignored if null or empty. Gives special treatment
+        *            to Date-type values.
         * @return List of MLPSolutions from Remote Acumos
         * @throws HttpStatusCodeException
-        *              Throws HttpStatusCodeException is remote acumos is not available
+        *             Throws HttpStatusCodeException is remote acumos is not available
         */
-       public JsonResponse<List<MLPSolution>> getSolutions(Map<String, Object> theSelection) throws HttpStatusCodeException {
+       public JsonResponse<List<MLPSolution>> getSolutions(Map<String, Object> theSelection)
+                       throws HttpStatusCodeException {
 
                String selectorParam = null;
                try {
                        selectorParam = theSelection == null ? null
-                                                                                                                                                                        //: UriUtils.encodeQueryParam(Utils.mapToJsonString(theSelection),"UTF-8"); 
-                                                                                                                                                                        : Base64Utils.encodeToString(Utils.mapToJsonString(theSelection).getBytes("UTF-8")); 
-               }
-               catch (Exception x) {
+                                       // : UriUtils.encodeQueryParam(Utils.mapToJsonString(theSelection),"UTF-8");
+                                       : Base64Utils.encodeToString(Utils.mapToJsonString(theSelection).getBytes("UTF-8"));
+               } catch (Exception x) {
                        throw new IllegalArgumentException("Cannot process the selection argument", x);
                }
 
-               URI uri =       
-                       API.SOLUTIONS.buildUri(
-                               this.baseUrl,
-                               selectorParam == null ? Collections.EMPTY_MAP
-                                                                                                                       : Collections.singletonMap(API.QueryParameters.SOLUTIONS_SELECTOR, selectorParam));
+               URI uri = API.SOLUTIONS.buildUri(this.baseUrl, selectorParam == null ? Collections.EMPTY_MAP
+                               : Collections.singletonMap(API.QueryParameters.SOLUTIONS_SELECTOR, selectorParam));
                logger.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPSolution>>> response = null;
                try {
-                       response = restTemplate.exchange(
-                                                                       uri,
-                                                                       HttpMethod.GET,
-                                                                       null, 
-                                                                       new ParameterizedTypeReference<JsonResponse<List<MLPSolution>>>() {});
-               }
-               catch (HttpStatusCodeException x) {
+                       response = restTemplate.exchange(uri, HttpMethod.GET, null,
+                                       new ParameterizedTypeReference<JsonResponse<List<MLPSolution>>>() {
+                                       });
+               } catch (HttpStatusCodeException x) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " failed.", x);
                        throw x;
-               }
-               catch (Throwable t) {
+               } catch (Throwable t) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " unexpected failure.", t);
-               }
-               finally {
+               } finally {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
                }
                return response == null ? null : response.getBody();
        }
-       
+
        /**
         * 
-        * @param queryParameters
-        *                      key-value pairs; ignored if null or empty. Gives special
-        *            treatment to Date-type values.
+        * @param theSolutionId
+        *            key-value pairs; ignored if null or empty. Gives special treatment
+        *            to Date-type values.
         * @return List of MLPSolution Revisions from Remote Acumos
         * @throws HttpStatusCodeException
-        *              Throws HttpStatusCodeException is remote acumos is not available
+        *             Throws HttpStatusCodeException is remote acumos is not available
         */
-       public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(
-               String theSolutionId)   throws HttpStatusCodeException {
+       public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(String theSolutionId)
+                       throws HttpStatusCodeException {
 
-               URI uri =       API.SOLUTION_REVISIONS.buildUri(this.baseUrl, theSolutionId);
+               URI uri = API.SOLUTION_REVISIONS.buildUri(this.baseUrl, theSolutionId);
                logger.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPSolutionRevision>>> response = null;
                try {
-                       response = restTemplate.exchange(
-                                                                       uri,
-                                                                       HttpMethod.GET,
-                                                                       null,
-                                                                       new ParameterizedTypeReference<JsonResponse<List<MLPSolutionRevision>>>() {
-                               });
-               }
-               catch (HttpStatusCodeException x) {
+                       response = restTemplate.exchange(uri, HttpMethod.GET, null,
+                                       new ParameterizedTypeReference<JsonResponse<List<MLPSolutionRevision>>>() {
+                                       });
+               } catch (HttpStatusCodeException x) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " failed.", x);
                        throw x;
-               }
-               catch (Throwable t) {
+               } catch (Throwable t) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " unexpected failure.", t);
-               }
-               finally {
+               } finally {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
                }
                return response == null ? null : response.getBody();
        }
-       
+
        /**
         * 
-        * @param queryParameters
-        *                      key-value pairs; ignored if null or empty. Gives special
-        *            treatment to Date-type values.
+        * @param theSolutionId 
+        * @param theRevisionId 
         * @return List of MLPArtifacts from Remote Acumos
         * @throws HttpStatusCodeException
-        *              Throws HttpStatusCodeException is remote acumos is not available
+        *             Throws HttpStatusCodeException is remote acumos is not available
         */
-       public JsonResponse<List<MLPArtifact>> getArtifacts(
-               String theSolutionId, String theRevisionId) throws HttpStatusCodeException {
-               URI uri =       API.SOLUTION_REVISION_ARTIFACTS.buildUri(this.baseUrl, theSolutionId, theRevisionId);
+       public JsonResponse<List<MLPArtifact>> getArtifacts(String theSolutionId, String theRevisionId)
+                       throws HttpStatusCodeException {
+               URI uri = API.SOLUTION_REVISION_ARTIFACTS.buildUri(this.baseUrl, theSolutionId, theRevisionId);
                logger.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPArtifact>>> response = null;
                try {
-                       response = restTemplate.exchange(
-                                                                       uri,
-                                                                       HttpMethod.GET,
-                                                                       null,
-                                                                       new ParameterizedTypeReference<JsonResponse<List<MLPArtifact>>>() {
-                               });
-               }
-               catch (HttpStatusCodeException x) {
+                       response = restTemplate.exchange(uri, HttpMethod.GET, null,
+                                       new ParameterizedTypeReference<JsonResponse<List<MLPArtifact>>>() {
+                                       });
+               } catch (HttpStatusCodeException x) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " failed.", x);
                        throw x;
-               }
-               catch (Throwable t) {
+               } catch (Throwable t) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " unexpected failure.", t);
-               }
-               finally {
+               } finally {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
                }
                return response == null ? null : response.getBody();
        }
-       
+
        /**
+        * @param theArtifactId 
+        * @return Resource
+        * @throws HttpStatusCodeException On failure 
         */
-       public Resource downloadArtifact(String theArtifactId) 
-                                                                                                                                                                                               throws HttpStatusCodeException {
-               URI uri =       API.ARTIFACT_DOWNLOAD.buildUri(this.baseUrl, theArtifactId);
+       public Resource downloadArtifact(String theArtifactId) throws HttpStatusCodeException {
+               URI uri = API.ARTIFACT_DOWNLOAD.buildUri(this.baseUrl, theArtifactId);
                logger.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
                ResponseEntity<Resource> response = null;
                try {
-                       response = restTemplate.exchange(
-                                                                       uri,
-                                                                       HttpMethod.GET,
-                                                                       null,
-                                                                       Resource.class);
-               }
-               catch (HttpStatusCodeException x) {
+                       response = restTemplate.exchange(uri, HttpMethod.GET, null, Resource.class);
+               } catch (HttpStatusCodeException x) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " failed.", x);
                        throw x;
-               }
-               catch (Throwable t) {
+               } catch (Throwable t) {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " unexpected failure.", t);
-               }
-               finally {
+               } finally {
                        logger.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
                }
 
                if (response == null) {
                        return null;
-               }
-               else {
+               } else {
                        return response.getBody();
                }
        }
index 435a662..d133e6e 100644 (file)
 
 package org.acumos.federation.gateway.util;
 
-
 import org.springframework.http.HttpStatus;
 import org.springframework.web.client.HttpStatusCodeException;
 
-
 /** */
 public class Errors {
 
        private Errors() {
        }
-       
 
        /**
         * CDS provides a 400 error with a particular error message
+        * 
+        * @param theError
+        *            Error to parse
+        * @return true or false
         */
        public static boolean isCDSNotFound(HttpStatusCodeException theError) {
 
                if (theError.getStatusCode() == HttpStatus.BAD_REQUEST) {
                        String msg = theError.getResponseBodyAsString();
                        if (msg != null) {
-                               return ((String)Utils
-                                                                                                       .jsonStringToMap(msg)
-                                                                                                               .getOrDefault("error", ""))
-                                                                                               .startsWith("No entry for ID");
+                               return ((String) Utils.jsonStringToMap(msg).getOrDefault("error", "")).startsWith("No entry for ID");
                        }
                }
                return false;
        }
 
-}      
+}
index 7f45c7e..54cd886 100644 (file)
@@ -26,17 +26,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-
 import org.acumos.cds.domain.MLPAccessType;
+import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-
-import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class Utils {
@@ -45,10 +39,6 @@ public class Utils {
        
        public static ObjectMapper objectMapper = new ObjectMapper();
        
-       
-       @Autowired
-       private Environment env;
-       
        public Utils() {
        }
        
@@ -96,6 +86,7 @@ public class Utils {
        /**
         * 
         * @param accessType
+        * Access type
         * @return
         *              MLPAccessType object for Storing in DB
         */
index f5b78fb..cafbbaf 100644 (file)
@@ -185,7 +185,7 @@ public class PeerGatewayTest {
                assertTrue(response.getStatusCodeValue() == 200);
                assertTrue(response.getBody().getResponseBody().size() == 1); //no errors
        }
-/*
+
        @Test
        public void testPeersForbidden() {
 
@@ -203,7 +203,7 @@ public class PeerGatewayTest {
 
                assertTrue(response.getStatusCodeValue() == 403);
        }
-*/
+
        private HttpEntity prepareRequest(String theResourceName) {
                String content = new Scanner(
                                                                           Thread.currentThread().getContextClassLoader().getResourceAsStream(theResourceName), "UTF-8")
diff --git a/gateway/src/test/java/org/acumos/federation/gateway/test/TaskTest.java b/gateway/src/test/java/org/acumos/federation/gateway/test/TaskTest.java
new file mode 100644 (file)
index 0000000..9a215df
--- /dev/null
@@ -0,0 +1,90 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.test;
+
+import java.util.List;
+import java.util.Scanner;
+
+import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat; 
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.core.ParameterizedTypeReference;
+
+import org.apache.http.client.HttpClient;
+
+/* this is not good for unit testing .. */
+import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.federation.gateway.common.HttpClientConfigurationBuilder;
+import static org.acumos.federation.gateway.common.HttpClientConfigurationBuilder.SSLBuilder;
+
+import org.acumos.cds.domain.MLPPeer;
+import org.acumos.cds.domain.MLPSolution;
+import org.acumos.cds.domain.MLPSolutionRevision;
+import org.acumos.cds.domain.MLPArtifact;
+
+
+
+/**
+ */
+
+//@RunWith(SpringJUnit4ClassRunner.class)
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = org.acumos.federation.gateway.Application.class,
+                                                               webEnvironment = WebEnvironment.RANDOM_PORT,
+                                                               properties = {
+                                                                       "federation.instance=adapter",
+                                                                       "federation.instance.name=Ghost",
+                                                                       "peersLocal.source=classpath:/test-peers.json",
+                                                                       "catalogLocal.source=classpath:/test-catalog.json",
+                                                                       "server.ssl.key-store=classpath:acumosa.pkcs12",
+                                                                       "server.ssl.key-store-password=acumosa",
+                                                                       "server.ssl.key-store-type=PKCS12",
+                                                                       "server.ssl.key-password = acumosa",
+                                                                       "server.ssl.trust-store=classpath:acumosTrustStore.jks",
+                                                                       "server.ssl.trust-store-password=acumos",
+                                                                       "server.ssl.client-auth=need"
+                                                               })
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TaskTest {
+
+       @Test
+       public void testPeerTask() {
+
+       }
+
+}
diff --git a/pom.xml b/pom.xml
index 3b72cc2..7cdc6b4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -11,6 +11,7 @@
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   </properties>
 
   <modules>
   <build>
                <plugins>
                        <!-- Skip the deployment step, this makes jenkins config easy -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>2.5.2</version>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-deploy-plugin</artifactId>