1 package org.onap.sdc.dcae.composition.controller;
3 import org.onap.sdc.dcae.composition.restmodels.sdc.Asset;
4 import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed;
5 import org.onap.sdc.dcae.enums.AssetType;
6 import org.onap.sdc.dcae.enums.LifecycleOperationType;
7 import org.onap.sdc.dcae.errormng.ErrConfMgr;
8 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
9 import org.springframework.http.HttpStatus;
10 import org.springframework.http.ResponseEntity;
11 import org.springframework.web.bind.annotation.*;
13 import java.util.UUID;
16 @EnableAutoConfiguration
18 public class LifecycleController extends BaseController {
20 private static final String VFCMT = "vfcmt";
22 @RequestMapping(value={"/checkin/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"})
23 public ResponseEntity putCheckin(
24 @PathVariable("assetType") String assetType,
25 @PathVariable("uuid") UUID uuid,
26 @RequestHeader("USER_ID") String user_id,
27 @ModelAttribute("requestId") String requestId) {
32 Asset res_checkin = checkin(user_id, uuid.toString(), AssetType.RESOURCE, requestId);
33 return new ResponseEntity<>(res_checkin, HttpStatus.OK);
36 return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
38 } catch (Exception e) {
39 return handleException(e, ErrConfMgr.ApiType.CHECK_IN_RESOURCE);
43 @RequestMapping(value={"/checkout/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"})
44 public ResponseEntity putCheckout(
45 @PathVariable("assetType") String assetType,
46 @PathVariable("uuid") UUID uuid,
47 @RequestHeader("USER_ID") String user_id,
48 @ModelAttribute("requestId") String requestId) {
53 Asset asset = checkout(user_id, uuid.toString(), AssetType.RESOURCE, requestId);
54 return new ResponseEntity<>(asset, HttpStatus.OK);
57 return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
59 } catch (Exception e) {
60 return handleException(e, ErrConfMgr.ApiType.CHECK_OUT_RESOURCE);
64 @RequestMapping(value={"/certify/{assetType}/{uuid}"}, method={RequestMethod.PUT}, produces={"application/json"})
65 public ResponseEntity putCertify(
66 @PathVariable("assetType") String assetType,
67 @PathVariable("uuid") String uuid,
68 @RequestHeader("USER_ID") String user_id,
69 @ModelAttribute("requestId") String requestId) {
74 ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().changeResourceLifecycleState(user_id, uuid, LifecycleOperationType.CERTIFY.name(), "certifying VFCMT", requestId);
75 return new ResponseEntity<>(vfcmt, HttpStatus.OK);
78 return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
80 } catch (Exception e) {
81 return handleException(e, ErrConfMgr.ApiType.CHECK_OUT_RESOURCE);