gov.nasa.pds.registry.client
Class RegistryClient

java.lang.Object
  extended by gov.nasa.pds.registry.client.RegistryClient

public class RegistryClient
extends Object

This class is a Java client to be used to exchange information with a registry service. In the background it simply uses HTTP calls but returns Java objects to ease integration.

Author:
pramirez

Constructor Summary
RegistryClient(String baseUrl)
           
RegistryClient(String baseUrl, SecurityContext securityContext, String username, String password)
           
 
Method Summary
 void changeStatusOfPackage(String packageGuid, ObjectAction action)
          Approve, deprecate, or undeprecate of a package
 void changeStatusOfPackageMembers(String packageGuid, ObjectAction action)
          Approve, deprecate, or undeprecate all members of a package
<T extends RegistryObject>
void
deleteObject(String guid, Class<T> objectClass)
          Removes an object from the registry of the given type
 void deletePackageMembers(String packageGuid)
          Deletes all members that are associated with the given package guid.
 PagedResponse<Association> getAssociations(RegistryQuery<AssociationFilter> query, Integer start, Integer rows)
          Retrieves a set of association objects that match the query.
 PagedResponse<AuditableEvent> getAuditableEvents(RegistryQuery<EventFilter> query, Integer start, Integer rows)
          Retrieves a paged set of registry objects from the collection of objects of the specified type.
 PagedResponse<ExtrinsicObject> getExtrinsics(RegistryQuery<ExtrinsicFilter> query, Integer start, Integer rows)
          Retrieves a set of extrinsic objects that match the query.
<T extends RegistryObject>
T
getLatestObject(String lid, Class<T> objectClass)
          Retrieve the latest version of a registry object
<T extends RegistryObject>
T
getObject(String guid, Class<T> objectClass)
          Retrieves an object from the registry of the given type
<T extends RegistryObject>
PagedResponse<T>
getObjects(Integer start, Integer rows, Class<T> objectClass)
          Retrieves a paged set of registry objects from the collection of objects of the specified type.
 PagedResponse<RegistryPackage> getPackages(RegistryQuery<PackageFilter> query, Integer start, Integer rows)
          Retrieves a set of package objects that match the query.
 String getRegistrationPackageGuid()
           
 Report getReport()
           
static void main(String[] args)
           
 String publishObject(RegistryObject object)
          Publish a registry object to the service
 void setMediaType(String mediaType)
          Used to override the type of messages the client will exchange.
 void setRegistrationPackageId(String registrationPackageGuid)
           
 void updateObject(RegistryObject object)
          Updates the given registry object by using its guid to indicate the object to update.
 String versionObject(RegistryObject object)
          Publishes a version of the given object that is considered a major version update.
 String versionObject(RegistryObject object, Boolean major)
          Publishes a version of the given object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryClient

public RegistryClient(String baseUrl)
               throws RegistryClientException
Throws:
RegistryClientException

RegistryClient

public RegistryClient(String baseUrl,
                      SecurityContext securityContext,
                      String username,
                      String password)
               throws RegistryClientException
Throws:
RegistryClientException
Method Detail

setMediaType

public void setMediaType(String mediaType)
Used to override the type of messages the client will exchange. Currently the regsitry supports application/xml and application/json but defaults to json. The end client will not see these calls so to cut down on data transferred the more compact json should be used.

Parameters:
mediaType - to use for exchanging messages

getObject

public <T extends RegistryObject> T getObject(String guid,
                                              Class<T> objectClass)
                                   throws RegistryServiceException
Retrieves an object from the registry of the given type

Parameters:
guid - identifier for the object
objectClass - of object interested in retrieving
Returns:
the identified object
Throws:
RegistryServiceException

deleteObject

public <T extends RegistryObject> void deleteObject(String guid,
                                                    Class<T> objectClass)
                  throws RegistryServiceException
Removes an object from the registry of the given type

Type Parameters:
T -
Parameters:
guid - identifier for the object
objectClass - of object interested in deleting
Throws:
RegistryServiceException

deletePackageMembers

public void deletePackageMembers(String packageGuid)
                          throws RegistryServiceException
Deletes all members that are associated with the given package guid.

Parameters:
packageGuid - to delete from
Throws:
RegistryServiceException

changeStatusOfPackageMembers

public void changeStatusOfPackageMembers(String packageGuid,
                                         ObjectAction action)
                                  throws RegistryServiceException
Approve, deprecate, or undeprecate all members of a package

Parameters:
packageGuid - to update members from
action - to take which will end up affecting members statuses
Throws:
RegistryServiceException

changeStatusOfPackage

public void changeStatusOfPackage(String packageGuid,
                                  ObjectAction action)
                           throws RegistryServiceException
Approve, deprecate, or undeprecate of a package

Parameters:
packageGuid - to update
action - to take which will end up affecting package statuses
Throws:
RegistryServiceException

publishObject

public String publishObject(RegistryObject object)
                     throws RegistryServiceException
Publish a registry object to the service

Parameters:
object - to publish
Returns:
the globally unique identifier
Throws:
RegistryServiceException

versionObject

public String versionObject(RegistryObject object)
                     throws RegistryServiceException
Publishes a version of the given object that is considered a major version update.

Parameters:
object - to publish
Returns:
globally unique identifier of versioned object
Throws:
RegistryServiceException

versionObject

public String versionObject(RegistryObject object,
                            Boolean major)
                     throws RegistryServiceException
Publishes a version of the given object

Parameters:
object - to publish
major - flag to indicate major or minor version
Returns:
globally unique identifier of versioned object
Throws:
RegistryServiceException

updateObject

public void updateObject(RegistryObject object)
                  throws RegistryServiceException
Updates the given registry object by using its guid to indicate the object to update.

Parameters:
object - to update to
Throws:
RegistryServiceException

getLatestObject

public <T extends RegistryObject> T getLatestObject(String lid,
                                                    Class<T> objectClass)
                                         throws RegistryServiceException
Retrieve the latest version of a registry object

Parameters:
lid - logical identifier which is associated with a collection of objects
objectClass - of object interested in retrieving
Returns:
latest managed copy of the requested object
Throws:
RegistryServiceException

getObjects

public <T extends RegistryObject> PagedResponse<T> getObjects(Integer start,
                                                              Integer rows,
                                                              Class<T> objectClass)
                                                   throws RegistryServiceException
Retrieves a paged set of registry objects from the collection of objects of the specified type.

Parameters:
start - indicates where in the set of objects to begin
rows - indicates how many objects to return
objectClass - the type of object to retrieve
Returns:
all objects found with the given constraints
Throws:
RegistryServiceException

getExtrinsics

public PagedResponse<ExtrinsicObject> getExtrinsics(RegistryQuery<ExtrinsicFilter> query,
                                                    Integer start,
                                                    Integer rows)
                                             throws RegistryServiceException
Retrieves a set of extrinsic objects that match the query.

Parameters:
query - filters for the extrinsic
start - indicates where in the set of objects to begin
rows - indicates how many objects to return
Returns:
paged set of extrisic objects
Throws:
RegistryServiceException

getPackages

public PagedResponse<RegistryPackage> getPackages(RegistryQuery<PackageFilter> query,
                                                  Integer start,
                                                  Integer rows)
                                           throws RegistryServiceException
Retrieves a set of package objects that match the query.

Parameters:
query - filters for the package
start - indicates where in the set of objects to begin
rows - indicates how many objects to return
Returns:
paged set of package objects
Throws:
RegistryServiceException

getAssociations

public PagedResponse<Association> getAssociations(RegistryQuery<AssociationFilter> query,
                                                  Integer start,
                                                  Integer rows)
                                           throws RegistryServiceException
Retrieves a set of association objects that match the query.

Parameters:
query - filters for the association
start - indicates where in the set of objects to begin
rows - indicates how many objects to return
Returns:
paged set of association objects
Throws:
RegistryServiceException

getAuditableEvents

public PagedResponse<AuditableEvent> getAuditableEvents(RegistryQuery<EventFilter> query,
                                                        Integer start,
                                                        Integer rows)
                                                 throws RegistryServiceException
Retrieves a paged set of registry objects from the collection of objects of the specified type.

Parameters:
start - indicates where in the set of objects to begin
rows - indicates how many objects to return
objectClass - the type of object to retrieve
Returns:
all objects found with the given constraints
Throws:
RegistryServiceException

getReport

public Report getReport()
                 throws RegistryServiceException
Throws:
RegistryServiceException

getRegistrationPackageGuid

public String getRegistrationPackageGuid()

setRegistrationPackageId

public void setRegistrationPackageId(String registrationPackageGuid)

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2010–2015 Planetary Data System. All rights reserved.