DocumentBaselinesResource { @GET @ApiOperation(value = "Get document baseline by id", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}") @Produces(MediaType.APPLICATION_JSON) public DocumentBaselineDTO getBaseline( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { DocumentBaseline documentBaseline = documentBaselineService.getBaselineLight(workspaceId, baselineId); DocumentCollection documentCollection = documentBaselineService.getACLFilteredDocumentCollection(workspaceId, baselineId); List<BaselinedDocumentDTO> baselinedDocumentDTOs = Tools.mapBaselinedDocumentsToBaselinedDocumentDTOs(documentCollection); DocumentBaselineDTO baselineDTO = mapper.map(documentBaseline, DocumentBaselineDTO.class); baselineDTO.setBaselinedDocuments(baselinedDocumentDTOs); return baselineDTO; } DocumentBaselinesResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get document baselines", response = DocumentBaselineDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of checked out DocumentBaselineDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response getDocumentBaselines(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @POST @ApiOperation(value = "Create a new document baseline", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of created DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) Response createDocumentBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Document baseline to create") DocumentBaselineDTO documentBaselineDTO); @DELETE @ApiOperation(value = "Delete a document baseline", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}") @Consumes(MediaType.APPLICATION_JSON) Response deleteBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Get document baseline by id", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}") @Produces(MediaType.APPLICATION_JSON) DocumentBaselineDTO getBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Get document baseline in a light format", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}-light") @Produces(MediaType.APPLICATION_JSON) DocumentBaselineDTO getBaselineLight(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Export document baseline's files", response = File.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful files export, download a zipped file containing requested files."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}/export-files") Response exportDocumentFiles(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId);  }
@Test public void getBaselineTest() throws ApplicationException { DocumentBaseline baseline = new DocumentBaseline(); baseline.setId(42); DocumentBaselineDTO documentBaselineDTO = new DocumentBaselineDTO(); documentBaselineDTO.setName("foo"); documentBaselineDTO.setType(DocumentBaselineType.LATEST); BaselinedDocumentDTO doc = new BaselinedDocumentDTO(); doc.setDocumentMasterId("blah"); doc.setVersion("A"); doc.setIteration(1); List<BaselinedDocumentDTO> docs = Collections.singletonList(doc); documentBaselineDTO.setBaselinedDocuments(docs); DocumentCollection docCollection = new DocumentCollection(); Mockito.when(documentBaselineService.getBaselineLight(workspaceId, baseline.getId())) .thenReturn(baseline); Mockito.when(documentBaselineService.getACLFilteredDocumentCollection(workspaceId, baseline.getId())) .thenReturn(docCollection); DocumentBaselineDTO result = documentBaselinesResource.getBaseline(workspaceId, baseline.getId()); Assert.assertNotNull(result); Assert.assertEquals(result.getId(), baseline.getId()); }