Package com.socrata.model.requests

Examples of com.socrata.model.requests.SodaRequest


     * any user, meaning any use will have teh "viewer" role for this dataset.
     *
     * @param datasetId id of the dataset to make public.
     */
    public void makePublic(final String datasetId) throws SodaError, InterruptedException {
        SodaRequest requester = new SodaRequest<String>(datasetId,null)
        {

            //accessType=WEBSITE&method=setPermission&value=public.read
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI publicationUri = UriBuilder.fromUri(viewUri)
                                                     .path(resourceId)
                                                     .queryParam("accessType", "WEBSITE")
                                                     .queryParam("method", "setPermission")
                                                     .queryParam("value", "public.read")
                                                     .build();

                return httpLowLevel.putRaw(publicationUri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, "method=setPermission");
            }
        };

        try {

            requester.issueRequest();
        } catch (LongRunningQueryException e) {
            getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), Dataset.class, requester);
        }
    }
View Full Code Here


     * with, or people who are admins on the site.
     *
     * @param datasetId id of the dataset
     */
    public void makePrivate(final String datasetId) throws SodaError, InterruptedException {
        SodaRequest requester = new SodaRequest<String>(datasetId,null)
        {

            //accessType=WEBSITE&method=setPermission&value=public.read
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI publicationUri = UriBuilder.fromUri(viewUri)
                                                     .path(resourceId)
                                                     .queryParam("accessType", "WEBSITE")
                                                     .queryParam("method", "setPermission")
                                                     .queryParam("value", "private")
                                                     .build();

                return httpLowLevel.putRaw(publicationUri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, "method=setPermission");
            }
        };

        try {

            requester.issueRequest();
        } catch (LongRunningQueryException e) {
            getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), Dataset.class, requester);
        }
    }
View Full Code Here

     * @throws SodaError
     * @throws InterruptedException
     */
    public GeocodingResults findPendingGeocodingResults(final String datasetId) throws SodaError, InterruptedException
    {
        SodaRequest requester = new SodaRequest<String>(datasetId, null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(geocodingUri)
                                          .path(datasetId)
                                          .queryParam("method", "pending")
                                          .build();

                return httpLowLevel.queryRaw(uri, HttpLowLevel.JSON_TYPE);
            }
        };


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

    }

    public Comment addComment(final String datasetId, final Comment comment) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<String>(datasetId, null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            {
                final URI uri = UriBuilder.fromUri(viewUri)
                                          .path(datasetId)
                                          .path(COMMENTS_METHOD_PATH)
                                          .build();

                return httpLowLevel.postRaw(uri, HttpLowLevel.JSON_TYPE, ContentEncoding.IDENTITY, comment);
            }
        };


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

     * @throws InterruptedException throws is the thread is interrupted.
     */
    public void truncate(String resourceId) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<String>(resourceId, null)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doTruncate(resourceId); }
        };

        try {
            requester.issueRequest();
        } catch (LongRunningQueryException e) {
            getHttpLowLevel().getAsyncResults(e.location, HttpLowLevel.JSON_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<String>(String.class), requester);
        }
    }
View Full Code Here

     * @throws InterruptedException throws is the thread is interrupted.
     */
    public void delete(String resourceId, String id) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<String>(resourceId, id)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doDelete(resourceId, payload); }
        };

        try {
            requester.issueRequest();
        } catch (LongRunningQueryException e) {
            getHttpLowLevel().getAsyncResults(e.location, HttpLowLevel.JSON_TYPE, e.timeToRetry, getHttpLowLevel().getMaxRetries(), new GenericType<String>(String.class), requester);
        }

    }
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 addObject(String resourceId, T object) throws SodaError, InterruptedException
    {
        SodaRequest requester = new SodaRequest<T>(resourceId, object)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doAdd(resourceId, payload); }
        };

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

     * @throws InterruptedException throws is the thread is interrupted.
     */
    public <T> T addObject(String resourceId, T object, Class<T> retType) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<T>(resourceId, object)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doAdd(resourceId, payload); }
        };

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

     * @throws InterruptedException throws is the thread is interrupted.
     */
    public UpsertResult upsert(String resourceId, List objects) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<List>(resourceId, objects)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doAddObjects(resourceId, payload); }
        };

        try {
            ClientResponse response = requester.issueRequest();
            return deserializeUpsertResult(response.getEntityInputStream());
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), UpsertResult.class, requester);
        } catch (IOException ioe) {
            throw new SodaError("Error upserting a dataset from this list of objects.  Error message: " + ioe.getLocalizedMessage());
View Full Code Here

     * @throws InterruptedException
     */
    public UpsertResult replace(String resourceId, List objects) throws SodaError, InterruptedException
    {

        SodaRequest requester = new SodaRequest<List>(resourceId, objects)
        {
            public ClientResponse issueRequest() throws LongRunningQueryException, SodaError
            { return doReplaceObjects(resourceId, payload); }
        };

        try {
            ClientResponse response = requester.issueRequest();
            return deserializeUpsertResult(response.getEntityInputStream());
        } catch (LongRunningQueryException e) {
            return getHttpLowLevel().getAsyncResults(e.location, e.timeToRetry, getHttpLowLevel().getMaxRetries(), UpsertResult.class, requester);
        } catch (IOException ioe) {
            throw new SodaError("Error replacing dataset from this list of objects.  Error message: " + ioe.getLocalizedMessage());
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.