@Test public void testRevokeLockedDraft() { String intygsTyp = "fk7263"; String intygsId = "intyg1"; setupUser(intygsTyp, false, UserOriginType.NORMAL.name(), Arrays.asList(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG), Arrays.asList(AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST)); RevokeSignedIntygParameter param = new RevokeSignedIntygParameter(); doReturn(buildUtkast("intygtyp", "intygsid")).when(utkastService).getDraft(anyString(), anyString(), anyBoolean()); Response response = moduleApiController.revokeLockedDraft(intygsTyp, intygsId, param); verify(utkastService).revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); assertEquals(OK.getStatusCode(), response.getStatus()); }
@POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) { Utkast utkast = utkastService.getDraft(intygsId, intygsTyp, false); lockedDraftAccessServiceHelper.validateAllowToInvalidateLockedUtkast(utkast); if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp) .features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) { LOG.warn("Request to revoke '{}' is not valid", intygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } utkastService.revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); return Response.ok().build(); }
UtkastModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) { Utkast utkast = utkastService.getDraft(intygsId, intygsTyp, false); lockedDraftAccessServiceHelper.validateAllowToInvalidateLockedUtkast(utkast); if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp) .features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) { LOG.warn("Request to revoke '{}' is not valid", intygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } utkastService.revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); return Response.ok().build(); } }
UtkastModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) { Utkast utkast = utkastService.getDraft(intygsId, intygsTyp, false); lockedDraftAccessServiceHelper.validateAllowToInvalidateLockedUtkast(utkast); if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp) .features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) { LOG.warn("Request to revoke '{}' is not valid", intygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } utkastService.revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); return Response.ok().build(); }  }
UtkastModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) { Utkast utkast = utkastService.getDraft(intygsId, intygsTyp, false); lockedDraftAccessServiceHelper.validateAllowToInvalidateLockedUtkast(utkast); if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp) .features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) { LOG.warn("Request to revoke '{}' is not valid", intygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } utkastService.revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); return Response.ok().build(); }  @GET @Path("/{intygsTyp}/{intygsId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @Context HttpServletRequest request); @PUT @Path("/{intygsTyp}/{intygsId}/{version}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response saveDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @PathParam("version") long version,
        @DefaultValue("false") @QueryParam("autoSave") boolean autoSave, byte[] payload, @Context HttpServletRequest request); @POST @Path("/{intygsTyp}/{intygsId}/validate") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response validateDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        byte[] payload); @POST @Path("/{intygsTyp}/{intygsId}/copyfromcandidate") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response copyFromCandidate(
        @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String intygsId,
        CopyFromCandidateRequest request); @POST @Path("/{intygsTyp}/{intygsId}/copy") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response copyUtkast(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId); @DELETE @Path("/{intygsTyp}/{intygsId}/{version}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response discardDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @PathParam("version") long version,
        @Context HttpServletRequest request); @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        RevokeSignedIntygParameter param); }
UtkastModuleApiController extends AbstractApiController { @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod public Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) { Utkast utkast = utkastService.getDraft(intygsId, intygsTyp, false); lockedDraftAccessServiceHelper.validateAllowToInvalidateLockedUtkast(utkast); if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp) .features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) { LOG.warn("Request to revoke '{}' is not valid", intygsId); throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload"); } utkastService.revokeLockedDraft(intygsId, intygsTyp, param.getMessage(), param.getReason()); return Response.ok().build(); }  @GET @Path("/{intygsTyp}/{intygsId}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response getDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @Context HttpServletRequest request); @PUT @Path("/{intygsTyp}/{intygsId}/{version}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response saveDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @PathParam("version") long version,
        @DefaultValue("false") @QueryParam("autoSave") boolean autoSave, byte[] payload, @Context HttpServletRequest request); @POST @Path("/{intygsTyp}/{intygsId}/validate") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response validateDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        byte[] payload); @POST @Path("/{intygsTyp}/{intygsId}/copyfromcandidate") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response copyFromCandidate(
        @PathParam("intygsTyp") String intygsTyp,
        @PathParam("intygsId") String intygsId,
        CopyFromCandidateRequest request); @POST @Path("/{intygsTyp}/{intygsId}/copy") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response copyUtkast(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId); @DELETE @Path("/{intygsTyp}/{intygsId}/{version}") @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response discardDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        @PathParam("version") long version,
        @Context HttpServletRequest request); @POST @Path("/{intygsTyp}/{intygsId}/aterkalla") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET) @PrometheusTimeMethod Response revokeLockedDraft(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId,
        RevokeSignedIntygParameter param); static final String LAST_SAVED_DRAFT; }