diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso')
9 files changed, 38 insertions, 59 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java index c8889beb33..b9c0725766 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java @@ -36,6 +36,7 @@ import java.io.IOException; public class CamundaClient extends RequestClient{ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + private static final String CAMUNDA_URL_MESAGE = "Camunda url is: "; public CamundaClient() { super(CommonConstants.CAMUNDA); @@ -47,13 +48,13 @@ public class CamundaClient extends RequestClient{ String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws ClientProtocolException, IOException{ HttpPost post = new HttpPost(url); - msoLogger.debug("Camunda url is: "+ url); + msoLogger.debug(CAMUNDA_URL_MESAGE + url); String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - String encryptedCredentials = null; + String encryptedCredentials; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); if(encryptedCredentials != null){ @@ -65,22 +66,18 @@ public class CamundaClient extends RequestClient{ } post.setEntity(input); - HttpResponse response = client.execute(post); - - return response; + return client.execute(post); } @Override - public HttpResponse post(String jsonReq) - throws ClientProtocolException, IOException{ + public HttpResponse post(String jsonReq) throws ClientProtocolException, IOException{ HttpPost post = new HttpPost(url); - msoLogger.debug("Camunda url is: "+ url); - //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); + msoLogger.debug(CAMUNDA_URL_MESAGE + url); StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - String encryptedCredentials = null; + String encryptedCredentials; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); if(encryptedCredentials != null){ @@ -92,9 +89,8 @@ public class CamundaClient extends RequestClient{ } post.setEntity(input); - HttpResponse response = client.execute(post); - return response; + return client.execute(post); } @Override @@ -105,7 +101,7 @@ public class CamundaClient extends RequestClient{ String requestDetails) throws ClientProtocolException, IOException{ HttpPost post = new HttpPost(url); - msoLogger.debug("Camunda url is: "+ url); + msoLogger.debug(CAMUNDA_URL_MESAGE + url); String jsonReq = wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, serviceType, vnfType, vfModuleType, networkType, requestDetails); @@ -113,7 +109,7 @@ public class CamundaClient extends RequestClient{ StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - String encryptedCredentials = null; + String encryptedCredentials; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); if(encryptedCredentials != null){ @@ -125,9 +121,8 @@ public class CamundaClient extends RequestClient{ } post.setEntity(input); - HttpResponse response = client.execute(post); - return response; + return client.execute(post); } @Override diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java index b4e7b7e068..64193cf6c4 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java @@ -20,19 +20,14 @@ package org.openecomp.mso.apihandler.common;
-import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
import javax.xml.bind.DatatypeConverter;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
import java.io.IOException;
public class CamundaTaskClient extends RequestClient{
@@ -63,9 +58,7 @@ public class CamundaTaskClient extends RequestClient{ }
post.setEntity(input);
- HttpResponse response = client.execute(post);
-
- return response;
+ return client.execute(post);
}
@Override
@@ -88,8 +81,7 @@ public class CamundaTaskClient extends RequestClient{ }
@Override
- public HttpResponse get()
- throws ClientProtocolException, IOException{
+ public HttpResponse get() throws ClientProtocolException, IOException{
HttpGet get = new HttpGet(url);
msoLogger.debug("Camunda Task url is: "+ url);
String encryptedCredentials;
@@ -103,12 +95,7 @@ public class CamundaTaskClient extends RequestClient{ }
}
- HttpResponse getResponse = client.execute(get);
-
- return getResponse;
-}
-
-
-
+ return client.execute(get);
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java index 72f72c2939..2cafef3253 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java @@ -22,6 +22,9 @@ package org.openecomp.mso.apihandler.common; public final class ErrorNumbers { + private ErrorNumbers() { + } + public static final String REQUEST_FAILED_SCHEMA_VALIDATION = "1000"; public static final String RECIPE_DOES_NOT_EXIST = "1010"; public static final String VFMODULE_TYPE_DOES_NOT_EXIST = "1011"; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java index 42d77f5f00..b39b5347ee 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java @@ -37,9 +37,6 @@ public class LSInputImpl implements LSInput { protected String fEncoding; protected boolean fCertifiedText; - public LSInputImpl () { - } - @Override public InputStream getByteStream () { return fByteStream; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java index 1324e12fbc..addf4e11a5 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java @@ -22,7 +22,6 @@ package org.openecomp.mso.apihandler.common; import java.io.IOException; import java.security.GeneralSecurityException; -import java.util.Properties; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; @@ -83,16 +82,11 @@ public abstract class RequestClient { protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) { try { - String result = CryptoUtils.decrypt(prop, encryptionKey); - return result; + return CryptoUtils.decrypt(prop, encryptionKey); } catch (GeneralSecurityException e) { msoLogger.debug("Security exception", e); } return defaultValue; } - - - - } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java index 773c5b0a96..8f919861dc 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java @@ -21,14 +21,15 @@ package org.openecomp.mso.apihandler.common; -import java.util.Properties; - import org.apache.http.impl.client.DefaultHttpClient; import org.openecomp.mso.properties.MsoJavaProperties; public class RequestClientFactory { - + + private RequestClientFactory() { + } + //based on URI, returns BPEL, CamundaTask or Camunda client public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{ RequestClient retClient; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java index 6722a930ae..4e7cf4cddd 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java @@ -41,6 +41,7 @@ public class ResponseHandler { private HttpResponse httpResponse; private int type; private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + private static final String RESPONSE_BODY_MSG = "response body is: "; public ResponseHandler(HttpResponse httpResponse, int type) { this.httpResponse = httpResponse; @@ -84,7 +85,7 @@ public class ResponseHandler { if(response!=null){ responseBody = response.getResponse(); } - msoLogger.debug("response body is: " + responseBody); + msoLogger.debug(RESPONSE_BODY_MSG + responseBody); if(status!=HttpStatus.SC_ACCEPTED){ @@ -99,7 +100,7 @@ public class ResponseHandler { try { if (bpelEntity!=null) { responseBody = EntityUtils.toString(bpelEntity); - msoLogger.debug("response body is: " + responseBody); + msoLogger.debug(RESPONSE_BODY_MSG + responseBody); } if(status!=HttpStatus.SC_ACCEPTED){ @@ -118,7 +119,7 @@ public class ResponseHandler { try { if (camundataskEntity!=null) { responseBody = EntityUtils.toString(camundataskEntity); - msoLogger.debug("response body is: " + responseBody); + msoLogger.debug(RESPONSE_BODY_MSG + responseBody); } if(status!=HttpStatus.SC_NO_CONTENT && status != HttpStatus.SC_ACCEPTED){ diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java index bf2088ed45..73bf020c21 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java @@ -31,17 +31,18 @@ public class ValidationException extends Exception { **/ private static final long serialVersionUID = 1L; - private static final String validationFailMessage = "No valid $ELEMENT is specified"; - private static final String invalidElementMessage = "$ELEMENT is not valid in the $VERSION version"; + private static final String VALIDATION_FAIL_MESSAGE = "No valid $ELEMENT is specified"; + private static final String INVALID_ELEMENT_MESSAGE = "$ELEMENT is not valid in the $VERSION version"; + private static final String ELEMENT_MESSAGE = "\\$ELEMENT"; public ValidationException (String msg) { - super (validationFailMessage.replaceAll ("\\$ELEMENT", msg)); + super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg)); } public ValidationException (String msg, Exception cause) { - super (validationFailMessage.replaceAll ("\\$ELEMENT", msg), cause); + super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg), cause); } public ValidationException(String msg, String version) { - super(invalidElementMessage.replaceAll("\\$ELEMENT", msg).replaceAll("\\$VERSION", version)); + super(INVALID_ELEMENT_MESSAGE.replaceAll(ELEMENT_MESSAGE, msg).replaceAll("\\$VERSION", version)); } } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java index b498259eed..ebb1dd28cf 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java @@ -40,14 +40,14 @@ import org.openecomp.mso.logger.MsoLogger; public class XMLValidator { - private static String XSDS_PATH; + private static String xsdsPath; static { String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); if (prefixMsoPropertiesPath == null) { prefixMsoPropertiesPath = ""; } - XSDS_PATH = prefixMsoPropertiesPath + "xsds/"; + xsdsPath = prefixMsoPropertiesPath + "xsds/"; } private String stringXsd; @@ -60,12 +60,12 @@ public class XMLValidator { public XMLValidator (String xsdFile) { - try (FileInputStream xsdStream = new FileInputStream (XSDS_PATH + xsdFile)) { + try (FileInputStream xsdStream = new FileInputStream (xsdsPath + xsdFile)) { stringXsd = IOUtils.toString (xsdStream); factory = SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI); - factory.setResourceResolver (new PathResourceResolver (XSDS_PATH)); + factory.setResourceResolver (new PathResourceResolver (xsdsPath)); factory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); String quotedXsd = stringXsd.replaceAll (""", "\""); @@ -73,7 +73,7 @@ public class XMLValidator { schema = factory.newSchema (src); } catch (IOException | SAXException e) { - msoLogger.debug ("Cannot open file " + XSDS_PATH + xsdFile, e); + msoLogger.debug ("Cannot open file " + xsdsPath + xsdFile, e); errorMsg = "ErrorDetails: xsd file " + xsdFile + "could not be opened - " + e.getMessage (); } } |