org.gcube.contentmanagement.contentmanager.stubs.model.protocol
Class URIs

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

public class URIs
extends java.lang.Object

Utility methods for content URI creation and manipulation.

Author:
Fabio Simeoni (University of Strathclyde)

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

Field Detail

PROTOCOL

public static final java.lang.String PROTOCOL
Scheme of cms URIs.

See Also:
Constant Field Values
Constructor Detail

URIs

public URIs()
Method Detail

validate

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

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

make

public static java.net.URI make(java.lang.String collectionID,
                                java.lang.String... identifiers)
                         throws java.lang.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:
java.lang.IllegalArgumentException - if the input is null or empty.

collectionID

public static java.lang.String collectionID(java.net.URI uri)
                                     throws java.net.URISyntaxException
Returns the collection identifier in a cms URI.

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

documentID

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

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

nodeID

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

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

nodeIDs

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

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

parentURI

public static java.net.URI parentURI(java.net.URI uri)
                              throws java.net.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:
java.net.URISyntaxException - if the input URI is not a content URL.

documentURI

public static java.net.URI documentURI(java.net.URI uri)
                                throws java.net.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:
java.net.URISyntaxException - if the input URI is not a content URI.

predicate

public static final TreePredicate predicate(java.net.URI uri)
                                     throws java.net.URISyntaxException
Returns a tree predicate for the existence of the path of identifiers in a content URI.

Parameters:
uri - the URI.
Returns:
the predicate.
Throws:
java.net.URISyntaxException - if the URI is not a content URI.

toRSElement

public static final GenericRecord toRSElement(java.net.URI uri)
                                       throws java.net.URISyntaxException,
                                              java.lang.Exception
Returns the serialisation of a content URI as an element of ResultSet, as expected by the service.

Parameters:
uri - the URI.
Returns:
the element.
Throws:
java.net.URISyntaxException - if the URI is not a content URI.
java.lang.Exception - if the URI could not be serialised as an element.

connection

public static java.net.URLConnection connection(java.net.URI uri,
                                                java.lang.String scope)
                                         throws java.io.IOException,
                                                java.net.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:
java.io.IOException - if the connections could not be established.
java.net.URISyntaxException - if the URI is not a content URI or if the protocol handler for the cms scheme is not active.