}
//Verify if MLPSolution is not same
- if(mlpSolution != null && !isSameMLPSolution(acumosSolution, mlpSolution)) {
+ if(mlpSolution != null &&
+ isSameMLPSolution(acumosSolution, mlpSolution)) {
//if already exists locally then loop through next
mlpSolution = updateMLPSolution(acumosSolution, mlpSolution, cdsClient);
- } else {
+ }
+ else {
mlpSolution = createMLPSolution(acumosSolution, cdsClient);
}
- updateMLPSolutionArtifacts(mlpSolution, cdsClient);
- //ONAP.this.asdc.checkinResource(UUID.fromString(sdcAsset.getString("artifactUUID")), ONAP.this.asdcOperator, "solution imported " + " the acumos revision number ");
+
+ if (mlpSolution != null) {
+ updateMLPSolutionArtifacts(mlpSolution, cdsClient);
+ }
}
catch (Exception x) {
logger.warn(EELFLoggerDelegate.debugLogger, "Mapping of acumos solution failed for: " + acumosSolution + ": " + x);
}
private MLPSolution updateMLPSolution(MLPSolution peerMLPSolution, MLPSolution localMLPSolution, ICommonDataServiceRestClient cdsClient) {
- logger.info(EELFLoggerDelegate.debugLogger, "Updating Local MLP Solutino for peer solution " + peerMLPSolution);
+ logger.info(EELFLoggerDelegate.debugLogger, "Updating Local MLP Solution for peer solution " + peerMLPSolution);
localMLPSolution.setSolutionId(peerMLPSolution.getSolutionId());
localMLPSolution.setName(peerMLPSolution.getName());
localMLPSolution.setDescription(peerMLPSolution.getDescription());
MLPSolutionRevision mlpSolutionRevision = cdsClient.getSolutionRevision(theSolution.getSolutionId(), acumosRevisions.get(acumosRevisions.size()-1).getRevisionId());
if(mlpSolutionRevision == null && !Utils.isEmptyList(acumosArtifacts)) {
- //If SolutinoRevision is null, we need to create a Solution Revision in Local Acumos
+ //If SolutionRevision is null, we need to create a Solution Revision in Local Acumos
mlpSolutionRevision = createMLPSolutionRevision(acumosRevisions.get(acumosRevisions.size()-1), cdsClient);
}
Resource artifactContent = null;
try {
artifactContent = fedClient.downloadArtifact(artifact.getArtifactId());
- logger.warn(EELFLoggerDelegate.debugLogger, "Received artifact content: " + new BufferedReader(new InputStreamReader(artifactContent.getInputStream())).lines().collect(Collectors.joining("\n")));
+ //logger.warn(EELFLoggerDelegate.debugLogger, "Received artifact content: " + new BufferedReader(new InputStreamReader(artifactContent.getInputStream())).lines().collect(Collectors.joining("\n")));
}
catch (Exception x) {
logger.warn(EELFLoggerDelegate.debugLogger, "Failed to retrieve acumos artifact content", x);
}
+
+ if (artifactContent != null) {
+ try {
+ PeerGateway.this.clients.getNexusClient().uploadArtifact("", "", "", "", 0, artifactContent.getInputStream());
+ }
+ catch (Exception x) {
+ logger.warn(EELFLoggerDelegate.debugLogger, "Failed to push artifact content to local Nexus repo", x);
+ }
+ }
+
+ //update artifact with local repo
+ //updateMLPArtifact(artifact, mlpArtifact, cdsClient);
}
}
import org.springframework.context.annotation.Conditional;
import org.acumos.nexus.client.NexusArtifactClient;
-import org.acumos.nexus.client.RepositoryLocation;
import org.acumos.cds.AccessTypeCode;
import org.acumos.cds.ValidationStatusCode;
ICommonDataServiceRestClient cdsClient = getClient();
MLPArtifact mlpArtifact = cdsClient.getArtifact(theArtifactId);
- String path = Utils.getTempFolderPath(mlpArtifact.getName(), mlpArtifact.getVersion(), env.getProperty("nexus.tempFolder", ""));
-
- RepositoryLocation repositoryLocation = new RepositoryLocation();
- repositoryLocation.setId("1");
- repositoryLocation.setUrl(env.getProperty("nexus.url"));
- repositoryLocation.setUsername(env.getProperty("nexus.username"));
- repositoryLocation.setPassword(env.getProperty("nexus.password"));
- repositoryLocation.setProxy(env.getProperty("nexus.proxy"));
-
- // if you need a proxy to access the Nexus
- NexusArtifactClient artifactClient = new NexusArtifactClient(repositoryLocation);
+ NexusArtifactClient artifactClient = this.clients.getNexusClient();
byteArrayOutputStream = artifactClient.getArtifact(mlpArtifact.getUri());
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
if(byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
- Utils.deletetTempFiles(path);
} catch (Exception e) {
log.error(EELFLoggerDelegate.errorLogger, "getSolutionRevisionArtifactiContent", e);
import org.acumos.cds.client.CommonDataServiceRestClientImpl;
import org.acumos.cds.client.ICommonDataServiceRestClient;
+import org.acumos.nexus.client.NexusArtifactClient;
+import org.acumos.nexus.client.RepositoryLocation;
+
+
/**
* Unique entry point for building clients: peer access clients, cds clients
*/
thePeerURI,
(HttpClient)this.appCtx.getBean("federationClient"));
}
+
+ public NexusArtifactClient getNexusClient() {
+
+ RepositoryLocation repositoryLocation = new RepositoryLocation();
+ repositoryLocation.setId("1");
+ repositoryLocation.setUrl(this.env.getProperty("nexus.url"));
+ repositoryLocation.setUsername(this.env.getProperty("nexus.username"));
+ repositoryLocation.setPassword(this.env.getProperty("nexus.password"));
+ repositoryLocation.setProxy(this.env.getProperty("nexus.proxy"));
+
+ // if you need a proxy to access the Nexus
+ return new NexusArtifactClient(repositoryLocation);
+ }
}