@Test @RunWithCustomExecutor public void given_manifest_with_signature_in_content() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); prepareResponseOKForAdminManagementClientFindIngestContracts(INGEST_CONTRACT_NO_CHECK); final InputStream sedaLocal = new FileInputStream(PropertiesUtils.findFile("SIP_with_signature_in_content.xml")); when(workspaceClient.getObject(any(), eq("SIP/manifest.xml"))) .thenReturn(Response.status(Status.OK).entity(sedaLocal).build()); handlerIO.addOutIOParameters(out); final ItemStatus response = handler.execute(params, handlerIO); assertThat(response.getGlobalStatus()).isEqualTo(StatusCode.OK); }
@Override public ItemStatus execute(WorkerParameters params, HandlerIO ioParam) { checkMandatoryParameters(params); handlerIO = ioParam; final ItemStatus globalCompositeItemStatus = new ItemStatus(HANDLER_ID); UnitType workflowUnitType = getUnitType(); try (LogbookLifeCyclesClient lifeCycleClient = handlerIO.getLifecyclesClient()) { if (asyncIO) { handlerIO.enableAsync(true); } checkMandatoryIOParameter(ioParam); globalSedaParametersFile = handlerIO.getNewLocalFile(handlerIO.getOutput(GLOBAL_SEDA_PARAMETERS_FILE_IO_RANK).getPath()); unmarshaller = jaxbContext.createUnmarshaller(); listener = new ArchiveUnitListener(handlerIO, archiveUnitTree, unitIdToGuid, guidToUnitId, unitIdToGroupId, objectGroupIdToUnitId, dataObjectIdToObjectGroupId, dataObjectIdWithoutObjectGroupId, guidToLifeCycleParameters, existingUnitGuids, params.getLogbookTypeProcess(), params.getContainerName(), metaDataClientFactory, objectGroupIdToGuid, dataObjectIdToGuid, unitIdToSetOfRuleId, workflowUnitType, originatingAgencies, existingGOTs, existingUnitIdWithExistingObjectGroup, isThereManifestRelatedReferenceRemained, existingGOTGUIDToNewGotGUIDInAttachment, adminManagementClientFactory); unmarshaller.setListener(listener); ObjectNode evDetData = extractSEDA(lifeCycleClient, params, globalCompositeItemStatus, workflowUnitType); if (!existingUnitGuids.isEmpty()) { evDetData.set(ATTACHMENT_IDS, JsonHandler.toJsonNode(existingUnitGuids)); } globalCompositeItemStatus.setEvDetailData(JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.setMasterData(LogbookParameterName.eventDetailData.name(), JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.increment(StatusCode.OK); if (asyncIO) { handlerIO.enableAsync(false); } ObjectNode agIdExt = JsonHandler.createObjectNode(); if (originatingAgency != null) { LOGGER.debug("supplier service is: " + originatingAgency); agIdExt.put(ORIGIN_ANGENCY_NAME, originatingAgency); } if (transferringAgency != null) { LOGGER.debug("Find a transfAgency: " + transferringAgency); agIdExt.put(TRANSFER_AGENCY, transferringAgency); } if (archivalAgency != null) { LOGGER.debug("Find a archivalAgency: " + archivalAgency); agIdExt.put(ARCHIVAL_AGENCY, archivalAgency); } if (submissionAgencyIdentifier != null) { LOGGER.debug("Find a submissionAgencyIdentifier: " + submissionAgencyIdentifier); agIdExt.put(ORIGIN_ANGENCY_SUBMISSION, submissionAgencyIdentifier); } if (agIdExt.size() > 0) { globalCompositeItemStatus.setMasterData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); } ObjectNode rightsStatementIdentifier = JsonHandler.createObjectNode(); if (ingestContract != null) { LOGGER.debug("contract name is: " + ingestContract.getIdentifier()); rightsStatementIdentifier.put(ARCHIVAl_AGREEMENT, ingestContract.getIdentifier()); } if (archivalProfile != null) { LOGGER.debug("archivalProfile is: " + archivalProfile); rightsStatementIdentifier.put(ARCHIVAl_PROFIL, archivalProfile); } extractOntology(); if (rightsStatementIdentifier.size() > 0) { globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); globalCompositeItemStatus .setMasterData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); ObjectNode data; data = (ObjectNode) JsonHandler.getFromString(globalCompositeItemStatus.getEvDetailData()); data.set(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier); globalCompositeItemStatus.setEvDetailData(data.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); } } catch (final ProcessingDuplicatedVersionException e) { LOGGER.debug("ProcessingException: duplicated version", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotFoundException e) { LOGGER.debug("ProcessingException : " + e.getType() + " not found", e); String message; if (e.getType() == ExceptionType.UNIT) { message = getMessageItemStatusAUNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } else { message = getMessageItemStatusOGNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } updateDetailItemStatus(globalCompositeItemStatus, message, e.getTaskKey()); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyUnitsFoundException e) { LOGGER.debug("ProcessingException : multiple units found", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUNotFound(e.getUnitId(), e.getUnitGuid(), e.isValidGuid()), SUBTASK_TOO_MANY_FOUND_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyVersionsByUsageException e) { LOGGER.debug("ProcessingException :", e); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(JsonHandler.createObjectNode().put("MsgError", e.getMessage())), SUBTASK_TOO_MANY_VERSION_BY_USAGE); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingMalformedDataException e) { LOGGER.debug("ProcessingException : Missing or malformed data in the manifest", e); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), SUBTASK_MALFORMED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectReferenceException e) { LOGGER.error("ProcessingObjectReferenceException: archive unit references more than one got"); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), AU_REFRENCES_MULTIPLE_GOT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingManifestReferenceException e) { LOGGER.debug("ProcessingException : reference incorrect in Manifest", e); updateItemStatusForManifestReferenceException(globalCompositeItemStatus, e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final MissingFieldException e) { LOGGER.debug("MissingFieldException", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupMasterMandatoryException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTMasterMandatory(e.getObjectGroupId()), MASTER_MANDATORY_REQUIRED); } catch (ProcessingObjectGroupEveryDataObjectVersionException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTEveryDataObjectVersion(e.getUnitId(), e.getObjectGroupId()), ATTACHMENT_OBJECTGROUP); } catch (final ArchiveUnitContainDataObjectException e) { LOGGER.debug("ProcessingException: archive unit contain an data object declared object group.", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUDeclaringObject(e.getUnitId(), e.getBdoId(), e.getGotId()), EXISTING_OG_NOT_DECLARED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ArchiveUnitContainSpecialCharactersException e) { LOGGER.debug("ProcessingException: archive unit contains special characters.", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingUnitLinkingException e) { LOGGER.debug("ProcessingException: Linking FILING_UNIT or HOLDING_UNIT to INGEST Unauthorized", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAULinkingException(e), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentUnauthorizedException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotValidLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentRequiredException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_ATTACHMENT_REQUIRED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTLinkingException(e.getUnitId(), e.getObjectGroupId()), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingException | WorkerspaceQueueException | InvalidParseOperationException e) { LOGGER.debug("ProcessingException ", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } catch (final CycleFoundException e) { LOGGER.debug("ProcessingException: cycle found", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, e.getCycle(), SUBTASK_LOOP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (JAXBException e) { LOGGER.error("unable to create ExtractSeda handler, unmarshaller failed", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } finally { unitIdToGuid.clear(); guidToUnitId.clear(); dataObjectIdWithoutObjectGroupId.clear(); objectGroupIdToDataObjectId.clear(); guidToLifeCycleParameters.clear(); objectGuidToDataObject.clear(); dataObjectIdToDetailDataObject.clear(); existingGOTs.clear(); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, globalCompositeItemStatus); }
ExtractSedaActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO ioParam) { checkMandatoryParameters(params); handlerIO = ioParam; final ItemStatus globalCompositeItemStatus = new ItemStatus(HANDLER_ID); UnitType workflowUnitType = getUnitType(); try (LogbookLifeCyclesClient lifeCycleClient = handlerIO.getLifecyclesClient()) { if (asyncIO) { handlerIO.enableAsync(true); } checkMandatoryIOParameter(ioParam); globalSedaParametersFile = handlerIO.getNewLocalFile(handlerIO.getOutput(GLOBAL_SEDA_PARAMETERS_FILE_IO_RANK).getPath()); unmarshaller = jaxbContext.createUnmarshaller(); listener = new ArchiveUnitListener(handlerIO, archiveUnitTree, unitIdToGuid, guidToUnitId, unitIdToGroupId, objectGroupIdToUnitId, dataObjectIdToObjectGroupId, dataObjectIdWithoutObjectGroupId, guidToLifeCycleParameters, existingUnitGuids, params.getLogbookTypeProcess(), params.getContainerName(), metaDataClientFactory, objectGroupIdToGuid, dataObjectIdToGuid, unitIdToSetOfRuleId, workflowUnitType, originatingAgencies, existingGOTs, existingUnitIdWithExistingObjectGroup, isThereManifestRelatedReferenceRemained, existingGOTGUIDToNewGotGUIDInAttachment, adminManagementClientFactory); unmarshaller.setListener(listener); ObjectNode evDetData = extractSEDA(lifeCycleClient, params, globalCompositeItemStatus, workflowUnitType); if (!existingUnitGuids.isEmpty()) { evDetData.set(ATTACHMENT_IDS, JsonHandler.toJsonNode(existingUnitGuids)); } globalCompositeItemStatus.setEvDetailData(JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.setMasterData(LogbookParameterName.eventDetailData.name(), JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.increment(StatusCode.OK); if (asyncIO) { handlerIO.enableAsync(false); } ObjectNode agIdExt = JsonHandler.createObjectNode(); if (originatingAgency != null) { LOGGER.debug("supplier service is: " + originatingAgency); agIdExt.put(ORIGIN_ANGENCY_NAME, originatingAgency); } if (transferringAgency != null) { LOGGER.debug("Find a transfAgency: " + transferringAgency); agIdExt.put(TRANSFER_AGENCY, transferringAgency); } if (archivalAgency != null) { LOGGER.debug("Find a archivalAgency: " + archivalAgency); agIdExt.put(ARCHIVAL_AGENCY, archivalAgency); } if (submissionAgencyIdentifier != null) { LOGGER.debug("Find a submissionAgencyIdentifier: " + submissionAgencyIdentifier); agIdExt.put(ORIGIN_ANGENCY_SUBMISSION, submissionAgencyIdentifier); } if (agIdExt.size() > 0) { globalCompositeItemStatus.setMasterData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); } ObjectNode rightsStatementIdentifier = JsonHandler.createObjectNode(); if (ingestContract != null) { LOGGER.debug("contract name is: " + ingestContract.getIdentifier()); rightsStatementIdentifier.put(ARCHIVAl_AGREEMENT, ingestContract.getIdentifier()); } if (archivalProfile != null) { LOGGER.debug("archivalProfile is: " + archivalProfile); rightsStatementIdentifier.put(ARCHIVAl_PROFIL, archivalProfile); } extractOntology(); if (rightsStatementIdentifier.size() > 0) { globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); globalCompositeItemStatus .setMasterData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); ObjectNode data; data = (ObjectNode) JsonHandler.getFromString(globalCompositeItemStatus.getEvDetailData()); data.set(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier); globalCompositeItemStatus.setEvDetailData(data.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); } } catch (final ProcessingDuplicatedVersionException e) { LOGGER.debug("ProcessingException: duplicated version", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotFoundException e) { LOGGER.debug("ProcessingException : " + e.getType() + " not found", e); String message; if (e.getType() == ExceptionType.UNIT) { message = getMessageItemStatusAUNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } else { message = getMessageItemStatusOGNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } updateDetailItemStatus(globalCompositeItemStatus, message, e.getTaskKey()); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyUnitsFoundException e) { LOGGER.debug("ProcessingException : multiple units found", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUNotFound(e.getUnitId(), e.getUnitGuid(), e.isValidGuid()), SUBTASK_TOO_MANY_FOUND_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyVersionsByUsageException e) { LOGGER.debug("ProcessingException :", e); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(JsonHandler.createObjectNode().put("MsgError", e.getMessage())), SUBTASK_TOO_MANY_VERSION_BY_USAGE); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingMalformedDataException e) { LOGGER.debug("ProcessingException : Missing or malformed data in the manifest", e); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), SUBTASK_MALFORMED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectReferenceException e) { LOGGER.error("ProcessingObjectReferenceException: archive unit references more than one got"); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), AU_REFRENCES_MULTIPLE_GOT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingManifestReferenceException e) { LOGGER.debug("ProcessingException : reference incorrect in Manifest", e); updateItemStatusForManifestReferenceException(globalCompositeItemStatus, e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final MissingFieldException e) { LOGGER.debug("MissingFieldException", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupMasterMandatoryException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTMasterMandatory(e.getObjectGroupId()), MASTER_MANDATORY_REQUIRED); } catch (ProcessingObjectGroupEveryDataObjectVersionException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTEveryDataObjectVersion(e.getUnitId(), e.getObjectGroupId()), ATTACHMENT_OBJECTGROUP); } catch (final ArchiveUnitContainDataObjectException e) { LOGGER.debug("ProcessingException: archive unit contain an data object declared object group.", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUDeclaringObject(e.getUnitId(), e.getBdoId(), e.getGotId()), EXISTING_OG_NOT_DECLARED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ArchiveUnitContainSpecialCharactersException e) { LOGGER.debug("ProcessingException: archive unit contains special characters.", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingUnitLinkingException e) { LOGGER.debug("ProcessingException: Linking FILING_UNIT or HOLDING_UNIT to INGEST Unauthorized", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAULinkingException(e), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentUnauthorizedException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotValidLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentRequiredException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_ATTACHMENT_REQUIRED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTLinkingException(e.getUnitId(), e.getObjectGroupId()), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingException | WorkerspaceQueueException | InvalidParseOperationException e) { LOGGER.debug("ProcessingException ", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } catch (final CycleFoundException e) { LOGGER.debug("ProcessingException: cycle found", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, e.getCycle(), SUBTASK_LOOP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (JAXBException e) { LOGGER.error("unable to create ExtractSeda handler, unmarshaller failed", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } finally { unitIdToGuid.clear(); guidToUnitId.clear(); dataObjectIdWithoutObjectGroupId.clear(); objectGroupIdToDataObjectId.clear(); guidToLifeCycleParameters.clear(); objectGuidToDataObject.clear(); dataObjectIdToDetailDataObject.clear(); existingGOTs.clear(); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, globalCompositeItemStatus); } }
ExtractSedaActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO ioParam) { checkMandatoryParameters(params); handlerIO = ioParam; final ItemStatus globalCompositeItemStatus = new ItemStatus(HANDLER_ID); UnitType workflowUnitType = getUnitType(); try (LogbookLifeCyclesClient lifeCycleClient = handlerIO.getLifecyclesClient()) { if (asyncIO) { handlerIO.enableAsync(true); } checkMandatoryIOParameter(ioParam); globalSedaParametersFile = handlerIO.getNewLocalFile(handlerIO.getOutput(GLOBAL_SEDA_PARAMETERS_FILE_IO_RANK).getPath()); unmarshaller = jaxbContext.createUnmarshaller(); listener = new ArchiveUnitListener(handlerIO, archiveUnitTree, unitIdToGuid, guidToUnitId, unitIdToGroupId, objectGroupIdToUnitId, dataObjectIdToObjectGroupId, dataObjectIdWithoutObjectGroupId, guidToLifeCycleParameters, existingUnitGuids, params.getLogbookTypeProcess(), params.getContainerName(), metaDataClientFactory, objectGroupIdToGuid, dataObjectIdToGuid, unitIdToSetOfRuleId, workflowUnitType, originatingAgencies, existingGOTs, existingUnitIdWithExistingObjectGroup, isThereManifestRelatedReferenceRemained, existingGOTGUIDToNewGotGUIDInAttachment, adminManagementClientFactory); unmarshaller.setListener(listener); ObjectNode evDetData = extractSEDA(lifeCycleClient, params, globalCompositeItemStatus, workflowUnitType); if (!existingUnitGuids.isEmpty()) { evDetData.set(ATTACHMENT_IDS, JsonHandler.toJsonNode(existingUnitGuids)); } globalCompositeItemStatus.setEvDetailData(JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.setMasterData(LogbookParameterName.eventDetailData.name(), JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.increment(StatusCode.OK); if (asyncIO) { handlerIO.enableAsync(false); } ObjectNode agIdExt = JsonHandler.createObjectNode(); if (originatingAgency != null) { LOGGER.debug("supplier service is: " + originatingAgency); agIdExt.put(ORIGIN_ANGENCY_NAME, originatingAgency); } if (transferringAgency != null) { LOGGER.debug("Find a transfAgency: " + transferringAgency); agIdExt.put(TRANSFER_AGENCY, transferringAgency); } if (archivalAgency != null) { LOGGER.debug("Find a archivalAgency: " + archivalAgency); agIdExt.put(ARCHIVAL_AGENCY, archivalAgency); } if (submissionAgencyIdentifier != null) { LOGGER.debug("Find a submissionAgencyIdentifier: " + submissionAgencyIdentifier); agIdExt.put(ORIGIN_ANGENCY_SUBMISSION, submissionAgencyIdentifier); } if (agIdExt.size() > 0) { globalCompositeItemStatus.setMasterData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); } ObjectNode rightsStatementIdentifier = JsonHandler.createObjectNode(); if (ingestContract != null) { LOGGER.debug("contract name is: " + ingestContract.getIdentifier()); rightsStatementIdentifier.put(ARCHIVAl_AGREEMENT, ingestContract.getIdentifier()); } if (archivalProfile != null) { LOGGER.debug("archivalProfile is: " + archivalProfile); rightsStatementIdentifier.put(ARCHIVAl_PROFIL, archivalProfile); } extractOntology(); if (rightsStatementIdentifier.size() > 0) { globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); globalCompositeItemStatus .setMasterData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); ObjectNode data; data = (ObjectNode) JsonHandler.getFromString(globalCompositeItemStatus.getEvDetailData()); data.set(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier); globalCompositeItemStatus.setEvDetailData(data.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); } } catch (final ProcessingDuplicatedVersionException e) { LOGGER.debug("ProcessingException: duplicated version", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotFoundException e) { LOGGER.debug("ProcessingException : " + e.getType() + " not found", e); String message; if (e.getType() == ExceptionType.UNIT) { message = getMessageItemStatusAUNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } else { message = getMessageItemStatusOGNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } updateDetailItemStatus(globalCompositeItemStatus, message, e.getTaskKey()); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyUnitsFoundException e) { LOGGER.debug("ProcessingException : multiple units found", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUNotFound(e.getUnitId(), e.getUnitGuid(), e.isValidGuid()), SUBTASK_TOO_MANY_FOUND_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyVersionsByUsageException e) { LOGGER.debug("ProcessingException :", e); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(JsonHandler.createObjectNode().put("MsgError", e.getMessage())), SUBTASK_TOO_MANY_VERSION_BY_USAGE); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingMalformedDataException e) { LOGGER.debug("ProcessingException : Missing or malformed data in the manifest", e); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), SUBTASK_MALFORMED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectReferenceException e) { LOGGER.error("ProcessingObjectReferenceException: archive unit references more than one got"); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), AU_REFRENCES_MULTIPLE_GOT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingManifestReferenceException e) { LOGGER.debug("ProcessingException : reference incorrect in Manifest", e); updateItemStatusForManifestReferenceException(globalCompositeItemStatus, e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final MissingFieldException e) { LOGGER.debug("MissingFieldException", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupMasterMandatoryException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTMasterMandatory(e.getObjectGroupId()), MASTER_MANDATORY_REQUIRED); } catch (ProcessingObjectGroupEveryDataObjectVersionException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTEveryDataObjectVersion(e.getUnitId(), e.getObjectGroupId()), ATTACHMENT_OBJECTGROUP); } catch (final ArchiveUnitContainDataObjectException e) { LOGGER.debug("ProcessingException: archive unit contain an data object declared object group.", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUDeclaringObject(e.getUnitId(), e.getBdoId(), e.getGotId()), EXISTING_OG_NOT_DECLARED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ArchiveUnitContainSpecialCharactersException e) { LOGGER.debug("ProcessingException: archive unit contains special characters.", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingUnitLinkingException e) { LOGGER.debug("ProcessingException: Linking FILING_UNIT or HOLDING_UNIT to INGEST Unauthorized", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAULinkingException(e), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentUnauthorizedException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotValidLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentRequiredException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_ATTACHMENT_REQUIRED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTLinkingException(e.getUnitId(), e.getObjectGroupId()), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingException | WorkerspaceQueueException | InvalidParseOperationException e) { LOGGER.debug("ProcessingException ", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } catch (final CycleFoundException e) { LOGGER.debug("ProcessingException: cycle found", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, e.getCycle(), SUBTASK_LOOP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (JAXBException e) { LOGGER.error("unable to create ExtractSeda handler, unmarshaller failed", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } finally { unitIdToGuid.clear(); guidToUnitId.clear(); dataObjectIdWithoutObjectGroupId.clear(); objectGroupIdToDataObjectId.clear(); guidToLifeCycleParameters.clear(); objectGuidToDataObject.clear(); dataObjectIdToDetailDataObject.clear(); existingGOTs.clear(); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, globalCompositeItemStatus); } ExtractSedaActionHandler(); @VisibleForTesting  ExtractSedaActionHandler(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); }
ExtractSedaActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO ioParam) { checkMandatoryParameters(params); handlerIO = ioParam; final ItemStatus globalCompositeItemStatus = new ItemStatus(HANDLER_ID); UnitType workflowUnitType = getUnitType(); try (LogbookLifeCyclesClient lifeCycleClient = handlerIO.getLifecyclesClient()) { if (asyncIO) { handlerIO.enableAsync(true); } checkMandatoryIOParameter(ioParam); globalSedaParametersFile = handlerIO.getNewLocalFile(handlerIO.getOutput(GLOBAL_SEDA_PARAMETERS_FILE_IO_RANK).getPath()); unmarshaller = jaxbContext.createUnmarshaller(); listener = new ArchiveUnitListener(handlerIO, archiveUnitTree, unitIdToGuid, guidToUnitId, unitIdToGroupId, objectGroupIdToUnitId, dataObjectIdToObjectGroupId, dataObjectIdWithoutObjectGroupId, guidToLifeCycleParameters, existingUnitGuids, params.getLogbookTypeProcess(), params.getContainerName(), metaDataClientFactory, objectGroupIdToGuid, dataObjectIdToGuid, unitIdToSetOfRuleId, workflowUnitType, originatingAgencies, existingGOTs, existingUnitIdWithExistingObjectGroup, isThereManifestRelatedReferenceRemained, existingGOTGUIDToNewGotGUIDInAttachment, adminManagementClientFactory); unmarshaller.setListener(listener); ObjectNode evDetData = extractSEDA(lifeCycleClient, params, globalCompositeItemStatus, workflowUnitType); if (!existingUnitGuids.isEmpty()) { evDetData.set(ATTACHMENT_IDS, JsonHandler.toJsonNode(existingUnitGuids)); } globalCompositeItemStatus.setEvDetailData(JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.setMasterData(LogbookParameterName.eventDetailData.name(), JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.increment(StatusCode.OK); if (asyncIO) { handlerIO.enableAsync(false); } ObjectNode agIdExt = JsonHandler.createObjectNode(); if (originatingAgency != null) { LOGGER.debug("supplier service is: " + originatingAgency); agIdExt.put(ORIGIN_ANGENCY_NAME, originatingAgency); } if (transferringAgency != null) { LOGGER.debug("Find a transfAgency: " + transferringAgency); agIdExt.put(TRANSFER_AGENCY, transferringAgency); } if (archivalAgency != null) { LOGGER.debug("Find a archivalAgency: " + archivalAgency); agIdExt.put(ARCHIVAL_AGENCY, archivalAgency); } if (submissionAgencyIdentifier != null) { LOGGER.debug("Find a submissionAgencyIdentifier: " + submissionAgencyIdentifier); agIdExt.put(ORIGIN_ANGENCY_SUBMISSION, submissionAgencyIdentifier); } if (agIdExt.size() > 0) { globalCompositeItemStatus.setMasterData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); } ObjectNode rightsStatementIdentifier = JsonHandler.createObjectNode(); if (ingestContract != null) { LOGGER.debug("contract name is: " + ingestContract.getIdentifier()); rightsStatementIdentifier.put(ARCHIVAl_AGREEMENT, ingestContract.getIdentifier()); } if (archivalProfile != null) { LOGGER.debug("archivalProfile is: " + archivalProfile); rightsStatementIdentifier.put(ARCHIVAl_PROFIL, archivalProfile); } extractOntology(); if (rightsStatementIdentifier.size() > 0) { globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); globalCompositeItemStatus .setMasterData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); ObjectNode data; data = (ObjectNode) JsonHandler.getFromString(globalCompositeItemStatus.getEvDetailData()); data.set(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier); globalCompositeItemStatus.setEvDetailData(data.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); } } catch (final ProcessingDuplicatedVersionException e) { LOGGER.debug("ProcessingException: duplicated version", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotFoundException e) { LOGGER.debug("ProcessingException : " + e.getType() + " not found", e); String message; if (e.getType() == ExceptionType.UNIT) { message = getMessageItemStatusAUNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } else { message = getMessageItemStatusOGNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } updateDetailItemStatus(globalCompositeItemStatus, message, e.getTaskKey()); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyUnitsFoundException e) { LOGGER.debug("ProcessingException : multiple units found", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUNotFound(e.getUnitId(), e.getUnitGuid(), e.isValidGuid()), SUBTASK_TOO_MANY_FOUND_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyVersionsByUsageException e) { LOGGER.debug("ProcessingException :", e); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(JsonHandler.createObjectNode().put("MsgError", e.getMessage())), SUBTASK_TOO_MANY_VERSION_BY_USAGE); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingMalformedDataException e) { LOGGER.debug("ProcessingException : Missing or malformed data in the manifest", e); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), SUBTASK_MALFORMED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectReferenceException e) { LOGGER.error("ProcessingObjectReferenceException: archive unit references more than one got"); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), AU_REFRENCES_MULTIPLE_GOT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingManifestReferenceException e) { LOGGER.debug("ProcessingException : reference incorrect in Manifest", e); updateItemStatusForManifestReferenceException(globalCompositeItemStatus, e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final MissingFieldException e) { LOGGER.debug("MissingFieldException", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupMasterMandatoryException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTMasterMandatory(e.getObjectGroupId()), MASTER_MANDATORY_REQUIRED); } catch (ProcessingObjectGroupEveryDataObjectVersionException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTEveryDataObjectVersion(e.getUnitId(), e.getObjectGroupId()), ATTACHMENT_OBJECTGROUP); } catch (final ArchiveUnitContainDataObjectException e) { LOGGER.debug("ProcessingException: archive unit contain an data object declared object group.", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUDeclaringObject(e.getUnitId(), e.getBdoId(), e.getGotId()), EXISTING_OG_NOT_DECLARED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ArchiveUnitContainSpecialCharactersException e) { LOGGER.debug("ProcessingException: archive unit contains special characters.", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingUnitLinkingException e) { LOGGER.debug("ProcessingException: Linking FILING_UNIT or HOLDING_UNIT to INGEST Unauthorized", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAULinkingException(e), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentUnauthorizedException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotValidLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentRequiredException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_ATTACHMENT_REQUIRED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTLinkingException(e.getUnitId(), e.getObjectGroupId()), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingException | WorkerspaceQueueException | InvalidParseOperationException e) { LOGGER.debug("ProcessingException ", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } catch (final CycleFoundException e) { LOGGER.debug("ProcessingException: cycle found", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, e.getCycle(), SUBTASK_LOOP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (JAXBException e) { LOGGER.error("unable to create ExtractSeda handler, unmarshaller failed", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } finally { unitIdToGuid.clear(); guidToUnitId.clear(); dataObjectIdWithoutObjectGroupId.clear(); objectGroupIdToDataObjectId.clear(); guidToLifeCycleParameters.clear(); objectGuidToDataObject.clear(); dataObjectIdToDetailDataObject.clear(); existingGOTs.clear(); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, globalCompositeItemStatus); } ExtractSedaActionHandler(); @VisibleForTesting  ExtractSedaActionHandler(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); static String getId(); HandlerIO getHandlerIO(); @Override ItemStatus execute(WorkerParameters params, HandlerIO ioParam); ObjectNode extractSEDA(LogbookLifeCyclesClient logbookLifeCycleClient, WorkerParameters params,
        ItemStatus globalCompositeItemStatus, UnitType workflowUnitType); @Override void checkMandatoryIOParameter(HandlerIO handler); }
ExtractSedaActionHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters params, HandlerIO ioParam) { checkMandatoryParameters(params); handlerIO = ioParam; final ItemStatus globalCompositeItemStatus = new ItemStatus(HANDLER_ID); UnitType workflowUnitType = getUnitType(); try (LogbookLifeCyclesClient lifeCycleClient = handlerIO.getLifecyclesClient()) { if (asyncIO) { handlerIO.enableAsync(true); } checkMandatoryIOParameter(ioParam); globalSedaParametersFile = handlerIO.getNewLocalFile(handlerIO.getOutput(GLOBAL_SEDA_PARAMETERS_FILE_IO_RANK).getPath()); unmarshaller = jaxbContext.createUnmarshaller(); listener = new ArchiveUnitListener(handlerIO, archiveUnitTree, unitIdToGuid, guidToUnitId, unitIdToGroupId, objectGroupIdToUnitId, dataObjectIdToObjectGroupId, dataObjectIdWithoutObjectGroupId, guidToLifeCycleParameters, existingUnitGuids, params.getLogbookTypeProcess(), params.getContainerName(), metaDataClientFactory, objectGroupIdToGuid, dataObjectIdToGuid, unitIdToSetOfRuleId, workflowUnitType, originatingAgencies, existingGOTs, existingUnitIdWithExistingObjectGroup, isThereManifestRelatedReferenceRemained, existingGOTGUIDToNewGotGUIDInAttachment, adminManagementClientFactory); unmarshaller.setListener(listener); ObjectNode evDetData = extractSEDA(lifeCycleClient, params, globalCompositeItemStatus, workflowUnitType); if (!existingUnitGuids.isEmpty()) { evDetData.set(ATTACHMENT_IDS, JsonHandler.toJsonNode(existingUnitGuids)); } globalCompositeItemStatus.setEvDetailData(JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.setMasterData(LogbookParameterName.eventDetailData.name(), JsonHandler.unprettyPrint(evDetData)); globalCompositeItemStatus.increment(StatusCode.OK); if (asyncIO) { handlerIO.enableAsync(false); } ObjectNode agIdExt = JsonHandler.createObjectNode(); if (originatingAgency != null) { LOGGER.debug("supplier service is: " + originatingAgency); agIdExt.put(ORIGIN_ANGENCY_NAME, originatingAgency); } if (transferringAgency != null) { LOGGER.debug("Find a transfAgency: " + transferringAgency); agIdExt.put(TRANSFER_AGENCY, transferringAgency); } if (archivalAgency != null) { LOGGER.debug("Find a archivalAgency: " + archivalAgency); agIdExt.put(ARCHIVAL_AGENCY, archivalAgency); } if (submissionAgencyIdentifier != null) { LOGGER.debug("Find a submissionAgencyIdentifier: " + submissionAgencyIdentifier); agIdExt.put(ORIGIN_ANGENCY_SUBMISSION, submissionAgencyIdentifier); } if (agIdExt.size() > 0) { globalCompositeItemStatus.setMasterData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.agIdExt.getDbname(), agIdExt.toString()); } ObjectNode rightsStatementIdentifier = JsonHandler.createObjectNode(); if (ingestContract != null) { LOGGER.debug("contract name is: " + ingestContract.getIdentifier()); rightsStatementIdentifier.put(ARCHIVAl_AGREEMENT, ingestContract.getIdentifier()); } if (archivalProfile != null) { LOGGER.debug("archivalProfile is: " + archivalProfile); rightsStatementIdentifier.put(ARCHIVAl_PROFIL, archivalProfile); } extractOntology(); if (rightsStatementIdentifier.size() > 0) { globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); globalCompositeItemStatus .setMasterData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); ObjectNode data; data = (ObjectNode) JsonHandler.getFromString(globalCompositeItemStatus.getEvDetailData()); data.set(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier); globalCompositeItemStatus.setEvDetailData(data.toString()); globalCompositeItemStatus.setData(LogbookMongoDbName.rightsStatementIdentifier.getDbname(), rightsStatementIdentifier.toString()); } } catch (final ProcessingDuplicatedVersionException e) { LOGGER.debug("ProcessingException: duplicated version", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotFoundException e) { LOGGER.debug("ProcessingException : " + e.getType() + " not found", e); String message; if (e.getType() == ExceptionType.UNIT) { message = getMessageItemStatusAUNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } else { message = getMessageItemStatusOGNotFound(e.getManifestId(), e.getGuid(), e.isValidGuid()); } updateDetailItemStatus(globalCompositeItemStatus, message, e.getTaskKey()); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyUnitsFoundException e) { LOGGER.debug("ProcessingException : multiple units found", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUNotFound(e.getUnitId(), e.getUnitGuid(), e.isValidGuid()), SUBTASK_TOO_MANY_FOUND_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingTooManyVersionsByUsageException e) { LOGGER.debug("ProcessingException :", e); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(JsonHandler.createObjectNode().put("MsgError", e.getMessage())), SUBTASK_TOO_MANY_VERSION_BY_USAGE); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingMalformedDataException e) { LOGGER.debug("ProcessingException : Missing or malformed data in the manifest", e); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), SUBTASK_MALFORMED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectReferenceException e) { LOGGER.error("ProcessingObjectReferenceException: archive unit references more than one got"); ObjectNode error = JsonHandler.createObjectNode(); error.put("error", e.getMessage()); updateDetailItemStatus(globalCompositeItemStatus, JsonHandler.unprettyPrint(error), AU_REFRENCES_MULTIPLE_GOT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingManifestReferenceException e) { LOGGER.debug("ProcessingException : reference incorrect in Manifest", e); updateItemStatusForManifestReferenceException(globalCompositeItemStatus, e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final MissingFieldException e) { LOGGER.debug("MissingFieldException", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupMasterMandatoryException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTMasterMandatory(e.getObjectGroupId()), MASTER_MANDATORY_REQUIRED); } catch (ProcessingObjectGroupEveryDataObjectVersionException e) { globalCompositeItemStatus.increment(StatusCode.KO); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTEveryDataObjectVersion(e.getUnitId(), e.getObjectGroupId()), ATTACHMENT_OBJECTGROUP); } catch (final ArchiveUnitContainDataObjectException e) { LOGGER.debug("ProcessingException: archive unit contain an data object declared object group.", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAUDeclaringObject(e.getUnitId(), e.getBdoId(), e.getGotId()), EXISTING_OG_NOT_DECLARED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ArchiveUnitContainSpecialCharactersException e) { LOGGER.debug("ProcessingException: archive unit contains special characters.", e); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingUnitLinkingException e) { LOGGER.debug("ProcessingException: Linking FILING_UNIT or HOLDING_UNIT to INGEST Unauthorized", e); updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusAULinkingException(e), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentUnauthorizedException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingNotValidLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingAttachmentRequiredException e) { updateDetailItemStatus(globalCompositeItemStatus, e.getMessage(), SUBTASK_ATTACHMENT_REQUIRED); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingObjectGroupLinkingException e) { updateDetailItemStatus(globalCompositeItemStatus, getMessageItemStatusGOTLinkingException(e.getUnitId(), e.getObjectGroupId()), SUBTASK_UNAUTHORIZED_ATTACHMENT); globalCompositeItemStatus.increment(StatusCode.KO); } catch (final ProcessingException | WorkerspaceQueueException | InvalidParseOperationException e) { LOGGER.debug("ProcessingException ", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } catch (final CycleFoundException e) { LOGGER.debug("ProcessingException: cycle found", e); globalCompositeItemStatus.setEvDetailData(e.getEventDetailData()); updateDetailItemStatus(globalCompositeItemStatus, e.getCycle(), SUBTASK_LOOP); globalCompositeItemStatus.increment(StatusCode.KO); } catch (JAXBException e) { LOGGER.error("unable to create ExtractSeda handler, unmarshaller failed", e); globalCompositeItemStatus.increment(StatusCode.FATAL); } finally { unitIdToGuid.clear(); guidToUnitId.clear(); dataObjectIdWithoutObjectGroupId.clear(); objectGroupIdToDataObjectId.clear(); guidToLifeCycleParameters.clear(); objectGuidToDataObject.clear(); dataObjectIdToDetailDataObject.clear(); existingGOTs.clear(); } return new ItemStatus(HANDLER_ID).setItemsStatus(HANDLER_ID, globalCompositeItemStatus); } ExtractSedaActionHandler(); @VisibleForTesting  ExtractSedaActionHandler(MetaDataClientFactory metaDataClientFactory,
        AdminManagementClientFactory adminManagementClientFactory); static String getId(); HandlerIO getHandlerIO(); @Override ItemStatus execute(WorkerParameters params, HandlerIO ioParam); ObjectNode extractSEDA(LogbookLifeCyclesClient logbookLifeCycleClient, WorkerParameters params,
        ItemStatus globalCompositeItemStatus, UnitType workflowUnitType); @Override void checkMandatoryIOParameter(HandlerIO handler); static final int OG_ID_TO_UNID_ID_IO_RANK; static final int OG_ID_TO_GUID_IO_MEMORY_RANK; static final String SUBTASK_ERROR_PARSE_ATTACHMENT; static final String SUBTASK_EMPTY_KEY_ATTACHMENT; static final String SUBTASK_NULL_LINK_PARENT_ID_ATTACHMENT; static final String SUBTASK_TOO_MANY_FOUND_ATTACHMENT; static final String SUBTASK_TOO_MANY_VERSION_BY_USAGE; static final String SUBTASK_NOT_FOUND_ATTACHMENT; static final String SUBTASK_ATTACHMENT_REQUIRED; static final String SUBTASK_UNAUTHORIZED_ATTACHMENT; static final String SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_CONTRACT; static final String SUBTASK_UNAUTHORIZED_ATTACHMENT_BY_BAD_SP; static final String SUBTASK_INVALID_GUID_ATTACHMENT; static final String SUBTASK_MODIFY_PARENT_EXISTING_UNIT_UNAUTHORIZED; }