@Test public void execute_GivenNoAccessContractProvidedThenKO() throws Exception { givenDslRequests(mock(ParsedReclassificationDslRequestEntry.class)); VitamThreadUtils.getVitamSession().setContractId(null); ItemStatus itemStatus = reclassificationPreparationLoadRequestHandler.execute(parameters, handlerIO); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.KO); assertThat( JsonHandler.getFromString(itemStatus.getEvDetailData(), ReclassificationEventDetails.class).getError()) .isEqualTo(NO_ACCESS_CONTRACT_PROVIDED); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { JsonNode reclassificationDslJson = loadReclassificationRequestJsonFromWorkspace(handler); ParsedReclassificationDslRequest parsedReclassificationDslRequest = parseReclassificationDslRequest(reclassificationDslJson); checkMaxRequestCount(parsedReclassificationDslRequest); AccessContractModel accessContractModel = getAccessContract(); checkParentAccessContract(parsedReclassificationDslRequest, accessContractModel); ReclassificationOrders reclassificationOrders = selectReclassificationOrders(parsedReclassificationDslRequest, accessContractModel); checkMinUnitsToUpdate(reclassificationOrders); checkMaxDistinctUnits(reclassificationOrders); checkAttachmentAndDetachmentForSameParent(reclassificationOrders); storeReclassificationOrders(handler, reclassificationOrders); } catch (ProcessingStatusException e) { LOGGER.error("Reclassification request loading failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, e.getStatusCode(), e.getEventDetails()); } LOGGER.info("Reclassification request loading succeeded"); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, StatusCode.OK, null); }
ReclassificationPreparationLoadRequestHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { JsonNode reclassificationDslJson = loadReclassificationRequestJsonFromWorkspace(handler); ParsedReclassificationDslRequest parsedReclassificationDslRequest = parseReclassificationDslRequest(reclassificationDslJson); checkMaxRequestCount(parsedReclassificationDslRequest); AccessContractModel accessContractModel = getAccessContract(); checkParentAccessContract(parsedReclassificationDslRequest, accessContractModel); ReclassificationOrders reclassificationOrders = selectReclassificationOrders(parsedReclassificationDslRequest, accessContractModel); checkMinUnitsToUpdate(reclassificationOrders); checkMaxDistinctUnits(reclassificationOrders); checkAttachmentAndDetachmentForSameParent(reclassificationOrders); storeReclassificationOrders(handler, reclassificationOrders); } catch (ProcessingStatusException e) { LOGGER.error("Reclassification request loading failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, e.getStatusCode(), e.getEventDetails()); } LOGGER.info("Reclassification request loading succeeded"); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, StatusCode.OK, null); } }
ReclassificationPreparationLoadRequestHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { JsonNode reclassificationDslJson = loadReclassificationRequestJsonFromWorkspace(handler); ParsedReclassificationDslRequest parsedReclassificationDslRequest = parseReclassificationDslRequest(reclassificationDslJson); checkMaxRequestCount(parsedReclassificationDslRequest); AccessContractModel accessContractModel = getAccessContract(); checkParentAccessContract(parsedReclassificationDslRequest, accessContractModel); ReclassificationOrders reclassificationOrders = selectReclassificationOrders(parsedReclassificationDslRequest, accessContractModel); checkMinUnitsToUpdate(reclassificationOrders); checkMaxDistinctUnits(reclassificationOrders); checkAttachmentAndDetachmentForSameParent(reclassificationOrders); storeReclassificationOrders(handler, reclassificationOrders); } catch (ProcessingStatusException e) { LOGGER.error("Reclassification request loading failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, e.getStatusCode(), e.getEventDetails()); } LOGGER.info("Reclassification request loading succeeded"); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, StatusCode.OK, null); } ReclassificationPreparationLoadRequestHandler(); @VisibleForTesting  ReclassificationPreparationLoadRequestHandler(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, UnitGraphInfoLoader unitGraphInfoLoader,
        ReclassificationRequestDslParser reclassificationRequestDslParser, int maxBulkThreshold, int maxUnitsThreshold,
        int maxGuildListSizeInLogbookOperation); }
ReclassificationPreparationLoadRequestHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { JsonNode reclassificationDslJson = loadReclassificationRequestJsonFromWorkspace(handler); ParsedReclassificationDslRequest parsedReclassificationDslRequest = parseReclassificationDslRequest(reclassificationDslJson); checkMaxRequestCount(parsedReclassificationDslRequest); AccessContractModel accessContractModel = getAccessContract(); checkParentAccessContract(parsedReclassificationDslRequest, accessContractModel); ReclassificationOrders reclassificationOrders = selectReclassificationOrders(parsedReclassificationDslRequest, accessContractModel); checkMinUnitsToUpdate(reclassificationOrders); checkMaxDistinctUnits(reclassificationOrders); checkAttachmentAndDetachmentForSameParent(reclassificationOrders); storeReclassificationOrders(handler, reclassificationOrders); } catch (ProcessingStatusException e) { LOGGER.error("Reclassification request loading failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, e.getStatusCode(), e.getEventDetails()); } LOGGER.info("Reclassification request loading succeeded"); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, StatusCode.OK, null); } ReclassificationPreparationLoadRequestHandler(); @VisibleForTesting  ReclassificationPreparationLoadRequestHandler(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, UnitGraphInfoLoader unitGraphInfoLoader,
        ReclassificationRequestDslParser reclassificationRequestDslParser, int maxBulkThreshold, int maxUnitsThreshold,
        int maxGuildListSizeInLogbookOperation); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId(); }
ReclassificationPreparationLoadRequestHandler extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) throws ProcessingException { try { JsonNode reclassificationDslJson = loadReclassificationRequestJsonFromWorkspace(handler); ParsedReclassificationDslRequest parsedReclassificationDslRequest = parseReclassificationDslRequest(reclassificationDslJson); checkMaxRequestCount(parsedReclassificationDslRequest); AccessContractModel accessContractModel = getAccessContract(); checkParentAccessContract(parsedReclassificationDslRequest, accessContractModel); ReclassificationOrders reclassificationOrders = selectReclassificationOrders(parsedReclassificationDslRequest, accessContractModel); checkMinUnitsToUpdate(reclassificationOrders); checkMaxDistinctUnits(reclassificationOrders); checkAttachmentAndDetachmentForSameParent(reclassificationOrders); storeReclassificationOrders(handler, reclassificationOrders); } catch (ProcessingStatusException e) { LOGGER.error("Reclassification request loading failed with status [" + e.getStatusCode() + "]", e); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, e.getStatusCode(), e.getEventDetails()); } LOGGER.info("Reclassification request loading succeeded"); return buildItemStatus(RECLASSIFICATION_PREPARATION_LOAD_REQUEST, StatusCode.OK, null); } ReclassificationPreparationLoadRequestHandler(); @VisibleForTesting  ReclassificationPreparationLoadRequestHandler(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, UnitGraphInfoLoader unitGraphInfoLoader,
        ReclassificationRequestDslParser reclassificationRequestDslParser, int maxBulkThreshold, int maxUnitsThreshold,
        int maxGuildListSizeInLogbookOperation); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); static String getId();  }