diff options
Diffstat (limited to 'catalog-be/src/main/java/org')
3 files changed, 25 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java index 7214d011e0..2c051b2b94 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java @@ -1196,7 +1196,7 @@ public class ElementBusinessLogic extends BaseBusinessLogic { if(subcategories != null){ return fetchByMainCategory(subcategories.left().value(), inTransaction, resourceType); } - return fetchByResourceType(filters.get(FilterKeyEnum.RESOURCE_TYPE), inTransaction); + return fetchComponentMetaDataByResourceType(filters.get(FilterKeyEnum.RESOURCE_TYPE), inTransaction); } private Either<List<ImmutablePair<SubCategoryData, GraphEdge>>, StorageOperationStatus> getAllSubCategories(String categoryName) { @@ -1320,14 +1320,14 @@ public class ElementBusinessLogic extends BaseBusinessLogic { return Either.left(components); } - private Either<List<Component>, StorageOperationStatus> fetchByResourceType(String resourceType, boolean inTransaction) { + private Either<List<Component>, StorageOperationStatus> fetchComponentMetaDataByResourceType(String resourceType, boolean inTransaction) { List<Component> components = null; StorageOperationStatus status; Wrapper<StorageOperationStatus> statusWrapper = new Wrapper<>(); Either<List<Component>, StorageOperationStatus> result; try { - - Either<List<Component>, StorageOperationStatus> getResources = toscaOperationFacade.fetchByResourceType(resourceType); //titanGenericDao.getByCriteria(nodeType, props, clazz); + ComponentParametersView fetchUsersAndCategoriesFilter = new ComponentParametersView(Arrays.asList(ComponentFieldsEnum.USERS.getValue(), ComponentFieldsEnum.CATEGORIES.getValue())); + Either<List<Component>, StorageOperationStatus> getResources = toscaOperationFacade.fetchMetaDataByResourceType(resourceType, fetchUsersAndCategoriesFilter); if (getResources.isRight()) { status = getResources.right().value(); if(status != StorageOperationStatus.NOT_FOUND){ diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index 82382f961d..8fd28e1224 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -4858,7 +4858,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { Either<Resource, ResponseFormat> result = null; try { - if(resource.getLifecycleState() != LifecycleStateEnum.CERTIFIED && forceCertificationAllowed){ + if(resource.getLifecycleState() != LifecycleStateEnum.CERTIFIED && forceCertificationAllowed && lifecycleBusinessLogic.isFirstCertification(resource.getVersion())){ result = nodeForceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock); if(result.isRight()){ return result; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java index dfe04f919d..f0b369072e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java @@ -464,7 +464,18 @@ public class LifecycleBusinessLogic { return Either.left(latestComponent); } - +/** + * Performs Force certification. + * Note that a Force certification is allowed for the first certification only, + * as only a state and a version is promoted due a Force certification, + * skipping other actions required if a previous certified version exists. + * @param resource + * @param user + * @param lifecycleChangeInfo + * @param inTransaction + * @param needLock + * @return + */ public Either<Resource, ResponseFormat> forceResourceCertification(Resource resource, User user, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) { Either<Resource, ResponseFormat> result = null; Either<ToscaElement, StorageOperationStatus> certifyResourceRes = null; @@ -472,6 +483,10 @@ public class LifecycleBusinessLogic { log.debug("Force certification is not allowed for the action {}. ", lifecycleChangeInfo.getAction().name()); result = Either.right(componentUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); } + if(!isFirstCertification(resource.getVersion())){ + log.debug("Failed to perform a force certification of resource{}. Force certification is allowed for the first certification only. ", resource.getName()); + result = Either.right(componentUtils.getResponseFormat(ActionStatus.NOT_ALLOWED)); + } // lock resource if(result == null && !inTransaction && needLock){ log.info("lock component {}", resource.getUniqueId()); @@ -512,4 +527,8 @@ public class LifecycleBusinessLogic { return result; } + public boolean isFirstCertification(String previousVersion) { + return previousVersion.split("\\.")[0].equals("0"); + } + } |