Merge "Add template and tosca model entities and repositories"
[clamp.git] / src / main / resources / clds / camel / rest / clamp-api-v2.xml
index da856e9..a0a3eb1 100644 (file)
@@ -68,7 +68,7 @@
                                        <to
                                                uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')" />
                                        <to
-                                               uri="bean:org.onap.clamp.loop.LoopController?method=getSVGRepresentation(${header.loopName})" />
+                                               uri="bean:org.onap.clamp.loop.LoopController?method=getSvgRepresentation(${header.loopName})" />
                                        <to
                                                uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
                                        <doCatch>
                        </route>
                </post>
                <put
-                       uri="/v2/loop/deployLoop/{loopName}"
+                       uri="/v2/loop/deploy/{loopName}"
                        outType="org.onap.clamp.loop.Loop"
                        produces="application/json">
                        <route>
                                        <to uri="direct:load-loop" />
                                        <to
                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DCAE DEPLOY request','INFO',${exchangeProperty[loopObject]})" />
-                                       
-                                       <to uri="direct:get-status-from-policy" />
-                                       <to uri="direct:get-status-from-dcae" />
-                                       <log
-                                               loggingLevel="INFO"
-                                               message="Policy deployment status: ${exchangeProperty[policyStatus]}"></log>
-                                       <choice>
-                                               <when>
-                                                       <simple> ${exchangeProperty[policyStatus]} == 'SUBMITTED' and
-                                                               ${exchangeProperty[dcaeStatus]} == 'NOT_DEPLOYED'
-                                                       </simple>
-                                                       <to uri="direct:deploy-loop" />
-                                               </when>
-                                               <otherwise>
-                                                       <log
-                                                               loggingLevel="INFO"
-                                                               message="POLICY status ${exchangeProperty[policyStatus]}/DCAE status ${exchangeProperty[dcaeStatus]}, DCAE deployment will be started anyway" />
-                                                       <to
-                                                               uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('POLICY status ${exchangeProperty[policyStatus]}/DCAE status ${exchangeProperty[dcaeStatus]}, DCAE deployment will be started anyway','ERROR',${exchangeProperty[loopObject]})" />
-                                                       <to uri="direct:deploy-loop" />
-                                               </otherwise>
-                                       </choice>
+
+                                       <to uri="direct:deploy-loop" />
+
                                        <log
                                                loggingLevel="INFO"
                                                message="DEPLOY request successfully executed for loop: ${header.loopName}" />
                                                        loggingLevel="ERROR"
                                                        message="DEPLOY request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DEPLOY request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DEPLOY request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
+                                       </doCatch>
+                               </doTry>
+                       </route>
+               </put>
+               <put
+                       uri="/v2/loop/refreshOpPolicyJsonSchema/{loopName}"
+                       outType="org.onap.clamp.loop.Loop"
+                       produces="application/json">
+                       <route>
+                               <removeHeaders
+                                       pattern="*"
+                                       excludePattern="loopName" />
+                               <doTry>
+                                       <log
+                                               loggingLevel="INFO"
+                                               message="Refresh Operational Policy UI for loop: ${header.loopName}" />
+                                       <to
+                                               uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'REFRESH OP Policy UI request')" />
+                                       <to
+                                               uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
+                                       <to uri="direct:load-loop" />
+                                       <to
+                                               uri="bean:org.onap.clamp.loop.LoopController?method=refreshOpPolicyJsonRepresentation(${header.loopName})" />
+                                       <log
+                                               loggingLevel="INFO"
+                                               message="REFRESH request successfully executed for loop: ${header.loopName}" />
+                                       <to
+                                               uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('REFRESH request successfully executed','INFO',${exchangeProperty[loopObject]})" />
+                                       <to
+                                               uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
+                                       <doCatch>
+                                               <exception>java.lang.Exception</exception>
+                                               <handled>
+                                                       <constant>false</constant>
+                                               </handled>
+                                               <to
+                                                       uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=errorLog()" />
+                                               <log
+                                                       loggingLevel="ERROR"
+                                                       message="REFRESH request failed for loop: ${header.loopName}" />
+                                               <to
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('REFRESH request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                </put>
                <put
-                       uri="/v2/loop/undeployLoop/{loopName}"
+                       uri="/v2/loop/undeploy/{loopName}"
                        outType="org.onap.clamp.loop.Loop"
                        produces="application/json">
                        <route>
                                        <to uri="direct:load-loop" />
                                        <to
                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DCAE UNDEPLOY request','INFO',${exchangeProperty[loopObject]})" />
-                                       <to uri="direct:get-status-from-dcae" />
-                                       <choice>
-                                               <when>
-                                                       <simple> ${exchangeProperty[dcaeStatus]} == 'DEPLOYED' or ${exchangeProperty[dcaeStatus]} == 'IN_ERROR' or ${exchangeProperty[dcaeStatus]} == 'PROCESSING'
-                                                       </simple>
-                                                       <to uri="direct:undeploy-loop" />
-                                               </when>
-                                               <otherwise>
-                                                       <log
-                                                               loggingLevel="INFO"
-                                                               message="Loop is in state ${exchangeProperty[dcaeStatus]}, it can only be undeployed when in state DEPLOYED/IN_ERROR/PROCESSING" />
-                                                       <to
-                                                               uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Loop is in state ${exchangeProperty[dcaeStatus]}, it can only be deployed when in state DEPLOYED','ERROR',${exchangeProperty[loopObject]})" />
-                                               </otherwise>
-                                       </choice>
+                                       <to uri="direct:undeploy-loop" />
+
                                        <log
                                                loggingLevel="INFO"
                                                message="UNDEPLOY request successfully executed for loop: ${header.loopName}" />
                                                        loggingLevel="ERROR"
                                                        message="UNDEPLOY request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('UNDEPLOY request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('UNDEPLOY request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                                        <to uri="direct:load-loop" />
                                        <to
                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request','INFO',${exchangeProperty[loopObject]})" />
-                                       
+
                                        <to uri="direct:remove-all-policy-from-active-pdp-group" />
                                        <log
                                                loggingLevel="INFO"
                                                        loggingLevel="ERROR"
                                                        message="STOP request failed for loop: $${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('STOP request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                                                        loggingLevel="ERROR"
                                                        message="RESTART request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('RESTART request failed, Error reported: ${exception}','INFO',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('RESTART request failed, Error reported: ${exception} - Body: ${exception.responseBody}','INFO',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                                                </split>
                                        </split>
 
+                                       <delay>
+                                               <constant>3000</constant>
+                                       </delay>
+
                                        <to uri="direct:add-all-to-active-pdp-group" />
 
                                        <log
                                                        loggingLevel="ERROR"
                                                        message="SUBMIT request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                                        <to uri="direct:load-loop" />
                                        <to
                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request','INFO',${exchangeProperty[loopObject]})" />
+                                       <to uri="direct:undeploy-loop" />
                                        <to uri="direct:remove-all-policy-from-active-pdp-group" />
                                        <split>
                                                <simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
                                                        loggingLevel="ERROR"
                                                        message="DELETE request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                </doTry>
                        </route>
                                        <to uri="direct:load-loop" />
                                        <to
                                                uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request','INFO',${exchangeProperty[loopObject]})" />
-                                       <setProperty propertyName="raiseHttpExceptionFlag">
-                                               <simple resultType="java.lang.Boolean">false</simple>
-                                       </setProperty>
-                                       <to uri="direct:get-status-from-policy" />
-                                       <to uri="direct:get-status-from-dcae" />
-                                       <to
-                                               uri="bean:org.onap.clamp.loop.LoopOperation?method=updateLoopStatus(${exchangeProperty[loopObject]},${exchangeProperty[policyStatus]}, ${exchangeProperty[dcaeStatus]})" />
-                                       <log
-                                               loggingLevel="INFO"
-                                               message="Get Status request successfully executed. The new state is: ${body}" />
-                                       <to
-                                               uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request successfully executed','INFO',${exchangeProperty[loopObject]})" />
-                                       <to
-                                               uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
+                                       <doTry>
+                                               <to uri="direct:update-policy-status-for-loop" />
+                                               <to uri="direct:update-dcae-status-for-loop" />
+                                               <to uri="direct:update-loop-state" />
+
+                                               <to
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request successfully executed','INFO',${exchangeProperty[loopObject]})" />
+                                               <to
+                                                       uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" />
+                                       </doTry>
                                        <doCatch>
                                                <exception>java.lang.Exception</exception>
                                                <handled>
                                                        loggingLevel="ERROR"
                                                        message="Get Status request failed for loop: ${header.loopName}" />
                                                <to
-                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request failed, Error reported: ${exception}','ERROR',${exchangeProperty[loopObject]})" />
+                                                       uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Get Status request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" />
                                        </doCatch>
                                        <doFinally>
-                                               <to
-                                                       uri="bean:org.onap.clamp.loop.LoopController?method=getLoop(${header.loopName})" />
+                                               <setBody>
+                                                       <simple>${exchangeProperty[loopObject]}</simple>
+                                               </setBody>
                                        </doFinally>
                                </doTry>
                        </route>