List the Named Maps In the Repository - Latest

Spectrum Spatial Guide

Product type
Software
Portfolio
Locate
Product family
Spectrumâ„¢ software
Product
Spectrumâ„¢ software > Spatial > Spectrum Spatial
Version
Latest
ft:locale
en-US
Product name
Spectrum Technology Platform
ft:title
Spectrum Spatial Guide
Copyright
2025
First publish date
2007
ft:lastEdition
2025-03-07
ft:lastPublication
2025-03-07T10:28:48.112000

This Java application calls the Mapping Service's REST interface to list the named maps in the repository. The list of named maps that is returned in the response is then output at the command line.

Here is the code:


public static void main(String[] args)
{
    java.io.InputStream is = null;

    try
    {
        // Create the REST request URL
        String serverUrl = "http://<server>:<port>/rest/Spatial/MappingService/maps.json";
        java.net.URL url = new java.net.URL(serverUrl);
        java.net.HttpURLConnection conn = (java.net.HttpURLConnection)url.openConnection();

        String user = "user";
        String password = "pass";

        // Credentials need to be a base64 encoded string of the nature "user:pass"
        String credentials = user + ":" + password;
        byte[] encodedBytes  = org.apache.commons.codec.binary.Base64.encodeBase64(credentials.getBytes());     
        String base64EncodedString = new String(encodedBytes);

        // Apply the authorization header - a string of nature "Basic <base64EncodedCredentialsString>"
        String authHeader = "Basic" + " " + base64EncodedString; 
        conn.addRequestProperty("Authorization", authHeader);

        // Get response for the request
        is = conn.getInputStream();
        java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
        org.apache.commons.io.IOUtils.copy(is, bos);
        is.close();

        // Display the response 
        System.out.println(new String(bos.toByteArray()));
    }
    catch (Exception e)
    {
        System.out.println(e.getMessage());
    }
    finally
    {
        org.apache.commons.io.IOUtils.closeQuietly(is);
    }
}