Package com.socrata.model.requests

Examples of com.socrata.model.requests.SodaRequest


     * @throws SodaError
     * @throws InterruptedException
     */
    public Column addColumn(final String datasetId, final Column column) throws SodaError, InterruptedException
    {
        SodaRequest requester = new SodaRequest<Column>(datasetId, column)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(viewUri)
                                          .path(resourceId)
                                          .path(COLUMNS_PATH)
                                          .build();
                return httpLowLevel.postRaw(uri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, payload);
            }
        };

        try {
            final ClientResponse response = requester.issueRequest();
            return response.getEntity(Column.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), Column.class, requester);
        }

View Full Code Here


     * @throws InterruptedException
     */
    public Column alterColumn(final String datasetId, final Column column) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<Column>(datasetId, column)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(viewUri)
                                          .path(resourceId)
                                          .path(COLUMNS_PATH)
                                          .path(Integer.toString(payload.getId()))
                                          .build();
                return httpLowLevel.putRaw(uri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, payload);
            }
        };

        try {
            final ClientResponse response = requester.issueRequest();
            return response.getEntity(Column.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), Column.class, requester);
        }
    }
View Full Code Here

     * @return the asset ID and name
     */
    public AssetResponse addAsset(final File file) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<File>(null, file)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                return httpLowLevel.postFileRaw(assetUri, MediaType.TEXT_PLAIN_TYPE, MediaType.TEXT_PLAIN_TYPE, payload);
            }
        };

        try {
            final ClientResponse response = requester.issueRequest();
            return mapper.readValue(response.getEntity(InputStream.class), AssetResponse.class);
            //return response.getEntity(AssetResponse.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), AssetResponse.class, requester);
        } catch (JsonMappingException e) {
View Full Code Here

     * @return InputStream of the file saved as the asset
     */
    public InputStream getAsset(final String id) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<File>(id, null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(assetUri)
                                          .path(resourceId)
                                          .build();

                return httpLowLevel.queryRaw(uri, MediaType.WILDCARD_TYPE);
            }
        };

        try {
            final ClientResponse response = requester.issueRequest();
            return response.getEntity(InputStream.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), InputStream.class, requester);
        }
    }
View Full Code Here

    public InputStream getFileBlob(final NonDataFileDataset dataset) throws SodaError, InterruptedException
    {
        Preconditions.checkArgument(dataset.getBlobId()!=null, "Dataset MUST be imported already before calling this.  Otherwise, the file doesn't have a Blob ID yet.");


        SodaRequest requester = new SodaRequest<File>(dataset.getBlobId(), null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(fileResourceUri)
                                          .path(resourceId)
                                          .build();

                return httpLowLevel.queryRaw(uri, MediaType.WILDCARD_TYPE);
            }
        };

        try {
            final ClientResponse response = requester.issueRequest();
            return response.getEntity(InputStream.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), InputStream.class, requester);
        }
    }
View Full Code Here

TOP

Related Classes of com.socrata.model.requests.SodaRequest

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.