Some sonar code fixes are done in this patch.
https://sonar.onap.org/issues/search#issues=AV3BntKO5bp_wwmIVCLv
https://sonar.onap.org/issues/search#issues=AV5mhwQk32hFUzlqebFJ
https://sonar.onap.org/issues/search#issues=AV3BntKc5bp_wwmIVCMJ
https://sonar.onap.org/issues/search#issues=AV3BntKi5bp_wwmIVCMK
https://sonar.onap.org/issues/search#issues=AV3BntKu5bp_wwmIVCMQ
https://sonar.onap.org/issues/search#issues=AV3BntK35bp_wwmIVCMX
https://sonar.onap.org/issues/search#issues=AV5mhwRN32hFUzlqebFQ
https://sonar.onap.org/issues/search#issues=AV3BntLG5bp_wwmIVCMc
https://sonar.onap.org/issues/search#issues=AV3BntLR5bp_wwmIVCMh
Change-Id: I3ba77adec1951fb7153ed640eb1ea0a4a3ed3e6b
Issue-ID: SO-165
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
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);
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){
}
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){
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
- return response;
+ return client.execute(post);
}
@Override
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);
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){
}
post.setEntity(input);
- HttpResponse response = client.execute(post);
- return response;
+ return client.execute(post);
}
@Override
\r
package org.openecomp.mso.apihandler.common;\r
\r
-import org.openecomp.mso.logger.MessageEnum;\r
import org.openecomp.mso.logger.MsoLogger;\r
import org.apache.http.HttpResponse;\r
import org.apache.http.client.ClientProtocolException;\r
import org.apache.http.client.methods.HttpGet;\r
import org.apache.http.client.methods.HttpPost;\r
import org.apache.http.entity.StringEntity;\r
-import org.codehaus.jackson.map.ObjectMapper;\r
-import org.codehaus.jackson.map.SerializationConfig;\r
\r
import javax.xml.bind.DatatypeConverter;\r
-import java.io.BufferedReader;\r
-import java.io.InputStreamReader;\r
import java.io.IOException;\r
\r
public class CamundaTaskClient extends RequestClient{\r
}\r
\r
post.setEntity(input);\r
- HttpResponse response = client.execute(post);\r
-\r
- return response;\r
+ return client.execute(post);\r
}\r
\r
@Override\r
}\r
\r
@Override\r
- public HttpResponse get()\r
- throws ClientProtocolException, IOException{\r
+ public HttpResponse get() throws ClientProtocolException, IOException{\r
HttpGet get = new HttpGet(url);\r
msoLogger.debug("Camunda Task url is: "+ url); \r
String encryptedCredentials;\r
}\r
}\r
\r
- HttpResponse getResponse = client.execute(get); \r
-\r
- return getResponse;\r
-}\r
- \r
- \r
-\r
+ return client.execute(get);\r
+ }\r
\r
}\r
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";
protected String fEncoding;
protected boolean fCertifiedText;
- public LSInputImpl () {
- }
-
@Override
public InputStream getByteStream () {
return fByteStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
-import java.util.Properties;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
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;
}
-
-
-
-
}
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;
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;
if(response!=null){
responseBody = response.getResponse();
}
- msoLogger.debug("response body is: " + responseBody);
+ msoLogger.debug(RESPONSE_BODY_MSG + responseBody);
if(status!=HttpStatus.SC_ACCEPTED){
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){
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){
**/
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));
}
}
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;
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 (""", "\"");
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 ();
}
}