@Test public void testGetShareUrl() throws IOException, JSONException { Map<String, String> headers = new HashMap<>(); headers.put(OVERRIDE, Operation.GET_SHARE_URL.name()); checkPostNotFound(headers); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(501, response.getStatus()); } headers.put(URL_TYPE, "foo"); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(501, response.getStatus()); } headers.put(URL_TYPE, SHARE_URL_READ_ONLY); Map<String, String> toReplace = new HashMap<>(); toReplace.put(REPOSITORY_VAR, blobDoc.getRepositoryName()); toReplace.put(DOC_ID_VAR, blobDoc.getId()); toReplace.put(XPATH_VAR, FILE_CONTENT_PROPERTY); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); checkJSONResponse(response, "json/GetShareUrl-read-only.json", toReplace); } headers.put(URL_TYPE, SHARE_URL_READ_WRITE); try (CloseableClientResponse response = post(johnToken, headers, blobDocFileId)) { assertEquals(200, response.getStatus()); checkJSONResponse(response, "json/GetShareUrl-read-write.json", toReplace); } }
public Object getShareUrl() { String urlType = getHeader(OPERATION_GET_SHARE_URL, URL_TYPE, true); logRequest(OPERATION_GET_SHARE_URL, URL_TYPE, urlType); if (!SHARE_URL_READ_ONLY.equals(urlType) && !SHARE_URL_READ_WRITE.equals(urlType)) { logCondition( () -> URL_TYPE + " header should be either " + SHARE_URL_READ_ONLY + " or " + SHARE_URL_READ_WRITE); logResponse(OPERATION_GET_SHARE_URL, SC_NOT_IMPLEMENTED); throw new NotImplementedException(); } String shareURL = Helpers.getWOPIURL(baseURL, urlType.equals(SHARE_URL_READ_ONLY) ? ACTION_VIEW : ACTION_EDIT, doc, xpath); Map<String, Serializable> map = new HashMap<>(); map.put(SHARE_URL, shareURL); logResponse(OPERATION_GET_SHARE_URL, OK.getStatusCode(), map); return Response.ok(map).type(MediaType.APPLICATION_JSON).build(); }
FilesEndpoint extends DefaultObject { public Object getShareUrl() { String urlType = getHeader(OPERATION_GET_SHARE_URL, URL_TYPE, true); logRequest(OPERATION_GET_SHARE_URL, URL_TYPE, urlType); if (!SHARE_URL_READ_ONLY.equals(urlType) && !SHARE_URL_READ_WRITE.equals(urlType)) { logCondition( () -> URL_TYPE + " header should be either " + SHARE_URL_READ_ONLY + " or " + SHARE_URL_READ_WRITE); logResponse(OPERATION_GET_SHARE_URL, SC_NOT_IMPLEMENTED); throw new NotImplementedException(); } String shareURL = Helpers.getWOPIURL(baseURL, urlType.equals(SHARE_URL_READ_ONLY) ? ACTION_VIEW : ACTION_EDIT, doc, xpath); Map<String, Serializable> map = new HashMap<>(); map.put(SHARE_URL, shareURL); logResponse(OPERATION_GET_SHARE_URL, OK.getStatusCode(), map); return Response.ok(map).type(MediaType.APPLICATION_JSON).build(); } }
FilesEndpoint extends DefaultObject { public Object getShareUrl() { String urlType = getHeader(OPERATION_GET_SHARE_URL, URL_TYPE, true); logRequest(OPERATION_GET_SHARE_URL, URL_TYPE, urlType); if (!SHARE_URL_READ_ONLY.equals(urlType) && !SHARE_URL_READ_WRITE.equals(urlType)) { logCondition( () -> URL_TYPE + " header should be either " + SHARE_URL_READ_ONLY + " or " + SHARE_URL_READ_WRITE); logResponse(OPERATION_GET_SHARE_URL, SC_NOT_IMPLEMENTED); throw new NotImplementedException(); } String shareURL = Helpers.getWOPIURL(baseURL, urlType.equals(SHARE_URL_READ_ONLY) ? ACTION_VIEW : ACTION_EDIT, doc, xpath); Map<String, Serializable> map = new HashMap<>(); map.put(SHARE_URL, shareURL); logResponse(OPERATION_GET_SHARE_URL, OK.getStatusCode(), map); return Response.ok(map).type(MediaType.APPLICATION_JSON).build(); }  }
FilesEndpoint extends DefaultObject { public Object getShareUrl() { String urlType = getHeader(OPERATION_GET_SHARE_URL, URL_TYPE, true); logRequest(OPERATION_GET_SHARE_URL, URL_TYPE, urlType); if (!SHARE_URL_READ_ONLY.equals(urlType) && !SHARE_URL_READ_WRITE.equals(urlType)) { logCondition( () -> URL_TYPE + " header should be either " + SHARE_URL_READ_ONLY + " or " + SHARE_URL_READ_WRITE); logResponse(OPERATION_GET_SHARE_URL, SC_NOT_IMPLEMENTED); throw new NotImplementedException(); } String shareURL = Helpers.getWOPIURL(baseURL, urlType.equals(SHARE_URL_READ_ONLY) ? ACTION_VIEW : ACTION_EDIT, doc, xpath); Map<String, Serializable> map = new HashMap<>(); map.put(SHARE_URL, shareURL); logResponse(OPERATION_GET_SHARE_URL, OK.getStatusCode(), map); return Response.ok(map).type(MediaType.APPLICATION_JSON).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 { public Object getShareUrl() { String urlType = getHeader(OPERATION_GET_SHARE_URL, URL_TYPE, true); logRequest(OPERATION_GET_SHARE_URL, URL_TYPE, urlType); if (!SHARE_URL_READ_ONLY.equals(urlType) && !SHARE_URL_READ_WRITE.equals(urlType)) { logCondition( () -> URL_TYPE + " header should be either " + SHARE_URL_READ_ONLY + " or " + SHARE_URL_READ_WRITE); logResponse(OPERATION_GET_SHARE_URL, SC_NOT_IMPLEMENTED); throw new NotImplementedException(); } String shareURL = Helpers.getWOPIURL(baseURL, urlType.equals(SHARE_URL_READ_ONLY) ? ACTION_VIEW : ACTION_EDIT, doc, xpath); Map<String, Serializable> map = new HashMap<>(); map.put(SHARE_URL, shareURL); logResponse(OPERATION_GET_SHARE_URL, OK.getStatusCode(), map); return Response.ok(map).type(MediaType.APPLICATION_JSON).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();  }