/*
 * Copyright (c) 2015. hp.weber GmbH & Co secucard KG (www.secucard.com)
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.secucard.connect.product.document;

import com.secucard.connect.client.Callback;
import com.secucard.connect.client.ProductService;
import com.secucard.connect.product.document.model.Upload;

public class UploadsService extends ProductService<Upload> {
  /**
   * Upload a Base64 encoded document
   *
   * @param base64EncodeDocument Base64 encoded document
   * @return JSONObject with id
   */
  public Upload uploadDocument(Upload base64EncodeDocument, Callback<Upload> callback) {
    return super.execute(null, null, null, base64EncodeDocument, Upload.class, null, callback);
  }

  @Override
  protected ServiceMetaData<Upload> createMetaData() {
    return new ServiceMetaData<>("document", "uploads", Upload.class);
  }

}

@@ -819,16 +819,166 @@
 .Upload;
+%0Aimport com.secucard.connect.util.CallbackAdapter;%0Aimport com.secucard.connect.util.Converter;%0A%0A/**%0A * Implements the document/uploads operations.%0A */
 %0A%0Apublic
@@ -1032,16 +1032,17 @@
 load%3E %7B%0A
+%0A
   /**%0A  
@@ -1055,233 +1055,499 @@
 oad 
-a Base64 encoded document%0A   *%0A   * @param base64EncodeDocument Base64 encoded document%0A   * @return JSONObject with id%0A   */%0A  public Upload uploadDocument(Upload base64EncodeDocument, Callback%3CUpload%3E callback) %7B%0A    return
+the given document and returns the new id for the upload.%0A   * Note: the uploaded content should be base64 encoded.%0A   */%0A  public String upload(Upload content, Callback%3CString%3E callback) %7B%0A    Converter%3CUpload, String%3E conv = new Converter%3CUpload, String%3E() %7B%0A      @Override%0A      public String convert(Upload value) %7B%0A        return value.getId();%0A      %7D%0A    %7D;%0A    CallbackAdapter%3CUpload, String%3E cb = callback == null ? null : new CallbackAdapter%3C%3E(callback, conv);%0A    Upload result =
  sup
@@ -1579,25 +1579,12 @@
 ll, 
-base64EncodeDocum
+cont
 ent,
@@ -1605,23 +1605,50 @@
  null, c
-allback
+b);%0A    return conv.convert(result
 );%0A  %7D%0A%0A

document product refactoring