diff options
Diffstat (limited to 'bpmn')
16 files changed, 100 insertions, 265 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java index c58f22f949..ae8638f0b7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java @@ -42,8 +42,6 @@ import org.onap.aai.domain.yang.Pservers; import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.openecomp.mso.client.aai.entities.CustomQuery; import org.openecomp.mso.client.aai.entities.Results; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoPropertiesFactory; import org.springframework.stereotype.Service; import com.fasterxml.jackson.core.JsonParseException; @@ -56,15 +54,10 @@ public class AAIRestClientImpl implements AAIRestClient { private final WebTarget webTarget; - private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - private static final String ENDPOINT_VERSION = "v10"; private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; - private static final String PSERVER_BY_VNF_QUERY = "g.V().has('aai-node-type', 'generic-vnf').has('vnf-name','USAUTOUFTIL2001UJDM02').out('runsOnPserver').has('aai-node-type', 'pserver')"; private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" @@ -92,7 +85,6 @@ public class AAIRestClientImpl implements AAIRestClient { public AAIRestClientImpl(final String host) throws NoSuchAlgorithmException { Logger logger = Logger.getLogger(getClass().getName()); Client client = this.getSSLClient(); - Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper()).target(host + "/aai"); } @@ -107,7 +99,7 @@ public class AAIRestClientImpl implements AAIRestClient { @Override public List<Pserver> getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - List<String> startNodes = new ArrayList<String>(); + List<String> startNodes = new ArrayList<>(); startNodes.add("network/generic-vnfs/generic-vnf/" + vnfId); String jsonInput = webTarget.register(AAIQueryObjectMapperProvider.class).path(ENDPOINT_CUSTOM_QUERY) .queryParam("format", "resource").request().header("X-FromAppId", "MSO") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java index c9c12c4afb..aea223da56 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java @@ -42,7 +42,7 @@ public class Results<T> { public List<T> getResult() { if (result == null) { - result = new ArrayList<T>(); + result = new ArrayList<>(); } return this.result; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java index b164682bc7..26c1c4acd2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java @@ -63,15 +63,7 @@ public class ApplicationControllerClient { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - private static final int ACCEPT_SERIES = 100; - private static final int ERROR_SERIES = 200; - private static final int REJECT_SERIES = 300; - private static final int SUCCESS_SERIES = 400; - private static final int SUCCESS_STATUS = SUCCESS_SERIES + 0; private static final int PARTIAL_SERIES = 500; - private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES + 0; - - private final boolean useLCMBypass = false; private final String apiVer = "2.00"; private final String originatorId = "MSO"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java index abd8543f84..665b9052eb 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java @@ -53,19 +53,20 @@ public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
throws IOException {
- if (!stream.markSupported()) {
- stream = new BufferedInputStream(stream);
+ InputStream inputStream = stream;
+ if (!inputStream.markSupported()) {
+ inputStream = new BufferedInputStream(inputStream);
}
- stream.mark(maxEntitySize + 1);
+ inputStream.mark(maxEntitySize + 1);
final byte[] entity = new byte[maxEntitySize + 1];
- final int entitySize = stream.read(entity);
+ final int entitySize = inputStream.read(entity);
b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
if (entitySize > maxEntitySize) {
b.append("...more...");
}
b.append('\n');
- stream.reset();
- return stream;
+ inputStream.reset();
+ return inputStream;
}
@Override
@@ -126,4 +127,4 @@ public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, out.write(i);
}
}
-}
\ No newline at end of file +}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java index 3138349fd2..2db4dea069 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Body.java @@ -41,7 +41,7 @@ public class Body implements Serializable @JsonProperty("input") private Input input; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 9101706044452851559L; @JsonProperty("input") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java index 27efe03243..25eb2ed270 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/Input.java @@ -41,7 +41,7 @@ public class Input implements Serializable @JsonProperty("request-healthdiagnostic") private RequestHealthDiagnostic RequestHealthDiagnostic; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 7155546785389227528L; @JsonProperty("request-healthdiagnostic") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java index 20bd735ae2..b1ed77b513 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/RequestHealthDiagnostic.java @@ -59,7 +59,7 @@ public class RequestHealthDiagnostic implements Serializable @JsonProperty("health-diagnostic-code") private String healthDiagnosticCode; @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<String, Object>(); + private Map<String, Object> additionalProperties = new HashMap<>(); private final static long serialVersionUID = 1166788526178388021L; @JsonProperty("request-client-name") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java index 63894b9c16..0997b2df90 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/ResultInfo.java @@ -51,7 +51,7 @@ private String requestId; @JsonProperty("status") private String status; @JsonIgnore -private Map<String, Object> additionalProperties = new HashMap<String, Object>(); +private Map<String, Object> additionalProperties = new HashMap<>(); @JsonProperty("client-name") public String getClientName() { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java index 6080768cee..419f4aacf5 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java @@ -71,6 +71,7 @@ public class XQueryScriptTask extends BaseTask { private Expression atomicInputVariables; private Expression outputVariable; + @Override public void execute(DelegateExecution execution) throws Exception { if (msoLogger.isDebugEnabled()) { msoLogger.debug("Started Executing " + getTaskName()); @@ -222,12 +223,11 @@ public class XQueryScriptTask extends BaseTask { */ private XQueryExecutable compile(XQueryCompiler compiler, String resource) throws Exception { - try (InputStream xqStream = getClass().getResourceAsStream(resource)) { - XQueryExecutable executable = compiler.compile(xqStream); - return executable; - } catch (Exception e) { - msoLogger.debug ("Exception at resourceFile stream:", e); - return null; - } + try (InputStream xqStream = getClass().getResourceAsStream(resource)) { + return compiler.compile(xqStream); + } catch (Exception e) { + msoLogger.debug ("Exception at resourceFile stream:", e); + return null; + } } }
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java index da340a02f7..1e68c84878 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java @@ -235,7 +235,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { Resource resource = iter.next();
//resource.getModelInfo().getModelInvariantId();
- if (resourceObjectId.equals("extracted information")){
+ if ("extracted information".equals(resourceObjectId)){
return resource.toJsonString();
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/pom.xml b/bpmn/MSOInfrastructureBPMN/pom.xml index be03cb44f5..3ca9c636a3 100644 --- a/bpmn/MSOInfrastructureBPMN/pom.xml +++ b/bpmn/MSOInfrastructureBPMN/pom.xml @@ -414,7 +414,7 @@ </dependency>
<!--for yang tools-->
- <dependency>
+<!-- <dependency>
<groupId>org.openecomp.so</groupId>
<artifactId>common</artifactId>
<version>1.1.0-SNAPSHOT</version>
@@ -424,6 +424,6 @@ <groupId>org.onap.sdnc.northbound</groupId>
<artifactId>generic-resource-api.model</artifactId>
<version>1.2.0</version>
- </dependency>
+ </dependency>-->
</dependencies>
</project>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java deleted file mode 100644 index 25727bdcd0..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncOperationTaskYangToolsImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.bpmn.infrastructure.workflow.serviceTask; - -import okhttp3.RequestBody; -import okhttp3.ResponseBody; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput; -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkTopologyRequestBodyBuilder; -import org.openecomp.mso.requestsdb.RequestsDbConstant; -import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService; -import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory; - -import java.util.Map; - -/** - * Created by 10112215 on 2017/9/20. - */ -public class SdncOperationTaskYangToolsImpl extends AbstractSdncOperationTask { - - public void sendRestrequestAndHandleResponse(DelegateExecution execution, - Map<String, String> inputs, - GenericResourceApi genericResourceApiClient) throws Exception { - updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!"); - NetworkTopologyRequestBodyBuilder builder = new NetworkTopologyRequestBodyBuilder(); - RequestBody body = builder.build(execution, inputs); - updateProgress(execution, null, null, "50", "RequestBody build finished!"); - ResponseBody responseBody = genericResourceApiClient.postNetworkTopologyOperation(body).execute().body(); - updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveResponse(execution, responseBody); - } - - private void saveResponse(DelegateExecution execution, ResponseBody responseBody) throws Exception { - ITransformJava2StringService java2jsonService = TransfromJava2StringFactory.getJava2jsonService(); - NetworkTopologyOperationOutput output = (NetworkTopologyOperationOutput) java2jsonService. - transformRpcDataObjectFromString(NetworkTopologyRequestBodyBuilder.URI_PATH, responseBody.string()); - String responseCode = output.getResponseCode(); - if (!"200".equals(responseCode)) { - String processKey = getProcessKey(execution); - int errorCode = Integer.valueOf(responseCode); - String errorMessage = output.getResponseMessage(); - WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage); - execution.setVariable("SDNCA_SuccessIndicator", workflowException); - updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage); - throw new Exception(""); - } - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java index 91b95df1b2..41fa8f250a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java @@ -22,8 +22,6 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builde import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.SdncUnderlayVpnPreprocessTask; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.OnapModelInformationEntity; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.ParamEntity; @@ -36,35 +34,101 @@ import java.util.List; import java.util.Map; import java.util.UUID; +//import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; +//import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; + /** * Created by 10112215 on 2017/9/20. */ public abstract class AbstractBuilder<IN, OUT> { + public static enum RequestAction { + CreateNetworkInstance(0, "CreateNetworkInstance"), + ActivateNetworkInstance(1, "ActivateNetworkInstance"), + CreateServiceInstance(2, "CreateServiceInstance"), + DeleteServiceInstance(3, "DeleteServiceInstance"), + DeleteNetworkInstance(4, "DeleteNetworkInstance"), + CreateVnfInstance(5, "CreateVnfInstance"), + ActivateVnfInstance(6, "ActivateVnfInstance"), + DeleteVnfInstance(7, "DeleteVnfInstance"), + CreateVfModuleInstance(8, "CreateVfModuleInstance"), + ActivateVfModuleInstance(9, "ActivateVfModuleInstance"), + DeleteVfModuleInstance(10, "DeleteVfModuleInstance"), + CreateContrailRouteInstance(11, "CreateContrailRouteInstance"), + DeleteContrailRouteInstance(12, "DeleteContrailRouteInstance"), + CreateSecurityZoneInstance(13, "CreateSecurityZoneInstance"), + DeleteSecurityZoneInstance(14, "DeleteSecurityZoneInstance"); + + String name; + int value; + + private RequestAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + + public enum SvcAction { + Reserve(0, "reserve"), + Assign(1, "assign"), + Activate(2, "activate"), + Delete(3, "delete"), + Changeassign(4, "changeassign"), + Changedelete(5, "changedelete"), + Rollback(6, "rollback"), + Deactivate(7, "deactivate"), + Unassign(8, "unassign"), + Create(9, "create"); + + String name; + int value; + + private SvcAction(int value, String name) { + this.value = value; + this.name = name; + } + + public String getName() { + return this.name; + } + + public int getIntValue() { + return this.value; + } + } + protected String requestId = null; abstract OUT build(DelegateExecution execution, IN input) throws Exception; protected String getRequestActoin(DelegateExecution execution) { - String action = RequestInformation.RequestAction.CreateNetworkInstance.name(); + String action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name(); String operType = getOperType(execution); if (!StringUtils.isBlank(operType)) { if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { - action = RequestInformation.RequestAction.DeleteNetworkInstance.name(); + action = /*RequestInformation.*/RequestAction.DeleteNetworkInstance.name(); } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { - action = RequestInformation.RequestAction.CreateNetworkInstance.name(); + action = /*RequestInformation.*/RequestAction.CreateNetworkInstance.name(); } } return action; } protected String getOperationType(DelegateExecution execution) { - String action = SdncRequestHeader.SvcAction.Create.name(); + String action = /*SdncRequestHeader.*/SvcAction.Create.name(); String operType = getOperType(execution); if (!StringUtils.isBlank(operType)) { if (RequestsDbConstant.OperationType.DELETE.equals(operType)) { - action = SdncRequestHeader.SvcAction.Delete.name(); + action = /*SdncRequestHeader.*/SvcAction.Delete.name(); } else if (RequestsDbConstant.OperationType.CREATE.equals(operType)) { - action = SdncRequestHeader.SvcAction.Create.name(); + action = /*SdncRequestHeader.*/SvcAction.Create.name(); } } return action; diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java deleted file mode 100644 index d5ba528911..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder; - -import okhttp3.RequestBody; -import org.apache.commons.lang3.StringUtils; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.json.JSONObject; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.NetworkRequestInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.network.request.input.NetworkInputParametersBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.Param; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamKey; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder; -import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService; -import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Created by 10112215 on 2017/9/20. - */ -public class NetworkTopologyRequestBodyBuilder extends AbstractBuilder<Map<String, String>, RequestBody> { - - public static final String URI_PATH = "GENERIC-RESOURCE-API:network-topology-operation"; - public static final SdncRequestHeader.SvcAction SVC_DEFAULT_ACTION = SdncRequestHeader.SvcAction.Create; - public static final String SVC_REQUEST_ID = "MSO"; - public static final String SDC_ACTION = "SDC_ACTION"; - public static final RequestInformation.RequestAction REQUEST_ACTION = RequestInformation.RequestAction.CreateNetworkInstance; - protected static ITransformJava2StringService java2jsonService; - - static - { - try { - java2jsonService = TransfromJava2StringFactory.getJava2jsonService(); - } catch (Exception e) { - e.printStackTrace(); - java2jsonService = null; - } - } - - @Override - public RequestBody build(DelegateExecution execution, Map<String, String> input) throws Exception { - NetworkTopologyOperationInput sdncInput = getSdncInput(input); - RequestBody body = getRequestBody(sdncInput); - return body; - } - - protected String getJsonInput(NetworkTopologyOperationInput sdncInput) throws Exception { - return java2jsonService.transformRpcDataObjectToString(URI_PATH, sdncInput); - } - - private RequestBody getRequestBody(NetworkTopologyOperationInput sdncInput) throws Exception { - String jsonString = getJsonInput(sdncInput); - String json = (new JSONObject(jsonString)).toString(); - return RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),json); - } - - protected NetworkTopologyOperationInput getSdncInput(Map<String, String> inputs) { - NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder = new NetworkTopologyOperationInputBuilder(); - { - loadSdncRequestHeader(inputs, networkTopologyOperationInputBuilder); - loadRequestInformation(networkTopologyOperationInputBuilder); - loadNetworkInputParameters(inputs, networkTopologyOperationInputBuilder); - } - return networkTopologyOperationInputBuilder.build(); - } - - private void loadNetworkInputParameters(Map<String, String> inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - NetworkRequestInputBuilder networkRequestInputBuilder = new NetworkRequestInputBuilder(); - { - NetworkInputParametersBuilder networkInputParametersBuilder = new NetworkInputParametersBuilder(); - { - List<Param> paramList = getParamList(inputs); - networkInputParametersBuilder.setParam(paramList); - } - networkRequestInputBuilder.setNetworkInputParameters(networkInputParametersBuilder.build()); - } - networkTopologyOperationInputBuilder.setNetworkRequestInput(networkRequestInputBuilder.build()); - } - - private void loadRequestInformation(NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder(); - { - requestInformationBuilder.setRequestId(SVC_REQUEST_ID); - requestInformationBuilder.setRequestAction(REQUEST_ACTION); - } - networkTopologyOperationInputBuilder.setRequestInformation(requestInformationBuilder.build()); - } - - private void loadSdncRequestHeader(Map<String, String> inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) { - SdncRequestHeaderBuilder sdncRequestHeaderBuilder = new SdncRequestHeaderBuilder(); - { - sdncRequestHeaderBuilder.setSvcRequestId(SVC_REQUEST_ID); - SdncRequestHeader.SvcAction svcAction = SVC_DEFAULT_ACTION; - String action = inputs.get(SDC_ACTION); - if (!StringUtils.isBlank(action)) { - if (action.toLowerCase().contains("delete")) { - svcAction = SdncRequestHeader.SvcAction.Delete; - } else if (action.toLowerCase().contains("create")) { - svcAction = SdncRequestHeader.SvcAction.Create; - } - } - sdncRequestHeaderBuilder.setSvcAction(svcAction); - } - networkTopologyOperationInputBuilder.setSdncRequestHeader(sdncRequestHeaderBuilder.build()); - } - - private List<Param> getParamList(Map<String, String> inputs) { - List<Param> paramList = new ArrayList<>(); - if (inputs != null && !inputs.isEmpty()) { - inputs.keySet().forEach(key -> { - ParamBuilder paramBuilder = new ParamBuilder(); - paramBuilder.setName(key); - paramBuilder.setValue(inputs.get(key)); - paramBuilder.setKey(new ParamKey(key)); - paramList.add(paramBuilder.build()); - }); - } - return paramList; - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java index dbddbee928..b11a1d022d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java @@ -39,7 +39,8 @@ import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource; */
@Path("/async")
public class WorkflowAsyncVcpeResource extends WorkflowAsyncResource {
-
+
+ @Override
protected ProcessEngineServices getProcessEngineServices() {
return pes4junit.orElse(ProcessEngines.getProcessEngine("vcpe"));
}
diff --git a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java index 9e43ee3512..60d65665fe 100644 --- a/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java +++ b/bpmn/MSOURN-plugin/src/main/java/org/openecomp/camunda/bpmn/plugin/urnmap/db/MyBatisExtendedSessionFactory.java @@ -37,6 +37,7 @@ public class MyBatisExtendedSessionFactory extends StandaloneProcessEngineConfig private String resourceName;
+ @Override
protected void init() {
throw new IllegalArgumentException(
"Normal 'init' on process engine only used for extended MyBatis mappings is not allowed, please use 'initFromProcessEngineConfiguration'. You cannot construct a process engine with this configuration.");
@@ -55,7 +56,6 @@ public class MyBatisExtendedSessionFactory extends StandaloneProcessEngineConfig setDatabaseTablePrefix(processEngineConfiguration.getDatabaseTablePrefix());
initDataSource();
- //initVariableTypes();
initCommandContextFactory();
initTransactionFactory();
initTransactionContextFactory();
@@ -75,7 +75,7 @@ public class MyBatisExtendedSessionFactory extends StandaloneProcessEngineConfig */
@Override
protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() {
- List<CommandInterceptor> defaultCommandInterceptorsTxRequired = new ArrayList<CommandInterceptor>();
+ List<CommandInterceptor> defaultCommandInterceptorsTxRequired = new ArrayList<>();
defaultCommandInterceptorsTxRequired.add(new LogInterceptor());
defaultCommandInterceptorsTxRequired.add(new CommandContextInterceptor(commandContextFactory, this, true));
return defaultCommandInterceptorsTxRequired;
|