@Test public void testGetLock() { Map<String, String> headers = new HashMap<>(); headers.put(OVERRIDE, Operation.GET_LOCK.name()); checkPostNotFound(headers); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); String lock = response.getHeaders().getFirst(LOCK); assertEquals("", lock); } headers.put(OVERRIDE, Operation.LOCK.name()); String expectedLock = "foo"; headers.put(LOCK, expectedLock); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(blobDoc.getRef()).isLocked()); } headers.remove(LOCK); headers.put(OVERRIDE, Operation.GET_LOCK.name()); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); String lock = response.getHeaders().getFirst(LOCK); assertEquals(expectedLock, lock); } session.getDocument(hugeBlobDoc.getRef()).setLock(); transactionalFeature.nextTransaction(); try (CloseableClientResponse response = post(johnToken, headers, hugeBlobDocFileId)) { assertEquals(409, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(hugeBlobDoc.getRef()).isLocked()); } }
protected Object getLock() { logRequest(OPERATION_GET_LOCK); if (!doc.isLocked()) { logCondition("Document isn't locked"); String lockHeader = ""; response.addHeader(LOCK, lockHeader); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, lockHeader); return Response.ok().build(); } String currentLock = getCurrentLock(OPERATION_GET_LOCK); response.addHeader(LOCK, currentLock); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, currentLock); return Response.ok().build(); }
FilesEndpoint extends DefaultObject { protected Object getLock() { logRequest(OPERATION_GET_LOCK); if (!doc.isLocked()) { logCondition("Document isn't locked"); String lockHeader = ""; response.addHeader(LOCK, lockHeader); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, lockHeader); return Response.ok().build(); } String currentLock = getCurrentLock(OPERATION_GET_LOCK); response.addHeader(LOCK, currentLock); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, currentLock); return Response.ok().build(); } }
FilesEndpoint extends DefaultObject { protected Object getLock() { logRequest(OPERATION_GET_LOCK); if (!doc.isLocked()) { logCondition("Document isn't locked"); String lockHeader = ""; response.addHeader(LOCK, lockHeader); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, lockHeader); return Response.ok().build(); } String currentLock = getCurrentLock(OPERATION_GET_LOCK); response.addHeader(LOCK, currentLock); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, currentLock); return Response.ok().build(); }  }
FilesEndpoint extends DefaultObject { protected Object getLock() { logRequest(OPERATION_GET_LOCK); if (!doc.isLocked()) { logCondition("Document isn't locked"); String lockHeader = ""; response.addHeader(LOCK, lockHeader); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, lockHeader); return Response.ok().build(); } String currentLock = getCurrentLock(OPERATION_GET_LOCK); response.addHeader(LOCK, currentLock); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, currentLock); return Response.ok().build(); }  @Override void initialize(Object... args); @GET @Produces(MediaType.APPLICATION_JSON) Response checkFileInfo(); @GET @Path("contents") Object getFile(@HeaderParam(MAX_EXPECTED_SIZE) String maxExpectedSizeHeader); @POST Object doPost(@HeaderParam(OVERRIDE) Operation operation); Object putRelativeFile(); Object renameFile(); Object getShareUrl(); @POST @Path("contents") Object doPostContents(@HeaderParam(OVERRIDE) Operation operation); Object putFile(); }
FilesEndpoint extends DefaultObject { protected Object getLock() { logRequest(OPERATION_GET_LOCK); if (!doc.isLocked()) { logCondition("Document isn't locked"); String lockHeader = ""; response.addHeader(LOCK, lockHeader); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, lockHeader); return Response.ok().build(); } String currentLock = getCurrentLock(OPERATION_GET_LOCK); response.addHeader(LOCK, currentLock); logResponse(OPERATION_GET_LOCK, OK.getStatusCode(), LOCK, currentLock); return Response.ok().build(); }  @Override void initialize(Object... args); @GET @Produces(MediaType.APPLICATION_JSON) Response checkFileInfo(); @GET @Path("contents") Object getFile(@HeaderParam(MAX_EXPECTED_SIZE) String maxExpectedSizeHeader); @POST Object doPost(@HeaderParam(OVERRIDE) Operation operation); Object putRelativeFile(); Object renameFile(); Object getShareUrl(); @POST @Path("contents") Object doPostContents(@HeaderParam(OVERRIDE) Operation operation); Object putFile();  }