Revise POMs for LF CI/CD env 63/463/10
authorChristopher Lott (cl778h) <clott@research.att.com>
Thu, 11 Jan 2018 16:54:30 +0000 (11:54 -0500)
committerChristopher Lott (cl778h) <clott@research.att.com>
Fri, 19 Jan 2018 20:22:46 +0000 (15:22 -0500)
Revise docker projects to deploy images to nexus3.acumos.org
  using appropriate properties in docker plugin config.
Upgrade to use acumos-nexus-client v2.0.0-SNAPSHOT.
Upgrade to use cmn-data-svc-client 1.12.0-SNAPSHOT.
Drop repositories section.
Adjust javadoc comments to silence warnings.

Change-Id: I9af51d1e4527faf32ca6a64c348ee979cb901bdc
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
14 files changed:
gateway/.gitignore [new file with mode: 0644]
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/adapter/Ghost.java
gateway/src/main/java/org/acumos/federation/gateway/adapter/PeerGateway.java
gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerController.java
gateway/src/main/java/org/acumos/federation/gateway/service/PeerService.java
gateway/src/main/java/org/acumos/federation/gateway/service/PeerSubscriptionService.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/AbstractClient.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/Clients.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/FederationClient.java
gateway/src/main/java/org/acumos/federation/gateway/task/PeerCommunicationTask.java
gateway/src/main/java/org/acumos/federation/gateway/task/PeerCommunicationTaskScheduler.java
pom.xml

diff --git a/gateway/.gitignore b/gateway/.gitignore
new file mode 100644 (file)
index 0000000..fbdf7eb
--- /dev/null
@@ -0,0 +1,3 @@
+/.classpath
+/.project
+/.settings/
index bf423a6..854fce9 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 />
+               <!-- silence warning about parent relative path -->
+               <relativePath />
        </parent>
 
        <properties>
-               <encoding>UTF-8</encoding>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                <!-- Stand-alone RESTFul application -->
                <start-class>org.acumos.federation.gateway.Application</start-class>
                <!-- Jenkins invokes mvn with argument -Dbuild.number=${BUILD_NUMBER} -->
                <build.number>0</build.number>
-               <eelf.version>1.0.0</eelf.version>
                <!-- tests require database to be running -->
                <skipTests>false</skipTests>
-               <!-- Docker daemon -->
-               <docker.host.url>unix:/var/run/docker.sock</docker.host.url>
-               <!-- Docker image registry -->
-               <docker.registry.url>Set by Jenkins</docker.registry.url>
-               <docker.registry.login>Registry userId - supplied by jenkins</docker.registry.login>
-               <docker.registry.password>Registry password - supplied by jenkins</docker.registry.password>
-               <!--
-               <docker.registry.url>registry.hub.docker.io</docker.registry.url>
-               --> 
                <!-- dependencies versions -->
                <slf4j.version>1.7.25</slf4j.version>
                <logback.version>1.2.3</logback.version>
                <spring.boot.starter.security.version>1.5.8.RELEASE</spring.boot.starter.security.version>
                <spring.boot.starter.test.version>1.5.8.RELEASE</spring.boot.starter.test.version>
                <spring.boot.configuration.processor.version>1.5.8.RELEASE</spring.boot.configuration.processor.version>
-               <!-- All acumos.nexus.* are overridden by Jenkins settings -->
-               <acumos.nexus.url>http://cognita-nexus01.eastus.cloudapp.azure.com:8081</acumos.nexus.url>
-               <acumos.nexus.snapshot.path>repository/repo_cognita_platform_maven_snapshots</acumos.nexus.snapshot.path>
-               <acumos.nexus.release.path>repository/repo_cognita_platform_maven</acumos.nexus.release.path>
+               <!-- Not supplied to all jobs; e.g., Javadoc -->
+               <docker.pull.registry>nexus3.acumos.org:10001</docker.pull.registry>
+               <!-- Supplied by Jenkins -->
+               <docker.push.registry>${env.NEXUS3_PUSH_REGISTRY}</docker.push.registry>
                <maven.build.timestamp.format>yyyy.MM.dd_HH.mm</maven.build.timestamp.format>
        </properties>
 
-       <repositories>
-               <repository>
-                       <id>acumos-snapshots</id>
-                       <name>acumos-repository-snapshots</name>
-                       <url>${acumos.nexus.url}/${acumos.nexus.snapshot.path}</url>
-               </repository>
-               <repository>
-                       <id>acumos-releases</id>
-                       <name>acumos-repository-releases</name>
-                       <url>${acumos.nexus.url}/${acumos.nexus.release.path}</url>
-               </repository>
-               <repository>
-                       <id>onap-snapshots</id>
-                       <name>ONAP Snapshot Repository</name>
-                       <url>${onap.nexus.url}/${onap.nexus.snapshot.path}</url>
-               </repository>
-               <repository>
-                       <id>onap-releases</id>
-                       <name>ONAP Release Repository</name>
-                       <url>${onap.nexus.url}/${onap.nexus.release.path}</url>
-               </repository>
-       </repositories>
+       <!-- Some dependencies are specific to Acumos, but this POM defines no repositories 
+               section. The Jenkins server specifies Acumos repositories. Developers should 
+               ensure their ~/.m2/settings.xml file has the following URLs in both the repositories 
+               and pluginRepositories sections or in a profile: https://nexus.acumos.org/content/repositories/snapshots/ 
+               https://nexus.acumos.org/content/repositories/releases/ -->
 
        <dependencies>
                <dependency>
-                       <groupId>org.acumos</groupId>
+                       <groupId>org.acumos.acumos-nexus-client</groupId>
                        <artifactId>acumos-nexus-client</artifactId>
-                       <!-- <version>1.0.0-SNAPSHOT</version> -->
-                       <version>1.12.0</version>
+                       <version>2.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> -->
+                       <version>1.12.0-SNAPSHOT</version>
                </dependency>
                <dependency>
-             <groupId>org.json</groupId>
-             <artifactId>json</artifactId>
-             <version>20160212</version>
-           </dependency>
+                       <groupId>org.json</groupId>
+                       <artifactId>json</artifactId>
+                       <version>20160212</version>
+               </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
-                       <version>${slf4j.version}</version>
+                       <!-- spring sets the <version>${slf4j.version}</version> -->
                </dependency>
                <dependency>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
-                       <version>${logback.version}</version>
+                       <!-- spring sets the <version>${logback.version}</version> -->
                </dependency>
                <dependency>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-core</artifactId>
-                       <version>${logback.version}</version>
+                       <!-- spring sets the <version>${logback.version}</version> -->
                </dependency>
                <dependency>
-       <groupId>org.springframework.boot</groupId>
-               <artifactId>spring-boot-starter-security</artifactId>
-                       <version>${spring.boot.starter.security.version}</version>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-security</artifactId>
+                       <!-- spring sets the ${spring.boot.starter.security.version}</version> -->
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-web</artifactId>
-                       <version>${spring.boot.starter.web.version}</version>
+                       <!-- spring sets the <version>${spring.boot.starter.web.version}</version> -->
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-configuration-processor</artifactId>
-                       <version>${spring.boot.configuration.processor.version}</version>
+                       <!-- spring sets the <version>${spring.boot.configuration.processor.version}</version> -->
                        <optional>true</optional>
                </dependency>
                <dependency>
-                   <groupId>org.apache.httpcomponents</groupId>
-                   <artifactId>httpclient</artifactId>
-                   <version>4.5</version>
+                       <groupId>org.apache.httpcomponents</groupId>
+                       <artifactId>httpclient</artifactId>
+                       <!-- spring sets the <version>4.5</version> -->
                </dependency>
                <dependency>
-       <groupId>org.springframework.shell</groupId>
-       <artifactId>spring-shell</artifactId>
-       <version>1.2.0.RELEASE</version>
+                       <groupId>org.springframework.shell</groupId>
+                       <artifactId>spring-shell</artifactId>
+                       <version>1.2.0.RELEASE</version>
                </dependency>
                <dependency>
                        <groupId>io.springfox</groupId>
                <dependency>
                        <groupId>com.att.eelf</groupId>
                        <artifactId>eelf-core</artifactId>
-                       <version>${eelf.version}</version>
+                       <version>1.0.0</version>
                </dependency>
                <dependency>
                        <groupId>javax.inject</groupId>
                        <version>0.6.0</version>
                </dependency>
                <dependency>
-               <groupId>org.python</groupId>
-               <artifactId>jython-standalone</artifactId>
-               <version>2.7.1-rc3</version>
+                       <groupId>org.python</groupId>
+                       <artifactId>jython-standalone</artifactId>
+                       <version>2.7.1-rc3</version>
                </dependency>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
-                       <version>3.8.1</version>
+                       <!-- spring sets the <version>3.8.1</version> -->
                        <scope>test</scope>
                </dependency>
                <dependency>
-               <groupId>commons-cli</groupId>
-               <artifactId>commons-cli</artifactId>
-               <version>1.2</version>
-               </dependency>
-               <dependency>
-               <groupId>org.apache.commons</groupId>
-               <artifactId>commons-lang3</artifactId>
-               <version>3.6</version>
+                       <groupId>commons-cli</groupId>
+                       <artifactId>commons-cli</artifactId>
+                       <version>1.2</version>
                </dependency>
                <dependency>
-       <groupId>org.aspectj</groupId>
-       <artifactId>aspectjweaver</artifactId>
-       <version>1.8.13</version>
+                       <groupId>org.apache.commons</groupId>
+                       <artifactId>commons-lang3</artifactId>
+                       <version>3.6</version>
                </dependency>
-
                <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <version>4.12</version>
-                       <scope>test</scope>
+                       <groupId>org.aspectj</groupId>
+                       <artifactId>aspectjweaver</artifactId>
+                       <version>1.8.13</version>
                </dependency>
                <dependency>
                        <groupId>org.assertj</groupId>
                        <artifactId>assertj-core</artifactId>
-                       <version>3.8.0</version>
+                       <!-- spring sets the <version>3.8.0</version> -->
                        <scope>test</scope>
                </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
-                       <version>${spring.boot.starter.test.version}</version>
+                       <!-- spring sets the <version>1.5.3.RELEASE</version> -->
                        <scope>test</scope>
                </dependency>
        </dependencies>
-       
+
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
-                               <version>3.0</version>
+                               <!-- spring sets the <version>3.0</version> -->
                                <configuration>
                                        <source>1.8</source>
                                        <target>1.8</target>
                                </configuration>
                        </plugin>
+                       <!-- Add the build number to the jar manifest. Spring-Boot uses a complex 
+                               packaging process that makes access to the original Manifest.MF very difficult. 
+                               However, Java provides access to the implementation version for a package, 
+                               so cram the build number into there. -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                                </manifest>
                                                <manifestEntries>
-                                                       <Build-Number>${project.version}.${build.number}</Build-Number>
-                                                       <Build-Time>${maven.build.timestamp}</Build-Time>
+                                                       <Implementation-Version>${project.version}-b${build.number}</Implementation-Version>
                                                </manifestEntries>
                                        </archive>
                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <version>2.10</version>
-        <executions>
-          <execution>
-            <id>copy-dependencies</id>
-            <phase>package</phase>
-            <goals>
-              <goal>copy-dependencies</goal>
-            </goals>
-            <configuration>
-              <outputDirectory>${project.build.directory}/deps</outputDirectory>
-              <overWriteReleases>true</overWriteReleases>
-              <overWriteSnapshots>true</overWriteSnapshots>
-              <overWriteIfNewer>true</overWriteIfNewer>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-dependency-plugin</artifactId>
+                               <version>2.10</version>
+                               <executions>
+                                       <execution>
+                                               <id>copy-dependencies</id>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>copy-dependencies</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <outputDirectory>${project.build.directory}/deps</outputDirectory>
+                                                       <overWriteReleases>true</overWriteReleases>
+                                                       <overWriteSnapshots>true</overWriteSnapshots>
+                                                       <overWriteIfNewer>true</overWriteIfNewer>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <!-- No need to deploy Spring super-boot -->
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-deploy-plugin</artifactId>
+                               <!-- Spring sets the <version>2.8</version> -->
+                               <configuration>
+                                       <skip>true</skip>
+                               </configuration>
+                       </plugin>
                        <plugin>
                                <groupId>io.fabric8</groupId>
                                <artifactId>docker-maven-plugin</artifactId>
-                               <version>0.21.0</version>
+                               <version>0.23.0</version>
                                <configuration>
                                        <verbose>true</verbose>
                                        <dockerHost>${docker.host.url}</dockerHost>
                                        </authConfig>
                                        <images>
                                                <image>
+                                                       <!-- Specify a tag to avoid default tag "latest" -->
                                                        <name>federation-gateway:${project.version}</name>
                                                        <build>
-                                                               <!-- This is the same FROM used in a Dockerfile -->
-                                                               <!-- <from>openjdk:8-jdk</from> -->
                                                                <from>frolvlad/alpine-oraclejdk8:slim</from>
                                                                <tags>
-                                                               <tag>latest</tag>
-                                                       <tag>${project.version}</tag>
-                                                               <tag>${maven.build.timestamp}</tag>
+                                                                       <!-- Add tag with build number -->
+                                                                       <tag>${project.version}-b${build.number}</tag>
                                                                </tags>
                                                                <assembly>
                                                                        <inline>
                                                                </assembly>
                                                                <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
-                                                                       <shell><![CDATA[        cd /maven; java -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}]]></shell>
+                                                                       <!-- CDATA prevents Eclipse formatter from breaking line -->
+                                                                       <shell><![CDATA[cd /maven; java -Djavax.net.debug=ssl -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}]]></shell>
                                                                </cmd>
                                                        </build>
                                                </image>
                                                <image>
+                                                       <!-- Specify a tag to avoid default tag "latest" -->
                                                        <name>federation-gateway-test:${project.version}</name>
                                                        <build>
-                                                               <!-- This is the same FROM used in a Dockerfile -->
-                                                               <!-- <from>openjdk:8-jdk</from> -->
                                                                <from>frolvlad/alpine-oraclejdk8:slim</from>
                                                                <tags>
-                                                               <tag>latest</tag>
-                                                       <tag>${project.version}</tag>
-                                                               <tag>${maven.build.timestamp}</tag>
+                                                                       <!-- Add tag with build number -->
+                                                                       <tag>${project.version}-b${build.number}</tag>
                                                                </tags>
                                                                <assembly>
                                                                        <inline>
                                                                                                <outputDirectory />
                                                                                                <destName>application.properties</destName>
                                                                                        </file>
-<!--
-       need the following two for server config
--->
+                                                                                       <!-- need the following two for server config -->
                                                                                        <file>
                                                                                                <source>src/test/resources/acumosa.pkcs12</source>
                                                                                                <outputDirectory />
                                                                                        </file>
                                                                                </files>
                                                                                <fileSets>
-                      <fileSet>
-                        <directory>${project.build.directory}/deps/</directory>
-                        <outputDirectory>/libs/</outputDirectory>
-                        <includes>
-                          <include>*</include>
-                        </includes>
-                        <fileMode>0755</fileMode>
+                                                                                       <fileSet>
+                                                                                               <directory>${project.build.directory}/deps/</directory>
+                                                                                               <outputDirectory>/libs/</outputDirectory>
+                                                                                               <includes>
+                                                                                                       <include>*</include>
+                                                                                               </includes>
+                                                                                               <fileMode>0755</fileMode>
                                                                                        </fileSet>
                                                                                </fileSets>
                                                                        </inline>
                                                                </assembly>
-                                                               <!-- This is the same CMD used in a Dockerfile -->
                                                                <cmd>
-                                                                       <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><![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>
--->
+                                                                       <!-- CDATA prevents Eclipse formatter from breaking line -->
+                                                                       <shell><![CDATA[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>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> -->
                                                                </cmd>
                                                        </build>
                                                </image>
                                        <processEndTag>===============LICENSE_END=========================================================</processEndTag>
                                        <sectionDelimiter>===================================================================================</sectionDelimiter>
                                        <inceptionYear>2017</inceptionYear>
-                                       <organizationName>AT&amp;T Intellectual Property &amp; Tech Mahindra. All rights reserved.</organizationName>
+                                       <organizationName>AT&amp;T Intellectual Property &amp; Tech
+                                               Mahindra. All rights reserved.</organizationName>
                                        <projectName>Acumos</projectName>
                                        <canUpdateCopyright>true</canUpdateCopyright>
                                        <canUpdateDescription>true</canUpdateDescription>
                                                <include>**/*.java</include>
                                        </includes>
                                </configuration>
-<!--
-                               <executions>
-                                       <execution>
-                                               <id>first</id>
-                                               <goals>
-                                                       <goal>update-file-header</goal>
-                                               </goals>
-                                               <phase>process-sources</phase>
-                                       </execution>
-                               </executions>
--->
+                               <!-- <executions> <execution> <id>first</id> <goals> <goal>update-file-header</goal> 
+                                       </goals> <phase>process-sources</phase> </execution> </executions> -->
                        </plugin>
                        <plugin>
                                <groupId>org.jacoco</groupId>
                                <artifactId>jacoco-maven-plugin</artifactId>
-                               <version>0.7.6.201602180812</version>
+                               <version>0.7.9</version>
                                <executions>
                                        <execution>
                                                <id>default-prepare-agent</id>
 
                </plugins>
        </build>
-       <distributionManagement>
-               <snapshotRepository>
-                       <!-- must match ID in Jenkins settings -->
-                       <id>acumos-nexus</id>
-                       <name>acumos-repository-snapshots</name>
-                       <url>${acumos.nexus.url}/${acumos.nexus.snapshot.path}</url>
-               </snapshotRepository>
-               <repository>
-                       <!-- must match ID in Jenkins settings -->
-                       <id>acumos-nexus</id>
-                       <name>acumos-repository-releases</name>
-                       <url>${acumos.nexus.url}/${acumos.nexus.release.path}</url>
-               </repository>
-       </distributionManagement>
 </project>
index 0446a54..d5ec4d4 100644 (file)
  * ===============LICENSE_END=========================================================
  */
 
-package org.acumos.federation.gateway.gateway.adapter;
+package org.acumos.federation.gateway.adapter;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
-
-import java.net.URI;
-
+import java.util.HashMap;
 import java.util.List;
-import java.util.LinkedList;
 import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.UUID;
 import java.util.stream.Collectors;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 
-import org.springframework.http.HttpStatus;
-import org.springframework.web.client.HttpClientErrorException;
-
-import org.springframework.core.io.Resource;
-import org.springframework.stereotype.Component;
+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.common.GhostAdapterCondition;
+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.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.context.annotation.Conditional;
 //import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.context.annotation.Conditional;
 import org.springframework.context.event.EventListener;
+import org.springframework.core.io.Resource;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.common.GhostAdapterCondition;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
-import org.acumos.federation.gateway.service.impl.FederationClient;
-import org.acumos.federation.gateway.service.impl.Clients;
-
-import org.acumos.cds.domain.MLPPeer;
-import org.acumos.cds.domain.MLPArtifact;
-import org.acumos.cds.domain.MLPSolution;
-import org.acumos.cds.domain.MLPSolutionRevision;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-
-import org.apache.commons.io.IOUtils;
-
+import org.springframework.stereotype.Component;
 
 @Component("ghost")
-//@Scope("singleton")
-@ConfigurationProperties(prefix="ghost")
+// @Scope("singleton")
+@ConfigurationProperties(prefix = "ghost")
 @Conditional(GhostAdapterCondition.class)
 public class Ghost {
 
        private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Ghost.class);
-       private TaskExecutor    taskExecutor; 
+       private TaskExecutor taskExecutor;
 
-       private Map<String, Map<String, MLPSolution>>   imports = 
-                                               new HashMap<String, Map<String, MLPSolution>>();
+       private Map<String, Map<String, MLPSolution>> imports = new HashMap<String, Map<String, MLPSolution>>();
        @Autowired
        private Clients clients;
 
-       
        @PostConstruct
        public void initGhost() {
                logger.debug(EELFLoggerDelegate.debugLogger, "initGhost");
 
                this.taskExecutor = new ThreadPoolTaskExecutor();
-               ((ThreadPoolTaskExecutor)this.taskExecutor).setCorePoolSize(1);
-    ((ThreadPoolTaskExecutor)this.taskExecutor).setMaxPoolSize(1);
-    ((ThreadPoolTaskExecutor)this.taskExecutor).setQueueCapacity(25);
-    ((ThreadPoolTaskExecutor)this.taskExecutor).initialize();
+               ((ThreadPoolTaskExecutor) this.taskExecutor).setCorePoolSize(1);
+               ((ThreadPoolTaskExecutor) this.taskExecutor).setMaxPoolSize(1);
+               ((ThreadPoolTaskExecutor) this.taskExecutor).setQueueCapacity(25);
+               ((ThreadPoolTaskExecutor) this.taskExecutor).initialize();
 
                // Done
                logger.debug(EELFLoggerDelegate.debugLogger, "Ghost available");
@@ -109,10 +87,9 @@ public class Ghost {
                taskExecutor.execute(new GhostTask(theEvent.getPeer(), theEvent.getSolutions()));
        }
 
-
        public class GhostTask implements Runnable {
 
-               private MLPPeer         peer;
+               private MLPPeer peer;
                private List<MLPSolution> solutions;
 
                public GhostTask(MLPPeer thePeer, List<MLPSolution> theSolutions) {
@@ -125,61 +102,57 @@ public class Ghost {
                        Map<String, MLPSolution> peerImports = null;
 
                        synchronized (imports) {
-                               peerImports = imports.computeIfAbsent(peer.getPeerId(),
-                                                                                                                                                                                       pid -> new HashMap());
+                               peerImports = imports.computeIfAbsent(peer.getPeerId(), pid -> new HashMap());
                        }
 
                        synchronized (peerImports) {
-                               for (MLPSolution solution: this.solutions) {
-                                       
+                               for (MLPSolution solution : this.solutions) {
+
                                        MLPSolution peerImport = peerImports.get(solution.getSolutionId());
                                        if (peerImport == null) {
                                                logger.debug(EELFLoggerDelegate.debugLogger, "New solution");
                                                peerImports.put(solution.getSolutionId(), solution);
-                                       }
-                                       else {
+                                       } else {
                                                logger.debug(EELFLoggerDelegate.debugLogger, "Existing solution");
                                                if (peerImport.getModified().equals(solution.getModified())) {
                                                        logger.debug(EELFLoggerDelegate.debugLogger, "No updates");
-                                               }
-                                               else {
+                                               } else {
                                                        logger.debug(EELFLoggerDelegate.debugLogger, "Has updates");
                                                }
                                        }
 
-                                       FederationClient fedClient =
-                                               clients.getFederationClient(this.peer.getApiUrl());
+                                       FederationClient fedClient = clients.getFederationClient(this.peer.getApiUrl());
 
                                        List<MLPSolutionRevision> revisions = null;
                                        try {
-                                               revisions = (List<MLPSolutionRevision>)
-                                                       fedClient.getSolutionRevisions(solution.getSolutionId()).getResponseBody();
-                                       }
-                                       catch (Exception x) {
+                                               revisions = (List<MLPSolutionRevision>) fedClient.getSolutionRevisions(solution.getSolutionId())
+                                                               .getResponseBody();
+                                       } catch (Exception x) {
                                                logger.warn(EELFLoggerDelegate.debugLogger, "Failed to retrieve revisions", x);
                                                continue;
                                        }
-                                       logger.debug(EELFLoggerDelegate.debugLogger, "Received " + revisions.size() + " revisions " + revisions);
-                       
+                                       logger.debug(EELFLoggerDelegate.debugLogger,
+                                                       "Received " + revisions.size() + " revisions " + revisions);
+
                                        List<MLPArtifact> artifacts = null;
                                        try {
-                                               artifacts = (List<MLPArtifact>)
-                                                       fedClient.getArtifacts(solution.getSolutionId(), revisions.get(revisions.size()-1).getRevisionId())
-                                                               .getResponseBody();
-                                       }
-                                       catch (Exception x) {
+                                               artifacts = (List<MLPArtifact>) fedClient.getArtifacts(solution.getSolutionId(),
+                                                               revisions.get(revisions.size() - 1).getRevisionId()).getResponseBody();
+                                       } catch (Exception x) {
                                                logger.warn(EELFLoggerDelegate.debugLogger, "Failed to retrieve artifacts", x);
                                                continue;
                                        }
-                                       logger.debug(EELFLoggerDelegate.debugLogger, "Received " + artifacts.size() + " artifacts " + artifacts);
+                                       logger.debug(EELFLoggerDelegate.debugLogger,
+                                                       "Received " + artifacts.size() + " artifacts " + artifacts);
 
-                                       for (MLPArtifact artifact: artifacts) {
+                                       for (MLPArtifact artifact : artifacts) {
                                                Resource artifactContent = null;
                                                try {
                                                        artifactContent = fedClient.downloadArtifact(artifact.getArtifactId());
-                                               logger.warn(EELFLoggerDelegate.debugLogger, "Received artifact content: " + new BufferedReader(new InputStreamReader(artifactContent.getInputStream())).lines().collect(Collectors.joining("\n")));
-                                               }
-                                               catch (Exception x) {
+                                                       logger.warn(EELFLoggerDelegate.debugLogger, "Received artifact content: "
+                                                                       + new BufferedReader(new InputStreamReader(artifactContent.getInputStream()))
+                                                                                       .lines().collect(Collectors.joining("\n")));
+                                               } catch (Exception x) {
                                                        logger.debug(EELFLoggerDelegate.debugLogger, "Failed to download artifact", x);
                                                }
                                        }
index f9564d7..1a3630f 100644 (file)
 
 package org.acumos.federation.gateway.adapter;
 
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
 import java.util.List;
-import java.util.stream.Collectors;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 
+import org.acumos.cds.AccessTypeCode;
+import org.acumos.cds.ValidationStatusCode;
+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;
 import org.acumos.federation.gateway.common.GatewayCondition;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
@@ -36,33 +40,19 @@ import org.acumos.federation.gateway.service.impl.Clients;
 import org.acumos.federation.gateway.service.impl.FederationClient;
 import org.acumos.federation.gateway.util.Errors;
 import org.acumos.federation.gateway.util.Utils;
-
 import org.acumos.nexus.client.data.UploadArtifactInfo;
-
-import org.springframework.beans.factory.annotation.Autowired;
 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.env.Environment;
+import org.springframework.core.io.Resource;
 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.springframework.web.client.HttpClientErrorException;
-import org.springframework.core.io.Resource;
-import org.springframework.http.HttpStatus;
-
-import org.acumos.cds.AccessTypeCode;
-import org.acumos.cds.ValidationStatusCode;
-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")
@@ -72,7 +62,6 @@ import org.acumos.cds.domain.MLPSolutionRevision;
 public class PeerGateway {
 
        private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerGateway.class);
-       private String                          operator;
        private TaskExecutor    taskExecutor; 
        @Autowired
        private Environment env;
index 3b86753..7994640 100644 (file)
@@ -62,53 +62,16 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping("/")
 public class CatalogController extends AbstractController {
 
-       @Autowired
-       CatalogService catalogService;
+       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(CatalogController.class.getName());
 
-       // /**
-       // * @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;
-       // }
+       @Autowired
+       private CatalogService catalogService;
 
        /**
         * @param theHttpResponse
         *            HttpServletResponse
         * @param theSelector
+        *            Solutions selector
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
@@ -183,6 +146,7 @@ public class CatalogController extends AbstractController {
 
        /**
         * @param theSolutionId
+        *            Solution ID
         * @param theHttpResponse
         *            HttpServletResponse
         * @return List of Published ML Solutions in JSON format.
@@ -222,7 +186,9 @@ public class CatalogController extends AbstractController {
        /**
         * 
         * @param theSolutionId
+        *            Solution ID
         * @param theRevisionId
+        *            Revision ID
         * @param theHttpResponse
         *            HttpServletResponse
         * @return List of Published ML Solutions in JSON format.
@@ -266,7 +232,9 @@ public class CatalogController extends AbstractController {
         * @param theHttpResponse
         *            HttpServletResponse
         * @param theSolutionId
+        *            Solution ID
         * @param theRevisionId
+        *            Revision ID
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
@@ -326,6 +294,7 @@ public class CatalogController extends AbstractController {
         * @param theHttpResponse
         *            HttpServletResponse
         * @param theArtifactId
+        *            Artifact ID
         * @return Archive file of the Artifact for the Solution.
         */
        @CrossOrigin
index 42ab9c1..b74fba1 100644 (file)
@@ -22,62 +22,48 @@ package org.acumos.federation.gateway.controller;
 
 import java.util.List;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.acumos.cds.domain.MLPPeer;
+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.PeerService;
+import org.acumos.federation.gateway.service.ServiceContext;
 import org.springframework.beans.factory.annotation.Autowired;
-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.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.acumos.cds.domain.MLPPeer;
-import org.acumos.federation.gateway.common.JSONTags;
-import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.common.API;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.acumos.federation.gateway.service.PeerService;
-import org.acumos.federation.gateway.service.ServiceContext;
-import org.acumos.federation.gateway.security.Peer;
-
 import io.swagger.annotations.ApiOperation;
 
-/**
- * 
- *
- */
 @Controller
 @RequestMapping("/")
 public class PeerController extends AbstractController {
-       
-       
+
+       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(PeerController.class.getName());
+
        @Autowired
        PeerService peerService;
-       
+
        /**
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *                      HttpServletResponse
+        * @param theHttpResponse
+        *            HttpServletResponse
         * @return List of Published ML Solutions in JSON format.
         */
        @CrossOrigin
        @PreAuthorize("hasAuthority('PEERS_ACCESS')")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list of peers from local Acumos Instance .", response = MLPPeer.class, responseContainer = "List")
-       @RequestMapping(value = {API.Paths.PEERS}, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = { API.Paths.PEERS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
        public JsonResponse<List<MLPPeer>> getSolutions(
-                       /* HttpServletRequest theHttpRequest,*/
+                       /* HttpServletRequest theHttpRequest, */
                        HttpServletResponse theHttpResponse) {
 
                JsonResponse<List<MLPPeer>> response = null;
@@ -88,12 +74,11 @@ public class PeerController extends AbstractController {
                        log.debug(EELFLoggerDelegate.debugLogger, "getPeers");
 
                        peers = peerService.getPeers(new ControllerContext());
-/*
- * TODO: We only expose simple peers, not the partners.
- * But we only serve this service
- * to parners so .. ?? No pb.
- */
-                       if(peers != null) {
+                       /*
+                        * TODO: We only expose simple peers, not the partners. But we only serve this
+                        * service to parners so .. ?? No pb.
+                        */
+                       if (peers != null) {
                                response.setResponseBody(peers);
                                response.setResponseCode(String.valueOf(HttpServletResponse.SC_OK));
                                response.setResponseDetail(JSONTags.TAG_STATUS_SUCCESS);
@@ -114,8 +99,7 @@ public class PeerController extends AbstractController {
        protected class ControllerContext implements ServiceContext {
 
                public Peer getPeer() {
-                       return (Peer)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+                       return (Peer) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                }
        }
 }
-
index 3a7a7e1..f9a8e06 100644 (file)
@@ -34,36 +34,44 @@ public interface PeerService {
         * @return List of Peers configured in the Local Acumos Instance
         */
        List<MLPPeer> getPeers();
-       
+
        /**
         * Provide the list of locally registered peers to one of our peers
+        * 
+        * @param theContext
+        *            Service context
+        * @return List of peers
         */
        List<MLPPeer> getPeers(ServiceContext theContext);
-       
+
        /**
+        * @param subjectName
+        *            Subject name
         * @return Peer based on the configured Subject Name
         */
        List<MLPPeer> getPeer(String subjectName);
-       
+
        MLPPeer getOnePeer(String peerId);
-       
+
        /**
-        * @param mlpPeer MLPPeer Configuration that needs to be created on the Platform
+        * @param mlpPeer
+        *            MLPPeer Configuration that needs to be created on the Platform
         * 
         * @return Peer configuration that has been created.
         */
        MLPPeer savePeer(MLPPeer mlpPeer);
-       
-       
+
        /**
-        * @param mlpPeer MLPPeer Configuration that needs to be updated on the Platform
+        * @param mlpPeer
+        *            MLPPeer Configuration that needs to be updated on the Platform
         * 
         * @return Peer configuration that has been updated.
         */
        boolean updatePeer(MLPPeer mlpPeer);
-       
+
        /**
-        * @param mlpPeer MLPPeer Configuration that needs to be deleted on the Platform
+        * @param mlpPeer
+        *            MLPPeer Configuration that needs to be deleted on the Platform
         * 
         * @return true if successfully deleted else false.
         */
index eda1f68..d8fe980 100644 (file)
@@ -23,7 +23,6 @@ package org.acumos.federation.gateway.service;
 import java.util.List;
 
 import org.acumos.cds.domain.MLPPeerSubscription;
-import org.acumos.cds.transport.RestPageResponse;
 
 /**
  * 
@@ -32,32 +31,38 @@ import org.acumos.cds.transport.RestPageResponse;
 public interface PeerSubscriptionService {
 
        /**
+        * @param peerId
+        *            Peer ID
         * @return List of PeerSubscription configured in the Local Acumos Instance
         */
        List<MLPPeerSubscription> getPeerSubscriptions(String peerId);
-       
+
        /**
+        * @param subId
+        *            Peer subscription ID
         * @return Peer Subscription based on the configured Subject Name
         */
        MLPPeerSubscription getPeerSubscription(Long subId);
-       
+
        /**
-        * @param mlpPeerSubscription MLPPeer Configuration that needs to be created on the Platform
+        * @param mlpPeerSubscription
+        *            MLPPeer Configuration that needs to be created on the Platform
         * 
         * @return MLPPeerSubscription configuration that has been created.
         */
        MLPPeerSubscription savePeerSubscription(MLPPeerSubscription mlpPeerSubscription);
-       
-       
+
        /**
-        * @param mlpPeerSubscription MLPPeer Configuration that needs to be updated on the Platform
+        * @param mlpPeerSubscription
+        *            MLPPeer Configuration that needs to be updated on the Platform
         * 
         * @return MLPPeerSubscription configuration that has been updated.
         */
        boolean updatePeerSubscription(MLPPeerSubscription mlpPeerSubscription);
-       
+
        /**
-        * @param mlpPeerSubscription MLPPeerSubscription that needs to be deleted on the Platform
+        * @param mlpPeerSubscription
+        *            MLPPeerSubscription that needs to be deleted on the Platform
         * 
         * @return true if successfully deleted else false.
         */
index 39d28b6..a46a7cc 100644 (file)
@@ -24,68 +24,40 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
-import org.apache.http.HttpHost;
-import org.apache.http.client.HttpClient;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.acumos.federation.gateway.common.JsonResponse;
+import org.acumos.cds.transport.RestPageRequest;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.HttpStatusCodeException;
-import org.springframework.web.client.RestTemplate;
+import org.apache.http.client.HttpClient;
 import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.web.util.UriComponentsBuilder;
-
 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.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
 
 /**
  * 
  * 
  * 
- *         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 abstract class AbstractClient {
 
        protected final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(getClass().getName());
-       
+
        protected final String baseUrl;
        protected final RestTemplate restTemplate;
 
        /**
-        * Builds a restTemplate. If user and pass are both supplied, uses basic
-        * HTTP authentication; if either one is missing, no authentication is used.
+        * Builds a restTemplate. If user and pass are both supplied, uses basic HTTP
+        * authentication; if either one is missing, no authentication is used.
         * 
         * @param theTarget
         *            URL of the web endpoint
         * @param theClient
-        *                                              underlying http client
+        *            underlying http client
         */
-       public AbstractClient(String theTarget,
-                                                                                                       HttpClient theClient) {
+       public AbstractClient(String theTarget, HttpClient theClient) {
                if (theTarget == null)
                        throw new IllegalArgumentException("Null URL not permitted");
 
@@ -93,33 +65,26 @@ public abstract class AbstractClient {
                try {
                        url = new URL(theTarget);
                        this.baseUrl = url.toExternalForm();
-               }
-               catch (MalformedURLException ex) {
+               } catch (MalformedURLException ex) {
                        throw new RuntimeException("Failed to parse targedt URL", ex);
                }
 
                this.restTemplate = new RestTemplateBuilder()
-                                                                                                               .requestFactory(
-                                                                                                                       new HttpComponentsClientHttpRequestFactory(theClient))  
-                                                                                                               .rootUri(this.baseUrl)
-                                                                                                               .build();
+                               .requestFactory(new HttpComponentsClientHttpRequestFactory(theClient)).rootUri(this.baseUrl).build();
        }
 
-
        /**
-        * Builds URI by adding specified path segments and query parameters to the
-        * base URL.
+        * Builds URI by adding specified path segments and query parameters to the base
+        * URL.
         * 
         * @param path
         *            Array of path segments
         * @param queryParams
-        *            key-value pairs; ignored if null or empty. Gives special
-        *            treatment to Date-type values.
-        * @param restPageRequest
-        *            TODO
+        *            key-value pairs; ignored if null or empty. Gives special treatment
+        *            to Date-type values.
         * @param pageRequest
         *            page, size and sort specification; ignored if null.
-        * @return
+        * @return URI
         */
        protected URI buildUri(final String[] path, final Map<String, Object> queryParams, RestPageRequest pageRequest) {
                UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.baseUrl);
@@ -151,4 +116,4 @@ public abstract class AbstractClient {
                return builder.build().encode().toUri();
        }
 
-}      
+}
index b81ceb5..b111f83 100644 (file)
 
 package org.acumos.federation.gateway.service.impl;
 
-import org.apache.http.client.HttpClient;
-
-import org.springframework.stereotype.Component;
-import org.springframework.context.annotation.Scope;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
-
 import org.acumos.cds.client.CommonDataServiceRestClientImpl;
 import org.acumos.cds.client.ICommonDataServiceRestClient;
-
 import org.acumos.nexus.client.NexusArtifactClient;
 import org.acumos.nexus.client.RepositoryLocation;
+import org.apache.http.client.HttpClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Scope;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
 
 /**
  * Unique entry point for building clients: peer access clients, cds clients
@@ -49,33 +44,31 @@ public class Clients implements ApplicationContextAware {
 
        protected ApplicationContext appCtx = null;
 
-       public void     setApplicationContext(ApplicationContext theAppContext) {
+       public void setApplicationContext(ApplicationContext theAppContext) {
                this.appCtx = theAppContext;
        }
 
-       /** The standard CDS client */  
+       /**
+        * @return The standard CDS client
+        */
        public ICommonDataServiceRestClient getClient() {
-               return new CommonDataServiceRestClientImpl(
-                                                               env.getProperty("cdms.client.url"),
-                                                               env.getProperty("cdms.client.username"),
-                                                               env.getProperty("cdms.client.password"));
+               return new CommonDataServiceRestClientImpl(env.getProperty("cdms.client.url"),
+                               env.getProperty("cdms.client.username"), env.getProperty("cdms.client.password"));
        }
-       
+
        public FederationClient getFederationClient(String thePeerURI) {
-    return new FederationClient(
-                                                                       thePeerURI,
-                  (HttpClient)this.appCtx.getBean("federationClient"));
+               return new FederationClient(thePeerURI, (HttpClient) this.appCtx.getBean("federationClient"));
        }
 
        public NexusArtifactClient getNexusClient() {
                RepositoryLocation repositoryLocation = new RepositoryLocation();
-      
+
                repositoryLocation.setId("1");
+
                repositoryLocation.setUrl(env.getProperty("nexus.url"));
                repositoryLocation.setUsername(env.getProperty("nexus.username"));
                repositoryLocation.setPassword(env.getProperty("nexus.password"));
                repositoryLocation.setProxy(env.getProperty("nexus.proxy"));
-
                return new NexusArtifactClient(repositoryLocation);
        }
 }
index 616b1f7..5534a6d 100644 (file)
@@ -50,8 +50,10 @@ import org.springframework.web.client.HttpStatusCodeException;
 public class FederationClient extends AbstractClient {
 
        /**
-        * @param theTarget 
-        * @param theClient 
+        * @param theTarget
+        *            Target
+        * @param theClient
+        *            HttpClient
         */
        public FederationClient(String theTarget, HttpClient theClient) {
                super(theTarget, theClient);
@@ -129,8 +131,10 @@ public class FederationClient extends AbstractClient {
 
        /**
         * 
-        * @param theSolutionId 
-        * @param theRevisionId 
+        * @param theSolutionId
+        *            Solution ID
+        * @param theRevisionId
+        *            Revision ID
         * @return List of MLPArtifacts from Remote Acumos
         * @throws HttpStatusCodeException
         *             Throws HttpStatusCodeException is remote acumos is not available
@@ -156,9 +160,11 @@ public class FederationClient extends AbstractClient {
        }
 
        /**
-        * @param theArtifactId 
+        * @param theArtifactId
+        *            Artifact ID
         * @return Resource
-        * @throws HttpStatusCodeException On failure 
+        * @throws HttpStatusCodeException
+        *             On failure
         */
        public Resource downloadArtifact(String theArtifactId) throws HttpStatusCodeException {
                URI uri = API.ARTIFACT_DOWNLOAD.buildUri(this.baseUrl, theArtifactId);
index 1faa3af..aa85299 100644 (file)
 
 package org.acumos.federation.gateway.task;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
+import org.acumos.cds.domain.MLPPeer;
+import org.acumos.cds.domain.MLPPeerSubscription;
+import org.acumos.cds.domain.MLPSolution;
 import org.acumos.federation.gateway.common.JsonResponse;
 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.federation.gateway.util.Utils;
-
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
 import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import org.acumos.cds.AccessTypeCode;
-import org.acumos.cds.domain.MLPPeer;
-import org.acumos.cds.domain.MLPPeerSubscription;
-import org.acumos.cds.domain.MLPSolution;
-
-import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
-
-import org.springframework.stereotype.Component;
 import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
 /**
  * 
- * Peer Acumos Task to Communicate to Remote Acumos and fetch Solutions & Catalogs
+ * Peer Acumos Task to Communicate to Remote Acumos and fetch Solutions and
+ * Catalogs
  */
 @Component("peerSubscriptionTask")
 @Scope("prototype")
 public class PeerCommunicationTask implements Runnable {
 
        private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerCommunicationTask.class);
-       
 
        @Autowired
        private ApplicationEventPublisher eventPublisher;
-       
+
        private MLPPeer mlpPeer;
        private MLPPeerSubscription mlpSubscription;
 
-  @Autowired
-  private Clients clients;
+       @Autowired
+       private Clients clients;
 
-  public PeerCommunicationTask() {
-       }       
+       public PeerCommunicationTask() {
+       }
 
        public PeerCommunicationTask handle(MLPPeer peer, MLPPeerSubscription subscription) {
                this.mlpPeer = peer;
                this.mlpSubscription = subscription;
                return this;
-  }
+       }
 
        public MLPPeer getPeer() {
                return this.mlpPeer;
@@ -83,10 +73,9 @@ public class PeerCommunicationTask implements Runnable {
                return this.mlpSubscription;
        }
 
-
        @Override
        public void run() {
-       
+
                if (this.mlpPeer == null || this.mlpSubscription == null) {
                        logger.info(EELFLoggerDelegate.debugLogger, "Peer task has no peer subscription info");
                        return;
@@ -94,30 +83,32 @@ public class PeerCommunicationTask implements Runnable {
 
                try {
                        logger.info(EELFLoggerDelegate.debugLogger, "Peer task: " + mlpPeer);
-               
-      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
-       logger.info(EELFLoggerDelegate.debugLogger, "Peer Task: filter " + mlpSubscription.getSelector());
-                       
-       JsonResponse<List<MLPSolution>> jsonResponse = 
-                                               fedClient.getSolutions(
-                                                       Utils.jsonStringToMap(mlpSubscription.getSelector()));
-                       if(jsonResponse != null && jsonResponse.getResponseBody() != null) {
+
+                       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
+                       logger.info(EELFLoggerDelegate.debugLogger, "Peer Task: filter " + mlpSubscription.getSelector());
+
+                       JsonResponse<List<MLPSolution>> jsonResponse = fedClient
+                                       .getSolutions(Utils.jsonStringToMap(mlpSubscription.getSelector()));
+                       if (jsonResponse != null && jsonResponse.getResponseBody() != null) {
                                List<MLPSolution> mlpSolutions = jsonResponse.getResponseBody();
-        logger.debug(EELFLoggerDelegate.debugLogger, "Peer task: Number of Solutions fetch from Remote Instance: " + mlpSolutions.size());
+                               logger.debug(EELFLoggerDelegate.debugLogger,
+                                               "Peer task: Number of Solutions fetch from Remote Instance: " + mlpSolutions.size());
                                if (mlpSolutions.size() > 0) {
                                        this.eventPublisher.publishEvent(
-                                                               new PeerSubscriptionEvent(this, this.mlpPeer, this.mlpSubscription, mlpSolutions));
-        }
+                                                       new PeerSubscriptionEvent(this, this.mlpPeer, this.mlpSubscription, mlpSolutions));
+                               }
                        }
-    }
-               catch (Exception x) {
+               } catch (Exception x) {
                        logger.info(EELFLoggerDelegate.errorLogger, "Peer task for " + this.mlpPeer + " failed", x);
                }
-    // System.out.println(mlpPeer.getName() + " : Runnable Task with " + message + " on thread " + Thread.currentThread().getName() + ", id:"+ Thread.currentThread().getId());
-   }
+               // System.out.println(mlpPeer.getName() + " : Runnable Task with " + message + "
+               // on thread " + Thread.currentThread().getName() + ", id:"+
+               // Thread.currentThread().getId());
+       }
 }
index e16d680..22e7328 100644 (file)
 
 package org.acumos.federation.gateway.task;
 
-import java.util.Calendar;
-
-import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledFuture;
 
 import javax.annotation.PreDestroy;
 
-import com.google.common.collect.Table;
-import com.google.common.collect.HashBasedTable;
-
+import org.acumos.cds.domain.MLPPeer;
+import org.acumos.cds.domain.MLPPeerSubscription;
 import org.acumos.federation.gateway.config.EELFLoggerDelegate;
 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;
 import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.core.env.Environment;
@@ -48,11 +44,9 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
 import org.springframework.stereotype.Component;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
 
-import org.acumos.cds.domain.MLPPeer;
-import org.acumos.cds.domain.MLPPeerSubscription;
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.Table;
 
 /**
  * 
@@ -78,10 +72,6 @@ public class PeerCommunicationTaskScheduler implements       ApplicationContextAware
 
        private static Table<String, Long, PeerTaskHandler> peersSubsTask = HashBasedTable.create();
 
-       private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
-                       "MM/dd/yyyy HH:mm:ss");
-
-
        public void setApplicationContext(ApplicationContext theCtx) { //throws BeansException {
     this.appCtx = theCtx;
        }
diff --git a/pom.xml b/pom.xml
index 7cdc6b4..a2314fe 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,41 +1,33 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.acumos.federation</groupId>
-  <artifactId>federation-parent</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
-  <packaging>pom</packaging>
+       <groupId>org.acumos.federation</groupId>
+       <artifactId>federation-parent</artifactId>
+       <version>1.0.0-SNAPSHOT</version>
+       <packaging>pom</packaging>
 
-  <name>Federation Parent</name>
+       <name>Federation Parent</name>
 
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-  </properties>
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+       </properties>
 
-  <modules>
-       <module>gateway</module>
-  </modules>
-  <build>
+       <modules>
+               <!-- Child modules do NOT name this parent. -->
+               <module>gateway</module>
+       </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>
+                       <!-- support sonar in multi-module project -->
                        <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-deploy-plugin</artifactId>
-                               <version>2.8.2</version>
-                               <configuration>
-                                       <skip>true</skip>
-                               </configuration>
+                               <groupId>org.sonarsource.scanner.maven</groupId>
+                               <artifactId>sonar-maven-plugin</artifactId>
+                               <version>3.4.0.905</version>
                        </plugin>
+                        <!-- No "skip" configuration for maven-deploy-plugin. Let the pom be deployed 
+                        to LF Nexus repo, so that the final deploy step finds a file and succeeds. -->
                </plugins>
        </build>
 </project>