@Test @RunWithCustomExecutor public void testAfterUnmarshalGetOriginatingAgenciesOK() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); ArchiveUnitType target = mock(ArchiveUnitType.class); JAXBElement parent = mock(JAXBElement.class); List<String> agenciesList = new ArrayList<>(); Map<String, String> unitIdToGuid = new HashMap<>(); Map<String, String> guidToUnitId = new HashMap<>(); HandlerIO handlerIO = mock(HandlerIO.class); Map<String, LogbookLifeCycleParameters> guidToLifeCycleParameters = new HashMap<>(); ArchiveUnitListener archiveUnitListener = new ArchiveUnitListener(handlerIO, JsonHandler.createObjectNode(), unitIdToGuid, guidToUnitId, null, null, null, null, guidToLifeCycleParameters, new HashSet<>(), LogbookTypeProcess.INGEST_TEST, "OperationID", metaDataClientFactory, null, null, null, UnitType.INGEST, agenciesList, null, null, null, null, null); when(target.getArchiveUnitRefId()).thenReturn(null); ManagementType management = mock(ManagementType.class); when(target.getManagement()).thenReturn(management); UpdateOperationType updateOperation = mock(UpdateOperationType.class); when(management.getUpdateOperation()).thenReturn(updateOperation); when(updateOperation.getSystemId()).thenReturn("aeaaaaaaaaaam7mxabxccakzrw47heqaaaaq"); when(parent.isGlobalScope()).thenReturn(true); RequestResponseOK<JsonNode> resp = new RequestResponseOK<>(); ObjectNode unit = JsonHandler.createObjectNode(); unit.put("#id", "aeaaaaaaaaaam7mxabxccakzrw47heqaaaaq"); unit.put("#unitType", UnitType.INGEST.name()); ArrayNode agencies = JsonHandler.createArrayNode(); agencies.add("AGENCY1").add("AGENCY1"); unit.set("#originating_agencies", agencies); resp.addResult(unit); File file = temporaryFolder.newFile(); when(handlerIO.getNewLocalFile(anyString())).thenReturn(file); when(metaDataClient.selectUnits(any())).thenReturn(resp.toJsonNode()); try { archiveUnitListener.afterUnmarshal(target, parent); } catch (Exception e) { e.printStackTrace(); fail("Should not throws an exception"); } assertThat(agenciesList).hasSize(2); }
@Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ArchiveUnitType) { ArchiveUnitType archiveUnitType = (ArchiveUnitType) target; String sedaAchiveUnitId = archiveUnitType.getId(); JAXBElement jaxbElementParent = (JAXBElement) parent; String elementGUID = GUIDFactory.newUnitGUID(ParameterHelper.getTenantParameter()).toString(); checkAutoAttachmentsByIngestContract(); boolean isValidAttachment = archiveUnitType.getManagement() != null && archiveUnitType.getManagement().getUpdateOperation() != null && (archiveUnitType.getManagement().getUpdateOperation().getSystemId() != null || archiveUnitType.getManagement().getUpdateOperation().getArchiveUnitIdentifierKey() != null); if (isValidAttachment) { elementGUID = attachArchiveUnitToExisting(archiveUnitType, sedaAchiveUnitId); } if (archiveUnitType.getArchiveUnitRefId() != null && !jaxbElementParent.isGlobalScope()) { if (!archiveUnitType.getArchiveUnitRefId().equals(archiveUnitType.getArchiveUnitRefId().trim())) { throw new VitamRuntimeException(new ProcessingMalformedDataException( "The ArchiveUnitRefId " + archiveUnitType.getArchiveUnitRefId() + " contains line break or spaces")); } return; } if (archiveUnitType.getArchiveUnitRefId() != null) { String childArchiveUnitRef = archiveUnitType.getArchiveUnitRefId(); ObjectNode childArchiveUnitNode = (ObjectNode) archiveUnitTree.get(childArchiveUnitRef); if (childArchiveUnitNode == null) { childArchiveUnitNode = JsonHandler.createObjectNode(); } final ArrayNode parentsField = childArchiveUnitNode.withArray(SedaConstants.PREFIX_UP); parentsField.addAll((ArrayNode) archiveUnitTree.get(sedaAchiveUnitId).get(SedaConstants.PREFIX_UP)); archiveUnitTree.set(childArchiveUnitRef, childArchiveUnitNode); archiveUnitTree.without(sedaAchiveUnitId); return; } List<Object> archiveUnitOrDataObjectReferenceOrAny = archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup(); String groupId = buildGraph(sedaAchiveUnitId, elementGUID, archiveUnitOrDataObjectReferenceOrAny); ObjectNode archiveUnitNode = (ObjectNode) archiveUnitTree.get(sedaAchiveUnitId); if (archiveUnitNode == null) { archiveUnitNode = JsonHandler.createObjectNode(); } fillCustodialHistoryReference(archiveUnitType); archiveUnitTree.set(sedaAchiveUnitId, archiveUnitNode); unitIdToGuid.put(sedaAchiveUnitId, elementGUID); guidToUnitId.put(elementGUID, sedaAchiveUnitId); ArchiveUnitRoot archiveUnitRoot; try { String operationId = handlerIO.getContainerName(); archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, elementGUID, groupId, operationId, workflowUnitType.name()); } catch (ProcessingMalformedDataException | ProcessingObjectReferenceException e) { throw new VitamRuntimeException(e); } DescriptiveMetadataModel descriptiveMetadataModel = archiveUnitRoot.getArchiveUnit().getDescriptiveMetadataModel(); enhanceSignatures(descriptiveMetadataModel); replaceInternalReferenceForRelatedObjectReference(sedaAchiveUnitId, descriptiveMetadataModel); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAccess()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getStorage()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAppraisal()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getClassification()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getDissemination()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getReuse()); if (!existingUnitGuids.contains(elementGUID)) { storeArchiveUnit(elementGUID, archiveUnitRoot); createUnitLifeCycle(elementGUID, containerId, logbookTypeProcess); } archiveUnitType.setManagement(null); archiveUnitType.setContent(null); archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup().clear(); archiveUnitType.setArchiveUnitRefId(sedaAchiveUnitId); } super.afterUnmarshal(target, parent); }
ArchiveUnitListener extends Unmarshaller.Listener { @Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ArchiveUnitType) { ArchiveUnitType archiveUnitType = (ArchiveUnitType) target; String sedaAchiveUnitId = archiveUnitType.getId(); JAXBElement jaxbElementParent = (JAXBElement) parent; String elementGUID = GUIDFactory.newUnitGUID(ParameterHelper.getTenantParameter()).toString(); checkAutoAttachmentsByIngestContract(); boolean isValidAttachment = archiveUnitType.getManagement() != null && archiveUnitType.getManagement().getUpdateOperation() != null && (archiveUnitType.getManagement().getUpdateOperation().getSystemId() != null || archiveUnitType.getManagement().getUpdateOperation().getArchiveUnitIdentifierKey() != null); if (isValidAttachment) { elementGUID = attachArchiveUnitToExisting(archiveUnitType, sedaAchiveUnitId); } if (archiveUnitType.getArchiveUnitRefId() != null && !jaxbElementParent.isGlobalScope()) { if (!archiveUnitType.getArchiveUnitRefId().equals(archiveUnitType.getArchiveUnitRefId().trim())) { throw new VitamRuntimeException(new ProcessingMalformedDataException( "The ArchiveUnitRefId " + archiveUnitType.getArchiveUnitRefId() + " contains line break or spaces")); } return; } if (archiveUnitType.getArchiveUnitRefId() != null) { String childArchiveUnitRef = archiveUnitType.getArchiveUnitRefId(); ObjectNode childArchiveUnitNode = (ObjectNode) archiveUnitTree.get(childArchiveUnitRef); if (childArchiveUnitNode == null) { childArchiveUnitNode = JsonHandler.createObjectNode(); } final ArrayNode parentsField = childArchiveUnitNode.withArray(SedaConstants.PREFIX_UP); parentsField.addAll((ArrayNode) archiveUnitTree.get(sedaAchiveUnitId).get(SedaConstants.PREFIX_UP)); archiveUnitTree.set(childArchiveUnitRef, childArchiveUnitNode); archiveUnitTree.without(sedaAchiveUnitId); return; } List<Object> archiveUnitOrDataObjectReferenceOrAny = archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup(); String groupId = buildGraph(sedaAchiveUnitId, elementGUID, archiveUnitOrDataObjectReferenceOrAny); ObjectNode archiveUnitNode = (ObjectNode) archiveUnitTree.get(sedaAchiveUnitId); if (archiveUnitNode == null) { archiveUnitNode = JsonHandler.createObjectNode(); } fillCustodialHistoryReference(archiveUnitType); archiveUnitTree.set(sedaAchiveUnitId, archiveUnitNode); unitIdToGuid.put(sedaAchiveUnitId, elementGUID); guidToUnitId.put(elementGUID, sedaAchiveUnitId); ArchiveUnitRoot archiveUnitRoot; try { String operationId = handlerIO.getContainerName(); archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, elementGUID, groupId, operationId, workflowUnitType.name()); } catch (ProcessingMalformedDataException | ProcessingObjectReferenceException e) { throw new VitamRuntimeException(e); } DescriptiveMetadataModel descriptiveMetadataModel = archiveUnitRoot.getArchiveUnit().getDescriptiveMetadataModel(); enhanceSignatures(descriptiveMetadataModel); replaceInternalReferenceForRelatedObjectReference(sedaAchiveUnitId, descriptiveMetadataModel); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAccess()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getStorage()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAppraisal()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getClassification()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getDissemination()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getReuse()); if (!existingUnitGuids.contains(elementGUID)) { storeArchiveUnit(elementGUID, archiveUnitRoot); createUnitLifeCycle(elementGUID, containerId, logbookTypeProcess); } archiveUnitType.setManagement(null); archiveUnitType.setContent(null); archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup().clear(); archiveUnitType.setArchiveUnitRefId(sedaAchiveUnitId); } super.afterUnmarshal(target, parent); } }
ArchiveUnitListener extends Unmarshaller.Listener { @Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ArchiveUnitType) { ArchiveUnitType archiveUnitType = (ArchiveUnitType) target; String sedaAchiveUnitId = archiveUnitType.getId(); JAXBElement jaxbElementParent = (JAXBElement) parent; String elementGUID = GUIDFactory.newUnitGUID(ParameterHelper.getTenantParameter()).toString(); checkAutoAttachmentsByIngestContract(); boolean isValidAttachment = archiveUnitType.getManagement() != null && archiveUnitType.getManagement().getUpdateOperation() != null && (archiveUnitType.getManagement().getUpdateOperation().getSystemId() != null || archiveUnitType.getManagement().getUpdateOperation().getArchiveUnitIdentifierKey() != null); if (isValidAttachment) { elementGUID = attachArchiveUnitToExisting(archiveUnitType, sedaAchiveUnitId); } if (archiveUnitType.getArchiveUnitRefId() != null && !jaxbElementParent.isGlobalScope()) { if (!archiveUnitType.getArchiveUnitRefId().equals(archiveUnitType.getArchiveUnitRefId().trim())) { throw new VitamRuntimeException(new ProcessingMalformedDataException( "The ArchiveUnitRefId " + archiveUnitType.getArchiveUnitRefId() + " contains line break or spaces")); } return; } if (archiveUnitType.getArchiveUnitRefId() != null) { String childArchiveUnitRef = archiveUnitType.getArchiveUnitRefId(); ObjectNode childArchiveUnitNode = (ObjectNode) archiveUnitTree.get(childArchiveUnitRef); if (childArchiveUnitNode == null) { childArchiveUnitNode = JsonHandler.createObjectNode(); } final ArrayNode parentsField = childArchiveUnitNode.withArray(SedaConstants.PREFIX_UP); parentsField.addAll((ArrayNode) archiveUnitTree.get(sedaAchiveUnitId).get(SedaConstants.PREFIX_UP)); archiveUnitTree.set(childArchiveUnitRef, childArchiveUnitNode); archiveUnitTree.without(sedaAchiveUnitId); return; } List<Object> archiveUnitOrDataObjectReferenceOrAny = archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup(); String groupId = buildGraph(sedaAchiveUnitId, elementGUID, archiveUnitOrDataObjectReferenceOrAny); ObjectNode archiveUnitNode = (ObjectNode) archiveUnitTree.get(sedaAchiveUnitId); if (archiveUnitNode == null) { archiveUnitNode = JsonHandler.createObjectNode(); } fillCustodialHistoryReference(archiveUnitType); archiveUnitTree.set(sedaAchiveUnitId, archiveUnitNode); unitIdToGuid.put(sedaAchiveUnitId, elementGUID); guidToUnitId.put(elementGUID, sedaAchiveUnitId); ArchiveUnitRoot archiveUnitRoot; try { String operationId = handlerIO.getContainerName(); archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, elementGUID, groupId, operationId, workflowUnitType.name()); } catch (ProcessingMalformedDataException | ProcessingObjectReferenceException e) { throw new VitamRuntimeException(e); } DescriptiveMetadataModel descriptiveMetadataModel = archiveUnitRoot.getArchiveUnit().getDescriptiveMetadataModel(); enhanceSignatures(descriptiveMetadataModel); replaceInternalReferenceForRelatedObjectReference(sedaAchiveUnitId, descriptiveMetadataModel); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAccess()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getStorage()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAppraisal()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getClassification()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getDissemination()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getReuse()); if (!existingUnitGuids.contains(elementGUID)) { storeArchiveUnit(elementGUID, archiveUnitRoot); createUnitLifeCycle(elementGUID, containerId, logbookTypeProcess); } archiveUnitType.setManagement(null); archiveUnitType.setContent(null); archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup().clear(); archiveUnitType.setArchiveUnitRefId(sedaAchiveUnitId); } super.afterUnmarshal(target, parent); } ArchiveUnitListener(HandlerIO handlerIO, ObjectNode archiveUnitTree, Map<String, String> unitIdToGuid,
        Map<String, String> guidToUnitId,
        Map<String, String> unitIdToGroupId,
        Map<String, List<String>> objectGroupIdToUnitId,
        Map<String, String> dataObjectIdToObjectGroupId,
        Map<String, GotObj> dataObjectIdWithoutObjectGroupId,
        Map<String, LogbookLifeCycleParameters> guidToLifeCycleParameters,
        Set<String> existingUnitGuids, LogbookTypeProcess logbookTypeProcess, String containerId,
        MetaDataClientFactory metaDataClientFactory,
        Map<String, String> objectGroupIdToGuid,
        Map<String, String> dataObjectIdToGuid, Map<String, Set<String>> unitIdToSetOfRuleId, UnitType workflowUnitType,
        List<String> originatingAgencies, Map<String, JsonNode> existingGOTs,
        Map<String, String> existingUnitIdWithExistingObjectGroup,
        Map<String, Boolean> isThereManifestRelatedReferenceRemained,
        Map<String, String> existingGOTGUIDToNewGotGUIDInAttachment,
        AdminManagementClientFactory adminManagementClientFactory); }
ArchiveUnitListener extends Unmarshaller.Listener { @Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ArchiveUnitType) { ArchiveUnitType archiveUnitType = (ArchiveUnitType) target; String sedaAchiveUnitId = archiveUnitType.getId(); JAXBElement jaxbElementParent = (JAXBElement) parent; String elementGUID = GUIDFactory.newUnitGUID(ParameterHelper.getTenantParameter()).toString(); checkAutoAttachmentsByIngestContract(); boolean isValidAttachment = archiveUnitType.getManagement() != null && archiveUnitType.getManagement().getUpdateOperation() != null && (archiveUnitType.getManagement().getUpdateOperation().getSystemId() != null || archiveUnitType.getManagement().getUpdateOperation().getArchiveUnitIdentifierKey() != null); if (isValidAttachment) { elementGUID = attachArchiveUnitToExisting(archiveUnitType, sedaAchiveUnitId); } if (archiveUnitType.getArchiveUnitRefId() != null && !jaxbElementParent.isGlobalScope()) { if (!archiveUnitType.getArchiveUnitRefId().equals(archiveUnitType.getArchiveUnitRefId().trim())) { throw new VitamRuntimeException(new ProcessingMalformedDataException( "The ArchiveUnitRefId " + archiveUnitType.getArchiveUnitRefId() + " contains line break or spaces")); } return; } if (archiveUnitType.getArchiveUnitRefId() != null) { String childArchiveUnitRef = archiveUnitType.getArchiveUnitRefId(); ObjectNode childArchiveUnitNode = (ObjectNode) archiveUnitTree.get(childArchiveUnitRef); if (childArchiveUnitNode == null) { childArchiveUnitNode = JsonHandler.createObjectNode(); } final ArrayNode parentsField = childArchiveUnitNode.withArray(SedaConstants.PREFIX_UP); parentsField.addAll((ArrayNode) archiveUnitTree.get(sedaAchiveUnitId).get(SedaConstants.PREFIX_UP)); archiveUnitTree.set(childArchiveUnitRef, childArchiveUnitNode); archiveUnitTree.without(sedaAchiveUnitId); return; } List<Object> archiveUnitOrDataObjectReferenceOrAny = archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup(); String groupId = buildGraph(sedaAchiveUnitId, elementGUID, archiveUnitOrDataObjectReferenceOrAny); ObjectNode archiveUnitNode = (ObjectNode) archiveUnitTree.get(sedaAchiveUnitId); if (archiveUnitNode == null) { archiveUnitNode = JsonHandler.createObjectNode(); } fillCustodialHistoryReference(archiveUnitType); archiveUnitTree.set(sedaAchiveUnitId, archiveUnitNode); unitIdToGuid.put(sedaAchiveUnitId, elementGUID); guidToUnitId.put(elementGUID, sedaAchiveUnitId); ArchiveUnitRoot archiveUnitRoot; try { String operationId = handlerIO.getContainerName(); archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, elementGUID, groupId, operationId, workflowUnitType.name()); } catch (ProcessingMalformedDataException | ProcessingObjectReferenceException e) { throw new VitamRuntimeException(e); } DescriptiveMetadataModel descriptiveMetadataModel = archiveUnitRoot.getArchiveUnit().getDescriptiveMetadataModel(); enhanceSignatures(descriptiveMetadataModel); replaceInternalReferenceForRelatedObjectReference(sedaAchiveUnitId, descriptiveMetadataModel); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAccess()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getStorage()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAppraisal()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getClassification()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getDissemination()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getReuse()); if (!existingUnitGuids.contains(elementGUID)) { storeArchiveUnit(elementGUID, archiveUnitRoot); createUnitLifeCycle(elementGUID, containerId, logbookTypeProcess); } archiveUnitType.setManagement(null); archiveUnitType.setContent(null); archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup().clear(); archiveUnitType.setArchiveUnitRefId(sedaAchiveUnitId); } super.afterUnmarshal(target, parent); } ArchiveUnitListener(HandlerIO handlerIO, ObjectNode archiveUnitTree, Map<String, String> unitIdToGuid,
        Map<String, String> guidToUnitId,
        Map<String, String> unitIdToGroupId,
        Map<String, List<String>> objectGroupIdToUnitId,
        Map<String, String> dataObjectIdToObjectGroupId,
        Map<String, GotObj> dataObjectIdWithoutObjectGroupId,
        Map<String, LogbookLifeCycleParameters> guidToLifeCycleParameters,
        Set<String> existingUnitGuids, LogbookTypeProcess logbookTypeProcess, String containerId,
        MetaDataClientFactory metaDataClientFactory,
        Map<String, String> objectGroupIdToGuid,
        Map<String, String> dataObjectIdToGuid, Map<String, Set<String>> unitIdToSetOfRuleId, UnitType workflowUnitType,
        List<String> originatingAgencies, Map<String, JsonNode> existingGOTs,
        Map<String, String> existingUnitIdWithExistingObjectGroup,
        Map<String, Boolean> isThereManifestRelatedReferenceRemained,
        Map<String, String> existingGOTGUIDToNewGotGUIDInAttachment,
        AdminManagementClientFactory adminManagementClientFactory); @Override void afterUnmarshal(Object target, Object parent); IngestContractModel loadIngestContract(String ingestContractIdentifier); }
ArchiveUnitListener extends Unmarshaller.Listener { @Override public void afterUnmarshal(Object target, Object parent) { if (target instanceof ArchiveUnitType) { ArchiveUnitType archiveUnitType = (ArchiveUnitType) target; String sedaAchiveUnitId = archiveUnitType.getId(); JAXBElement jaxbElementParent = (JAXBElement) parent; String elementGUID = GUIDFactory.newUnitGUID(ParameterHelper.getTenantParameter()).toString(); checkAutoAttachmentsByIngestContract(); boolean isValidAttachment = archiveUnitType.getManagement() != null && archiveUnitType.getManagement().getUpdateOperation() != null && (archiveUnitType.getManagement().getUpdateOperation().getSystemId() != null || archiveUnitType.getManagement().getUpdateOperation().getArchiveUnitIdentifierKey() != null); if (isValidAttachment) { elementGUID = attachArchiveUnitToExisting(archiveUnitType, sedaAchiveUnitId); } if (archiveUnitType.getArchiveUnitRefId() != null && !jaxbElementParent.isGlobalScope()) { if (!archiveUnitType.getArchiveUnitRefId().equals(archiveUnitType.getArchiveUnitRefId().trim())) { throw new VitamRuntimeException(new ProcessingMalformedDataException( "The ArchiveUnitRefId " + archiveUnitType.getArchiveUnitRefId() + " contains line break or spaces")); } return; } if (archiveUnitType.getArchiveUnitRefId() != null) { String childArchiveUnitRef = archiveUnitType.getArchiveUnitRefId(); ObjectNode childArchiveUnitNode = (ObjectNode) archiveUnitTree.get(childArchiveUnitRef); if (childArchiveUnitNode == null) { childArchiveUnitNode = JsonHandler.createObjectNode(); } final ArrayNode parentsField = childArchiveUnitNode.withArray(SedaConstants.PREFIX_UP); parentsField.addAll((ArrayNode) archiveUnitTree.get(sedaAchiveUnitId).get(SedaConstants.PREFIX_UP)); archiveUnitTree.set(childArchiveUnitRef, childArchiveUnitNode); archiveUnitTree.without(sedaAchiveUnitId); return; } List<Object> archiveUnitOrDataObjectReferenceOrAny = archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup(); String groupId = buildGraph(sedaAchiveUnitId, elementGUID, archiveUnitOrDataObjectReferenceOrAny); ObjectNode archiveUnitNode = (ObjectNode) archiveUnitTree.get(sedaAchiveUnitId); if (archiveUnitNode == null) { archiveUnitNode = JsonHandler.createObjectNode(); } fillCustodialHistoryReference(archiveUnitType); archiveUnitTree.set(sedaAchiveUnitId, archiveUnitNode); unitIdToGuid.put(sedaAchiveUnitId, elementGUID); guidToUnitId.put(elementGUID, sedaAchiveUnitId); ArchiveUnitRoot archiveUnitRoot; try { String operationId = handlerIO.getContainerName(); archiveUnitRoot = archiveUnitMapper.map(archiveUnitType, elementGUID, groupId, operationId, workflowUnitType.name()); } catch (ProcessingMalformedDataException | ProcessingObjectReferenceException e) { throw new VitamRuntimeException(e); } DescriptiveMetadataModel descriptiveMetadataModel = archiveUnitRoot.getArchiveUnit().getDescriptiveMetadataModel(); enhanceSignatures(descriptiveMetadataModel); replaceInternalReferenceForRelatedObjectReference(sedaAchiveUnitId, descriptiveMetadataModel); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAccess()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getStorage()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getAppraisal()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getClassification()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getDissemination()); fillListRulesToMap(sedaAchiveUnitId, archiveUnitRoot.getArchiveUnit().getManagement().getReuse()); if (!existingUnitGuids.contains(elementGUID)) { storeArchiveUnit(elementGUID, archiveUnitRoot); createUnitLifeCycle(elementGUID, containerId, logbookTypeProcess); } archiveUnitType.setManagement(null); archiveUnitType.setContent(null); archiveUnitType.getArchiveUnitOrDataObjectReferenceOrDataObjectGroup().clear(); archiveUnitType.setArchiveUnitRefId(sedaAchiveUnitId); } super.afterUnmarshal(target, parent); } ArchiveUnitListener(HandlerIO handlerIO, ObjectNode archiveUnitTree, Map<String, String> unitIdToGuid,
        Map<String, String> guidToUnitId,
        Map<String, String> unitIdToGroupId,
        Map<String, List<String>> objectGroupIdToUnitId,
        Map<String, String> dataObjectIdToObjectGroupId,
        Map<String, GotObj> dataObjectIdWithoutObjectGroupId,
        Map<String, LogbookLifeCycleParameters> guidToLifeCycleParameters,
        Set<String> existingUnitGuids, LogbookTypeProcess logbookTypeProcess, String containerId,
        MetaDataClientFactory metaDataClientFactory,
        Map<String, String> objectGroupIdToGuid,
        Map<String, String> dataObjectIdToGuid, Map<String, Set<String>> unitIdToSetOfRuleId, UnitType workflowUnitType,
        List<String> originatingAgencies, Map<String, JsonNode> existingGOTs,
        Map<String, String> existingUnitIdWithExistingObjectGroup,
        Map<String, Boolean> isThereManifestRelatedReferenceRemained,
        Map<String, String> existingGOTGUIDToNewGotGUIDInAttachment,
        AdminManagementClientFactory adminManagementClientFactory); @Override void afterUnmarshal(Object target, Object parent); IngestContractModel loadIngestContract(String ingestContractIdentifier);  }