import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
* @param userId
* @return AttributeDefinition if created successfully Or ResponseFormat
*/
- public Either<AttributeDefinition, ResponseFormat> createAttribute(String resourceId, AttributeDefinition newAttributeDef, String userId) {
- Either<AttributeDefinition, ResponseFormat> result = null;
+ public Either<PropertyDefinition, ResponseFormat> createAttribute(String resourceId, PropertyDefinition newAttributeDef, String userId) {
+ Either<PropertyDefinition, ResponseFormat> result = null;
Either<User, ResponseFormat> resp = validateUserExists(userId, "create Attribute", false);
if (resp.isRight()) {
return Either.right(resp.right().value());
// add the new attribute to resource on graph
// need to get StorageOpaerationStatus and convert to ActionStatus from
// componentsUtils
- Either<AttributeDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
+ Either<PropertyDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
if (either.isRight()) {
result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()), resource.getName()));
return result;
}
- private boolean isAttributeExist(List<AttributeDefinition> attributes, String resourceUid, String propertyName) {
+ private boolean isAttributeExist(List<PropertyDefinition> attributes, String resourceUid, String propertyName) {
boolean isExist = false;
if (attributes != null) {
isExist = attributes.stream().filter(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getParentUniqueId(), resourceUid)).findAny().isPresent();
* @param userId
* @return
*/
- public Either<AttributeDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
+ public Either<PropertyDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
Either<User, ResponseFormat> resp = validateUserExists(userId, "get Attribute", false);
if (resp.isRight()) {
}
Resource resource = status.left().value();
- List<AttributeDefinition> attributes = resource.getAttributes();
+ List<PropertyDefinition> attributes = resource.getAttributes();
if (attributes == null) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
} else {
- Either<AttributeDefinition, ResponseFormat> result;
+ Either<PropertyDefinition, ResponseFormat> result;
// verify attribute exist in resource
- Optional<AttributeDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
+ Optional<PropertyDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
if (optionalAtt.isPresent()) {
result = Either.left(optionalAtt.get());
* @param userId
* @return
*/
- public Either<AttributeDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, AttributeDefinition newAttDef, String userId) {
- Either<AttributeDefinition, ResponseFormat> result = null;
+ public Either<PropertyDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, PropertyDefinition newAttDef, String userId) {
+ Either<PropertyDefinition, ResponseFormat> result = null;
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
}
// verify attribute exist in resource
- Either<AttributeDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
+ Either<PropertyDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
}
- Either<AttributeDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
+ Either<PropertyDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
if (eitherAttUpdate.isRight()) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, eitherAttUpdate.right().value());
* @param userId
* @return
*/
- public Either<AttributeDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
+ public Either<PropertyDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
- Either<AttributeDefinition, ResponseFormat> result = null;
+ Either<PropertyDefinition, ResponseFormat> result = null;
Either<User, ResponseFormat> resp = validateUserExists(userId, "delete Attribute", false);
if (resp.isRight()) {
}
// verify attribute exist in resource
- Either<AttributeDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
+ Either<PropertyDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
if (eitherAttributeExist.isRight()) {
return Either.right(eitherAttributeExist.right().value());
}