diff options
author | 2018-10-21 10:20:53 +0300 | |
---|---|---|
committer | 2018-10-21 13:35:08 +0300 | |
commit | f53d4650e18007ab7820efd84638edac90b61090 (patch) | |
tree | b27d22bd8ad1343f9ed69091f9d6496a174f6c89 /dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java | |
parent | b1b380c5e83b044605bddfc390b80bedafd359f5 (diff) |
upgrade dace-be
Change-Id: Iaef6ef0d37e2e216321f141d10692edcaf26ffab
Issue-ID: DCAEGEN2-836
Signed-off-by: Manor, Yanir (ym903w) <ym903w@intl.att.com>
Diffstat (limited to 'dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java')
-rw-r--r-- | dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java b/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java index e13990d..13eb724 100644 --- a/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java +++ b/dcaedt_be/src/main/java/org/onap/sdc/dcae/composition/controller/CompositionController.java @@ -3,6 +3,7 @@ package org.onap.sdc.dcae.composition.controller; import org.onap.sdc.common.onaplog.Enums.LogLevel; import org.onap.sdc.dcae.composition.impl.CompositionBusinessLogic; import org.onap.sdc.dcae.composition.impl.CompositionCatalogBusinessLogic; +import org.onap.sdc.dcae.composition.restmodels.CreateMcResponse; import org.onap.sdc.dcae.composition.restmodels.MessageResponse; import org.onap.sdc.dcae.composition.restmodels.ReferenceUUID; import org.onap.sdc.dcae.composition.restmodels.sdc.Artifact; @@ -27,57 +28,6 @@ public class CompositionController extends BaseController { @Autowired private CompositionBusinessLogic compositionBusinessLogic; -// @Deprecated -// @RequestMapping(value = { "/utils/clone/{assetType}/{sourceId}/{targetId}" }, method = { RequestMethod.GET }, produces = { "application/json" }) -// public ResponseEntity clone(@RequestHeader("USER_ID") String userId, -// @PathVariable("assetType") String theAssetType, @PathVariable("sourceId") String theSourceId, @PathVariable("targetId") String theTargetId, @ModelAttribute("requestId") String requestId) { -// MessageResponse response = new MessageResponse(); -// -// try { -// // fetch the source and assert it is a vfcmt containing clone worthy artifacts (composition + rules) -// ResourceDetailed sourceVfcmt = baseBusinessLogic.getSdcRestClient().getResource(theSourceId, requestId); -// baseBusinessLogic.checkVfcmtType(sourceVfcmt); -// List<Artifact> artifactsToClone = CollectionUtils.isEmpty(sourceVfcmt.getArtifacts()) ? -// null : -// sourceVfcmt.getArtifacts().stream().filter(p -> DcaeBeConstants.Composition.fileNames.COMPOSITION_YML.equals(p.getArtifactName()) || p.getArtifactName().endsWith(DcaeBeConstants.Composition.fileNames.MAPPING_RULE_POSTFIX)) -// .collect(Collectors.toList()); -// if (CollectionUtils.isEmpty(artifactsToClone)) { -// response.setSuccessResponse("Nothing to clone"); -// return new ResponseEntity<>(response, HttpStatus.NO_CONTENT); -// } -// -// // fetch the target -// ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().getResource(theTargetId, requestId); -// debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), vfcmt.toString()); -// baseBusinessLogic.checkVfcmtType(vfcmt); -// baseBusinessLogic.checkUserIfResourceCheckedOut(userId, vfcmt); -// boolean isTargetNeed2Checkout = baseBusinessLogic.isNeedToCheckOut(vfcmt.getLifecycleState()); -// if (isTargetNeed2Checkout) { -// ResourceDetailed targetVfcmt = baseBusinessLogic.getSdcRestClient().changeResourceLifecycleState(userId, theTargetId, LifecycleOperationType.CHECKOUT.name(), "checking out VFCMT before clone", requestId); -// if (null == targetVfcmt) { -// return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.GENERAL_ERROR); -// } -// theTargetId = targetVfcmt.getUuid(); -// debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "New targetVfcmt (for artifact clone) after checkoutVfcmt is: {}", theTargetId); -// } -// -// Map<String, Artifact> currentArtifacts = CollectionUtils.isEmpty(vfcmt.getArtifacts()) ? new HashMap<>() : vfcmt.getArtifacts().stream().collect(Collectors.toMap(Artifact::getArtifactName, Function.identity())); -// -// //TODO target VFCMT rule artifacts should be removed -// for (Artifact artifactToClone : artifactsToClone) { -// String payload = baseBusinessLogic.getSdcRestClient().getResourceArtifact(theSourceId, artifactToClone.getArtifactUUID(), requestId); -// baseBusinessLogic.cloneArtifactToTarget(userId, theTargetId, payload, artifactToClone, currentArtifacts.get(artifactToClone.getArtifactName()), requestId); -// } -// -// baseBusinessLogic.getSdcRestClient().changeResourceLifecycleState(userId, theTargetId, LifecycleOperationType.CHECKIN.name(), "check in VFCMT after clone", requestId); -// debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Cloning {} from {} has finished successfully", theSourceId, theTargetId); -// response.setSuccessResponse("Clone VFCMT complete"); -// return new ResponseEntity<>(response, HttpStatus.OK); -// } catch (Exception e) { -// return handleException(e, ApiType.CLONE_VFCMT); -// } -// } - @RequestMapping(value = "/{theItemId}/model", method = RequestMethod.GET , produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity model(@ModelAttribute("requestId") String requestId, @PathVariable String theItemId) { return compositionCatalogBusinessLogic.getModelById(requestId, theItemId); @@ -85,7 +35,7 @@ public class CompositionController extends BaseController { @RequestMapping(value = "/{theItemId}/type/{theTypeName:.*}", method = RequestMethod.GET , produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity typeInfo(@ModelAttribute("requestId") String requestId, @PathVariable String theItemId, @PathVariable String theTypeName) { - return compositionCatalogBusinessLogic.getTypeInfo(theItemId, theTypeName); + return compositionCatalogBusinessLogic.getTypeInfo(theItemId, theTypeName, requestId); } @RequestMapping(value = "/catalog", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @@ -116,7 +66,6 @@ public class CompositionController extends BaseController { } } - @RequestMapping(value = { "/getMC/{vfcmtUuid}" }, method = RequestMethod.GET , produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getMC(@PathVariable String vfcmtUuid, @ModelAttribute String requestId) { try { @@ -126,6 +75,18 @@ public class CompositionController extends BaseController { } } + // 1810 US436244 MC table + @RequestMapping(value = { "/getMC/{vfcmtUuid}/{revertedUuid}" }, method = RequestMethod.GET , produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getSubmittedMcWithRevertedReference(@PathVariable String vfcmtUuid, @PathVariable String revertedUuid, @ModelAttribute String requestId) { + try { + CreateMcResponse res = compositionBusinessLogic.getDataAndComposition(vfcmtUuid, requestId); + res.getVfcmt().setUuid(vfcmtUuid.concat("/").concat(revertedUuid)); + return new ResponseEntity<>(res, HttpStatus.OK); + } catch (Exception e) { + return handleException(e, ApiType.GET_VFCMT); + } + } + @RequestMapping(value = "/saveComposition/{vfcmtUuid}", method = RequestMethod.POST) public ResponseEntity saveComposition(@RequestHeader("USER_ID") String userId, @RequestBody String theCdump, @PathVariable("vfcmtUuid") String vfcmtUuid, @ModelAttribute("requestId") String requestId) { @@ -151,4 +112,21 @@ public class CompositionController extends BaseController { } return res; } + + @RequestMapping(value = "/{contextType}/{serviceUuid}/{vfiName}/saveComposition/{vfcmtUuid}/{revertedUuid}", method = RequestMethod.POST) + public ResponseEntity overwriteRevertedComposition(@RequestHeader("USER_ID") String userId, @RequestBody String theCdump, + @PathVariable String contextType, @PathVariable String serviceUuid, @PathVariable String vfiName, @PathVariable String vfcmtUuid, @PathVariable String revertedUuid, @ModelAttribute String requestId) { + try { + debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Reverted MC version {} is about to be overwritten with submitted MC version {}", revertedUuid, vfcmtUuid); + ResponseEntity res = compositionBusinessLogic.overwriteRevertedMC(userId, vfcmtUuid, revertedUuid, theCdump, requestId); + debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Reverted MC version {} overwrite result status code: {}", revertedUuid, res.getStatusCodeValue()); + if(HttpStatus.OK == res.getStatusCode()) { + debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "About to undo revert of external monitoring reference from service {} to MC {}", serviceUuid, revertedUuid); + compositionBusinessLogic.undoRevert(userId, contextType, serviceUuid, vfiName, revertedUuid, requestId); + } + return res; + } catch (Exception e) { + return handleException(e, ApiType.SAVE_CDUMP); + } + } }
\ No newline at end of file |