2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Nokia. 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=========================================================
20 package org.onap.appc.flow.controller.node;
22 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
23 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE;
25 import java.util.Properties;
26 import org.apache.commons.lang3.StringUtils;
27 import org.onap.appc.flow.controller.data.Transaction;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 * Helper class for RestServiceNode
33 class TransactionHandler {
35 Transaction buildTransaction(SvcLogicContext ctx, Properties prop, String resourceUri)
38 String inputRequestAction = ctx.getAttribute(INPUT_REQUEST_ACTION);
39 String inputRequestActionType = ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE);
41 if (StringUtils.isBlank(inputRequestActionType)) {
42 throw new Exception("Don't know REST operation for Action " + inputRequestActionType);
44 if (StringUtils.isBlank(inputRequestAction)) {
45 throw new Exception("Don't know request-action " + INPUT_REQUEST_ACTION);
48 Transaction transaction = new Transaction();
49 transaction.setExecutionEndPoint(resourceUri);
50 transaction.setExecutionRPC(inputRequestActionType);
51 transaction.setAction(INPUT_REQUEST_ACTION);
53 //This code need to get changed to get the UserID and pass from a common place.
54 transaction.setuId(prop.getProperty(inputRequestAction.concat(".default-rest-user")));
55 transaction.setPswd(prop.getProperty(inputRequestAction.concat(".default-rest-pass")));