import com.google.gson.JsonElement;
import fj.data.Either;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Supplier;
-import javax.servlet.ServletContext;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.WebApplicationContext;
+import javax.servlet.ServletContext;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Supplier;
+
+
@org.springframework.stereotype.Component("propertyBusinessLogic")
public class PropertyBusinessLogic extends BaseBusinessLogic {
return webApplicationContext.getBean(class1);
}
- public Either<Map<String, DataTypeDefinition>, ResponseFormat> getAllDataTypes() {
+ public Map<String, DataTypeDefinition> getAllDataTypes() {
return getAllDataTypes(applicationDataTypeCache);
}
String userId) {
Either<EntryData<String, PropertyDefinition>, ResponseFormat> result = null;
- validateUserExists(userId, "create Property", false);
+ validateUserExists(userId);
Either<Component, StorageOperationStatus> serviceElement =
toscaOperationFacade.getToscaElement(componentId);
} else {
- Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
- if (allDataTypes.isRight()) {
- result = Either.right(allDataTypes.right().value());
- return result;
- }
-
- Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
+ Map<String, DataTypeDefinition> allDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newPropertyDefinition, dataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newPropertyDefinition, allDataTypes);
if (defaultValuesValidation.isRight()) {
result = Either.right(defaultValuesValidation.right().value());
return result;
String convertedValue = null;
if (newPropertyDefinition.getDefaultValue() != null) {
convertedValue = converter.convert(
- newPropertyDefinition.getDefaultValue(), innerType, allDataTypes.left().value());
+ newPropertyDefinition.getDefaultValue(), innerType, allDataTypes);
newPropertyDefinition.setDefaultValue(convertedValue);
}
}
return result;
}
}
-
result = Either.left(new EntryData<>(propertyName, newPropertyDefinition));
return result;
-
} finally {
commitOrRollback(result);
// unlock component
graphLockOperation.unlockComponent(componentId, nodeType);
}
-
}
/**
public Either<Map.Entry<String, PropertyDefinition>, ResponseFormat> getComponentProperty(String componentId, String propertyId, String userId) {
- validateUserExists(userId, "create Component Instance", false);
+ validateUserExists(userId);
// Get the resource from DB
Either<Component, StorageOperationStatus> status =
toscaOperationFacade.getToscaElement(componentId);
public Either<List<PropertyDefinition>, ResponseFormat> getPropertiesList(String componentId,
String userId) {
- validateUserExists(userId, "create Component Instance", false);
+ validateUserExists(userId);
// Get the resource from DB
ComponentParametersView filter = new ComponentParametersView(true);
Either<Map.Entry<String, PropertyDefinition>, ResponseFormat> result = null;
- validateUserExists(userId, "delete Property", false);
+ validateUserExists(userId);
// Get the resource from DB
Either<Component, StorageOperationStatus> getComponentRes = toscaOperationFacade.getToscaElement(componentId);
}
Optional<PropertyDefinition> propertyCandidate =
- properties.stream().filter(property -> property.getName().equals(propertyName))
- .findAny();
+ properties.stream().filter(property -> property.getName().equals(propertyName))
+ .findAny();
return propertyCandidate.isPresent();
}