@JsonIgnore public void addFileData(String aipId, String representationUUID, File file) { if (!updatedData.containsKey(aipId)) { updatedData.put(aipId, new HashMap<String, List<String>>()); } else if (updatedData.get(aipId).containsKey(RodaConstants.RODA_OBJECT_REPRESENTATION) && updatedData.get(aipId).get(RodaConstants.RODA_OBJECT_REPRESENTATION).contains(representationUUID)) { return; } Map<String, List<String>> map = updatedData.get(aipId); if (!updatedData.get(aipId).containsKey(RodaConstants.RODA_OBJECT_FILE)) { map.put(RodaConstants.RODA_OBJECT_FILE, new ArrayList<String>()); } StringBuilder builder = new StringBuilder(); builder.append(file.getRepresentationId()); for (String path : file.getPath()) { builder.append("/").append(path); } builder.append("/").append(file.getId()); map.get(RodaConstants.RODA_OBJECT_FILE).add(builder.toString()); return; } }
private static <T extends IsRODAObject> Optional<LiteRODAObject> getFile(T object) { File o = (File) object; List<String> list = new ArrayList<>(); list.add(o.getAipId()); list.add(o.getRepresentationId()); list.addAll(o.getPath()); list.add(o.getId()); return get(File.class, list, false); }
public static void createPremisSkeletonOnFile(ModelService model, File file, Collection<String> fixityAlgorithms) throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException, ValidationException, XmlException, IOException { gov.loc.premis.v3.Representation representation; try { Binary preservationObject = model.retrievePreservationRepresentation(file.getAipId(), file.getRepresentationId()); representation = PremisV3Utils.binaryToRepresentation(preservationObject.getContent(), false); } catch (NotFoundException e) { representation = PremisV3Utils.createBaseRepresentation(file.getAipId(), file.getRepresentationId()); } PremisSkeletonPluginUtils.createPremisSkeletonOnFile(model, file, fixityAlgorithms, representation); }
fileInfo.add(file.getAipId()); } else if (fieldName.equalsIgnoreCase(InventoryReportPlugin.CSV_FIELD_REPRESENTATION_ID)) { fileInfo.add(file.getRepresentationId()); } else if (fieldName.equalsIgnoreCase(InventoryReportPlugin.CSV_FIELD_FILE_PATH)) { fileInfo.add(FSUtils.asString(file.getPath()));
} else { for (File file : alteredFiles) { premisSourceFilesIdentifiers.add(PluginHelper.getLinkingIdentifier(aipId, file.getRepresentationId(), file.getPath(), file.getId(), RodaConstants.PRESERVATION_LINKING_OBJECT_SOURCE)); premisTargetFilesIdentifiers.add(PluginHelper.getLinkingIdentifier(aipId, file.getRepresentationId(), file.getPath(), file.getId(), RodaConstants.PRESERVATION_LINKING_OBJECT_OUTCOME));
/************************************************/ public CloseableIterable<OptionalWithCause<File>> listFilesUnder(File f, boolean recursive) throws NotFoundException, GenericException, RequestNotValidException, AuthorizationDeniedException { return listFilesUnder(f.getAipId(), f.getRepresentationId(), f.getPath(), f.getId(), recursive); }
public File updateFile(File file, ContentPayload contentPayload, boolean createIfNotExists, boolean notify) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException { return updateFile(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), contentPayload, createIfNotExists, notify); }
public Binary retrievePreservationFile(File file) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException { return retrievePreservationFile(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId()); }
public static StoragePath getFileStoragePath(File f) throws RequestNotValidException { return getFileStoragePath(f.getAipId(), f.getRepresentationId(), f.getPath(), f.getId()); }
private String getFileFulltext(File file) { String fulltext = ""; try { Binary fulltextBinary = RodaCoreFactory.getModelService().retrieveOtherMetadataBinary(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), RodaConstants.TIKA_FILE_SUFFIX_FULLTEXT, RodaConstants.OTHER_METADATA_TYPE_APACHE_TIKA); if (fulltextBinary.getSizeInBytes() < RodaCoreFactory.getRodaConfigurationAsInt(TEN_MB_IN_BYTES, "core.index.fulltext_threshold_in_bytes")) { try (InputStream inputStream = fulltextBinary.getContent().createInputStream()) { fulltext = IOUtils.toString(inputStream, Charset.forName(RodaConstants.DEFAULT_ENCODING)); } } } catch (RequestNotValidException | GenericException | AuthorizationDeniedException | IOException e) { LOGGER.warn("Error getting fulltext for file: {}", file, e); } catch (NotFoundException e) { LOGGER.trace("Fulltext not found for file: {}", file, e); } return fulltext; }
public static String getFileId(File file) { return getFileId(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId()); }
} else { toAIP = file.getAipId(); toRepresentation = file.getRepresentationId(); model.createUpdateAIPEvent(file.getAipId(), file.getRepresentationId(), null, null, PreservationEventType.UPDATE, EVENT_DESCRIPTION, state, outcomeText.toString(), details, job.getUsername(), true);
public File moveFile(File file, String newAipId, String newRepresentationId, List<String> newDirectoryPath, String newId, boolean reindexResources) throws AlreadyExistsException, GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); StoragePath fileStoragePath = ModelUtils.getFileStoragePath(file); if (!storage.exists(fileStoragePath)) { throw new NotFoundException("File/folder '" + fileStoragePath.toString() + "' were moved or do not exist"); } File newFile = new File(newId, newAipId, newRepresentationId, newDirectoryPath, file.isDirectory()); StoragePath newFileStoragePath = ModelUtils.getFileStoragePath(newFile); storage.move(storage, fileStoragePath, newFileStoragePath); if (reindexResources) { notifyRepresentationUpdated(retrieveRepresentation(newAipId, newRepresentationId)).failOnError(); if (!newAipId.equals(file.getAipId()) || !newRepresentationId.equals(file.getRepresentationId())) { notifyRepresentationUpdated(retrieveRepresentation(file.getAipId(), file.getRepresentationId())).failOnError(); } } return newFile; }
public File renameFolder(File folder, String newName, boolean reindexResources) throws AlreadyExistsException, GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); StoragePath folderStoragePath = ModelUtils.getFileStoragePath(folder); if (storage.hasDirectory(folderStoragePath)) { List<String> newFolderPathList = new ArrayList<>(); newFolderPathList.add(folderStoragePath.getContainerName()); newFolderPathList.addAll(folderStoragePath.getDirectoryPath()); newFolderPathList.add(newName); StoragePath newFileStoragePath = DefaultStoragePath.parse(newFolderPathList); storage.move(storage, folderStoragePath, newFileStoragePath); if (reindexResources) { notifyAipUpdated(folder.getAipId()); } return retrieveFile(folder.getAipId(), folder.getRepresentationId(), folder.getPath(), newName); } else { throw new NotFoundException("Folder was moved or does not exist"); } }
@Override public ReturnWithExceptions<Void, ModelObserver> fileUpdated(File file) { ReturnWithExceptions<Void, ModelObserver> ret = fileDeleted(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), false); fileCreated(file).addTo(ret); return ret; }
LOGGER.debug("Processing file {} from representation {} from AIP {}", file.getId(), file.getRepresentationId(), file.getAipId()); Report reportItem = PluginHelper.initPluginReportItem(this, IdUtils.getFileId(file), File.class, AIPState.ACTIVE); PluginHelper.createPluginEvent(this, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), model, index, null, null, reportItem.getPluginState(), "", notify); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException
LOGGER.debug("Processing file {} from representation {} of AIP {}", file.getId(), file.getRepresentationId(), file.getAipId()); List<LinkingIdentifier> outcomes = null; boolean notify = true; PluginHelper.createPluginEvent(this, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), model, index, sources, outcomes, reportItem.getPluginState(), "", notify); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException
public static void createPremisSkeletonOnFile(ModelService model, File file, Collection<String> fixityAlgorithms, gov.loc.premis.v3.Representation representation) throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException, ValidationException, XmlException, IOException { boolean notifyInSteps = false; if (!file.isDirectory()) { LOGGER.debug("Processing {}", file); try { model.retrievePreservationFile(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId()); } catch (NotFoundException e) { ContentPayload filePreservation = PremisV3Utils.createBaseFile(file, model, fixityAlgorithms); String pmId; try { PreservationMetadata pm = model.createPreservationMetadata(PreservationMetadataType.FILE, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), filePreservation, notifyInSteps); pmId = pm.getId(); model.notifyFileCreated(file).failOnError(); } catch (AlreadyExistsException e1) { pmId = IdUtils.getPreservationFileId(file.getId()); model.updatePreservationMetadata(pmId, PreservationMetadataType.FILE, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), filePreservation, notifyInSteps); model.notifyFileUpdated(file).failOnError(); } PremisV3Utils.linkFileToRepresentation(pmId, RodaConstants.PREMIS_RELATIONSHIP_TYPE_STRUCTURAL, RodaConstants.PREMIS_RELATIONSHIP_SUBTYPE_HASPART, representation); } } }
public static <T extends IsRODAObject> List<LinkingIdentifier> runSiegfriedOnFile(ModelService model, File file) throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException, PluginException { StoragePath fileStoragePath = ModelUtils.getFileStoragePath(file); try (DirectResourceAccess directAccess = model.getStorage().getDirectAccess(fileStoragePath)) { Path filePath = directAccess.getPath(); List<LinkingIdentifier> sources = runSiegfriedOnRepresentationOrFile(model, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), filePath); model.notifyFileUpdated(file).failOnError(); return sources; } catch (IOException e) { throw new GenericException(e); } }
incidence.setRiskId(riskId); incidence.setAipId(file.getAipId()); incidence.setRepresentationId(file.getRepresentationId()); incidence.setFilePath(file.getPath()); incidence.setFileId(file.getId()); PluginHelper.createPluginEvent(this, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), model, index, null, null, state, "", true); } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException