org.sakaiproject.entitybroker.rest
Class EntityDescriptionManager

java.lang.Object
  extended by 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
protected static String ACTION_KEY_PREFIX
           
protected static String DESCRIBE
           
protected static String FAKE_ID
           
protected static String SLASH_DESCRIBE
           
protected static String XHTML_FOOTER
           
protected static String XHTML_HEADER
           
protected static String XML_HEADER
           
 
Constructor Summary
protected EntityDescriptionManager()
           
  EntityDescriptionManager(EntityViewAccessProviderManager entityViewAccessProviderManager, HttpServletAccessProviderManager httpServletAccessProviderManager, EntityProviderManager entityProviderManager, EntityPropertiesService entityProperties, EntityBrokerManager entityBrokerManager, EntityProviderMethodStore entityProviderMethodStore)
          Full constructor
 
Method Summary
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
 void destroy()
           
protected  String generateMethodDetails(String methodType, Locale locale)
          Generates the details listing which shows the response types for a view method
protected  String getEntityDescription(String prefix, String descriptionkey, Locale locale)
          Get the descriptions for an entity OR its capabilities OR custom actions
protected  String[] getFormats(String prefix, boolean output)
           
 void init()
           
protected  String makeActionURL(EntityView ev, CustomAction customAction)
           
protected  String makeArrayIntoString(Object[] array)
           
protected  String makeCustomActionKeyMethodText(CustomAction customAction)
          Create text to display for the CA key and method
 String makeDescribeAll(String format, Locale locale)
          Generate a description of all entities in the system, this is only available as XML and XHTML
 String makeDescribeEntity(String prefix, String id, String format, Locale locale)
          Generate a description of an entity type
protected  String makeEntityURL(EntityView ev, String viewType)
           
protected  String makeFormatsString(String[] formats, String[] extraFormats, Locale locale)
           
protected  String makeFormatsUrlHtml(String url, String[] formats)
           
protected  String makeFormatUrlHtml(String url, String format)
           
protected  String makeFormUrlHtml(String url, String[] formats)
           
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
protected  String makeResolveType(String typeName, String extra, Locale locale)
           
protected  String replacePrefix(String outgoingTemplate, String prefix)
          Replaces the {prefix} value in the template with the actual prefix, allows nulls to pass through
 void setEntityBrokerManager(EntityBrokerManager entityBrokerManager)
           
 void setEntityProperties(EntityPropertiesService entityProperties)
           
 void setEntityProviderManager(EntityProviderManager entityProviderManager)
           
 void setEntityProviderMethodStore(EntityProviderMethodStore entityProviderMethodStore)
           
 void setEntityViewAccessProviderManager(EntityViewAccessProviderManager entityViewAccessProviderManager)
           
 void setHttpServletAccessProviderManager(HttpServletAccessProviderManager httpServletAccessProviderManager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 prefix
id - the entity id to use for generating URLs
format - a format to output, HTML and XML supported
locale - 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


makeResolveType

protected String makeResolveType(String typeName,
                                 String extra,
                                 Locale locale)

makeActionURL

protected String makeActionURL(EntityView ev,
                               CustomAction customAction)
Parameters:
ev - the entity view
customAction - 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 view
viewType - 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

makeFormatsUrlHtml

protected String makeFormatsUrlHtml(String url,
                                    String[] formats)

makeFormatsString

protected String makeFormatsString(String[] formats,
                                   String[] extraFormats,
                                   Locale locale)

makeFormUrlHtml

protected String makeFormUrlHtml(String url,
                                 String[] formats)

makeFormatUrlHtml

protected String makeFormatUrlHtml(String url,
                                   String format)

makeArrayIntoString

protected String makeArrayIntoString(Object[] array)

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 prefix
descriptionkey - (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


Copyright © 2007-2013 Sakai Project. All Rights Reserved.