addresses review issues and filename changes 78/178/3
authorSerban Jora <jora@research.att.com>
Tue, 5 Dec 2017 19:43:18 +0000 (14:43 -0500)
committerSerban Jora <sj2381@att.com>
Wed, 6 Dec 2017 15:36:19 +0000 (10:36 -0500)
Change-Id: I828e92bc838968a40c31fac1f9bbb5f422eb70d0
Signed-off-by: Serban Jora <sj2381@att.com>
33 files changed:
.gitignore
LICENSE.txt [new file with mode: 0644]
gateway/acumosa.sh [changed mode: 0644->0755]
gateway/acumosb.sh [changed mode: 0644->0755]
gateway/application-adapter.properties
gateway/application-gateway.properties
gateway/application.properties.template
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/adapter/PeerGateway.java
gateway/src/main/java/org/acumos/federation/gateway/adapter/onap/ONAP.java
gateway/src/main/java/org/acumos/federation/gateway/adapter/onap/ONAPAdapterCondition.java
gateway/src/main/java/org/acumos/federation/gateway/adapter/onap/sdc/ASDC.java
gateway/src/main/java/org/acumos/federation/gateway/common/AdapterCondition.java
gateway/src/main/java/org/acumos/federation/gateway/common/GatewayCondition.java
gateway/src/main/java/org/acumos/federation/gateway/common/GhostAdapterCondition.java
gateway/src/main/java/org/acumos/federation/gateway/controller/FederationController.java [moved from gateway/src/main/java/org/acumos/federation/gateway/controller/FederatedCatalogController.java with 94% similarity]
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerCommunicationTaskScheduler.java
gateway/src/main/java/org/acumos/federation/gateway/security/X509AuthenticationFilter.java
gateway/src/main/java/org/acumos/federation/gateway/service/FederationService.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/FederatedCatalogService.java with 97% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/PeerService.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/PeerAcumosConfigService.java with 97% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/PeerSubscriptionService.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/PeerAcumosSubscriptionService.java with 97% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationServiceImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederatedCatalogServiceImpl.java with 96% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationServiceLocalImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederatedCatalogServiceLocalImpl.java with 97% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerAcumosConfigServiceImpl.java with 96% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceLocalImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerAcumosServiceLocalImpl.java with 95% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerSubscriptionServiceImpl.java [moved from gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerAcumosSubscriptionServiceImpl.java with 93% similarity]
gateway/src/main/java/org/acumos/federation/gateway/service/package-info.java
gateway/src/main/java/org/acumos/federation/gateway/task/PeerCommunicationTask.java
gateway/src/main/java/org/acumos/federation/gateway/task/package-info.java
gateway/src/main/java/org/acumos/federation/gateway/util/Utils.java
gateway/src/main/resources/application-gateway.properties
gateway/src/test/resources/application-acumosa.properties
gateway/src/test/resources/application-acumosb.properties

index 3a2a1cf..83485fa 100644 (file)
@@ -4,3 +4,5 @@
 /bin/
 /logs/
 /target/
+/gateway/target/
+/gateway/logs/
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..d2a3575
--- /dev/null
@@ -0,0 +1,15 @@
+ACUMOS
+================================================================================
+Copyright © 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.
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 2ff5b55..0612ebd 100644 (file)
@@ -3,8 +3,8 @@ server.port=8086
 
 #Instance of this component could be gateway or adapter
 #Based on the value configured, the behavior of this instance will vary.
-federated.instance=adapter
-federated.instance.name=ONAP
+federation.instance=adapter
+federation.instance.name=ONAP
 
 #local config
-peersLocal.sourceUri=file:///home/jora/
+peersLocal.sourceUri=file:///{path_to_peers_local}
index 5a12218..dc7994e 100644 (file)
@@ -1,15 +1,10 @@
 #Instance of this component could be gateway or adapter
 #Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
-federated.peerGatewayOperator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
+federation.instance=gateway
+federation.instance.name=Acumos
+federation.operator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
 
-security.user.name=federated_client
-#security.user.password = ENC(CTQD7Xk5bOIuC4MaqRZtzjW1K4ArjCjr)
-security.user.password=federated_pass
-management.security.roles=SUPERUSER
-
-# CDmS REST endpoints are protected by HTTP Basic Authentication
+# CDMS REST endpoints are protected by HTTP Basic Authentication
 #Common Data Source Configuration
 cdms.client.url=http://localhost:8002/ccds
 #cdms.client.url=http://localhost:8082/ccds
index 7b60fdb..83b5110 100644 (file)
@@ -7,8 +7,8 @@ server.contextPath=/
 
 #Instance of this component could be gateway or adapter
 #Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
+federation.instance=gateway
+federation.instance.name=ATT
 
 #Task executor that run every x seconds
 peer.jobchecker.interval=300
@@ -32,4 +32,4 @@ nexus.username=acumos_model_rw
 nexus.password=not4you
 nexus.groupId=com.artifact
 nexus.proxy=http://some.proxy.com:8080
-###################################################################
\ No newline at end of file
+###################################################################
index 917aa43..20c1bbe 100644 (file)
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.0</version>
                                <configuration>
                                        <source>1.8</source>
                                        <target>1.8</target>
                                        </authConfig>
                                        <images>
                                                <image>
-                                                       <name>federated-gateway:${project.version}</name>
+                                                       <name>federation-gateway:${project.version}</name>
                                                        <build>
                                                                <!-- This is the same FROM used in a Dockerfile -->
                                                                <from>openjdk:8-jdk</from>
 <!--                           </execution> -->
 <!--                   </executions> -->
                        </plugin>
+                       <plugin>
+                               <groupId>org.jacoco</groupId>
+                               <artifactId>jacoco-maven-plugin</artifactId>
+                               <version>0.7.6.201602180812</version>
+                               <executions>
+                                       <execution>
+                                               <id>default-prepare-agent</id>
+                                               <goals>
+                                                       <goal>prepare-agent</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>default-report</id>
+                                               <phase>prepare-package</phase>
+                                               <goals>
+                                                       <goal>report</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+
                </plugins>
        </build>
        <distributionManagement>
index cde94a7..ce2070d 100644 (file)
@@ -31,7 +31,9 @@ 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.federation.gateway.util.Utils;
+
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.BeanInitializationException;
 //import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.context.annotation.Conditional;
@@ -40,6 +42,7 @@ import org.springframework.core.env.Environment;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
+import org.springframework.web.client.HttpStatusCodeException;
 
 import org.acumos.cds.AccessTypeCode;
 import org.acumos.cds.ValidationStatusCode;
@@ -47,18 +50,19 @@ import org.acumos.cds.client.CommonDataServiceRestClientImpl;
 import org.acumos.cds.client.ICommonDataServiceRestClient;
 import org.acumos.cds.domain.MLPArtifact;
 import org.acumos.cds.domain.MLPPeer;
+import org.acumos.cds.domain.MLPPeerSubscription;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 
 
 @Component("peergateway")
 //@Scope("singleton")
-@ConfigurationProperties(prefix="federated")
+@ConfigurationProperties(prefix="federation")
 @Conditional(GatewayCondition.class)
 public class PeerGateway {
 
        private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerGateway.class);
-       private String  peerGatewayOperator = "testUser";
+       private String                          operator;
        private TaskExecutor    taskExecutor; 
        @Autowired
        private Environment env;
@@ -70,8 +74,21 @@ public class PeerGateway {
        public void initPeerGateway() {
                logger.debug(EELFLoggerDelegate.debugLogger, "initPeerGateway");
 
-               /*if (this.asdc.getUri() == null)
-                       throw new BeanInitializationException("Forgot to configure the SDC uri??");*/
+               /* make sure an operator was specified and that it is a declared user */
+               if (null == this.env.getProperty("federation.operator")) {
+                       throw new BeanInitializationException("Missing 'federation.operator' configuration");
+               }
+               else {
+                       try {
+                               if (null == this.clients.getClient().getUser(
+                                                                                       this.env.getProperty("federation.operator"))) {
+                                       logger.warn(EELFLoggerDelegate.errorLogger, "'federation.operator' does not point to an existing user");
+                               }
+                       }
+                       catch (HttpStatusCodeException dx) {
+                               logger.warn(EELFLoggerDelegate.errorLogger, "failed to verify 'federation.operator' value", dx);
+                       }
+               }
 
                this.taskExecutor = new ThreadPoolTaskExecutor();
                ((ThreadPoolTaskExecutor)this.taskExecutor).setCorePoolSize(1);
@@ -88,20 +105,34 @@ public class PeerGateway {
                logger.debug(EELFLoggerDelegate.debugLogger, "PeerGateway destroyed");
        }
 
+       protected String getOwnerId(MLPPeerSubscription theSubscription/*,
+                                                                                                                       MLPSolution theSolution*/) {
+               // Need to get from c_user table . It has to be admin user
+               return this.env.getProperty("federation.operator");
+       }
+
        @EventListener
        public void handlePeerSubscriptionUpdate(PeerSubscriptionEvent theEvent) {
                logger.info(EELFLoggerDelegate.debugLogger, "received peer subscription update event " + theEvent);
-               taskExecutor.execute(new PeerGatewayUpdateTask(theEvent.getPeer(), theEvent.getSolutions()));
+               taskExecutor.execute(
+                       new PeerGatewayUpdateTask(theEvent.getPeer(),
+                                                                                                                               theEvent.getSubscription(),
+                                                                                                                               theEvent.getSolutions()));
        }
 
 
        public class PeerGatewayUpdateTask implements Runnable {
 
-               private MLPPeer                                         peer;
-               private List<MLPSolution> solutions;
+               private MLPPeer                                                 peer;
+               private MLPPeerSubscription sub;
+               private List<MLPSolution>       solutions;
+               
 
-               public PeerGatewayUpdateTask(MLPPeer thePeer, List<MLPSolution> theSolutions) {
+               public PeerGatewayUpdateTask(MLPPeer thePeer,
+                                                                                                                                MLPPeerSubscription theSub,
+                                                                                                                                List<MLPSolution> theSolutions) {
                        this.peer = thePeer;
+                       this.sub = theSub;
                        this.solutions = theSolutions;
                }
 
@@ -144,7 +175,9 @@ public class PeerGateway {
                        }
                }
                
-               private MLPSolution createMLPSolution(MLPSolution peerMLPSolution, ICommonDataServiceRestClient cdsClient) {
+               private MLPSolution createMLPSolution(
+                                                                                                                               MLPSolution peerMLPSolution,
+                                                                                                                               ICommonDataServiceRestClient cdsClient) {
                        logger.info(EELFLoggerDelegate.debugLogger, "Creating Local MLP Solutino for peer solution " + peerMLPSolution);
                        MLPSolution mlpSolution = new MLPSolution();
                        mlpSolution.setSolutionId(peerMLPSolution.getSolutionId());
@@ -159,7 +192,7 @@ public class PeerGateway {
                        mlpSolution.setValidationStatusCode(ValidationStatusCode.PS.toString());
                        mlpSolution.setCreated(peerMLPSolution.getCreated());
                        mlpSolution.setModified(peerMLPSolution.getModified());
-                       mlpSolution.setOwnerId(env.getProperty("federated.peerGatewayOperator")); // Need to get from c_user table . It has to be admin user
+                       mlpSolution.setOwnerId(getOwnerId(this.sub)); 
                        try {
                                cdsClient.createSolution(mlpSolution);
                        } catch (Exception e) {
@@ -168,13 +201,15 @@ public class PeerGateway {
                        return mlpSolution;
                }
                
-               private MLPSolutionRevision createMLPSolutionRevision(MLPSolutionRevision mlpSolutionRevision, ICommonDataServiceRestClient cdsClient) {
+               private MLPSolutionRevision createMLPSolutionRevision(
+                                                                                                                                               MLPSolutionRevision mlpSolutionRevision,
+                                                                                                                                               ICommonDataServiceRestClient cdsClient) {
                        MLPSolutionRevision solutionRevision = new MLPSolutionRevision();
                        solutionRevision.setSolutionId(mlpSolutionRevision.getSolutionId());
                        solutionRevision.setRevisionId(mlpSolutionRevision.getRevisionId());
                        solutionRevision.setVersion(mlpSolutionRevision.getVersion());
                        solutionRevision.setDescription(mlpSolutionRevision.getDescription());
-                       solutionRevision.setOwnerId(env.getProperty("federated.peerGatewayOperator"));//TODO
+                       solutionRevision.setOwnerId(getOwnerId(this.sub));
                        solutionRevision.setMetadata(mlpSolutionRevision.getMetadata());
                        solutionRevision.setCreated(mlpSolutionRevision.getCreated());
                        solutionRevision.setModified(mlpSolutionRevision.getModified());
@@ -195,7 +230,7 @@ public class PeerGateway {
                        artifact.setMetadata(mlpArtifact.getMetadata());
                        artifact.setModified(mlpArtifact.getModified());
                        artifact.setName(mlpArtifact.getName());
-                       artifact.setOwnerId(env.getProperty("federated.peerGatewayOperator"));
+                       artifact.setOwnerId(getOwnerId(this.sub));
                        artifact.setSize(mlpArtifact.getSize());;
                        artifact.setUri(mlpArtifact.getUri());
                        artifact.setVersion(mlpArtifact.getVersion());
@@ -217,7 +252,7 @@ public class PeerGateway {
                        localMLPArtifact.setMetadata(peerMLPArtifact.getMetadata());
                        localMLPArtifact.setModified(peerMLPArtifact.getModified());
                        localMLPArtifact.setName(peerMLPArtifact.getName());
-                       localMLPArtifact.setOwnerId(env.getProperty("federated.peerGatewayOperator"));
+                       localMLPArtifact.setOwnerId(getOwnerId(this.sub));
                        localMLPArtifact.setSize(peerMLPArtifact.getSize());;
                        localMLPArtifact.setUri(peerMLPArtifact.getUri());
                        localMLPArtifact.setVersion(peerMLPArtifact.getVersion());
@@ -241,7 +276,8 @@ public class PeerGateway {
                        localMLPSolution.setActive(peerMLPSolution.isActive());
                        localMLPSolution.setToolkitTypeCode(peerMLPSolution.getToolkitTypeCode());
                        localMLPSolution.setValidationStatusCode(localMLPSolution.getValidationStatusCode());
-                       localMLPSolution.setOwnerId(env.getProperty("federated.peerGatewayOperator")); // Need to get from c_user table . It has to be admin user
+                       localMLPSolution.setOwnerId(getOwnerId(this.sub));
+
                        try {
                                cdsClient.updateSolution(localMLPSolution);
                        } catch (Exception e) {
index 2c93269..fffa1a5 100644 (file)
@@ -79,7 +79,7 @@ public class ONAP {
 
        private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ONAP.class);
        private ASDC            asdc = new ASDC();
-       private String  asdcOperator = "admin";
+       private String  asdcOperator;
        private TaskExecutor    taskExecutor; 
   @Autowired
   private Clients clients;
@@ -102,7 +102,9 @@ public class ONAP {
                logger.debug(EELFLoggerDelegate.debugLogger, "initOnap");
 
                if (this.asdc.getUri() == null)
-                       throw new BeanInitializationException("Forgot to configure the SDC uri??");
+                       throw new BeanInitializationException("Forgot to configure the SDC uri ('onap.sdcUri') ??");
+               if (this.asdcOperator == null)
+                       throw new BeanInitializationException("Forgot to configure the SDC user ('onap.sdcOperator) ??");
 
                this.taskExecutor = new ThreadPoolTaskExecutor();
                ((ThreadPoolTaskExecutor)this.taskExecutor).setCorePoolSize(1);
@@ -241,7 +243,7 @@ public class ONAP {
                                        fedClient.getSolutionsRevisionListFromPeer(theSolution.getSolutionId(), null).getResponseBody();
                        }
                        catch (Exception x) {
-                               logger.warn(EELFLoggerDelegate.debugLogger, "Failed to retrieve acumos revisions: " + x);
+                               logger.warn(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos revisions: " + x);
                                throw x;
                        }
 
index 314025b..ce09c3d 100644 (file)
@@ -37,7 +37,7 @@ public class ONAPAdapterCondition extends AdapterCondition {
                Environment env = theContext.getEnvironment();
     return super.matches(theContext, theMetadata) &&
                                         null != env &&
-                                        "ONAP".equals(env.getProperty("federated.instance.name"));
+                                        "ONAP".equals(env.getProperty("federation.instance.name"));
   }
 
 }
index 8a2dddd..d369065 100644 (file)
@@ -1057,477 +1057,5 @@ public class ASDC {
          return theExecution.executeAsync(theRequest, theBody);
     }
        }
-       
-//amdocs: "http://dcaedt:dcae123@135.16.121.89:8080#demo"));
-       public static void main(String[] theArgs) throws Exception {
-
-               CommandLineParser parser = new BasicParser();
-               
-               Options options = new Options();
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("target")
-                                                                                                                       .withLongOpt("target")
-                               .withDescription("target asdc system")
-                                                                                                                       .hasArg()
-                                                                                                                       .isRequired()
-                                                                                                                       .create('t') );
-                       
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("rootPath")
-                                                                                                                       .withLongOpt("rootpath")
-                               .withDescription("asdc rootpath")
-                                                                                                                       .hasArg()
-                                                                                                                       .isRequired()
-                                                                                                                       .create('r') );
-
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("action")
-                                                                                                                       .withLongOpt("action")
-                              .withDescription("one of: list, get, getartifact, checkin, checkout")
-                                                                                                                       .hasArg()
-                                                                                                                       .isRequired()
-                                                                                                                       .create('a') );
-
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("assetType")
-                                                                                                                       .withLongOpt("assetType")
-                               .withDescription("one of resource, service, product")
-                                                                                                                       .hasArg()
-                                                                                                                       .isRequired()
-                                                                                                                       .create('k') ); //k for 'kind' ..
-
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("assetId")
-                                                                                                                       .withLongOpt("assetId")
-                               .withDescription("asset uuid")
-                                                                                                                       .hasArg()
-                                                                                                                       .create('u') ); //u for 'uuid'
-
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("artifactId")
-                                                                                                                       .withLongOpt("artifactId")
-                               .withDescription("artifact uuid")
-                                                                                                                       .hasArg()
-                                                                                                                       .create('s') ); //s for 'stuff'
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("instance")
-                                                                                                                       .withLongOpt("instance")
-                               .withDescription("asset instance name")
-                                                                                                                       .hasArg()
-                                                                                                                       .create('i') );
-               options.addOption(OptionBuilder
-                                                                                                                 .withArgName("listFilter")
-                                                                                                                       .withLongOpt("listFilter")
-                               .withDescription("filter for list operations")
-                                                                                                                       .hasArg()
-                                                                                                                       .create('f') ); //u for 'uuid'
-
-               CommandLine line = null;
-               try {
-               line = parser.parse(options, theArgs);
-               }
-               catch(ParseException exp) {
-                       System.err.println(exp.getMessage());
-                       new HelpFormatter().printHelp("asdc", options);
-                       return;
-               }
-
-               ASDC asdc = new ASDC();
-               asdc.setUri(new URI(line.getOptionValue("target")));
-               asdc.setRootPath(line.getOptionValue("rootpath"));
-
-               String instance = line.getOptionValue("instance");
-               String action = line.getOptionValue("action");
-               if (action.equals("list")) {
-                       JSONObject filterInfo = new JSONObject(
-                                                                                                                                                       line.hasOption("listFilter") ?
-                                                                                                                                                               line.getOptionValue("listFilter") : "{}");
-                       JSONArray assets = 
-                               asdc.getAssets(ASDC.AssetType.valueOf(line.getOptionValue("assetType")), JSONArray.class,
-                                                                                        filterInfo.optString("category", null), filterInfo.optString("subCategory", null))
-                                               .waitForResult();
-                       for (int i = 0; i < assets.length(); i++) {
-                               System.out.println("> " + assets.getJSONObject(i).toString(2));
-                       }
-               }
-               else if (action.equals("get")) {
-                       System.out.println(
-                               asdc.getAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
-                                                                                       UUID.fromString(line.getOptionValue("assetId")),
-                                                                                       JSONObject.class)
-                                               .waitForResult()
-                                               .toString(2)
-                       );
-               }
-               else if (action.equals("getartifact")) {
-                       if (instance == null) {
-                               System.out.println(
-                                       asdc.getAssetArtifact(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
-                                                                                                                               UUID.fromString(line.getOptionValue("assetId")),
-                                                                                                                               UUID.fromString(line.getOptionValue("artifactId")),
-                                                                                                                               String.class)
-                                                       .waitForResult()
-                               );
-                       }
-                       else {
-                               System.out.println(
-                                       asdc.getAssetInstanceArtifact(
-                                                                                                                               ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
-                                                                                                                               UUID.fromString(line.getOptionValue("assetId")),
-                                                                                                                               instance,
-                                                                                                                               UUID.fromString(line.getOptionValue("artifactId")),
-                                                                                                                               String.class)
-                                                       .waitForResult()
-                               );
-                       }
-               }
-               else if (action.equals("checkin")) {
-                       System.out.println(
-                                       asdc.cycleAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
-                                                                                                       UUID.fromString(line.getOptionValue("assetId")),
-                                                                                                       ASDC.LifecycleState.Checkin,
-                                                                                                       "Admin",
-                                                                                                       "cli op")
-                                                       .waitForResult()
-                       );
-               }
-               else if (action.equals("checkout")) {
-                       System.out.println(
-                                       asdc.cycleAsset(ASDC.AssetType.valueOf(line.getOptionValue("assetType")),
-                                                                                                       UUID.fromString(line.getOptionValue("assetId")),
-                                                                                                       ASDC.LifecycleState.Checkout,
-                                                                                                       "Admin",
-                                                                                                       "cli op")
-                                                       .waitForResult()
-                       );
-               }
-               else if (action.equals("cleanup")) {
-                       JSONArray resources = asdc.getResources()
-                                                                                                                                       .waitForResult();
-                       System.out.println("Got " + resources.length() + " resources");
-
-
-                       // vfcmt cleanup 
-                       for (int i = 0; i < resources.length(); i++) {
-
-                               JSONObject resource = resources.getJSONObject(i);
-
-                               if (resource.getString("resourceType").equals("VFCMT") &&
-                                               resource.getString("name").contains("test")) {
-
-                                       System.out.println("undocheckout for " + resource.getString("uuid"));
-
-                                       try {
-                                               asdc.cycleAsset(AssetType.resource, UUID.fromString(resource.getString("uuid")), LifecycleState.undocheckout, "sj2381", null)
-                                                       .waitForResult();
-                                       }
-                                       catch (Exception x) {
-                                               System.out.println("** " + x);
-                                       }
-                               }
-                       }
-
-               }
-               else {
-                       try {
-                               System.out.println(
-                                       asdc.createVF()
-                                                       .withInfo(new JSONObject()
-                                                                                                       .put("category", "Generic")
-                                                                                                       .put("subcategory", "Abstract"))
-                                                       .withName("Cognitor")
-                                                       .withDescription("Acumos import 07262017")
-                                                       .withVendorName("AcumosInc")
-                                                       .withVendorRelease("1.0")
-                                                       .withTags("acumos")
-                                                       .withOperator("sj2381")
-                                                       .execute()
-                                                       .waitForResult());
-                       }
-                       catch(Exception x) {
-                               System.out.println("Failed to create VF: " + x);
-                       }
-       }       
-/*
-               else {
-                       UUID cid = UUID.fromString(line.getOptionValue("assetId"));
-                       JSONObject jsonObj = asdc.getResource(cid).waitForResult();
-                       System.out.println(jsonObj);
-               
-                       JSONObject artifactObj = null;
-                       boolean flag = false;
-
-                       JSONArray resObj = jsonObj.optJSONArray("artifacts");
-                       if(resObj != null) {
-                               for(int i=0; i< resObj.length(); i++) {
-                                       artifactObj = (JSONObject) resObj.get(i);
-                                       System.out.println(artifactObj);
-                                       if(artifactObj.get("artifactName").equals("superposition.yml")) {
-                                               asdc.updateResourceArtifact(cid, artifactObj)
-                                                       .withContent("{}".getBytes())
-                                                       .withOperator("sj2381")
-                               //                      .withLabel("Superposition")
-                               //                      .withType(ArtifactType.DCAE_TOSCA)
-                               //                      .withGroupType(ArtifactGroupType.DEPLOYMENT)
-                                                       .withDescription(" serban asdc api test")
-                                                       .execute()
-                                                       .waitForResult();
-                                                       flag = true;
-                                       }
-                               }
-                       }
-
-                       if(!flag) {
-                                       asdc.createResourceArtifact(cid)
-                                                       .withName("superposition.yml")
-                                                       .withDisplayName("composition")
-                                                       .withContent("{}".getBytes())
-                                                       .withOperator("sj2381")
-                                                       .withLabel("Superposition")
-                                                       .withType(ArtifactType.DCAE_TOSCA)
-                                                       .withGroupType(ArtifactGroupType.DEPLOYMENT)
-                                                       .withDescription(" serban asdc api test")
-                                                       .execute()
-                                                       .waitForResult();
-                       }
-
-                       System.out.println(">>> " + 
-                               asdc.checkinResource(cid, "sj2381", "done")
-                                               .waitForResult());
-
-               }
-*/
-/*
-               System.out.println(
-               asdc.deleteServiceInstanceArtifact(UUID.fromString("b8c40b18-a295-4f7d-905f-4ce18f939f9c"),
-                                                                                                                                                        "vMOG_for_DCAEDT 1",
-                                                                                                                                                        UUID.fromString("0992b5a9-75e0-4f0f-994c-8c7be6616e13"))
-                                                               .withOperator("sj2381")
-                                                               .execute()
-                                                               .waitForResult());
-*/
-
-/*
-               JSONArray services = asdc.getServices()
-//("DCAE Component", null)
-//                                                                                                                             .waitForResult();
-//             System.out.println("Got " + services.length() + " services");
-//             System.out.println(services.toString(2));
-
-               for (int i = 0; i < services.length(); i++) {
-//                     if (services.getJSONObject(i).getString("name").equals("DCAEDT_vMOG_Srvc3")) {
-//                     if (services.getJSONObject(i).getString("name").equals("MonicaforBP")) {
-                               UUID serviceId = UUID.fromString(services.getJSONObject(i).getString("uuid"));
-
-                               System.out.println("Service " + serviceId);
-
-                               if (theArgs.length > 1 && !theArgs[1].equals(serviceId.toString()))
-                                       continue;
-       
-                               JSONObject service = null;
-                               try {
-                                       service = asdc.getService(serviceId)
-                                                                                                                                       .waitForResult();
-                               }
-                               catch(Exception x) {
-                                       System.out.println(x);
-                                       continue;
-                               }
-                               System.out.println("Service details: " + service);
-                       
-                               asdc.checkinService(serviceId, "sj2381", "ready for update")
-                                                       .waitForResult();
-       
-
-                               JSONArray instances = service.optJSONArray("resources");
-                               if (instances != null) {
-                                       JSONObject instance = instances.getJSONObject(0);
-                                       try {
-*/
-                                               //System.out.println("Found instances, processing artifact for " + instance);
-
-/*
-                                               System.out.println(
-                                               asdc.createServiceInstanceArtifact(UUID.fromString(services.getJSONObject(i).getString("uuid")),
-                                                                                                                                                                                                       instance.getString("resourceInstanceName"))
-                                                               .withName("test.yaml")
-                                                               .withDisplayName("artificial")
-                                                               .withLabel("artificial")
-                                                               .withDescription("serban asdc api test")
-                                                               .withContent(new File(theArgs[theArgs.length-1]))
-                                                               //.withType(ArtifactType.DCAE_TOSCA)
-                                                               //.withType(ArtifactType.HEAT_ARTIFACT)
-                                                               .withType(ArtifactType.DCAE_INVENTORY_BLUEPRINT)
-                                                               .withGroupType(ArtifactGroupType.DEPLOYMENT)
-                                                               .withOperator("sj2381")
-                                                               .execute()
-                                                               .waitForResult());
-                                                       asdc.deleteServiceInstanceArtifact(UUID.fromString(services.getJSONObject(i).getString("uuid")),
-                                                                                                                                                                                                instance.getString("resourceInstanceName"),
-                                                                                                                                                                                                UUID.fromString(
-                                                                                                                                                                                                       instance.getJSONArray("artifacts").getJSONObject(0).getString("artifactUUID")))
-                                                               .withOperator("sj2381")
-                                                               .execute()
-                                                               .waitForResult());
-*/
-
-/*
-                                       }
-                                       catch(Exception x) {
-                                               System.out.println("Failed to create resource instance artifact" + x);
-                                               return;
-                                       }
-//                             }
-                       }
-               }       
-*/
-
-
-
-//             List resources = asdc.getResources(List.class, "DCAE Component", "Database")
-//                                                                                                                             .waitForResult();
-//             System.out.println(resources.toString());
-
-
-//             String artifact = asdc.getResourceArtifact(UUID.fromString(theArgs[1]),UUID.fromString(theArgs[2]),String.class)
-//                                                                                                             .waitForResult();
-//             System.out.println(artifact);
-
-//             System.out.println(
-//                     asdc.checkinService(UUID.fromString(theArgs[1]), "sj2381", "testing")
-//                             .waitForResult());
-
-//             System.out.println(
-//                     asdc.checkinService(UUID.fromString(theArgs[1]), "sj2381", "tested")
-//                             .waitForResult());
-
-/*
-               try {
-                       System.out.println(
-                               asdc.createResourceArtifact(UUID.fromString(theArgs[1]))
-                                               .withName("test.yml")
-                                               .withDisplayName("test")
-                                               .withLabel("test")
-                                               .withDescription("serban asdc api test")
-                                               .withContent(new File(theArgs[2]))
-                                               .withType(ArtifactType.DCAE_TOSCA)
-                                               .withGroupType(ArtifactGroupType.DEPLOYMENT)
-                                               .withOperator("sj2381")
-                                               .execute()
-                                               .waitForResult());
-               }
-               catch(Exception x) {
-                       System.out.println("Failed to create asset " + x);
-                       return;
-               }       
-*/
-
-/*
-               JSONObject resource = asdc.getResource(UUID.fromString(theArgs[1]), JSONObject.class)
-                                                                                                                               .waitForResult();
-               System.out.println(resource.toString(2));
-               JSONArray artifacts = resource.getJSONArray("artifacts");
-               JSONObject artifact = artifacts.getJSONObject(0);
-*/
-
-
-/*             
-               byte[] archive = asdc.getResourceArchive(UUID.fromString(theArgs[1]))
-                                                                                                       .waitForResult();
-               FileUtils.writeByteArrayToFile(new File("archive.jar"), archive);       
-*/
 
-/*
-               String artifactInfo = asdc.getResourceArtifact(
-                                                                                                                                                                               UUID.fromString(theArgs[1]),
-                                                                                                                                                                               UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")),
-                                                                                                                                                                               String.class)
-                                                                                                               .waitForResult();
-               System.out.println(artifactInfo);
-*/
-
-/*
-               System.out.println(
-                               asdc.fetch(
-                                       asdc.refAssetArtifact(AssetType.resource, UUID.fromString(theArgs[1]), UUID.fromString(artifact.getString("artifactUUID"))), JSONObject.class)
-                                       .waitForResult()
-                                       .toString(2));
-*/
-
-/*
-               try {
-                       System.out.println(
-                               asdc.updateResourceArtifact(UUID.fromString(theArgs[1]), artifact)
-                                               .withDescription("serban asdc api test update")
-                                               .withContent(new File(theArgs[3]))
-                                               .withLabel("test")
-                                               .withOperator("sj2381")
-                                               .execute()
-                                               .waitForResult());
-               }
-               catch(Exception x) {
-                       System.out.println("Failed to update asset " + x);
-                       return;
-               }
-*/
-
-
-/*
-               try {
-                       asdc.deleteResourceArtifact(UUID.fromString(theArgs[1]),
-                                                                                                                                       UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")))
-                                       .withOperator("sj2381")
-                                       .execute()
-                                       .waitForResult();
-               }
-               catch(Exception x) {
-                       System.out.println("Failed to delete asset artifact " + x);
-               }       
-*/
-
-/*
-       try {
-               JSONObject artifact = artifacts.getJSONObject(0);
-
-               System.out.println(
-                       asdc.updateResourceArtifact(UUID.fromString(theArgs[1]),
-                                                                                                                                 UUID.fromString(artifacts.getJSONObject(0).getString("artifactUUID")))
-                                               .withName(artifact.getString("artifactName"))
-                                               .withDescription("serban asdc api test update")
-                                               .withContent(new File(theArgs[2]))
-                                               .withGroupType(ArtifactGroupType.DEPLOYMENT)
-                                               .withLabel("test")
-                                               .withType(ArtifactType.valueOf(artifact.getString("artifactType")))
-                                               .withATTContact("sj2381")
-                                               .post()
-                                               .waitForResult());
-       }
-       catch(Exception x) {
-               System.out.println("Failed to update asset artifact " + x);
-       }       
-*/
-/*
-       try {
-               System.out.println(
-                       asdc.createVFCMT()
-                                                       .withName("SB4.5")
-                                                       .withDescription("All mountain")
-                                                       .withVendorName("Yeti")
-                                                       .withVendorRelease("1.0")
-                                                       .withTags("MTB", "FS")
-                                                       .withOperator("sj2381")
-                                                       .execute()
-                                                       .waitForResult());
-       }
-       catch(Exception x) {
-               System.out.println("Failed to create VFCMT: " + x);
-       }       
-*/
-/*
-               asdc.updateAssetArtifact(AssetType.resource, UUID.fromString(theArgs[1]), UUID.fromString(theArgs[2]))
-                                       .withDescription("serban asdc api test")
-                                       .post();        
-*/
-       }
-}
+}      
index f4942e1..69a23a9 100644 (file)
@@ -36,6 +36,6 @@ public class AdapterCondition implements Condition {
 
                Environment env = theContext.getEnvironment();
     return null != env &&
-                                        "adapter".equals(env.getProperty("federated.instance"));
+                                        "adapter".equals(env.getProperty("federation.instance"));
   }
 }
index a8cab2d..0a2c70b 100644 (file)
@@ -35,6 +35,6 @@ public class GatewayCondition implements Condition {
                                                                                                 AnnotatedTypeMetadata theMetadata) {
 
                Environment env = theContext.getEnvironment();
-    return null != env && "gateway".equals(env.getProperty("federated.instance"));
+    return null != env && "gateway".equals(env.getProperty("federation.instance"));
   }
 }
index 6723c83..0775164 100644 (file)
@@ -37,7 +37,7 @@ public class GhostAdapterCondition extends AdapterCondition {
                Environment env = theContext.getEnvironment();
                return super.matches(theContext, theMetadata) &&
                                                                                                 null != env &&
-                                                                                                "ghost".equals(env.getProperty("federated.instance.name"));
+                                                                                                "ghost".equals(env.getProperty("federation.instance.name"));
   }
 
 }
@@ -47,7 +47,7 @@ import org.acumos.federation.gateway.common.JSONTags;
 import org.acumos.federation.gateway.common.JsonResponse;
 import org.acumos.federation.gateway.config.APINames;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
 
 import io.swagger.annotations.ApiOperation;
 
@@ -57,12 +57,12 @@ import io.swagger.annotations.ApiOperation;
  */
 @Controller
 @RequestMapping("/")
-public class FederatedCatalogController extends AbstractController {
+public class FederationController extends AbstractController {
        
-       private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederatedCatalogController.class);
+       private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederationController.class);
        
        @Autowired
-       FederatedCatalogService federationGatewayService;
+       FederationService federationService;
        
        
 //     /**
@@ -113,7 +113,7 @@ public class FederatedCatalogController extends AbstractController {
                try {
                        data = new JsonResponse<List<MLPSolution>>();
                        logger.debug(EELFLoggerDelegate.debugLogger, "getSolutionsListFromPeer: model types " + mlpModelTypes);
-                       peerCatalogSolutions = federationGatewayService.getPeerCatalogSolutionsList(mlpModelTypes);
+                       peerCatalogSolutions = federationService.getPeerCatalogSolutionsList(mlpModelTypes);
                        if(peerCatalogSolutions != null) {
                                data.setResponseBody(peerCatalogSolutions);
                                data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
@@ -150,7 +150,7 @@ public class FederatedCatalogController extends AbstractController {
                List<MLPSolutionRevision> peerCatalogSolutionRevisions= null;
                try {
                        data = new JsonResponse<List<MLPSolutionRevision>>();
-                       peerCatalogSolutionRevisions = federationGatewayService.getPeerCatalogSolutionRevision(solutionId);
+                       peerCatalogSolutionRevisions = federationService.getPeerCatalogSolutionRevision(solutionId);
                        if(peerCatalogSolutionRevisions != null) {
                                data.setResponseBody(peerCatalogSolutionRevisions);
                                data.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
@@ -187,7 +187,7 @@ public class FederatedCatalogController extends AbstractController {
                List<MLPArtifact> peerSolutionArtifacts= null;
                try {
                        data = new JsonResponse<List<MLPArtifact>>();
-                       peerSolutionArtifacts = federationGatewayService.getPeerSolutionArtifacts(solutionId, revisionId);
+                       peerSolutionArtifacts = federationService.getPeerSolutionArtifacts(solutionId, revisionId);
                        if(peerSolutionArtifacts != null) {
                                //re-encode the artifact uri
                                {
@@ -232,7 +232,7 @@ public class FederatedCatalogController extends AbstractController {
                HttpServletRequest request, HttpServletResponse response) {
                InputStreamResource inputStreamResource = null;
                try {
-                       inputStreamResource = federationGatewayService.getPeerSolutionArtifactFile(artifactId);
+                       inputStreamResource = federationService.getPeerSolutionArtifactFile(artifactId);
                        //TODO : Need to Implement a logic to download a Artifact or Docker Image from Nexus
                        response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
                        response.setHeader("Pragma", "no-cache");
index 246d9af..81c1e54 100644 (file)
@@ -35,8 +35,8 @@ import com.google.common.collect.Table;
 import com.google.common.collect.HashBasedTable;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
 import org.acumos.federation.gateway.task.PeerCommunicationTask;
 import org.acumos.federation.gateway.util.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -69,10 +69,10 @@ public class PeerCommunicationTaskScheduler implements      ApplicationContextAware
        private Environment env;
 
        @Autowired
-       private PeerAcumosConfigService peerAcumosConfigService;
+       private PeerService peerService;
 
        @Autowired
-       private PeerAcumosSubscriptionService peerAcumosSubscriptionService;
+       private PeerSubscriptionService peerSubscriptionService;
 
        private ApplicationContext                      appCtx;
 
@@ -94,7 +94,7 @@ public class PeerCommunicationTaskScheduler implements        ApplicationContextAware
 
        @Bean
        public ThreadPoolTaskScheduler taskScheduler() {
-               String name = env.getProperty("federated.instance.name") + "-" + env.getProperty("federated.instance") + "-taskscheduler";
+               String name = env.getProperty("federation.instance.name") + "-" + env.getProperty("federation.instance") + "-taskscheduler";
                ThreadPoolTaskScheduler threadPoolTaskScheduler = null;
                try {
                        threadPoolTaskScheduler = (ThreadPoolTaskScheduler)this.appCtx.getBean(name);
@@ -138,9 +138,9 @@ public class PeerCommunicationTaskScheduler implements      ApplicationContextAware
        public void checkPeerJobs() {
 
                //Get the List of MLP Peers
-               List<MLPPeer> mlpPeers = peerAcumosConfigService.getPeers();
+               List<MLPPeer> mlpPeers = peerService.getPeers();
                if(Utils.isEmptyList(mlpPeers)) {
-                       logger.info(EELFLoggerDelegate.debugLogger, "checkPeer : no peers from " + peerAcumosConfigService);
+                       logger.info(EELFLoggerDelegate.debugLogger, "checkPeer : no peers from " + peerService);
                        return;
                }
                
@@ -164,7 +164,7 @@ public class PeerCommunicationTaskScheduler implements      ApplicationContextAware
                                continue;
                        }
 
-                       List<MLPPeerSubscription> mlpSubs = peerAcumosSubscriptionService.getPeerSubscriptions(mlpPeer.getPeerId());
+                       List<MLPPeerSubscription> mlpSubs = peerSubscriptionService.getPeerSubscriptions(mlpPeer.getPeerId());
                        if(Utils.isEmptyList(mlpSubs)) {
                                //the peer is still there but has no subscriptions: cancel any ongoing tasks
 
index 801f80c..1edef20 100644 (file)
@@ -25,7 +25,7 @@ import java.util.List;
 import org.acumos.cds.domain.MLPPeer;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
+import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.util.Utils;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,7 +49,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
 public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
 
        @Autowired
-       private PeerAcumosConfigService peerConfigService;
+       private PeerService peerService;
 
        private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
 
@@ -83,7 +83,7 @@ public class X509AuthenticationFilter extends WebSecurityConfigurerAdapter {
        public UserDetailsService userDetailsService() {
                return (username -> {
                        log.info(EELFLoggerDelegate.debugLogger, " X509 subject : " + username);
-                       List<MLPPeer> mlpPeers = peerConfigService.getPeer(username);
+                       List<MLPPeer> mlpPeers = peerService.getPeer(username);
                        log.info(EELFLoggerDelegate.debugLogger, " Peers matching X509 subject : " + mlpPeers);
       if(!Utils.isEmptyList(mlpPeers)) {
                                log.info(EELFLoggerDelegate.debugLogger, " We are providing a matching Use ");
@@ -34,10 +34,9 @@ import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.cds.transport.RestPageResponse;
 
 /**
- * 
- *
+ * Handles the business behind the Acumos federation interface
  */
-public interface FederatedCatalogService {
+public interface FederationService {
        
        
        /**
@@ -28,7 +28,7 @@ import org.acumos.cds.domain.MLPPeer;
  * 
  *
  */
-public interface PeerAcumosConfigService {
+public interface PeerService {
 
        /**
         * @return List of Peers configured in the Local Acumos Instance
@@ -29,7 +29,7 @@ import org.acumos.cds.transport.RestPageResponse;
  * 
  *
  */
-public interface PeerAcumosSubscriptionService {
+public interface PeerSubscriptionService {
 
        /**
         * @return List of PeerSubscription configured in the Local Acumos Instance
@@ -38,7 +38,7 @@ import javax.annotation.PostConstruct;
 
 import org.apache.commons.io.FileUtils;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,9 +64,9 @@ import org.acumos.cds.transport.RestPageResponse;
  */
 @Service
 @Conditional(GatewayCondition.class)
-public class FederatedCatalogServiceImpl extends AbstractServiceImpl implements FederatedCatalogService {
+public class FederationServiceImpl extends AbstractServiceImpl implements FederationService {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(FederatedCatalogServiceImpl.class);
+       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(FederationServiceImpl.class);
 
        @Autowired
        private Environment env;
@@ -46,7 +46,7 @@ import com.fasterxml.jackson.databind.ObjectReader;
 import org.apache.commons.io.FileUtils;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.FederatedCatalogService;
+import org.acumos.federation.gateway.service.FederationService;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.util.LocalWatchService;
 import org.acumos.federation.gateway.common.AdapterCondition;
@@ -74,8 +74,8 @@ import org.acumos.cds.transport.RestPageResponse;
 @Service
 @ConfigurationProperties(prefix="catalogLocal")
 @Conditional(AdapterCondition.class)
-public class FederatedCatalogServiceLocalImpl extends AbstractServiceImpl
-                                                                                                                                                                implements FederatedCatalogService {
+public class FederationServiceLocalImpl extends AbstractServiceImpl
+                                                                                                                                                                implements FederationService {
 
        private URI                                                                                             catalogUri;
        private List<FLPSolution>                                       solutions;
@@ -30,7 +30,7 @@ import java.util.Collections;
 
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
+import org.acumos.federation.gateway.service.PeerService;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -46,12 +46,12 @@ import org.acumos.cds.domain.MLPPeer;
  */
 @Service
 @Conditional(GatewayCondition.class)
-public class PeerAcumosConfigServiceImpl extends AbstractServiceImpl implements PeerAcumosConfigService {
+public class PeerServiceImpl extends AbstractServiceImpl implements PeerService {
 
        /**
         * 
         */
-       public PeerAcumosConfigServiceImpl() {
+       public PeerServiceImpl() {
                // TODO Auto-generated constructor stub
        }
 
@@ -63,8 +63,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.acumos.federation.gateway.util.LocalWatchService;
 import org.acumos.federation.gateway.common.AdapterCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
 
 import org.acumos.cds.domain.MLPPeer;
 import org.acumos.cds.domain.MLPPeerSubscription;
@@ -74,15 +74,15 @@ import org.apache.commons.io.IOUtils;
 @Service
 @ConfigurationProperties(prefix="peersLocal")
 @Conditional(AdapterCondition.class)
-public class PeerAcumosServiceLocalImpl
-                                                                                               implements PeerAcumosConfigService,
-                                                                                                                                        PeerAcumosSubscriptionService {
+public class PeerServiceLocalImpl
+                                                                                               implements PeerService,
+                                                                                                                                        PeerSubscriptionService {
 
        private List<FLPPeer>           peers;
        private URI                                                     sourceUri;
        private WatchService            sourceWatcher = null;
 
-       private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerAcumosServiceLocalImpl.class);
+       private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerServiceLocalImpl.class);
 
        @Autowired
        private LocalWatchService       watcher;
@@ -28,7 +28,7 @@ import java.util.stream.Collectors;
 
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
+import org.acumos.federation.gateway.service.PeerSubscriptionService;
 import org.acumos.federation.gateway.util.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
@@ -45,9 +45,7 @@ import org.acumos.cds.transport.RestPageResponse;
  */
 @Service
 @Conditional(GatewayCondition.class)
-public class PeerAcumosSubscriptionServiceImpl extends AbstractServiceImpl implements PeerAcumosSubscriptionService {
-
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(PeerAcumosSubscriptionServiceImpl.class);
+public class PeerSubscriptionServiceImpl extends AbstractServiceImpl implements PeerSubscriptionService {
 
        @Autowired
        private Environment env;
@@ -55,7 +53,7 @@ public class PeerAcumosSubscriptionServiceImpl extends AbstractServiceImpl imple
        /**
         * 
         */
-       public PeerAcumosSubscriptionServiceImpl() {
+       public PeerSubscriptionServiceImpl() {
                // TODO Auto-generated constructor stub
        }
 
index c2af83e..f2da5fc 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ===============LICENSE_END=========================================================
- */
-
-/**
- * 
- */
-/**
- * 
  *
+ * Contains the specifications of federation gateway/adapter services (used through the gateway implementation)
  */
-package org.acumos.federated.gateway.service;
+
+package org.acumos.federation.gateway.service;
index b7c2423..f79dd2b 100644 (file)
@@ -26,8 +26,6 @@ import java.util.Map;
 
 import org.acumos.federation.gateway.common.JsonResponse;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerAcumosConfigService;
-import org.acumos.federation.gateway.service.PeerAcumosSubscriptionService;
 import org.acumos.federation.gateway.service.impl.Clients;
 import org.acumos.federation.gateway.service.impl.FederationClient;
 import org.acumos.federation.gateway.util.Utils;
@@ -97,15 +95,13 @@ public class PeerCommunicationTask implements Runnable {
                try {
                        logger.info(EELFLoggerDelegate.debugLogger, "Peer task: " + mlpPeer);
                
-                       //} else if(env.getProperty("federated.instance") != null && env.getProperty("federated.instance").equalsIgnoreCase("adapter")) {
                                
-      //TODO: X509 Verification and Send Principa verified in the request certificates
       logger.info(EELFLoggerDelegate.debugLogger, "Peer task: invoking getSolutions from Remote instance " + mlpPeer.getApiUrl());
       FederationClient fedClient =
           clients.getFederationClient(this.mlpPeer.getApiUrl());      
 
-               //Map<String, Object> queryParameters = new HashMap<String, Object>();
-               //queryParameters.put("modelTypeCode", mlpSubscription.getSelector()); // Subscriptions
+      //Map<String, Object> queryParameters = new HashMap<String, Object>();
+      //queryParameters.put("modelTypeCode", mlpSubscription.getSelector()); // Subscriptions
        logger.info(EELFLoggerDelegate.debugLogger, "Peer Task: filter " + mlpSubscription.getSelector());
                        
        JsonResponse<List<MLPSolution>> jsonResponse = 
index f195337..69a1f47 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ===============LICENSE_END=========================================================
- */
-
-/**
- * 
- */
-/**
- * 
  *
+ * Jobs performed within the federation gateway/adapter, such as peer subscription processing
  */
+
 package org.acumos.federation.gateway.task;
index 3688ddd..da9af74 100644 (file)
@@ -27,7 +27,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.controller.FederatedCatalogController;
 
 import org.acumos.cds.domain.MLPAccessType;
 
@@ -41,7 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class Utils {
 
-       private final static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FederatedCatalogController.class);
+       private final static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Utils.class);
        
        public static ObjectMapper objectMapper = new ObjectMapper();
        
index e0a12e9..e760f1c 100644 (file)
@@ -20,9 +20,9 @@
 
 #Instance of this component could be gateway or adapter
 #Based on the value configured, the behavior of this instance will vary.
-federated.instance=gateway
-federated.instance.name=ATT
-#federated.peerGatewayOperator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
+federation.instance=gateway
+federation.instance.name=ATT
+#federation.operator=d468656f-57d0-46e3-9f94-7ffa4f66dc03
 
 security.user.name=federated_client
 #security.user.password = ENC(CTQD7Xk5bOIuC4MaqRZtzjW1K4ArjCjr)
index aaef587..dd9eec4 100644 (file)
@@ -7,16 +7,15 @@ server.ssl.trust-store = src/test/resources/acumosTrustStore.jks
 server.ssl.trust-store-password = acumos
 server.ssl.client-auth = want
 
-client.ssl.key-store = file:///home/src/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
+client.ssl.key-store = file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa.pkcs12
 client.ssl.key-store-password = acumosa
 client.ssl.key-store-type = PKCS12
 client.ssl.key-password = acumosa
 
 #pretend we are an adapter so that we can use local peer config
-federated.instance=adapter
-federated.instance.name=ghost
+federation.instance=adapter
+federation.instance.name=ghost
 
-#peersLocal.sourceUri=classpath:acumosa-peers.json
-#peersLocal.catalogUri=classpath:acumosa-catalog.json
-peersLocal.sourceUri=file:///home/src/acumos/federation/gateway/src/test/resources/acumosa-peers.json
-catalogLocal.catalogUri=file:///home/src/acumos/federation/gateway/src/test/resources/acumosa-catalog.json
+#replace 
+peersLocal.sourceUri=file:///{path_to_src}/acumos/federation/gateway/src/test/resources/acumosa-peers.json
+catalogLocal.catalogUri=file:///{path_to_src}acumos/federation/gateway/src/test/resources/acumosa-catalog.json
index b2e277b..7b25b4d 100644 (file)
@@ -7,15 +7,15 @@ server.ssl.trust-store = src/test/resources/acumosTrustStore.jks
 server.ssl.trust-store-password = acumos
 server.ssl.client-auth = want
 
-client.ssl.key-store = file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb.pkcs12
+client.ssl.key-store = file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb.pkcs12
 client.ssl.key-store-password = acumosb
 client.ssl.key-store-type = PKCS12
 client.ssl.key-password = acumosb
 
 #pretend we are an adapter so that we can use local peer config
-federated.instance=adapter
-federated.instance.name=ghost
+federation.instance=adapter
+federation.instance.name=ghost
 
-peersLocal.sourceUri=file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb-peers.json
-catalogLocal.catalogUri=file:///home/jora/src/acumos/federation/gateway/src/test/resources/acumosb-catalog.json
+peersLocal.sourceUri=file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb-peers.json
+catalogLocal.catalogUri=file:///#{systemProperties['user.dir']}/gateway/src/test/resources/acumosb-catalog.json