diff options
Diffstat (limited to 'src/main')
11 files changed, 25 insertions, 29 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java index 88735d4..adc58e5 100644 --- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java +++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java @@ -25,6 +25,7 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; @@ -123,17 +124,13 @@ public class ModelLoaderConfig implements IConfiguration { // Get list of artifact types String types = get(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES); if (types != null) { - for (String artType : types.split(",")) { - artifactTypes.add(artType); - } + artifactTypes.addAll(Arrays.asList(types.split(","))); } // Get list of message bus addresses String addresses = get(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES); if (addresses != null) { - for (String addr : addresses.split(",")) { - msgBusAddrs.add(addr); - } + msgBusAddrs.addAll(Arrays.asList(addresses.split(","))); } } @@ -148,7 +145,7 @@ public class ModelLoaderConfig implements IConfiguration { @Override public boolean activateServerTLSAuth() { String value = get(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH); - return value != null && Boolean.parseBoolean(value); + return Boolean.parseBoolean(value); } @Override diff --git a/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java index b1fed03..50abdd0 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java +++ b/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java @@ -28,7 +28,7 @@ public abstract class ArtifactHandler { protected ModelLoaderConfig config;
- public ArtifactHandler(ModelLoaderConfig config) {
+ protected ArtifactHandler(ModelLoaderConfig config) {
this.config = config;
}
diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java index ee70939..7d5cafb 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java @@ -45,7 +45,7 @@ public abstract class AbstractModelArtifact extends Artifact implements IModelAr private String modelNamespaceVersion; private Set<String> referencedModelIds = new HashSet<>(); - public AbstractModelArtifact(ArtifactType type) { + protected AbstractModelArtifact(ArtifactType type) { super(type); } diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java index 7c9b4c2..87823a6 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java @@ -286,6 +286,7 @@ public class ModelArtifact extends AbstractModelArtifact { private String nodeToString(Node node) throws TransformerException { StringWriter sw = new StringWriter(); TransformerFactory transFact = TransformerFactory.newInstance(); + transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); transFact.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); Transformer t = transFact.newTransformer(); t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); diff --git a/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java b/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java index 5682774..0e27d57 100644 --- a/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java +++ b/src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java @@ -49,7 +49,7 @@ public class VnfCatalogExtractor { private static final Logger logger = LoggerFactory.getInstance().getLogger(VnfCatalogExtractor.class.getName()); private static final Pattern VNFCFILE_EXTENSION_REGEX = - Pattern.compile("(?i)artifacts(\\\\|\\/)deployment(\\\\|\\/)vnf_catalog(\\\\|\\/).*\\.xml$"); + Pattern.compile("(?i)artifacts([\\\\/])deployment([\\\\/])vnf_catalog([\\\\/]).*\\.xml$"); /** * This method is responsible for filtering the contents of the supplied archive and returning a collection of diff --git a/src/main/java/org/onap/aai/modelloader/gizmo/GizmoEdgeOperation.java b/src/main/java/org/onap/aai/modelloader/gizmo/GizmoEdgeOperation.java index 68384c2..a932d02 100644 --- a/src/main/java/org/onap/aai/modelloader/gizmo/GizmoEdgeOperation.java +++ b/src/main/java/org/onap/aai/modelloader/gizmo/GizmoEdgeOperation.java @@ -40,8 +40,7 @@ public class GizmoEdgeOperation { public JsonElement toJsonElement() { JsonObject opObj = new JsonObject(); - JsonParser parser = new JsonParser(); - JsonObject edgeObj = parser.parse(edge.toJson()).getAsJsonObject(); + JsonObject edgeObj = JsonParser.parseString(edge.toJson()).getAsJsonObject(); opObj.addProperty(GizmoBulkPayload.OP_KEY, operation); opObj.add(internalId, edgeObj); diff --git a/src/main/java/org/onap/aai/modelloader/gizmo/GizmoVertexOperation.java b/src/main/java/org/onap/aai/modelloader/gizmo/GizmoVertexOperation.java index 79e8869..6a6768d 100644 --- a/src/main/java/org/onap/aai/modelloader/gizmo/GizmoVertexOperation.java +++ b/src/main/java/org/onap/aai/modelloader/gizmo/GizmoVertexOperation.java @@ -40,8 +40,7 @@ public class GizmoVertexOperation { public JsonElement toJsonElement() { JsonObject opObj = new JsonObject(); - JsonParser parser = new JsonParser(); - JsonObject vertexObj = parser.parse(vertex.toJson()).getAsJsonObject(); + JsonObject vertexObj = JsonParser.parseString(vertex.toJson()).getAsJsonObject(); opObj.addProperty(GizmoBulkPayload.OP_KEY, getOperation()); opObj.add(internalId, vertexObj); diff --git a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java index 7ad552b..6e6ff13 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java +++ b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java @@ -21,6 +21,7 @@ package org.onap.aai.modelloader.notification; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -50,8 +51,8 @@ public class NotificationPublisher { public NotificationPublisher() { Properties configProperties = new Properties(); - try { - configProperties.load(Files.newInputStream(ModelLoaderConfig.propertiesFile())); + try (InputStream configInputStream = Files.newInputStream(ModelLoaderConfig.propertiesFile())) { + configProperties.load(configInputStream); } catch (IOException e) { String errorMsg = "Failed to load configuration: " + e.getMessage(); logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, e, errorMsg); diff --git a/src/main/java/org/onap/aai/modelloader/service/EchoService.java b/src/main/java/org/onap/aai/modelloader/service/EchoService.java index 9600fc4..040e894 100644 --- a/src/main/java/org/onap/aai/modelloader/service/EchoService.java +++ b/src/main/java/org/onap/aai/modelloader/service/EchoService.java @@ -21,16 +21,16 @@ package org.onap.aai.modelloader.service; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/services/model-loader/v1/echo-service") public class EchoService { - @RequestMapping(value = "/echo/{input}", method = RequestMethod.GET) + @GetMapping(value = "/echo/{input}") public ResponseEntity<String> echo(@PathVariable String input) { return ResponseEntity.ok(input); } diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java index e65e02c..4c7b182 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java @@ -22,24 +22,22 @@ package org.onap.aai.modelloader.service; import java.io.IOException; import javax.ws.rs.core.Response; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.ResponseBody; public interface ModelLoaderInterface { - @RequestMapping(value = "/loadModel/{modelid}", // - method = RequestMethod.GET, produces = "application/json") + @GetMapping(value = "/loadModel/{modelid}", produces = "application/json") @ResponseBody Response loadModel(String modelid); - @RequestMapping(value = "/saveModel/{modelid}/{modelname}", // - method = RequestMethod.PUT, produces = "application/json") + @PutMapping(value = "/saveModel/{modelid}/{modelname}", produces = "application/json") @ResponseBody Response saveModel(String modelid, String modelname); - @RequestMapping(value = "/ingestModel/{modelName}/{modelVersion}", // - method = RequestMethod.POST, produces = "application/json") + @PostMapping(value = "/ingestModel/{modelName}/{modelVersion}", produces = "application/json") @ResponseBody Response ingestModel(String modelid, String modelVersion, String payload) throws IOException; } diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java index c338e5b..22f7671 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java @@ -21,6 +21,7 @@ package org.onap.aai.modelloader.service; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -80,12 +81,12 @@ public class ModelLoaderService implements ModelLoaderInterface { logger.info(ModelLoaderMsgs.LOADING_CONFIGURATION); ModelLoaderConfig.setConfigHome(configDir); Properties configProperties = new Properties(); - try { - configProperties.load(Files.newInputStream(Paths.get(configDir, "model-loader.properties"))); + try (InputStream configInputStream = Files.newInputStream(Paths.get(configDir, "model-loader.properties"))) { + configProperties.load(configInputStream); config = new ModelLoaderConfig(configProperties); // Set the truststore for SDC Client to connect to Dmaap central bus if applicable (as in case of TI) - if (config.isUseHttpsWithDmaap()) { + if (Boolean.TRUE.equals(config.isUseHttpsWithDmaap())) { String trustStorePath = config.getKeyStorePath(); String trustStorePassword = config.getKeyStorePassword(); if (trustStorePath != null && Paths.get(trustStorePath).toFile().isFile() && trustStorePassword != null |