Package com.socrata.model.requests

Examples of com.socrata.model.requests.SodaRequest


     * @throws InterruptedException throws is the thread is interrupted.
     */
    public UpsertResult upsertStream(String resourceId, MediaType mediaType, InputStream stream) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaTypedRequest<InputStream>(resourceId, stream, mediaType)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doAddStream(resourceId, mediaType, payload); }
        };

        try {

            ClientResponse response = requester.issueRequest();
            return deserializeUpsertResult(response.getEntityInputStream());

        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, mediaType, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<UpsertResult>(InputStream.class), requester);
        } catch (IOException ioe) {
View Full Code Here


     * @throws InterruptedException
     */
    public UpsertResult replaceStream(String resourceId, MediaType mediaType, InputStream stream) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaTypedRequest<InputStream>(resourceId, stream, mediaType)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doReplaceStream(resourceId, mediaType, payload); }
        };

        try {

            ClientResponse response = requester.issueRequest();
            return deserializeUpsertResult(response.getEntityInputStream());

        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, mediaType, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<UpsertResult>(InputStream.class), requester);
        } catch (IOException ioe) {
View Full Code Here

    public UpsertResult upsertCsv(String resourceId, File csvFile) throws SodaError, InterruptedException
    {
        try {
            InputStream is = new FileInputStream(csvFile);

            SodaRequest requester = new SodaTypedRequest<InputStream>(resourceId, is, HttpLowLevel.CSV_TYPE)
            {
                public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
                { return doAddStream(resourceId, mediaType, payload); }
            };

            try {
                ClientResponse response = requester.issueRequest();
                return deserializeUpsertResult(response.getEntityInputStream());
            } catch (LongRunningQueryException e) {
                return getHttpLowLevel().getAsyncResults(e.location, HttpLowLevel.CSV_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<UpsertResult>(InputStream.class), requester);
            } finally {
                GeneralUtils.closeQuietly(is);
View Full Code Here

    public UpsertResult replaceCsv(String resourceId, File csvFile) throws SodaError, InterruptedException
    {
        try {
            InputStream is = new FileInputStream(csvFile);

            SodaRequest requester = new SodaTypedRequest<InputStream>(resourceId, is, HttpLowLevel.CSV_TYPE)
            {
                public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
                { return doReplaceStream(resourceId, mediaType, payload); }
            };

            try {
                ClientResponse response = requester.issueRequest();
                return deserializeUpsertResult(response.getEntityInputStream());
            } catch (LongRunningQueryException e) {
                return getHttpLowLevel().getAsyncResults(e.location, HttpLowLevel.CSV_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<UpsertResult>(InputStream.class), requester);
            } finally {
                GeneralUtils.closeQuietly(is);
View Full Code Here

     * @throws SodaError  thrown if there is an error.  Investigate the structure for more information.
     * @throws InterruptedException throws is the thread is interrupted.
     */
    public <T> Meta  update(String resourceId, Object id, T object) throws SodaError, InterruptedException
    {
        SodaRequest requester = new SodaModRequest<T>(resourceId, object, id)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doUpdate(resourceId, id, payload); }
        };

        try {

            ClientResponse response = requester.issueRequest();
            return response.getEntity(Meta.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, HttpLowLevel.JSON_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<Meta>(Meta.class), requester);
        }

View Full Code Here

            searchBuilder.queryParam(clause.getQueryParamName(), clause.getValue());
        }
        searchBuilder.queryParam("limit", 200);


        SodaRequest requester = new SodaRequest<URI>(null, searchBuilder.build())
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return httpLowLevel.queryRaw(payload, MediaType.APPLICATION_JSON_TYPE); }
        };

        try {
            final ClientResponse    response = requester.issueRequest();
            return response.getEntity(SearchResults.class);
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, MediaType.APPLICATION_JSON_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<SearchResults>() {}, requester);
        }
    }
View Full Code Here

     * @throws SodaError
     * @throws InterruptedException
     */
    public DatasetInfo createDataset(final DatasetInfo dataset, final boolean useNewBackend) throws SodaError, InterruptedException
    {
        SodaRequest requester = new SodaRequest<DatasetInfo>(null, dataset)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                httpLowLevel.setUseNewBackend(useNewBackend);
                return httpLowLevel.postRaw(viewUri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, payload);
            }
        };

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

        final URI uri = UriBuilder.fromUri(viewUri)
                                  .path(id)
                                  .build();

        SodaRequest requester = new SodaRequest<URI>(null, uri)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return httpLowLevel.queryRaw(payload, HttpLowLevel.JSON_TYPE); }
        };
View Full Code Here

     */
    public  DatasetInfo updateDatasetInfo(final DatasetInfo datasetInfo) throws SodaError, InterruptedException
    {


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

        try {

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

     * @throws InterruptedException
     */
    public void deleteDataset(final String id) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<DatasetInfo>(id, null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {   URI uri = UriBuilder.fromUri(viewUri)
                                    .path(id)
                                    .build();
                return httpLowLevel.deleteRaw(uri);
            }
        };

        try {
            requester.issueRequest();
        } catch (LongRunningQueryException e) {
            getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), Dataset.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.