org.wso2.carbon.registry.app
Class RegistryAdapter

java.lang.Object
  extended by org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
      extended by org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
          extended by org.wso2.carbon.registry.app.RegistryAdapter
All Implemented Interfaces:
org.apache.abdera.protocol.server.CollectionAdapter, org.apache.abdera.protocol.server.CollectionInfo, org.apache.abdera.protocol.server.MediaCollectionAdapter, org.apache.abdera.protocol.server.Transactional

public class RegistryAdapter
extends org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>

This is the component that provides the business logic which runs on the Abdera instance. The Provider will use it's Workspace Manager to determine which Collection Adapter to dispatch a request to. Once an adapter is selected, the Provider will determine what kind of request is being made and will forward the request on to the appropriate Collection Adapter method.

The Registry Adapter is a specialized Collection Adapter designed to expose registry logic within an APP world.


Constructor Summary
RegistryAdapter()
          Default constructor
RegistryAdapter(RegistryResolver resolver, EmbeddedRegistryService embeddedRegistryService)
          Deprecated. 
 
Method Summary
protected  java.lang.String addEntryDetails(org.apache.abdera.protocol.server.RequestContext request, org.apache.abdera.model.Entry entry, org.apache.abdera.i18n.iri.IRI feedIri, Resource entryObj)
          Method to add entry details.
protected  void addFeedDetails(org.apache.abdera.model.Feed feed, org.apache.abdera.protocol.server.RequestContext request)
          Method to add feed details.
protected  java.lang.String addMediaContent(org.apache.abdera.i18n.iri.IRI feedIri, org.apache.abdera.model.Entry entry, Resource entryObj, org.apache.abdera.protocol.server.RequestContext request)
          Method to add media content.
protected  org.apache.abdera.protocol.server.ResponseContext buildGetEntryResponse(org.apache.abdera.protocol.server.RequestContext request, org.apache.abdera.model.Entry entry)
          Method to build a get entry response.
protected  org.apache.abdera.protocol.server.ResponseContext buildGetFeedResponse(org.apache.abdera.model.Feed feed)
          Method to build a get feed response.
 void deleteEntry(java.lang.String resourceName, org.apache.abdera.protocol.server.RequestContext request)
          Method to delete an entry from the collection.
 org.apache.abdera.protocol.server.ResponseContext extensionRequest(org.apache.abdera.protocol.server.RequestContext request)
          Handle anything out of the ordinary Abdera-supported world.
 java.lang.String getAuthor(org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the primary author for an entry.
 java.util.List<org.apache.abdera.model.Person> getAuthors(Resource entry, org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the list of authors for an entry.
 java.lang.Object getContent(Resource entry, org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the resource content.
 java.lang.String getContentType(Resource entry)
          Method to obtain the content type of an entry.
 java.lang.Iterable<Resource> getEntries(org.apache.abdera.protocol.server.RequestContext request)
          Method to get an iterator of entries.
 Resource getEntry(java.lang.String resourceName, org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the resource from the request.
protected  java.lang.String getFeedIriForEntry(Resource entryObj, org.apache.abdera.protocol.server.RequestContext request)
          Generates the feed IRI for the given entry.
 java.lang.String getId(org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the identifier for an entry.
 java.lang.String getId(Resource entry)
          Method to obtain the unique identifier of a resource.
protected  java.lang.String getLink(Resource entryObj, org.apache.abdera.i18n.iri.IRI feedIri, org.apache.abdera.protocol.server.RequestContext requestContext)
          Method to obtain the entry IRI link.
 java.lang.String getMediaName(Resource entry)
          Method to obtain the media name.
 java.io.InputStream getMediaStream(Resource entry)
          Method to obtain an input stream for the given resource.
 java.lang.String getName(Resource entry)
          Method to obtain the name of a resource.
 org.apache.abdera.model.Text getSummary(Resource entry, org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the summary for an entry.
 java.lang.String getTitle(org.apache.abdera.protocol.server.RequestContext request)
          Method to obtain the title for an entry.
 java.lang.String getTitle(Resource entry)
          Method to obtain the title of a resource.
 java.util.Date getUpdated(Resource entry)
          Method to obtain the updated time of a resource.
 boolean isMediaEntry(Resource entry)
          Method to determine whether the given resource is a media entry.
static java.util.Map<java.lang.String,java.lang.String> parseQueryString(java.lang.String query)
          Utility function to parse query string TODO: Isn't there a standard way to do this?
 org.apache.abdera.protocol.server.ResponseContext postEntry(org.apache.abdera.protocol.server.RequestContext request)
          Method to post an entry.
 Resource postEntry(java.lang.String title, org.apache.abdera.i18n.iri.IRI id, java.lang.String summary, java.util.Date updated, java.util.List<org.apache.abdera.model.Person> authors, org.apache.abdera.model.Content content, org.apache.abdera.protocol.server.RequestContext request)
          Method to post an entry to the collection.
 org.apache.abdera.protocol.server.ResponseContext postFeed(org.apache.abdera.protocol.server.RequestContext request)
          Method to post a feed.
 Resource postMedia(javax.activation.MimeType mimeType, java.lang.String slug, java.io.InputStream inputStream, org.apache.abdera.protocol.server.RequestContext request)
          Posts a new media entry.
 org.apache.abdera.protocol.server.ResponseContext putEntry(org.apache.abdera.protocol.server.RequestContext request)
          Method to add an entry to the collection.
 void putEntry(Resource entry, java.lang.String title, java.util.Date updated, java.util.List<org.apache.abdera.model.Person> authors, java.lang.String summary, org.apache.abdera.model.Content content, org.apache.abdera.protocol.server.RequestContext request)
          Method to add an entry to the collection.
 
Methods inherited from class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter
addContent, buildGetMediaResponse, createMediaEntry, createNonMediaEntry, deleteEntry, deleteMedia, deleteMedia, getEntry, getEntryFromCollectionProvider, getFeed, getLink, getLink, getLink, getMedia, getQueryParameters, headEntry, headMedia, postMedia, putMedia, putMedia
 
Methods inherited from class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
asCollectionElement, buildCreateEntryResponse, buildHeadEntryResponse, buildPostMediaEntryResponse, compensate, createErrorResponse, createFeedBase, end, getAccepts, getCategories, getCategoriesInfo, getEntryFromRequest, getHref, getHref, getResourceName, optionsEntry, optionsMedia, setHref, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryAdapter

@Deprecated
public RegistryAdapter(RegistryResolver resolver,
                                  EmbeddedRegistryService embeddedRegistryService)
                throws RegistryException
Deprecated. 

Throws:
RegistryException

RegistryAdapter

public RegistryAdapter()
Default constructor

Method Detail

extensionRequest

public org.apache.abdera.protocol.server.ResponseContext extensionRequest(org.apache.abdera.protocol.server.RequestContext request)
Handle anything out of the ordinary Abdera-supported world.

This method basically acts as a clearing house for all of the Registry-specific URLs that result in special processing, like ...;tags or ...;comments, etc. The resolver will have already parsed the URL and matched it with a particular custom TargetType, so in here we switch control based on the TargetType to a meta data processing routine.

Specified by:
extensionRequest in interface org.apache.abdera.protocol.server.CollectionAdapter
Overrides:
extensionRequest in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Parameters:
request - the RequestContext containing all the relevant info
Returns:
a ResponseContext indicating the disposition of the request

parseQueryString

public static java.util.Map<java.lang.String,java.lang.String> parseQueryString(java.lang.String query)
Utility function to parse query string TODO: Isn't there a standard way to do this?

Parameters:
query - query string to parse
Returns:
a Map of name -> value for each parameter

buildGetEntryResponse

protected org.apache.abdera.protocol.server.ResponseContext buildGetEntryResponse(org.apache.abdera.protocol.server.RequestContext request,
                                                                                  org.apache.abdera.model.Entry entry)
                                                                           throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to build a get entry response.

Overrides:
buildGetEntryResponse in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Parameters:
request - the request context.
entry - the entry
Returns:
the response context.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException

buildGetFeedResponse

protected org.apache.abdera.protocol.server.ResponseContext buildGetFeedResponse(org.apache.abdera.model.Feed feed)
Method to build a get feed response.

Overrides:
buildGetFeedResponse in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Parameters:
feed - the feed.
Returns:
the response context.

postEntry

public org.apache.abdera.protocol.server.ResponseContext postEntry(org.apache.abdera.protocol.server.RequestContext request)
Method to post an entry.

Specified by:
postEntry in interface org.apache.abdera.protocol.server.CollectionAdapter
Overrides:
postEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
request - the request context.
Returns:
the response context.

postFeed

public org.apache.abdera.protocol.server.ResponseContext postFeed(org.apache.abdera.protocol.server.RequestContext request)
Method to post a feed.

Parameters:
request - the request context.
Returns:
the response context.

postEntry

public Resource postEntry(java.lang.String title,
                          org.apache.abdera.i18n.iri.IRI id,
                          java.lang.String summary,
                          java.util.Date updated,
                          java.util.List<org.apache.abdera.model.Person> authors,
                          org.apache.abdera.model.Content content,
                          org.apache.abdera.protocol.server.RequestContext request)
                   throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to post an entry to the collection.

Specified by:
postEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
title - the title of the entry.
updated - the updated time.
authors - the list of authors.
summary - the summary text.
content - the resource content.
request - the request context.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

deleteEntry

public void deleteEntry(java.lang.String resourceName,
                        org.apache.abdera.protocol.server.RequestContext request)
                 throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to delete an entry from the collection.

Specified by:
deleteEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
resourceName - the resource name.
request - the request context.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

isMediaEntry

public boolean isMediaEntry(Resource entry)
                     throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to determine whether the given resource is a media entry.

Overrides:
isMediaEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
Returns:
whether the given resource is a media entry.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getContent

public java.lang.Object getContent(Resource entry,
                                   org.apache.abdera.protocol.server.RequestContext request)
                            throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the resource content.

Specified by:
getContent in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
request - the request context.
Returns:
the resource content object.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException

getLink

protected java.lang.String getLink(Resource entryObj,
                                   org.apache.abdera.i18n.iri.IRI feedIri,
                                   org.apache.abdera.protocol.server.RequestContext requestContext)
                            throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the entry IRI link.

Overrides:
getLink in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entryObj - the entry object.
feedIri - the feed IRI
requestContext - the request context.
Returns:
the entry IRI link.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

addEntryDetails

protected java.lang.String addEntryDetails(org.apache.abdera.protocol.server.RequestContext request,
                                           org.apache.abdera.model.Entry entry,
                                           org.apache.abdera.i18n.iri.IRI feedIri,
                                           Resource entryObj)
                                    throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to add entry details.

Overrides:
addEntryDetails in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the entry.
feedIri - the IRI of the feed.
entryObj - the resource.
request - the request context.
Returns:
the entry IRI link.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

addFeedDetails

protected void addFeedDetails(org.apache.abdera.model.Feed feed,
                              org.apache.abdera.protocol.server.RequestContext request)
                       throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to add feed details.

Overrides:
addFeedDetails in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
feed - the feed.
request - the request context.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getEntries

public java.lang.Iterable<Resource> getEntries(org.apache.abdera.protocol.server.RequestContext request)
                                        throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to get an iterator of entries.

Specified by:
getEntries in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
request - the request context.
Returns:
an iterator of resources.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getEntry

public Resource getEntry(java.lang.String resourceName,
                         org.apache.abdera.protocol.server.RequestContext request)
                  throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the resource from the request.

Specified by:
getEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
resourceName - the resource name.
request - the request.
Returns:
the resource.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getId

public java.lang.String getId(Resource entry)
                       throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the unique identifier of a resource.

Specified by:
getId in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
Returns:
the unique identifier.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getName

public java.lang.String getName(Resource entry)
                         throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the name of a resource.

Specified by:
getName in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
Returns:
the name.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getTitle

public java.lang.String getTitle(Resource entry)
                          throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the title of a resource.

Specified by:
getTitle in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
Returns:
the title.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getUpdated

public java.util.Date getUpdated(Resource entry)
                          throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the updated time of a resource.

Specified by:
getUpdated in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource.
Returns:
the updated time.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

putEntry

public org.apache.abdera.protocol.server.ResponseContext putEntry(org.apache.abdera.protocol.server.RequestContext request)
Method to add an entry to the collection.

Specified by:
putEntry in interface org.apache.abdera.protocol.server.CollectionAdapter
Overrides:
putEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
request - the request context.
Returns:
the response context.

putEntry

public void putEntry(Resource entry,
                     java.lang.String title,
                     java.util.Date updated,
                     java.util.List<org.apache.abdera.model.Person> authors,
                     java.lang.String summary,
                     org.apache.abdera.model.Content content,
                     org.apache.abdera.protocol.server.RequestContext request)
              throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to add an entry to the collection.

Specified by:
putEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource to add.
title - the title of the entry.
updated - the updated time.
authors - the list of authors.
summary - the summary text.
content - the resource content.
request - the request context.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getAuthor

public java.lang.String getAuthor(org.apache.abdera.protocol.server.RequestContext request)
                           throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the primary author for an entry.

Specified by:
getAuthor in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Parameters:
request - the request context.
Returns:
the primary author.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException

getAuthors

public java.util.List<org.apache.abdera.model.Person> getAuthors(Resource entry,
                                                                 org.apache.abdera.protocol.server.RequestContext request)
                                                          throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the list of authors for an entry.

Overrides:
getAuthors in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource entry.
request - the request context.
Returns:
the list of authors.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getId

public java.lang.String getId(org.apache.abdera.protocol.server.RequestContext request)
Method to obtain the identifier for an entry.

Specified by:
getId in class org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter
Parameters:
request - the request context.
Returns:
the identifier.

getTitle

public java.lang.String getTitle(org.apache.abdera.protocol.server.RequestContext request)
Method to obtain the title for an entry.

Parameters:
request - the request context.
Returns:
the title.

getSummary

public org.apache.abdera.model.Text getSummary(Resource entry,
                                               org.apache.abdera.protocol.server.RequestContext request)
                                        throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the summary for an entry.

Overrides:
getSummary in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource entry.
request - the request context.
Returns:
the summary text.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

postMedia

public Resource postMedia(javax.activation.MimeType mimeType,
                          java.lang.String slug,
                          java.io.InputStream inputStream,
                          org.apache.abdera.protocol.server.RequestContext request)
                   throws org.apache.abdera.protocol.server.context.ResponseContextException
Posts a new media entry.

Overrides:
postMedia in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
mimeType - the MIME type of the content.
slug - the slug as a String.
inputStream - the content stream.
request - the request context.
Returns:
the generated media object.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getContentType

public java.lang.String getContentType(Resource entry)
Method to obtain the content type of an entry.

Overrides:
getContentType in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the entry.
Returns:
the content type.

getMediaName

public java.lang.String getMediaName(Resource entry)
                              throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain the media name.

Overrides:
getMediaName in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource (media entry).
Returns:
the media name.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

addMediaContent

protected java.lang.String addMediaContent(org.apache.abdera.i18n.iri.IRI feedIri,
                                           org.apache.abdera.model.Entry entry,
                                           Resource entryObj,
                                           org.apache.abdera.protocol.server.RequestContext request)
                                    throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to add media content.

Overrides:
addMediaContent in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
feedIri - the feed IRI.
entry - the entry.
entryObj - the resource object.
request - the request context.
Returns:
the added media IRI.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException

getMediaStream

public java.io.InputStream getMediaStream(Resource entry)
                                   throws org.apache.abdera.protocol.server.context.ResponseContextException
Method to obtain an input stream for the given resource.

Overrides:
getMediaStream in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entry - the resource entry.
Returns:
the resource content as a stream.
Throws:
org.apache.abdera.protocol.server.context.ResponseContextException - if the operation failed.

getFeedIriForEntry

protected java.lang.String getFeedIriForEntry(Resource entryObj,
                                              org.apache.abdera.protocol.server.RequestContext request)
Generates the feed IRI for the given entry.

Overrides:
getFeedIriForEntry in class org.apache.abdera.protocol.server.impl.AbstractEntityCollectionAdapter<Resource>
Parameters:
entryObj - the entry object.
request - the request context.
Returns:
the feed IRI.


Copyright © 2011 WSO2 Inc. All Rights Reserved.