コード例 #1
0
  /**
   * Creates a package and uploads the documents in one step
   *
   * @param aPackage
   * @param documents
   * @return
   * @throws EslException
   */
  public PackageId createPackageOneStep(
      Package aPackage, Collection<com.silanis.esl.sdk.Document> documents) throws EslException {
    String path = template.urlFor(UrlTemplate.PACKAGE_PATH).build();
    String packageJson = Serialization.toJson(aPackage);

    try {
      String response = client.postMultipartPackage(path, documents, packageJson);
      return Serialization.fromJson(response, PackageId.class);

    } catch (RequestException e) {
      throw new EslServerException("Could not create a new package in one-step", e);
    } catch (Exception e) {
      throw new EslException("Could not create a new package in one-step", e);
    }
  }