package org.onap.so.asdc.client;
+ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
- private IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact,
+ protected IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact,
String distributionId) throws ASDCDownloadException {
LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL ()
+ artifact.getArtifactUUID ()
+ ")");
+ String filePath = System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactVersion() + "/" + artifact.getArtifactName();
+ // make parent directory
+ File file = new File(filePath);
+ File fileParent = file.getParentFile();
+ if (!fileParent.exists()) {
+ fileParent.mkdirs();
+ }
+
byte[] payloadBytes = resultArtifact.getArtifactPayload();
- try (FileOutputStream outFile = new FileOutputStream(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName())) {
+ try (FileOutputStream outFile = new FileOutputStream(filePath)) {
LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName());
outFile.write(payloadBytes, 0, payloadBytes.length);
outFile.close();
}
- private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
+ protected void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) {
for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) {
}
}
- private void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
+ protected void sendCsarDeployNotification(INotificationData iNotif, VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
}
}
- private void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
+ protected void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC");
try {
DOWNLOAD, DEPLOY
}
- private void sendASDCNotification (NotificationType notificationType,
+ protected void sendASDCNotification (NotificationType notificationType,
String artifactURL,
String consumerID,
String distributionID,
LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent notification to ASDC", "ASDC", action, null);
}
- private void sendFinalDistributionStatus (
+ protected void sendFinalDistributionStatus (
String distributionID,
DistributionStatusEnum status,
String errorReason) {
}
}
- private void processResourceNotification (INotificationData iNotif) {
+ protected void processResourceNotification (INotificationData iNotif) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
VfResourceStructure resourceStructure = null;
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
"Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e);
}
}
- private void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
+ protected void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
}
private static final String UNKNOWN="Unknown";
-
+
/**
* @return the address of the ASDC we are connected to.
*/
public class ResourceRequestBuilder {
- public static String CUSTOMIZATION_UUID = "customizationUUID";
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
- public static String SERVICE_URL_TOSCA_CSAR = "/v3/serviceToscaCsar?serviceModelUuid=";
+ private static String SERVICE_URL_TOSCA_CSAR = "/v3/serviceToscaCsar";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ResourceRequestBuilder.class);
private static String getCsarFromUuid(String uuid) throws Exception {
String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
- HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint + SERVICE_URL_TOSCA_CSAR + uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
+ HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
Response response = client.get();
String value = response.readEntity(String.class);
HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
- File csarFile = new File(System.getProperty("mso.config.path") + "ASDC/" + map.get("name"));
+ String filePath = System.getProperty("mso.config.path") + "ASDC/" + map.get("version") + "/" + map.get("name");
+
+ File csarFile = new File(filePath);
if(!csarFile.exists()) {
throw new Exception("csar file does not exist.");