Class RestDocData
java.lang.Object
org.opencastproject.util.doc.DocData
org.opencastproject.runtimeinfo.rest.RestDocData
This is the document model class which holds the data about a set of rest endpoints.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<RestEndpointHolderData> List of RestEndpointHolderData which each stores a group of endpoints.static final StringRegular expression used to count the number of path parameters in a path.Fields inherited from class org.opencastproject.util.doc.DocData
meta, notes, TEMPLATE_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionRestDocData(String name, String title, String url, String[] notes) Create the base data object for creating REST documentation. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEndpoint(RestQuery restQuery, Class<?> returnType, javax.ws.rs.Produces produces, String httpMethodString, javax.ws.rs.Path path) Add an endpoint to the Rest documentation.Gets the path to the default template (a .xhtml file).static booleanisValidPath(String path) Validates paths: VALID: /sample , /sample/{thing} , /{my}/{path}.xml , /my/fancy_path/is/{awesome}.voidsetAbstract(String abstractText) Creates an abstract section which is displayed at the top of the documentation page.toMap()Verify the integrity of this object.toString()Returns a string representation of this object.Methods inherited from class org.opencastproject.util.doc.DocData
addNote, getMeta, getMetaData, getNotes, isValidName
-
Field Details
-
PATH_PARAM_COUNTING_REGEX
Regular expression used to count the number of path parameters in a path.- See Also:
-
holders
List of RestEndpointHolderData which each stores a group of endpoints. Currently there are 2 groups, READ group and WRITE group.
-
-
Constructor Details
-
RestDocData
public RestDocData(String name, String title, String url, String[] notes) throws IllegalArgumentException Create the base data object for creating REST documentation.- Parameters:
name- the name of the set of rest endpoints (must be alphanumeric (includes _) and no spaces or special chars)title- [OPTIONAL] the title of the documentationurl- this is the absolute base URL for this endpoint, do not include the trailing slash (e.g. /workflow)notes- [OPTIONAL] an array of notes to add into the end of the documentation- Throws:
IllegalArgumentException- if the url is null or empty
-
-
Method Details
-
toMap
Verify the integrity of this object. If its data is verified to be okay, it return a map representation of this RestDocData object.- Overrides:
toMapin classDocData- Returns:
- a map representation of this RestDocData object if this object passes the verification
- Throws:
IllegalStateException- if any path parameter is not present in the endpoint's path
-
getDefaultTemplatePath
Gets the path to the default template (a .xhtml file).- Overrides:
getDefaultTemplatePathin classDocData- Returns:
- the path to the default template file
-
toString
Returns a string representation of this object. -
setAbstract
Creates an abstract section which is displayed at the top of the documentation page.- Parameters:
abstractText- any text to place at the top of the document, can be html markup but must be valid
-
isValidPath
Validates paths: VALID: /sample , /sample/{thing} , /{my}/{path}.xml , /my/fancy_path/is/{awesome}.{FORMAT} INVALID: sample, /sample/, /sa#$%mple/path- Parameters:
path- the path value to check- Returns:
- true if this path is valid, false otherwise
-
addEndpoint
public void addEndpoint(RestQuery restQuery, Class<?> returnType, javax.ws.rs.Produces produces, String httpMethodString, javax.ws.rs.Path path) Add an endpoint to the Rest documentation.- Parameters:
restQuery- the RestQuery annotation type storing information of an endpointreturnType- the return type for this endpoint. If this isXmlRootElementorXmlRootElement, the XML schema for the class will be made available to clientsproduces- the return type(s) of this endpoint, values should be constants from javax.ws.rs.core.MediaType or ExtendedMediaType (org.opencastproject.util.doc.rest.ExtendedMediaType).httpMethodString- the HTTP method of this endpoint (e.g. GET, POST)path- the path of this endpoint
-