@Test public void testUnlock() { Map<String, String> headers = new HashMap<>(); headers.put(OVERRIDE, Operation.UNLOCK.name()); checkPostNotFound(headers); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(400, response.getStatus()); } headers.put(LOCK, ""); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(400, response.getStatus()); } headers.put(LOCK, "foo"); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(409, response.getStatus()); String lock = response.getHeaders().getFirst(LOCK); assertEquals("", 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()); } headers.put(OVERRIDE, Operation.LOCK.name()); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(blobDoc.getRef()).isLocked()); } headers.put(OVERRIDE, Operation.UNLOCK.name()); try (CloseableClientResponse response = post(joeToken, headers, blobDocFileId)) { assertEquals(409, response.getStatus()); transactionalFeature.nextTransaction(); assertTrue(session.getDocument(blobDoc.getRef()).isLocked()); } headers.put(LOCK, "bar"); assertConflictResponseWithLock(headers); headers.put(LOCK, "foo"); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); transactionalFeature.nextTransaction(); assertFalse(session.getDocument(blobDoc.getRef()).isLocked()); String itemVersion = response.getHeaders().getFirst(ITEM_VERSION); assertEquals(expectedFileBlob.getDigest(), itemVersion); } }
protected Object unlock() { String lock = getHeader(OPERATION_UNLOCK, LOCK); logRequest(OPERATION_UNLOCK, LOCK, lock); return unlockOrRefresh(OPERATION_UNLOCK, lock, true); }
FilesEndpoint extends DefaultObject { protected Object unlock() { String lock = getHeader(OPERATION_UNLOCK, LOCK); logRequest(OPERATION_UNLOCK, LOCK, lock); return unlockOrRefresh(OPERATION_UNLOCK, lock, true); } }
FilesEndpoint extends DefaultObject { protected Object unlock() { String lock = getHeader(OPERATION_UNLOCK, LOCK); logRequest(OPERATION_UNLOCK, LOCK, lock); return unlockOrRefresh(OPERATION_UNLOCK, lock, true); }  }
FilesEndpoint extends DefaultObject { protected Object unlock() { String lock = getHeader(OPERATION_UNLOCK, LOCK); logRequest(OPERATION_UNLOCK, LOCK, lock); return unlockOrRefresh(OPERATION_UNLOCK, lock, true); }  @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 unlock() { String lock = getHeader(OPERATION_UNLOCK, LOCK); logRequest(OPERATION_UNLOCK, LOCK, lock); return unlockOrRefresh(OPERATION_UNLOCK, lock, true); }  @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();  }