public static <T extends IsRODAObject> Report initPluginReportItem(Plugin<T> plugin, TransferredResource transferredResource) { return initPluginReportItem(plugin, Report.NO_OUTCOME_OBJECT_ID, transferredResource.getUUID()) .setSourceObjectClass(TransferredResource.class.getName()).setOutcomeObjectClass(AIP.class.getName()) .setOutcomeObjectState(AIPState.INGEST_PROCESSING).setSourceObjectOriginalName(transferredResource.getName()); }
.replace(baseFolder + "/" + unsuccessFolder + "/", "")); } else { newResourcePath = newResourcePath.resolve(resource.getName());
private void processTransferredResource(IndexService index, ModelService model, Report report, Job job, TransferredResource transferredResource) { Report reportItem = PluginHelper.initPluginReportItem(this, transferredResource); Path bagitPath = Paths.get(transferredResource.getFullPath()); try { LOGGER.debug("Converting {} to AIP", bagitPath); SIP bagit = BagitSIP.parse(bagitPath); Optional<String> computedParentId = PluginHelper.getComputedParent(model, index, bagit.getAncestors(), computedSearchScope, forceSearchScope, job.getId()); AIP aipCreated = BagitToAIPPluginUtils.bagitToAip(bagit, model, METADATA_FILE, Arrays.asList(transferredResource.getName()), reportItem.getJobId(), computedParentId, job.getUsername(), PermissionUtils.getIngestPermissions(job.getUsername()), transferredResource.getUUID()); PluginHelper.createSubmission(model, createSubmission, bagitPath, aipCreated.getId()); createUnpackingEventSuccess(model, index, transferredResource, aipCreated, UNPACK_DESCRIPTION); reportItem.setSourceAndOutcomeObjectId(reportItem.getSourceObjectId(), aipCreated.getId()) .setPluginState(PluginState.SUCCESS); if (aipCreated.getParentId() == null && computedParentId.isPresent()) { reportItem.setPluginDetails(String.format("Parent with id '%s' not found", computedParentId.get())); } createWellformedEventSuccess(model, index, transferredResource, aipCreated); LOGGER.debug("Done with converting {} to AIP {}", bagitPath, aipCreated.getId()); } catch (RODAException | RuntimeException | ParseException e) { reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage()); LOGGER.error("Error converting " + bagitPath + " to AIP", e); } report.addReport(reportItem); PluginHelper.createJobReport(this, model, reportItem); }
public static ContentPayload getMetadataPayload(TransferredResource transferredResource) { try { Element root = new Element("metadata"); org.jdom2.Document doc = new org.jdom2.Document(); Element child = new Element("field"); child.setAttribute("name", "title"); child.addContent(transferredResource.getName()); root.addContent(child); doc.setRootElement(root); XMLOutputter outter = new XMLOutputter(); outter.setFormat(Format.getPrettyFormat()); outter.outputString(doc); return new StringContentPayload(outter.outputString(doc)); } catch (IllegalDataException e) { LOGGER.debug("Error generating TransferredResource metadata file {}", e.getMessage()); return new StringContentPayload(""); } }
@Override public SolrInputDocument toSolrDocument(TransferredResource tr, IndexingAdditionalInfo info) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException { SolrInputDocument doc = super.toSolrDocument(tr, info); doc.addField(RodaConstants.TRANSFERRED_RESOURCE_FULLPATH, tr.getFullPath()); if (tr.getParentId() != null) { doc.addField(RodaConstants.TRANSFERRED_RESOURCE_PARENT_ID, tr.getParentId()); doc.addField(RodaConstants.TRANSFERRED_RESOURCE_PARENT_UUID, IdUtils.createUUID(tr.getParentId())); } if (tr.getRelativePath() != null) { doc.addField(RodaConstants.TRANSFERRED_RESOURCE_RELATIVEPATH, tr.getRelativePath()); } doc.addField(RodaConstants.TRANSFERRED_RESOURCE_DATE, SolrUtils.formatDate(tr.getCreationDate())); doc.addField(RodaConstants.TRANSFERRED_RESOURCE_ISFILE, tr.isFile()); doc.addField(RodaConstants.TRANSFERRED_RESOURCE_SIZE, tr.getSize()); doc.addField(RodaConstants.TRANSFERRED_RESOURCE_NAME, tr.getName()); if (tr.getAncestorsPaths() != null && !tr.getAncestorsPaths().isEmpty()) { doc.addField(RodaConstants.TRANSFERRED_RESOURCE_ANCESTORS, tr.getAncestorsPaths()); } doc.addField(RodaConstants.TRANSFERRED_RESOURCE_LAST_SCAN_DATE, SolrUtils.formatDateWithMillis(tr.getLastScanDate())); return doc; }