@Test public void testUnlockAndRelockOnMultipleBlobs() { DocumentRef multipleBlobsDocRef = multipleBlobsDoc.getRef(); Map<String, String> headers = new HashMap<>(); headers.put(OVERRIDE, Operation.LOCK.name()); headers.put(LOCK, "fooContent"); try (CloseableClientResponse response = post(johnToken, headers, multipleBlobsDocFileId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(multipleBlobsDocRef).isLocked()); String lock = LockHelper.getLock(multipleBlobsDocFileId); assertEquals("fooContent", lock); } headers.put(LOCK, "barContent"); headers.put(OLD_LOCK, "fooContent"); try (CloseableClientResponse response = post(johnToken, headers, multipleBlobsDocFileId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(multipleBlobsDocRef).isLocked()); String lock = LockHelper.getLock(multipleBlobsDocFileId); assertEquals("barContent", lock); } headers.put(LOCK, "fooAttachment"); headers.remove(OLD_LOCK); try (CloseableClientResponse response = post(johnToken, headers, multipleBlobsDocAttachementId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(multipleBlobsDocRef).isLocked()); String lock = LockHelper.getLock(multipleBlobsDocAttachementId); assertEquals("fooAttachment", lock); } headers.put(LOCK, "barAttachment"); headers.put(OLD_LOCK, "fooAttachment"); try (CloseableClientResponse response = post(johnToken, headers, multipleBlobsDocAttachementId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(multipleBlobsDocRef).isLocked()); String lock = LockHelper.getLock(multipleBlobsDocAttachementId); assertEquals("barAttachment", lock); } }
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();  }