Search in sources :

Example 1 with UpdateDataStorageItemVO

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;
}
Also used : AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) UpdateDataStorageItemVO(com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO) AbstractDataStorageItem(com.epam.pipeline.entity.datastorage.AbstractDataStorageItem) ArrayList(java.util.ArrayList)

Example 2 with UpdateDataStorageItemVO

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);
}
Also used : MessageConstants(com.epam.pipeline.common.MessageConstants) LoggerFactory(org.slf4j.LoggerFactory) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) Autowired(org.springframework.beans.factory.annotation.Autowired) CompletableFuture(java.util.concurrent.CompletableFuture) StringUtils(org.apache.commons.lang3.StringUtils) MessageHelper(com.epam.pipeline.common.MessageHelper) Propagation(org.springframework.transaction.annotation.Propagation) Service(org.springframework.stereotype.Service) DateUtils(com.epam.pipeline.entity.utils.DateUtils) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Logger(org.slf4j.Logger) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Attachment(com.epam.pipeline.entity.issue.Attachment) AccessDeniedException(org.springframework.security.access.AccessDeniedException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) DataStorageFile(com.epam.pipeline.entity.datastorage.DataStorageFile) Objects(java.util.Objects) List(java.util.List) DataStorageStreamingContent(com.epam.pipeline.entity.datastorage.DataStorageStreamingContent) AuthManager(com.epam.pipeline.manager.security.AuthManager) UpdateDataStorageItemVO(com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO) DataStorageManager(com.epam.pipeline.manager.datastorage.DataStorageManager) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) InputStream(java.io.InputStream) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) UpdateDataStorageItemVO(com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO) AccessDeniedException(org.springframework.security.access.AccessDeniedException)

Aggregations

UpdateDataStorageItemVO (com.epam.pipeline.controller.vo.data.storage.UpdateDataStorageItemVO)2 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)2 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 AbstractDataStorageItem (com.epam.pipeline.entity.datastorage.AbstractDataStorageItem)1 DataStorageFile (com.epam.pipeline.entity.datastorage.DataStorageFile)1 DataStorageStreamingContent (com.epam.pipeline.entity.datastorage.DataStorageStreamingContent)1 Attachment (com.epam.pipeline.entity.issue.Attachment)1 DateUtils (com.epam.pipeline.entity.utils.DateUtils)1 DataStorageManager (com.epam.pipeline.manager.datastorage.DataStorageManager)1 PreferenceManager (com.epam.pipeline.manager.preference.PreferenceManager)1 SystemPreferences (com.epam.pipeline.manager.preference.SystemPreferences)1 AuthManager (com.epam.pipeline.manager.security.AuthManager)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1