import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.ArtifactTypeDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.operations.api.IHeatParametersOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.ArtifactTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
private static final String UPDATE_ARTIFACT = "Update Artifact";
private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}";
private static final String VALID_ARTIFACT_LABEL_NAME = "'A-Z', 'a-z', '0-9', '-', '@', '+' and space.";
+ private final ArtifactTypeOperation artifactTypeOperation;
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
@javax.annotation.Resource
private IInterfaceLifecycleOperation interfaceLifecycleOperation;
ArtifactsResolver artifactsResolver, IElementOperation elementDao, IGroupOperation groupOperation,
IGroupInstanceOperation groupInstanceOperation, IGroupTypeOperation groupTypeOperation,
InterfaceOperation interfaceOperation, InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
- ArtifactsOperations artifactToscaOperation) {
+ ArtifactsOperations artifactToscaOperation,
+ ArtifactTypeOperation artifactTypeOperation) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation,
artifactToscaOperation);
this.artifactCassandraDao = artifactCassandraDao;
this.lifecycleBusinessLogic = lifecycleBusinessLogic;
this.userBusinessLogic = userBusinessLogic;
this.artifactsResolver = artifactsResolver;
+ this.artifactTypeOperation = artifactTypeOperation;
}
public static <R> Either<Boolean, R> ifTrue(boolean predicate, Supplier<Either<Boolean, R>> ifTrue) {
new ArtifactOperationInfo(false, false, ArtifactOperationEnum.DOWNLOAD), artifactId, null, null, null, null, null, parentId,
containerComponentType);
ArtifactDefinition artifactDefinition;
- Either<ArtifactDefinition, Operation> insideValue = result;
- if (insideValue.isLeft()) {
- artifactDefinition = insideValue.left().value();
+ if (result.isLeft()) {
+ artifactDefinition = result.left().value();
} else {
- artifactDefinition = insideValue.right().value().getImplementationArtifact();
+ artifactDefinition = result.right().value().getImplementationArtifact();
}
// for tosca artifacts and heat env on VF level generated on download without saving
if (artifactDefinition.getPayloadData() != null) {
private Either<ArtifactDefinition, ResponseFormat> validateOrSetArtifactGroupType(ArtifactDefinition artifactInfo,
ArtifactDefinition currentArtifact) {
- if (Objects.nonNull(artifactInfo) && Objects.nonNull(currentArtifact)) {
+ if (null != artifactInfo && null != currentArtifact) {
if (artifactInfo.getArtifactGroupType() == null) {
artifactInfo.setArtifactGroupType(currentArtifact.getArtifactGroupType());
} else if (!currentArtifact.getArtifactGroupType().getType().equalsIgnoreCase(artifactInfo.getArtifactGroupType().getType())) {
}
private Either<Boolean, ResponseFormat> validateAndServiceApiUrl(ArtifactDefinition artifactInfo) {
- if (!ValidationUtils.validateStringNotEmpty(artifactInfo.getApiUrl())) {
+ if (StringUtils.isEmpty(artifactInfo.getApiUrl())) {
log.debug("Artifact url cannot be empty.");
return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_DATA, ARTIFACT_URL));
}
}
private Service validateServiceNameAndVersion(String serviceName, String serviceVersion) {
- Either<List<Service>, StorageOperationStatus> serviceListBySystemName = toscaOperationFacade
- .getBySystemName(ComponentTypeEnum.SERVICE, serviceName);
- if (serviceListBySystemName.isRight()) {
+ final Either<Service, StorageOperationStatus> serviceBySystemNameAndVersion
+ = toscaOperationFacade.getBySystemNameAndVersion(ComponentTypeEnum.SERVICE, serviceName, serviceVersion);
+ if (serviceBySystemNameAndVersion.isRight()) {
log.debug("Couldn't fetch any service with name {}", serviceName);
throw new ByActionStatusComponentException(
- componentsUtils.convertFromStorageResponse(serviceListBySystemName.right().value(), ComponentTypeEnum.SERVICE), serviceName);
+ componentsUtils.convertFromStorageResponse(serviceBySystemNameAndVersion.right().value(), ComponentTypeEnum.SERVICE), serviceName);
}
- List<Service> serviceList = serviceListBySystemName.left().value();
- if (serviceList == null || serviceList.isEmpty()) {
- log.debug("Couldn't fetch any service with name {}", serviceName);
- throw new ByActionStatusComponentException(ActionStatus.SERVICE_NOT_FOUND, serviceName);
- }
- Service foundService = null;
- for (Service service : serviceList) {
- if (service.getVersion().equals(serviceVersion)) {
- log.trace("Found service with version {}", serviceVersion);
- foundService = service;
- break;
- }
- }
- if (foundService == null) {
- log.debug("Couldn't find version {} for service {}", serviceVersion, serviceName);
- throw new ByActionStatusComponentException(ActionStatus.COMPONENT_VERSION_NOT_FOUND, ComponentTypeEnum.SERVICE.getValue(),
- serviceVersion);
- }
- return foundService;
+ return serviceBySystemNameAndVersion.left().value();
}
private Resource validateResourceNameAndVersion(String resourceName, String resourceVersion) {
List<HeatParameterDefinition> empltyHeatValues = new ArrayList<>();
for (HeatParameterDefinition heatParameterDefinition : heatParameters) {
String heatValue = heatParameterDefinition.getCurrentValue();
- if (!ValidationUtils.validateStringNotEmpty(heatValue)) {
+ if (StringUtils.isEmpty(heatValue)) {
heatValue = heatParameterDefinition.getDefaultValue();
- if (!ValidationUtils.validateStringNotEmpty(heatValue)) {
+ if (StringUtils.isEmpty(heatValue)) {
empltyHeatValues.add(heatParameterDefinition);
continue;
}
json.put(Constants.ARTIFACT_GROUP_TYPE, artifactGroupType.getType());
json.put(Constants.REQUIRED_ARTIFACTS, (updatedRequiredArtifacts == null || updatedRequiredArtifacts.isEmpty()) ? new ArrayList<>()
: updatedRequiredArtifacts.stream().filter(
- e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType()))
+ e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType()))
.map(ArtifactTemplateInfo::getFileName).collect(Collectors.toList()));
json.put(Constants.ARTIFACT_HEAT_PARAMS, (heatParameters == null || heatParameters.isEmpty()) ? new ArrayList<>() : heatParameters);
return json;
operation.setImplementation(implementationArtifact);
gotInterface.setOperationsMap(operationsMap);
Either<List<InterfaceDefinition>, StorageOperationStatus> interfaceDefinitionStorageOperationStatusEither = interfaceOperation
- .updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(gotInterface));
+ .updateInterfaces(storedComponent, Collections.singletonList(gotInterface));
if (interfaceDefinitionStorageOperationStatusEither.isRight()) {
StorageOperationStatus storageOperationStatus = interfaceDefinitionStorageOperationStatusEither.right().value();
ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForDataType(storageOperationStatus);