1 package org.onap.clamp.clds.client;
4 import java.util.logging.Logger;
6 import org.camunda.bpm.engine.delegate.DelegateExecution;
7 import org.camunda.bpm.engine.delegate.JavaDelegate;
8 import org.springframework.beans.factory.annotation.Autowired;
10 import org.onap.clamp.clds.client.req.TcaMPolicyReq;
11 import org.onap.clamp.clds.model.prop.ModelProperties;
12 import org.onap.clamp.clds.model.prop.Tca;
13 import org.onap.clamp.clds.model.refprop.RefProp;
17 * Send Tca info to policy api.
21 public class TcaPolicyDelegate implements JavaDelegate {
22 // currently uses the java.util.logging.Logger like the Camunda engine
23 private static final Logger logger = Logger.getLogger(TcaPolicyDelegate.class.getName());
26 private RefProp refProp;
28 @Autowired PolicyClient policyClient;
31 * Perform activity. Send Tca info to policy api.
35 public void execute(DelegateExecution execution) throws Exception {
36 String tcaPolicyRequestUuid = UUID.randomUUID().toString();
37 execution.setVariable("tcaPolicyRequestUuid", tcaPolicyRequestUuid);
39 ModelProperties prop = ModelProperties.create(execution);
40 Tca tca = prop.getTca();
42 String policyJson = TcaMPolicyReq.formatTca(refProp, prop);
43 String responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid);
44 if(responseMessage != null)
46 execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes());