Ejemplo n.º 1
0
 /**
  * This method performs create operation using request body.
  *
  * @param body POST Request Body
  * @return JSONObject as response
  * @throws DaoException Exception thrown
  */
 JSONObject internalCreate(HashMap<String, Object> body) throws DaoException {
   String url = this.getUrl();
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   DcResponse res = rest.post(url, JSONObject.toJSONString(body), RestAdapter.CONTENT_TYPE_JSON);
   JSONObject json = (JSONObject) ((JSONObject) res.bodyAsJson().get("d")).get("results");
   return json;
 }
Ejemplo n.º 2
0
  /**
   * This method is used to remove the link.
   *
   * @param cx Target object to delete link
   * @throws DaoException Exception thrown
   */
  public void unLink(AbstractODataContext cx) throws DaoException {

    String uri = getLinkUrl(cx);

    IRestAdapter rest = RestAdapterFactory.create(accessor);
    rest.del(uri + cx.getKey());
  }
Ejemplo n.º 3
0
 /**
  * This method checks whether the specified Odata exists.
  *
  * @param id ID value
  * @return true:Survival false:Absence
  */
 public Boolean exists(String id) {
   String url = this.getUrl() + "('" + id + "')";
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   try {
     rest.head(url);
     return true;
   } catch (DaoException e) {
     return false;
   }
 }
Ejemplo n.º 4
0
  /**
   * This method is used to create the link.
   *
   * @param cx Target object to create link
   * @throws DaoException Exception thrown
   */
  @SuppressWarnings("unchecked")
  public void link(AbstractODataContext cx) throws DaoException {
    String uri = getLinkUrl(cx);

    JSONObject body = new JSONObject();
    body.put("uri", cx.getODataLink());

    IRestAdapter rest = RestAdapterFactory.create(accessor);
    rest.post(uri, body.toJSONString(), RestAdapter.CONTENT_TYPE_JSON);
  }
Ejemplo n.º 5
0
 /**
  * This method appends query string to execute Query for Search.
  *
  * @param query Query object
  * @return JSON response
  * @throws DaoException Exception thrown
  */
 @SuppressWarnings("unchecked")
 @Override
 public HashMap<String, Object> doSearch(Query query) throws DaoException {
   StringBuilder sb = new StringBuilder(this.getUrl());
   String qry = query.makeQueryString();
   if (qry != null && !"".equals(qry)) {
     sb.append("?" + qry);
   }
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   DcResponse res = rest.get(sb.toString(), RestAdapter.CONTENT_TYPE_JSON);
   return (HashMap<String, Object>) ((JSONObject) res.bodyAsJson());
 }
Ejemplo n.º 6
0
 /**
  * This method performs delete operation.
  *
  * @param id id composite key url encoding the target
  * @param etag ETag Value
  * @throws DaoException Exception thrown
  */
 void internalDelMultiKey(String id, String etag) throws DaoException {
   String url = this.getUrl() + "(" + id + ")";
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   rest.del(url, etag);
 }
Ejemplo n.º 7
0
 /**
  * This method performs update operation using Request Body and Etag value.
  *
  * @param multiKeymultiKey composite key url encoding the target
  * @param body PUT Request Body
  * @param etag ETag Value
  * @throws DaoException Exception thrown
  */
 void internalUpdateMultiKey(String multiKey, HashMap<String, Object> body, String etag)
     throws DaoException {
   String url = this.getUrl() + "(" + multiKey + ")";
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   rest.put(url, JSONObject.toJSONString(body), etag, RestAdapter.CONTENT_TYPE_JSON);
 }
Ejemplo n.º 8
0
 /**
  * This method performs update operation using Request Body, Header and Etag value.
  *
  * @param id ID value
  * @param body PUT Request Body
  * @param etag ETag value
  * @param headers PUT Request Headers
  * @throws DaoException DAO例外
  */
 void internalUpdate(String id, JSONObject body, String etag, HashMap<String, String> headers)
     throws DaoException {
   String url = this.getUrl() + "('" + id + "')";
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   rest.put(url, body.toJSONString(), etag, headers, RestAdapter.CONTENT_TYPE_JSON);
 }
Ejemplo n.º 9
0
 /**
  * This method is used to retrieve the OData data for the specified ID.
  *
  * @param id composite key url encoding the target
  * @return Object of the result
  * @throws DaoException Exception thrown
  */
 DcResponse internalRetrieveMultikeyAsDcResponse(String id) throws DaoException {
   String url = this.getUrl() + "(" + id + ")";
   IRestAdapter rest = RestAdapterFactory.create(accessor);
   return rest.get(url, RestAdapter.CONTENT_TYPE_JSON);
 }