summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java56
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java23
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/artifact/ArtifactOperationInfo.java79
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMerge.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java7
8 files changed, 124 insertions, 68 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
index dadd12f673..b0344007f0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.BaseBusinessLogic;
import org.openecomp.sdc.be.components.impl.CsarValidationUtils;
import org.openecomp.sdc.be.components.impl.GroupBusinessLogic;
@@ -820,7 +820,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(
resource, csarInfo.getModifier(), json,
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE));
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE));
if (uploadArtifactToService.isRight()) {
return Either.right(uploadArtifactToService.right().value());
@@ -1705,7 +1705,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> uploadArtifactToService = createOrUpdateCsarArtifactFromJson(
resource, csarInfo.getModifier(), json,
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE));
+ new ArtifactOperationInfo(false, false, ArtifactOperationEnum.UPDATE));
if (uploadArtifactToService.isRight()) {
resStatus = Either.right(uploadArtifactToService.right().value());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index f48b3ebbbe..8a188792d8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -59,6 +59,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.ArtifactsResolver;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.artifact.ArtifactTypeToPayloadTypeSelector;
import org.openecomp.sdc.be.components.impl.artifact.PayloadTypeEnum;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
@@ -223,32 +224,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
}
- public class ArtifactOperationInfo {
-
- private ArtifactOperationEnum artifactOperationEnum;
- private boolean isExternalApi;
- private boolean ignoreLifecycleState;
-
- public ArtifactOperationInfo(boolean isExternalApi, boolean ignoreLifecycleState, ArtifactOperationEnum artifactOperationEnum) {
- this.artifactOperationEnum = artifactOperationEnum;
- this.isExternalApi = isExternalApi;
- this.ignoreLifecycleState = ignoreLifecycleState;
- }
-
- public boolean isExternalApi() {
- return isExternalApi;
- }
-
- public boolean ignoreLifecycleState() {
- return ignoreLifecycleState;
- }
-
- public ArtifactOperationEnum getArtifactOperationEnum() {
- return artifactOperationEnum;
- }
-
- }
-
// new flow US556184
public Either<ArtifactDefinition, Operation> handleArtifactRequest(String componentId, String userId, ComponentTypeEnum componentType,
ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo,
@@ -321,7 +296,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
ArtifactOperationEnum operationEnum = operation.getArtifactOperationEnum();
if (operationEnum == ArtifactOperationEnum.UPDATE || operationEnum == ArtifactOperationEnum.DELETE || operationEnum == ArtifactOperationEnum.DOWNLOAD) {
ArtifactDefinition dbArtifact = getArtifactIfBelongsToComponent(componentId, componentType, artifactId, component);
- if (operationEnum == ArtifactOperationEnum.DOWNLOAD) {
+ if (operation.isDownload()) {
artifactInfoToReturn = dbArtifact;
handleHeatEnvDownload(componentId, componentType, user, component, dbArtifact, shouldLock, inTransaction);
}
@@ -1046,7 +1021,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
private void validateMd5(String origMd5, String originData, byte[] payload, ArtifactOperationInfo operation) {
if (origMd5 == null) {
- if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && ArrayUtils.isNotEmpty(payload)) {
+ if (operation.isCreateOrLink() && ArrayUtils.isNotEmpty(payload)) {
log.debug("Missing md5 header during artifact create");
throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_INVALID_MD5);
}
@@ -1114,7 +1089,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
final ArtifactGroupTypeEnum artifactGroupType =
operationName != null ? ArtifactGroupTypeEnum.LIFE_CYCLE : ArtifactGroupTypeEnum.INFORMATIONAL;
- if (!isCreateOrLinkOperation) {
+ if (operation.isNotCreateOrLink()) {
checkAndSetUnUpdatableFields(user, artifactInfo, existingArtifactInfo, artifactGroupType);
} else {
checkCreateFields(user, artifactInfo, artifactGroupType);
@@ -1123,13 +1098,13 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
composeArtifactId(componentId, artifactId, artifactInfo, interfaceName, operationName);
if (existingArtifactInfo != null) {
artifactInfo.setMandatory(existingArtifactInfo.getMandatory());
- if (!isCreateOrLinkOperation) {
+ if (operation.isNotCreateOrLink()) {
validateArtifactTypeNotChanged(artifactInfo, existingArtifactInfo);
}
}
// artifactGroupType is not allowed to be updated
- if (!isCreateOrLinkOperation) {
+ if (operation.isNotCreateOrLink()) {
Either<ArtifactDefinition, ResponseFormat> validateGroupType = validateOrSetArtifactGroupType(artifactInfo, existingArtifactInfo);
if (validateGroupType.isRight()) {
return Either.right(validateGroupType.right().value());
@@ -1143,7 +1118,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (isDeploymentArtifact(artifactInfo)) {
if (componentType != ComponentTypeEnum.RESOURCE_INSTANCE) {
final String artifactName = artifactInfo.getArtifactName();
- if (isCreateOrLinkOperation || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) {
+ if (operation.isCreateOrLink() || !artifactName.equalsIgnoreCase(existingArtifactInfo.getArtifactName())) {
validateSingleDeploymentArtifactName(artifactName, parentComponent);
}
}
@@ -1200,7 +1175,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
private void ignoreUnupdateableFieldsInUpdate(final ArtifactOperationInfo operation,
final ArtifactDefinition artifactInfo,
final ArtifactDefinition currentArtifactInfo) {
- if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) {
+ if (operation.isUpdate()) {
artifactInfo.setArtifactType(currentArtifactInfo.getArtifactType());
artifactInfo.setArtifactGroupType(currentArtifactInfo.getArtifactGroupType());
artifactInfo.setArtifactLabel(currentArtifactInfo.getArtifactLabel());
@@ -1214,11 +1189,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
if (StringUtils.isNotEmpty(artifactId)) {
foundArtifact = findArtifact(parentComponent, componentType, parentId, artifactId);
}
- if (foundArtifact != null && ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) {
+ if (foundArtifact != null && operation.isCreateOrLink()) {
log.debug("Artifact {} already exist", artifactId);
throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_EXIST, foundArtifact.getArtifactLabel());
}
- if (foundArtifact == null && !ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) {
+ if (foundArtifact == null && operation.isNotCreateOrLink()) {
log.debug("The artifact {} was not found on parent component or instance {}. ", artifactId, parentId);
throw new ByActionStatusComponentException(ActionStatus.ARTIFACT_NOT_FOUND, "");
}
@@ -1628,7 +1603,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
log.debug("missing artifact logical name for component {}", componentId);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_DATA, ARTIFACT_LABEL));
}
- if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && !artifactInfo.getMandatory()) {
+ if (operation.isCreateOrLink() && !artifactInfo.getMandatory()) {
if (operationName != null) {
if (artifactInfo.getArtifactLabel() != null && !operationName.equals(artifactInfo.getArtifactLabel())) {
@@ -3079,7 +3054,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return componentResult.left().value();
}
- private Boolean validateWorkOnComponent(Component component, String userId, AuditingActionEnum auditingAction, User user, String artifactId, ArtifactOperationInfo operation) {
+ private void validateWorkOnComponent(Component component, String userId, AuditingActionEnum auditingAction, User user, String artifactId, ArtifactOperationInfo operation) {
if (operation.getArtifactOperationEnum() != ArtifactOperationEnum.DOWNLOAD && !operation.ignoreLifecycleState()) {
try {
validateCanWorkOnComponent(component, userId);
@@ -3091,12 +3066,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
throw e;
}
}
- return true;
}
private void validateUserRole(User user, AuditingActionEnum auditingAction, String componentId, String artifactId, ComponentTypeEnum componentType, ArtifactOperationInfo operation) {
- if (operation.getArtifactOperationEnum() != ArtifactOperationEnum.DOWNLOAD) {
+ if (operation.isNotDownload()) {
String role = user.getRole();
if (!role.equals(Role.ADMIN.name()) && !role.equals(Role.DESIGNER.name())) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION);
@@ -4628,7 +4602,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
} catch (ComponentException e) {
log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, component
.getName(), e.getResponseFormat());
- if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) {
+ if (operation.isCreateOrLink()) {
vfcsNewCreatedArtifacts.addAll(uploadedArtifacts);
}
throw e;
@@ -4696,7 +4670,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
handleArtifactsResult = uploadedArtifacts;
}catch (ComponentException e){
- if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum())) {
+ if (operation.isCreateOrLink()) {
vfcsNewCreatedArtifacts.addAll(uploadedArtifacts);
}
throw e;
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 50f9bc989c..71707e61f9 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
@@ -61,7 +61,7 @@ import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
@@ -792,7 +792,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
} else {
Either<Resource, ResponseFormat> createdCsarArtifactsEither = handleVfCsarArtifacts(preparedResource,
csarInfo, createdArtifacts,
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false, operation), shouldLock,
+ new ArtifactOperationInfo(false, false, operation), shouldLock,
inTransaction);
log.trace("************* Finished to add artifacts from yaml {}", yamlFileName);
if (createdCsarArtifactsEither.isRight()) {
@@ -1079,7 +1079,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
nodeTypeResource.getName());
handleNodeTypeArtifactsRequestRes = artifactsBusinessLogic
.handleArtifactsRequestForInnerVfcComponent(curArtifactsToHandle, nodeTypeResource, user,
- createdArtifacts, artifactsBusinessLogic.new ArtifactOperationInfo(false,
+ createdArtifacts, new ArtifactOperationInfo(false,
ignoreLifecycleState, curOperation),
false, inTransaction);
if (ArtifactOperationEnum.isCreateOrLink(curOperation)) {
@@ -2226,7 +2226,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
String vendorLicenseModelId = null;
String vfLicenseModelId = null;
- if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) {
+ if (artifactOperation.isUpdate()) {
Map<String, ArtifactDefinition> deploymentArtifactsMap = resource.getDeploymentArtifacts();
if (deploymentArtifactsMap != null && !deploymentArtifactsMap.isEmpty()) {
for (Entry<String, ArtifactDefinition> artifactEntry : deploymentArtifactsMap.entrySet()) {
@@ -2277,7 +2277,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.value()
.getValue();
Either<Resource, ResponseFormat> createArtifactsFromCsar;
- if (ArtifactOperationEnum.isCreateOrLink(artifactOperation.getArtifactOperationEnum())) {
+ if (artifactOperation.isCreateOrLink()) {
createArtifactsFromCsar = csarArtifactsAndGroupsBusinessLogic.createResourceArtifactsFromCsar(
csarInfo, resource, artifactsContents, artifactsFileName, createdArtifacts);
} else {
@@ -2317,8 +2317,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.get(artifactPath);
}
Either<Boolean, ResponseFormat> result = Either.left(true);
- if (operation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE
- || operation.getArtifactOperationEnum() == ArtifactOperationEnum.DELETE) {
+ if (operation.isUpdate() || operation.isDelete()) {
if (isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar)) {
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> handleDelete = artifactsBusinessLogic
.handleDelete(resource.getUniqueId(), artifactId, csarInfo.getModifier(),
@@ -2342,7 +2341,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (StringUtils.isEmpty(artifactId) && artifactFileBytes != null) {
- operation = artifactsBusinessLogic.new ArtifactOperationInfo(false, false,
+ operation = new ArtifactOperationInfo(false, false,
ArtifactOperationEnum.CREATE);
}
@@ -2385,7 +2384,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
private void addNonMetaCreatedArtifactsToSupportRollback(ArtifactOperationInfo operation,
List<ArtifactDefinition> createdArtifacts,
Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts) {
- if (ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && createdArtifacts != null
+ if (operation.isCreateOrLink() && createdArtifacts != null
&& eitherNonMetaArtifacts.isLeft()) {
Either<ArtifactDefinition, Operation> eitherResult = eitherNonMetaArtifacts.left()
.value();
@@ -2413,7 +2412,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> vfCsarArtifactsToHandle = null;
- if (ArtifactOperationEnum.isCreateOrLink(artifactOperation.getArtifactOperationEnum())) {
+ if (artifactOperation.isCreateOrLink()) {
vfCsarArtifactsToHandle = new EnumMap<>(ArtifactOperationEnum.class);
vfCsarArtifactsToHandle.put(artifactOperation.getArtifactOperationEnum(), artifactPathAndNameList.left()
.value());
@@ -2464,7 +2463,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
e.getArtifactName(), e.getArtifactType(),
e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(),
CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(),
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false,
+ new ArtifactOperationInfo(false, false,
currArtifactOperationPair.getKey()),
createdArtifacts, e.isFromCsar(), shouldLock, inTransaction))
// filter in only error
@@ -5851,7 +5850,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
foundArtifact.getArtifactType());
AuditingActionEnum auditingAction = artifactsBusinessLogic
- .detectAuditingType(artifactsBusinessLogic.new ArtifactOperationInfo(false, false,
+ .detectAuditingType(new ArtifactOperationInfo(false, false,
ArtifactOperationEnum.CREATE), foundArtifact.getArtifactChecksum());
artifactsBusinessLogic.handleAuditing(auditingAction, resource, resource.getUniqueId(),
user, null, null, foundArtifact.getUniqueId(), responseFormat,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/artifact/ArtifactOperationInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/artifact/ArtifactOperationInfo.java
new file mode 100644
index 0000000000..84316dbdff
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/artifact/ArtifactOperationInfo.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.components.impl.artifact;
+
+import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE;
+import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum.DELETE;
+import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum.DOWNLOAD;
+import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum.LINK;
+import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE;
+
+import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
+
+public final class ArtifactOperationInfo {
+
+ private final ArtifactOperationEnum artifactOperationEnum;
+ private final boolean isExternalApi;
+ private final boolean ignoreLifecycleState;
+
+ public ArtifactOperationInfo(boolean isExternalApi, boolean ignoreLifecycleState,
+ ArtifactOperationEnum artifactOperationEnum) {
+ this.artifactOperationEnum = artifactOperationEnum;
+ this.isExternalApi = isExternalApi;
+ this.ignoreLifecycleState = ignoreLifecycleState;
+ }
+
+ public boolean isExternalApi() {
+ return isExternalApi;
+ }
+
+ public boolean ignoreLifecycleState() {
+ return ignoreLifecycleState;
+ }
+
+ public ArtifactOperationEnum getArtifactOperationEnum() {
+ return artifactOperationEnum;
+ }
+
+ public boolean isCreateOrLink() {
+ return artifactOperationEnum == CREATE || artifactOperationEnum == LINK;
+ }
+
+ public boolean isNotCreateOrLink() {
+ return !isCreateOrLink();
+ }
+
+ public boolean isDownload() {
+ return artifactOperationEnum == DOWNLOAD;
+ }
+
+ public boolean isNotDownload() {
+ return !isDownload();
+ }
+
+ public boolean isUpdate() {
+ return artifactOperationEnum == UPDATE;
+ }
+
+ public boolean isDelete() {
+ return artifactOperationEnum == DELETE;
+ }
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java
index 6a74428a90..f68019c75d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMerge.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.components.merge.instance;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -107,7 +108,7 @@ public class ComponentInstanceArtifactsMerge implements ComponentInstanceMergeIn
null, currentArtifactDefinition.getValue().getListHeatParameters());
addEsIdToArtifactJson(jsonForUpdateArtifact, currentArtifactDefinition.getValue().getEsId());
artifactsBusinessLogic.updateResourceInstanceArtifactNoContent(newInstanceId, updatedContainerComponent,
- user, jsonForUpdateArtifact, artifactsBusinessLogic.new ArtifactOperationInfo(
+ user, jsonForUpdateArtifact, new ArtifactOperationInfo(
false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.LINK), currentArtifactDefinition.getValue());
}
return updatedContainerComponent;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMerge.java
index aa0dc22486..2f9943909c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMerge.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceHeatEnvMerge.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.be.components.merge.instance;
import fj.data.Either;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.merge.heat.HeatEnvArtifactsMergeBusinessLogic;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
@@ -69,7 +70,7 @@ public class ComponentInstanceHeatEnvMerge implements ComponentInstanceMergeInte
Map<String, Object> json = artifactsBusinessLogic.buildJsonForUpdateArtifact(artifactInfo, ArtifactGroupTypeEnum.DEPLOYMENT, null);
Either<ArtifactDefinition, Operation> uploadArtifactToService = artifactsBusinessLogic.updateResourceInstanceArtifactNoContent(newInstanceId, updatedContainerComponent, user, json,
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE), null);
+ new ArtifactOperationInfo(false, false, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE), null);
}
return updatedContainerComponent;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
index a2395c8541..1eb4bf651c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java
@@ -38,6 +38,7 @@ import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -188,7 +189,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither = artifactsBusinessLogic
.updateArtifactOnInterfaceOperationByResourceUUID(data, request, ComponentTypeEnum
.findByParamName(assetType), uuid, interfaceUUID, operationUUID, artifactUUID,
- resourceCommonInfo, artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
+ resourceCommonInfo, new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
if (uploadArtifactEither.isRight()) {
log.debug(FAILED_TO_UPDATE_ARTIFACT);
responseFormat = uploadArtifactEither.right().value();
@@ -293,7 +294,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.uploadArtifactToComponentByUUID(data, request, componentType, uuid,
- resourceCommonInfo, artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
+ resourceCommonInfo, new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
@@ -402,7 +403,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.uploadArtifactToRiByUUID(data, request, componentType, uuid, resourceInstanceName,
- artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
+ new ArtifactOperationInfo(true, false, ArtifactOperationEnum.CREATE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
@@ -506,7 +507,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.updateArtifactOnComponentByUUID(data, request, componentType, uuid, artifactUUID,
- resourceCommonInfo, artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
+ resourceCommonInfo, new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
@@ -616,7 +617,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.updateArtifactOnRiByUUID(data, request, componentType, uuid, resourceInstanceName, artifactUUID,
- artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
+ new ArtifactOperationInfo(true, false, ArtifactOperationEnum.UPDATE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
@@ -719,7 +720,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.deleteArtifactOnComponentByUUID(request, componentType, uuid, artifactUUID,
- resourceCommonInfo, artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
+ resourceCommonInfo, new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
@@ -822,7 +823,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet {
try {
if (responseWrapper.isEmpty()) {
artifactDefinition = artifactsBusinessLogic.deleteArtifactOnRiByUUID(request, componentType, uuid, resourceInstanceName, artifactUUID,
- artifactsBusinessLogic.new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
+ new ArtifactOperationInfo(true, false, ArtifactOperationEnum.DELETE));
Object representation = RepresentationUtils.toRepresentation(artifactDefinition);
Map<String, String> headers = new HashMap<>();
headers.put(Constants.MD5_HEADER, GeneralUtility.calculateMD5Base64EncodedByString((String) representation));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java
index ab914dc930..037ca47b13 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java
@@ -38,6 +38,7 @@ import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
+import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -716,7 +717,7 @@ public class ArtifactServlet extends BeGenericServlet {
Either<ArtifactDefinition, ResponseFormat> uploadArtifactEither =
artifactsBusinessLogic.updateArtifactOnInterfaceOperationByResourceUUID(data, request,
ComponentTypeEnum.findByParamName(assetType), uuid, interfaceUUID, operationUUID, artifactUUID,
- new ResourceCommonInfo(assetType), artifactsBusinessLogic.new ArtifactOperationInfo(true,
+ new ResourceCommonInfo(assetType), new ArtifactOperationInfo(true,
false, ArtifactOperationEnum.UPDATE));
if (uploadArtifactEither.isRight()) {
log.debug("failed to update artifact");
@@ -775,7 +776,7 @@ public class ArtifactServlet extends BeGenericServlet {
private Response handleDeleteRequest(HttpServletRequest request, String componentId, String artifactId, ComponentTypeEnum componentType, String interfaceType, String operationName, String parentId) {
String userId = request.getHeader(Constants.USER_ID_HEADER);
- Either<ArtifactDefinition, org.openecomp.sdc.be.model.Operation> actionResult = artifactsBusinessLogic.handleArtifactRequest(componentId, userId, componentType, artifactsBusinessLogic.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.DELETE), artifactId, null, null, null, interfaceType, operationName,
+ Either<ArtifactDefinition, org.openecomp.sdc.be.model.Operation> actionResult = artifactsBusinessLogic.handleArtifactRequest(componentId, userId, componentType, new ArtifactOperationInfo(false, false, ArtifactOperationEnum.DELETE), artifactId, null, null, null, interfaceType, operationName,
parentId, null);
Response response;
@@ -798,7 +799,7 @@ public class ArtifactServlet extends BeGenericServlet {
String userId = request.getHeader(Constants.USER_ID_HEADER);
Either<ArtifactDefinition, org.openecomp.sdc.be.model.Operation> result = artifactsBusinessLogic.handleArtifactRequest(componentId, userId, componentType,
- artifactsBusinessLogic.new ArtifactOperationInfo(false, false, operationEnum), artifactId, artifactInfo, origMd5, data, interfaceName, operationName, parentId,
+ new ArtifactOperationInfo(false, false, operationEnum), artifactId, artifactInfo, origMd5, data, interfaceName, operationName, parentId,
containerComponentType);
Response response;
if (result.isLeft()) {