public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
private static final Logger log = Logger.getLogger(ComponentBusinessLogic.class.getName());
+
protected final GroupBusinessLogic groupBusinessLogic;
protected ArtifactsBusinessLogic artifactsBusinessLogic;
protected GenericTypeBusinessLogic genericTypeBusinessLogic;
*/
public abstract Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String componentId,
List<String> dataParamsToReturn);
+
+ public Either<ComponentMetadataData, StorageOperationStatus> getComponentMetadata(final String componentId) {
+ return toscaOperationFacade.getComponentMetadata(componentId);
+ }
User validateUser(User user, String ecompErrorContext, Component component, AuditingActionEnum auditAction, boolean inTransaction) {
User validatedUser;
log.debug("validate Icon");
ComponentTypeEnum type = component.getComponentType();
String icon = component.getIcon();
- if (!ValidationUtils.validateStringNotEmpty(icon)) {
+ if (StringUtils.isEmpty(icon)) {
log.info("icon is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_ICON, type.getValue());
componentsUtils.auditComponentAdmin(errorResponse, user, component, actionEnum, type);
}
}
- public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponentsMetadata(boolean isAbstractAbstract,
- HighestFilterEnum highestFilter,
- ComponentTypeEnum componentTypeEnum,
- String internalComponentType, String userId,
- String modelName) {
+ public Either<List<Component>, ResponseFormat> getLatestVersionNotAbstractComponentsMetadata(final boolean isAbstractAbstract,
+ final HighestFilterEnum highestFilter,
+ final ComponentTypeEnum componentTypeEnum,
+ final String internalComponentType, String userId,
+ final String modelName,
+ final boolean includeNormativeExtensionModels) {
Either<List<Component>, StorageOperationStatus> nonCheckoutCompResponse = null;
try {
validateUserExists(userId);
- nonCheckoutCompResponse = toscaOperationFacade
- .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName);
+ nonCheckoutCompResponse = toscaOperationFacade
+ .getLatestVersionNotAbstractMetadataOnly(isAbstractAbstract, componentTypeEnum, internalComponentType, modelName,
+ includeNormativeExtensionModels);
if (nonCheckoutCompResponse.isLeft()) {
log.debug("Retrieved Resource successfully.");
return Either.left(nonCheckoutCompResponse.left().value());
return Either
.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(nonCheckoutCompResponse.right().value())));
} finally {
- if(nonCheckoutCompResponse != null && nonCheckoutCompResponse.isLeft() ) {
+ if (nonCheckoutCompResponse != null && nonCheckoutCompResponse.isLeft()) {
janusGraphDao.commit();
}
}
throw new ByResponseFormatComponentException(
componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
}
- ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
- .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().get();
+
+ final ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
+ .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().orElseThrow(() -> {
+ throw new ByResponseFormatComponentException(
+ componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND, ArtifactTypeEnum.TOSCA_CSAR.name()));
+ });
return artifactsBusinessLogic.handleDownloadToscaModelRequest(component, csarArtifact);
}
});
return componentNonGenericInputs;
}
-
+
protected void generatePropertiesFromGenericType(final Component component, final Resource genericType) {
if (CollectionUtils.isEmpty(genericType.getProperties())) {
return;
}
component.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(null));
}
+
protected <T extends Component> Resource fetchAndSetDerivedFromGenericType(final T component) {
return fetchAndSetDerivedFromGenericType(component, null);
}
protected <T extends Component> Resource fetchAndSetDerivedFromGenericType(final T component, final String toscaType) {
+ final Resource genericTypeResource = fetchDerivedFromGenericType(component, toscaType);
+ component.setDerivedFromGenericInfo(genericTypeResource);
+ return genericTypeResource;
+ }
+
+ public <T extends Component> Resource fetchDerivedFromGenericType(final T component, final String toscaType) {
final Either<Resource, ResponseFormat> genericTypeEither = this.genericTypeBusinessLogic.fetchDerivedFromGenericType(component, toscaType);
if (genericTypeEither.isRight()) {
- log.debug("Failed to fetch latest generic type for component {} of type", component.getName(), component.assetType());
+ log.debug("Failed to fetch latest generic type for component {} of type {}", component.getName(), component.assetType());
throw new ByActionStatusComponentException(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType());
}
- final Resource genericTypeResource = genericTypeEither.left().value();
- component.setDerivedFromGenericInfo(genericTypeResource);
- return genericTypeResource;
+ return genericTypeEither.left().value();
}
+
public Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> getFilteredComponentInstanceProperties(String componentId,
Map<FilterKeyEnum, List<String>> filters,
String userId) {
if (validPropertiesMerge.isRight()) {
if (log.isDebugEnabled()) {
log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic",
- validPropertiesMerge.right().value());
+ validPropertiesMerge.right().value());
}
return false;
}
if (validAttributesMerge.isRight()) {
if (log.isDebugEnabled()) {
log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic",
- validAttributesMerge.right().value());
+ validAttributesMerge.right().value());
}
return false;
}
protected Either<Component, ResponseFormat> updateCatalog(Component component, ChangeTypeEnum changeStatus) {
if (log.isDebugEnabled()) {
log.debug("update Catalog start with Component Type {} And Componet Name {} with change status {}",
- component.getComponentType().name(),component.getName(), changeStatus.name());
+ component.getComponentType().name(), component.getName(), changeStatus.name());
}
ActionStatus status = catalogOperations.updateCatalog(changeStatus, component);
if (status != ActionStatus.OK) {