aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java36
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java34
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java5
4 files changed, 38 insertions, 42 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java b/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
index 059cc2b2..8781fc34 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeHttpConnectionManager.java
@@ -19,7 +19,7 @@
* ============LICENSE_END============================================
* Modifications copyright (c) 2018 Nokia
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
@@ -42,20 +42,17 @@ import org.onap.clamp.clds.util.LoggingUtils;
import org.springframework.stereotype.Component;
/**
- *
+ *
* This class manages the HTTP and HTTPS connections to DCAE.
*
*/
@Component
public class DcaeHttpConnectionManager {
- protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(DcaeHttpConnectionManager.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private static final String DCAE_REQUEST_FAILED_LOG = "Request Failed - response payload=";
-
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeHttpConnectionManager.class);
+ protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private static final String DCAE_REQUEST_FAILED_LOG = "Request Failed - response payload=";
- private String doHttpsQuery(URL url, String requestMethod, String payload, String contentType)
- throws IOException {
+ private String doHttpsQuery(URL url, String requestMethod, String payload, String contentType) throws IOException {
logger.info("Using HTTPS URL to contact DCAE:" + url.toString());
HttpsURLConnection secureConnection = (HttpsURLConnection) url.openConnection();
secureConnection.setRequestMethod(requestMethod);
@@ -87,12 +84,11 @@ public class DcaeHttpConnectionManager {
}
}
- private String doHttpQuery(URL url, String requestMethod, String payload, String contentType)
- throws IOException {
- LoggingUtils utils = new LoggingUtils (logger);
+ private String doHttpQuery(URL url, String requestMethod, String payload, String contentType) throws IOException {
+ LoggingUtils utils = new LoggingUtils(logger);
logger.info("Using HTTP URL to contact DCAE:" + url);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection = utils.invoke(connection,"DCAE", requestMethod);
+ connection = utils.invoke(connection, "DCAE", requestMethod);
connection.setRequestMethod(requestMethod);
connection.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());
if (payload != null && contentType != null) {
@@ -126,21 +122,21 @@ public class DcaeHttpConnectionManager {
/**
* This method does a HTTP/HTTPS query to DCAE with parameters specified.
- *
+ *
* @param url
- * The string HTTP or HTTPS that mustr be used to connect
+ * The string HTTP or HTTPS that mustr be used to connect
* @param requestMethod
- * The Request Method (PUT, POST, GET, DELETE, etc ...)
+ * The Request Method (PUT, POST, GET, DELETE, etc ...)
* @param payload
- * The payload if any, in that case an ouputstream is opened
+ * The payload if any, in that case an ouputstream is opened
* @param contentType
- * The "application/json or application/xml, or whatever"
+ * The "application/json or application/xml, or whatever"
* @return The payload of the answer
* @throws IOException
- * In case of issue with the streams
+ * In case of issue with the streams
*/
public String doDcaeHttpQuery(String url, String requestMethod, String payload, String contentType)
- throws IOException {
+ throws IOException {
URL urlObj = new URL(url);
if (url.contains("https://")) { // Support for HTTPS
return doHttpsQuery(urlObj, requestMethod, payload, contentType);
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java
index d1beb956..8af1286c 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java
@@ -5,32 +5,30 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.config;
import com.google.gson.JsonParseException;
-import com.google.gson.reflect.TypeToken;
+
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
-import java.util.List;
import org.apache.commons.io.IOUtils;
import org.onap.clamp.clds.exception.CldsUsersException;
import org.onap.clamp.clds.service.CldsUser;
@@ -39,13 +37,13 @@ import org.onap.clamp.clds.util.JsonUtils;
public class CldsUserJsonDecoder {
/**
- * This method decodes the JSON file provided to a CldsUser Array. The
- * stream is closed after this call, this is not possible to reuse it.
- *
+ * This method decodes the JSON file provided to a CldsUser Array. The stream is
+ * closed after this call, this is not possible to reuse it.
+ *
* @param cldsUsersFile
- * The inputStream containing the users json file
- * @return CldsUser[] Array containing a list of the user defined in the
- * JSON file
+ * The inputStream containing the users json file
+ * @return CldsUser[] Array containing a list of the user defined in the JSON
+ * file
*/
public static CldsUser[] decodeJson(InputStream cldsUsersFile) {
try {
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
index b60f0728..b65a994a 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -29,6 +29,7 @@ import com.att.eelf.configuration.EELFManager;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -135,7 +136,7 @@ public class CsarHandler {
blueprintArtifact
.setBlueprintInvariantServiceUuid(this.getSdcNotification().getServiceInvariantUUID());
try (InputStream stream = zipFile.getInputStream(entry)) {
- blueprintArtifact.setDcaeBlueprint(IOUtils.toString(stream));
+ blueprintArtifact.setDcaeBlueprint(IOUtils.toString(stream, StandardCharsets.UTF_8));
}
blueprintArtifact.setResourceAttached(searchForResourceByInstanceName(entry.getName().substring(
entry.getName().indexOf(RESOURCE_INSTANCE_NAME_PREFIX) + RESOURCE_INSTANCE_NAME_PREFIX.length(),
@@ -175,7 +176,7 @@ public class CsarHandler {
try (ZipFile zipFile = new ZipFile(csarFilePath)) {
ZipEntry entry = zipFile.getEntry(POLICY_DEFINITION_NAME_SUFFIX);
if (entry != null) {
- result = IOUtils.toString(zipFile.getInputStream(entry));
+ result = IOUtils.toString(zipFile.getInputStream(entry), StandardCharsets.UTF_8);
} else {
logger.info("Policy model not found inside the CSAR file: " + csarFilePath);
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index a4ae14d0..6dc41834 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -28,6 +28,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -269,8 +270,8 @@ public class CsarInstallerImpl implements CsarInstaller {
CldsTemplate template = new CldsTemplate();
template.setBpmnId("Sdc-Generated");
- template
- .setBpmnText(IOUtils.toString(appContext.getResource(configFiles.getBpmnXmlFilePath()).getInputStream()));
+ template.setBpmnText(IOUtils.toString(appContext.getResource(configFiles.getBpmnXmlFilePath()).getInputStream(),
+ StandardCharsets.UTF_8));
template.setPropText(
"{\"global\":[{\"name\":\"service\",\"value\":[\"" + blueprintArtifact.getDcaeBlueprint() + "\"]}]}");
template