use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderEventService method updateEventsWithChildrenAndIssues.
@Override
public void updateEventsWithChildrenAndIssues(Long id) {
String folderType = EventObjectType.FOLDER.name().toLowerCase();
eventManager.addUpdateEvent(folderType, id);
eventManager.addUpdateEventsForIssues(id, AclClass.FOLDER);
Folder folder = folderManager.load(id);
ListUtils.emptyIfNull(folder.getChildFolders()).forEach(childFolder -> updateEventsWithChildrenAndIssues(childFolder.getId()));
ListUtils.emptyIfNull(folder.getPipelines()).forEach(pipeline -> pipelineEventService.updateEventsWithChildrenAndIssues(pipeline.getId()));
ListUtils.emptyIfNull(folder.getStorages()).forEach(storage -> dataStorageEventService.updateEventsWithChildrenAndIssues(storage.getId()));
ListUtils.emptyIfNull(folder.getConfigurations()).forEach(runConfiguration -> configurationEventService.updateEventsWithChildrenAndIssues(runConfiguration.getId()));
folder.getMetadata().keySet().forEach(metadataClass -> ListUtils.emptyIfNull(metadataEntityManager.loadMetadataEntityByClassNameAndFolderId(id, metadataClass)).forEach(metadataEntity -> metadataEntityEventService.updateEventsWithChildrenAndIssues(metadataEntity.getId())));
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class MetadataUploadManager method readFile.
private MetadataParsingResult readFile(Long parentId, MultipartFile file) {
try {
final Folder parent = folderManager.load(parentId);
String delimiter = MetadataParsingUtils.getDelimiterFromFileExtension(file.getOriginalFilename());
byte[] inputData = file.getBytes();
MetadataHeader header = new MetadataEntityHeaderParser(delimiter).readHeader(ByteSource.wrap(inputData).openStream());
validateTypes(header, parentId);
MetadataClass metadataClass = getOrCreateClass(header.getClassName());
return new MetadataEntityReader(delimiter, parent, metadataClass).readData(ByteSource.wrap(inputData).openStream(), header.getFields());
} catch (IOException e) {
throw new MetadataReadingException(e.getMessage(), e);
}
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method loadByNameOrId.
/**
* Tries to find a {@link Folder} entity by some pathOrIdentifier.
* If identifier is a number, it is interpreted as ID and will be loaded from DB by primary key.
* Otherwise pathOrIdentifier is interpreted as full path to folder like:
* /root/parent/folder-name
* and method will try to resolve folder hierarchy from this path.
* @param pathOrIdentifier specifies folder to look for
* @return {@link Folder} entity if present
* @throws IllegalArgumentException if {@link Folder} pathOrIdentifier not found
*/
@Override
public Folder loadByNameOrId(String pathOrIdentifier) {
Folder folder = null;
String path = pathOrIdentifier;
try {
folder = folderDao.loadFolder(Long.parseLong(path));
} catch (NumberFormatException e) {
LOGGER.trace(e.getMessage(), e);
}
if (folder == null) {
Long parentId = null;
if (path.startsWith("/")) {
path = path.substring(1);
}
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
String[] pathComponents = path.split("/");
for (String name : pathComponents) {
folder = loadByNameAndParentId(name, parentId);
if (folder == null) {
break;
} else {
parentId = folder.getId();
}
}
}
Assert.notNull(folder, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NOT_FOUND, path));
folder.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(folder.getId(), AclClass.FOLDER)));
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method load.
/**
* Loads {@link Folder} specified by id parameter
* @param id to find
* @return {@link Folder} entity if present
* @throws IllegalArgumentException if {@link Folder} id not found
*/
@Override
public Folder load(Long id) {
Folder folder = folderDao.loadFolder(id);
Assert.notNull(folder, messageHelper.getMessage(MessageConstants.ERROR_FOLDER_NOT_FOUND, id));
folder.setHasMetadata(metadataManager.hasMetadata(new EntityVO(id, AclClass.FOLDER)));
return folder;
}
use of com.epam.pipeline.entity.pipeline.Folder in project cloud-pipeline by epam.
the class FolderCrudManager method changeOwner.
/**
* Assigns a specified user as a new owner of a folder
* @param id of {@link Folder} entity
* @param owner new owner of an enitity
* @return updated {@link Folder}
*/
@Override
@Transactional(propagation = Propagation.REQUIRED)
public AbstractSecuredEntity changeOwner(Long id, String owner) {
final Folder folder = load(id);
folder.setOwner(owner);
folderDao.updateFolder(folder);
return folder;
}
Aggregations