diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/main')
11 files changed, 80 insertions, 76 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 5f70ab5924..3a1e126fef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -82,7 +82,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple String correlationValue = messageId; callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "queryVnfNotification") @@ -117,7 +117,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setOutputs(outputs); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "createVnfNotification") @@ -150,7 +150,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "updateVnfNotification") @@ -181,7 +181,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setRollback(rollback); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } @WebMethod(operationName = "deleteVnfNotification") @@ -208,6 +208,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple message.setErrorMessage(errorMessage); callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable, - correlationValue, logMarker); + correlationValue, logMarker, null); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index ace6e1937d..4fb63651eb 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -102,7 +102,11 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); processor.startProcess(processKey, variableMap); WorkflowResponse response = waitForResponse(inputVariables); - return Response.status(202).entity(response).build(); + if (response.getMessageCode() == 500) { + return Response.status(500).entity(response).build(); + } else { + return Response.status(202).entity(response).build(); + } } catch (WorkflowProcessorException e) { WorkflowResponse response = e.getWorkflowResponse(); return Response.status(500).entity(response).build(); @@ -112,7 +116,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } } - private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { + protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; long waitTime = getWaitTime(inputVariables); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index d33e7aed0c..70365b744c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -85,12 +85,14 @@ public class WorkflowProcessor extends ProcessEngineAwareService { Map<String, Object> inputVariables = new HashMap<>(); @SuppressWarnings("unchecked") Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables"); - for (Map.Entry<String, Object> entry : vMap.entrySet()) { - String vName = entry.getKey(); - Object value = entry.getValue(); - @SuppressWarnings("unchecked") - Map<String, Object> valueMap = (Map<String, Object>) value; // value, type - inputVariables.put(vName, valueMap.get("value")); + if (vMap != null) { + for (Map.Entry<String, Object> entry : vMap.entrySet()) { + String vName = entry.getKey(); + Object value = entry.getValue(); + @SuppressWarnings("unchecked") + Map<String, Object> valueMap = (Map<String, Object>) value; // value, type + inputVariables.put(vName, valueMap.get("value")); + } } return inputVariables; } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index bcc3739c32..6debcfbff6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -333,8 +333,6 @@ public class WorkflowResource extends ProcessEngineAwareService { public void run() { setLogContext(processKey, inputVariables); - long startTime = System.currentTimeMillis(); - try { RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); @@ -557,7 +555,6 @@ public class WorkflowResource extends ProcessEngineAwareService { // TODO filter only set of variables WorkflowResponse response = new WorkflowResponse(); - long startTime = System.currentTimeMillis(); try { ProcessEngineServices engine = getProcessEngineServices(); List<HistoricVariableInstance> variables = engine.getHistoryService().createHistoricVariableInstanceQuery() diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java new file mode 100644 index 0000000000..94f4b313d4 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/AsyncTaskExecutorListener.java @@ -0,0 +1,42 @@ +package org.onap.so.bpmn.core.plugins; + +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.onap.so.bpmn.common.listener.validation.WorkflowActionListenerRunner; +import org.onap.so.spring.SpringContextHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AsyncTaskExecutorListener implements ExecutionListener { + private final Logger logger = LoggerFactory.getLogger(AsyncTaskExecutorListener.class); + + + private WorkflowActionListenerRunner listenerRunner; + + @Override + public void notify(DelegateExecution execution) throws Exception { + if (!isBlank(execution.getCurrentActivityName())) { + try { + String id = execution.getId(); + if (id != null) { + RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); + String processName = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(execution.getProcessDefinitionId()).singleResult().getName(); + logger.info("ProcessName : {}", processName); + if (processName != null) { + listenerRunner = + SpringContextHelper.getAppContext().getBean(WorkflowActionListenerRunner.class); + listenerRunner.executeAsyncListeners(processName, execution, ExecutionListener.EVENTNAME_END); + } + } + } catch (Exception e) { + logger.error("Error occured in executing Complete Task Listeners", e); + } + } + } + + private boolean isBlank(Object object) { + return object == null || "".equals(object.toString().trim()); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 251464a34d..6de22825b7 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -37,8 +37,10 @@ import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl; import org.camunda.bpm.engine.impl.util.xml.Element; import org.camunda.bpm.engine.impl.variable.VariableDeclaration; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -50,6 +52,9 @@ import org.springframework.stereotype.Component; @Component public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { + public static final String SERVICE_INSTANCE_ID = "ServiceInstanceId"; + public static final String SERVICE_NAME = "ServiceName"; + @Autowired private LoggingParseListener loggingParseListener; @@ -294,6 +299,13 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { String requestId = (String) execution.getVariable("mso-request-id"); String svcid = (String) execution.getVariable("mso-service-instance-id"); + try { + MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId); + MDC.put(SERVICE_INSTANCE_ID, svcid); + MDC.put(SERVICE_NAME, processName); + } catch (Exception e) { + logger.error("Error trying to add variables to MDC", e); + } } } catch (Exception e) { logger.error("Exception occurred", e); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java index a049f81906..03feda6d0f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java @@ -38,9 +38,7 @@ import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource; import org.onap.so.bpmn.common.workflow.service.WorkflowResource; import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor; import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor; -import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; @@ -65,7 +63,7 @@ public class CXFConfiguration { private WorkflowAsyncResource workflowAsyncResource; @Autowired - private JaxRsFilterLogging jaxRsFilterLogging; + private SOAuditLogContainerFilter soAuditLogContainerFilter; @Autowired private ObjectMapper mapper; @@ -108,7 +106,7 @@ public class CXFConfiguration { endpoint.setServiceBeans(Arrays.<Object>asList(wmr, workflowResource, workflowAsyncResource)); endpoint.setAddress("/"); endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature())); - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), jaxRsFilterLogging)); + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), soAuditLogContainerFilter)); return endpoint.create(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index 093fba089d..29fc4e93fc 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -33,7 +33,7 @@ import org.camunda.bpm.engine.repository.DeploymentBuilder; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.db.catalog.beans.Workflow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.onap.logging.filter.spring.MDCTaskDecorator;; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -99,7 +99,7 @@ public class MSOInfrastructureApplication { DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment(); deployCustomWorkflows(deploymentBuilder); } catch (Exception e) { - logger.warn("Unable to invoke deploymentBuilder: " + e.getMessage()); + logger.warn("Unable to invoke deploymentBuilder ", e); } } @@ -136,11 +136,11 @@ public class MSOInfrastructureApplication { deploymentBuilder.addString(workflowName, workflowBody); } deploymentBuilder.enableDuplicateFiltering(true); - deploymentBuilder.deploy(); } + deploymentBuilder.deploy(); } } catch (Exception e) { - logger.warn("Unable to deploy custom workflows, " + e.getMessage()); + logger.warn("Unable to deploy custom workflows ", e); } } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java deleted file mode 100644 index 1ed3214214..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.so.bpmn.infrastructure; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", - "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - -} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application-aaf.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-aaf.yaml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-aaf.yaml diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application-basic.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-basic.yaml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application-basic.yaml |