summaryrefslogtreecommitdiffstats
path: root/artifactbroker/plugins/reception-plugins
diff options
context:
space:
mode:
authorliboNet <libo.zhu@intel.com>2019-04-11 12:23:56 +0800
committerliboNet <libo.zhu@intel.com>2019-04-11 12:30:13 +0800
commitbda0a8701a6113e42ab8f0cbb14aa3bc69c8ac5d (patch)
tree2fad5305d907d2ee0f630be1519721e8409bfed5 /artifactbroker/plugins/reception-plugins
parentacbf18f98440e52e55cfe85ff75845081b7c9165 (diff)
Fix sonar issue of artifactbroker
add try and catch in the filewriter improve code style Change-Id: I6352815c75726969325aea4474ffca303846b90f Issue-ID: MULTICLOUD-569 Signed-off-by: liboNet <libo.zhu@intel.com>
Diffstat (limited to 'artifactbroker/plugins/reception-plugins')
-rw-r--r--artifactbroker/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java22
1 files changed, 14 insertions, 8 deletions
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 6b8f3b6..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
@@ -28,8 +28,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.List;
import java.util.HashMap;
+import java.util.List;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -228,13 +228,13 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
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;
@@ -256,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);
@@ -336,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);
+ }
}
}
/**