Update to CDS 2.x 08/3808/6
authorSerban Jora <sj2381@att.com>
Fri, 15 Feb 2019 21:33:18 +0000 (16:33 -0500)
committerLott, Christopher (cl778h) <cl778h@att.com>
Tue, 19 Feb 2019 21:11:10 +0000 (16:11 -0500)
Remove EELF dependency
Fix ACUMOS-2399

Change-Id: Ia6f320fabb5b3fb60e35810de66210ada5554354
Signed-off-by: Serban Jora <sj2381@att.com>
Issue-ID: ACUMOS-2399

131 files changed:
docs/release-notes.rst
gateway/application-dev.properties [new file with mode: 0644]
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/Application.java
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/sdc/ASDC.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Artifact.java
gateway/src/main/java/org/acumos/federation/gateway/cds/ArtifactBuilder.java
gateway/src/main/java/org/acumos/federation/gateway/cds/ArtifactType.java
gateway/src/main/java/org/acumos/federation/gateway/cds/ArtifactTypes.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/cds/CodeName.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNames.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNamesConfiguration.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/cds/DocumentBuilder.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Mapper.java
gateway/src/main/java/org/acumos/federation/gateway/cds/PeerStatus.java
gateway/src/main/java/org/acumos/federation/gateway/cds/PeerStatuses.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/cds/PeerSubscription.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Reference.java
gateway/src/main/java/org/acumos/federation/gateway/cds/SolutionBuilder.java
gateway/src/main/java/org/acumos/federation/gateway/cds/SolutionRevision.java
gateway/src/main/java/org/acumos/federation/gateway/cds/SolutionRevisionBuilder.java
gateway/src/main/java/org/acumos/federation/gateway/cds/TimestampedEntity.java
gateway/src/main/java/org/acumos/federation/gateway/cds/Updater.java
gateway/src/main/java/org/acumos/federation/gateway/common/AbstractClient.java
gateway/src/main/java/org/acumos/federation/gateway/common/Clients.java
gateway/src/main/java/org/acumos/federation/gateway/common/FederationClient.java
gateway/src/main/java/org/acumos/federation/gateway/common/JsonResponse.java
gateway/src/main/java/org/acumos/federation/gateway/config/AdapterConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/CDMSClientConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/DockerConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/EELFLoggerDelegate.java [deleted file]
gateway/src/main/java/org/acumos/federation/gateway/config/FederationConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/FederationInterfaceConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/GatewayConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/InterfaceConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/LocalConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/LocalInterfaceConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/config/NexusConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/controller/CatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerCatalogController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerPeersController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerPingController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerRegistrationController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeerSubscriptionController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PeersController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/PingController.java
gateway/src/main/java/org/acumos/federation/gateway/controller/RegistrationController.java
gateway/src/main/java/org/acumos/federation/gateway/security/AuthenticationConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/security/FederationMethodSecurityExpressionRoot.java
gateway/src/main/java/org/acumos/federation/gateway/security/Peer.java
gateway/src/main/java/org/acumos/federation/gateway/security/Tools.java
gateway/src/main/java/org/acumos/federation/gateway/service/CatalogService.java
gateway/src/main/java/org/acumos/federation/gateway/service/CatalogServiceConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/service/CodeNamesService.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/service/ContentService.java
gateway/src/main/java/org/acumos/federation/gateway/service/LocalWatchService.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/CatalogServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/CatalogServiceLocalImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/CodeNamesServiceImpl.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/CodeNamesServiceLocalImpl.java [new file with mode: 0644]
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ContentServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ContentServiceLocalImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerServiceLocalImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/PeerSubscriptionServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ServiceImpl.java
gateway/src/main/java/org/acumos/federation/gateway/task/PeerSubscriptionTaskScheduler.java
gateway/src/main/java/org/acumos/federation/gateway/task/TaskConfiguration.java
gateway/src/main/java/org/acumos/federation/gateway/util/Action.java
gateway/src/main/java/org/acumos/federation/gateway/util/FutureHandler.java
gateway/src/main/java/org/acumos/federation/gateway/util/Futures.java
gateway/src/main/java/org/acumos/federation/gateway/util/JSONHttpMessageConverter.java
gateway/src/main/java/org/acumos/federation/gateway/util/Utils.java
gateway/src/main/resources/logback.xml
gateway/src/test/java/org/acumos/federation/gateway/test/AsdcTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/AuthorizationTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/CatalogServiceTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/CdsTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/ControllerTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/LocalControllerTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/LocalTester.java
gateway/src/test/java/org/acumos/federation/gateway/test/MockAnswer.java [new file with mode: 0644]
gateway/src/test/java/org/acumos/federation/gateway/test/MockResponse.java
gateway/src/test/java/org/acumos/federation/gateway/test/PeerGatewayTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/PeerServiceTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/ServiceTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/TaskTest.java
gateway/src/test/java/org/acumos/federation/gateway/test/TestAdapter.java
gateway/src/test/resources/acumosa-catalog.json
gateway/src/test/resources/acumosa-codes.json [new file with mode: 0644]
gateway/src/test/resources/acumosb-catalog.json
gateway/src/test/resources/acumosb-codes.json [new file with mode: 0644]
gateway/src/test/resources/application-acumosa.properties
gateway/src/test/resources/application-acumosb.properties
gateway/src/test/resources/application-onap.properties
gateway/src/test/resources/docker-compose-test.yml
gateway/src/test/resources/mockCDSArtifactTypeResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSCreateArtifactResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSCreateRevisionArtifactResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSCreateSolutionResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSCreateSolutionRevisionResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSDateSolutionsResponsePage0.json
gateway/src/test/resources/mockCDSDateSolutionsResponsePage1.json
gateway/src/test/resources/mockCDSNoSuchSolutionResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSNoSuchSolutionRevisionsResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSPeerCreateResponse.json
gateway/src/test/resources/mockCDSPeerSearchAllResponse.json
gateway/src/test/resources/mockCDSPeerSearchResponse.json
gateway/src/test/resources/mockCDSPeerSearchSelfResponse.json
gateway/src/test/resources/mockCDSPeerStatusResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSPeerSubscriptionResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSPeerSubscriptionsResponse.json [new file with mode: 0644]
gateway/src/test/resources/mockCDSPeerUpdateResponse.json
gateway/src/test/resources/mockCDSPortalSolutionsResponse.json
gateway/src/test/resources/mockCDSSolutionResponse.json
gateway/src/test/resources/mockCDSSolutionRevisionsResponse.json
gateway/src/test/resources/mockPeerDownload.tgz [new file with mode: 0644]
gateway/src/test/resources/mockPeerSolutionResponse.json
gateway/src/test/resources/mockPeerSolutionRevisionArtifactsResponse.json
gateway/src/test/resources/mockPeerSolutionRevisionResponse.json
gateway/src/test/resources/mockPeerSolutionRevisionsResponse.json
gateway/src/test/resources/mockPeerSolutionsResponse.json
gateway/src/test/resources/task-test-catalog.json
gateway/src/test/resources/task-test-peers.json
gateway/src/test/resources/test-catalog.json
gateway/src/test/resources/test-codes.json [new file with mode: 0644]
gateway/src/test/resources/test-peers.json

index 2bb7200..f87d511 100644 (file)
@@ -22,6 +22,13 @@ Federation Gateway Release Notes
 
 This server is available as a Docker image in a Docker registry at the Linux Foundation.
 
+--------------------------
+Version 2.0.0, 2019-02-20
+--------------------------
+* Fix repeated update of metadata (`ACUMOS-2399 <https://jira.acumos.org/browse/ACUMOS-2399>`_)
+* Remove EELF
+* Update to CDS 2.x
+
 --------------------------
 Version 1.18.7, 2018-10-30
 --------------------------
diff --git a/gateway/application-dev.properties b/gateway/application-dev.properties
new file mode 100644 (file)
index 0000000..d037af0
--- /dev/null
@@ -0,0 +1,51 @@
+federation.addr = 127.0.0.1
+federation.server.port = 9084
+federation.ssl.key-store = file:///home/jora/digs/certs/dev/acumos_dev.pkcs12
+federation.ssl.key-store-password = dev1
+federation.ssl.key-store-type = PKCS12
+federation.ssl.key-password = dev1
+federation.ssl.trust-store = file:///home/jora/digs/certs/dev/acumosTrustStore.jks
+federation.ssl.trust-store-password = acumos
+federation.ssl.client-auth = need
+federation.registration.enabled = true
+
+local.addr = 127.0.0.1
+local.server.port = 9884
+local.ssl.key-store = file:///home/jora/digs/certs/dev/acumos_dev.pkcs12
+local.ssl.key-store-password = dev1
+local.ssl.key-store-type = PKCS12
+local.ssl.key-password = dev1
+local.ssl.trust-store = file:///home/jora/digs/certs/dev/acumosTrustStore.jks
+local.ssl.trust-store-password = acumos
+local.ssl.client-auth = need
+
+#pretend we are an adapter so that we can use local peer config
+#federation.instance=adapter
+federation.instance=gateway
+federation.instance.name=test
+federation.operator=1
+
+#
+nexus.url = http://cognita-nexus01.eastus.cloudapp.azure.com:8081/repository/repo_cognita_model_maven/
+nexus.user = cognita_model_rw
+nexus.pass = not4you
+nexus.prefix = org.acumos
+nexus.proxy:
+
+
+#
+docker.registryUrl = nexus.research.att.com:18004
+docker.registryUsername = snr_acumos_model_rw
+docker.registryPassword = password
+docker.registryEmail =
+
+#replace 
+#peersLocal.source=file:///home/jora/src/acumos/gerrit/federation/gateway/src/test/resources/acumosr-test-peers.json
+#catalogLocal.source=file:///home/jora/src/acumos/gerrit/federation/gateway/src/test/resources/acumosr-test-catalog.json
+
+cdms.client.url=http://cognita-dev1-vm01-core.eastus.cloudapp.azure.com:8002/ccds
+cdms.client.username=ccds_client
+cdms.client.password=ccds_client
+
+peer.jobchecker.interval=600
+debug=true
index 20976c8..51e3006 100644 (file)
@@ -1,15 +1,23 @@
 <?xml version="1.0"?>
-<!-- ===============LICENSE_START======================================================= 
-       Acumos Apache-2.0 =================================================================================== 
-       Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights 
-       reserved. =================================================================================== 
-       This Acumos software file is distributed by AT&T and Tech Mahindra under 
-       the Apache License, Version 2.0 (the "License"); you may not use this file 
-       except in compliance with the License. You may obtain a copy of the License 
-       at http://www.apache.org/licenses/LICENSE-2.0 This file is distributed on 
-       an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 
-       or implied. See the License for the specific language governing permissions 
-       and limitations under the License. ===============LICENSE_END========================================================= -->
+       <!--
+       ===============LICENSE_START=======================================================
+       Acumos
+       ===================================================================================
+       Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+       ===================================================================================
+       This Acumos software file is distributed by AT&T and Tech Mahindra
+       under the Apache License, Version 2.0 (the "License");
+       you may not use this file except in compliance with the License.
+       You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+       This file is distributed on an "AS IS" BASIS,
+       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+       See the License for the specific language governing permissions and
+       limitations under the License.
+       ===============LICENSE_END=========================================================
+       -->
 <project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0"
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.acumos.federation</groupId>
        <artifactId>gateway</artifactId>
-       <version>1.18.7-SNAPSHOT</version>
+       <version>2.0.0-SNAPSHOT</version>
        <name>Federation Gateway</name>
        <description>Federated Acumos Interface for inter-acumos and ONAP communication</description>
 
        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
-               <version>1.5.16.RELEASE</version>
+               <version>2.1.2.RELEASE</version>
                <!-- silence warning about parent relative path -->
                <relativePath />
        </parent>
                <dependency>
                        <groupId>org.acumos.common-dataservice</groupId>
                        <artifactId>cmn-data-svc-client</artifactId>
-                       <version>1.18.2</version>
+                       <version>2.0.7</version>
                </dependency>
                <dependency>
                        <groupId>org.json</groupId>
                        <artifactId>json</artifactId>
                        <!-- Override Spring-boot choice -->
-                       <version>20160212</version><!--$NO-MVN-MAN-VER$-->
+                       <version>20160212</version><!--$NO-MVN-MAN-VER$ -->
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>springfox-swagger-ui</artifactId>
                        <version>${springfox.version}</version>
                </dependency>
-               <dependency>
-                       <groupId>com.att.eelf</groupId>
-                       <artifactId>eelf-core</artifactId>
-                       <version>1.0.0</version>
-               </dependency>
                <dependency>
                        <groupId>javax.inject</groupId>
                        <artifactId>javax.inject</artifactId>
                        <artifactId>jython-standalone</artifactId>
                        <version>2.7.1-rc3</version>
                </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <!-- spring sets the <version>2.9.7</version> -->
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.datatype</groupId>
+                       <artifactId>jackson-datatype-jsr310</artifactId>
+               </dependency>
+
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                <dependency>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-lang3</artifactId>
-                       <version>3.6</version>
+                       <!-- spring sets the <version>3.6</version> -->
                </dependency>
                <dependency>
                        <groupId>org.apache.commons</groupId>
                <dependency>
                        <groupId>commons-beanutils</groupId>
                        <artifactId>commons-beanutils</artifactId>
-                       <!-- spring sets the <version>1.9.3</version> -->
+                       <version>1.9.3</version>
                </dependency>
                <dependency>
                        <groupId>com.github.docker-java</groupId>
                        <!-- spring sets the <version>3.8.0</version> -->
                        <scope>test</scope>
                </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-core</artifactId>
+                       <!-- spring sets the <version>2.21.0</version> -->
+                       <scope>test</scope>
+               </dependency>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
-                       <!-- spring sets the <version>1.5.3.RELEASE</version> -->
+                       <!-- spring sets the <version>2.1.2.RELEASE</version> -->
+                       <exclusions>
+                               <!-- silence warning about duplicate JSON class -->
+                               <exclusion>
+                                       <groupId>com.vaadin.external.google</groupId>
+                                       <artifactId>android-json</artifactId>
+                               </exclusion>
+                       </exclusions>
                        <scope>test</scope>
                </dependency>
        </dependencies>
                                        </execution>
                                </executions>
                        </plugin>
-                       <!-- No need to deploy Spring super-boot -->
+                       <!-- No need to deploy Spring super-jar -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-deploy-plugin</artifactId>
                                                        <!-- Specify a tag to avoid default tag "latest" -->
                                                        <name>federation-gateway:${project.version}</name>
                                                        <build>
-                                                               <from>frolvlad/alpine-oraclejdk8:slim</from>
+                                                               <from>openjdk:8-jre-slim</from>
                                                                <tags>
                                                                        <!-- Add tag with build number -->
                                                                        <tag>${project.version}-b${build.number}</tag>
                                                <image>
                                                        <name>federation-gateway-test:${project.version}</name>
                                                        <build>
-                                                               <from>frolvlad/alpine-oraclejdk8:slim</from>
+                                                               <from>openjdk:8-jre-slim</from>
                                                                <tags>
                                                                        <tag>${project.version}-b${build.number}</tag>
                                                                </tags>
                                        </execution>
                                </executions>
                        </plugin>
+                       <!--
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>license-maven-plugin</artifactId>
                                        <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>
                                        </execution>
                                </executions>
                        </plugin>
-
                </plugins>
        </build>
 </project>
index 893f36c..7ab1360 100644 (file)
@@ -22,10 +22,12 @@ package org.acumos.federation.gateway;
 
 import java.io.IOException;
 
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.config.FederationConfiguration;
 import org.acumos.federation.gateway.config.LocalConfiguration;
 import org.springframework.boot.Banner;
+import org.springframework.boot.WebApplicationType;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -54,7 +56,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
                                                                                                                                                                                         org.acumos.federation.gateway.config.AdapterConfiguration.class}))
 public class Application {
 
-       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(Application.class);
+       private static final Logger log = LoggerFactory.getLogger(Application.class);
 
        /**
         * We should be able to swap the LocalConfiguration in the case of adapters.
@@ -69,14 +71,14 @@ public class Application {
                SpringApplicationBuilder gatewayBuilder =
                        new SpringApplicationBuilder(Application.class)
                                                                                        .bannerMode(Banner.Mode.OFF)
-                                                                                       .web(false);
+                                                                                       .web(WebApplicationType.NONE);
                gatewayBuilder.child(FederationConfiguration.class)
                                                                                        .bannerMode(Banner.Mode.OFF)
-                                                                                       .web(true)
+                                                                                       .web(WebApplicationType.SERVLET)
                                                                                        .run(args);
                gatewayBuilder.child(LocalConfiguration.class)
                                                                                        .bannerMode(Banner.Mode.OFF)
-                                                                                       .web(true)
+                                                                                       .web(WebApplicationType.SERVLET)
                                                                                        .run(args);
 
        }
@@ -89,9 +91,9 @@ public class Application {
                        final ObjectMapper mapper = new ObjectMapper();
                        // ensure it's valid
                        mapper.readTree(springApplicationJson);
-                       logger.info("main: successfully parsed configuration from environment {}", CONFIG_ENV_VAR_NAME);
+                       log.info("main: successfully parsed configuration from environment {}", CONFIG_ENV_VAR_NAME);
                } else {
-                       logger.warn("main: no configuration found in environment {}", CONFIG_ENV_VAR_NAME);
+                       log.warn("main: no configuration found in environment {}", CONFIG_ENV_VAR_NAME);
                }
        }
 }
index 9bb84ea..c4f889f 100644 (file)
@@ -25,8 +25,11 @@ import java.lang.invoke.MethodHandles;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.time.Instant;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -38,6 +41,7 @@ import org.acumos.cds.domain.MLPPeerSubscription;
 import org.acumos.cds.domain.MLPRevisionDescription;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
+import org.acumos.cds.domain.MLPTag;
 import org.acumos.federation.gateway.cds.Artifact;
 import org.acumos.federation.gateway.cds.Document;
 import org.acumos.federation.gateway.cds.PeerSubscription;
@@ -50,7 +54,8 @@ import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.FederationClient;
 import org.acumos.federation.gateway.common.FederationException;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.config.GatewayCondition;
 import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
 import org.acumos.federation.gateway.service.CatalogService;
@@ -60,6 +65,7 @@ import org.acumos.federation.gateway.service.ServiceContext;
 import org.acumos.federation.gateway.service.ServiceException;
 import org.springframework.beans.factory.BeanInitializationException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.annotation.Conditional;
 import org.springframework.context.annotation.Scope;
 import org.springframework.context.event.EventListener;
@@ -75,8 +81,9 @@ import org.springframework.web.client.HttpStatusCodeException;
 @Conditional({GatewayCondition.class})
 public class PeerGateway {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
        @Autowired
+       @Qualifier("acumos")
        private TaskExecutor taskExecutor;
        @Autowired
        private Environment env;
@@ -92,12 +99,12 @@ public class PeerGateway {
        private static final String federationDotOperator = "federation.operator";
 
        public PeerGateway() {
-               log.trace(EELFLoggerDelegate.debugLogger, "PeerGateway::new");
+               log.trace("PeerGateway::new");
        }
 
        @PostConstruct
        public void initGateway() {
-               log.trace(EELFLoggerDelegate.debugLogger, "initPeerGateway");
+               log.trace("initPeerGateway");
 
                /* make sure an operator was specified and that it is a declared user */
                if (null == this.env.getProperty(federationDotOperator)) {
@@ -106,22 +113,22 @@ public class PeerGateway {
                else {
                        try {
                                if (null == this.clients.getCDSClient().getUser(this.env.getProperty(federationDotOperator))) {
-                                       log.warn(EELFLoggerDelegate.errorLogger, federationDotOperator + 
+                                       log.warn(federationDotOperator + 
                                                        " does not point to an existing user");
                                }
                        }
                        catch (/* HttpStatusCode */Exception dx) {
-                               log.warn(EELFLoggerDelegate.errorLogger, "failed to verify value " + federationDotOperator, dx);
+                               log.warn("failed to verify value " + federationDotOperator, dx);
                        }
                }
 
                // Done
-               log.debug(EELFLoggerDelegate.debugLogger, "PeerGateway available");
+               log.debug("PeerGateway available");
        }
 
        @PreDestroy
        public void cleanupGateway() {
-               log.debug(EELFLoggerDelegate.debugLogger, "PeerGateway destroyed");
+               log.debug("PeerGateway destroyed");
        }
 
        protected String getUserId(MLPPeerSubscription theSubscription/*
@@ -133,7 +140,7 @@ public class PeerGateway {
 
        @EventListener
        public void handlePeerSubscriptionUpdate(PeerSubscriptionEvent theEvent) {
-               log.info(EELFLoggerDelegate.debugLogger, "received peer subscription update event {}", theEvent);
+               log.info("received peer subscription update event {}", theEvent);
                taskExecutor.execute(
                                new PeerGatewayUpdateTask(theEvent.getPeer(), theEvent.getSubscription()));
        }
@@ -160,18 +167,18 @@ public class PeerGateway {
                                selector = Utils.jsonStringToMap(this.sub.getSelector());
                        }
                        catch(Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to parse selector for subscription {}", this.sub);
+                               log.error("Failed to parse selector for subscription {}", this.sub);
                                return;
                        }
-                       Date lastProcessed = this.sub.getProcessed();
+                       Instant lastProcessed = this.sub.getProcessed();
                        if (lastProcessed != null) {
                                selector.put("modified", lastProcessed);
                        }
-                       lastProcessed = new Date();
+                       lastProcessed = Instant.now();
                        
                        FederationClient peerClient = clients.getFederationClient(this.peer.getApiUrl());
                        if (peerClient == null) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to get client for peer {}", this.peer);
+                               log.error("Failed to get client for peer {}", this.peer);
                                return;
                        }
 
@@ -180,14 +187,14 @@ public class PeerGateway {
                                peerSolutionsResponse = peerClient.getSolutions(selector);
                        }
                        catch (FederationException fx) {
-                               log.info(EELFLoggerDelegate.errorLogger, "Processing peer " + this.peer + " subscription " + this.sub.getSubId() + " error.", fx);
+                               log.info("Processing peer " + this.peer + " subscription " + this.sub.getSubId() + " error.", fx);
                                return;
                        }
 
                        List<MLPSolution> peerSolutions = peerSolutionsResponse.getContent();
-                       log.info(EELFLoggerDelegate.debugLogger, "Processing peer {} subscription {}, {} yielded solutions {}", this.peer, this.sub.getSubId(), selector, peerSolutions);
+                       log.info("Processing peer {} subscription {}, {} yielded solutions {}", this.peer, this.sub.getSubId(), selector, peerSolutions);
                        if (peerSolutions == null) {
-                               log.warn(EELFLoggerDelegate.debugLogger, "No solutions available for peer {} subscription {} in {}", this.peer, this.sub.getSubId(), peerSolutionsResponse);
+                               log.warn("No solutions available for peer {} subscription {} in {}", this.peer, this.sub.getSubId(), peerSolutionsResponse);
                                peerSolutions = Collections.EMPTY_LIST;
                                //and let it proceed so we end up marking it as processed
                        }
@@ -196,18 +203,17 @@ public class PeerGateway {
                        boolean isComplete = true;
 
                        for (MLPSolution peerSolution : peerSolutions) {
-                               log.info(EELFLoggerDelegate.debugLogger, "Processing peer solution {}", peerSolution);
+                               log.info("Processing peer solution {}", peerSolution);
 
                                try {
                                        isComplete &= mapSolution(peerSolution, peerClient, ctx);
                                }
                                catch (Throwable t) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Mapping of acumos solution failed for " + peerSolution, t);
+                                       log.error("Mapping of acumos solution failed for " + peerSolution, t);
                                }
                        }
                                        
-                       log.info(EELFLoggerDelegate.debugLogger, "Processing of subscription {} completed succesfully: {}", this.sub, isComplete);
+                       log.info("Processing of subscription {} completed succesfully: {}", this.sub, isComplete);
                        //only commit the last processed date if we completed succesfully
                        if (isComplete) {
                                try {
@@ -215,8 +221,7 @@ public class PeerGateway {
                                        peerSubscriptionService.updatePeerSubscription(this.sub);
                                }
                                catch (ServiceException sx) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Failed to update subscription information", sx);
+                                       log.error("Failed to update subscription information", sx);
                                }
                        }
                }
@@ -230,8 +235,8 @@ public class PeerGateway {
                private Artifact copyArtifact(Artifact peerArtifact) {
                        return Artifact.buildFrom(peerArtifact)
                                                                .withUser(getUserId(this.sub))
-                                                               .withCreatedDate(TimestampedEntity.ORIGIN)
-                                                               .withModifiedDate(TimestampedEntity.ORIGIN)
+                                                               .withCreated(TimestampedEntity.ORIGIN)
+                                                               .withModified(TimestampedEntity.ORIGIN)
                                                                .build();
                }
 
@@ -246,25 +251,26 @@ public class PeerGateway {
                private void putArtifact(String theSolutionId, String theRevisionId, Artifact theArtifact,
                                ServiceContext theContext) throws ServiceException {
 
+                       assert(getCDSClient(theContext) != null);
+
                        try {
-                               if (theArtifact.getCreated().getTime() == 0) {
+                               if (theArtifact.getCreated() == Instant.MIN) {
                                        getCDSClient(theContext).createArtifact(theArtifact);
                                        getCDSClient(theContext).addSolutionRevisionArtifact(theSolutionId, theRevisionId, theArtifact.getArtifactId());
-                                       log.info(EELFLoggerDelegate.debugLogger, "Local artifact created: {}", theArtifact);
+                                       log.info("Local artifact created: {}", theArtifact);
                                }
                                else {
                                        getCDSClient(theContext).updateArtifact(theArtifact);
-                                       log.info(EELFLoggerDelegate.debugLogger, "Local artifact updated: {}", theArtifact);
+                                       log.info("Local artifact updated: {}", theArtifact);
                                }
        
                        }
                        catch (HttpStatusCodeException restx) {
-                               log.error(EELFLoggerDelegate.errorLogger,
-                                               "Artifact CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
+                               log.error("Artifact CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
                                throw new ServiceException("Artifact CDS call failed.", restx);
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Artifact unexpected failure", x);
+                               log.error("Artifact unexpected failure", x);
                                throw new ServiceException("Artifact CDS call failed.", x);
                        }
                }
@@ -272,8 +278,8 @@ public class PeerGateway {
                private Document copyDocument(Document peerDocument) {
                        return Document.buildFrom(peerDocument)
                                                                .withUser(getUserId(this.sub))
-                                                               .withCreatedDate(TimestampedEntity.ORIGIN)
-                                                               .withModifiedDate(TimestampedEntity.ORIGIN)
+                                                               .withCreated(TimestampedEntity.ORIGIN)
+                                                               .withModified(TimestampedEntity.ORIGIN)
                                                                .build();
                }
 
@@ -288,23 +294,22 @@ public class PeerGateway {
                                ServiceContext theContext) throws ServiceException {
 
                        try {
-                               if (theDocument.getCreated().getTime() == 0) {
+                               if (theDocument.getCreated() == Instant.MIN) {
                                        getCDSClient(theContext).createDocument(theDocument);
                                        getCDSClient(theContext).addSolutionRevisionDocument(theRevisionId, AccessTypeCode.PB.name(), theDocument.getDocumentId());
-                                       log.info(EELFLoggerDelegate.debugLogger, "Local document created: {}", theDocument);
+                                       log.info("Local document created: {}", theDocument);
                                }
                                else {
                                        getCDSClient(theContext).updateDocument(theDocument);
-                                       log.info(EELFLoggerDelegate.debugLogger, "Local document updated: {}", theDocument);
+                                       log.info("Local document updated: {}", theDocument);
                                }
                        }
                        catch (HttpStatusCodeException restx) {
-                               log.error(EELFLoggerDelegate.errorLogger,
-                                               "Document CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
+                               log.error("Document CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
                                throw new ServiceException("Document CDS call failed.", restx);
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Document handling unexpected failure", x);
+                               log.error("Document handling unexpected failure", x);
                                throw new ServiceException("Document handling unexpected failure", x);
                        }
                }
@@ -324,21 +329,20 @@ public class PeerGateway {
                private void putRevisionDescription(MLPRevisionDescription theDescription,ServiceContext theContext) throws ServiceException {
                        
                        try {
-                               if (theDescription.getCreated().getTime() == 0) {
+                               if (theDescription.getCreated() == Instant.MIN) {
                                        getCDSClient(theContext).createRevisionDescription(theDescription);
-                                       log.info(EELFLoggerDelegate.debugLogger, "Local description created: {}", theDescription);
+                                       log.info("Local description created: {}", theDescription);
                                }
                                else {
                                        getCDSClient(theContext).updateRevisionDescription(theDescription);
                                }
                        }
                        catch (HttpStatusCodeException restx) {
-                               log.error(EELFLoggerDelegate.errorLogger,
-                                       "Revision description CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
+                               log.error("Revision description CDS call failed. CDS message is " + restx.getResponseBodyAsString(), restx);
                                throw new ServiceException("Revision description CDS call failed.", restx);
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Revision description handling unexpected failure", x);
+                               log.error("Revision description handling unexpected failure", x);
                                throw new ServiceException("Revision description handling unexpected failure", x);
                        }
                }
@@ -366,7 +370,57 @@ public class PeerGateway {
 
                        return true;
                }
+
+               private Solution copySolution(Solution thePeerSolution) {
+                       return Solution.buildFrom(thePeerSolution)
+                                                               .withCreated(TimestampedEntity.ORIGIN)
+                                                               .withModified(TimestampedEntity.ORIGIN)
+                                                               .withUser(getUserId(this.sub))
+                                                               .withSource(this.peer.getPeerId())
+                                                               .resetStats()
+                                                               .build();
+               }
        
+               private Solution copySolution(Solution thePeerSolution, Solution theLocalSolution) {    
+                       String newUserId = getUserId(this.sub),
+                                                newSourceId = this.peer.getPeerId();
+
+                       //some basic warnings
+                       if (!theLocalSolution.getUserId().equals(newUserId)) {
+                               // is this solution being updated as part of different/new subscription?
+                               log.warn("Updating solution {} triggers a user change", theLocalSolution.getSolutionId());
+                               //but make the change anyway
+                               theLocalSolution.setUserId(newUserId);
+                       }
+
+                       if (theLocalSolution.getSourceId() == null) {
+                               //this is a local solution that made its way back
+                               log.info("Solution {} was originally provisioned locally, avoiding user update", theLocalSolution.getSolutionId());
+                       }
+                       else {
+                               if (!theLocalSolution.getSourceId().equals(newSourceId)) {
+                                       // we will see this if a solution is available in more than one peer
+                                       log.warn("Solution {} triggers a source change", theLocalSolution.getSolutionId());
+                                       //but make the change anyway
+                                       theLocalSolution.setSourceId(newSourceId);
+                               }
+                       }
+
+                       //tags, keep only the delta
+                       Set<MLPTag> tags = thePeerSolution.getTags();
+                       tags.removeAll(theLocalSolution.getTags());
+                       theLocalSolution.setTags(tags);                 
+
+                       return theLocalSolution;
+               }
+
+               private boolean hasChanged(Solution thePeerSolution, Solution theLocalSolution) {
+                       if (!theLocalSolution.getTags().containsAll(thePeerSolution.getTags()))
+                               return false;
+
+                       return true;
+               }
+
                /**
                 * Here comes the core process of updating a local solution's related
                 * information with what is available from a peer.
@@ -374,6 +428,8 @@ public class PeerGateway {
                 * @param theSolution
                 *            the local solution who's related information (revisions and
                 *            artifacts) we are trying to sync
+                * @param thePeerClient
+                *            client
                 * @param theContext
                 *            the context in which we perform the catalog operations
                 * @return true if mapping was succesful, false otherwise
@@ -382,7 +438,9 @@ public class PeerGateway {
                 */
                protected boolean mapSolution(MLPSolution theSolution, FederationClient thePeerClient, ServiceContext theContext) throws Exception {
 
-                       boolean isComplete = true;
+                       boolean isComplete = true,
+                                                       isSolutionNew = false,
+                                                       hasSolutionChanged = false;
 
                        Solution localSolution = null,
                                                         peerSolution = null;
@@ -393,50 +451,42 @@ public class PeerGateway {
                                peerSolutionResponse = thePeerClient.getSolution(theSolution.getSolutionId());
                        }
                        catch (FederationException fx) {
-                               log.warn(EELFLoggerDelegate.errorLogger, "Failed to retrieve peer solution details for " + theSolution, fx);
+                               log.warn("Failed to retrieve peer solution details for " + theSolution, fx);
                                return false;
                        }
 
                        peerSolution = (Solution)peerSolutionResponse.getContent();
                        if (peerSolution == null) {
-                               log.warn(EELFLoggerDelegate.debugLogger, "No solution details available for {} in {}", theSolution, peerSolutionResponse);
+                               log.warn("No solution details available for {} in {}", theSolution, peerSolutionResponse);
                                return false;
                        }
 
-                       localSolution = catalog.putSolution(
-                                                                                                                                       Solution.buildFrom(peerSolution)
-                                                                                                                                               .withUser(getUserId(this.sub))
-                                                                                                                                               .withSource(this.peer.getPeerId())
-                                                                                                                                               .build(), theContext);
-
+                       localSolution = catalog.getSolution(peerSolution.getSolutionId());
+                       if (localSolution == null) {
+                               localSolution = catalog.putSolution(copySolution(peerSolution), theContext);
+                       isSolutionNew = true;
+                       }
+                       else {
+                               hasSolutionChanged = hasChanged(peerSolution, localSolution);
+                       }
+                       
                        List<MLPSolutionRevision> peerRevisions = (List)peerSolution.getRevisions();
+                       Collections.sort(peerRevisions, (arev, brev) -> arev.getModified().compareTo(brev.getModified()));
 
                        // this should not happen as any solution should have at least one
                        // revision (but that's an assumption on how on-boarding works)
                        if (peerRevisions == null || peerRevisions.size() == 0) {
-                               log.warn(EELFLoggerDelegate.debugLogger, "No peer revisions were retrieved");
+                               log.warn("No peer revisions were retrieved");
                                return true;
                        }
 
                        // check if we have locally the latest revision available on the peer
-                       List<MLPSolutionRevision> catalogRevisions = Collections.EMPTY_LIST;
-                       try {
-                               catalogRevisions = catalog.getSolutionRevisions(localSolution.getSolutionId(), theContext);
-                       }
-                       catch (ServiceException sx) {
-                               log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Failed to retrieve catalog revisions for solution " + theSolution.getSolutionId(), sx);
-                               throw sx;
-                       }
-                       final List<MLPSolutionRevision> localRevisions = catalogRevisions;
+                       List<MLPSolutionRevision> catalogRevisions = (List)localSolution.getRevisions();
+                       final List<MLPSolutionRevision> localRevisions = catalogRevisions == null ? Collections.EMPTY_LIST : catalogRevisions;
 
                        // map peer revisions to local ones; new peer revisions have a null mapping
                        Map<MLPSolutionRevision, MLPSolutionRevision> peerToLocalRevisions =
-                                       /*
-                                        * Elegant but toMap uses map merging which does not allow null values
-                                        * peerRevisions .stream() .collect( Collectors.toMap(...)
-                                        */
-                                       new HashMap<MLPSolutionRevision, MLPSolutionRevision>();
+                                       new LinkedHashMap<MLPSolutionRevision, MLPSolutionRevision>();
                        peerRevisions.forEach(peerRevision -> peerToLocalRevisions.put(peerRevision,
                                        localRevisions.stream()
                                                        .filter(localRevision -> localRevision.getRevisionId().equals(peerRevision.getRevisionId()))
@@ -445,6 +495,9 @@ public class PeerGateway {
                        for (Map.Entry<MLPSolutionRevision, MLPSolutionRevision> revisionEntry : peerToLocalRevisions.entrySet()) {
                                MLPSolutionRevision peerRevision = revisionEntry.getKey(), localRevision = revisionEntry.getValue();
 
+                               boolean isRevisionNew = false,
+                                                               hasRevisionChanged = false;
+
                                //revision related information (artifacts/documents/description/..) is now embedded in the revision details
                                //federation api call so one call is all is needed
                                JsonResponse<MLPSolutionRevision> peerRevisionResponse = null;
@@ -462,20 +515,23 @@ public class PeerGateway {
                                        continue;
                                }
 
-                               try {
-                                       localRevision = catalog.putSolutionRevision(
-                                                                                                                                               SolutionRevision.buildFrom(peerRevision)
-                                                                                                                                                                       .withUser(getUserId(this.sub))
-                                                                                                                                                                       .withSource(this.peer.getPeerId())
-                                                                                                                                                                       .withAccessTypeCode(this.sub.getAccessType())
-                                                                                                                                                                       .withValidationStatusCode(this.peer.getValidationStatusCode())
-                                                                                                                                                                       .build(), theContext);
-                               }
-                               catch (ServiceException sx) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Failed to put revision " + theSolution.getSolutionId() + "/" + peerRevision.getRevisionId() + " into catalog", sx);
-                                       isComplete = false; //try procecessing the next revision but mark the processing as incomplete
-                                       continue;
+                               if (localRevision == null) {
+                                       try {
+                                               localRevision = catalog.putSolutionRevision(
+                                                                                                                                                       SolutionRevision.buildFrom(peerRevision)
+                                                                                                                                                               .withCreated(TimestampedEntity.ORIGIN)
+                                                                                                                                                               .withModified(TimestampedEntity.ORIGIN)
+                                                                                                                                                               .withUser(getUserId(this.sub))
+                                                                                                                                                               .withSource(this.peer.getPeerId())
+                                                                                                                                                               .withAccessTypeCode(this.sub.getAccessType())
+                                                                                                                                                               .build(), theContext);
+                                       }
+                                       catch (ServiceException sx) {
+                                               log.error("Failed to put revision " + theSolution.getSolutionId() + "/" + peerRevision.getRevisionId() + " into catalog", sx);
+                                               isComplete = false; //try procecessing the next revision but mark the processing as incomplete
+                                               continue;
+                                       }
+                                       isRevisionNew = true;
                                }
 
                                List<Artifact> peerArtifacts = (List)((SolutionRevision)peerRevision).getArtifacts();
@@ -497,7 +553,7 @@ public class PeerGateway {
                                                                         localArtifact = artifactEntry.getValue();
                                        boolean doCatalog = false;
                                        
-                                       log.info(EELFLoggerDelegate.debugLogger, "Processing peer artifact {} against local artifact {}", peerArtifact, localArtifact);
+                                       log.info("Processing peer artifact {} against local artifact {}", peerArtifact, localArtifact);
 
                                        if (localArtifact == null) {
                                                localArtifact = copyArtifact(peerArtifact);
@@ -515,7 +571,7 @@ public class PeerGateway {
                                                                                                                        (peerArtifact.getUri() != null) &&
                                                                                                                        (SubscriptionScope.Full == SubscriptionScope.forCode(this.sub.getScopeType()));
                                        if (doContent) {
-                                               log.info(EELFLoggerDelegate.debugLogger, "Processing content for artifact {}", peerArtifact); 
+                                               log.info("Processing content for artifact {}", peerArtifact); 
                                                // TODO: we are trying to access the artifact by its identifier which
                                                // is fine in the common case but the uri specified in the artifact
                                                // data is the right approach (as it does not rely on the E5 definition).
@@ -523,10 +579,10 @@ public class PeerGateway {
                                                try {
                                                        artifactContent = thePeerClient.getArtifactContent(
                                                                peerSolution.getSolutionId(), peerRevision.getRevisionId(), peerArtifact.getArtifactId());
-                                                       log.info(EELFLoggerDelegate.debugLogger, "Received {} bytes of artifact content", artifactContent.contentLength()); 
+                                                       log.info("Received {} bytes of artifact content", artifactContent.contentLength()); 
                                                }
                                                catch (FederationException x) {
-                                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos artifact content", x);
+                                                       log.error("Failed to retrieve acumos artifact content", x);
                                                        doCatalog = this.sub.getSubscriptionOptions().alwaysUpdateCatalog();
                                                        isComplete = false;
                                                }
@@ -538,8 +594,7 @@ public class PeerGateway {
                                                                doCatalog = true;
                                                        }
                                                        catch (ServiceException sx) {
-                                                               log.error(EELFLoggerDelegate.errorLogger,
-                                                                                       "Failed to store artifact content to local repo", sx);
+                                                               log.error("Failed to store artifact content to local repo", sx);
                                                                doCatalog = this.sub.getSubscriptionOptions().alwaysUpdateCatalog();
                                                                isComplete = false;
                                                        }
@@ -556,9 +611,10 @@ public class PeerGateway {
                                                        putArtifact(localSolution.getSolutionId(), localRevision.getRevisionId(), localArtifact, theContext);
                                                }
                                                catch (ServiceException sx) {
-                                                       log.error(EELFLoggerDelegate.errorLogger, "Artifact processing failed.", sx);
+                                                       log.error("Artifact processing failed.", sx);
                                                        isComplete = false;
                                                }
+                                               hasRevisionChanged = true;
                                        }
                                } //end map artifacts loop
 
@@ -576,7 +632,7 @@ public class PeerGateway {
                                                                         localDocument = documentEntry.getValue();
                                        boolean doCatalog = false;
 
-                                       log.info(EELFLoggerDelegate.debugLogger, "Processing peer document {} against local version {}", peerDocument, localDocument);
+                                       log.info("Processing peer document {} against local version {}", peerDocument, localDocument);
                                        if (localDocument == null) {
                                                localDocument = copyDocument(peerDocument);
                                                doCatalog = true;
@@ -594,7 +650,7 @@ public class PeerGateway {
                                                                                                                        (peerDocument.getUri() != null) &&
                                                                                                                        (SubscriptionScope.Full == SubscriptionScope.forCode(this.sub.getScopeType()));
                                        if (doContent) {
-                                               log.info(EELFLoggerDelegate.debugLogger, "Processing content for document {}", peerDocument); 
+                                               log.info("Processing content for document {}", peerDocument); 
                                                // TODO: we are trying to access the document by its identifier which
                                                // is fine in the common case but the uri specified in the document
                                                // data is a more flexible approach.
@@ -602,10 +658,10 @@ public class PeerGateway {
                                                try {
                                                        documentContent = thePeerClient.getDocumentContent(
                                                                peerSolution.getSolutionId(), localRevision.getRevisionId(), peerDocument.getDocumentId());
-                                                       log.info(EELFLoggerDelegate.debugLogger, "Received {} bytes of document content", documentContent.contentLength()); 
+                                                       log.info("Received {} bytes of document content", documentContent.contentLength()); 
                                                }
                                                catch (FederationException x) {
-                                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos document content", x);
+                                                       log.error("Failed to retrieve acumos document content", x);
                                                        doCatalog = this.sub.getSubscriptionOptions().alwaysUpdateCatalog();
                                                        isComplete = false;
                                                }
@@ -617,8 +673,7 @@ public class PeerGateway {
                                                                doCatalog = true;
                                                        }
                                                        catch (ServiceException sx) {
-                                                               log.error(EELFLoggerDelegate.errorLogger,
-                                                                                       "Failed to store document content to local repo", sx);
+                                                               log.error("Failed to store document content to local repo", sx);
                                                                doCatalog = this.sub.getSubscriptionOptions().alwaysUpdateCatalog();
                                                                isComplete = false;
                                                        }
@@ -630,9 +685,10 @@ public class PeerGateway {
                                                        putDocument(localSolution.getSolutionId(), localRevision.getRevisionId(), localDocument, theContext);
                                                }
                                                catch (ServiceException sx) {
-                                                       log.error(EELFLoggerDelegate.errorLogger,       "Document processing failed",   sx);
+                                                       log.error("Document processing failed", sx);
                                                        isComplete = false;
                                                }
+                                               hasRevisionChanged = true;
                                        }
        
                                } // end map documents loop
@@ -649,7 +705,7 @@ public class PeerGateway {
                                        }
                                        else {
                                                //is this a good enough test ?? it implies time sync ..
-                                               if (peerDescription.getModified().after(localDescription.getModified())) {
+                                               if (peerDescription.getModified().isAfter(localDescription.getModified())) {
                                                        localDescription = copyRevisionDescription(peerDescription, localDescription);
                                                        doCatalog = true;
                                                }
@@ -660,12 +716,36 @@ public class PeerGateway {
                                                        putRevisionDescription(localDescription, theContext);
                                                }
                                                catch (ServiceException sx) {
-                                                       log.error(EELFLoggerDelegate.errorLogger,       "Description processing failed",        sx);
+                                                       log.error("Description processing failed",      sx);
                                                        isComplete = false;
                                                }
+                                               hasRevisionChanged = true;
                                        }
-                               }
+                               } //end revision processing
+
+                               if (!isRevisionNew && hasRevisionChanged) {
+                                       try {
+                                               //we do not actually update any properties, just give CDS a chance to update the timestamps as to mark it as updated.
+                                               catalog.putSolutionRevision(SolutionRevision.buildFrom(localRevision).build(),
+                                                                                                                                                               theContext);
+                                       }
+                                       catch (ServiceException sx) {
+                                               log.error("Failed to update local revision",    sx);
+                                               isComplete = false;
+                                       }
+                               }       
 
+                               hasSolutionChanged |= (isRevisionNew || hasRevisionChanged);
+                       } //end revisions processing
+
+                       if (!isSolutionNew && hasSolutionChanged) {
+                               try {
+                                       catalog.putSolution(copySolution(peerSolution, localSolution), theContext);
+                               }
+                               catch (ServiceException sx) {
+                                       log.error("Failed to update local solution",    sx);
+                                       isComplete = false;
+                               }
                        }
 
                        return isComplete;
index 4fb51f9..abc4f38 100644 (file)
@@ -31,16 +31,17 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.time.Instant;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 
-import org.acumos.cds.ArtifactTypeCode;
 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.cds.ArtifactTypes;
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC;
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.ArtifactGroupType;
 import org.acumos.federation.gateway.adapter.onap.sdc.ASDC.ArtifactType;
@@ -50,7 +51,8 @@ import org.acumos.federation.gateway.adapter.onap.sdc.ASDCException;
 import org.acumos.federation.gateway.util.Utils;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.FederationClient;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.event.PeerSubscriptionEvent;
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -72,7 +74,7 @@ import org.springframework.util.StreamUtils;
 @Conditional(ONAPAdapterCondition.class)
 public class ONAP {
 
-       private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(ONAP.class);
+       private final Logger log = LoggerFactory.getLogger(ONAP.class);
        private ASDC asdc = new ASDC();
        private String asdcOperator;
        private TaskExecutor taskExecutor;
@@ -81,7 +83,7 @@ public class ONAP {
        private Clients clients;
 
        public ONAP() {
-               log.debug(EELFLoggerDelegate.debugLogger, "ONAP::new");
+               log.debug("ONAP::new");
        }
 
        public void setSdcUri(URI theUri) {
@@ -98,7 +100,7 @@ public class ONAP {
 
        @PostConstruct
        public void initOnap() {
-               log.trace(EELFLoggerDelegate.debugLogger, "initOnap");
+               log.trace("initOnap");
 
                if (this.asdc.getUri() == null)
                        throw new BeanInitializationException("Forgot to configure the SDC uri ('onap.sdcUri') ??");
@@ -115,17 +117,17 @@ public class ONAP {
                cleanup();
 
                // Done
-               log.trace(EELFLoggerDelegate.debugLogger, "Onap available");
+               log.trace("Onap available");
        }
 
        @PreDestroy
        public void cleanupOnap() {
-               log.trace(EELFLoggerDelegate.debugLogger, "Onap destroyed");
+               log.trace("Onap destroyed");
        }
 
        @EventListener
        public void handlePeerSubscriptionUpdate(PeerSubscriptionEvent theEvent) {
-               log.info(EELFLoggerDelegate.debugLogger, "received peer subscription update event " + theEvent);
+               log.info("received peer subscription update event " + theEvent);
                taskExecutor.execute(new ONAPPushTask(theEvent.getPeer(), theEvent.getSubscription()));
        }
 
@@ -150,18 +152,18 @@ public class ONAP {
                                selector = Utils.jsonStringToMap(this.sub.getSelector());
                        }
                        catch(Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to parse selector for subscription {}", this.sub);
+                               log.error("Failed to parse selector for subscription {}", this.sub);
                                return;
                        }
-                       Date lastProcessed = this.sub.getProcessed();
+                       Instant lastProcessed = this.sub.getProcessed();
                        if (lastProcessed != null) {
                                selector.put("modified", lastProcessed);
                        }
-                       lastProcessed = new Date();
+                       lastProcessed = Instant.now();
                        
                        FederationClient acumosClient = clients.getFederationClient(this.peer.getApiUrl());
                        if (acumosClient == null) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to get client for peer {}", this.peer);
+                               log.error("Failed to get client for peer {}", this.peer);
                                return;
                        }
 
@@ -170,24 +172,24 @@ public class ONAP {
                                acumosSolutions = (List)acumosClient.getSolutions(selector).getContent();
                        }
                        catch(Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Processing peer " + this.peer + " subscription " + this.sub.getSubId() + ": getSolutions failed.", x);
+                               log.error("Processing peer " + this.peer + " subscription " + this.sub.getSubId() + ": getSolutions failed.", x);
                                return;
                        }
-                       log.info(EELFLoggerDelegate.debugLogger, "Processing peer {} subscription {}, {} yielded solutions {}", this.peer, this.sub.getSubId(), selector, acumosSolutions);
+                       log.info("Processing peer {} subscription {}, {} yielded solutions {}", this.peer, this.sub.getSubId(), selector, acumosSolutions);
 
                        JSONArray sdcAssets = null;
                        try {
                                sdcAssets = asdc.getAssets(AssetType.resource, JSONArray.class, "Generic", "Abstract").waitForResult();
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to list ONAP SDC assets: " + x.getCause(), x);
+                               log.error("Failed to list ONAP SDC assets: " + x.getCause(), x);
                                // if this is a 404 NotFound, continue, otherwise, fail
                                if (ASDCException.isNotFound(x))
                                        sdcAssets = new JSONArray();
                                else
                                        return;
                        }
-                       log.info(EELFLoggerDelegate.debugLogger, "Mapping received Acumos solutions \n{}\n to retrieved ONAP SDC assets \n{}",
+                       log.info("Mapping received Acumos solutions \n{}\n to retrieved ONAP SDC assets \n{}",
                        acumosSolutions, sdcAssets);
 
                        for (MLPSolution acumosSolution : acumosSolutions) {
@@ -198,7 +200,7 @@ public class ONAP {
                                                        .getSolutionRevisions(acumosSolution.getSolutionId()).getContent();
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos revisions", x);
+                                       log.error("Failed to retrieve acumos revisions", x);
                                        return;
                                }
                                sortAcumosSolutionRevisions(acumosRevisions);
@@ -221,8 +223,7 @@ public class ONAP {
                                        // ");
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                                       "Mapping of acumos solution failed for: " + acumosSolution + ": " + x);
+                                       log.error("Mapping of acumos solution failed for: " + acumosSolution + ": " + x);
                                }
                        }
                }
@@ -239,15 +240,7 @@ public class ONAP {
                }
 
                public JSONObject createSdcAsset(MLPSolution theSolution, MLPSolutionRevision theRevision) throws Exception {
-                       log.info(EELFLoggerDelegate.debugLogger, "Creating ONAP SDC VF for solution " + theSolution);
-
-                       String description = null;// theSolution.getDescription();
-                       if (description == null) {
-                               description = theRevision.getDescription();
-                               if (description == null) {
-                                       description = theSolution.getSolutionId();// + "@acumos";
-                               }
-                       }
+                       log.info("Creating ONAP SDC VF for solution " + theSolution);
 
                        try {
                                return ONAP.this.asdc.createVF()
@@ -255,7 +248,7 @@ public class ONAP {
                                                .withSubCategory("Abstract")
                                                .withName(theSolution.getName() + "-" + theSolution.getSolutionId()) // sdc names are unique,
                                                                                                                                                                                                // acumos ones not so
-                                               .withDescription(description)
+                                               .withDescription(theSolution.getTags().toString()) //the actual description has moved and is too large to fit in here
                                                .withVendorName("Acumos")
                                                .withVendorRelease(theRevision.getVersion()) //is this meaningful ? given that it cannot be updated ..
                                                .withTags("acumos", theSolution.getSolutionId()) // can I fit an UUID as tag ??
@@ -264,7 +257,7 @@ public class ONAP {
                                                .execute().waitForResult();
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to create ONAP SDC VF", x);
+                               log.error("Failed to create ONAP SDC VF", x);
                                throw x;
                        }
                }
@@ -277,11 +270,11 @@ public class ONAP {
                 *            Asset info
                 * @param theSolution
                 *            solution
+                * @param theRevisions revision
                 * @return SDC Asset info
                 */
                public JSONObject updateSdcAsset(JSONObject theAssetInfo, MLPSolution theSolution, List<MLPSolutionRevision> theRevisions) {
-                       log.info(EELFLoggerDelegate.debugLogger,
-                                       "Updating ONAP SDC VF " + theAssetInfo.optString("uuid") + " for Acumos solution " + theSolution);
+                       log.info("Updating ONAP SDC VF " + theAssetInfo.optString("uuid") + " for Acumos solution " + theSolution);
                        return theAssetInfo;
                }
 
@@ -293,8 +286,7 @@ public class ONAP {
                                                .waitForResult();
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger,
-                                               "Failed to retrieve ONAP SDC asset metadata for " + theAssetInfo.getString("uuid") + " : " + x);
+                               log.error("Failed to retrieve ONAP SDC asset metadata for " + theAssetInfo.getString("uuid") + " : " + x);
                                throw x;
                        }
 
@@ -314,7 +306,7 @@ public class ONAP {
                                                .getContent();
                        }
                        catch (Exception x) {
-                               log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos artifacts" + x);
+                               log.error("Failed to retrieve acumos artifacts" + x);
                                throw x;
                        }
 
@@ -324,7 +316,7 @@ public class ONAP {
                        //add an artifact to be mapped for revision tracking purposes
                        {
                                MLPArtifact mapper = new MLPArtifact(mappedAcumosRevision.getVersion(),
-                                                                                                                               ArtifactTypeCode.MD.toString(),
+                                                                                                                               ArtifactTypes.Metadata.getCode(),
                                                                                                                                "mapper",
                                                                                                                                null,
                                                                                                                                "", //owner: never sees CDS so irrelevant 
@@ -343,8 +335,8 @@ public class ONAP {
                        Map<MLPArtifact, JSONArray> updatedArtifacts = new HashMap<MLPArtifact, JSONArray>();
                        // List<JSONObject> oldArtifacts = new LinkedList<JSONObject>();
 
-                       log.info(EELFLoggerDelegate.debugLogger, "Acumos artifacts: " + acumosArtifacts);
-                       log.info(EELFLoggerDelegate.debugLogger, "SDC artifacts: " + sdcArtifacts);
+                       log.info("Acumos artifacts: " + acumosArtifacts);
+                       log.info("SDC artifacts: " + sdcArtifacts);
 
                        for (MLPArtifact acumosArtifact : acumosArtifacts) {
                                JSONArray sdcMappedArtifacts = new JSONArray();
@@ -368,7 +360,7 @@ public class ONAP {
                                }
                        }
 
-                       log.info(EELFLoggerDelegate.debugLogger, "New artifacts: " + newArtifacts);
+                       log.info("New artifacts: " + newArtifacts);
                        for (MLPArtifact acumosArtifact : newArtifacts) {
                                try {
                                        for (ASDC.ArtifactUploadAction uploadAction:
@@ -378,11 +370,11 @@ public class ONAP {
                                        }
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to create ONAP SDC VF Artifacts for " + acumosArtifact, x);
+                                       log.error("Failed to create ONAP SDC VF Artifacts for " + acumosArtifact, x);
                                }
                        }
 
-                       log.warn(EELFLoggerDelegate.debugLogger, "Updated SDC artifacts: " + updatedArtifacts.keySet());
+                       log.warn("Updated SDC artifacts: " + updatedArtifacts.keySet());
                        for (Map.Entry<MLPArtifact, JSONArray> updateEntry : updatedArtifacts.entrySet()) {
                                MLPArtifact acumosArtifact = updateEntry.getKey();
                                try {
@@ -393,7 +385,7 @@ public class ONAP {
                                        }
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to update ONAP SDC VF Artifact for " + updateEntry.getKey(), x);
+                                       log.error("Failed to update ONAP SDC VF Artifact for " + updateEntry.getKey(), x);
                                }
                        }
 
@@ -414,7 +406,7 @@ public class ONAP {
                                        deletedArtifacts.add(sdcArtifact);
                                }
                        }
-                       log.warn(EELFLoggerDelegate.debugLogger, "Deleted SDC artifacts: " + deletedArtifacts);
+                       log.warn("Deleted SDC artifacts: " + deletedArtifacts);
                        for (JSONObject sdcArtifact : deletedArtifacts) {
                                try {
                                        asdc.deleteAssetArtifact(AssetType.resource, UUID.fromString(theAssetInfo.getString("uuid")),
@@ -422,7 +414,7 @@ public class ONAP {
                                                        .execute().waitForResult();
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to delete ONAP SDC VF Artifact", x);
+                                       log.error("Failed to delete ONAP SDC VF Artifact", x);
                                }
                        }
                }
@@ -440,7 +432,7 @@ public class ONAP {
                                        content = retrieveContent(theAcumosSolutionId, theAcumosRevisionId, theAcumosArtifact);
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve Acumoms artifact content from " + theAcumosArtifact.getUri(), x);
+                                       log.error("Failed to retrieve Acumoms artifact content from " + theAcumosArtifact.getUri(), x);
                                        return Collections.EMPTY_LIST;
                                }
 
@@ -449,11 +441,11 @@ public class ONAP {
                                        models = new JSONObject(toscalab.create_model(new ByteArrayInputStream(content)));
                                }
                                catch (JSONException jsonx) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to parse toscalab output", jsonx);
+                                       log.error("Failed to parse toscalab output", jsonx);
                                        return Collections.EMPTY_LIST;
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to process DCAE component specification from " + theAcumosArtifact, x);
+                                       log.error("Failed to process DCAE component specification from " + theAcumosArtifact, x);
                                        return Collections.EMPTY_LIST;
                                }
 
@@ -502,7 +494,7 @@ public class ONAP {
                                        content = retrieveContent(theAcumosSolutionId, theAcumosRevisionId, theAcumosArtifact);
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve Acumoms artifact content from " + theAcumosArtifact.getUri(), x);
+                                       log.error("Failed to retrieve Acumoms artifact content from " + theAcumosArtifact.getUri(), x);
                                        return Collections.EMPTY_LIST;
                                }
 
@@ -511,11 +503,11 @@ public class ONAP {
                                        models = new JSONObject(toscalab.create_model(new ByteArrayInputStream(content)));
                                }
                                catch (JSONException jsonx) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to parse toscalab output", jsonx);
+                                       log.error("Failed to parse toscalab output", jsonx);
                                        return Collections.EMPTY_LIST;
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Failed to process DCAE component specification from " + theAcumosArtifact, x);
+                                       log.error("Failed to process DCAE component specification from " + theAcumosArtifact, x);
                                        return Collections.EMPTY_LIST;
                                }
 
@@ -534,7 +526,7 @@ public class ONAP {
                        }
                        else if (isMapper(theAcumosArtifact)) {
                                if (theSDCArtifacts.length() != 1)
-                                       log.warn(EELFLoggerDelegate.errorLogger, "Found more than one mapper artifact {}", theSDCArtifacts);
+                                       log.warn("Found more than one mapper artifact {}", theSDCArtifacts);
                                return Collections.singletonList(
                                                asdc.updateAssetArtifact(AssetType.resource, UUID.fromString(theSDCAsset.getString("uuid")), theSDCArtifacts.getJSONObject(0))
                                                        .withOperator(ONAP.this.asdcOperator)
@@ -542,7 +534,7 @@ public class ONAP {
                                                        .withDescription(theAcumosArtifact.getArtifactId() + "@"        + theAcumosArtifact.getVersion()));
                        } 
                        else {
-                               log.error(EELFLoggerDelegate.errorLogger, "Found sdc artifacts for mlp artifact we do not process {}: {} ", theAcumosArtifact, theSDCArtifacts);
+                               log.error("Found sdc artifacts for mlp artifact we do not process {}: {} ", theAcumosArtifact, theSDCArtifacts);
                                return Collections.EMPTY_LIST;
                        }
                }
@@ -619,7 +611,7 @@ public class ONAP {
                try {
                        sdcAssets = asdc.getAssets(AssetType.resource, JSONArray.class, "Generic", "Abstract").waitForResult();
                } catch (Throwable x) {
-                       log.info(EELFLoggerDelegate.debugLogger, "Cleanup failed to list ONAP SDC assets: " + x.getCause(), x);
+                       log.info("Cleanup failed to list ONAP SDC assets: " + x.getCause(), x);
                }
 
                if (sdcAssets == null)
@@ -634,7 +626,7 @@ public class ONAP {
                                                        LifecycleState.undocheckout, ONAP.this.asdcOperator, null).waitForResult();
                                }
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger, "Cleanup ONAP SDC asset: " + sdcAsset.optString("uuid"), x);
+                                       log.error("Cleanup ONAP SDC asset: " + sdcAsset.optString("uuid"), x);
                                }
                        }
                }
index ebb12af..a528bd6 100644 (file)
@@ -499,8 +499,9 @@ public class ASDC {
        protected static final String[] artifactMandatoryEntries = new String[] {};
 
        /**
-        * We use teh same API to operate on artifacts attached to assets or to their
+        * We use the same API to operate on artifacts attached to assets or to their
         * instances
+        * @param <A> Action
         */
        public abstract class ASDCArtifactAction<A extends ASDCArtifactAction<A>> extends ASDCAction<A, JSONObject> {
 
index 9cd72f9..e3a5ed2 100644 (file)
@@ -62,7 +62,7 @@ public class Artifact extends MLPArtifact
        @JsonIgnore
        @Override
        public String getUriFilename() {
-               if (ArtifactType.DockerImage == ArtifactType.forCode(getArtifactTypeCode())) {
+               if (ArtifactTypes.DockerImage == ArtifactTypes.forCode(getArtifactTypeCode())) {
                        return Identifier.fromCompoundString(getUri()).repository.getPath();
                }
                else {
index 931038d..69b32cd 100644 (file)
@@ -19,7 +19,9 @@
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.Date;
+import java.net.URISyntaxException;
+
+import java.time.Instant;
 
 /**
  */
@@ -35,23 +37,23 @@ public class ArtifactBuilder {
                return this.artifact;
        } 
 
-       public ArtifactBuilder withCreatedDate(Date theDate) {
-               this.artifact.setCreated(theDate);
+       public ArtifactBuilder withCreated(Instant theInstant) {
+               this.artifact.setCreated(theInstant);
                return this;
        }
 
-       public ArtifactBuilder withCreated(long theDate) {
-               this.artifact.setCreated(new Date(theDate));
+       public ArtifactBuilder withCreated(long theEpoch) {
+               this.artifact.setCreated(Instant.ofEpochSecond(theEpoch));
                return this;
        }
 
-       public ArtifactBuilder withModifiedDate(Date theDate) {
-               this.artifact.setModified(theDate);
+       public ArtifactBuilder withModified(Instant theInstant) {
+               this.artifact.setModified(theInstant);
                return this;
        }
 
-       public ArtifactBuilder withModified(long theDate) {
-               this.artifact.setModified(new Date(theDate));
+       public ArtifactBuilder withModified(long theEpoch) {
+               this.artifact.setModified(Instant.ofEpochSecond(theEpoch));
                return this;
        }
 
@@ -90,7 +92,7 @@ public class ArtifactBuilder {
                return this;
        }
 
-       public ArtifactBuilder withUri(String theUri) {
+       public ArtifactBuilder withUri(String theUri) throws URISyntaxException {
                this.artifact.setUri(theUri);
                return this;
        }
index 728c3ff..34d267e 100644 (file)
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.EnumSet;
 
-import org.acumos.cds.ArtifactTypeCode;
+import org.acumos.cds.CodeNameType;
 
 /**
- * Supplements the CDS representation of artifact type information.
+ * A particular class of codes used to encode artifact types.
  */
-public enum ArtifactType {
+public interface ArtifactType extends CodeName {
 
-
-  Blueprint(ArtifactTypeCode.BP.name()), //
-  Cdump(ArtifactTypeCode.CD.name()), //
-  DockerImage(ArtifactTypeCode.DI.name()), //
-  DataSource(ArtifactTypeCode.DS.name()), //
-  Metadata(ArtifactTypeCode.MD.name()), //
-  ModelH2O(ArtifactTypeCode.MH.name()), //
-  ModelImage(ArtifactTypeCode.MI.name()), //
-  ModelR(ArtifactTypeCode.MR.name()), //
-  ModelScikit(ArtifactTypeCode.MS.name()), //
-  ModelTensorflow(ArtifactTypeCode.MT.name()), //
-  ToscaTemplate(ArtifactTypeCode.TE.name()), //
-  ToscaGenerator(ArtifactTypeCode.TG.name()), //
-  ToscaSchema(ArtifactTypeCode.TS.name()), //
-  ToscaTranslate(ArtifactTypeCode.TT.name()), //
-  ProtobufFile(ArtifactTypeCode.PJ.name());
-
-       private String                          code;
-
-       private ArtifactType(String theCode) {
-               this.code = theCode;
-       }
-
-       public String code() {
-               return this.code;
-       }
-
-       public static ArtifactType forCode(final String theCode) {
-               return EnumSet.allOf(ArtifactType.class)
-                                               .stream()
-                                               .filter(status -> status.code().equals(theCode))
-                                               .findFirst()
-                                               .orElse(null);
+       public default CodeNameType getType() {
+               return CodeNameType.ARTIFACT_TYPE;
        }
 }
 
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/cds/ArtifactTypes.java b/gateway/src/main/java/org/acumos/federation/gateway/cds/ArtifactTypes.java
new file mode 100644 (file)
index 0000000..31fcaf0
--- /dev/null
@@ -0,0 +1,56 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.cds;
+
+import java.util.List;
+
+/**
+ * The set of codes representing artifact types.
+ */
+public class ArtifactTypes extends CodeNames<ArtifactType> {
+
+       //these are the artifact type codes that we expect to find in all deployments.
+  public static ArtifactType Blueprint = forCode("BP");
+  public static ArtifactType Cdump = forCode("CD");
+  public static ArtifactType DockerImage = forCode("DI");
+  public static ArtifactType DataSource = forCode("DS");
+  public static ArtifactType Metadata = forCode("MD");
+  public static ArtifactType ModelH2O = forCode("MH");
+  public static ArtifactType ModelImage = forCode("MI");
+  public static ArtifactType ModelR = forCode("MR");
+  public static ArtifactType ModelScikit = forCode("MS");
+  public static ArtifactType ModelTensorflow = forCode("MT");
+  public static ArtifactType ToscaTemplate = forCode("TE");
+  public static ArtifactType ToscaGenerator = forCode("TG");
+  public static ArtifactType ToscaSchema = forCode("TS");
+  public static ArtifactType ToscaTranslate = forCode("TT");
+  public static ArtifactType ProtobufFile = forCode("PJ");
+
+
+       public static ArtifactType forCode(String theCode) {
+               return CodeNames.forCode(theCode, ArtifactType.class);
+       }
+
+       public static List<ArtifactType> codes() {
+               return codes(ArtifactType.class);
+       } 
+}
+
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeName.java b/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeName.java
new file mode 100644 (file)
index 0000000..b36d8b6
--- /dev/null
@@ -0,0 +1,38 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.cds;
+
+
+import org.acumos.cds.CodeNameType;
+
+/**
+ */
+public interface CodeName {
+
+       public CodeNameType getType();
+
+       public String getCode();
+
+       public String getName();
+
+       public boolean equals(Object theObject);
+}
+
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNames.java b/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNames.java
new file mode 100644 (file)
index 0000000..809aa43
--- /dev/null
@@ -0,0 +1,191 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property & Tech
+ *                                             Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.cds;
+
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.acumos.cds.CodeNameType;
+import org.acumos.cds.domain.MLPCodeNamePair;
+import org.acumos.federation.gateway.service.CodeNamesService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * The code is written to tolerate early/static references to particular codes by resolving such references only
+ * when method invocations occur upon the corresponding CodeName instance.
+ * @param <T> Type
+ */
+public abstract class CodeNames<T extends CodeName> {
+
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       private static CodeNamesService codes = null;
+
+       protected static Map<CodeNameType, List<MLPCodeNamePair>> codeNamePairs = new HashMap<>();
+       protected static Map<Class, List<CodeName>> codeNames = new HashMap<>();
+
+       @Autowired
+       public void setCodeNamesService(CodeNamesService theService) {
+               if (codes != null && codes != theService) {
+                       log.warn("Mismatched auto (RE-)wiring. Has " + codes + ". Got " + theService);
+               }
+               // TODO: last value wins?   if (codes == null)
+               codes = theService;
+       }       
+
+       protected static List<MLPCodeNamePair> loadCodeNamePairs(CodeNameType theType) {
+
+               List<MLPCodeNamePair> pairs = null;
+
+               if (codes == null)
+                       throw new IllegalStateException("Service not available");
+
+               try {
+                       pairs = codes.getCodeNames(theType);
+               }
+               catch(Exception x) {
+                       log.error("Failed to load codes for " + theType, x);
+                       return null;
+               }
+
+               log.debug("Loaded codes for {}: {}", theType, pairs);
+               codeNamePairs.put(theType, pairs);
+               return pairs;
+       }
+
+       /* generic return type so derived classes can downcast it accordingly */
+       protected static List/*<CodeName>*/ codes(Class theType) {
+               return codeNames.get(theType);
+       }
+
+       /**
+        * There is weakness in here as it can be called with different code types within the scope of the same container ..
+        * @param <T> Type
+        * @param theCode Code
+        * @param theType Code type
+        * @return Code
+        */     
+       protected static <T extends CodeName> T forCode(final String theCode, Class<T> theType) {
+               log.info("forCode {}: {}", theType, theCode); 
+               synchronized (codeNames) {
+                       List<CodeName> codes = codeNames.get(theType);
+                       if (codes == null) {
+                               codes = new LinkedList<CodeName>();
+                               codeNames.put(theType, codes);
+                       }
+                       //cannot call the CodeName.getCode in here as it will trigger an attempt to load the codes
+                       CodeName code = codes.stream().filter(c -> ((CodeNameHandler)Proxy.getInvocationHandler(c)).getCode().equals(theCode)).findFirst().orElse(null);        
+                       if (code == null) {
+                               code = (CodeName)Proxy.newProxyInstance(CodeNames.class.getClassLoader(), new Class[] { theType }, new CodeNameHandler(theCode));
+                               codes.add(code);
+                       }
+                       return (T)code;
+               }
+       }
+
+       protected static MLPCodeNamePair getCodeNamePair(CodeNameType theType, String theCode) {
+               synchronized (codeNamePairs) {
+                       List<MLPCodeNamePair> pairs = codeNamePairs.get(theType);
+                       if (pairs == null) {
+                               pairs = loadCodeNamePairs(theType);
+                       }
+
+                       return (pairs != null) ? pairs.stream().filter(pair -> pair.getCode().equals(theCode)).findFirst().orElse(null) : null;
+               }
+       }
+
+
+       static class CodeNameHandler implements InvocationHandler {
+
+               private String code;
+               private MLPCodeNamePair pair;
+
+               private CodeNameHandler(String theCode) {
+                       this.code = theCode;
+               }
+
+               public String getCode() {
+                       return this.code;
+               }
+
+               public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
+               
+                       if (this.pair == null) {
+                               CodeNameType theType = invokeGetType(theProxy);
+                               this.pair = getCodeNamePair(theType, this.code);
+                               if (this.pair == null)
+                                       throw new IllegalArgumentException("failed to find code: " + this.code + " in type: " + theType.name());
+                       }
+
+                       if (theMethod.getName().equals("getType")) {
+                               return invokeGetType(theProxy);
+                       }
+                       if (theMethod.getName().equals("getCode")) {
+                               return this.pair.getCode();
+                       }
+                       if (theMethod.getName().equals("getName")) {
+                               return this.pair.getName();
+                       }
+                       if (theMethod.getName().equals("equals")) {
+                               CodeName other = (CodeName)theArgs[0];
+                               return this.pair.getCode().equals(other.getCode()) &&
+                                                        this.pair.getName().equals(other.getName()); //we should also test the type ..
+                       }
+                       if (theMethod.getName().equals("toString")) {
+                               return this.pair.getCode().toString();
+                       }
+                       throw new IllegalArgumentException("Unexpected CodeName call: " + theMethod);
+               }
+
+               private CodeNameType invokeGetType(Object theProxy) throws Throwable {
+                       Class tgt = theProxy.getClass().getInterfaces()[0];
+                       Method tgtMethod = tgt.getDeclaredMethod("getType");
+
+                       if (tgtMethod == null || !tgtMethod.isDefault())
+                               throw new RuntimeException("invokeGetType: give a default definition to getType in an actual CodeName");
+
+                       Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class
+                .getDeclaredConstructor(Class.class, int.class);
+                       constructor.setAccessible(true);
+                       CodeNameType type = (CodeNameType)
+                               constructor.newInstance(tgt, MethodHandles.Lookup.PRIVATE)
+                .unreflectSpecial(tgtMethod, tgt)
+                                                                                        .bindTo(theProxy)
+                                                                                        .invokeWithArguments();
+
+                       log.debug("invokeGetType: found type {} for code {}", type, this.code);
+                       return type;    
+               }
+       }
+
+}
+
+
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNamesConfiguration.java b/gateway/src/main/java/org/acumos/federation/gateway/cds/CodeNamesConfiguration.java
new file mode 100644 (file)
index 0000000..b1dfff2
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.federation.gateway.cds;
+
+import org.acumos.federation.gateway.cds.ArtifactTypes;
+import org.acumos.federation.gateway.cds.PeerStatuses;
+import org.springframework.stereotype.Component;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * I wish I knew a better place for these .. this is no actual configuration ..
+ */
+@Component
+public class CodeNamesConfiguration {
+
+       public CodeNamesConfiguration() {
+       }
+
+  @Bean
+  public ArtifactTypes artifactTypes() {
+    return new ArtifactTypes();
+  }
+
+  @Bean
+  public PeerStatuses peerStatuses() {
+    return new PeerStatuses();
+  }
+}
index 55d8ca3..42e2d66 100644 (file)
@@ -19,7 +19,8 @@
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.Date;
+import java.net.URISyntaxException;
+import java.time.Instant;
 
 /**
  */
@@ -35,23 +36,23 @@ public class DocumentBuilder {
                return this.document;
        } 
 
-       public DocumentBuilder withCreatedDate(Date theDate) {
-               this.document.setCreated(theDate);
+       public DocumentBuilder withCreated(Instant theInstant) {
+               this.document.setCreated(theInstant);
                return this;
        }
 
-       public DocumentBuilder withCreated(long theDate) {
-               this.document.setCreated(new Date(theDate));
+       public DocumentBuilder withCreated(long theEpoch) {
+               this.document.setCreated(Instant.ofEpochSecond(theEpoch));
                return this;
        }
 
-       public DocumentBuilder withModifiedDate(Date theDate) {
-               this.document.setModified(theDate);
+       public DocumentBuilder withModified(Instant theInstant) {
+               this.document.setModified(theInstant);
                return this;
        }
 
-       public DocumentBuilder withModified(long theDate) {
-               this.document.setModified(new Date(theDate));
+       public DocumentBuilder withModified(long theEpoch) {
+               this.document.setModified(Instant.ofEpochSecond(theEpoch));
                return this;
        }
 
@@ -75,7 +76,7 @@ public class DocumentBuilder {
                return this;
        }
 
-       public DocumentBuilder withUri(String theUri) {
+       public DocumentBuilder withUri(String theUri) throws URISyntaxException {
                this.document.setUri(theUri);
                return this;
        }
index 18f7c7c..59a921c 100644 (file)
@@ -35,6 +35,7 @@ import com.fasterxml.jackson.databind.DeserializationContext;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
 import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
 
 
 /**
@@ -57,6 +58,7 @@ public class Mapper {
     fedModule.addDeserializer(MLPRevisionDescription.class, new RevisionDescriptionDeserializer());
 
                mapper.registerModule(fedModule);
+               mapper.registerModule(new JavaTimeModule());
 
                return mapper;
        }
index 6c9a5ad..6c0010c 100644 (file)
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.EnumSet;
-
-import org.acumos.cds.PeerStatusCode;
+import org.acumos.cds.CodeNameType;
 
 /**
- * Supplements the CDS representation of a peer status information.
- * Not needed but I did not notice the equivalent class in CDS .. To be removed once the set of
- * values in CDS is updated.
  */
-public enum PeerStatus {
-
-       Active(PeerStatusCode.AC.name()),
-       Inactive(PeerStatusCode.IN.name()),
-       Requested(PeerStatusCode.RQ.name()),/* the 'peer' has made a request to be registered with this Acumos instance (pending active)  */
-       Renounced(PeerStatusCode.RN.name()),  /* the peer has made a request to be unregistered as a peer of this Acumos instance (pending remove) */
-       Declined(PeerStatusCode.DC.name()) /* (removed) */
-       ;
-
-       private String                          code;
-       //private MLPPeerStatus mlp;
-
-       private PeerStatus(String theCode) {
-               this.code = theCode;
-               //mlp = new MLPPeerStatus(theCode, name());
-       }
-
-       public String code() {
-               return this.code;
-       }
-
-       //public MLPPeerStatus mlp() {
-       //      return this.mlp;
-       //}
+public interface PeerStatus extends CodeName {
 
-       public static PeerStatus forCode(final String theCode) {
-               return EnumSet.allOf(PeerStatus.class)
-                                               .stream()
-                                               .filter(status -> status.code().equals(theCode))
-                                               .findFirst()
-                                               .orElse(null);
+       public default CodeNameType getType() {
+               return CodeNameType.PEER_STATUS;
        }
 }
 
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/cds/PeerStatuses.java b/gateway/src/main/java/org/acumos/federation/gateway/cds/PeerStatuses.java
new file mode 100644 (file)
index 0000000..489de84
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.federation.gateway.cds;
+
+import java.util.List;
+
+/**
+ */
+public class PeerStatuses extends CodeNames<PeerStatus> {
+
+       public static PeerStatus Active = forCode("AC");
+       public static PeerStatus Inactive = forCode("IN");
+       public static PeerStatus Requested = forCode("RQ");
+       public static PeerStatus Renounced = forCode("RN");
+       public static PeerStatus Declined = forCode("DC");
+       public static PeerStatus Unknown = forCode("UK");
+
+       public PeerStatuses() {
+       }
+
+       public static PeerStatus forCode(String theCode) {
+               return CodeNames.forCode(theCode, PeerStatus.class);
+       }
+
+       public static List<PeerStatus> codes() {
+               return codes(PeerStatus.class);
+       } 
+
+}
+
+
index f0b7cf1..4d9b338 100644 (file)
@@ -99,7 +99,10 @@ public class PeerSubscription extends MLPPeerSubscription {
        /**
         * Detect changes in a peer subscription. The 'modified' timestamp is not a reliable test as we
         * we modify it outselves, so instead we look at the content.
-        * TODO: selector and options are json string, we should compare teh actual json structure.
+        * TODO: selector and options are json string, we should compare the actual json structure.
+        * @param theCurrentSub Old sub
+        * @param theNewSub New sub
+        * @return Boolean
         */
        public static boolean isModified(MLPPeerSubscription theCurrentSub, MLPPeerSubscription theNewSub) {
                boolean res = true;
index 98d7a29..9cc63ae 100644 (file)
@@ -23,7 +23,8 @@ import java.lang.invoke.MethodHandles;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.commons.io.FilenameUtils;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -34,11 +35,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
  */
 public interface Reference {
 
-       public static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       public static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        public String getUri();
 
-       public void setUri(String theUri);
+       public void setUri(String theUri) throws URISyntaxException;
 
        public String getVersion();
 
@@ -66,7 +67,7 @@ public interface Reference {
                                         basename = FilenameUtils.getBaseName(filename),
                                         extension = FilenameUtils.getExtension(filename);
 
-               log.debug(EELFLoggerDelegate.debugLogger, "filename: {}, basename: {}, extension: {}", filename, basename, extension);
+               log.debug("filename: {}, basename: {}, extension: {}", filename, basename, extension);
 
                if (basename != null && basename.endsWith("-" + getVersion())) {
                        return basename.substring(0, basename.lastIndexOf('-')) + (extension != null ? ("." + extension) : "");
index 79076a4..37e491c 100644 (file)
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.Date;
+import java.time.Instant;
+
 import java.util.Set;
 
-import org.acumos.cds.domain.MLPSolutionWeb;
 import org.acumos.cds.domain.MLPTag;
 
 /**
@@ -41,13 +41,13 @@ public class SolutionBuilder {
                return this.solution;
        } 
 
-       public SolutionBuilder withCreatedDate(Date theDate) {
-               this.solution.setCreated(theDate);
+       public SolutionBuilder withCreated(Instant theInstant) {
+               this.solution.setCreated(theInstant);
                return this;
        }
 
-       public SolutionBuilder withModifiedDate(Date theDate) {
-               this.solution.setModified(theDate);
+       public SolutionBuilder withModified(Instant theInstant) {
+               this.solution.setModified(theInstant);
                return this;
        }
 
@@ -66,11 +66,6 @@ public class SolutionBuilder {
                return this;
        }
 
-       public SolutionBuilder withDescription(String theDesc) {
-               this.solution.setDescription(theDesc);
-               return this;
-       }
-
        public SolutionBuilder withActive(boolean isActive) {
                this.solution.setActive(isActive);
                return this;
@@ -120,8 +115,13 @@ public class SolutionBuilder {
                return this;
        }
 
-       public SolutionBuilder withWebStats(MLPSolutionWeb theStats) {
-               this.solution.setWebStats(theStats);
+       public SolutionBuilder resetStats() {
+               this.solution.setViewCount(0L);
+               this.solution.setDownloadCount(0L);
+               this.solution.setLastDownload(null);
+               this.solution.setRatingCount(0L);
+               this.solution.setRatingAverageTenths(0L);
+               this.solution.setFeatured(false);
                return this;
        }
 }
index d75db66..8e2ea36 100644 (file)
@@ -35,7 +35,6 @@ public class SolutionRevision extends MLPSolutionRevision {
 
        public static interface Fields {
                public static final String accessTypeCode = "accessTypeCode";
-               public static final String validationStatusCode = "validationStatusCode";
        };
 
        private List<? extends MLPArtifact>             artifacts = Collections.EMPTY_LIST;
index e5f6ea9..5cd86df 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.Date;
+import java.time.Instant;
 
 /**
  */
@@ -35,13 +35,13 @@ public class SolutionRevisionBuilder {
                return this.revision;
        } 
 
-       public SolutionRevisionBuilder withCreatedDate(Date theDate) {
-               this.revision.setCreated(theDate);
+       public SolutionRevisionBuilder withCreated(Instant theInstant) {
+               this.revision.setCreated(theInstant);
                return this;
        }
 
-       public SolutionRevisionBuilder withModifiedDate(Date theDate) {
-               this.revision.setModified(theDate);
+       public SolutionRevisionBuilder withModified(Instant theInstant) {
+               this.revision.setModified(theInstant);
                return this;
        }
 
@@ -50,11 +50,6 @@ public class SolutionRevisionBuilder {
                return this;
        }
 
-       public SolutionRevisionBuilder withDescription(String theDesc) {
-               this.revision.setDescription(theDesc);
-               return this;
-       }
-
        public SolutionRevisionBuilder withMetadata(String theMetadata) {
                this.revision.setMetadata(theMetadata);
                return this;
@@ -65,8 +60,13 @@ public class SolutionRevisionBuilder {
                return this;
        }
 
-       public SolutionRevisionBuilder withValidationStatusCode(String theCode) {
-               this.revision.setValidationStatusCode(theCode);
+       public SolutionRevisionBuilder withVerifiedLicense(String theCode) {
+               this.revision.setVerifiedLicense(theCode);
+               return this;
+       }
+       
+       public SolutionRevisionBuilder withVerifiedVulnerability(String theCode) {
+               this.revision.setVerifiedVulnerability(theCode);
                return this;
        }
 
index 34b85b2..00da63b 100644 (file)
  */
 package org.acumos.federation.gateway.cds;
 
-import java.util.Date;
+import java.time.Instant;
 
 
 /**
  */
 public interface TimestampedEntity {
 
-       public static final Date ORIGIN = new Date(0);
+       public static final Instant ORIGIN = Instant.MIN;
 
-       public Date getCreated();
+       public Instant getCreated();
 
-       public void setCreated(Date created); 
+       public void setCreated(Instant created); 
 
        public default void resetCreated() {
                setCreated(ORIGIN);
        }
 
-       public Date getModified(); 
+       public Instant getModified(); 
 
-       public void setModified(Date modified); 
+       public void setModified(Instant modified); 
 
        public default void resetModified() {
                setModified(ORIGIN);
index ba1b69f..8791e8c 100644 (file)
@@ -22,6 +22,8 @@ package org.acumos.federation.gateway.cds;
 
 /**
  * Functional vararg interface for calculating updates to CDS properties.
+ * @param <R> Return type
+ * @param <T> Argument type
  */
 @FunctionalInterface
 public interface Updater<R,T> {
index 9143b90..5765de3 100644 (file)
@@ -56,7 +56,7 @@ public abstract class AbstractClient {
                setTarget(theTarget);
                
                this.restTemplate = new RestTemplateBuilder()
-                                                                                                       .requestFactory(new HttpComponentsClientHttpRequestFactory(theClient))
+                                                                                                       .requestFactory(() -> new HttpComponentsClientHttpRequestFactory(theClient))
                                                                                                        .rootUri(this.baseUrl)
                                                                                                        .build();
        }
@@ -71,7 +71,7 @@ public abstract class AbstractClient {
                contentConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_OCTET_STREAM));
 
                this.restTemplate = new RestTemplateBuilder()
-                                                                                                       .requestFactory(new HttpComponentsClientHttpRequestFactory(theClient))
+                                                                                                       .requestFactory(() -> new HttpComponentsClientHttpRequestFactory(theClient))
                                                                                                        .messageConverters(messageConverter, contentConverter)
                                                                                                        .rootUri(this.baseUrl)
                                                                                                        .build();
index d8e328a..45728e0 100644 (file)
@@ -26,7 +26,8 @@ import org.acumos.cds.client.ICommonDataServiceRestClient;
 import org.acumos.federation.gateway.cds.Mapper;
 import org.acumos.federation.gateway.config.CDMSClientConfiguration;
 import org.acumos.federation.gateway.config.DockerConfiguration;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.config.FederationInterfaceConfiguration;
 import org.acumos.federation.gateway.config.LocalInterfaceConfiguration;
 import org.acumos.federation.gateway.config.NexusConfiguration;
@@ -55,7 +56,7 @@ public class Clients {
        @Autowired
        private CDMSClientConfiguration cdmsConfig = null;
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        public Clients() {
        }
@@ -69,17 +70,17 @@ public class Clients {
 
        /**
         * Build a client for the given peer uri
+        * @param thePeerURI URI
+        * @return Client
         */
        public FederationClient getFederationClient(String thePeerURI) {
                return new FederationClient(thePeerURI, federationConfig.buildClient(), Mapper.build());
        }
 
-       /** */
        public RestTemplate getNexusClient() {
                return nexusConfig.getNexusClient();
        }
 
-       /** */
        public DockerClient     getDockerClient() {
     return dockerConfig.getDockerClient();
        }
index f3f6fd5..81f3043 100644 (file)
@@ -34,7 +34,8 @@ import org.acumos.cds.domain.MLPDocument;
 import org.acumos.cds.domain.MLPPeer;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.util.Utils;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.http.client.HttpClient;
@@ -60,7 +61,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
  */
 public class FederationClient extends AbstractClient {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        private HttpClient client;
 
@@ -88,7 +89,7 @@ public class FederationClient extends AbstractClient {
        public JsonResponse<MLPPeer> ping()
                        throws FederationException {
                URI uri = API.PING.buildUri(this.baseUrl);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<MLPPeer>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -96,25 +97,23 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
 
-       /**
-        */
        public JsonResponse<List<MLPPeer>> getPeers()
                        throws FederationException {
                URI uri = API.PEERS.buildUri(this.baseUrl);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPPeer>>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -122,15 +121,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }       
@@ -142,19 +141,19 @@ public class FederationClient extends AbstractClient {
         *            key-value pairs; ignored if null or empty. Gives special treatment
         *            to Date-type values.
         * @return List of MLPSolutions from Remote Acumos
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException is remote acumos is not available
+        * @throws FederationException
+        *             If remote acumos is not available
         */
        public JsonResponse<List<MLPSolution>> getSolutions(Map<String, Object> theSelection)
                        throws FederationException {
 
                String selectorParam = null;
                try {
-                       log.info(EELFLoggerDelegate.debugLogger, "getSolutions selector {}", Utils.mapToJsonString(theSelection));
+                       log.info("getSolutions selector {}", Utils.mapToJsonString(theSelection));
                        selectorParam = theSelection == null ? null
                                        // : UriUtils.encodeQueryParam(Utils.mapToJsonString(theSelection),"UTF-8");
                                        : Base64Utils.encodeToString(Utils.mapToJsonString(theSelection).getBytes("UTF-8"));
-                       log.info(EELFLoggerDelegate.debugLogger, "getSolutions encoded selector {}", selectorParam);
+                       log.info("getSolutions encoded selector {}", selectorParam);
                }
                catch (Exception x) {
                        throw new IllegalArgumentException("Cannot process the selection argument", x);
@@ -162,7 +161,7 @@ public class FederationClient extends AbstractClient {
 
                URI uri = API.SOLUTIONS.buildUri(this.baseUrl, selectorParam == null ? Collections.EMPTY_MAP
                                : Collections.singletonMap(API.QueryParameters.SOLUTIONS_SELECTOR, selectorParam));
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPSolution>>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -170,15 +169,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
@@ -186,14 +185,14 @@ public class FederationClient extends AbstractClient {
        /**
         * @param theSolutionId the solution id
         * @return Peer information from Remote Acumos
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException if remote acumos interaction has failed.
+        * @throws FederationException
+        *             if remote acumos interaction has failed.
         */
        public JsonResponse<MLPSolution> getSolution(String theSolutionId)
                        throws FederationException {
 
                URI uri = API.SOLUTION_DETAIL.buildUri(this.baseUrl, theSolutionId);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<MLPSolution>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -201,15 +200,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
@@ -218,14 +217,14 @@ public class FederationClient extends AbstractClient {
         * 
         * @param theSolutionId the solution id
         * @return List of MLPSolution Revisions from Remote Acumos
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException is remote acumos is not available
+        * @throws FederationException
+        *             if remote acumos is not available
         */
        public JsonResponse<List<MLPSolutionRevision>> getSolutionRevisions(String theSolutionId)
                        throws FederationException {
 
                URI uri = API.SOLUTION_REVISIONS.buildUri(this.baseUrl, theSolutionId);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPSolutionRevision>>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -233,15 +232,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.info(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.info(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
@@ -252,14 +251,14 @@ public class FederationClient extends AbstractClient {
         * @param theRevisionId
         *            Revision ID
         * @return Detailed artifact information from Remote Acumos. The returned value can be safely cast to ..gateway.cds.SolutionRevision.
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException is remote acumos is not available
+        * @throws FederationException
+        *             if remote acumos is not available
         */
        public JsonResponse<MLPSolutionRevision> getSolutionRevision(String theSolutionId, String theRevisionId)
                        throws FederationException {
 
                URI uri = API.SOLUTION_REVISION_DETAILS.buildUri(this.baseUrl, theSolutionId, theRevisionId);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<MLPSolutionRevision>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -267,15 +266,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.info(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.info(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
@@ -287,13 +286,13 @@ public class FederationClient extends AbstractClient {
         * @param theRevisionId
         *            Revision ID
         * @return List of MLPArtifacts from Remote Acumos
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException is remote acumos is not available
+        * @throws FederationException
+        *             if remote acumos is not available
         */
        public JsonResponse<List<MLPArtifact>> getArtifacts(String theSolutionId, String theRevisionId)
                        throws FederationException {
                URI uri = API.SOLUTION_REVISION_ARTIFACTS.buildUri(this.baseUrl, theSolutionId, theRevisionId);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPArtifact>>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -301,15 +300,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response.getBody();
        }
@@ -322,8 +321,7 @@ public class FederationClient extends AbstractClient {
         * @param theArtifactId
         *            Artifact ID
         * @return Resource
-        * @throws HttpStatusCodeException
-        *             On failure
+        * @throws FederationException On failure
         */
        public Resource getArtifactContent(String theSolutionId, String theRevisionId, String theArtifactId)
                                                                                                                                                                                                                                                                                                                                                        throws FederationException {
@@ -337,13 +335,13 @@ public class FederationClient extends AbstractClient {
         * @param theRevisionId
         *            Revision ID
         * @return List of MLPDocuments from Remote Acumos
-        * @throws HttpStatusCodeException
-        *             Throws HttpStatusCodeException is remote acumos is not available
+        * @throws FederationException
+        *             if remote acumos is not available
         */
        public JsonResponse<List<MLPDocument>> getDocuments(String theSolutionId, String theRevisionId)
                        throws FederationException {
                URI uri = API.SOLUTION_REVISION_DOCUMENTS.buildUri(this.baseUrl, theSolutionId, theRevisionId);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<List<MLPDocument>>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -351,15 +349,15 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", scx);
+                       log.error(uri + " failed", scx);
                        throw new PeerException(uri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                        throw new FederationException(uri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response == null ? null : response.getBody();
        }
@@ -372,7 +370,7 @@ public class FederationClient extends AbstractClient {
         * @param theDocumentId
         *            Document ID
         * @return Resource
-        * @throws HttpStatusCodeException
+        * @throws FederationException
         *             On failure
         */
        public Resource getDocumentContent(String theSolutionId, String theRevisionId, String theDocumentId)
@@ -381,7 +379,7 @@ public class FederationClient extends AbstractClient {
        }
 
        protected Resource download(URI theUri) throws FederationException {
-               log.info(EELFLoggerDelegate.debugLogger, "Query for download {}", theUri);
+               log.info("Query for download {}", theUri);
                ResponseEntity<Resource> response = null;
                RequestEntity<Void> request = RequestEntity
                                                                                                                                        .get(theUri)
@@ -391,15 +389,15 @@ public class FederationClient extends AbstractClient {
                        response = restTemplate.exchange(request, Resource.class);
                }
                catch (HttpStatusCodeException scx) {
-                       log.error(EELFLoggerDelegate.errorLogger, theUri + " failed", scx);
+                       log.error(theUri + " failed", scx);
                        throw new PeerException(theUri, scx);
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, theUri + " unexpected failure.", t);
+                       log.error(theUri + " unexpected failure.", t);
                        throw new FederationException(theUri, t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, theUri + " response " + response);
+                       log.info(theUri + " response " + response);
                }
 
                return response.getBody();
@@ -407,9 +405,12 @@ public class FederationClient extends AbstractClient {
 
        /**
         * Important: the Resource returned by this method MUST BE CLOSED by whoever uses it.
+        * @param theUri URI
+        * @return Resource
+        * @throws FederationException on failure
         */
        protected StreamingResource download2(URI theUri) throws FederationException {
-               log.info(EELFLoggerDelegate.debugLogger, "Query for download {}", theUri);
+               log.info("Query for download {}", theUri);
                ClientHttpResponse response = null;
                try {
                        ClientHttpRequest request =     new HttpComponentsClientHttpRequestFactory(this.client)
@@ -420,7 +421,7 @@ public class FederationClient extends AbstractClient {
                        if (!status.is2xxSuccessful())
                                throw new HttpClientErrorException(status, response.getStatusText());
                
-                       log.info(EELFLoggerDelegate.debugLogger, "Query for download got response {}", response);
+                       log.info("Query for download got response {}", response);
        
                        return new StreamingResource(response);
                }
@@ -432,7 +433,7 @@ public class FederationClient extends AbstractClient {
        public static class StreamingResource extends InputStreamResource
                                                                                                                                                                implements Closeable {
 
-               private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+               private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
                private ClientHttpResponse response;
 
                StreamingResource(ClientHttpResponse theResponse) throws IOException {
@@ -442,7 +443,7 @@ public class FederationClient extends AbstractClient {
 
                @Override
                public InputStream getInputStream() throws IOException, IllegalStateException {
-                       log.trace(EELFLoggerDelegate.debugLogger, "Download input stream access at {}",ExceptionUtils.getStackTrace(new RuntimeException("Input stream access")) );
+                       log.trace("Download input stream access at {}",ExceptionUtils.getStackTrace(new RuntimeException("Input stream access")) );
                        return super.getInputStream();
                }
 
@@ -453,7 +454,7 @@ public class FederationClient extends AbstractClient {
 
                @Override
                public void close()  throws IOException {
-                       log.info(EELFLoggerDelegate.debugLogger, "Streaming resource closed");
+                       log.info("Streaming resource closed");
                        this.response.close();
                }
        }
@@ -461,6 +462,7 @@ public class FederationClient extends AbstractClient {
 
 
        /**
+        * @param theSelf self
         * @return Register self with the peer this client points to.
         * @throws HttpStatusCodeException
         *             Throws HttpStatusCodeException if remote acumos interaction has failed.
@@ -468,7 +470,7 @@ public class FederationClient extends AbstractClient {
        public JsonResponse<MLPPeer> register(MLPPeer theSelf)
                        throws HttpStatusCodeException {
                URI uri = API.PEER_REGISTER.buildUri(this.baseUrl);
-               log.info(EELFLoggerDelegate.debugLogger, "Query for " + uri);
+               log.info("Query for " + uri);
                ResponseEntity<JsonResponse<MLPPeer>> response = null;
                try {
                        response = restTemplate.exchange(uri, HttpMethod.GET, null,
@@ -476,14 +478,14 @@ public class FederationClient extends AbstractClient {
                                        });
                }
                catch (HttpStatusCodeException x) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " failed", x);
+                       log.error(uri + " failed", x);
                        throw x;
                }
                catch (Throwable t) {
-                       log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       log.error(uri + " unexpected failure.", t);
                }
                finally {
-                       log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
+                       log.info(uri + " response " + response);
                }
                return response == null ? null : response.getBody();
        }       
index 522a3f7..36b4a43 100644 (file)
@@ -88,8 +88,6 @@ public class JsonResponse<T> implements Serializable {
                                                                .toString();
        }
 
-       /**
-        */
        public static class JsonResponseBuilder<T> {
 
                private JsonResponse<T> response = new JsonResponse();
@@ -113,13 +111,10 @@ public class JsonResponse<T> implements Serializable {
                }
        }
 
-       /** */
        public static <T> JsonResponseBuilder<T> buildResponse() {
                return new JsonResponseBuilder<T>();
        }
 
-       /**
-        */
        public static class JsonErrorResponseBuilder<T> {
 
                private JsonResponse<T> response = new JsonResponse();
@@ -144,7 +139,6 @@ public class JsonResponse<T> implements Serializable {
                }
        }
        
-       /** */
        public static <T> JsonErrorResponseBuilder<T> buildErrorResponse() {
                return new JsonErrorResponseBuilder<T>();
        }
index 614b2d2..b533c46 100644 (file)
 package org.acumos.federation.gateway.config;
 
 import org.acumos.federation.gateway.common.Clients;
+import org.acumos.federation.gateway.cds.CodeNamesConfiguration;
 import org.acumos.federation.gateway.security.AuthenticationConfiguration;
 import org.acumos.federation.gateway.security.FederationMethodSecurityConfiguration;
 import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.CodeNamesService;
 import org.acumos.federation.gateway.service.ContentService;
 import org.acumos.federation.gateway.service.LocalWatchService;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.service.PeerSubscriptionService;
 import org.acumos.federation.gateway.service.impl.CatalogServiceLocalImpl;
+import org.acumos.federation.gateway.service.impl.CodeNamesServiceLocalImpl;
 import org.acumos.federation.gateway.service.impl.ContentServiceLocalImpl;
 import org.acumos.federation.gateway.service.impl.PeerServiceLocalImpl;
 import org.acumos.federation.gateway.task.TaskConfiguration;
@@ -47,7 +50,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @Configuration
 @Import({TaskConfiguration.class,
                                 AuthenticationConfiguration.class,
-                                FederationMethodSecurityConfiguration.class})
+                                FederationMethodSecurityConfiguration.class,
+                                CodeNamesConfiguration.class})
 @EnableConfigurationProperties({FederationInterfaceConfiguration.class,
                                                                                                                                LocalInterfaceConfiguration.class,
                                                                                                                                CDMSClientConfiguration.class,
@@ -79,6 +83,11 @@ public abstract class AdapterConfiguration  {
                return new ContentServiceLocalImpl();
        }
 
+       @Bean
+       public CodeNamesService codeNamesService() {
+               return new CodeNamesServiceLocalImpl();
+       }
+
   @Bean
   public LocalWatchService watchService() {
     return new LocalWatchService();
index 29e5815..cb2563b 100644 (file)
@@ -22,6 +22,9 @@ package org.acumos.federation.gateway.config;
 
 import java.lang.invoke.MethodHandles;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.acumos.cds.client.CommonDataServiceRestClientImpl;
 import org.acumos.cds.client.ICommonDataServiceRestClient;
 import org.acumos.federation.gateway.cds.Mapper;
@@ -42,7 +45,7 @@ public class CDMSClientConfiguration {
 
        public static final int DEFAULT_PAGE_SIZE = 100;
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
        private String          url;
        private String          username;
        private String          password;
@@ -97,6 +100,7 @@ public class CDMSClientConfiguration {
 
        /**
         * CDS traffic is always routed through the local interface;
+        * @return Client
         */
        public ICommonDataServiceRestClient getCDSClient() {
 
@@ -105,12 +109,11 @@ public class CDMSClientConfiguration {
 
                RestTemplateBuilder builder =
                        new RestTemplateBuilder()
-                               .requestFactory(new HttpComponentsClientHttpRequestFactory( 
-                                                                                                       this.localIfConfig.buildClient()))
+                               .requestFactory(
+                                       () -> new HttpComponentsClientHttpRequestFactory(this.localIfConfig.buildClient()))
                                //.rootUri(env.getProperty("cdms.client.url"))
-                               .basicAuthorization(this.username, this.password)
-                               .messageConverters(cdsMessageConverter)
-                               ;
+                                       .basicAuthorization(this.username, this.password)
+                                       .messageConverters(cdsMessageConverter);
 
                return new CommonDataServiceRestClientImpl(this.url, builder.build());
        }
index f1331e1..b042e19 100644 (file)
@@ -22,6 +22,9 @@ package org.acumos.federation.gateway.config;
 
 import java.lang.invoke.MethodHandles;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
@@ -38,7 +41,7 @@ import com.github.dockerjava.core.DockerClientConfig;
 @ConfigurationProperties(prefix = "docker")
 public class DockerConfiguration {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
        private DefaultDockerClientConfig.Builder builder;
        // need to repeat as the builder does not expose it and it avoids building a config object every time ..
        private String registryUrl;
@@ -108,14 +111,12 @@ public class DockerConfiguration {
                return this.builder.build();
        }
 
-       /** */
        public DockerClient     getDockerClient() {
     return DockerClientBuilder.getInstance(buildConfig())
                        .withDockerCmdExecFactory(DockerClientBuilder.getDefaultDockerCmdExecFactory())
                        .build();
        }
 
-       /** */
        public AuthConfig getAuthConfig() {
                DockerClientConfig config = buildConfig();
                return new AuthConfig()
diff --git a/gateway/src/main/java/org/acumos/federation/gateway/config/EELFLoggerDelegate.java b/gateway/src/main/java/org/acumos/federation/gateway/config/EELFLoggerDelegate.java
deleted file mode 100644 (file)
index cc72157..0000000
+++ /dev/null
@@ -1,390 +0,0 @@
-/*-
- * ===============LICENSE_START=======================================================
- * Acumos
- * ===================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
- * ===================================================================================
- * This Acumos software file is distributed by AT&T and Tech Mahindra
- * under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *  
- *      http://www.apache.org/licenses/LICENSE-2.0
- *  
- * This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ===============LICENSE_END=========================================================
- */
-
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License 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.
- * ================================================================================
- */
-package org.acumos.federation.gateway.config;
-
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
-import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
-import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
-
-import java.net.InetAddress;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.slf4j.MDC;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.configuration.SLF4jWrapper;
-
-/**
- * Extends the EELF logger so the output includes the CLASS NAME, which the base
- * implementation does not provide by default. Example usage:
- * 
- * <pre>
- * private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MyClass.class);
- * ..
- * void methodName() {
- *   try {
- *     String result = doWork();
- *     logger.debug(EELFLoggerDelegate.debugLogger, "methodName: result is {} ", result);
- *   }
- *   catch (Exception ex) {
- *     logger.error(EELFLoggerDelegate.errorLogger, "methodName failed", ex);
- *   }
- * }
- * </pre>
- *
- */
-public class EELFLoggerDelegate extends SLF4jWrapper implements EELFLogger {
-
-       public static EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();
-       public static EELFLogger applicationLogger = EELFManager.getInstance().getApplicationLogger();
-       public static EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
-       // Usage of the audit and metrics loggers is required in certain environments
-       public static EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
-       public static EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
-       private static final String MDC_CLASS_NAME = "ClassName";
-       private String className;
-       private static ConcurrentMap<String, EELFLoggerDelegate> classMap = new ConcurrentHashMap<String, EELFLoggerDelegate>();
-
-       public EELFLoggerDelegate(String _className) {
-               super(_className);
-               className = _className;
-       }
-
-       /**
-        * Convenience method that gets a logger for the specified class.
-        * 
-        * @see #getLogger(String)
-        * 
-        * @param clazz
-        *            class
-        * @return Instance of EELFLoggerDelegate
-        */
-       public static EELFLoggerDelegate getLogger(Class<?> clazz) {
-               return getLogger(clazz.getName());
-       }
-
-       /**
-        * Gets a logger for the specified class name. If the logger does not already
-        * exist in the map, this creates a new logger.
-        * 
-        * @param className
-        *            If null or empty, uses EELFLoggerDelegate as the class name.
-        * @return Instance of EELFLoggerDelegate
-        */
-       public static EELFLoggerDelegate getLogger(String className) {
-               if (className == null || className == "")
-                       className = EELFLoggerDelegate.class.getName();
-               EELFLoggerDelegate delegate = classMap.get(className);
-               if (delegate == null) {
-                       delegate = new EELFLoggerDelegate(className);
-                       classMap.put(className, delegate);
-               }
-               return delegate;
-       }
-
-       /**
-        * Logs a message at the lowest level: trace.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        */
-       public void trace(EELFLogger logger, String msg) {
-               if (logger.isTraceEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.trace(msg);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message with parameters at the lowest level: trace.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param arguments
-        *            arguments to interpolate into message
-        */
-       public void trace(EELFLogger logger, String msg, Object... arguments) {
-               if (logger.isTraceEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.trace(msg, arguments);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message and throwable at the lowest level: trace.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param th
-        *            throwable to show as a stack trace
-        */
-       public void trace(EELFLogger logger, String msg, Throwable th) {
-               if (logger.isTraceEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.trace(msg, th);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message at the second-lowest level: debug.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        */
-       public void debug(EELFLogger logger, String msg) {
-               if (logger.isDebugEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.debug(msg);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message with parameters at the second-lowest level: debug.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param arguments
-        *            arguments to interpolate into message
-        */
-       public void debug(EELFLogger logger, String msg, Object... arguments) {
-               if (logger.isDebugEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.debug(msg, arguments);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message and throwable at the second-lowest level: debug.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param th
-        *            throwable to show as a stack trace
-        */
-       public void debug(EELFLogger logger, String msg, Throwable th) {
-               if (logger.isDebugEnabled()) {
-                       MDC.put(MDC_CLASS_NAME, className);
-                       logger.debug(msg, th);
-                       MDC.remove(MDC_CLASS_NAME);
-               }
-       }
-
-       /**
-        * Logs a message at info level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        */
-       public void info(EELFLogger logger, String msg) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.info(msg);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message with parameters at info level.
-        *
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param arguments
-        *            arguments to interpolate into message
-        */
-       public void info(EELFLogger logger, String msg, Object... arguments) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.info(msg, arguments);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message and throwable at info level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param th
-        *            throwable to show as a stack trace
-        */
-       public void info(EELFLogger logger, String msg, Throwable th) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.info(msg, th);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message at warn level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        */
-       public void warn(EELFLogger logger, String msg) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.warn(msg);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message with parameters at warn level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param arguments
-        *            arguments to interpolate into message
-        */
-       public void warn(EELFLogger logger, String msg, Object... arguments) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.warn(msg, arguments);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message and throwable at warn level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param th
-        *            throwable to show as a stack trace
-        */
-       public void warn(EELFLogger logger, String msg, Throwable th) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.warn(msg, th);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message at error level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        */
-       public void error(EELFLogger logger, String msg) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.error(msg);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message with parameters at error level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param arguments
-        *            arguments to interpolate into message
-        */
-       public void error(EELFLogger logger, String msg, Object... arguments) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.error(msg, arguments);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Logs a message and throwable at error level.
-        * 
-        * @param logger
-        *            Logger to use
-        * @param msg
-        *            message to log
-        * @param th
-        *            throwable to show as a stack trace
-        */
-       public void error(EELFLogger logger, String msg, Throwable th) {
-               MDC.put(MDC_CLASS_NAME, className);
-               logger.error(msg, th);
-               MDC.remove(MDC_CLASS_NAME);
-       }
-
-       /**
-        * Initializes the logger context.
-        */
-       public void init() {
-               setGlobalLoggingContext();
-               final String msg = "############################ Logging is started. ############################";
-               info(applicationLogger, msg);
-               error(errorLogger, msg);
-               debug(debugLogger, msg);
-       }
-
-       /**
-        * Loads all the default logging fields into the MDC context.
-        */
-       private void setGlobalLoggingContext() {
-               MDC.put(MDC_SERVICE_INSTANCE_ID, "");
-               try {
-                       MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
-                       MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
-               } catch (Exception e) {
-               }
-       }
-
-}
index 16fb6fa..8349380 100644 (file)
@@ -22,6 +22,9 @@ package org.acumos.federation.gateway.config;
 
 import java.lang.invoke.MethodHandles;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.acumos.federation.gateway.controller.CatalogController;
 import org.acumos.federation.gateway.controller.PeersController;
 import org.acumos.federation.gateway.controller.PingController;
@@ -31,8 +34,8 @@ import org.apache.http.client.HttpClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
-import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
+import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Conditional;
 import org.springframework.context.annotation.Configuration;
@@ -47,7 +50,7 @@ public class FederationConfiguration {
 
        @Autowired
        private FederationInterfaceConfiguration interfaceConfig;
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        public FederationConfiguration() {
        }
@@ -80,22 +83,23 @@ public class FederationConfiguration {
         * roles when interacting with peers: we'll assume the same identity, use the
         * same network interface, etc. If this ever needs to change we can pick
         * the values from a separate configuration properties set.
+        * @return Client
         */
        @Bean
   @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
        //@ConfigurationProperties(prefix = "server", ignoreInvalidFields = true)
        public HttpClient federationClient() {
-               log.debug(EELFLoggerDelegate.debugLogger, this + "::federationClient from " + this.interfaceConfig);
+               log.debug(this + "::federationClient from " + this.interfaceConfig);
                return this.interfaceConfig.buildClient();
        }
 
        @Bean
-       public EmbeddedServletContainerCustomizer federationServer() {
-               log.debug(EELFLoggerDelegate.debugLogger, this + "::federationServer from " + this.interfaceConfig);
-               return new EmbeddedServletContainerCustomizer() {
+       public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> federationServer() {
+               log.debug(this + "::federationServer from " + this.interfaceConfig);
+               return new WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>() {
                        @Override
-                       public void customize(ConfigurableEmbeddedServletContainer theContainer) {
-                               FederationConfiguration.this.interfaceConfig.configureContainer(theContainer);
+                       public void customize(ConfigurableServletWebServerFactory theServer) {
+                               FederationConfiguration.this.interfaceConfig.configureWebServer(theServer);
                        }
                }; 
        }
index b529bd1..71591d9 100644 (file)
@@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
 /**
  * Defines a specific external configuration prefix for the federation interface.
  */
-@Component
+@Component("federationInterface")
 @ConfigurationProperties(prefix = "federation")
 public class FederationInterfaceConfiguration extends InterfaceConfiguration {
 
index edb5edc..2d3f9f0 100644 (file)
@@ -22,14 +22,17 @@ package org.acumos.federation.gateway.config;
 
 import org.acumos.federation.gateway.adapter.PeerGateway;
 import org.acumos.federation.gateway.common.Clients;
+import org.acumos.federation.gateway.cds.CodeNamesConfiguration;
 import org.acumos.federation.gateway.security.AuthenticationConfiguration;
 import org.acumos.federation.gateway.security.FederationMethodSecurityConfiguration;
 import org.acumos.federation.gateway.service.CatalogService;
+import org.acumos.federation.gateway.service.CodeNamesService;
 import org.acumos.federation.gateway.service.CatalogServiceConfiguration;
 import org.acumos.federation.gateway.service.ContentService;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.service.PeerSubscriptionService;
 import org.acumos.federation.gateway.service.impl.CatalogServiceImpl;
+import org.acumos.federation.gateway.service.impl.CodeNamesServiceImpl;
 import org.acumos.federation.gateway.service.impl.ContentServiceImpl;
 import org.acumos.federation.gateway.service.impl.ContentServiceLocalImpl;
 import org.acumos.federation.gateway.service.impl.PeerServiceImpl;
@@ -52,7 +55,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @Configuration
 @Import({TaskConfiguration.class,
                                 AuthenticationConfiguration.class,
-                                FederationMethodSecurityConfiguration.class})
+                                FederationMethodSecurityConfiguration.class,
+                                CodeNamesConfiguration.class})
 @EnableConfigurationProperties({FederationInterfaceConfiguration.class,
                                                                                                                                LocalInterfaceConfiguration.class,
                                                                                                                                CDMSClientConfiguration.class,
@@ -83,9 +87,14 @@ public class GatewayConfiguration {
                return new PeerSubscriptionServiceImpl();
        }
 
+       @Bean
+       public CodeNamesService codeNamesService() {
+               return new CodeNamesServiceImpl();
+       }
+
        /**
         * The 'local' profile allows us to run a gateway based on a local artifact supplier, for testing purposes.
-
+        * @return ContentService
         */
        @Bean
        @Profile({"!local"})
index 2a33f9b..7a4276e 100644 (file)
@@ -36,6 +36,9 @@ import java.util.NoSuchElementException;
 import javax.annotation.PostConstruct;
 import javax.net.ssl.SSLContext;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.catalina.connector.Connector;
 import org.apache.coyote.http11.Http11NioProtocol;
 import org.apache.http.HttpHost;
@@ -61,8 +64,8 @@ import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
 import org.apache.http.protocol.HttpContext;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
-import org.springframework.boot.context.embedded.Ssl;
+import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
+import org.springframework.boot.web.server.Ssl;
 import org.springframework.core.io.DefaultResourceLoader;
 import org.springframework.core.io.ResourceLoader;
 import org.springframework.stereotype.Component;
@@ -70,7 +73,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class InterfaceConfiguration {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        private String                  address;
        private InetAddress     inetAddress;
@@ -79,7 +82,7 @@ public class InterfaceConfiguration {
        private Server  server; 
 
        public InterfaceConfiguration() {
-               log.trace(EELFLoggerDelegate.debugLogger, this + "::new");
+               log.trace(this + "::new");
        }
 
 /*
@@ -93,7 +96,7 @@ public class InterfaceConfiguration {
 */
        @PostConstruct
        public void initInterface() {
-               log.trace(EELFLoggerDelegate.debugLogger, this + "::init");
+               log.trace(this + "::init");
        }       
 
        public String getAddress() {
@@ -149,6 +152,8 @@ public class InterfaceConfiguration {
 
        /** 
         * Provide the subject name specified in the SSL config
+        * @return Name
+        * @throws KeyStoreException On failure
         */
        public String getSubjectName() throws KeyStoreException {
                if (!hasSSL())
@@ -272,7 +277,7 @@ public class InterfaceConfiguration {
         */
        public static class SSL {
 
-               private final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(getClass().getName());
+               private final Logger log = LoggerFactory.getLogger(getClass().getName());
 
                @Autowired
                private ResourceLoader resourceLoader;
@@ -421,7 +426,7 @@ public class InterfaceConfiguration {
                        try {
                                store = KeyStore.getInstance(theType);
                                store.load(storeSource, thePasswd.toCharArray());
-                               log.trace(EELFLoggerDelegate.debugLogger, "Loaded key store: " + theLocation);
+                               log.trace("Loaded key store: " + theLocation);
                        }
                        catch (Exception x) {
                                throw new IllegalStateException("Error loading key material: " + x, x);
@@ -431,7 +436,7 @@ public class InterfaceConfiguration {
                                        storeSource.close();
                                }
                                catch (IOException iox) {
-                                       log.warn(EELFLoggerDelegate.debugLogger, "Error closing key store source", iox);
+                                       log.warn("Error closing key store source", iox);
                                }
                        }
                        return store;
@@ -442,16 +447,16 @@ public class InterfaceConfiguration {
        /**
         * Configure the existing/default/a servlet container with the configuration
         * information of this interface.
-        * @param theContainer the servlet container to be configured
+        * @param theServer the servlet container to be configured
         * @return ConfigurableEmbeddedServletContainer the container, configured
         */
-       public ConfigurableEmbeddedServletContainer configureContainer(
-                                                                               ConfigurableEmbeddedServletContainer theContainer) {
+       public ConfigurableServletWebServerFactory configureWebServer(
+                                                                               ConfigurableServletWebServerFactory theServer) {
                if (hasServer()) {
-                       theContainer.setPort(this.server.getPort());
+                       theServer.setPort(this.server.getPort());
                }
                if (hasAddress()) {
-                       theContainer.setAddress(this.inetAddress);
+                       theServer.setAddress(this.inetAddress);
                }
                if (hasSSL()) {
                        Ssl cssl = new Ssl();
@@ -465,9 +470,9 @@ public class InterfaceConfiguration {
                        cssl.setTrustStoreType(this.ssl.getTrustStoreType());
                        cssl.setKeyAlias(this.ssl.getKeyAlias());
                        cssl.setClientAuth(Ssl.ClientAuth.valueOf(this.ssl.clientAuth.toUpperCase()));
-                       theContainer.setSsl(cssl);
+                       theServer.setSsl(cssl);
                }
-               return theContainer;
+               return theServer;
        }
 
        /**
@@ -505,10 +510,10 @@ public class InterfaceConfiguration {
        public HttpClient buildClient() {
 
                SSLContext sslContext = null;
-               log.trace(EELFLoggerDelegate.debugLogger, "Build HttpClient with " + this);
+               log.trace("Build HttpClient with " + this);
 
                if (this.ssl == null) {
-                       log.trace(EELFLoggerDelegate.debugLogger, "No ssl config was provided");
+                       log.trace("No ssl config was provided");
                }
                else {
                        KeyStore keyStore = this.ssl.loadKeyStore(),
@@ -541,7 +546,7 @@ public class InterfaceConfiguration {
                if (sslContext != null) {
                        sslSocketFactory = new SSLConnectionSocketFactory(sslContext, new String[] { "TLSv1.2" }, null,
                                        SSLConnectionSocketFactory.getDefaultHostnameVerifier());
-                       log.trace(EELFLoggerDelegate.debugLogger, "SSL connection factory configured");
+                       log.trace("SSL connection factory configured");
                }
 
                RegistryBuilder<ConnectionSocketFactory> registryBuilder = RegistryBuilder.<ConnectionSocketFactory>create();
@@ -562,10 +567,10 @@ public class InterfaceConfiguration {
                if (hasClient()) {
                        credsProvider = new BasicCredentialsProvider();
                        credsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(this.client.getUsername(), this.client.getPassword()));
-                       log.trace(EELFLoggerDelegate.debugLogger, "Credentials configured");
+                       log.trace("Credentials configured");
                }
                else {
-                       log.trace(EELFLoggerDelegate.debugLogger, "No credentials were provided");
+                       log.trace("No credentials were provided");
                }
 
                HttpClientBuilder clientBuilder = HttpClients.custom();
index e549f40..fc9f86d 100644 (file)
@@ -22,6 +22,9 @@ package org.acumos.federation.gateway.config;
 
 import java.lang.invoke.MethodHandles;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.acumos.federation.gateway.controller.PeerCatalogController;
 import org.acumos.federation.gateway.controller.PeerPeersController;
 import org.acumos.federation.gateway.controller.PeerPingController;
@@ -30,8 +33,8 @@ import org.apache.http.client.HttpClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
-import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
+import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Scope;
@@ -45,7 +48,7 @@ public class LocalConfiguration {
 
        @Autowired
        private LocalInterfaceConfiguration interfaceConfig;
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        public LocalConfiguration() {
        }
@@ -77,27 +80,29 @@ public class LocalConfiguration {
         * roles when interacting with peers: we'll assume the same identity, use the
         * same network interface, etc. If this ever needs to change we can pick
         * the values from a separate configuration properties set.
+        * @return Client
         */
        @Bean
   @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
        public HttpClient localClient() {
-               log.debug(EELFLoggerDelegate.debugLogger, this + "::localClient from " + this.interfaceConfig);
+               log.debug(this + "::localClient from " + this.interfaceConfig);
                return interfaceConfig.buildClient();
        }
 
        /**
         * Build a servlet container running on the local interface for serving
         * local interface requests (see controllers built here).
+        * @return Server customizer
         */
        @Bean
-       public EmbeddedServletContainerCustomizer localServer() {
-               log.debug(EELFLoggerDelegate.debugLogger, this + "::localServer from " + this.interfaceConfig);
-               return new EmbeddedServletContainerCustomizer() {
+       public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> localServer() {
+               log.debug(this + "::localServer from " + this.interfaceConfig);
+               return new WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>() {
                        @Override
-                       public void customize(ConfigurableEmbeddedServletContainer theContainer) {
-                               LocalConfiguration.this.interfaceConfig.configureContainer(theContainer);
+                       public void customize(ConfigurableServletWebServerFactory theServer) {
+                               LocalConfiguration.this.interfaceConfig.configureWebServer(theServer);
                        }
-               };
-       } 
+               }; 
+       }
        
 }
index 33f0c91..497e333 100644 (file)
@@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
 /**
  * Defines a specific external configuration prefix for the local interface.
  */
-@Component
+@Component("localInterface")
 @ConfigurationProperties(prefix = "local")
 public class LocalInterfaceConfiguration extends InterfaceConfiguration {
 
index d40af6c..708c193 100644 (file)
@@ -26,6 +26,9 @@ import java.net.MalformedURLException;
 
 import java.lang.invoke.MethodHandles;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.http.HttpHost;
 import org.apache.http.client.AuthCache;
 import org.apache.http.client.protocol.HttpClientContext;
@@ -56,7 +59,7 @@ import org.springframework.web.client.RestTemplate;
 @ConfigurationProperties(prefix = "nexus")
 public class NexusConfiguration {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        private String          proxy;
        private String    groupId;
@@ -122,13 +125,14 @@ public class NexusConfiguration {
 
        /**
         * Prepare a RestTemplate fitted for Nexus interactions, in particular ready to perform preemptive basic authentication.
+        * @return RestTemplate
         */
        public RestTemplate getNexusClient() {
 
                RestTemplateBuilder builder =
                        new RestTemplateBuilder()
                                .requestFactory(
-                                       new HttpComponentsClientHttpRequestFactory(this.localIfConfig.buildClient()) {
+                                       () -> new HttpComponentsClientHttpRequestFactory(this.localIfConfig.buildClient()) {
 
                                                protected HttpContext createHttpContext(HttpMethod theMethod, URI theUri) {
                                                        HttpHost nexusHost = new HttpHost(NexusConfiguration.this.url.getHost(), NexusConfiguration.this.url.getPort());
index e7db988..c4bfa3c 100644 (file)
@@ -35,12 +35,13 @@ import org.acumos.cds.domain.MLPDocument;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 import org.acumos.federation.gateway.cds.Artifact;
-import org.acumos.federation.gateway.cds.ArtifactType;
+import org.acumos.federation.gateway.cds.ArtifactTypes;
 import org.acumos.federation.gateway.cds.Document;
 import org.acumos.federation.gateway.cds.SolutionRevision;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.service.CatalogService;
 import org.acumos.federation.gateway.service.ContentService;
 import org.acumos.federation.gateway.util.Utils;
@@ -67,7 +68,7 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(API.Roots.FEDERATION)
 public class CatalogController extends AbstractController {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        @Autowired
        private CatalogService catalogService;
@@ -75,6 +76,7 @@ public class CatalogController extends AbstractController {
        private ContentService contentService;
 
        /**
+        * @param theHttpRequest Request
         * @param theHttpResponse
         *            HttpServletResponse
         * @param theSelector
@@ -85,7 +87,7 @@ public class CatalogController extends AbstractController {
        // @PreAuthorize("hasAuthority('PEER')"
        @PreAuthorize("isActive && hasAuthority(T(org.acumos.federation.gateway.security.Priviledge).CATALOG_ACCESS)")
        @ApiOperation(value = "Invoked by Peer Acumos to get a list of Published Solutions from the Catalog of the local Acumos Instance .", response = MLPSolution.class, responseContainer = "List")
-       @RequestMapping(value = { API.Paths.SOLUTIONS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = { API.Paths.SOLUTIONS }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
        @ResponseBody
        public JsonResponse<List<MLPSolution>> getSolutions(
                        HttpServletRequest theHttpRequest,
@@ -93,9 +95,9 @@ public class CatalogController extends AbstractController {
                        @RequestParam(value = API.QueryParameters.SOLUTIONS_SELECTOR, required = false) String theSelector) {
                JsonResponse<List<MLPSolution>> response = null;
                List<MLPSolution> solutions = null;
-               log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTIONS);
+               log.debug(API.Paths.SOLUTIONS);
                try {
-                       log.debug(EELFLoggerDelegate.debugLogger, "getSolutions: selector " + theSelector);
+                       log.debug("getSolutions: selector " + theSelector);
                        Map<String, ?> selector = null;
                        if (theSelector != null)
                                selector = Utils.jsonStringToMap(new String(Base64Utils.decodeFromString(theSelector), "UTF-8"));
@@ -112,14 +114,14 @@ public class CatalogController extends AbstractController {
                                                                                                                .withContent(solutions)
                                                                                                                .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                       log.debug(EELFLoggerDelegate.debugLogger, "getSolutions: provided {} solutions", solutions == null ? 0 : solutions.size());
+                       log.debug("getSolutions: provided {} solutions", solutions == null ? 0 : solutions.size());
                }
-               catch (Exception x) {
+               catch (/*Exception*/Throwable x) {
                        response = JsonResponse.<List<MLPSolution>> buildErrorResponse()
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred while fetching solutions", x);
+                       log.error("Exception occurred while fetching solutions", x);
                }
                return response;
        }
@@ -135,7 +137,7 @@ public class CatalogController extends AbstractController {
                        @PathVariable(value = "solutionId") String theSolutionId) {
                JsonResponse<MLPSolution> response = null;
                MLPSolution solution = null;
-               log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_DETAILS + ": " + theSolutionId);
+               log.debug(API.Paths.SOLUTION_DETAILS + ": " + theSolutionId);
                try {
                        solution = catalogService.getSolution(theSolutionId, new ControllerContext());
                        if (null == solution) {
@@ -158,7 +160,7 @@ public class CatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occurred while fetching solution " + theSolutionId, x);
+                       log.error("An error occurred while fetching solution " + theSolutionId, x);
                }
                return response;
        }
@@ -179,7 +181,7 @@ public class CatalogController extends AbstractController {
                        @PathVariable("solutionId") String theSolutionId) {
                JsonResponse<List<MLPSolutionRevision>> response = null;
                List<MLPSolutionRevision> solutionRevisions = null;
-               log.debug(EELFLoggerDelegate.debugLogger, API.Paths.SOLUTION_REVISIONS);
+               log.debug(API.Paths.SOLUTION_REVISIONS);
                try {
                        solutionRevisions = catalogService.getSolutionRevisions(theSolutionId, new ControllerContext());
                        if (null == solutionRevisions) {
@@ -194,7 +196,7 @@ public class CatalogController extends AbstractController {
                                                                                                                        .withContent(solutionRevisions)
                                                                                                                        .build();
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionsRevisions for solution {} provided {} revisions",
+                               log.debug("getSolutionsRevisions for solution {} provided {} revisions",
                                                theSolutionId, solutionRevisions.size());
                        }
                }
@@ -203,13 +205,14 @@ public class CatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occured while fetching solution " + theSolutionId + " revisions", x);
+                       log.error("An error occured while fetching solution " + theSolutionId + " revisions", x);
                }
                return response;
        }
 
        /**
         * 
+        * @param theHttpRequest Request
         * @param theSolutionId
         *            Solution ID
         * @param theRevisionId
@@ -221,8 +224,7 @@ public class CatalogController extends AbstractController {
        @CrossOrigin
        @PreAuthorize("isActive && hasAuthority('CATALOG_ACCESS')")
        @ApiOperation(value = "Invoked by peer Acumos to get solution revision details from the local Acumos Instance .", response = MLPSolutionRevision.class)
-       @RequestMapping(value = {
-                       API.Paths.SOLUTION_REVISION_DETAILS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
+       @RequestMapping(value = {       API.Paths.SOLUTION_REVISION_DETAILS }, method = RequestMethod.GET, produces = APPLICATION_JSON)
        @ResponseBody
        public JsonResponse<MLPSolutionRevision> getSolutionRevisionDetails(
                        HttpServletRequest theHttpRequest, HttpServletResponse theHttpResponse,
@@ -230,8 +232,7 @@ public class CatalogController extends AbstractController {
                ControllerContext context = new ControllerContext();
                JsonResponse<MLPSolutionRevision> response = null;
                SolutionRevision solutionRevision = null;
-               log.debug(EELFLoggerDelegate.debugLogger,
-                               API.Paths.SOLUTION_REVISION_DETAILS + "(" + theSolutionId + "," + theRevisionId + ")");
+               log.debug(API.Paths.SOLUTION_REVISION_DETAILS + "(" + theSolutionId + "," + theRevisionId + ")");
                try {
                        solutionRevision = catalogService.getSolutionRevision(theSolutionId, theRevisionId, context);
                        if (null == solutionRevision) {
@@ -264,7 +265,7 @@ public class CatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " details", x);
+                       log.error("An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " details", x);
                }
                return response;
        }
@@ -292,8 +293,7 @@ public class CatalogController extends AbstractController {
                JsonResponse<List<MLPArtifact>> response = null;
                List<MLPArtifact> solutionRevisionArtifacts = null;
                ControllerContext context = new ControllerContext();
-               log.debug(EELFLoggerDelegate.debugLogger,
-                               API.Paths.SOLUTION_REVISION_ARTIFACTS + "(" + theSolutionId + "," + theRevisionId + ")");
+               log.debug(API.Paths.SOLUTION_REVISION_ARTIFACTS + "(" + theSolutionId + "," + theRevisionId + ")");
                try {
                        solutionRevisionArtifacts = catalogService.getSolutionRevisionArtifacts(theSolutionId, theRevisionId, context);
                        if (null == solutionRevisionArtifacts) {
@@ -313,7 +313,7 @@ public class CatalogController extends AbstractController {
                                                                                                                .withContent(solutionRevisionArtifacts)
                                                                                                                .build();
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionArtifacts provided {} artifacts",
+                               log.debug("getSolutionRevisionArtifacts provided {} artifacts",
                                                        solutionRevisionArtifacts.size());
                        }
                } 
@@ -322,7 +322,7 @@ public class CatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " artifacts", x);
+                       log.error("An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " artifacts", x);
                }
                return response;
        }
@@ -350,8 +350,7 @@ public class CatalogController extends AbstractController {
                JsonResponse<List<MLPDocument>> response = null;
                List<MLPDocument> solutionRevisionDocuments = null;
                ControllerContext context = new ControllerContext();
-               log.debug(EELFLoggerDelegate.debugLogger,
-                               API.Paths.SOLUTION_REVISION_DOCUMENTS + "(" + theSolutionId + "," + theRevisionId + ")");
+               log.debug(API.Paths.SOLUTION_REVISION_DOCUMENTS + "(" + theSolutionId + "," + theRevisionId + ")");
                try {
                        solutionRevisionDocuments = catalogService.getSolutionRevisionDocuments(theSolutionId, theRevisionId, context);
                        if (null == solutionRevisionDocuments) {
@@ -371,7 +370,7 @@ public class CatalogController extends AbstractController {
                                                                                                                .withContent(solutionRevisionDocuments)
                                                                                                                .build();
                                theHttpResponse.setStatus(HttpServletResponse.SC_OK);
-                               log.debug(EELFLoggerDelegate.debugLogger, "getSolutionRevisionDocuments provided {} documents",
+                               log.debug("getSolutionRevisionDocuments provided {} documents",
                                                        solutionRevisionDocuments.size());
                        }
                } 
@@ -380,7 +379,7 @@ public class CatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " documents", x);
+                       log.error("An error occured while fetching solution " + theSolutionId + " revision " + theRevisionId + " documents", x);
                }
                return response;
        }
@@ -422,8 +421,7 @@ public class CatalogController extends AbstractController {
                                                theSolutionId, theRevisionId, catalogService.getSolutionRevisionArtifact(theArtifactId, ctx), ctx);
                                } 
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                               "An error occurred while retrieving artifact content " + theArtifactId, x);
+                                       log.error("An error occurred while retrieving artifact content " + theArtifactId, x);
                                        throw x;
                                }
                        }
@@ -466,8 +464,7 @@ public class CatalogController extends AbstractController {
                                                                        theSolutionId, theRevisionId, catalogService.getSolutionRevisionDocument(theDocumentId, ctx), ctx);
                                } 
                                catch (Exception x) {
-                                       log.error(EELFLoggerDelegate.errorLogger,
-                                               "An error occurred while retrieving artifact content " + theDocumentId, x);
+                                       log.error("An error occurred while retrieving artifact content " + theDocumentId, x);
                                        throw x;
                                }
                        }
@@ -504,11 +501,11 @@ public class CatalogController extends AbstractController {
                                                                                                        new URI(requestUri.getScheme(), null, requestUri.getHost(),
                                                                                                                                        requestUri.getPort(), null, null, null).toString(),
                                                                                                        theSolutionId, theRevisionId, theArtifact.getArtifactId());
-                       log.debug(EELFLoggerDelegate.debugLogger,       "encodeArtifact: redirected artifact uri " + redirectUri);
+                       log.debug("encodeArtifact: redirected artifact uri " + redirectUri);
                        theArtifact.setUri(redirectUri.toString());
                }
                
-               if (ArtifactType.DockerImage == ArtifactType.forCode(theArtifact.getArtifactTypeCode())) {
+               if (ArtifactTypes.DockerImage.getCode().equals(theArtifact.getArtifactTypeCode())) {
                        if (artifactUri != null) {
                                //ugly but avoids parsing the manifest on the receiving side
                                //this seems to be what on-boarding is doing anyway, otherwise this would amount to information loss
@@ -533,7 +530,7 @@ public class CatalogController extends AbstractController {
                                                                                                        new URI(requestUri.getScheme(), null, requestUri.getHost(),
                                                                                                                                        requestUri.getPort(), null, null, null).toString(),
                                                                                                        theSolutionId, theRevisionId, theDocument.getDocumentId());
-                       log.debug(EELFLoggerDelegate.debugLogger,       "encodeDocument: redirected document uri " + redirectUri);
+                       log.debug("encodeDocument: redirected document uri " + redirectUri);
                        theDocument.setUri(redirectUri.toString());
                }
        }
index 2b04fc7..3416b85 100644 (file)
@@ -31,7 +31,8 @@ import org.acumos.cds.domain.MLPSolution;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.service.PeerService;
 import org.acumos.federation.gateway.util.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -56,7 +57,7 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(API.Roots.LOCAL)
 public class PeerCatalogController extends AbstractController {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        @Autowired
        private Clients clients;
@@ -67,6 +68,7 @@ public class PeerCatalogController extends AbstractController {
         * Provides access 
         * @param theHttpResponse
         *            HttpServletResponse
+        * @param thePeerId Peer ID
         * @param theSelector
         *            Solutions selector
         * @return List of Published ML Solutions in JSON format.
@@ -81,7 +83,7 @@ public class PeerCatalogController extends AbstractController {
                        HttpServletResponse theHttpResponse,
                        @PathVariable("peerId") String thePeerId,
                        @RequestParam(value = API.QueryParameters.SOLUTIONS_SELECTOR, required = false) String theSelector) {
-               log.debug(EELFLoggerDelegate.debugLogger, API.Roots.LOCAL + "" + API.Paths.SOLUTIONS);
+               log.debug(API.Roots.LOCAL + "" + API.Paths.SOLUTIONS);
                JsonResponse<List<MLPSolution>> response = null;
                try {
                        MLPPeer peer = this.peerService.getPeerById(thePeerId);
@@ -98,7 +100,7 @@ public class PeerCatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occurred while processing a local peer solutions request for peer " + thePeerId, x);
+                       log.error("An error occurred while processing a local peer solutions request for peer " + thePeerId, x);
                }
                return response;
        }
@@ -112,7 +114,7 @@ public class PeerCatalogController extends AbstractController {
                        HttpServletResponse theHttpResponse,
                        @PathVariable("peerId") String thePeerId,
                        @PathVariable(value = "solutionId") String theSolutionId) {
-               log.debug(EELFLoggerDelegate.debugLogger, API.Roots.LOCAL + "" + API.Paths.SOLUTION_DETAILS);
+               log.debug(API.Roots.LOCAL + "" + API.Paths.SOLUTION_DETAILS);
                JsonResponse<MLPSolution> response = null;
                try {
                        MLPPeer peer = this.peerService.getPeerById(thePeerId);
@@ -125,7 +127,7 @@ public class PeerCatalogController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "An error occurred while fetching solution " + theSolutionId + " from peer " + thePeerId, x);
+                       log.error("An error occurred while fetching solution " + theSolutionId + " from peer " + thePeerId, x);
                }
                return response;
        }
index d49a5a3..2d79d72 100644 (file)
@@ -29,7 +29,8 @@ import org.acumos.cds.domain.MLPPeer;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.service.PeerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -46,7 +47,7 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(API.Roots.LOCAL)
 public class PeerPeersController extends AbstractController {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        @Autowired
        private Clients clients;
@@ -58,6 +59,7 @@ public class PeerPeersController extends AbstractController {
         * Allows local components to ping a peer.
         * @param theHttpResponse
         *            HttpServletResponse
+        * @param thePeerId Peer ID
         * @return The remote peer information
         */
        @CrossOrigin
@@ -71,7 +73,7 @@ public class PeerPeersController extends AbstractController {
                        @PathVariable("peerId") String thePeerId) {
 
                JsonResponse<List<MLPPeer>> response = new JsonResponse<List<MLPPeer>>();
-               log.debug(EELFLoggerDelegate.debugLogger, API.Roots.LOCAL + "" + API.Paths.PEERS);
+               log.debug(API.Roots.LOCAL + "" + API.Paths.PEERS);
                try {
                        MLPPeer peer = this.peerService.getPeerById(thePeerId);
                        response = this.clients.getFederationClient(peer.getApiUrl()).getPeers();
@@ -83,7 +85,7 @@ public class PeerPeersController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred during peer " + thePeerId + " getPeers", x);
+                       log.error("Exception occurred during peer " + thePeerId + " getPeers", x);
                }
                return response;
        }
index 9f218e8..8f5b850 100644 (file)
@@ -28,7 +28,8 @@ import org.acumos.cds.domain.MLPPeer;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.service.PeerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -45,7 +46,7 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(API.Roots.LOCAL)
 public class PeerPingController extends AbstractController {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        @Autowired
        private Clients clients;
@@ -57,6 +58,7 @@ public class PeerPingController extends AbstractController {
         * Allows local components to ping a peer.
         * @param theHttpResponse
         *            HttpServletResponse
+        * @param thePeerId Peer ID
         * @return The remote peer information
         */
        @CrossOrigin
@@ -70,7 +72,7 @@ public class PeerPingController extends AbstractController {
                        @PathVariable("peerId") String thePeerId) {
 
                JsonResponse<MLPPeer> response = new JsonResponse<MLPPeer>();
-               log.debug(EELFLoggerDelegate.debugLogger, API.Roots.LOCAL + "" + API.Paths.PING);
+               log.debug(API.Roots.LOCAL + "" + API.Paths.PING);
                try {
                        MLPPeer peer = this.peerService.getPeerById(thePeerId);
                        if (peer == null) {
@@ -89,7 +91,7 @@ public class PeerPingController extends AbstractController {
                                                                                                                 .withError(x)
                                                                                                                 .build();
                        theHttpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                       log.error(EELFLoggerDelegate.errorLogger, "Exception occurred during peer ping", x);
+                       log.error("Exception occurred during peer ping", x);
                }
                return response;
        }
index 0b09cb1..4b6b09d 100644 (file)
@@ -28,7 +28,8 @@ import org.acumos.cds.domain.MLPPeer;
 import org.acumos.federation.gateway.common.API;
 import org.acumos.federation.gateway.common.Clients;
 import org.acumos.federation.gateway.common.JsonResponse;
-import org.acumos.federation.gateway.config.EELFLoggerDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.acumos.federation.gateway.service.PeerService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -45,7 +46,7 @@ import io.swagger.annotations.ApiOperation;
 @RequestMapping(API.Roots.LOCAL)
 public class PeerRegistrationController extends AbstractController {
 
-       private static final EELFLoggerDelegate log = EELFLoggerDelegate.getLogger(MethodHandles.lookup().lookupClass());
+       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        @Autowired
        private Clients clients;
@@