com.sage.orion.sdata.servlet
Class SDataResponseEntry

java.lang.Object
  extended by com.sage.orion.sdata.servlet.SDataResponseEntry
Direct Known Subclasses:
ConnectionResponseEntry, ResponseEntry

public class SDataResponseEntry
extends java.lang.Object

An Atom Entry in an SData response. This has various properties and capabilities appropriate to returning a response.


Field Summary
static java.lang.String AUTHOR_NAME
          A simple Author because the ATOM specification requires something.
protected static java.lang.String AUTHOR_TAG
           
protected static java.lang.String EDIT_RELATIONSHIP
           
protected static java.lang.String ENTRY_TAG
           
protected static java.lang.String FEED_TAG
           
protected static java.lang.String FIRST_RELATIONSHIP
           
protected static java.lang.String HREF_ATTRIBUTE
           
protected static java.lang.String ID_TAG
           
protected static java.lang.String LAST_RELATIONSHIP
           
protected static java.lang.String LINK_TAG
           
protected static java.lang.String MIME_ATOM_XML_ENTRY
           
protected static java.lang.String MIME_ATOM_XML_FEED
           
protected static java.lang.String MIME_XML_XSD
           
protected static java.lang.String NEXT_RELATIONSHIP
           
protected static java.lang.String PREV_RELATIONSHIP
           
protected static java.lang.String RELATIONSHIP_ATTRIBUTE
           
protected static java.lang.String SELF_RELATIONSHIP
           
protected static java.lang.String TITLE_ATTRIBUTE
           
protected static java.lang.String TITLE_EDIT
           
protected static java.lang.String TITLE_FIRST
           
protected static java.lang.String TITLE_LAST
           
protected static java.lang.String TITLE_NEXT
           
protected static java.lang.String TITLE_PREV
           
protected static java.lang.String TITLE_SELF
           
protected static java.lang.String TYPE_ATTRIBUTE
           
protected static java.lang.String UPDATED_TAG
           
 
Constructor Summary
SDataResponseEntry(SDataResourceElement body, java.lang.String eTag, java.lang.String id)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String key, java.lang.String eTag, boolean editable)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String key, java.lang.String eTag, boolean editable, java.util.List<SDataDiagnosis> errors)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String key, java.lang.String eTag, boolean editable, java.util.List<SDataDiagnosis> errors, SDataSchema schema, java.lang.String title)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String key, java.lang.String eTag, boolean editable, java.util.List<SDataDiagnosis> errors, SDataSchema schema, java.lang.String title, Category category)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String key, java.lang.String eTag, boolean editable, java.util.List<SDataDiagnosis> errors, SDataSchema schema, java.lang.String title, Category category, boolean canPost, boolean hasService)
          construct a response entry
SDataResponseEntry(SDataResourceElement body, java.lang.String eTag, java.lang.String id, java.util.List<SDataDiagnosis> errors)
          construct a response entry
 
Method Summary
protected  void addCategory(org.w3c.dom.Element atomElement)
          Add the category information to the given DOM element (feed or entry)
protected static void addNamespaces(org.w3c.dom.Element parent)
          Add the namespace attributes that are common to SDataEntry and SDataFeed
protected  void addSchemaEtcLinks(org.w3c.dom.Element parent, java.lang.String urlBase, boolean canPost, boolean hasService)
          Add the schema, post, service and template links to the given feed or entry element
protected static void appendIfNotNull(org.w3c.dom.Element entry, org.w3c.dom.Element child)
          Utility to append a child only if it is defined
protected  org.w3c.dom.Element createElement(org.w3c.dom.Document doc, boolean isDocumentElement, java.lang.String resourcesURL, java.util.List<SDataDiagnosis> errors)
          create an XML Element representing this Entry.
protected  org.w3c.dom.Element createElement(org.w3c.dom.Document doc, boolean isDocumentElement, java.lang.String resourcesURL, java.util.List<SDataDiagnosis> errors, java.lang.String typeTag)
          Creates an atom element
protected  void createSchemaLink(java.lang.String urlBase, org.w3c.dom.Element atomElement)
          adds the schema link to the parent provided, complete with actual schema if any
protected static org.w3c.dom.Element getAtomEntryLinkElement(org.w3c.dom.Document document, java.lang.String relationship, java.lang.String title, java.lang.String href)
          Create an Atom entry link element
protected static org.w3c.dom.Element getAtomLinkElement(org.w3c.dom.Document document, java.lang.String type, java.lang.String relationship, java.lang.String title, java.lang.String href)
          Create an Atom link element for the given link-relation entry
protected  java.lang.String getEditLink(java.lang.String id)
          gets the edit link content for the item
protected  java.lang.String getID(java.lang.String resourcesURL)
          Get the ID used for the ID, self and edit links
protected  java.lang.String getKey()
          returns the value that represents the key for the entry.
protected static org.w3c.dom.Element getLinkRelationElement(org.w3c.dom.Document document, java.lang.String relationship, java.lang.String type, java.lang.String title, java.lang.String href)
          Create an Atom link element for the given link-relation entry
 SDataResourceElement getPayload()
          get the payload of the SDataResponseEntry
static SDataResponseEntry newIntermediateEntry(Category category, java.lang.String id, java.lang.String title, java.lang.String content)
          factory to create an intermediate URL entry
 void setPayload(SDataResourceElement payload)
          set the payload of the SDataResponseEntry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TITLE_EDIT

protected static final java.lang.String TITLE_EDIT
See Also:
Constant Field Values

TITLE_SELF

protected static final java.lang.String TITLE_SELF
See Also:
Constant Field Values

TITLE_FIRST

protected static final java.lang.String TITLE_FIRST
See Also:
Constant Field Values

TITLE_LAST

protected static final java.lang.String TITLE_LAST
See Also:
Constant Field Values

TITLE_PREV

protected static final java.lang.String TITLE_PREV
See Also:
Constant Field Values

TITLE_NEXT

protected static final java.lang.String TITLE_NEXT
See Also:
Constant Field Values

MIME_XML_XSD

protected static final java.lang.String MIME_XML_XSD
See Also:
Constant Field Values

MIME_ATOM_XML_FEED

protected static final java.lang.String MIME_ATOM_XML_FEED
See Also:
Constant Field Values

MIME_ATOM_XML_ENTRY

protected static final java.lang.String MIME_ATOM_XML_ENTRY
See Also:
Constant Field Values

SELF_RELATIONSHIP

protected static final java.lang.String SELF_RELATIONSHIP
See Also:
Constant Field Values

EDIT_RELATIONSHIP

protected static final java.lang.String EDIT_RELATIONSHIP
See Also:
Constant Field Values

FIRST_RELATIONSHIP

protected static final java.lang.String FIRST_RELATIONSHIP
See Also:
Constant Field Values

LAST_RELATIONSHIP

protected static final java.lang.String LAST_RELATIONSHIP
See Also:
Constant Field Values

PREV_RELATIONSHIP

protected static final java.lang.String PREV_RELATIONSHIP
See Also:
Constant Field Values

NEXT_RELATIONSHIP

protected static final java.lang.String NEXT_RELATIONSHIP
See Also:
Constant Field Values

LINK_TAG

protected static final java.lang.String LINK_TAG
See Also:
Constant Field Values

RELATIONSHIP_ATTRIBUTE

protected static final java.lang.String RELATIONSHIP_ATTRIBUTE
See Also:
Constant Field Values

TITLE_ATTRIBUTE

protected static final java.lang.String TITLE_ATTRIBUTE
See Also:
Constant Field Values

TYPE_ATTRIBUTE

protected static final java.lang.String TYPE_ATTRIBUTE
See Also:
Constant Field Values

HREF_ATTRIBUTE

protected static final java.lang.String HREF_ATTRIBUTE
See Also:
Constant Field Values

ENTRY_TAG

protected static final java.lang.String ENTRY_TAG
See Also:
Constant Field Values

FEED_TAG

protected static final java.lang.String FEED_TAG
See Also:
Constant Field Values

ID_TAG

protected static final java.lang.String ID_TAG
See Also:
Constant Field Values

AUTHOR_TAG

protected static final java.lang.String AUTHOR_TAG
See Also:
Constant Field Values

UPDATED_TAG

protected static final java.lang.String UPDATED_TAG
See Also:
Constant Field Values

AUTHOR_NAME

public static final java.lang.String AUTHOR_NAME
A simple Author because the ATOM specification requires something.

See Also:
Constant Field Values
Constructor Detail

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String eTag,
                          java.lang.String id)
construct a response entry

Parameters:
body - the body of the entry
eTag - the eTag of the entry or null
id - the id of the entry or null

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String key,
                          java.lang.String eTag,
                          boolean editable)
construct a response entry

Parameters:
body - the body of the entry
key - the key of the entry (used to form links) or null
eTag - the eTag of the entry or null
editable - the entry is or is not editable

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String eTag,
                          java.lang.String id,
                          java.util.List<SDataDiagnosis> errors)
construct a response entry

Parameters:
body - the body of the entry
eTag - the eTag of the entry or null
id - the id of the entry or null
errors - the list of errors

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String key,
                          java.lang.String eTag,
                          boolean editable,
                          java.util.List<SDataDiagnosis> errors)
construct a response entry

Parameters:
body - the body of the entry
key - the key of the entry (used to form links) or null
eTag - the eTag of the entry or null
editable - the entry is or is not editable
errors - the list of errors

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String key,
                          java.lang.String eTag,
                          boolean editable,
                          java.util.List<SDataDiagnosis> errors,
                          SDataSchema schema,
                          java.lang.String title)
construct a response entry

Parameters:
body - the body of the entry
key - the key of the entry (used to form links) or null
eTag - the eTag of the entry or null
editable - the entry is or is not editable
errors - the list of errors
schema - a potential in-lined schema
title - the title for the entry

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String key,
                          java.lang.String eTag,
                          boolean editable,
                          java.util.List<SDataDiagnosis> errors,
                          SDataSchema schema,
                          java.lang.String title,
                          Category category)
construct a response entry

Parameters:
body - the body of the entry
key - the key of the entry (used to form links) or null
eTag - the eTag of the entry or null
editable - the entry is or is not editable
errors - the list of errors
schema - a potential in-lined schema
title - the title for the entry
category - the category of the entry

SDataResponseEntry

public SDataResponseEntry(SDataResourceElement body,
                          java.lang.String key,
                          java.lang.String eTag,
                          boolean editable,
                          java.util.List<SDataDiagnosis> errors,
                          SDataSchema schema,
                          java.lang.String title,
                          Category category,
                          boolean canPost,
                          boolean hasService)
construct a response entry

Parameters:
body - the body of the entry
key - the key of the entry (used to form links) or null
eTag - the eTag of the entry or null
editable - the entry is or is not editable
errors - the list of errors
schema - a potential in-lined schema
title - the title for the entry
category - the category of the entry
canPost - true if and only if the entry supports post (and so the post and template links will be included if the entry is not inside a feed)
hasService - true if and only if the entry supports services (and so the service link will be included if the entry is not inside a feed)
Method Detail

createElement

protected org.w3c.dom.Element createElement(org.w3c.dom.Document doc,
                                            boolean isDocumentElement,
                                            java.lang.String resourcesURL,
                                            java.util.List<SDataDiagnosis> errors)
create an XML Element representing this Entry.

Parameters:
doc - the Document in which to create the element
isDocumentElement - true if this element is the document top level element, in which case it will have the namespace attributes. If false then the namespace attributes should be added to the feed above this element.
resourcesURL - The base URL to be used in creating links, ids etc. This includes all elements up to and including the resource kind but does not include subresources etc.
errors - The list of errors
Returns:
the newly created element

getEditLink

protected java.lang.String getEditLink(java.lang.String id)
gets the edit link content for the item

Parameters:
id - the id of the item, which is generally useful as the base of the link
Returns:
the text of the edit link

getID

protected java.lang.String getID(java.lang.String resourcesURL)
Get the ID used for the ID, self and edit links

Parameters:
resourcesURL - the base resources URL, already encoded for transport

getAtomEntryLinkElement

protected static org.w3c.dom.Element getAtomEntryLinkElement(org.w3c.dom.Document document,
                                                             java.lang.String relationship,
                                                             java.lang.String title,
                                                             java.lang.String href)
Create an Atom entry link element

Parameters:
document - the document to act as container for the element
relationship - the text of the relationship
title - the title of the link
href - the href entry of the link
Returns:
an Element representing the link

getKey

protected java.lang.String getKey()
returns the value that represents the key for the entry. This corresponds to the sdata:key value. It is the opaque value that is passed in quotes inside the resource selector.

This is returned in the form that the application has encoded (e.g. handling of separator characters for multi-part keys); no transport encoding has been performed.

Returns:
the key

newIntermediateEntry

public static SDataResponseEntry newIntermediateEntry(Category category,
                                                      java.lang.String id,
                                                      java.lang.String title,
                                                      java.lang.String content)
factory to create an intermediate URL entry

Parameters:
category - the category of the entry
id - the id of the entry (also used for the self link). This must already be encoded for transport
title - the title for the entry
content - the content of the entry
Returns:
an SDataResponseEntry representing the arguments

getPayload

public SDataResourceElement getPayload()
get the payload of the SDataResponseEntry

Returns:
the payload of the SDataResponseEntry

setPayload

public void setPayload(SDataResourceElement payload)
set the payload of the SDataResponseEntry

Parameters:
payload - the payload of the SDataResponseEntry

appendIfNotNull

protected static void appendIfNotNull(org.w3c.dom.Element entry,
                                      org.w3c.dom.Element child)
Utility to append a child only if it is defined

Parameters:
entry - entry
child - child

getLinkRelationElement

protected static org.w3c.dom.Element getLinkRelationElement(org.w3c.dom.Document document,
                                                            java.lang.String relationship,
                                                            java.lang.String type,
                                                            java.lang.String title,
                                                            java.lang.String href)
Create an Atom link element for the given link-relation entry

Parameters:
document - the document which will own the entry
relationship - the relationship; one of schema, template, post and service
type - the type of the result? depends on relationship
title - title
href - href
Returns:
atom link element

getAtomLinkElement

protected static org.w3c.dom.Element getAtomLinkElement(org.w3c.dom.Document document,
                                                        java.lang.String type,
                                                        java.lang.String relationship,
                                                        java.lang.String title,
                                                        java.lang.String href)
Create an Atom link element for the given link-relation entry

Parameters:
document - the document which will own the entry
relationship - the relationship; one of schema, template, post and service
type - the type of the result? depends on relationship
title - title
href - href
Returns:
atom link element

addSchemaEtcLinks

protected void addSchemaEtcLinks(org.w3c.dom.Element parent,
                                 java.lang.String urlBase,
                                 boolean canPost,
                                 boolean hasService)
Add the schema, post, service and template links to the given feed or entry element

Parameters:
parent - the entry or feed element to which the links are attached
urlBase - the URL that is used as the base text for the links. It should already be in RFC3987 IRI format.
canPost - true if and only if the entry or feed supports post (and so the post and template links are included)
hasService - true if and only if the entry or feed has services (and so the service link is included)

createSchemaLink

protected final void createSchemaLink(java.lang.String urlBase,
                                      org.w3c.dom.Element atomElement)
adds the schema link to the parent provided, complete with actual schema if any

Parameters:
urlBase - the base string to use in forming the href
atomElement - the parent element that is the feed or entry

createElement

protected org.w3c.dom.Element createElement(org.w3c.dom.Document doc,
                                            boolean isDocumentElement,
                                            java.lang.String resourcesURL,
                                            java.util.List<SDataDiagnosis> errors,
                                            java.lang.String typeTag)
Creates an atom element

Parameters:
doc - document
isDocumentElement - whether document is document element
resourcesURL - resources URL
errors - errors
typeTag - type tag ( i.e. feed or entry)
Returns:
atom element of specified type

addNamespaces

protected static final void addNamespaces(org.w3c.dom.Element parent)
Add the namespace attributes that are common to SDataEntry and SDataFeed

Parameters:
parent - the element to which to add the attributes

addCategory

protected final void addCategory(org.w3c.dom.Element atomElement)
Add the category information to the given DOM element (feed or entry)

Parameters:
atomElement - the parent element that is the feed or entry


Copyright © 2011 Sage Software, Inc. All rights reserved.