diff options
Diffstat (limited to 'vid-app-common/src/main/java/org')
6 files changed, 80 insertions, 166 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 563e798df..a472268a3 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 @@ -23,6 +23,7 @@ package org.onap.vid.controller; import io.joshworks.restclient.http.mapper.ObjectMapper; import org.onap.portalsdk.core.util.SystemProperties; import org.onap.vid.aai.AaiClientInterface; +import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.client.SyncRestClient; import org.onap.vid.factories.MsoRequestFactory; import org.onap.vid.mso.MsoBusinessLogic; @@ -47,10 +48,10 @@ public class MsoConfig { } @Bean - public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper){ + public MsoRestClientNew msoClient(ObjectMapper unirestObjectMapper, HttpsAuthClient httpsAuthClient){ // Satisfy both interfaces -- MsoInterface and RestMsoImplementation return new MsoRestClientNew(new SyncRestClient(unirestObjectMapper), SystemProperties.getProperty( - MsoProperties.MSO_SERVER_URL)); + MsoProperties.MSO_SERVER_URL),httpsAuthClient); } @Bean 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 ff12bb8bc..e14ac0e11 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 @@ -51,7 +51,7 @@ import static org.onap.vid.utils.Logging.*; /** * Created by pickjonathan on 26/06/2017. */ -public abstract class RestMsoImplementation implements RestInterface { +public class RestMsoImplementation implements RestInterface { /** * The logger. @@ -62,7 +62,7 @@ public abstract class RestMsoImplementation implements RestInterface { /** The client. */ private Client client = null; - @Autowired + protected HttpsAuthClient httpsAuthClient; private static final String START_LOG = " start"; @@ -79,6 +79,11 @@ public abstract class RestMsoImplementation implements RestInterface { * Instantiates a new mso rest interface. */ + @Autowired + protected RestMsoImplementation(HttpsAuthClient httpsAuthClient){ + this.httpsAuthClient=httpsAuthClient; + } + @SuppressWarnings("Duplicates") protected MultivaluedHashMap<String, Object> initMsoClient() { @@ -139,7 +144,7 @@ public abstract class RestMsoImplementation implements RestInterface { MultivaluedHashMap<String, Object> commonHeaders = initMsoClient(); Logging.logRequest(outgoingRequestsLogger, HttpMethod.GET, url); - final Response cres = client.target(url) + final Response cres = client.target(url) .request() .accept(APPLICATION_JSON) .headers(commonHeaders) @@ -219,7 +224,8 @@ public abstract class RestMsoImplementation implements RestInterface { .accept(APPLICATION_JSON) .headers(commonHeaders) //.entity(r) - .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)).invoke(); + .build("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON)) + .invoke(); Logging.logResponse(outgoingRequestsLogger, HttpMethod.DELETE, url, cres); int status = cres.getStatus(); restObject.setStatusCode (status); @@ -245,6 +251,7 @@ public abstract class RestMsoImplementation implements RestInterface { catch ( Exception e ) { logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG + e.getMessage()); + throw e; } } @@ -252,7 +259,6 @@ public abstract class RestMsoImplementation implements RestInterface { { logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + WITH_URL_LOG +url+ EXCEPTION_LOG + e.toString()); throw e; - } } @@ -349,7 +355,6 @@ public abstract class RestMsoImplementation implements RestInterface { restObject.setStatusCode (status); return restObject; - } @Override @@ -383,6 +388,7 @@ public abstract class RestMsoImplementation implements RestInterface { catch ( Exception e ) { logger.debug(EELFLoggerDelegate.debugLogger,"<== " + methodName + NO_RESPONSE_ENTITY_LOG + e.getMessage()); + throw e; } int status = cres.getStatus(); 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 76e61b35f..8dac0ce1b 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 @@ -22,25 +22,31 @@ package org.onap.vid.mso.rest; import com.google.common.collect.ImmutableMap; import io.joshworks.restclient.http.HttpResponse; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; import org.apache.commons.codec.binary.Base64; 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.util.HttpsAuthClient; import org.onap.vid.changeManagement.MsoRequestDetails; import org.onap.vid.changeManagement.RequestDetailsWrapper; import org.onap.vid.client.SyncRestClient; import org.onap.vid.model.RequestReferencesContainer; -import org.onap.vid.mso.*; +import org.onap.vid.mso.MsoInterface; +import org.onap.vid.mso.MsoProperties; +import org.onap.vid.mso.MsoResponseWrapper; +import org.onap.vid.mso.MsoResponseWrapperInterface; +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 javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - /** * Created by pickjonathan on 21/06/2017. @@ -61,7 +67,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf */ EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MsoRestClientNew.class); - public MsoRestClientNew(SyncRestClient client, String baseUrl) { + public MsoRestClientNew(SyncRestClient client, String baseUrl, HttpsAuthClient authClient) { + super(authClient); this.client = client; this.baseUrl = baseUrl; this.commonHeaders = initCommonHeaders(); @@ -218,13 +225,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf return MsoUtil.wrapResponse(response); } - public MsoResponseWrapper getManualTasks(String endpoint) { - String path = baseUrl + endpoint; - - HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class); - return MsoUtil.wrapResponse(response); - } - + @Override public MsoResponseWrapper getManualTasksByRequestId(String t, String sourceId, String endpoint, RestObject restObject) { String methodName = "getManualTasksByRequestId"; logger.debug(methodName + START); @@ -232,9 +233,10 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf try { String path = baseUrl + endpoint; - MsoResponseWrapper w =getManualTasks(path); - logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); + HttpResponse<String> response = client.get(path, commonHeaders, new HashMap<>(), String.class); + MsoResponseWrapper w = MsoUtil.wrapResponse(response); + logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w=" + w.getResponse()); return w; } catch (Exception e) { diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java deleted file mode 100644 index 23a5119e9..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 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. - * 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 - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.vid.mso.rest; - -import java.util.List; - -public class Task { - - private String taskId; - private String type; - private String nfRole; - private String subscriptionServiceType; - private String originalRequestId; - private String originalRequestorId; - private String errorSource; - private String errorCode; - private String errorMessage; - private String buildingBlockName; - private String buildingBlockStep; - private List<String> validResponses; - - - public String getTaskId() { - return taskId; - } - - public void setTaskId(String taskId) { - this.taskId = taskId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getNfRole() { - return nfRole; - } - - public void setNfRole(String nfRole) { - this.nfRole = nfRole; - } - - public String getSubscriptionServiceType() { - return subscriptionServiceType; - } - - public void setSubscriptionServiceType(String subscriptionServiceType) { - this.subscriptionServiceType = subscriptionServiceType; - } - - public String getOriginalRequestId() { - return originalRequestId; - } - - public void setOriginalRequestId(String originalRequestId) { - this.originalRequestId = originalRequestId; - } - - public String getOriginalRequestorId() { - return originalRequestorId; - } - - public void setOriginalRequestorId(String originalRequestorId) { - this.originalRequestorId = originalRequestorId; - } - - public String getErrorSource() { - return errorSource; - } - - public void setErrorSource(String errorSource) { - this.errorSource = errorSource; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getBuildingBlockName() { - return buildingBlockName; - } - - public void setBuildingBlockName(String buildingBlockName) { - this.buildingBlockName = buildingBlockName; - } - - public String getBuildingBlockStep() { - return buildingBlockStep; - } - - public void setBuildingBlockStep(String buildingBlockStep) { - this.buildingBlockStep = buildingBlockStep; - } - - public List<String> getValidResponses() { - return validResponses; - } - - public void setValidResponses(List<String> validResponses) { - this.validResponses = validResponses; - } - - - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt new file mode 100644 index 000000000..311b0fbbe --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 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. + * 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 + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.mso.rest + +data class Task( + var taskId: String?, + var type: String?, + var nfRole: String?, + var subscriptionServiceType: String?, + var originalRequestId: String?, + var originalRequestorId: String?, + var errorSource: String?, + var errorCode: String?, + var errorMessage: String?, + var buildingBlockName: String?, + var buildingBlockStep: String?, + var validResponses: List<String>? +) { + // i.e. "default constructor", no params + constructor() : this( + null, null, null, null, + null, null, null, null, + null, null, null, null + ) +} diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java index dfe3185b2..1c68e8292 100644 --- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java +++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java @@ -62,6 +62,7 @@ public enum Features implements Feature { FLAG_1902_NEW_VIEW_EDIT, FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER, FLAG_1902_VNF_GROUPING, + FLAG_HANDLE_SO_WORKFLOWS ; public boolean isActive() { |