Search in sources :

Example 46 with Response

use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method deleteInvitation.

/**
 * Adapted from similar method in org.alfresco.repo.web.scripts.invitation.InvitationWebScriptTest
 */
JSONObject deleteInvitation(String invitationID, String siteShortName, int expectedStatus) throws Exception {
    assertNotNull(invitationID);
    assertNotNull(siteShortName);
    assertFalse(invitationID.isEmpty());
    assertFalse(siteShortName.isEmpty());
    Response response = sendRequest(new DeleteRequest(URL_SITES + "/" + siteShortName + "/invitations/" + invitationID), expectedStatus);
    JSONObject jsonResponse = new JSONObject(response.getContentAsString());
    assertNotNull(jsonResponse);
    return jsonResponse;
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) DeleteRequest(org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)

Example 47 with Response

use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method getInvitesByInviteId.

private JSONObject getInvitesByInviteId(String inviteId, int expectedStatus) throws Exception {
    // construct get invites URL
    String getInvitesUrl = URL_INVITES + "?inviteId=" + inviteId;
    // invoke get invites web script
    Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
    JSONObject result = new JSONObject(response.getContentAsString());
    return result;
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 48 with Response

use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method getInvitesByInviteeUserName.

private JSONObject getInvitesByInviteeUserName(String inviteeUserName, int expectedStatus) throws Exception {
    // construct get invites URL
    String getInvitesUrl = URL_INVITES + "?inviteeUserName=" + inviteeUserName;
    // invoke get invites web script
    Response response = sendRequest(new GetRequest(getInvitesUrl), expectedStatus);
    JSONObject result = new JSONObject(response.getContentAsString());
    return result;
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 49 with Response

use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method createModeratedInvitation.

private String createModeratedInvitation(String siteName, String inviteeComments, String inviteeUserName, String inviteeRoleName) throws Exception {
    String URL_SITES = "/api/sites";
    /*
         * Create a new moderated invitation
         */
    JSONObject newInvitation = new JSONObject();
    newInvitation.put("invitationType", "MODERATED");
    newInvitation.put("inviteeRoleName", inviteeRoleName);
    newInvitation.put("inviteeComments", inviteeComments);
    newInvitation.put("inviteeUserName", inviteeUserName);
    Response response = sendRequest(new PostRequest(URL_SITES + "/" + siteName + "/invitations", newInvitation.toString(), "application/json"), 201);
    JSONObject top = new JSONObject(response.getContentAsString());
    JSONObject data = top.getJSONObject("data");
    String inviteId = data.getString("inviteId");
    return inviteId;
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) PostRequest(org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest) JSONObject(org.json.JSONObject)

Example 50 with Response

use of org.springframework.extensions.webscripts.TestWebScriptServer.Response in project alfresco-remote-api by Alfresco.

the class InviteServiceTest method getInviteInfo.

private JSONObject getInviteInfo(String inviteId, String inviteTicket, String inviteeUid) throws Exception {
    String url = "/api/invite/" + inviteId + "/" + inviteTicket + "?inviteeUserName=" + inviteeUid;
    String runAsUser = AuthenticationUtil.getRunAsUser();
    Response response = sendRequest(new GetRequest(url), Status.STATUS_OK);
    if (!runAsUser.equals(AuthenticationUtil.getRunAsUser())) {
        AuthenticationUtil.setRunAsUser(runAsUser);
    }
    JSONObject result = new JSONObject(response.getContentAsString());
    return result;
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Aggregations

Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)281 JSONObject (org.json.JSONObject)228 GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)171 JSONArray (org.json.JSONArray)116 PostRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest)84 JSONTokener (org.json.JSONTokener)39 PutRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)37 NodeRef (org.alfresco.service.cmr.repository.NodeRef)34 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)32 HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)16 TestWebScriptServer (org.springframework.extensions.webscripts.TestWebScriptServer)16 Serializable (java.io.Serializable)14 QName (org.alfresco.service.namespace.QName)14 Date (java.util.Date)13 JSONStringer (org.json.JSONStringer)13 UserTransaction (javax.transaction.UserTransaction)12 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)12 ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)11 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)11