use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class InviteServiceTest method getInvitesByInviterUserName.
private JSONObject getInvitesByInviterUserName(String inviterUserName, int expectedStatus) throws Exception {
// construct get invites URL
String getInvitesUrl = URL_INVITES + "?inviterUserName=" + inviterUserName;
// invoke get invites web script
Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
JSONObject result = new JSONObject(response.getContentAsString());
return result;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class LinksRestApiTest method createComment.
private JSONObject createComment(String nodeRef, String title, String content, int expectedStatus) throws Exception {
JSONObject comment = new JSONObject();
comment.put("title", title);
comment.put("content", content);
comment.put("site", SITE_SHORT_NAME_LINKS);
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
if (expectedStatus != 200) {
return null;
}
// logger.debug("Comment created: " + response.getContentAsString());
JSONObject result = new JSONObject(response.getContentAsString());
return result.getJSONObject("item");
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class LinksRestApiTest method createLink.
/**
* Creates a single link based on the supplied details
*/
private JSONObject createLink(String title, String description, String url, boolean internal, int expectedStatus) throws Exception {
JSONObject json = new JSONObject();
json.put("site", SITE_SHORT_NAME_LINKS);
json.put("title", title);
json.put("description", description);
json.put("url", url);
json.put("tags", "");
if (internal) {
json.put("internal", "true");
}
// TODO Is this really needed?
json.put("page", "links-view");
Response response = sendRequest(new PostRequest(URL_LINKS_CREATE, json.toString(), "application/json"), expectedStatus);
if (expectedStatus == Status.STATUS_OK) {
JSONObject result = new JSONObject(response.getContentAsString());
if (result.has("link")) {
return result.getJSONObject("link");
}
return result;
} else {
return null;
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class LinksRestApiTest method getLinks.
// Test helper methods
private JSONObject getLinks(String filter, String username) throws Exception {
String origUser = this.authenticationComponent.getCurrentUserName();
if (username != null) {
this.authenticationComponent.setCurrentUser(username);
filter = "user";
}
String url = URL_LINKS_LIST;
if (filter == null) {
filter = "all";
}
url += "?filter=" + filter;
url += "&startIndex=0&page=1&pageSize=4";
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
if (username != null) {
this.authenticationComponent.setCurrentUser(origUser);
}
return result;
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.
the class LinksRestApiTest method checkLinkPermissions.
private void checkLinkPermissions(String siteName) throws Exception {
String url = "/api/links/site/" + siteName + "/links";
url += "?filter=" + "all";
url += "&startIndex=0&page=1&pageSize=4";
Response response = sendRequest(new GetRequest(url), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertTrue("The user sould have permission to create a new link.", result.getJSONObject("metadata").getJSONObject("linkPermissions").getBoolean("create"));
}
Aggregations