From 0275de365ae2024825b90b2ac5f494962e105126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Guimar=C3=A3es?= Date: Wed, 20 Mar 2024 17:52:13 +0000 Subject: [PATCH] wip --- .../org/roda/core/common/PremisV3Utils.java | 186 +++++++++--------- .../model/TechnicalMetadata.java | 4 +- .../model/TechnicalMetadataElement.java | 4 +- .../model/TechnicalMetadataField.java | 5 +- .../wui/client/common/dialogs/Dialogs.java | 4 +- .../java/org/roda/wui/common/HTMLUtils.java | 3 +- .../config/i18n/ServerMessages.properties | 39 ---- 7 files changed, 108 insertions(+), 137 deletions(-) diff --git a/roda-core/roda-core/src/main/java/org/roda/core/common/PremisV3Utils.java b/roda-core/roda-core/src/main/java/org/roda/core/common/PremisV3Utils.java index 53cca59534..7fd60a0012 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/common/PremisV3Utils.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/common/PremisV3Utils.java @@ -2,16 +2,22 @@ * The contents of this file are subject to the license and copyright * detailed in the LICENSE file at the root of the source * tree and available online at - * + *

+ * https://github.com/keeps/roda + *

+ * The contents of this file are subject to the license and copyright + * detailed in the LICENSE file at the root of the source + * tree and available online at + *

* https://github.com/keeps/roda */ /** -* The contents of this file are subject to the license and copyright -* detailed in the LICENSE file at the root of the source -* tree and available online at -* -* https://github.com/keeps/roda -*/ + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE file at the root of the source + * tree and available online at + * + * https://github.com/keeps/roda + */ package org.roda.core.common; import java.io.IOException; @@ -41,6 +47,7 @@ import org.joda.time.DateTime; import org.roda.core.RodaCoreFactory; import org.roda.core.common.characterization.model.TechnicalMetadata; +import org.roda.core.common.characterization.model.TechnicalMetadataElement; import org.roda.core.common.characterization.model.TechnicalMetadataField; import org.roda.core.data.common.RodaConstants; import org.roda.core.data.common.RodaConstants.PreservationAgentType; @@ -131,7 +138,7 @@ private PremisV3Utils() { } public static List calculateFixities(Binary binary, Collection algorithms, String originator) - throws IOException, NoSuchAlgorithmException { + throws IOException, NoSuchAlgorithmException { List ret = new ArrayList<>(); try (InputStream stream = binary.getContent().createInputStream()) { Map checksums = FileUtility.checksums(stream, algorithms); @@ -149,7 +156,7 @@ public static List calculateFixities(Binary binary, Collection a public static boolean isPremisV2(Binary binary) throws IOException, SAXException { boolean premisV2 = true; try (InputStream inputStream = binary.getContent().createInputStream(); - InputStream schemaStream = RodaCoreFactory.getConfigurationFileAsStream("schemas/premis-v2-0.xsd")) { + InputStream schemaStream = RodaCoreFactory.getConfigurationFileAsStream("schemas/premis-v2-0.xsd")) { Source xmlFile = new StreamSource(inputStream); SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(new StreamSource(schemaStream)); @@ -171,7 +178,7 @@ public static boolean isPremisV2(Binary binary) throws IOException, SAXException } public static void updateFileFormat(gov.loc.premis.v3.File file, String formatDesignationName, - String formatDesignationVersion, String pronom, String mimeType) { + String formatDesignationVersion, String pronom, String mimeType) { if (StringUtils.isNotBlank(formatDesignationName)) { FormatDesignationComplexType fdct = getFormatDesignation(file); @@ -195,7 +202,7 @@ public static void updateFileFormat(gov.loc.premis.v3.File file, String formatDe } public static void updateTechnicalMetadata(gov.loc.premis.v3.File file, TechnicalMetadata technicalMetadata) - throws JAXBException { + throws JAXBException { String type = technicalMetadata.getType(); ExtensionComplexType ect = null; @@ -204,15 +211,15 @@ public static void updateTechnicalMetadata(gov.loc.premis.v3.File file, Technica } // Create element based on the class technicalMetadata - JAXBElement dataElement = new JAXBElement<>(new QName("", type), - TechnicalMetadata.class, null, technicalMetadata); + JAXBElement dataElement = new JAXBElement<>(new QName("http://www.loc.gov/premis/v3", type), + TechnicalMetadata.class, null, technicalMetadata); // Add to objectCharacteristicsExtension ect.getAny().add(dataElement); } public static void updateCreatingApplication(gov.loc.premis.v3.File file, String creatingApplicationName, - String creatingApplicationVersion, String dateCreatedByApplication) { + String creatingApplicationVersion, String dateCreatedByApplication) { if (StringUtils.isNotBlank(creatingApplicationName)) { CreatingApplicationComplexType cact = getCreatingApplication(file); cact.getCreatingApplicationName().add(getStringPlusAuthority(creatingApplicationName)); @@ -334,8 +341,8 @@ private static FormatDesignationComplexType getFormatDesignation(gov.loc.premis. } public static ContentPayload createPremisEventBinary(String eventID, Date date, String type, String details, - List sources, List outcomes, String outcome, String detailNote, - String detailExtension, List agentIds) { + List sources, List outcomes, String outcome, String detailNote, + String detailExtension, List agentIds) { EventComplexType ect = FACTORY.createEventComplexType(); ect.setEventDateTime(DateTime.parse(date.toInstant().toString()).toString()); ect.setEventType(getStringPlusAuthority(type)); @@ -401,8 +408,8 @@ public static ContentPayload createPremisEventBinary(String eventID, Date date, } public static ContentPayload retrievePremisEventBinary(String eventID, Date date, String type, String details, - List sources, List outcomes, String outcome, String detailNote, - String detailExtension, List agentIds) throws GenericException, ValidationException { + List sources, List outcomes, String outcome, String detailNote, + String detailExtension, List agentIds) throws GenericException, ValidationException { EventComplexType eventComplexType = FACTORY.createEventComplexType(); EventIdentifierComplexType eventIdentifier = FACTORY.createEventIdentifierComplexType(); @@ -442,7 +449,7 @@ public static ContentPayload retrievePremisEventBinary(String eventID, Date date for (LinkingIdentifier agentId : agentIds) { LinkingAgentIdentifierComplexType linkingAgentIdentifier = FACTORY.createLinkingAgentIdentifierComplexType(); linkingAgentIdentifier - .setLinkingAgentIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN)); + .setLinkingAgentIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN)); linkingAgentIdentifier.setLinkingAgentIdentifierValue(agentId.getValue()); if (agentId.getRoles() != null) { linkingAgentIdentifier.getLinkingAgentRole().addAll(getStringPlusAuthorityArray(agentId.getRoles())); @@ -468,7 +475,7 @@ public static ContentPayload retrievePremisEventBinary(String eventID, Date date } public static ContentPayload createPremisAgentBinary(String id, String name, PreservationAgentType type, - String extension, String note, String version) { + String extension, String note, String version) { AgentComplexType agent = FACTORY.createAgentComplexType(); AgentIdentifierComplexType agentIdentifier = FACTORY.createAgentIdentifierComplexType(); agentIdentifier.setAgentIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN)); @@ -499,7 +506,7 @@ public static Representation createBaseRepresentation(String aipId, String repre ObjectIdentifierComplexType objectIdentifier = FACTORY.createObjectIdentifierComplexType(); objectIdentifier.setObjectIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN)); objectIdentifier.setObjectIdentifierValue( - IdUtils.getRepresentationPreservationId(aipId, representationId, RODAInstanceUtils.getLocalInstanceIdentifier())); + IdUtils.getRepresentationPreservationId(aipId, representationId, RODAInstanceUtils.getLocalInstanceIdentifier())); representation.getObjectIdentifier().add(objectIdentifier); PreservationLevelComplexType preservationLevelComplexType = FACTORY.createPreservationLevelComplexType(); preservationLevelComplexType.setPreservationLevelValue(getStringPlusAuthority("")); @@ -509,8 +516,8 @@ public static Representation createBaseRepresentation(String aipId, String repre } public static ContentPayload createBaseFile(File originalFile, ModelService model, - Collection fixityAlgorithms) - throws RequestNotValidException, AuthorizationDeniedException, NotFoundException, GenericException { + Collection fixityAlgorithms) + throws RequestNotValidException, AuthorizationDeniedException, NotFoundException, GenericException { gov.loc.premis.v3.File file = FACTORY.createFile(); PreservationLevelComplexType preservationLevel = FACTORY.createPreservationLevelComplexType(); @@ -520,14 +527,14 @@ public static ContentPayload createBaseFile(File originalFile, ModelService mode // URN-local identifier ObjectIdentifierComplexType objectIdentifier = FACTORY.createObjectIdentifierComplexType(); objectIdentifier.setObjectIdentifierValue(URNUtils.createRodaPreservationURN(PreservationMetadataType.FILE, - originalFile.getId(), RODAInstanceUtils.getLocalInstanceIdentifier())); + originalFile.getId(), RODAInstanceUtils.getLocalInstanceIdentifier())); objectIdentifier.setObjectIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN_LOCAL)); file.getObjectIdentifier().add(objectIdentifier); // URN identifier (UUID) ObjectIdentifierComplexType objectIdentifier2 = FACTORY.createObjectIdentifierComplexType(); objectIdentifier2.setObjectIdentifierValue(URNUtils.createRodaPreservationURN(PreservationMetadataType.FILE, - IdUtils.getFileId(originalFile), RODAInstanceUtils.getLocalInstanceIdentifier())); + IdUtils.getFileId(originalFile), RODAInstanceUtils.getLocalInstanceIdentifier())); objectIdentifier2.setObjectIdentifierType(getStringPlusAuthority(RodaConstants.PREMIS_IDENTIFIER_TYPE_URN)); file.getObjectIdentifier().add(objectIdentifier2); @@ -577,7 +584,7 @@ public static ContentPayload createBaseFile(File originalFile, ModelService mode String contentLocation; try { contentLocation = String - .valueOf(model.getStorage().getBinary(ModelUtils.getFileStoragePath(originalFile)).getContent().getURI()); + .valueOf(model.getStorage().getBinary(ModelUtils.getFileStoragePath(originalFile)).getContent().getURI()); } catch (IOException e) { LOGGER.debug(String.format("Can't create URI, %s: %s", e.getCause(), e.getMessage())); contentLocation = ModelUtils.getFileStoragePath(originalFile).asString("/", null, null, false); @@ -707,23 +714,23 @@ public static SolrInputDocument getSolrDocument(Binary premisBinary) throws Gene } FormatRegistryComplexType pronomRegistry = getFormatRegistry(premisFile, - RodaConstants.PRESERVATION_REGISTRY_PRONOM); + RodaConstants.PRESERVATION_REGISTRY_PRONOM); if (pronomRegistry.getFormatRegistryKey() != null) { doc.addField(RodaConstants.FILE_PRONOM, pronomRegistry.getFormatRegistryKey().getValue()); } FormatRegistryComplexType mimeRegistry = getFormatRegistry(premisFile, - RodaConstants.PRESERVATION_REGISTRY_MIME); + RodaConstants.PRESERVATION_REGISTRY_MIME); if (mimeRegistry.getFormatRegistryKey() != null) { doc.addField(RodaConstants.FILE_FORMAT_MIMETYPE, mimeRegistry.getFormatRegistryKey().getValue()); } // TODO extension } if (objectCharacteristics.getCreatingApplication() != null - && !objectCharacteristics.getCreatingApplication().isEmpty()) { + && !objectCharacteristics.getCreatingApplication().isEmpty()) { CreatingApplicationComplexType cact = objectCharacteristics.getCreatingApplication().get(0); if (cact.getCreatingApplicationName() != null && !cact.getCreatingApplicationName().isEmpty()) { doc.addField(RodaConstants.FILE_CREATING_APPLICATION_NAME, - cact.getCreatingApplicationName().get(0).getValue()); + cact.getCreatingApplicationName().get(0).getValue()); } doc.addField(RodaConstants.FILE_CREATING_APPLICATION_VERSION, cact.getCreatingApplicationVersion()); doc.addField(RodaConstants.FILE_DATE_CREATED_BY_APPLICATION, cact.getDateCreatedByApplication()); @@ -744,17 +751,17 @@ public static SolrInputDocument getSolrDocument(Binary premisBinary) throws Gene } public static PreservationMetadata createPremisAgentBinary(Plugin plugin, ModelService model, boolean notify) - throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException, - ValidationException, AlreadyExistsException { + throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException, + ValidationException, AlreadyExistsException { String id = IdUtils.getPluginAgentId(plugin.getClass().getName(), plugin.getVersion(), - RODAInstanceUtils.getLocalInstanceIdentifier()); + RODAInstanceUtils.getLocalInstanceIdentifier()); ContentPayload agentPayload = PremisV3Utils.createPremisAgentBinary(id, plugin.getName(), plugin.getAgentType(), "", - plugin.getDescription(), plugin.getVersion()); + plugin.getDescription(), plugin.getVersion()); return model.createPreservationMetadata(PreservationMetadataType.AGENT, id, agentPayload, notify); } public static void linkFileToRepresentation(String fileId, List filePath, String relationshipType, - String relationshipSubType, Representation representation) { + String relationshipSubType, Representation representation) { RelationshipComplexType relationship = FACTORY.createRelationshipComplexType(); relationship.setRelationshipType(getStringPlusAuthority(relationshipType)); relationship.setRelationshipSubType(getStringPlusAuthority(relationshipSubType)); @@ -767,7 +774,7 @@ public static void linkFileToRepresentation(String fileId, List filePath } public static List extractAgentsFromEvent(Binary binary) - throws ValidationException, GenericException { + throws ValidationException, GenericException { List identifiers = new ArrayList<>(); EventComplexType event = PremisV3Utils.binaryToEvent(binary.getContent(), true); if (event.getLinkingObjectIdentifier() != null && !event.getLinkingObjectIdentifier().isEmpty()) { @@ -792,7 +799,7 @@ public static List extractAgentsFromEvent(Binary binary) } public static List extractObjectFromEvent(Binary binary) - throws ValidationException, GenericException { + throws ValidationException, GenericException { List identifiers = new ArrayList<>(); EventComplexType event = PremisV3Utils.binaryToEvent(binary.getContent(), true); if (event.getLinkingObjectIdentifier() != null && !event.getLinkingObjectIdentifier().isEmpty()) { @@ -841,12 +848,12 @@ public static List toStringList(List source) { } public static void updatePremisEventInstanceId(PreservationMetadata pm, ModelService model, IndexService index, - String instanceId, String username) throws AuthorizationDeniedException, RequestNotValidException, GenericException, - ValidationException, AlreadyExistsException, AlreadyHasInstanceIdentifier, InstanceIdNotUpdated { + String instanceId, String username) throws AuthorizationDeniedException, RequestNotValidException, GenericException, + ValidationException, AlreadyExistsException, AlreadyHasInstanceIdentifier, InstanceIdNotUpdated { if (URNUtils.verifyInstanceIdentifier(pm.getId(), instanceId)) { throw new AlreadyHasInstanceIdentifier( - "The preservation event (" + pm.getId() + ") already has instance identifier"); + "The preservation event (" + pm.getId() + ") already has instance identifier"); } String updatedId = IdUtils.updatePreservationMetadataInstanceId(pm.getId(), instanceId); @@ -855,24 +862,24 @@ public static void updatePremisEventInstanceId(PreservationMetadata pm, ModelSer IndexedPreservationEvent event = null; try { Binary binary = model.retrievePreservationEvent(pm.getAipId(), pm.getRepresentationId(), - pm.getFileDirectoryPath(), pm.getFileId(), pm.getId()); + pm.getFileDirectoryPath(), pm.getFileId(), pm.getId()); model.createPreservationMetadata(pm.getType(), updatedId, pm.getAipId(), pm.getRepresentationId(), - pm.getFileDirectoryPath(), pm.getFileId(), binary.getContent(), username, true); + pm.getFileDirectoryPath(), pm.getFileId(), binary.getContent(), username, true); model.deletePreservationMetadata(pm.getType(), pm.getAipId(), pm.getRepresentationId(), pm.getId(), - pm.getFileDirectoryPath(), true); + pm.getFileDirectoryPath(), true); } catch (NotFoundException e) { throw new InstanceIdNotUpdated(e); } } else if (pm.getType().equals(PreservationMetadataType.REPRESENTATION) - || pm.getType().equals(PreservationMetadataType.FILE)) { + || pm.getType().equals(PreservationMetadataType.FILE)) { try { StoragePath path = ModelUtils.getPreservationMetadataStoragePath(pm); ContentPayload payload = model.getStorage().getBinary(path).getContent(); model.createPreservationMetadata(pm.getType(), updatedId, pm.getAipId(), pm.getRepresentationId(), - pm.getFileDirectoryPath(), pm.getFileId(), payload, username, false); + pm.getFileDirectoryPath(), pm.getFileId(), payload, username, false); model.deletePreservationMetadata(pm, false); } catch (NotFoundException e) { @@ -882,8 +889,8 @@ public static void updatePremisEventInstanceId(PreservationMetadata pm, ModelSer } public static void updatePremisUserAgentId(PreservationMetadata pm, ModelService model, IndexService index, - String instanceId) throws GenericException, AuthorizationDeniedException, RequestNotValidException, - AlreadyExistsException, ValidationException, NotFoundException { + String instanceId) throws GenericException, AuthorizationDeniedException, RequestNotValidException, + AlreadyExistsException, ValidationException, NotFoundException { String updatedId = IdUtils.updatePreservationMetadataInstanceId(pm.getId(), instanceId); @@ -892,42 +899,42 @@ public static void updatePremisUserAgentId(PreservationMetadata pm, ModelService agent = index.retrieve(IndexedPreservationAgent.class, pm.getId(), new ArrayList<>()); ContentPayload agentPayload = PremisV3Utils.createPremisAgentBinary(updatedId, agent.getName(), - PreservationAgentType.valueOf(agent.getType().toUpperCase()), agent.getExtension(), agent.getNote(), - agent.getVersion()); + PreservationAgentType.valueOf(agent.getType().toUpperCase()), agent.getExtension(), agent.getNote(), + agent.getVersion()); model.createPreservationMetadata(PreservationMetadataType.AGENT, updatedId, agentPayload, true); model.deletePreservationMetadata(PreservationMetadataType.AGENT, pm.getAipId(), pm.getRepresentationId(), - pm.getId(), pm.getFileDirectoryPath(), true); + pm.getId(), pm.getFileDirectoryPath(), true); } catch (NotFoundException e) { RODAMember member = index.retrieve(RODAMember.class, - IdUtils.getUserId(URNUtils.getAgentUsernameFromURN(pm.getId())), - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.MEMBERS_FULLNAME, RodaConstants.MEMBERS_EMAIL)); + IdUtils.getUserId(URNUtils.getAgentUsernameFromURN(pm.getId())), + Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.MEMBERS_FULLNAME, RodaConstants.MEMBERS_EMAIL)); if (member instanceof User) { User user = (User) member; String note = user.getEmail(); ContentPayload agentPayload = PremisV3Utils.createPremisAgentBinary(updatedId, member.getFullName(), - PreservationAgentType.PERSON, null, note, null); + PreservationAgentType.PERSON, null, note, null); model.createPreservationMetadata(PreservationMetadataType.AGENT, updatedId, agentPayload, true); model.deletePreservationMetadata(PreservationMetadataType.AGENT, pm.getAipId(), pm.getRepresentationId(), - pm.getId(), pm.getFileDirectoryPath(), true); + pm.getId(), pm.getFileDirectoryPath(), true); } } } public static PreservationMetadata createOrUpdatePremisUserAgentBinary(String username, ModelService model, - IndexService index, boolean notify) throws GenericException, ValidationException, NotFoundException, - RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException { + IndexService index, boolean notify) throws GenericException, ValidationException, NotFoundException, + RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException { return createOrUpdatePremisUserAgentBinary(username, model, index, notify, null); } public static PreservationMetadata createOrUpdatePremisUserAgentBinary(String username, ModelService model, - IndexService index, boolean notify, Job job) throws GenericException, ValidationException, NotFoundException, - RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException { + IndexService index, boolean notify, Job job) throws GenericException, ValidationException, NotFoundException, + RequestNotValidException, AuthorizationDeniedException, AlreadyExistsException { PreservationMetadata pm = null; if (StringUtils.isNotBlank(username)) { @@ -947,7 +954,7 @@ public static PreservationMetadata createOrUpdatePremisUserAgentBinary(String us } else { try { RODAMember member = index.retrieve(RODAMember.class, IdUtils.getUserId(username), - Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.MEMBERS_FULLNAME, RodaConstants.MEMBERS_EMAIL)); + Arrays.asList(RodaConstants.INDEX_UUID, RodaConstants.MEMBERS_FULLNAME, RodaConstants.MEMBERS_EMAIL)); fullName = member.getFullName(); if (member instanceof User) { @@ -960,7 +967,7 @@ public static PreservationMetadata createOrUpdatePremisUserAgentBinary(String us } ContentPayload agentPayload = PremisV3Utils.createPremisAgentBinary(id, fullName, PreservationAgentType.PERSON, - extension, note, version); + extension, note, version); try { if (model.retrievePreservationAgent(id) != null) { @@ -977,8 +984,8 @@ public static PreservationMetadata createOrUpdatePremisUserAgentBinary(String us } public static void updateFormatPreservationMetadata(ModelService model, String aipId, String representationId, - List fileDirectoryPath, String fileId, String format, String version, String pronom, String mime, - String username, boolean notify) { + List fileDirectoryPath, String fileId, String format, String version, String pronom, String mime, + String username, boolean notify) { Binary premisBin; try { @@ -990,7 +997,7 @@ public static void updateFormatPreservationMetadata(ModelService model, String a if (fileId == null) { PremisSkeletonPluginUtils.createPremisSkeletonOnRepresentation(model, aipId, representationId, algorithms, - username); + username); } else { // File file; // if (shallow) { @@ -1016,14 +1023,14 @@ public static void updateFormatPreservationMetadata(ModelService model, String a ContentPayload premisFilePayload = fileToBinary(premisFile); model.updatePreservationMetadata(id, type, aipId, representationId, fileDirectoryPath, fileId, premisFilePayload, - username, notify); + username, notify); } catch (RODAException | IOException e) { LOGGER.error("PREMIS will not be updated due to an error", e); } } public static Representation binaryToRepresentation(ContentPayload payload, boolean validate) - throws ValidationException, GenericException { + throws ValidationException, GenericException { try (InputStream inputStream = payload.createInputStream()) { return binaryToRepresentation(inputStream, validate); } catch (IOException e) { @@ -1032,7 +1039,7 @@ public static Representation binaryToRepresentation(ContentPayload payload, bool } public static gov.loc.premis.v3.File binaryToFile(ContentPayload payload, boolean validate) - throws ValidationException, GenericException { + throws ValidationException, GenericException { try (InputStream inputStream = payload.createInputStream()) { return binaryToFile(inputStream, validate); } catch (IOException e) { @@ -1041,7 +1048,7 @@ public static gov.loc.premis.v3.File binaryToFile(ContentPayload payload, boolea } public static EventComplexType binaryToEvent(ContentPayload payload, boolean validate) - throws ValidationException, GenericException { + throws ValidationException, GenericException { try (InputStream inputStream = payload.createInputStream()) { return binaryToEvent(inputStream, validate); } catch (IOException e) { @@ -1050,7 +1057,7 @@ public static EventComplexType binaryToEvent(ContentPayload payload, boolean val } public static AgentComplexType binaryToAgent(ContentPayload payload, boolean validate) - throws ValidationException, GenericException { + throws ValidationException, GenericException { try (InputStream inputStream = payload.createInputStream()) { return binaryToAgent(inputStream, validate); } catch (IOException e) { @@ -1059,7 +1066,7 @@ public static AgentComplexType binaryToAgent(ContentPayload payload, boolean val } public static ContentPayload fileToBinary(gov.loc.premis.v3.File file, Class... additionalClass) - throws GenericException, ValidationException { + throws GenericException, ValidationException { if (additionalClass == null || additionalClass.length == 0) { return MetadataUtils.saveToContentPayload(FACTORY.createObject(file), gov.loc.premis.v3.File.class); } @@ -1078,8 +1085,8 @@ public static ContentPayload representationToBinary(Representation representatio } public static void updateCreatingApplicationPreservationMetadata(ModelService model, String aipId, - String representationId, List fileDirectoryPath, String fileId, String creatingApplicationName, - String creatingApplicationVersion, String dateCreatedByApplication, String username, boolean notify) { + String representationId, List fileDirectoryPath, String fileId, String creatingApplicationName, + String creatingApplicationVersion, String dateCreatedByApplication, String username, boolean notify) { Binary premisBin; try { @@ -1089,29 +1096,29 @@ public static void updateCreatingApplicationPreservationMetadata(ModelService mo LOGGER.debug("PREMIS object skeleton does not exist yet. Creating PREMIS object!"); List algorithms = RodaCoreFactory.getFixityAlgorithms(); PremisSkeletonPluginUtils.createPremisSkeletonOnRepresentation(model, aipId, representationId, algorithms, - username); + username); premisBin = model.retrievePreservationFile(aipId, representationId, fileDirectoryPath, fileId); LOGGER.debug("PREMIS object skeleton created"); } gov.loc.premis.v3.File premisFile = binaryToFile(premisBin.getContent(), false); PremisV3Utils.updateCreatingApplication(premisFile, creatingApplicationName, creatingApplicationVersion, - dateCreatedByApplication); + dateCreatedByApplication); PreservationMetadataType type = PreservationMetadataType.FILE; String id = IdUtils.getPreservationFileId(fileId, RODAInstanceUtils.getLocalInstanceIdentifier()); ContentPayload premisFilePayload = fileToBinary(premisFile); model.updatePreservationMetadata(id, type, aipId, representationId, fileDirectoryPath, fileId, premisFilePayload, - username, notify); + username, notify); } catch (RODAException | IOException e) { LOGGER.error("PREMIS will not be updated due to an error", e); } } public static void updateCreatingApplicationTechnicalMetadata(ModelService model, String aipId, - String representationId, List fileDirectoryPath, String fileId, String username, boolean notify, - TechnicalMetadata technicalMetadata) { + String representationId, List fileDirectoryPath, String fileId, String username, boolean notify, + TechnicalMetadata technicalMetadata) { Binary premisBin; try { @@ -1121,7 +1128,7 @@ public static void updateCreatingApplicationTechnicalMetadata(ModelService model LOGGER.debug("PREMIS object skeleton does not exist yet. Creating PREMIS object!"); List algorithms = RodaCoreFactory.getFixityAlgorithms(); PremisSkeletonPluginUtils.createPremisSkeletonOnRepresentation(model, aipId, representationId, algorithms, - username); + username); premisBin = model.retrievePreservationFile(aipId, representationId, fileDirectoryPath, fileId); LOGGER.debug("PREMIS object skeleton created"); } @@ -1131,17 +1138,16 @@ public static void updateCreatingApplicationTechnicalMetadata(ModelService model PremisV3Utils.updateTechnicalMetadata(premisFile, technicalMetadata); PreservationMetadataType pmtype = PreservationMetadataType.FILE; String id = IdUtils.getPreservationFileId(fileId, RODAInstanceUtils.getLocalInstanceIdentifier()); - ContentPayload premisFilePayload = fileToBinary(premisFile, TechnicalMetadata.class, - TechnicalMetadataField.class); + ContentPayload premisFilePayload = fileToBinary(premisFile, TechnicalMetadata.class, TechnicalMetadataElement.class, TechnicalMetadataField.class); model.updatePreservationMetadata(id, pmtype, aipId, representationId, fileDirectoryPath, fileId, - premisFilePayload, username, notify); + premisFilePayload, username, notify); } catch (RODAException | IOException | JAXBException e) { LOGGER.error("PREMIS will not be updated due to an error", e); } } public static List getApplicationTechnicalMetadataParameters(ModelService model, String aipId, - String representationId, List fileDirectoryPath, String fileId) { + String representationId, List fileDirectoryPath, String fileId) { Binary premisBin = null; List parameters = null; try { @@ -1162,11 +1168,11 @@ public static List getApplicationTechnicalMetadataParameters(ModelServic private static List getTechnicalMetadataParameters(Binary premisFile) throws IOException { return XMLUtility.getListString(premisFile.getContent().createInputStream(), - "//featureExtractor/@featureExtractorType | //@featureExtractorVersion"); + "//featureExtractor/@featureExtractorType | //@featureExtractorVersion"); } private static Representation binaryToRepresentation(InputStream binaryInputStream, boolean validate) - throws GenericException, ValidationException { + throws GenericException, ValidationException { JAXBContext jaxbContext; ValidationEventCollector validationCollector = new ValidationEventCollector(); @@ -1177,7 +1183,7 @@ private static Representation binaryToRepresentation(InputStream binaryInputStre if (validate) { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource source = new StreamSource( - PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); + PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); Schema schema = sf.newSchema(source); jaxbUnmarshaller.setSchema(schema); jaxbUnmarshaller.setEventHandler(validationCollector); @@ -1196,7 +1202,7 @@ private static Representation binaryToRepresentation(InputStream binaryInputStre } private static AgentComplexType binaryToAgent(InputStream binaryInputStream, boolean validate) - throws IOException, GenericException, ValidationException { + throws IOException, GenericException, ValidationException { JAXBContext jaxbContext; ValidationEventCollector validationCollector = new ValidationEventCollector(); @@ -1207,7 +1213,7 @@ private static AgentComplexType binaryToAgent(InputStream binaryInputStream, boo if (validate) { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource source = new StreamSource( - PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); + PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); Schema schema = sf.newSchema(source); jaxbUnmarshaller.setSchema(schema); jaxbUnmarshaller.setEventHandler(validationCollector); @@ -1226,7 +1232,7 @@ private static AgentComplexType binaryToAgent(InputStream binaryInputStream, boo } private static gov.loc.premis.v3.File binaryToFile(InputStream binaryInputStream, boolean validate) - throws GenericException, ValidationException { + throws GenericException, ValidationException { JAXBContext jaxbContext; ValidationEventCollector validationCollector = new ValidationEventCollector(); @@ -1237,7 +1243,7 @@ private static gov.loc.premis.v3.File binaryToFile(InputStream binaryInputStream if (validate) { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource source = new StreamSource( - PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); + PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); Schema schema = sf.newSchema(source); jaxbUnmarshaller.setSchema(schema); jaxbUnmarshaller.setEventHandler(validationCollector); @@ -1256,7 +1262,7 @@ private static gov.loc.premis.v3.File binaryToFile(InputStream binaryInputStream } private static EventComplexType binaryToEvent(InputStream binaryInputStream, boolean validate) - throws GenericException, ValidationException { + throws GenericException, ValidationException { JAXBContext jaxbContext; ValidationEventCollector validationCollector = new ValidationEventCollector(); @@ -1267,7 +1273,7 @@ private static EventComplexType binaryToEvent(InputStream binaryInputStream, boo if (validate) { SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); StreamSource source = new StreamSource( - PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); + PremisV3Utils.class.getClassLoader().getResourceAsStream("premis/v3/premis.xsd")); Schema schema = sf.newSchema(source); jaxbUnmarshaller.setSchema(schema); jaxbUnmarshaller.setEventHandler(validationCollector); diff --git a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadata.java b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadata.java index 3769377261..b039250ac9 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadata.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadata.java @@ -12,12 +12,14 @@ import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; /** * @author Carlos Afonso */ @XmlRootElement(name = "featureExtractor") @XmlAccessorType(XmlAccessType.FIELD) +@XmlType(namespace = "http://www.loc.gov/premis/v3") public class TechnicalMetadata { @XmlAttribute @@ -31,7 +33,7 @@ public class TechnicalMetadata { @XmlAttribute private String algorithm; - @XmlElement(name = "metadata") + @XmlElement(name = "metadata", namespace = "http://www.loc.gov/premis/v3") private TechnicalMetadataElement technicalMetadataElement; public TechnicalMetadata() { diff --git a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataElement.java b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataElement.java index a3c1d50f7f..45c242d12c 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataElement.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataElement.java @@ -10,6 +10,7 @@ import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlType; import java.util.ArrayList; import java.util.List; @@ -18,9 +19,10 @@ * @author Miguel GuimarĂ£es */ @XmlAccessorType(XmlAccessType.FIELD) +@XmlType(namespace = "http://www.loc.gov/premis/v3") public class TechnicalMetadataElement { - @XmlElement(name = "field") + @XmlElement(name = "field", namespace = "http://www.loc.gov/premis/v3") private List technicalMetadataFields = new ArrayList<>(); public TechnicalMetadataElement() { diff --git a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataField.java b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataField.java index d482510c6f..f028866227 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataField.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/common/characterization/model/TechnicalMetadataField.java @@ -10,15 +10,14 @@ import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlValue; /** * @author Miguel GuimarĂ£es */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "metadata") - +@XmlType(namespace = "http://www.loc.gov/premis/v3") public class TechnicalMetadataField { public TechnicalMetadataField() { diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/dialogs/Dialogs.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/dialogs/Dialogs.java index 9ab4c01ddf..417d33df9a 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/dialogs/Dialogs.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/client/common/dialogs/Dialogs.java @@ -162,12 +162,12 @@ public static void showTechnicalMetadataInformation(String title, String downloa layout.add(verticalPanel); layout.addStyleName("wui-dialog-message"); - footer.add(downloadButton); footer.add(closeButton); + footer.add(downloadButton); footer.addStyleName("wui-dialog-layout-footer"); downloadButton.addStyleName("btn btn-download"); - closeButton.addStyleName("btn btn-default btn-times-circle btn-separator"); + closeButton.addStyleName("btn btn-link"); main.addStyleName("wui-dialog-layout"); main.add(layout); main.add(footer); diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/common/HTMLUtils.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/common/HTMLUtils.java index 0e84b28123..015f2b9cb6 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/common/HTMLUtils.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/common/HTMLUtils.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.ResourceBundle; import org.roda.core.RodaCoreFactory; import org.roda.core.common.Messages; @@ -86,7 +87,7 @@ public static String preservationMetadataEventToHtml(Binary binary, boolean only } } - public static Map getTranslations(String descriptiveMetadataType, String descriptiveMetadataVersion, + public static Map getTranslations(String descriptiveMetadataType, String descriptiveMetadataVersion, final Locale locale) { Map translations = null; Messages messages = RodaCoreFactory.getI18NMessages(locale); diff --git a/roda-ui/roda-wui/src/main/resources/config/i18n/ServerMessages.properties b/roda-ui/roda-wui/src/main/resources/config/i18n/ServerMessages.properties index fd4b9057b0..53eac80d69 100644 --- a/roda-ui/roda-wui/src/main/resources/config/i18n/ServerMessages.properties +++ b/roda-ui/roda-wui/src/main/resources/config/i18n/ServerMessages.properties @@ -523,45 +523,6 @@ crosswalks.dissemination.html.dc_simpledc20021212.source=Source crosswalks.dissemination.html.dc_simpledc20021212.subject=Subject crosswalks.dissemination.html.dc_simpledc20021212.type=Type -crosswalks.dissemination.html.tika_1.transparency_alpha=Transparency -crosswalks.dissemination.html.tika_1.parsed_by_full_set=Parsed by -crosswalks.dissemination.html.tika_1.tiff_imagelength=Length -crosswalks.dissemination.html.tika_1.compression_compressiontypename=Compression type -crosswalks.dissemination.html.tika_1.data_bitspersample=Bitrate sample -crosswalks.dissemination.html.tika_1.data_planarconfiguration=Planar configuration -crosswalks.dissemination.html.tika_1.ihdr=IHDR -crosswalks.dissemination.html.tika_1.sbit_sbit_rgbalpha=RGBA -crosswalks.dissemination.html.tika_1.chroma_colorspacetype=Color space type -crosswalks.dissemination.html.tika_1.tiff_bitspersample=Bitrate Sample -crosswalks.dissemination.html.tika_1.content_type=Content type -crosswalks.dissemination.html.tika_1.height=Height -crosswalks.dissemination.html.tika_1.imagereader_numimages=Number of images -crosswalks.dissemination.html.tika_1.text_textentry=Text entry -crosswalks.dissemination.html.tika_1.dimension_pixelaspectratio=Pixel aspect ratio -crosswalks.dissemination.html.tika_1.compression_numprogressivescans=Number of progressive scans -crosswalks.dissemination.html.tika_1.data_significantbitspersample=Bitrate sample -crosswalks.dissemination.html.tika_1.x_tika_parsed_by=Parsed by -crosswalks.dissemination.html.tika_1.chroma_blackiszero=Is black zero -crosswalks.dissemination.html.tika_1.compression_lossless=Compression lossless -crosswalks.dissemination.html.tika_1.width=Width -crosswalks.dissemination.html.tika_1.dimension_imageorientation=Image orientation -crosswalks.dissemination.html.tika_1.tiff_imagewidth=Width -crosswalks.dissemination.html.tika_1.chroma_numchannels=Number of channels -crosswalks.dissemination.html.tika_1.data_sampleformat=Sample format -crosswalks.dissemination.html.tika_1.filesize=File size -crosswalks.dissemination.html.tika_1.xmpdm_genre=Genre -crosswalks.dissemination.html.tika_1.xmpdm_composer=Composer -crosswalks.dissemination.html.tika_1.xmpdm_album=Album -crosswalks.dissemination.html.tika_1.xmpdm_releasedate=Release date -crosswalks.dissemination.html.tika_1.xmpdm_artist=Artist -crosswalks.dissemination.html.tika_1.xmpdm_duration=Duration -crosswalks.dissemination.html.tika_1.meta_paragraph_count=Paragraph count -crosswalks.dissemination.html.tika_1.meta_word_count=Word count -crosswalks.dissemination.html.tika_1.extended_properties_application=Application -crosswalks.dissemination.html.tika_1.dc_creator=Creator -crosswalks.dissemination.html.tika_1.meta_slide_count=Slide count - - crosswalks.dissemination.html.event.identifierType: Identifier type crosswalks.dissemination.html.event.identifierValue: Identifier value crosswalks.dissemination.html.event.dateTime: Date