|
7 | 7 | */ |
8 | 8 | package org.roda.core.plugins.base.ingest; |
9 | 9 |
|
| 10 | +import java.io.IOException; |
10 | 11 | import java.io.UnsupportedEncodingException; |
11 | 12 | import java.net.URLDecoder; |
12 | 13 | import java.util.Collections; |
|
20 | 21 | import gov.loc.premis.v3.PremisComplexType; |
21 | 22 | import jakarta.xml.bind.JAXBElement; |
22 | 23 | import org.apache.commons.io.FilenameUtils; |
| 24 | +import org.apache.commons.io.IOUtils; |
23 | 25 | import org.roda.core.common.PremisV3Utils; |
24 | 26 | import org.roda.core.data.common.RodaConstants; |
25 | 27 | import org.roda.core.data.exceptions.AlreadyExistsException; |
|
44 | 46 | import org.roda.core.model.utils.ModelUtils; |
45 | 47 | import org.roda.core.plugins.Plugin; |
46 | 48 | import org.roda.core.plugins.PluginHelper; |
| 49 | +import org.roda.core.storage.Binary; |
47 | 50 | import org.roda.core.storage.ContentPayload; |
48 | 51 | import org.roda.core.storage.ExternalFileManifestContentPayload; |
49 | 52 | import org.roda.core.storage.StorageService; |
@@ -224,10 +227,19 @@ private static void processPreservationMetadata(ModelService model, List<IPMetad |
224 | 227 | agentComplexType.getVersion()); |
225 | 228 |
|
226 | 229 | try { |
227 | | - if (model.retrievePreservationAgent( |
228 | | - agentComplexType.getAgentIdentifier().getFirst().getAgentIdentifierValue()) != null) { |
229 | | - model.updatePreservationMetadata(PreservationMetadataType.AGENT, |
230 | | - agentComplexType.getAgentIdentifier().getFirst().getAgentIdentifierValue(), premisAgentBinary, true); |
| 230 | + Binary existingPA = model |
| 231 | + .retrievePreservationAgent(agentComplexType.getAgentIdentifier().getFirst().getAgentIdentifierValue()); |
| 232 | + if (existingPA != null) { |
| 233 | + try { |
| 234 | + if (!IOUtils.contentEquals(existingPA.getContent().createInputStream(), |
| 235 | + premisAgentBinary.createInputStream())) { |
| 236 | + model.updatePreservationMetadata(PreservationMetadataType.AGENT, |
| 237 | + agentComplexType.getAgentIdentifier().getFirst().getAgentIdentifierValue(), premisAgentBinary, |
| 238 | + true); |
| 239 | + } |
| 240 | + } catch (IOException e) { |
| 241 | + throw new GenericException("Could not update binary content", e); |
| 242 | + } |
231 | 243 | } else { |
232 | 244 | model.createPreservationMetadata(PreservationMetadataType.AGENT, |
233 | 245 | agentComplexType.getAgentIdentifier().getFirst().getAgentIdentifierValue(), premisAgentBinary, true); |
|
0 commit comments