Package com.ibm.sbt.services.client

Examples of com.ibm.sbt.services.client.Response


    resource.setSource(source);
    resource.setResourceType(type);
    FollowSerializer serializer = new FollowSerializer(resource);
    String atomPayload = serializer.startFollowingPayload();
    String url = FollowUrls.format(source, this, Resource.get(resourceId));
    Response response = createData(url, generateParams(null, source, type, null), getAtomHeaders(), atomPayload);
    //Returns 200 but should be 201
    checkResponseCode(response, HTTPCode.OK);
    return getFollowFeedHandler().createEntity(response);
  }
View Full Code Here


   * @return boolean
   * @throws ClientServicesException
   */
  public boolean stopFollowing(String source,String type,String resourceId) throws ClientServicesException{
    String stopResourceUrl = FollowUrls.format(source, this, Resource.get(resourceId));
    Response response = deleteData(stopResourceUrl, generateParams(null, source, type, resourceId), resourceId);
    //Returns 202 but should be 204
    checkResponseCode(response, HTTPCode.ACCEPTED);
    return true;
  }
View Full Code Here

  /*
   * This method makes a network call and returns an entity
   */
  protected <T extends BaseEntity> T getEntity(String url, Map<String, String> parameters, IFeedHandler<T> feedHandler) throws ClientServicesException {
    try {
      Response response = retrieveData(url, parameters);
      return feedHandler.createEntity(response);
    } catch (Exception e){
      throw new ClientServicesException(e);
    }
  }
View Full Code Here

  /*
   * This method makes a network call and returns a Collection of Entities
   */
  protected <T extends BaseEntity> EntityList<T> getEntities(String url, Map<String, String> parameters, IFeedHandler<T> feedHandler) throws ClientServicesException {
    try {
      Response dataHolder = retrieveData(url, parameters);
      return feedHandler.createEntityList(dataHolder);
    } catch (Exception e){
      throw new ClientServicesException(e);
    }
  }
View Full Code Here

  /*
     * This method makes a network call and returns a Collection of Entities
     */
    protected <T extends BaseEntity> EntityList<T> getEntities(String url, Map<String, String> parameters, Map<String, String> headers, IFeedHandler<T> feedHandler) throws ClientServicesException {
    try {
          Response dataHolder = retrieveData(url, parameters, headers, null);
          return feedHandler.createEntityList(dataHolder);
    } catch (Exception e){
      throw new ClientServicesException(e);
    }
    }
View Full Code Here

     * @param format
     * @return
     * @throws ClientServicesException
     */
    public Response createData(String serviceUrl, Map<String, String> parameters, Map<String,String> headers, Object content, Handler format) throws ClientServicesException {
        Response result = getClientService().post(serviceUrl, parameters, headers, content, format);
        return result;
    }
View Full Code Here

        String uniqueId = null;
        if (nameParameterId != null) {
            uniqueId = (parameters == null) ? nameParameterId : parameters.get(nameParameterId);
        }

        Response r = getClientService().delete(serviceUrl, parameters, headers, getDataFormat());
       
        if (cacheSize > 0 && uniqueId != null) {
            removeFromCache(uniqueId);
        }
View Full Code Here

      String uniqueId = null;
        if (nameParameterId != null) {
            uniqueId = (parameters == null) ? nameParameterId : parameters.get(nameParameterId);
        }

        Response r = getClientService().delete(serviceUrl, parameters, headers, getDataFormat(),content);
       
        if (cacheSize > 0 && uniqueId != null) {
            removeFromCache(uniqueId);
        }
View Full Code Here

   * @throws ClientServicesException
   */
  public Response retrieveData(String url, Map<String, String> parameters, Map<String, String> headers, String nameParameterId)
              throws ClientServicesException {
          Object data = null;
          Response dataHolder = null;
          String uniqueId = "";
          if (nameParameterId != null) {
              uniqueId = parameters.get(nameParameterId);
              data = findInCache(uniqueId);
              dataHolder = new Response(data);
          }
          if (data == null) {
              dataHolder = getClientService().get(url, parameters, headers, getDataFormat());
              //in case of 401 errors  client service returns null
              if (dataHolder == null) return null;
              data = dataHolder.getData();
              if (cacheSize > 0 && nameParameterId != null) {
                  addDataToCache(uniqueId, data);
              }
          }
          return dataHolder;
View Full Code Here

        if (!headers.containsKey(CONTENT_TYPE)) {
            // TODO shouldn't assume this
          headers.put(CONTENT_TYPE, APPLICATION_ATOM_XML);
        }
        Response result = getClientService().put(serviceUrl, parameters, headers, content, getDataFormat());
        if (cacheSize > 0 && nameParameterId != null) {
            addDataToCache(uniqueId, content);
        }

        return result;
View Full Code Here

TOP

Related Classes of com.ibm.sbt.services.client.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.