private List<DescriptiveMetadata> getDescriptiveMetadata(AIP aip, String representationId) { List<DescriptiveMetadata> descriptiveMetadataList = Collections.emptyList(); if (representationId == null) { // AIP descriptive metadata descriptiveMetadataList = aip.getDescriptiveMetadata(); } else { // Representation descriptive metadata Optional<Representation> oRep = aip.getRepresentations().stream() .filter(rep -> rep.getId().equals(representationId)).findFirst(); if (oRep.isPresent()) { descriptiveMetadataList = oRep.get().getDescriptiveMetadata(); } } return descriptiveMetadataList; }
public static List<List<String>> getDescriptiveMetadataInformation(List<String> fields, AIP aip, ModelService model, StorageService storage) { List<List<String>> descriptiveMetadataInformation = new ArrayList<>(); for (DescriptiveMetadata dm : aip.getDescriptiveMetadata()) { descriptiveMetadataInformation.add(retrieveDescriptiveMetadataInfo(fields, aip, dm, storage)); } if (aip.getRepresentations() != null) { for (Representation r : aip.getRepresentations()) { for (DescriptiveMetadata dm : r.getDescriptiveMetadata()) { descriptiveMetadataInformation.add(retrieveDescriptiveMetadataInfo(fields, aip, dm, storage)); } } } return descriptiveMetadataInformation; }
public static Permissions grantReadPermissionToUserGroup(ModelService model, AIP aip, Permissions permissions) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, IOException { List<DescriptiveMetadata> descriptiveMetadataList = aip.getDescriptiveMetadata(); Set<Permissions.PermissionType> readPermissionToUserGroup = new HashSet<>(); for (DescriptiveMetadata descriptiveMetadata : descriptiveMetadataList) { Binary descriptiveMetadataBinary = model.retrieveDescriptiveMetadataBinary(aip.getId(), descriptiveMetadata.getId()); try(InputStream createInputStream = descriptiveMetadataBinary.getContent().createInputStream()) { String xpath = RodaCoreFactory.getRodaConfigurationAsString("core", "permissions", "xpath"); String freeAccessTerm = RodaCoreFactory.getRodaConfigurationAsString("core", "permissions", "freeaccess"); if (StringUtils.isNotBlank(xpath) && StringUtils.isNotBlank(freeAccessTerm)) { String useRestrict = XMLUtility.getString(createInputStream, xpath); if (useRestrict.equals(freeAccessTerm)) { readPermissionToUserGroup.add(Permissions.PermissionType.READ); permissions.setGroupPermissions(RodaConstants.OBJECT_PERMISSIONS_USER_GROUP, readPermissionToUserGroup); } } } } return permissions; }
/** * Validates all descriptive metadata files contained in the AIP * * @throws AuthorizationDeniedException * @throws NotFoundException * @throws RequestNotValidException * @throws GenericException * * @throws ValidationException */ public static ValidationReport isAIPDescriptiveMetadataValid(ModelService model, String aipId, boolean failIfNoSchema) throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException { boolean valid = true; List<ValidationIssue> issues = new ArrayList<>(); List<DescriptiveMetadata> descriptiveMetadata = model.retrieveAIP(aipId).getDescriptiveMetadata(); for (DescriptiveMetadata dm : descriptiveMetadata) { ValidationReport report = isDescriptiveMetadataValid(model, dm, failIfNoSchema); valid &= report.isValid(); issues.addAll(report.getIssues()); } ValidationReport ret = new ValidationReport(); ret.setValid(valid); ret.setIssues(issues); return ret; }
List<DescriptiveMetadata> descriptiveMetadata = modelAIP.getDescriptiveMetadata(); if (descriptiveMetadata != null && !descriptiveMetadata.isEmpty()) { ArrayNode metadata = mapper.createArrayNode();
private void processAIP(ModelService model, StorageService storage, JobPluginInfo jobPluginInfo, CSVPrinter csvFilePrinter, AIP aip) { if (csvFilePrinter == null) { LOGGER.warn("CSVPrinter is NULL! Skipping..."); return; } try { if (outputDataInformation && aip.getRepresentations() != null) { List<List<String>> dataInformation = InventoryReportPluginUtils.getDataInformation(fields, aip, model, storage); csvFilePrinter.printRecords(dataInformation); } if (outputDescriptiveMetadataInformation && aip.getDescriptiveMetadata() != null) { List<List<String>> dataInformation = InventoryReportPluginUtils.getDescriptiveMetadataInformation(fields, aip, model, storage); csvFilePrinter.printRecords(dataInformation); } if (otherMetadataTypes != null && !otherMetadataTypes.isEmpty()) { for (String otherMetadataType : otherMetadataTypes) { List<List<String>> otherMetadataInformation = InventoryReportPluginUtils.getOtherMetadataInformation(fields, otherMetadataType, aip, model, storage); csvFilePrinter.printRecords(otherMetadataInformation); } } jobPluginInfo.incrementObjectsProcessedWithSuccess(); } catch (IOException e) { LOGGER.error("Error writing CSV file", e); jobPluginInfo.incrementObjectsProcessedWithFailure(); } }
ValidationReport report = new ValidationReport(); report.setValid(true); List<DescriptiveMetadata> descriptiveMetadata = model.retrieveAIP(aipId).getDescriptiveMetadata(); List<Pair<String, String>> schemasInfo = new ArrayList<>(); for (DescriptiveMetadata dm : descriptiveMetadata) {
doc.addField(RodaConstants.INGEST_UPDATE_JOB_IDS, aip.getIngestUpdateJobIds()); List<String> descriptiveMetadataIds = aip.getDescriptiveMetadata().stream().map(dm -> dm.getId()) .collect(Collectors.toList()); if (!safemode) { SolrUtils.indexDescriptiveMetadataFields(RodaCoreFactory.getModelService(), aip.getId(), null, aip.getDescriptiveMetadata(), doc);
RodaConstants.STORAGE_AIP_METADATA_FILENAME); addToZip(zipEntries, storage.getBinary(aipJsonPath)); for (DescriptiveMetadata dm : aip.getDescriptiveMetadata()) { Binary dmBinary = model.retrieveDescriptiveMetadataBinary(aip.getId(), dm.getId()); addToZip(zipEntries, dmBinary);