Package slash.navigation.rest

Examples of slash.navigation.rest.Get


    public String getName() {
        return "EarthTools";
    }

    public Double getElevationFor(double longitude, double latitude) throws IOException {
        Get get = new Get(getEarthToolsUrlPreference() + "height/" + latitude + "/" + longitude);
        String result = get.executeAsString();
        if (get.isSuccessful())
            try {
                Height height = unmarshal(result);
                Integer elevation = parseInt(height.getMeters());
                if (elevation != null && !elevation.equals(-9999))
                    return elevation.doubleValue();
View Full Code Here


        updateState(download, Resuming);
        long fileSize = download.getTempFile().length();
        Long contentLength = download.getFile().getExpectedChecksum() != null ? download.getFile().getExpectedChecksum().getContentLength() : null;
        log.info(format("Resuming bytes %d-%d from %s", fileSize, contentLength, download.getUrl()));

        get = new Get(download.getUrl());
        get.setRange(fileSize, contentLength);

        InputStream inputStream = get.executeAsStream();
        log.info(format("Resume from %s returned with status code %s", download.getUrl(), get.getStatusCode()));
        if (get.isPartialContent()) {
View Full Code Here

    private boolean download() throws IOException {
        updateState(download, Downloading);
        Long contentLength = download.getFile().getExpectedChecksum() != null ? download.getFile().getExpectedChecksum().getContentLength() : null;
        log.info(format("Downloading %d bytes from %s with ETag %s", contentLength, download.getUrl(), download.getETag()));

        get = new Get(download.getUrl());
        if (new Validator(download).existTargets() && download.getETag() != null)
            get.setIfNoneMatch(download.getETag());

        InputStream inputStream = get.executeAsStream();
        log.info(format("Download from %s returned with status code %s", download.getUrl(), get.getStatusCode()));
View Full Code Here

    private static String getGeocodingUrl(String payload) {
        return getGoogleMapsApiUrl("geocode", payload);
    }

    private Get get(String url) {
        Get get = new Get(url);
        get.setUserAgent("Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 5.1)");
        return get;
    }
View Full Code Here

        return get;
    }

    public String getLocationFor(double longitude, double latitude) throws IOException {
        String url = getGeocodingUrl("latlng=" + latitude + "," + longitude);
        Get get = get(url);
        String result = get.executeAsString();
        if (get.isSuccessful())
            try {
                GeocodeResponse geocodeResponse = unmarshalGeocode(result);
                if (geocodeResponse != null) {
                    String status = geocodeResponse.getStatus();
                    if (status.equals(OK))
View Full Code Here

        return positions != null && positions.size() > 0 ? positions.get(0) : null;
    }

    public List<NavigationPosition> getPositionsFor(String address) throws IOException {
        String url = getGeocodingUrl("address=" + encodeUri(address));
        Get get = get(url);
        String result = get.executeAsString();
        if (get.isSuccessful())
            try {
                GeocodeResponse geocodeResponse = unmarshalGeocode(result);
                if (geocodeResponse != null) {
                    String status = geocodeResponse.getStatus();
                    if (status.equals(OK))
View Full Code Here

        return result;
    }

    public Double getElevationFor(double longitude, double latitude) throws IOException {
        String url = getElevationUrl("locations=" + latitude + "," + longitude); // TODO could be up to 512 locations
        Get get = get(url);
        String result = get.executeAsString();
        if (get.isSuccessful())
            try {
                ElevationResponse elevationResponse = unmarshalElevation(result);
                if (elevationResponse != null) {
                    String status = elevationResponse.getStatus();
                    if (status.equals(OK)) {
View Full Code Here

        this.credentials = credentials;
    }

    GpxType fetchGpx(String url) throws IOException {
        log.fine("Fetching gpx from " + url);
        Get get = new Get(url);
        String result = get.executeAsString();
        if (get.isSuccessful())
            try {
                return unmarshal11(result);
            } catch (JAXBException e) {
                throw new IOException("Cannot unmarshall " + result + ": " + e, e);
            }
View Full Code Here

            assertNotNull(head304Etag.getETag());
            assertNull(head304Etag.getLastModified());
            assertNull(head304Etag.getContentLength());
            System.out.println(head304Etag.getHeaders());

            Get get200 = new Get(url);
            get200.executeAsString();
            assertTrue(get200.isOk());
            assertTrue(get200.getAcceptByteRanges());
            assertNotNull(get200.getETag());
            assertNotNull(get200.getLastModified());
            assertNotNull(get200.getContentLength());
            System.out.println("GET 200: " + get200.getHeaders());

            Get get304IfModifiedSince = new Get(url);
            get304IfModifiedSince.setIfModifiedSince(head200.getLastModified());
            get304IfModifiedSince.executeAsString();
            assertTrue(get304IfModifiedSince.isNotModified());
            assertFalse(get304IfModifiedSince.getAcceptByteRanges());
            assertNotNull(get304IfModifiedSince.getETag());
            assertNull(get304IfModifiedSince.getLastModified());
            assertNull(get304IfModifiedSince.getContentLength());
            System.out.println(get304IfModifiedSince.getHeaders());

            Get get304Etag = new Get(url);
            get304Etag.setIfNoneMatch(head200.getETag());
            get304Etag.executeAsString();
            assertTrue(get304Etag.isNotModified());
            assertFalse(get304Etag.getAcceptByteRanges());
            assertNotNull(get304Etag.getETag());
            assertNull(get304Etag.getLastModified());
            assertNull(get304Etag.getContentLength());
            System.out.println(get304Etag.getHeaders() + "\n");
        }
    }
View Full Code Here

        return preferences.get(GEONAMES_USERNAME_PREFERENCE, "routeconverter");
    }

    private String execute(String uri) throws IOException {
        String url = getGeoNamesNamesUrl() + uri + "&username=" + getGeoNamesUserName();
        Get get = new Get(url);
        String result = get.executeAsString();
        if (get.isSuccessful()) {
            checkCurrentlyOverloaded(url, result);
            return result;
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of slash.navigation.rest.Get

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.