org.apache.chemistry.opencmis.client.bindings.spi.atompub
Class AbstractAtomPubService

java.lang.Object
  extended by org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService
All Implemented Interfaces:
LinkAccess
Direct Known Subclasses:
AclServiceImpl, DiscoveryServiceImpl, MultiFilingServiceImpl, NavigationServiceImpl, ObjectServiceImpl, PolicyServiceImpl, RelationshipServiceImpl, RepositoryServiceImpl, VersioningServiceImpl

public class AbstractAtomPubService
extends Object
implements LinkAccess

Base class for all AtomPub clients.


Nested Class Summary
protected static class AbstractAtomPubService.IdentifierType
           
 
Field Summary
protected static String NAME_COLLECTION
           
protected static String NAME_NUM_ITEMS
           
protected static String NAME_PATH_SEGMENT
           
protected static String NAME_RELATIVE_PATH_SEGMENT
           
protected static String NAME_URI_TEMPLATE
           
 
Constructor Summary
AbstractAtomPubService()
           
 
Method Summary
protected  void addCollection(String repositoryId, String collection, String link)
          Adds a collection to the cache.
protected  void addLink(String repositoryId, String id, AtomLink link)
          Adds a link to the cache.
protected  void addLink(String repositoryId, String id, String rel, String type, String link)
          Adds a link to the cache.
protected  void addRepositoryLink(String repositoryId, AtomLink link)
          Adds a repository link to the cache.
protected  void addRepositoryLink(String repositoryId, String rel, String link)
          Adds a repository link to the cache.
protected  void addTemplate(String repositoryId, String type, String link)
          Adds an URI template to the cache.
protected  void addTypeLink(String repositoryId, String typeId, AtomLink link)
          Adds a type link to the cache.
protected  void addTypeLink(String repositoryId, String typeId, String rel, String type, String link)
          Adds a type link to the cache.
protected  CmisBaseException convertStatusCode(int code, String message, String errorContent, Throwable t)
          Converts a HTTP status code into an Exception.
protected  CmisObjectType createIdObject(String objectId)
          Creates a CMIS object that only contains an id in the property list.
protected  void delete(UrlBuilder url)
          Performs a DELETE on an URL, checks the response code and returns the result.
protected  String extractErrorMessage(String message, String errorContent)
           
protected  String extractException(String errorContent)
           
protected  String getCollection(String repositoryId, String collection)
          Gets a collection from the cache.
protected  String getLink(String repositoryId, String id, String rel)
          Gets a link from the cache.
protected  String getLink(String repositoryId, String id, String rel, String type)
          Gets a link from the cache.
protected  LinkCache getLinkCache()
          Returns the link cache or creates a new cache if it doesn't exist.
protected  ObjectData getObjectInternal(String repositoryId, AbstractAtomPubService.IdentifierType idOrPath, String objectIdOrPath, ReturnVersion returnVersion, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension)
          Retrieves an object from the server and caches the links.
protected  List<RepositoryInfo> getRepositoriesInternal(String repositoryId)
          Retrieves the Service Document from the server and caches the repository info objects, collections, links, URI templates, etc.
protected  String getRepositoryLink(String repositoryId, String rel)
          Gets a repository link from the cache.
protected  String getServiceDocURL()
          Returns the service document URL of this session.
protected  BindingSession getSession()
          Gets the current session.
protected  String getTemplateLink(String repositoryId, String type, Map<String,Object> parameters)
          Gets an URI template from the cache.
protected  TypeDefinition getTypeDefinitionInternal(String repositoryId, String typeId)
          Retrieves a type definition.
protected  String getTypeLink(String repositoryId, String typeId, String rel)
          Gets a type link from the cache.
protected  String getTypeLink(String repositoryId, String typeId, String rel, String type)
          Gets a type link from the cache.
protected  boolean is(String name, AtomElement element)
           
protected  boolean isAclMergeRequired(Acl addAces, Acl removeAces)
          Checks if at least one ACE list is not empty.
protected  boolean isInt(String name, AtomElement element)
           
protected  boolean isNextLink(AtomElement element)
           
protected  boolean isStr(String name, AtomElement element)
           
protected  String loadCollection(String repositoryId, String collection)
          Gets a collection from the cache if it is there or loads it into the cache if it is not there.
 String loadContentLink(String repositoryId, String id)
          Gets the content link from the cache if it is there or loads it into the cache if it is not there.
 String loadLink(String repositoryId, String id, String rel, String type)
          Gets a link from the cache if it is there or loads it into the cache if it is not there.
protected  String loadRepositoryLink(String repositoryId, String rel)
          Gets a repository link from the cache if it is there or loads it into the cache if it is not there.
protected  String loadTemplateLink(String repositoryId, String type, Map<String,Object> parameters)
          Gets a template link from the cache if it is there or loads it into the cache if it is not there.
protected  String loadTypeLink(String repositoryId, String typeId, String rel, String type)
          Gets a link from the cache if it is there or loads it into the cache if it is not there.
protected  void lockLinks()
          Locks the link cache.
protected  void lockTypeLinks()
          Locks the type link cache.
protected  Acl mergeAcls(Acl originalAces, Acl addAces, Acl removeAces)
          Merges the new ACL from original, add and remove ACEs lists.
protected
<T extends AtomBase>
T
parse(InputStream stream, Class<T> clazz)
          Parses an input stream.
protected  HttpUtils.Response post(UrlBuilder url, String contentType, HttpUtils.Output writer)
          Performs a POST on an URL, checks the response code and returns the result.
protected  HttpUtils.Response put(UrlBuilder url, String contentType, HttpUtils.Output writer)
          Performs a PUT on an URL, checks the response code and returns the result.
protected  HttpUtils.Response put(UrlBuilder url, String contentType, Map<String,String> headers, HttpUtils.Output writer)
          Performs a PUT on an URL, checks the response code and returns the result.
protected  HttpUtils.Response read(UrlBuilder url)
          Performs a GET on an URL, checks the response code and returns the result.
protected  void removeLinks(String repositoryId, String id)
          Removes all links of an object.
protected  void removeTypeLinks(String repositoryId, String id)
          Removes all links of a type.
protected  void setSession(BindingSession session)
          Sets the current session.
protected  void throwLinkException(String repositoryId, String id, String rel, String type)
          Checks a link throw an appropriate exception.
protected  void unlockLinks()
          Unlocks the link cache.
protected  void unlockTypeLinks()
          Unlocks the type link cache.
protected  AtomAcl updateAcl(String repositoryId, String objectId, Acl acl, AclPropagation aclPropagation)
          Updates the ACL of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_COLLECTION

protected static final String NAME_COLLECTION
See Also:
Constant Field Values

NAME_URI_TEMPLATE

protected static final String NAME_URI_TEMPLATE
See Also:
Constant Field Values

NAME_PATH_SEGMENT

protected static final String NAME_PATH_SEGMENT
See Also:
Constant Field Values

NAME_RELATIVE_PATH_SEGMENT

protected static final String NAME_RELATIVE_PATH_SEGMENT
See Also:
Constant Field Values

NAME_NUM_ITEMS

protected static final String NAME_NUM_ITEMS
See Also:
Constant Field Values
Constructor Detail

AbstractAtomPubService

public AbstractAtomPubService()
Method Detail

setSession

protected void setSession(BindingSession session)
Sets the current session.


getSession

protected BindingSession getSession()
Gets the current session.


getServiceDocURL

protected String getServiceDocURL()
Returns the service document URL of this session.


getLinkCache

protected LinkCache getLinkCache()
Returns the link cache or creates a new cache if it doesn't exist.


getLink

protected String getLink(String repositoryId,
                         String id,
                         String rel,
                         String type)
Gets a link from the cache.


getLink

protected String getLink(String repositoryId,
                         String id,
                         String rel)
Gets a link from the cache.


loadLink

public String loadLink(String repositoryId,
                       String id,
                       String rel,
                       String type)
Gets a link from the cache if it is there or loads it into the cache if it is not there.

Specified by:
loadLink in interface LinkAccess

loadContentLink

public String loadContentLink(String repositoryId,
                              String id)
Gets the content link from the cache if it is there or loads it into the cache if it is not there.

Specified by:
loadContentLink in interface LinkAccess

addLink

protected void addLink(String repositoryId,
                       String id,
                       String rel,
                       String type,
                       String link)
Adds a link to the cache.


addLink

protected void addLink(String repositoryId,
                       String id,
                       AtomLink link)
Adds a link to the cache.


removeLinks

protected void removeLinks(String repositoryId,
                           String id)
Removes all links of an object.


lockLinks

protected void lockLinks()
Locks the link cache.


unlockLinks

protected void unlockLinks()
Unlocks the link cache.


throwLinkException

protected void throwLinkException(String repositoryId,
                                  String id,
                                  String rel,
                                  String type)
Checks a link throw an appropriate exception.


getTypeLink

protected String getTypeLink(String repositoryId,
                             String typeId,
                             String rel,
                             String type)
Gets a type link from the cache.


getTypeLink

protected String getTypeLink(String repositoryId,
                             String typeId,
                             String rel)
Gets a type link from the cache.


loadTypeLink

protected String loadTypeLink(String repositoryId,
                              String typeId,
                              String rel,
                              String type)
Gets a link from the cache if it is there or loads it into the cache if it is not there.


addTypeLink

protected void addTypeLink(String repositoryId,
                           String typeId,
                           String rel,
                           String type,
                           String link)
Adds a type link to the cache.


addTypeLink

protected void addTypeLink(String repositoryId,
                           String typeId,
                           AtomLink link)
Adds a type link to the cache.


removeTypeLinks

protected void removeTypeLinks(String repositoryId,
                               String id)
Removes all links of a type.


lockTypeLinks

protected void lockTypeLinks()
Locks the type link cache.


unlockTypeLinks

protected void unlockTypeLinks()
Unlocks the type link cache.


getCollection

protected String getCollection(String repositoryId,
                               String collection)
Gets a collection from the cache.


loadCollection

protected String loadCollection(String repositoryId,
                                String collection)
Gets a collection from the cache if it is there or loads it into the cache if it is not there.


addCollection

protected void addCollection(String repositoryId,
                             String collection,
                             String link)
Adds a collection to the cache.


getRepositoryLink

protected String getRepositoryLink(String repositoryId,
                                   String rel)
Gets a repository link from the cache.


loadRepositoryLink

protected String loadRepositoryLink(String repositoryId,
                                    String rel)
Gets a repository link from the cache if it is there or loads it into the cache if it is not there.


addRepositoryLink

protected void addRepositoryLink(String repositoryId,
                                 String rel,
                                 String link)
Adds a repository link to the cache.


addRepositoryLink

protected void addRepositoryLink(String repositoryId,
                                 AtomLink link)
Adds a repository link to the cache.


getTemplateLink

protected String getTemplateLink(String repositoryId,
                                 String type,
                                 Map<String,Object> parameters)
Gets an URI template from the cache.


loadTemplateLink

protected String loadTemplateLink(String repositoryId,
                                  String type,
                                  Map<String,Object> parameters)
Gets a template link from the cache if it is there or loads it into the cache if it is not there.


addTemplate

protected void addTemplate(String repositoryId,
                           String type,
                           String link)
Adds an URI template to the cache.


convertStatusCode

protected CmisBaseException convertStatusCode(int code,
                                              String message,
                                              String errorContent,
                                              Throwable t)
Converts a HTTP status code into an Exception.


extractException

protected String extractException(String errorContent)

extractErrorMessage

protected String extractErrorMessage(String message,
                                     String errorContent)

is

protected boolean is(String name,
                     AtomElement element)

isStr

protected boolean isStr(String name,
                        AtomElement element)

isInt

protected boolean isInt(String name,
                        AtomElement element)

isNextLink

protected boolean isNextLink(AtomElement element)

createIdObject

protected CmisObjectType createIdObject(String objectId)
Creates a CMIS object that only contains an id in the property list.


parse

protected <T extends AtomBase> T parse(InputStream stream,
                                       Class<T> clazz)
Parses an input stream.


read

protected HttpUtils.Response read(UrlBuilder url)
Performs a GET on an URL, checks the response code and returns the result.


post

protected HttpUtils.Response post(UrlBuilder url,
                                  String contentType,
                                  HttpUtils.Output writer)
Performs a POST on an URL, checks the response code and returns the result.


put

protected HttpUtils.Response put(UrlBuilder url,
                                 String contentType,
                                 HttpUtils.Output writer)
Performs a PUT on an URL, checks the response code and returns the result.


put

protected HttpUtils.Response put(UrlBuilder url,
                                 String contentType,
                                 Map<String,String> headers,
                                 HttpUtils.Output writer)
Performs a PUT on an URL, checks the response code and returns the result.


delete

protected void delete(UrlBuilder url)
Performs a DELETE on an URL, checks the response code and returns the result.


isAclMergeRequired

protected boolean isAclMergeRequired(Acl addAces,
                                     Acl removeAces)
Checks if at least one ACE list is not empty.


mergeAcls

protected Acl mergeAcls(Acl originalAces,
                        Acl addAces,
                        Acl removeAces)
Merges the new ACL from original, add and remove ACEs lists.


getRepositoriesInternal

protected List<RepositoryInfo> getRepositoriesInternal(String repositoryId)
Retrieves the Service Document from the server and caches the repository info objects, collections, links, URI templates, etc.


getObjectInternal

protected ObjectData getObjectInternal(String repositoryId,
                                       AbstractAtomPubService.IdentifierType idOrPath,
                                       String objectIdOrPath,
                                       ReturnVersion returnVersion,
                                       String filter,
                                       Boolean includeAllowableActions,
                                       IncludeRelationships includeRelationships,
                                       String renditionFilter,
                                       Boolean includePolicyIds,
                                       Boolean includeAcl,
                                       ExtensionsData extension)
Retrieves an object from the server and caches the links.


getTypeDefinitionInternal

protected TypeDefinition getTypeDefinitionInternal(String repositoryId,
                                                   String typeId)
Retrieves a type definition.


updateAcl

protected AtomAcl updateAcl(String repositoryId,
                            String objectId,
                            Acl acl,
                            AclPropagation aclPropagation)
Updates the ACL of an object.



Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.