Skip to content

Commit

Permalink
added list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Farooq committed Sep 28, 2017
1 parent 8225e78 commit 0412504
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private void removeIncomingPhoneNumbers(Sid accountSid, IncomingPhoneNumbersDao



protected Response getAccounts(final MediaType responseType) {
protected Response getAccounts(final MultivaluedMap<String, String> data, final MediaType responseType) {
checkAuthenticatedAccount();
//First check if the account has the required permissions in general, this way we can fail fast and avoid expensive DAO operations
checkPermission("RestComm:Read:Accounts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public Response optionsAccount(@PathParam("accountSid") final String accountSid)
}

@GET
public Response getAccounts() {
return getAccounts(APPLICATION_JSON_TYPE);
public Response getAccounts(final MultivaluedMap<String, String> data) {
return getAccounts(data, APPLICATION_JSON_TYPE);
}

/* disabled as #1270
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public Response getAccountAsXml(@PathParam("accountSid") final String accountSid
}

@GET
public Response getAccounts() {
return getAccounts(APPLICATION_XML_TYPE);
public Response getAccounts(final MultivaluedMap<String, String> data) {
return getAccounts(data, APPLICATION_XML_TYPE);
}

@Consumes(APPLICATION_FORM_URLENCODED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ public void testCreateAccountInSpecificOrganization() {

@Test
public void testGetAccountsOfASpecificOrganization() {
ClientResponse response = RestcommAccountsTool.getInstance().getAccountsResponse(deploymentUrl.toString(), adminUsername, adminAuthToken);
//without any parameters
ClientResponse response = RestcommAccountsTool.getInstance().getAccountsWithFilterResponse(deploymentUrl.toString(), adminUsername, adminAuthToken, null, null, null);
logger.info("getAccountsWithFilterResponse: "+response);
assertEquals(200, response.getStatus());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ public ClientResponse getAccountsResponse (String deploymentUrl, String username
return response;
}

public ClientResponse getAccountsWithFilterResponse (String deploymentUrl, String username, String authtoken, String organizationSid, String domainName, String baseAccount) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(username, authtoken));
WebResource webResource = jerseyClient.resource(getAccountsUrl(deploymentUrl));

MultivaluedMap<String, String> params = new MultivaluedMapImpl();
if(organizationSid != null && !(organizationSid.trim().isEmpty()))
params.add("OrganizationSid", organizationSid);
if(domainName != null && !(domainName.trim().isEmpty()))
params.add("DomainName", domainName);
if(baseAccount != null && !(baseAccount.trim().isEmpty()))
params.add("BaseAccount", baseAccount);

ClientResponse response = webResource.queryParams(params).accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)
.get(ClientResponse.class);
return response;
}

public ClientResponse removeAccountResponse (String deploymentUrl, String operatingUsername, String operatingAuthToken, String removedAccountSid) {
Client jerseyClient = Client.create();
jerseyClient.addFilter(new HTTPBasicAuthFilter(operatingUsername, operatingAuthToken));
Expand Down

0 comments on commit 0412504

Please sign in to comment.