diff options
author | Stone, Avi (as206k) <as206k@att.com> | 2018-04-12 15:46:31 +0300 |
---|---|---|
committer | Stone, Avi (as206k) <as206k@att.com> | 2018-04-12 15:49:38 +0300 |
commit | 5032434b101f25fa44d2e1f8dc8393e30af1ed4f (patch) | |
tree | 2dc7d37a8048e025c7412af080640da4c9a22b65 /dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java | |
parent | 2205633792f95f46a02bbf8f87f0c2637265d924 (diff) |
DCAE-D be initial commit
DCAE-D be initial commit
Issue-ID: SDC-1218
Change-Id: Id18ba96c499e785aa9ac395fbaf32d57f08c281b
Signed-off-by: Stone, Avi (as206k) <as206k@att.com>
Diffstat (limited to 'dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java')
-rw-r--r-- | dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java b/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java new file mode 100644 index 0000000..3007335 --- /dev/null +++ b/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/LifecycleController.java @@ -0,0 +1,84 @@ +package org.onap.sdc.dcae.composition.controller; + +import org.onap.sdc.dcae.composition.restmodels.sdc.Asset; +import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed; +import org.onap.sdc.dcae.enums.AssetType; +import org.onap.sdc.dcae.enums.LifecycleOperationType; +import org.onap.sdc.dcae.errormng.ErrConfMgr; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.UUID; + +@RestController +@EnableAutoConfiguration +@CrossOrigin +public class LifecycleController extends BaseController { + + private static final String VFCMT = "vfcmt"; + + @RequestMapping(value={"/checkin/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"}) + public ResponseEntity putCheckin( + @PathVariable("assetType") String assetType, + @PathVariable("uuid") UUID uuid, + @RequestHeader("USER_ID") String user_id, + @ModelAttribute("requestId") String requestId) { + + try { + switch (assetType) { + case VFCMT: + Asset res_checkin = checkin(user_id, uuid.toString(), AssetType.RESOURCE, requestId); + return new ResponseEntity<>(res_checkin, HttpStatus.OK); + + default: + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + return handleException(e, ErrConfMgr.ApiType.CHECK_IN_RESOURCE); + } + } + + @RequestMapping(value={"/checkout/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"}) + public ResponseEntity putCheckout( + @PathVariable("assetType") String assetType, + @PathVariable("uuid") UUID uuid, + @RequestHeader("USER_ID") String user_id, + @ModelAttribute("requestId") String requestId) { + + try { + switch (assetType) { + case VFCMT: + Asset asset = checkout(user_id, uuid.toString(), AssetType.RESOURCE, requestId); + return new ResponseEntity<>(asset, HttpStatus.OK); + + default: + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + return handleException(e, ErrConfMgr.ApiType.CHECK_OUT_RESOURCE); + } + } + + @RequestMapping(value={"/certify/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"}) + public ResponseEntity putCertify( + @PathVariable("assetType") String assetType, + @PathVariable("uuid") String uuid, + @RequestHeader("USER_ID") String user_id, + @ModelAttribute("requestId") String requestId) { + + try { + switch (assetType) { + case VFCMT: + ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().changeResourceLifecycleState(user_id, uuid, LifecycleOperationType.CERTIFY.name(), "certifying VFCMT", requestId); + return new ResponseEntity<>(vfcmt, HttpStatus.OK); + + default: + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + } catch (Exception e) { + return handleException(e, ErrConfMgr.ApiType.CHECK_OUT_RESOURCE); + } + } +} |