org.gcube.contentmanager.storageclient.model.protocol
Class URIs

java.lang.Object
  extended by org.gcube.contentmanager.storageclient.model.protocol.URIs

public class URIs
extends Object

Utility methods for content URI creation and manipulation.

Author:
Fabio Simeoni (University of Strathclyde)

Field Summary
static String PROTOCOL
          Scheme of cms URIs.
 
Constructor Summary
URIs()
           
 
Method Summary
static String collectionID(URI uri)
          Returns the collection identifier in a sm URI.
static URLConnection connection(URI uri, String scope)
          Deprecated. since 2.3.1. Use URLConnection normally in current scope.
static String documentID(URI uri)
          Returns the document identifier in a content URI.
static URI documentURI(URI uri)
          Returns a content URI for the document of the node identified by another content URI.
static URI make(String collectionID, String... identifiers)
          Constructs a content URI from a collection identifiers and one or more node identifiers.
static String nodeID(URI uri)
          Returns the identifier of the node identified by a content URI.
static String[] nodeIDs(URI uri)
          Returns the identifiers in a content URI.
static URI parentURI(URI uri)
          Returns a content URI for the parent of the node identified by another content URI.
static void validate(URI uri)
          Indicates whether a URI is a valid content URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL

public static final String PROTOCOL
Scheme of cms URIs.

See Also:
Constant Field Values
Constructor Detail

URIs

public URIs()
Method Detail

validate

public static void validate(URI uri)
                     throws URISyntaxException
Indicates whether a URI is a valid content URI.

Parameters:
uri - the URI.
Throws:
URISyntaxException - if the URI fails validation.

make

public static URI make(String collectionID,
                       String... identifiers)
                throws IllegalArgumentException
Constructs a content URI from a collection identifiers and one or more node identifiers.

Parameters:
collectionID - the collection identifier.
identifiers - the node identifiers.
Returns:
the URI.
Throws:
IllegalArgumentException - if the input is null or empty.

collectionID

public static String collectionID(URI uri)
                           throws URISyntaxException
Returns the collection identifier in a sm URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a content URI.

documentID

public static String documentID(URI uri)
                         throws URISyntaxException
Returns the document identifier in a content URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a content URI.

nodeID

public static String nodeID(URI uri)
                     throws URISyntaxException
Returns the identifier of the node identified by a content URI.

Parameters:
uri - the URI.
Returns:
the identifier.
Throws:
URISyntaxException - if the URI is not a content URI.

nodeIDs

public static String[] nodeIDs(URI uri)
                        throws URISyntaxException
Returns the identifiers in a content URI.

Parameters:
uri - the URI.
Returns:
the identifiers.
Throws:
URISyntaxException - if the URI is not a content URI.

parentURI

public static URI parentURI(URI uri)
                     throws URISyntaxException
Returns a content URI for the parent of the node identified by another content URI.

Parameters:
uri - the input URI.
Returns:
the parent URI.
Throws:
URISyntaxException - if the input URI is not a content URL.

documentURI

public static URI documentURI(URI uri)
                       throws URISyntaxException
Returns a content URI for the document of the node identified by another content URI.

Parameters:
uri - the input URI.
Returns:
the document URI.
Throws:
URISyntaxException - if the input URI is not a content URI.

connection

public static URLConnection connection(URI uri,
                                       String scope)
                                throws IOException,
                                       URISyntaxException
Deprecated. since 2.3.1. Use URLConnection normally in current scope.

Returns a URL connection in a given scope.

Parameters:
uri - a content URI.
scope - the scope.
Returns:
the connection.
Throws:
IOException - if the connections could not be established.
URISyntaxException - if the URI is not a content URI or if the protocol handler for the smp scheme is not active.


Copyright © 2013. All Rights Reserved.