aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-08-13 16:51:44 +0300
committerMichael Lando <ml636r@att.com>2017-08-13 17:08:41 +0300
commit335d13c0e57ae61148b7a0871c5c9e46f768cd93 (patch)
tree0aec18acdd36c8092ea112e0a7d96dc78e35eb89 /catalog-be
parentce07d7cd59425944f85d0fef5126ebeef731bc7b (diff)
[SDC-235] rebase code
Change-Id: Iea503188e521fa3846f580ced7c1c4fce303abe5 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/LifecycleBusinessLogic.java21
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");
+ }
+
}