diff options
Diffstat (limited to 'vid-app-common/src/main/java/org')
8 files changed, 42 insertions, 22 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java index a82dfab75..8d5fbbdbb 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java @@ -33,6 +33,7 @@ import org.onap.vid.mso.MsoProperties; import org.onap.vid.mso.rest.MsoRestClientNew; import org.onap.vid.services.CloudOwnerService; import org.onap.vid.services.CloudOwnerServiceImpl; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.togglz.core.manager.FeatureManager; @@ -47,10 +48,10 @@ public class MsoConfig { } @Bean - public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){ + public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemPropertiesWrapper){ // Satisfy both interfaces -- MsoInterface and RestMsoImplementation return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty( - MsoProperties.MSO_SERVER_URL),httpsAuthClient); + MsoProperties.MSO_SERVER_URL),httpsAuthClient, systemPropertiesWrapper); } diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java index 543aa9432..e00c2d7a5 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java @@ -42,11 +42,18 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.togglz.core.manager.FeatureManager; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + import javax.servlet.ServletContext; import java.io.File; import java.io.IOException; +@EnableSwagger2 @Configuration public class WebConfig { @@ -193,4 +200,12 @@ public class WebConfig { } + @Bean + public Docket api(){ + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.onap.vid.controller.open")) + .paths(PathSelectors.any()) + .build(); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/HealthCheckController.java index 04d5babcc..92e1a1802 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/HealthCheckController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/HealthCheckController.java @@ -18,11 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import org.onap.portalsdk.core.controller.UnRestrictedBaseController; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; +import org.onap.vid.controller.HealthStatus; import org.onap.vid.dao.FnAppDoaImpl; import org.onap.vid.model.GitRepositoryState; import org.springframework.beans.factory.annotation.Autowired; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/MaintenanceController.java index dfba4e31a..d1004401a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/MaintenanceController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/MaintenanceController.java @@ -1,4 +1,4 @@ -package org.onap.vid.controller; +package org.onap.vid.controller.open; /*- * ============LICENSE_START======================================================= diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/RoleGeneratorController.java index 107142d7f..7b57df2c7 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/RoleGeneratorController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/RoleGeneratorController.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import static org.springframework.http.HttpStatus.OK; diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java b/vid-app-common/src/main/java/org/onap/vid/controller/open/VersionController.java index aa15f0fa3..0a4d6f5ac 100644 --- a/vid-app-common/src/main/java/org/onap/vid/controller/VersionController.java +++ b/vid-app-common/src/main/java/org/onap/vid/controller/open/VersionController.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.vid.controller; +package org.onap.vid.controller.open; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java index e14ac0e11..17af75200 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java @@ -26,7 +26,6 @@ import org.apache.commons.codec.binary.Base64; import org.apache.http.HttpException; import org.eclipse.jetty.util.security.Password; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; -import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; @@ -34,6 +33,7 @@ import org.onap.vid.client.HttpBasicClient; import org.onap.vid.exceptions.GenericUncheckedException; import org.onap.vid.mso.rest.RestInterface; import org.onap.vid.utils.Logging; +import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; @@ -64,6 +64,7 @@ public class RestMsoImplementation implements RestInterface { protected HttpsAuthClient httpsAuthClient; + protected SystemPropertiesWrapper systemProperties; private static final String START_LOG = " start"; private static final String APPLICATION_JSON = "application/json"; @@ -80,8 +81,9 @@ public class RestMsoImplementation implements RestInterface { */ @Autowired - protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){ + protected RestMsoImplementation(HttpsAuthClient httpsAuthClient, SystemPropertiesWrapper systemProperties){ this.httpsAuthClient=httpsAuthClient; + this.systemProperties = systemProperties; } @SuppressWarnings("Duplicates") @@ -89,9 +91,9 @@ public class RestMsoImplementation implements RestInterface { { final String methodname = "initRestClient()"; - final String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME); - final String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD); - final String mso_url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL); + final String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME); + final String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD); + final String mso_url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL); final String decrypted_password = Password.deobfuscate(password); String authString = username + ":" + decrypted_password; @@ -140,7 +142,7 @@ public class RestMsoImplementation implements RestInterface { try { restObject.set(t); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); @@ -179,7 +181,7 @@ public class RestMsoImplementation implements RestInterface { final String methodName = getMethodName(); logger.debug(EELFLoggerDelegate.debugLogger, "start {}->{}({}, {})", getMethodCallerName(), methodName, path, clazz); - String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; logger.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " sending request to url= " + url); MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); @@ -216,7 +218,7 @@ public class RestMsoImplementation implements RestInterface { try { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, HttpMethod.DELETE, url, r); cres = client.target(url) .request() @@ -281,7 +283,7 @@ public class RestMsoImplementation implements RestInterface { public Invocation.Builder prepareClient(String path, String methodName) { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - String url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + String url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + " sending request to url= " + url); // Change the content length return client.target(url) @@ -307,7 +309,7 @@ public class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); userId.ifPresent(id->commonHeaders.put("X-RequestorID", Collections.singletonList(id))); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, httpMethod, url, payload); // Change the content length final Invocation.Builder restBuilder = client.target(url) @@ -369,7 +371,7 @@ public class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); - url = SystemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; + url = systemProperties.getProperty(MsoProperties.MSO_SERVER_URL) + path; Logging.logRequest(outgoingRequestsLogger, HttpMethod.PUT, url, r); // Change the content length final Response cres = client.target(url) diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java index 0c05b80e2..6a498fc01 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java @@ -50,6 +50,7 @@ import org.onap.vid.mso.MsoUtil; import org.onap.vid.mso.RestMsoImplementation; import org.onap.vid.mso.RestObject; import org.onap.vid.utils.Logging; +import org.onap.vid.utils.SystemPropertiesWrapper; /** @@ -71,8 +72,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf */ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class); - public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) { - super(authClient); + public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient, SystemPropertiesWrapper systemPropertiesWrapper) { + super(authClient,systemPropertiesWrapper); this.client = client; this.baseUrl = baseUrl; this.commonHeaders = initCommonHeaders(); @@ -525,8 +526,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf } private Map<String, String> initCommonHeaders() { - String username = SystemProperties.getProperty(MsoProperties.MSO_USER_NAME); - String password = SystemProperties.getProperty(MsoProperties.MSO_PASSWORD); + String username = systemProperties.getProperty(MsoProperties.MSO_USER_NAME); + String password = systemProperties.getProperty(MsoProperties.MSO_PASSWORD); String decrypted_password = Password.deobfuscate(password); String authString = username + ":" + decrypted_password; @@ -538,7 +539,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf map.put(HttpHeaders.AUTHORIZATION, "Basic " + authStringEnc); map.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); - map.put(X_FROM_APP_ID, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); + map.put(X_FROM_APP_ID, systemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)); map.put(SystemProperties.ECOMP_REQUEST_ID, Logging.extractOrGenerateRequestId()); return ImmutableMap.copyOf(map); } |