use of com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO in project cloud-pipeline by epam.
the class DataStorageManager method updateDataStorageItems.
public List<AbstractDataStorageItem> updateDataStorageItems(final Long dataStorageId, List<UpdateDataStorageItemVO> list) throws DataStorageException {
AbstractDataStorage dataStorage = load(dataStorageId);
List<AbstractDataStorageItem> updatedItems = new ArrayList<>();
for (UpdateDataStorageItemVO item : list) {
updatedItems.add(updateDataStorageItem(dataStorage, item));
}
return updatedItems;
}
use of com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO in project cloud-pipeline by epam.
the class AttachmentFileManager method deleteAttachments.
/**
* Deletes attachments. Deletes records from DB transactionally and files from Data Storage in async mode.
* @param attachments attachments to delete
*/
public void deleteAttachments(List<Attachment> attachments) {
String systemDataStorageName = preferenceManager.getPreference(SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME);
if (StringUtils.isBlank(systemDataStorageName)) {
LOGGER.debug(messageHelper.getMessage(MessageConstants.ERROR_ATTACHMENT_SYSTEM_DATA_STORAGE_NOT_CONFIGURED));
return;
}
AbstractDataStorage attachmentStorage = dataStorageManager.loadByNameOrId(systemDataStorageName);
CompletableFuture.runAsync(() -> {
List<UpdateDataStorageItemVO> itemsToDelete = attachments.stream().map(a -> {
UpdateDataStorageItemVO updateVO = new UpdateDataStorageItemVO();
updateVO.setPath(a.getPath());
return updateVO;
}).collect(Collectors.toList());
try {
dataStorageManager.deleteDataStorageItems(attachmentStorage.getId(), itemsToDelete, attachmentStorage.isVersioningEnabled());
} catch (Exception e) {
LOGGER.error("Error while deleting attachments:", e);
}
});
attachmentManager.deleteAttachments(attachments);
}
Aggregations