Exemplo n.º 1
0
 /** false is bu default so we test positive case only */
 @Test
 public void testDelete() throws Exception {
   RestClient restClient = mock(RestClient.class);
   URI uri = new URI("DUMMY");
   when(restClient.buildURI(anyString(), any(Map.class))).thenReturn(uri);
   when(restClient.delete(eq(uri))).thenReturn(null);
   Issue issue = new Issue(restClient, Utils.getTestIssue());
   Assert.assertTrue(issue.delete(true));
 }
 /**
  * Deletes a role from the package.
  *
  * @param packageId
  * @param role
  * @throws EslException
  */
 public void deleteRole(PackageId packageId, Role role) throws EslException {
   String path =
       template
           .urlFor(UrlTemplate.ROLE_ID_PATH)
           .replace("{packageId}", packageId.getId())
           .replace("{roleId}", role.getId())
           .build();
   try {
     client.delete(path);
   } catch (RequestException e) {
     throw new EslServerException("Could not delete role", e);
   } catch (Exception e) {
     throw new EslException("Could not delete role", e);
   }
 }
 /**
  * Deletes the document from the package.
  *
  * @param packageId
  * @param documentId
  * @throws EslException
  */
 public void deleteDocument(PackageId packageId, String documentId) throws EslException {
   String path =
       template
           .urlFor(UrlTemplate.DOCUMENT_ID_PATH)
           .replace("{packageId}", packageId.getId())
           .replace("{documentId}", documentId)
           .build();
   try {
     client.delete(path);
   } catch (RequestException e) {
     throw new EslServerException("Could not delete document from package.", e);
   } catch (Exception e) {
     throw new EslException("Could not delete document from package.", e);
   }
 }
  /**
   * Deletes the specified package.
   *
   * @param packageId The id of the package to be deleted
   */
  public void deletePackage(PackageId packageId) {
    String path =
        template
            .urlFor(UrlTemplate.PACKAGE_ID_PATH)
            .replace("{packageId}", packageId.getId())
            .build();

    try {
      client.delete(path);
    } catch (RequestException e) {
      throw new EslServerException("Unable to delete package.", e);
    } catch (Exception e) {
      e.printStackTrace();
      throw new EslException("Unable to delete package. Exception: " + e.getMessage());
    }
  }
 /**
  * Removes a signer from a package
  *
  * @param packageId The id of the package containing the signer to be deleted
  * @param signerId The role id of the signer to be deleted
  */
 public void removeSigner(PackageId packageId, String signerId) {
   String path =
       template
           .urlFor(UrlTemplate.SIGNER_PATH)
           .replace("{packageId}", packageId.getId())
           .replace("{roleId}", signerId)
           .build();
   try {
     client.delete(path);
     return;
   } catch (RequestException e) {
     throw new EslServerException("Could not delete signer.", e);
   } catch (Exception e) {
     throw new EslException("Could not delete signer." + " Exception: " + e.getMessage());
   }
 }
Exemplo n.º 6
0
  /**
   * Generic resource delete
   *
   * @param uri
   * @return
   * @throws JSONException
   */
  public JSONObject delete(String uri, Map<String, Object> params) throws JSONException, Exception {
    if (params == null) {
      params = new HashMap<String, Object>();
    }
    String accessToken;
    try {
      accessToken = this.getAccessToken();
      params.put("access_token", accessToken);
    } catch (Exception e) {
      JSONObject result = new JSONObject(e.getMessage());
      return result;
    }

    if (!params.isEmpty()) {
      uri += (uri.contains("?") ? "&" : "?") + this.buildQuery(params);
    }

    JSONObject result = RestClient.delete(uri);
    return result;
  }