2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.pnf.delegate;
23 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
24 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
26 import org.camunda.bpm.engine.delegate.DelegateExecution;
27 import org.camunda.bpm.engine.delegate.JavaDelegate;
28 import org.onap.so.bpmn.common.scripts.ExceptionUtil;
29 import org.onap.so.logger.MsoLogger;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.beans.factory.annotation.Value;
32 import org.springframework.stereotype.Component;
35 public class PnfCheckInputs implements JavaDelegate {
37 private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, PnfCheckInputs.class);
39 private String defaultTimeout;
42 public PnfCheckInputs(@Value("${aai.pnfEntryNotificationTimeout}") String defaultTimeout) {
43 this.defaultTimeout = defaultTimeout;
47 public void execute(DelegateExecution execution) {
48 String correlationId = (String) execution.getVariable(CORRELATION_ID);
49 if (correlationId == null) {
50 new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined");
52 String timeout = (String) execution.getVariable(TIMEOUT_FOR_NOTIFICATION);
53 if (timeout == null) {
54 LOGGER.debug("timeoutForPnfEntryNotification variable not found, setting default");
55 if (defaultTimeout == null) {
56 new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
57 "default timeoutForPnfEntryNotification value not defined");
59 execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);