예제 #1
0
  /* (non-Javadoc)
   * @see de.udo.one.extensions.cdmi.datatypes.CDMICRUDInterface#read(java.lang.Object[])
   */
  @Override
  // @Params ( String:containerName, String:dataObjectName, Hashtable:headers, String[]:filter =
  // null )
  public CDMIResponse read(Object... params) throws Exception {
    if (params == null || params.length <= 2) {
      throw new CDMIOperationException(
          String.format("Missing mandatory parameters '%s'", Arrays.toString(params)));
    }

    String containerName = "";
    String dataObjectName = "";
    String filter = null;
    Hashtable<String, String> headers = null;

    if (params.length == 3) {
      containerName = params[0].toString();
      dataObjectName = params[1].toString();
      headers = (Hashtable<String, String>) params[2];
    } else if (params.length == 4) {
      containerName = params[0].toString();
      dataObjectName = params[1].toString();
      headers = (Hashtable<String, String>) params[2];
      filter = (String) params[3];
    }

    if (!containerName.endsWith("/")) containerName += "/";
    validate(CDMIOperation.READ, headers, null);
    String URL = cdmiEPR + containerName + dataObjectName;
    if (filter != null) URL += "?" + filter;

    return RestfulUtils.get(URL, headers);
  }
예제 #2
0
  @Override
  public CDMIResponse update(Object... params) throws Exception {
    if (params == null || params.length <= 3) {
      throw new CDMIOperationException(
          String.format("Missing mandatory parameters '%s'", Arrays.toString(params)));
    }

    String containerName = "";
    String dataObjectName = "";
    String mimetype = null;
    Hashtable<String, String> headers = null;
    Hashtable<String, String> body = null;

    if (params.length == 4) {
      containerName = params[0].toString();
      Object obj = params[1];
      if (obj instanceof String[]) {
        String[] array = (String[]) obj;
        mimetype = array[0];
        dataObjectName = array[1];
      } else {
        dataObjectName = obj.toString();
      }
      headers = (Hashtable<String, String>) params[2];
      body = (Hashtable<String, String>) params[3];

      if (mimetype != null) body.put("mimetype", mimetype);
    }

    validate(CDMIOperation.UPDATE, headers, body);
    String URL = cdmiEPR + containerName + "/" + dataObjectName;

    return RestfulUtils.put(URL, headers, body);
  }
예제 #3
0
  @Override
  public CDMIResponse delete(Object... params) throws Exception {
    if (params == null || params.length <= 2) {
      throw new CDMIOperationException(
          String.format("Missing mandatory parameters '%s'", Arrays.toString(params)));
    }

    String containerName = "";
    String objectDataName = "";
    Hashtable<String, String> headers = null;

    if (params.length == 3) {
      containerName = params[0].toString();
      objectDataName = params[1].toString();
      headers = (Hashtable<String, String>) params[2];
    }

    String URL = cdmiEPR + containerName + "/" + objectDataName;

    return RestfulUtils.delete(URL, headers);
  }