Package com.jalios.jcms.rest
Class JcmsRestResource
- java.lang.Object
-
- org.restlet.resource.Resource
-
- com.jalios.jcms.rest.JcmsRestResource
-
- All Implemented Interfaces:
MashupConstants,RestConstants
- Direct Known Subclasses:
AbstractAdminRestResource,AdminResource,ChannelNameResource,DataRestResource,DataTypeCollectionResource,DataTypeItemResource,DefaultMemberPreferenceResource,MemberPreferenceResource,NotificationResource,StateResource,WorkflowItemResource,WorkflowsResource,WorkspaceAdminResource
public abstract class JcmsRestResource extends org.restlet.resource.Resource implements RestConstants, MashupConstants
Generic Abstract Restlet Resource for all JCMS OpenAPI resource. It MUST be implemented by all such Resources. It : - provides facilities; - ensures stats are logged ... - formats list results.- Since:
- JCMS-6.0
- Author:
- dissert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJcmsRestResource.DataCollectionWrapper
-
Field Summary
Fields Modifier and Type Field Description protected Channelchannelprotected booleancheckCSRFShould we check CSRF on POST request ?protected org.restlet.Contextcontextprotected org.restlet.data.FormformQueryStringprotected javax.servlet.http.HttpServletRequestj2eeRequestprotected JcmsContextjcmsContextprotected PagerDatapagerDataprotected java.lang.StringqueryStringprotected java.lang.StringxmlEncoding-
Fields inherited from interface com.jalios.jcms.mashup.MashupConstants
DATA_TAG, DATASET_TAG, FIELD_CLASS, FIELD_ENTRY, FIELD_ITEM, FIELD_KEY, FIELD_NAME, FIELD_TAG, FIELD_VALUE, FILE_FIELD, FILE_ID, FILE_MTIME, FILE_SIZE, FILE_TAG, FILE_TICKET, FILESET_TAG, RELATED_TAG
-
Fields inherited from interface com.jalios.jcms.rest.RestConstants
CSRF_HEADER_NAME, HTTP_HEADERS, METHOD_OVERRIDE_HTTP_HEADER, SERVER_REQUEST_HTTP_HEADER_PREFIX, UTS_ADMIN, UTS_ADMIN_CHECK_0, UTS_ADMIN_CHECK_1, UTS_ADMIN_CHECK_2, UTS_ADMIN_INDEX_SNAPSHOT, UTS_ADMIN_MEMBER_PREFERENCES, UTS_ADMIN_MEMBER_PREFERENCES_2, UTS_ADMIN_PLUGINS, UTS_ADMIN_PREFIX, UTS_ADMIN_PROPS_1, UTS_ADMIN_PROPS_2, UTS_ADMIN_PROPS_3, UTS_ADMIN_STATUS, UTS_ALERT, UTS_ALERT_LIST, UTS_ALERT_LIST_LEGACY, UTS_ALERT_WS, UTS_CHANNEL_NAME, UTS_DATA_CHILDREN, UTS_DATA_PARAM, UTS_DATATYPE_ITEM, UTS_DATATYPE_LIST, UTS_DOC, UTS_JSYNC_REQUEST, UTS_LOCK, UTS_MEMBER_ITEM, UTS_MEMBER_PHOTO_UPDATE, UTS_MEMBER_PREFERENCES_2_ITEM, UTS_MEMBER_PREFERENCES_ITEM, UTS_MSG_ENC_OPTIONS_ITEM, UTS_PUSH, UTS_SEARCH, UTS_SEARCH_CAT, UTS_SEARCH_GROUP, UTS_SEARCH_MBR, UTS_SEARCH_WS, UTS_STATE, UTS_UNLOCK, UTS_WHOAMI_ITEM, UTS_WORKFLOWS, UTS_WORKFLOWS_ITEM, UTS_WORKSPACE_ADMIN, UTS_WORKSPACE_ADMIN2
-
-
Constructor Summary
Constructors Constructor Description JcmsRestResource(org.restlet.Context context, org.restlet.data.Request request, org.restlet.data.Response response)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected booleancheckReadRight(Data theData)Check if the given Data may be read by the logged Member.voiddelete()protected voiddoDelete()protected voiddoPost(java.lang.String action, org.restlet.data.Form requestEntityForm)protected voiddoPost(org.restlet.resource.Representation entity)protected voiddoPut(org.restlet.resource.Representation entity)protected voidforward(java.lang.String path)protected voidgenerateErrorRepresentation(java.lang.String errorMessage, java.lang.String applicationErrorCode, org.restlet.data.Status httpStatus, org.restlet.data.Response response)Deprecated.Prefer method with mediatype parameterprotected java.lang.StringgetAtomRepresentation()protected java.lang.StringgetItemXmlRepresentation(java.lang.Object item)protected java.lang.StringgetJSONRepresentation()protected MembergetLoggedMember()PagerDatagetPagerData()Retrieve the PagerData associated to this Resource, if any.protected java.lang.StringgetPlainTextRepresentation()org.restlet.data.MediaTypegetPreferredMediaType()org.restlet.resource.RepresentationgetRepresentation(org.restlet.resource.Variant variant)java.lang.StringgetXmlProlog()protected java.lang.StringgetXmlRepresentation()protected java.lang.StringinsertAfterXml()protected java.lang.StringinsertBeforeXml()voidpost(org.restlet.resource.Representation entity)voidput(org.restlet.resource.Representation entity)protected voidsetCheckCSRF(boolean checkCSRF)Set wether CSRF control must be verified for POST request on this resource or not.voidsetXmlUTF8Encoding()-
Methods inherited from class org.restlet.resource.Resource
allowDelete, allowGet, allowPost, allowPut, generateRef, getContext, getLogger, getPreferredRepresentation, getPreferredVariant, getRequest, getResponse, getVariants, handleDelete, handleGet, handleHead, handleOptions, handlePost, handlePut, init, isNegotiateContent, setContext, setNegotiateContent, setRequest, setResponse
-
-
-
-
Field Detail
-
channel
protected Channel channel
-
j2eeRequest
protected javax.servlet.http.HttpServletRequest j2eeRequest
-
jcmsContext
protected JcmsContext jcmsContext
-
xmlEncoding
protected java.lang.String xmlEncoding
-
pagerData
protected PagerData pagerData
-
queryString
protected java.lang.String queryString
-
formQueryString
protected org.restlet.data.Form formQueryString
-
context
protected org.restlet.Context context
-
checkCSRF
protected boolean checkCSRF
Should we check CSRF on POST request ?
-
-
Method Detail
-
getLoggedMember
protected Member getLoggedMember()
-
forward
protected void forward(java.lang.String path)
-
getXmlProlog
public java.lang.String getXmlProlog()
-
setXmlUTF8Encoding
public void setXmlUTF8Encoding()
-
setCheckCSRF
protected void setCheckCSRF(boolean checkCSRF)
Set wether CSRF control must be verified for POST request on this resource or not.Default behavior is configured with properties :
- Globally for all resources
rest.check-csrf: true|false - Per resources, using type hierarchy;
rest.check-csrf.{class-fqn}: true|false
- Parameters:
checkCSRF- true to require valid CSRF prevention measures on client POST request, false to skip CSRF control- Since:
- jcms-10.0.5 / JCMS-8546
- Globally for all resources
-
getRepresentation
public final org.restlet.resource.Representation getRepresentation(org.restlet.resource.Variant variant)
- Overrides:
getRepresentationin classorg.restlet.resource.Resource
-
getXmlRepresentation
protected java.lang.String getXmlRepresentation()
-
getItemXmlRepresentation
protected java.lang.String getItemXmlRepresentation(java.lang.Object item)
-
insertBeforeXml
protected java.lang.String insertBeforeXml()
-
insertAfterXml
protected java.lang.String insertAfterXml()
-
getPlainTextRepresentation
protected java.lang.String getPlainTextRepresentation()
-
getJSONRepresentation
protected java.lang.String getJSONRepresentation()
-
getAtomRepresentation
protected java.lang.String getAtomRepresentation()
-
generateErrorRepresentation
protected void generateErrorRepresentation(java.lang.String errorMessage, java.lang.String applicationErrorCode, org.restlet.data.Status httpStatus, org.restlet.data.Response response)Deprecated.Prefer method with mediatype parameterGenerate an XML representation of an error response. Prefer method RestUtil.sendDetailedError- Parameters:
errorMessage- the error message.applicationErrorCode- the error code.httpStatus- the HTTP statusresponse- the response
-
post
public final void post(org.restlet.resource.Representation entity)
- Overrides:
postin classorg.restlet.resource.Resource
-
doPost
protected void doPost(org.restlet.resource.Representation entity)
-
doPost
protected void doPost(java.lang.String action, org.restlet.data.Form requestEntityForm)
-
put
public final void put(org.restlet.resource.Representation entity)
- Overrides:
putin classorg.restlet.resource.Resource
-
doPut
protected void doPut(org.restlet.resource.Representation entity)
-
delete
public final void delete()
- Overrides:
deletein classorg.restlet.resource.Resource
-
doDelete
protected void doDelete()
-
checkReadRight
protected boolean checkReadRight(Data theData)
Check if the given Data may be read by the logged Member. For specific types (not Publication, Category, Workspace, Member), the data may be read only by their author or an admin member.- Parameters:
theData- the data- Returns:
- true is the Data can be read by the logged member
-
getPagerData
public PagerData getPagerData()
Retrieve the PagerData associated to this Resource, if any.The pager data instance returned may not contain any data if only one results was returned, in such case, see
DataRestResource.getData().- Returns:
- a PagerData instance or null if channel was not available.
-
getPreferredMediaType
public org.restlet.data.MediaType getPreferredMediaType()
-
-