Class EntityDescriptionManager
- java.lang.Object
-
- org.sakaiproject.entitybroker.rest.EntityDescriptionManager
-
public class EntityDescriptionManager extends Object
This handles all the methods related to generating descriptions for entities, html and xml currently supported- Author:
- Aaron Zeckoski (azeckoski @ gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringACTION_KEY_PREFIXprotected static StringDESCRIBEprotected static StringFAKE_IDprotected static StringSLASH_DESCRIBEprotected static StringXHTML_FOOTERprotected static StringXHTML_HEADERprotected static StringXML_HEADER
-
Constructor Summary
Constructors Modifier Constructor Description protectedEntityDescriptionManager()EntityDescriptionManager(EntityViewAccessProviderManager entityViewAccessProviderManager, HttpServletAccessProviderManager httpServletAccessProviderManager, EntityProviderManager entityProviderManager, EntityPropertiesService entityProperties, EntityBrokerManager entityBrokerManager, EntityProviderMethodStore entityProviderMethodStore)Full constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringdescribeEntity(StringBuilder sb, String prefix, String id, String format, boolean extra, List<Class<? extends EntityProvider>> caps, Locale locale)This is reducing code duplicationvoiddestroy()protected StringgenerateMethodDetails(String methodType, Locale locale)Generates the details listing which shows the response types for a view methodprotected StringgetEntityDescription(String prefix, String descriptionkey, Locale locale)Get the descriptions for an entity OR its capabilities OR custom actionsprotected String[]getFormats(String prefix, boolean output)voidinit()protected StringmakeActionURL(EntityView ev, CustomAction customAction)protected StringmakeArrayIntoString(Object[] array)protected StringmakeCustomActionKeyMethodText(CustomAction customAction)Create text to display for the CA key and methodStringmakeDescribeAll(String format, Locale locale)Generate a description of all entities in the system, this is only available as XML and XHTMLStringmakeDescribeEntity(String prefix, String id, String format, Locale locale)Generate a description of an entity typeprotected StringmakeEntityURL(EntityView ev, String viewType)protected StringmakeFormatsString(String[] formats, String[] extraFormats, Locale locale)protected StringmakeFormatsUrlHtml(String url, String[] formats)protected StringmakeFormatUrlHtml(String url, String format)protected StringmakeFormUrlHtml(String url, String[] formats)protected StringmakeRedirectLink(String redirect, String prefixURL)Turn a redirect template into html for a link if it has no variables in it, otherwise output the text of the template in a span with boldprotected StringmakeResolveType(String typeName, String extra, Locale locale)protected StringreplacePrefix(String outgoingTemplate, String prefix)Replaces the {prefix} value in the template with the actual prefix, allows nulls to pass throughvoidsetEntityBrokerManager(EntityBrokerManager entityBrokerManager)voidsetEntityProperties(EntityPropertiesService entityProperties)voidsetEntityProviderManager(EntityProviderManager entityProviderManager)voidsetEntityProviderMethodStore(EntityProviderMethodStore entityProviderMethodStore)voidsetEntityViewAccessProviderManager(EntityViewAccessProviderManager entityViewAccessProviderManager)voidsetHttpServletAccessProviderManager(HttpServletAccessProviderManager httpServletAccessProviderManager)
-
-
-
Field Detail
-
ACTION_KEY_PREFIX
protected static final String ACTION_KEY_PREFIX
- See Also:
- Constant Field Values
-
DESCRIBE
protected static String DESCRIBE
-
SLASH_DESCRIBE
protected static String SLASH_DESCRIBE
-
FAKE_ID
protected static String FAKE_ID
-
XML_HEADER
protected static final String XML_HEADER
- See Also:
- Constant Field Values
-
XHTML_HEADER
protected static final String XHTML_HEADER
- See Also:
- Constant Field Values
-
XHTML_FOOTER
protected static final String XHTML_FOOTER
-
-
Constructor Detail
-
EntityDescriptionManager
protected EntityDescriptionManager()
-
EntityDescriptionManager
public EntityDescriptionManager(EntityViewAccessProviderManager entityViewAccessProviderManager, HttpServletAccessProviderManager httpServletAccessProviderManager, EntityProviderManager entityProviderManager, EntityPropertiesService entityProperties, EntityBrokerManager entityBrokerManager, EntityProviderMethodStore entityProviderMethodStore)
Full constructor- Parameters:
entityViewAccessProviderManager-httpServletAccessProviderManager-entityProviderManager-entityProperties-entityBrokerManager-entityProviderMethodStore-
-
-
Method Detail
-
init
public void init()
-
destroy
public void destroy()
-
setEntityViewAccessProviderManager
public void setEntityViewAccessProviderManager(EntityViewAccessProviderManager entityViewAccessProviderManager)
-
setHttpServletAccessProviderManager
public void setHttpServletAccessProviderManager(HttpServletAccessProviderManager httpServletAccessProviderManager)
-
setEntityProviderManager
public void setEntityProviderManager(EntityProviderManager entityProviderManager)
-
setEntityProperties
public void setEntityProperties(EntityPropertiesService entityProperties)
-
setEntityBrokerManager
public void setEntityBrokerManager(EntityBrokerManager entityBrokerManager)
-
setEntityProviderMethodStore
public void setEntityProviderMethodStore(EntityProviderMethodStore entityProviderMethodStore)
-
makeDescribeAll
public String makeDescribeAll(String format, Locale locale)
Generate a description of all entities in the system, this is only available as XML and XHTML- Parameters:
format- XML or HTML (default is HTML)locale- the locale to use for any translations- Returns:
- the description string for all known entities
-
makeDescribeEntity
public String makeDescribeEntity(String prefix, String id, String format, Locale locale)
Generate a description of an entity type- Parameters:
prefix- an entity prefixid- the entity id to use for generating URLsformat- a format to output, HTML and XML supportedlocale- the locale to use for translations- Returns:
- the description string
- Throws:
IllegalArgumentException- if the entity does not exist
-
describeEntity
protected String describeEntity(StringBuilder sb, String prefix, String id, String format, boolean extra, List<Class<? extends EntityProvider>> caps, Locale locale)
This is reducing code duplication- Parameters:
sb-prefix-id-format-extra-caps-locale- used for translations- Returns:
- the entity description
-
generateMethodDetails
protected String generateMethodDetails(String methodType, Locale locale)
Generates the details listing which shows the response types for a view method- Parameters:
methodType- the view method (new, show, list, delete, edit)locale- the locale- Returns:
- the html string to place on the description page
-
replacePrefix
protected String replacePrefix(String outgoingTemplate, String prefix)
Replaces the {prefix} value in the template with the actual prefix, allows nulls to pass through
-
makeRedirectLink
protected String makeRedirectLink(String redirect, String prefixURL)
Turn a redirect template into html for a link if it has no variables in it, otherwise output the text of the template in a span with bold
-
makeActionURL
protected String makeActionURL(EntityView ev, CustomAction customAction)
- Parameters:
ev- the entity viewcustomAction- the custom action- Returns:
- a URL for triggering the custom action (without http://server/direct)
-
makeEntityURL
protected String makeEntityURL(EntityView ev, String viewType)
- Parameters:
ev- entity viewviewType- the type of view- Returns:
- a URL for triggering the entity action (without http://server/direct)
-
makeCustomActionKeyMethodText
protected String makeCustomActionKeyMethodText(CustomAction customAction)
Create text to display for the CA key and method- Parameters:
customAction-- Returns:
-
getFormats
protected String[] getFormats(String prefix, boolean output)
- Returns:
- all the format extensions handled by this, null if none handled, empty if all
-
makeFormatsString
protected String makeFormatsString(String[] formats, String[] extraFormats, Locale locale)
-
getEntityDescription
protected String getEntityDescription(String prefix, String descriptionkey, Locale locale)
Get the descriptions for an entity OR its capabilities OR custom actions- Parameters:
prefix- an entity prefixdescriptionkey- (optional) the key (simplename for capability, action.actionkey for actions)locale- the Locale to use for translations- Returns:
- the description (may be blank) OR null if there is none
-
-