@Override public Storage createStorage(StorageCreateRequest storageCreateRequest){
  validateStorageCreateRequest(storageCreateRequest);
  StoragePlatformEntity storagePlatformEntity=storagePlatformHelper.getStoragePlatformEntity(storageCreateRequest.getStoragePlatformName());
  StorageEntity storageEntity=storageDao.getStorageByName(storageCreateRequest.getName());
  if (storageEntity != null) {
    throw new AlreadyExistsException(String.format("Storage with name \"%s\" already exists.",storageCreateRequest.getName()));
  }
  storageEntity=new StorageEntity();
  storageEntity.setName(storageCreateRequest.getName());
  storageEntity.setStoragePlatform(storagePlatformEntity);
  if (!CollectionUtils.isEmpty(storageCreateRequest.getAttributes())) {
    List<StorageAttributeEntity> attributeEntities=new ArrayList<>();
    storageEntity.setAttributes(attributeEntities);
    for (    Attribute attribute : storageCreateRequest.getAttributes()) {
      StorageAttributeEntity attributeEntity=new StorageAttributeEntity();
      attributeEntities.add(attributeEntity);
      attributeEntity.setStorage(storageEntity);
      attributeEntity.setName(attribute.getName());
      attributeEntity.setValue(attribute.getValue());
    }
  }
  storageEntity=storageDao.saveAndRefresh(storageEntity);
  return createStorageFromEntity(storageEntity);
}

@ Override public Storage createStorage ( StorageCreateRequest storageCreateRequest ) { validateStorageCreateRequest ( storageCreateRequest ) ; StoragePlatformEntity storagePlatformEntity = storagePlatformHelper . getStoragePlatformEntity ( storageCreateRequest . getStoragePlatformName ( ) ) ; StorageEntity storageEntity = storageDao . getStorageByName ( storageCreateRequest . getName ( ) ) ; if ( storageEntity != null ) { throw new AlreadyExistsException ( String . format ( "Storage with name \"%s\" already exists." , storageCreateRequest . getName ( ) ) ) ; } storageEntity = new StorageEntity ( ) ; storageEntity . setName ( storageCreateRequest . getName ( ) ) ; storageEntity . setStoragePlatform ( storagePlatformEntity ) ; if ( ! CollectionUtils . isEmpty ( storageCreateRequest . getAttributes ( ) ) ) { List < StorageAttributeEntity > attributeEntities = new ArrayList < > ( ) ; storageEntity . setAttributes ( attributeEntities ) ; for ( Attribute attribute : storageCreateRequest . getAttributes ( ) ) { StorageAttributeEntity attributeEntity = new StorageAttributeEntity ( ) ; attributeEntities . add ( attributeEntity ) ; attributeEntity . setStorage ( storageEntity ) ; attributeEntity . setName ( attribute . getName ( ) ) ; attributeEntity . setValue ( attribute . getValue ( ) ) ; } } storageEntity = storageDao . saveAndRefresh ( storageEntity ) ; return createStorageFromEntity ( storageEntity ) ; }
creates a new storage .
