Temporary fix for missing tags bugs 12/2512/2
authorSerban Jora <sj2381@att.com>
Wed, 8 Aug 2018 17:21:43 +0000 (13:21 -0400)
committerSerban Jora <sj2381@att.com>
Wed, 8 Aug 2018 19:37:52 +0000 (15:37 -0400)
Change-Id: I9d099eda918e1f1fbfe89fa4c039fd4f915af88e
Signed-off-by: Serban Jora <sj2381@att.com>
Issue-ID: ACUMOS-1544
Signed-off-by: Serban Jora <sj2381@att.com>
docs/release-notes.rst
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/adapter/PeerGateway.java
gateway/src/main/java/org/acumos/federation/gateway/cds/SolutionBuilder.java
gateway/src/main/java/org/acumos/federation/gateway/common/FederationClient.java
gateway/src/main/java/org/acumos/federation/gateway/service/impl/ArtifactServiceImpl.java

index 153b1b0..b725760 100644 (file)
@@ -22,6 +22,11 @@ Federated Gateway Release Notes
 
 The Federated Gateway server is available as a Docker image in a Docker registry.
 
+Version 1.16.1, 2018-08-08
+-------------------------
+
+* Temporary patch for tag handling during federation procedures
+
 Version 1.16.0, 2018-08-01
 -------------------------
 
index b745303..0bfc1fa 100644 (file)
@@ -24,7 +24,7 @@ limitations under the License.
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.acumos.federation</groupId>
        <artifactId>gateway</artifactId>
-       <version>1.16.0-SNAPSHOT</version>
+       <version>1.16.1-SNAPSHOT</version>
        <name>Federation Gateway</name>
        <description>Federated Acumos Interface for inter-acumos and ONAP communication</description>
 
index 3f8f537..3085a0c 100644 (file)
@@ -191,6 +191,9 @@ public class PeerGateway {
                        //should the creted/modified reflect this information or the information we got from the peer ?
                                                                                                                                        .withUser(getUserId(this.sub))
                                                                                                                                        .withSource(this.peer.getPeerId())
+                                                                                                                                       //clear the tags and web info for now.
+                                                                                                                                       .withTags(null)
+                                                                                                                                       .withWebStats(null)
                                                                                                                                        .build();
                        try {
                                cdsClient.createSolution(localSolution);
@@ -299,6 +302,8 @@ public class PeerGateway {
                                                                                                                                                return newSourceId;
                                                                                                                                        }
                                                                                                                                })
+                                                                                                                       .withTags(null)
+                                                                                                                       .withWebStats(null)
                                                                                                                        .build();
 
                        try {
@@ -456,13 +461,15 @@ public class PeerGateway {
                                                        log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve acumos artifact content", x);
                                                }
 
-                                               try {
-                                                       artifacts.putArtifactContent(localArtifact, artifactContent);
-                                                       doUpdate = true;
-                                               }
-                                               catch (ServiceException sx) {
-                                                       log.error(EELFLoggerDelegate.errorLogger,
-                                                                               "Failed to store artifact content to local repo", sx);
+                                               if (artifactContent != null) {
+                                                       try {
+                                                               artifacts.putArtifactContent(localArtifact, artifactContent);
+                                                               doUpdate = true;
+                                                       }
+                                                       catch (ServiceException sx) {
+                                                               log.error(EELFLoggerDelegate.errorLogger,
+                                                                                       "Failed to store artifact content to local repo", sx);
+                                                       }
                                                }
                                        }
 
index 4616761..3f9c931 100644 (file)
  */
 package org.acumos.federation.gateway.cds;
 
+import java.util.Set;
 import java.util.Date;
 
+import org.acumos.cds.domain.MLPTag;
+import org.acumos.cds.domain.MLPSolutionWeb;
+
 /**
  * Supplements the CDS representation of a solution with related information: revisions.
  * Allows federation to pack information passed between peers.
@@ -111,6 +115,15 @@ public class SolutionBuilder {
                return this;
        }
 
+       public SolutionBuilder withTags(Set<MLPTag> theTags) {
+               this.solution.setTags(theTags);
+               return this;
+       }
+
+       public SolutionBuilder withWebStats(MLPSolutionWeb theStats) {
+               this.solution.setWebStats(theStats);
+               return this;
+       }
 }
 
 
index 80edd49..5dad968 100644 (file)
@@ -36,9 +36,11 @@ import org.apache.http.client.HttpClient;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.core.io.Resource;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.util.Base64Utils;
 import org.springframework.web.client.HttpStatusCodeException;
+import org.springframework.web.client.HttpClientErrorException;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
@@ -274,14 +276,18 @@ public class FederationClient extends AbstractClient {
                }
                catch (Throwable t) {
                        log.error(EELFLoggerDelegate.errorLogger, uri + " unexpected failure.", t);
+                       //not very clean
+                       throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, uri + " unexpected failure: " + t);
                }
                finally {
                        log.info(EELFLoggerDelegate.debugLogger, uri + " response " + response);
                }
 
                if (response == null) {
+                       //should never get here         
                        return null;
-               } else {
+               }
+               else {
                        return response.getBody();
                }
        }
index 4d1678f..1a41f72 100644 (file)
@@ -94,7 +94,7 @@ public class ArtifactServiceImpl extends AbstractServiceImpl
                }
                catch (Exception x) {
                        log.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve artifact content for artifact " + theArtifact, x);
-                       throw new ServiceException("Failed to retrieve artifsact content for artifact " + theArtifact, x);
+                       throw new ServiceException("Failed to retrieve artifact content for artifact " + theArtifact, x);
                }
                return streamResource;
        }