1 package org.onap.appc.flow.controller.node;
3 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION;
4 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE;
6 import java.util.Properties;
7 import org.apache.commons.lang3.StringUtils;
8 import org.onap.appc.flow.controller.data.Transaction;
9 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
12 * Helper class for RestServiceNode
14 class TransactionHandler {
16 private TransactionHandler() {}
18 static Transaction buildTransaction(SvcLogicContext ctx, Properties prop,
19 String resourceUri) throws Exception {
21 String inputRequestAction = ctx.getAttribute(INPUT_REQUEST_ACTION);
22 String inputRequestActionType = ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE);
24 if (StringUtils.isBlank(inputRequestActionType)) {
25 throw new IllegalArgumentException(
26 "Don't know REST operation for Action " + inputRequestActionType);
28 if (StringUtils.isBlank(inputRequestAction)) {
29 throw new IllegalArgumentException("Don't know request-action " + INPUT_REQUEST_ACTION);
32 Transaction transaction = new Transaction();
33 transaction.setExecutionEndPoint(resourceUri);
34 transaction.setExecutionRPC(inputRequestActionType);
35 transaction.setAction(INPUT_REQUEST_ACTION);
37 //This code need to get changed to get the UserID and pass from a common place.
38 transaction.setuId(prop.getProperty(inputRequestAction.concat(".default-rest-user")));
39 transaction.setPswd(prop.getProperty(inputRequestAction.concat(".default-rest-pass")));