Android Open Source - transloadit-Android-sdk Transloadit Request






From Project

Back to project page transloadit-Android-sdk.

License

The source code is released under:

MIT License

If you think the Android project transloadit-Android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package hu.szabot.transloadit;
/*from   w  w  w.  j  a  v a 2s  .c o m*/
import hu.szabot.transloadit.executor.DefaultHttpExecutor;
import hu.szabot.transloadit.executor.ParsedApiData;
import hu.szabot.transloadit.log.TransloaditLogger;
import hu.szabot.transloadit.parser.IRequestParser;
import hu.szabot.transloadit.parser.JSONRequestParser;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**Uses Transloadit services based on the current configuration*/
public class TransloaditRequest implements IApiRequest<TransloaditResponse>
{
    /**Default absolute URI path of assembly requests*/
    public static final String ASSEMBLY_ROOT = "/assemblies";

    /**Default absolute URI path to request bored instance*/
    public static final String BORED_INSTANCE_PATH = "/instances/bored";

    /**Default host of Transloadit services*/
    public static final String DEFAULT_HOST = "api2.transloadit.com";

    /**Default protocol of Transloadit services*/
    public static final String DEFAULT_SCHEME = "http";

    /**The request URI*/
    private URI uri;
    
    /**The request ApiData*/
    private ApiData data;
    
    /**The request method*/
    private RequestMethod method;
    
    /**Creates a new TransloaditRequest object. sets the Host to the default one, also sets the path to AssemblyRoot*/
    public TransloaditRequest()
    {
      try {
      uri=new URI(DEFAULT_SCHEME,DEFAULT_HOST,ASSEMBLY_ROOT,null);
    } catch (URISyntaxException e) {
      
      TransloaditLogger.logError(getClass(), e,"Default URI parameter syntax invalid");
    }
    }

  @Override
  public TransloaditResponse execute() throws IOException 
  {
    DefaultHttpExecutor executor=new DefaultHttpExecutor();
    
    executor.setUri(uri);
    
    executor.setMethod(getMethod());
    
    return new TransloaditResponse(executor.execute(new ParsedApiData(getData(),getParser())));
  }

  @Override
  public ApiData getData() 
  {
    return data;
  }

  @Override
  public RequestMethod getMethod() 
  {
    return method;
  }

  @Override
  public URI getURI() {
    return uri;
  }

  @Override
  public void setPath(String path) throws URISyntaxException
  {
    uri=new URI(uri.getScheme(),uri.getHost(),path,null);
  }
  
  @Override
  public void setHost(String host) throws URISyntaxException
  {
    uri=new URI(uri.getScheme(),host,uri.getPath(),null);
  }
  
  @Override
  public void setMethod(RequestMethod method) 
  {
    this.method=method;
  }
  
  @Override
  public IRequestParser getParser()
  {
    return new JSONRequestParser();
  }
  
  @Override
  public void setData(ApiData data) 
  {
    this.data=data;
  }
    
}




Java Source Code List

hu.szabot.transloadit.ApiData.java
hu.szabot.transloadit.IApiRequest.java
hu.szabot.transloadit.IApiResponse.java
hu.szabot.transloadit.ITransloadit.java
hu.szabot.transloadit.TransloaditRequest.java
hu.szabot.transloadit.TransloaditResponse.java
hu.szabot.transloadit.Transloadit.java
hu.szabot.transloadit.assembly.AssemblyBuilder.java
hu.szabot.transloadit.assembly.IAssemblyBuilder.java
hu.szabot.transloadit.assembly.IStep.java
hu.szabot.transloadit.assembly.Step.java
hu.szabot.transloadit.assembly.exceptions.AlreadyDefinedKeyException.java
hu.szabot.transloadit.assembly.exceptions.InvalidFieldKeyException.java
hu.szabot.transloadit.exceptions.FileNotOpenableException.java
hu.szabot.transloadit.exceptions.NotParseableException.java
hu.szabot.transloadit.executor.DefaultHttpExecutor.java
hu.szabot.transloadit.executor.IRequestExecutor.java
hu.szabot.transloadit.executor.ParsedApiData.java
hu.szabot.transloadit.log.TransloaditLogger.java
hu.szabot.transloadit.parser.IRequestParser.java
hu.szabot.transloadit.parser.IResponseParser.java
hu.szabot.transloadit.parser.JSONRequestParser.java
hu.szabot.transloadit.parser.JSONResponseParser.java
hu.szabot.transloadit.utils.ShaUtils.java