X-Git-Url: https://gerrit.onap.org/r/gitweb?p=multicloud%2Fframework.git;a=blobdiff_plain;f=artifactbroker%2Fplugins%2Freception-plugins%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fdistribution%2Freception%2Fhandling%2Fsdc%2FSdcReceptionHandler.java;h=37fb314a41ae1dd54d238f94b3abf5d12e42d84a;hp=998527bdbce408a61a0cec177da97680a79784c0;hb=bda0a8701a6113e42ab8f0cbb14aa3bc69c8ac5d;hpb=41373a9619308bdbab6a31c02fe3d54e91ac6ee3 diff --git a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java index 998527b..37fb314 100644 --- a/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java +++ b/artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java @@ -27,8 +27,9 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Map; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; @@ -220,20 +221,20 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo DistributionStatisticsManager.updateTotalDistributionCount(); List relevantArtifactTypes = sdcConfig.getRelevantArtifactTypes(); Path path = Paths.get("/data"); - List vfModuleModels = null; - Map artifactMap = null;//key is UUID, value is artifact for shared folder + ArrayList vfModuleModels = new ArrayList<>(); + HashMap artifactMap = new HashMap<>();//key is UUID, value is artifact for shared folder String vfArtifactData = null; for (final IArtifactInfo artifact : resource.getArtifacts()) { artifactMap.put(artifact.getArtifactUUID(),artifact); - //extract the artifactlist and write them into MongoDB + //extract the artifactlist and write them into MongoDB if (artifact.getArtifactType().equals("VF_MODULES_METADATA")) { try { final IDistributionClientDownloadResult resultArtifact = downloadTheArtifact(artifact,notificationData); vfArtifactData = new String(resultArtifact.getArtifactPayload()); - vfModuleModels= GsonUtil.parseJsonArrayWithGson(vfArtifactData,VfModuleModel.class); + vfModuleModels = GsonUtil.parseJsonArrayWithGson(vfArtifactData,VfModuleModel.class); } catch (final ArtifactDownloadException exp) { LOGGER.error("Failed to process csar service artifacts ", exp); artifactsProcessedSuccessfully = false; @@ -255,10 +256,12 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo Path temp = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID()); path = Files.createDirectory(temp);//create UUID path //store the value to vfmodule-meta.json - String filePath = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID(),"vfmodule-meta.json").toString(); + String filePath = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID(), + "vfmodule-meta.json").toString(); writeFileByFileWriter(filePath, vfArtifactData); //store the service level info to serivce-meta.json - filePath = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID(),"service-meta.json").toString(); + filePath = Paths.get("/data",vfModule.getVfModuleModelCustomizationUUID(), + "service-meta.json").toString(); writeFileByFileWriter(filePath, notificationData.toString()); } catch (final IOException exp) { LOGGER.error("Failed to create directory artifact file", exp); @@ -335,9 +338,13 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo private static void writeFileByFileWriter(String filePath, String content) throws IOException { File file = new File(filePath); synchronized (file) { - FileWriter fw = new FileWriter(filePath); - fw.write(content); - fw.close(); + try { + FileWriter fw = new FileWriter(filePath); + fw.write(content); + fw.close(); + } catch (final IOException exp) { + LOGGER.error("Failed to write File by File Writer ", exp); + } } } /**