@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); }
private void createNewFilesOnDIP(StorageService storage, ModelService model, List<File> unchangedFiles, String newRepresentationID, boolean notify) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, UnsupportedOperationException, IOException, AlreadyExistsException { for (File f : unchangedFiles) { StoragePath fileStoragePath = ModelUtils.getFileStoragePath(f); Binary binary = storage.getBinary(fileStoragePath); Path uriPath = Paths.get(binary.getContent().getURI()); ContentPayload payload = new FSPathContentPayload(uriPath); model.createDIPFile(newRepresentationID, f.getPath(), f.getId(), uriPath.toFile().length(), payload, notify); } }
fileInfo.add(file.getRepresentationId()); } else if (fieldName.equalsIgnoreCase(InventoryReportPlugin.CSV_FIELD_FILE_PATH)) { fileInfo.add(FSUtils.asString(file.getPath())); } else if (fieldName.equalsIgnoreCase(InventoryReportPlugin.CSV_FIELD_FILE_ID)) { fileInfo.add(file.getId());
/************************************************/ 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()); }
private void createNewFilesOnRepresentation(StorageService storage, ModelService model, List<File> unchangedFiles, String newRepresentationID, boolean notify) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, UnsupportedOperationException, IOException, AlreadyExistsException { for (File f : unchangedFiles) { StoragePath fileStoragePath = ModelUtils.getFileStoragePath(f); Binary binary = storage.getBinary(fileStoragePath); Path uriPath = Paths.get(binary.getContent().getURI()); ContentPayload payload = new FSPathContentPayload(uriPath); model.createFile(f.getAipId(), newRepresentationID, f.getPath(), f.getId(), payload, notify); } }
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; }
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); } } }
PluginHelper.createPluginEvent(this, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), model, index, null, null, reportItem.getPluginState(), "", notify); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException
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 <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.setAipId(file.getAipId()); incidence.setRepresentationId(file.getRepresentationId()); incidence.setFilePath(file.getPath()); incidence.setFileId(file.getId()); incidence.setObjectClass(File.class.getSimpleName()); PluginHelper.createPluginEvent(this, file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), model, index, null, null, state, "", true); } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException
model.deleteFile(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), true); } catch (NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { state = PluginState.FAILURE; new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_REPRESENTATION_ID, file.getRepresentationId()), new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_FILE_PATH_COMPUTED, StringUtils.join(file.getPath(), RodaConstants.RISK_INCIDENCE_FILE_PATH_COMPUTED_SEPARATOR)), new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_FILE_ID, file.getId())); deleteRelatedIncidences(model, index, incidenceFilter); sources.add(PluginHelper.getLinkingIdentifier(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), RodaConstants.PRESERVATION_LINKING_OBJECT_SOURCE)); model.createEvent(file.getAipId(), file.getRepresentationId(), file.getPath(), file.getId(), PreservationEventType.DELETION, EVENT_DESCRIPTION, sources, null, state, outcomeText, details, job.getUsername(), true);