public abstract class HypermediaJSONMessageBodyWriter extends GenericService implements atg.servlet.StateMessageBodyWriter<org.json.JSONObject>
Modifier and Type | Class and Description |
---|---|
protected class |
HypermediaJSONMessageBodyWriter.EmbeddedResourceFilterConfig
Utility inner class to help process embedded resource model filtering context.
|
static class |
HypermediaJSONMessageBodyWriter.MediaKey
Enum of possible Media field types
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected atg.service.jaxrs.JSONService |
mJsonService
property: mJsonService
|
protected RelationsRegistry |
mRelationsRegistry
property: mRelationsRegistry
|
protected atg.service.jaxrs.ResourceLookupService |
mResourceLookupService
Resource lookup service that allows us to invoke a member uri directly
|
protected atg.security.OPSSCipherSigningService |
mSigningService
The signing service used to create a signing key for state data.
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
HypermediaJSONMessageBodyWriter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addAdditionalState(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pAdditionalStateJSON)
Adds the given additional state JSON to the overall response JSON.
|
protected void |
addEmbeddedResources(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pEmbeddedResourcesJSON)
Adds the given embedded resources JSON object to the overall response JSON.
|
protected void |
addEmbeddedSelfLinks(java.util.List<java.lang.String> pUris,
org.json.JSONArray pEmbeddedArray)
Adds self links for 'expand=false' members where only the self link is added to the response.
|
protected void |
addLinks(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pLinksJSON)
Add the given links JSON object to the overall response JSON.
|
protected void |
addMembers(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pMembersJSON)
Adds the given members JSON object to the overall response JSON object.
|
protected void |
addProperties(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pPropertiesJSON)
Adds the given properties JSON to the overall response JSON
|
protected void |
addState(org.json.JSONObject pResponseJSON,
RepresentationModel pModel,
org.json.JSONObject pStateJSON)
Adds the given state JSON to the overall response JSON.
|
protected org.json.JSONObject |
convertModelToJson(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
Method to convert a model to json.
|
protected org.json.JSONObject |
convertToMediaType(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
This method reads the Representation Model object and responsible for
converting the object into the json response.
|
atg.service.payloadschema.filter.FilteringManager |
getFilteringManager()
Gets the filtering manager
|
atg.service.jaxrs.JSONService |
getJSONService()
Returns the JSONService
|
protected java.lang.String |
getMediaKeyName(HypermediaJSONMessageBodyWriter.MediaKey pMediaKey)
Gets the media specific field name to use for the given media field type key
|
atg.service.payloadschema.filter.OutputProducer |
getOutputProducer()
Returns a JSON output producer to be used to produce JSON
representations of objects whose state is to be written in
message body.
|
RelationsRegistry |
getRelationsRegistry()
Returns the RelationsRegistry
|
atg.service.jaxrs.ResourceLookupService |
getResourceLookupService()
Returns the resource lookup service that allows us to invoke a member uri directly
|
atg.security.OPSSCipherSigningService |
getSigningService()
Returns the signing service used to create a signing key for state data.
|
long |
getSize(java.lang.Object pObject,
java.lang.Class<?> pType,
java.lang.reflect.Type pGenericType,
java.lang.annotation.Annotation[] pAnnotations,
MediaType pMediaType)
get the size of the returned data
|
protected org.json.JSONArray |
handleEmbeddedResourceModels(RepresentationModel pParentModel,
java.lang.String pRel,
java.util.List<RepresentationModel> pModels,
atg.service.payloadschema.filter.FilteringContext pParentFilteringContext)
Method to create a JSON array for the given embedded resource models and relation name.
|
protected org.json.JSONObject |
handleEmbeddedResources(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
Construct JSON output for the embedded resources in the representation model.
|
protected org.json.JSONArray |
handleEmbeddedResourceUris(java.lang.String pRel,
java.util.List<java.lang.String> pUris,
atg.service.payloadschema.filter.FilteringContext pParentFilteringContext,
boolean pCrossRegistryUris)
Method to create a JSON array for the given embedded resource uris and relation name.
|
protected org.json.JSONObject |
handleLinks(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
Method to generate a JSON object for the links in the given representation model.
|
protected org.json.JSONObject |
handleMembers(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
Method to create a JSON object for the members of a collection resource by processing the given representation model.
|
protected RepresentationModel |
handleResponseURIPath(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
A response uri was set so we need to invoke a GET of that uri to get the model we want to build our response on.
|
protected org.json.JSONObject |
handleState(RepresentationModel pModel,
atg.service.payloadschema.filter.FilteringContext pFilteringContext)
Method to generate a JSON object for the state within the given representation model.
|
boolean |
isWriteable(java.lang.Class<?> pType,
java.lang.reflect.Type pGenericType,
java.lang.annotation.Annotation[] pAnnotations,
MediaType pMediaType)
Checks to see if this provider can write the given type.
|
void |
setFilteringManager(atg.service.payloadschema.filter.FilteringManager pFilteringManager)
Sets the filtering manager
|
void |
setJSONService(atg.service.jaxrs.JSONService pJsonService)
Sets the JSONService
|
void |
setRelationsRegistry(RelationsRegistry pRelationsRegistry)
Set the RelationsRegistry
|
void |
setResourceLookupService(atg.service.jaxrs.ResourceLookupService pResourceLookupService)
Set the resource lookup service that allows us to invoke a member uri directly
|
void |
setSigningService(atg.security.OPSSCipherSigningService pSigningService)
Sets the signing service used to create a signing key for state data.
|
void |
writeState(java.util.Map<java.lang.String,org.json.JSONObject> pKeyToStateString) |
void |
writeTo(java.lang.Object pObject,
java.lang.Class<?> pType,
java.lang.reflect.Type pGenericType,
java.lang.annotation.Annotation[] pAnnotations,
MediaType pMediaType,
<any> pHttpHeaders,
java.io.OutputStream pEntityStream) |
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toString
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static final java.lang.String CLASS_VERSION
protected atg.service.jaxrs.JSONService mJsonService
protected RelationsRegistry mRelationsRegistry
protected atg.service.jaxrs.ResourceLookupService mResourceLookupService
protected atg.security.OPSSCipherSigningService mSigningService
public void setJSONService(atg.service.jaxrs.JSONService pJsonService)
pJsonService
- the service to convert the object to jsonpublic atg.service.jaxrs.JSONService getJSONService()
public RelationsRegistry getRelationsRegistry()
public void setRelationsRegistry(RelationsRegistry pRelationsRegistry)
pRelationsRegistry
- the registry containing the relation name definitionpublic atg.service.payloadschema.filter.FilteringManager getFilteringManager()
public void setFilteringManager(atg.service.payloadschema.filter.FilteringManager pFilteringManager)
pFilteringManager
- new filtering managerpublic atg.service.jaxrs.ResourceLookupService getResourceLookupService()
public void setResourceLookupService(atg.service.jaxrs.ResourceLookupService pResourceLookupService)
pResourceLookupService
- resource lookup service that allows us to invoke a member uri directlypublic atg.security.OPSSCipherSigningService getSigningService()
public void setSigningService(atg.security.OPSSCipherSigningService pSigningService)
pSigningService
- the signing service.protected java.lang.String getMediaKeyName(HypermediaJSONMessageBodyWriter.MediaKey pMediaKey)
pMediaKey
- Media field type keyprotected org.json.JSONObject convertToMediaType(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
_links
and embedded resources are included under property
_embedded
.pModel
- the java object containing the response returned by endpoint.pFilteringContext
- context data for current filtering operationorg.json.JSONException
- if some property is not able to inserted into the json responseprotected org.json.JSONObject handleState(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
pModel
- Representation model with state to processpFilteringContext
- Filtering context to apply to the stateorg.json.JSONException
protected org.json.JSONObject handleLinks(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
pModel
- Representation model with the linkspFilteringContext
- Filtering context to use for filtering links in the responseorg.json.JSONException
protected org.json.JSONObject handleEmbeddedResources(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
pModel
- the representation model.pFilteringContext
- context data for current filtering operationorg.json.JSONException
- should a error happen during processing.protected org.json.JSONArray handleEmbeddedResourceUris(java.lang.String pRel, java.util.List<java.lang.String> pUris, atg.service.payloadschema.filter.FilteringContext pParentFilteringContext, boolean pCrossRegistryUris) throws org.json.JSONException
pRel
- Relation name for the embedded resourcespUris
- List of String embedded resource uris to processpParentFilteringContext
- Filtering context of the parent resourcepCrossRegistryUris
- true if pUris may include a uri for a registry not currently in contextorg.json.JSONException
protected org.json.JSONArray handleEmbeddedResourceModels(RepresentationModel pParentModel, java.lang.String pRel, java.util.List<RepresentationModel> pModels, atg.service.payloadschema.filter.FilteringContext pParentFilteringContext) throws org.json.JSONException
pParentModel
- Parent representation model that is embedding other resourcespRel
- Relation name for the embedded resourcespModels
- List of embeddded representation models to processpParentFilteringContext
- Filtering context of the parent resourceorg.json.JSONException
protected RepresentationModel handleResponseURIPath(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext)
pModel
- original modelpFilteringContext
- filtering context to use for the GETprotected org.json.JSONObject handleMembers(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
pModel
- Representation model to processpFilteringContext
- Filtering context to apply filtering to members as neededorg.json.JSONException
protected void addState(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pStateJSON) throws org.json.JSONException
pResponseJSON
- Overall response JSONpModel
- Representation model that contained the statepStateJSON
- State JSON to addorg.json.JSONException
protected void addAdditionalState(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pAdditionalStateJSON) throws org.json.JSONException
pResponseJSON
- Overall response JSONpModel
- Representation model that contained the statepAdditionalStateJSON
- Additional state JSON to addorg.json.JSONException
protected void addProperties(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pPropertiesJSON) throws org.json.JSONException
pResponseJSON
- Overall response JSONpModel
- Representation model the properties came frompPropertiesJSON
- Properties JSON to addorg.json.JSONException
protected void addLinks(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pLinksJSON) throws org.json.JSONException
pResponseJSON
- Overall JSON objectpModel
- Representation model the links apply topLinksJSON
- Links JSON object to addorg.json.JSONException
protected void addEmbeddedResources(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pEmbeddedResourcesJSON) throws org.json.JSONException
pResponseJSON
- Overall response JSONpModel
- Representation model the embedded resources were inpEmbeddedResourcesJSON
- Embedded resources JSONorg.json.JSONException
protected void addEmbeddedSelfLinks(java.util.List<java.lang.String> pUris, org.json.JSONArray pEmbeddedArray) throws org.json.JSONException
pUris
- String URIs for the embedded resourcespEmbeddedArray
- JSON array to add the self links toorg.json.JSONException
protected void addMembers(org.json.JSONObject pResponseJSON, RepresentationModel pModel, org.json.JSONObject pMembersJSON) throws org.json.JSONException
pResponseJSON
- Overall response JSONpModel
- Representation model the members belong topMembersJSON
- Members jsonorg.json.JSONException
protected org.json.JSONObject convertModelToJson(RepresentationModel pModel, atg.service.payloadschema.filter.FilteringContext pFilteringContext) throws org.json.JSONException
pModel
- RepresentationModel to convertpFilteringContext
- context data for current filtering operationorg.json.JSONException
public long getSize(java.lang.Object pObject, java.lang.Class<?> pType, java.lang.reflect.Type pGenericType, java.lang.annotation.Annotation[] pAnnotations, MediaType pMediaType)
public boolean isWriteable(java.lang.Class<?> pType, java.lang.reflect.Type pGenericType, java.lang.annotation.Annotation[] pAnnotations, MediaType pMediaType)
public void writeTo(java.lang.Object pObject, java.lang.Class<?> pType, java.lang.reflect.Type pGenericType, java.lang.annotation.Annotation[] pAnnotations, MediaType pMediaType, <any> pHttpHeaders, java.io.OutputStream pEntityStream)
This method converts the java object to the HAL specific json response.
public void writeState(java.util.Map<java.lang.String,org.json.JSONObject> pKeyToStateString)
writeState
in interface atg.servlet.StateMessageBodyWriter<org.json.JSONObject>
pKeyToStateString
- key to string representation of state data.public atg.service.payloadschema.filter.OutputProducer getOutputProducer()
getOutputProducer
in interface atg.servlet.StateMessageBodyWriter<org.json.JSONObject>