return new ByResponseFormatComponentException(error);
});
} else {
- return toscaExportUtils.exportComponent(parent).left().map(toscaRepresentation -> {
+ return toscaExportUtils.exportComponent(parent, checkIfSkipImports(parent.getModel())).left().map(toscaRepresentation -> {
log.debug("Tosca yaml exported for component {} ", parent.getUniqueId());
return toscaRepresentation.getMainYaml();
}).right().map(toscaError -> {
}
}
+ private boolean checkIfSkipImports(final String model) {
+ return null != model && !model.equalsIgnoreCase("ETSI SOL001 v2.5.1")
+ && !model.equalsIgnoreCase("AUTOMATION COMPOSITION");
+ }
+
private Either<ArtifactDefinition, Operation> doAction(String componentId, ComponentTypeEnum componentType, ArtifactOperationInfo operation,
String artifactId, ArtifactDefinition artifactInfo, String origMd5, String originData,
String interfaceName, String operationName, AuditingActionEnum auditingAction, User user,
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<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);
- }
- 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);
+ componentsUtils.convertFromStorageResponse(serviceBySystemNameAndVersion.right().value(), ComponentTypeEnum.SERVICE), serviceName);
}
- 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;
}
errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status)));
}
if (errorWrapper.isEmpty()) {
- NodeTypeEnum parentType = convertParentType(componentType);
final List<ArtifactDefinition> existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), null);
for (ArtifactDefinition artifactDefinition : existingDeploymentArtifacts) {
if (artifactInfo.getArtifactName().equalsIgnoreCase(artifactDefinition.getArtifactName())) {
String componentId = component.getUniqueId();
String artifactId = artifactDefinition.getUniqueId();
Either<ArtifactDefinition, Operation> result;
- Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
//artifact validation
artifactDefinition = validateArtifact(componentId, componentType, operation, artifactId, artifactDefinition, auditingAction, user, component,
shouldLock, inTransaction);
}
private Component checkoutParentComponent(ComponentTypeEnum componentType, String parentId, String userId) {
- Component component = null;
User modifier = userBusinessLogic.getUser(userId, false);
LifecycleChangeInfoWithAction changeInfo = new LifecycleChangeInfoWithAction("External API checkout",
LifecycleChanceActionEnum.UPDATE_FROM_EXTERNAL_API);