org.overlord.sramp.client
Class SrampAtomApiClient

java.lang.Object
  extended by org.overlord.sramp.client.SrampAtomApiClient

public class SrampAtomApiClient
extends Object

Class used to communicate with the S-RAMP server via the S-RAMP Atom API.

Author:
eric.wittmann@redhat.com

Constructor Summary
SrampAtomApiClient(String endpoint)
          Constructor.
SrampAtomApiClient(String endpoint, boolean validating)
          Constructor.
 
Method Summary
 SrampClientQuery buildQuery(String query)
          Build a query that can be parameterized and then executed.
 void deleteArtifact(String uuid, ArtifactType type)
          Delets an artifact from the s-ramp repository.
 void deleteOntology(String ontologyUuid)
          Deletes a single ontology by its UUID.
 InputStream getArtifactContent(ArtifactType artifactType, String artifactUuid)
          Gets the content for an artifact as an input stream.
 BaseArtifactType getArtifactMetaData(ArtifactType artifactType, String artifactUuid)
          Gets the full meta-data listing for an Artifact in the S-RAMP repository.
 BaseArtifactType getArtifactMetaData(String artifactUuid)
          Gets the full meta-data listing for an Artifact in the S-RAMP repository.
 String getEndpoint()
           
 List<OntologySummary> getOntologies()
          Gets a list of all the ontologies currently installed in the S-RAMP repository.
 org.jboss.resteasy.plugins.providers.atom.app.AppService getServiceDocument()
          Gets the S-RAMP service document.
 QueryResultSet query(String srampQuery)
          Provides a very simple mechanism for querying.
 QueryResultSet query(String srampQuery, int startIndex, int count, String orderBy, boolean ascending)
          Executes the given s-ramp query xpath and returns a Feed of the matching artifacts.
 QueryResultSet query(String srampQuery, int startIndex, int count, String orderBy, boolean ascending, Collection<String> propertyNames)
          Executes the given s-ramp query xpath and returns a Feed of the matching artifacts.
 void updateArtifactContent(BaseArtifactType artifact, InputStream content)
          Updates the content of the artifact.
 void updateArtifactMetaData(BaseArtifactType artifact)
          Called to update the meta-data stored in the s-ramp repository for the given s-ramp artifact.
 BaseArtifactType uploadArtifact(ArtifactType artifactType, InputStream content, String artifactFileName)
          Please refer to javadoc in SrampAtomApiClient#uploadArtifact(String, String, InputStream, String)
 BaseArtifactType uploadArtifact(BaseArtifactType baseArtifactType, InputStream content)
          Please refer to javadoc in SrampAtomApiClient#uploadArtifact(String, String, InputStream, String)
 Map<String,?> uploadBatch(SrampArchive archive)
          Performs a batch operation by uploading an s-ramp package archive to the s-ramp server for processing.
 RDF uploadOntology(InputStream content)
          Uploads an ontology to the S-RAMP repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SrampAtomApiClient

public SrampAtomApiClient(String endpoint)
Constructor.

Parameters:
endpoint -

SrampAtomApiClient

public SrampAtomApiClient(String endpoint,
                          boolean validating)
                   throws SrampClientException,
                          SrampAtomException
Constructor.

Parameters:
endpoint -
validating -
Throws:
SrampClientException
SrampAtomException
Method Detail

getEndpoint

public String getEndpoint()
Returns:
the s-ramp endpoint

getServiceDocument

public org.jboss.resteasy.plugins.providers.atom.app.AppService getServiceDocument()
                                                                            throws SrampClientException,
                                                                                   SrampAtomException
Gets the S-RAMP service document.

Throws:
SrampClientException
SrampAtomException

getArtifactMetaData

public BaseArtifactType getArtifactMetaData(String artifactUuid)
                                     throws SrampClientException,
                                            SrampAtomException
Gets the full meta-data listing for an Artifact in the S-RAMP repository. This method does not require the type of artifact. However, it should be noted that if you have the artifact type, you should instead call: getArtifactMetaData(ArtifactType, String) Use this variant only if you don't know the artifact type (you only know the UUID). The reason is that the client must first do a query to determine the artifact type and then make another call to fetch the meta data.

Parameters:
artifactUuid -
Throws:
SrampClientException
SrampAtomException

getArtifactMetaData

public BaseArtifactType getArtifactMetaData(ArtifactType artifactType,
                                            String artifactUuid)
                                     throws SrampClientException,
                                            SrampAtomException
Gets the full meta-data listing for an Artifact in the S-RAMP repository.

Parameters:
artifactType -
artifactUuid -
Throws:
SrampClientException
SrampAtomException

getArtifactContent

public InputStream getArtifactContent(ArtifactType artifactType,
                                      String artifactUuid)
                               throws SrampClientException,
                                      SrampAtomException
Gets the content for an artifact as an input stream. The caller must close the resulting

Parameters:
artifactType - the artifact type
artifactUuid - the S-RAMP uuid of the artifact
Returns:
an InputStream to the S-RAMP artifact content
Throws:
SrampClientException
SrampAtomException

uploadArtifact

public BaseArtifactType uploadArtifact(ArtifactType artifactType,
                                       InputStream content,
                                       String artifactFileName)
                                throws SrampClientException,
                                       SrampAtomException
Please refer to javadoc in SrampAtomApiClient#uploadArtifact(String, String, InputStream, String)

Parameters:
artifactType -
content -
artifactFileName -
Throws:
SrampClientException
SrampAtomException

uploadArtifact

public BaseArtifactType uploadArtifact(BaseArtifactType baseArtifactType,
                                       InputStream content)
                                throws SrampClientException,
                                       SrampAtomException
Please refer to javadoc in SrampAtomApiClient#uploadArtifact(String, String, InputStream, String)

Parameters:
baseArtifactType -
content -
Throws:
SrampClientException
SrampAtomException

uploadBatch

public Map<String,?> uploadBatch(SrampArchive archive)
                          throws SrampClientException,
                                 SrampAtomException
Performs a batch operation by uploading an s-ramp package archive to the s-ramp server for processing. The contents of the s-ramp archive will be processed, and the results will be returned as a Map. The Map is indexed by the S-RAMP Archive entry path, and each each value in the Map will either be a BaseArtifactType or an SrampAtomException, depending on success vs. failure of that entry.

Parameters:
archive - the s-ramp package archive to upload
Returns:
the collection of results (one per entry in the s-ramp package)
Throws:
SrampClientException
SrampAtomException

updateArtifactMetaData

public void updateArtifactMetaData(BaseArtifactType artifact)
                            throws SrampClientException,
                                   SrampAtomException
Called to update the meta-data stored in the s-ramp repository for the given s-ramp artifact.

Parameters:
artifact -
Throws:
SrampClientException
SrampAtomException

updateArtifactContent

public void updateArtifactContent(BaseArtifactType artifact,
                                  InputStream content)
                           throws SrampClientException,
                                  SrampAtomException
Updates the content of the artifact.

Parameters:
artifact -
content -
Throws:
SrampClientException
SrampAtomException

deleteArtifact

public void deleteArtifact(String uuid,
                           ArtifactType type)
                    throws SrampClientException,
                           SrampAtomException
Delets an artifact from the s-ramp repository.

Parameters:
uuid -
type -
Throws:
SrampClientException
SrampAtomException

query

public QueryResultSet query(String srampQuery)
                     throws SrampClientException,
                            SrampAtomException
Provides a very simple mechanism for querying. Defaults many of the parameters.

Parameters:
srampQuery - the s-ramp query (xpath formatted)
Throws:
SrampClientException
SrampAtomException

query

public QueryResultSet query(String srampQuery,
                            int startIndex,
                            int count,
                            String orderBy,
                            boolean ascending)
                     throws SrampClientException,
                            SrampAtomException
Executes the given s-ramp query xpath and returns a Feed of the matching artifacts.

Parameters:
srampQuery - the s-ramp query (xpath formatted)
startIndex - which index within the result to start (0 indexed)
count - the size of the page of results to return
orderBy - the s-ramp property to use for sorting (name, uuid, createdOn, etc)
ascending - the direction of the sort
propertyNames - an optional collection of names of custom s-ramp properties to be returned as part of the result set
Returns:
an Atom Feed
Throws:
SrampClientException
SrampAtomException

query

public QueryResultSet query(String srampQuery,
                            int startIndex,
                            int count,
                            String orderBy,
                            boolean ascending,
                            Collection<String> propertyNames)
                     throws SrampClientException,
                            SrampAtomException
Executes the given s-ramp query xpath and returns a Feed of the matching artifacts.

Parameters:
srampQuery - the s-ramp query (xpath formatted)
startIndex - which index within the result to start (0 indexed)
count - the size of the page of results to return
orderBy - the s-ramp property to use for sorting (name, uuid, createdOn, etc)
ascending - the direction of the sort
propertyNames - an optional collection of names of custom s-ramp properties to be returned as part of the result set
Returns:
an Atom Feed
Throws:
SrampClientException
SrampAtomException

buildQuery

public SrampClientQuery buildQuery(String query)
Build a query that can be parameterized and then executed. The format of the query can either be a complete valid query or a query with JDBC style parameters (using the ? placeholder for parameters). Additionally, the start index, count, order-by, ascending, and extra propertyNames can all be set after calling this method. String uuid = ... client.buildQuery("/s-ramp/core/Document[@uuid = ?]") .parameter(uuid) .startIndex(3) .count(20) .orderBy("name") .ascending() .propertyName("custom-prop-1") .propertyName("custom-prop-2") .query();

Parameters:
query -
Returns:
a client query object

uploadOntology

public RDF uploadOntology(InputStream content)
                   throws SrampClientException,
                          SrampAtomException
Uploads an ontology to the S-RAMP repository. This will only work if the S-RAMP repository supports the ontology collection, which is not a part of the S-RAMP 1.0 specification.

Parameters:
content -
Throws:
SrampClientException
SrampAtomException

getOntologies

public List<OntologySummary> getOntologies()
                                    throws SrampClientException,
                                           SrampAtomException
Gets a list of all the ontologies currently installed in the S-RAMP repository. This will only work if the S-RAMP repository supports the ontology collection, which is not a part of the S-RAMP 1.0 specification.

Throws:
SrampClientException
SrampAtomException

deleteOntology

public void deleteOntology(String ontologyUuid)
                    throws SrampClientException,
                           SrampAtomException
Deletes a single ontology by its UUID. Note that this will only work if the S-RAMP repository supports the ontology collection, which is not a part of the S-RAMP 1.0 specification.

Parameters:
ontologyUuid -
Throws:
SrampClientException
SrampAtomException


Copyright © 2011-2013 JBoss, a division of Red Hat. All Rights Reserved.