org.wso2.carbon.registry.core.jdbc.handlers
Class UIEnabledHandler

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.handlers.Handler
      extended by org.wso2.carbon.registry.core.jdbc.handlers.UIEnabledHandler
Direct Known Subclasses:
XSLTBasedUIEnabledHandler

public abstract class UIEnabledHandler
extends Handler

Base class for handler implementations which generate custom UIs. There are three main categories of custom UIs. Those are:

Browse: Displays the resource contents in read-only mode. Edit: Provides controls for editing the contents of an existing resource. New: Provides controls for creating a new resource.

Handler may provide any number of UIs under above three categories. For example handler may provide two UIs to browse the contents of an XML file. Handler implementations should provide the UI key and descriptive name for the UI for each of the UIs there are generating.

Edit and New UIs should have an associated EditProcessor implementation to convert the UI inputs to resource content.


Constructor Summary
UIEnabledHandler()
           
 
Method Summary
 Resource get(RequestContext requestContext)
          Implementation of the Handler.get(org.wso2.carbon.registry.core.jdbc.handlers.RequestContext) method of the Handler class.
 Resource getBrowseView(String browseViewKey, RequestContext requestContext)
          Implementations of this method should generate a HTML UI for rendering the resource content and set it as the content of the returned resource.
abstract  String[] getBrowseViews()
          Implementations have to implement this, if they provide more than one browse view.
 String getDefaultBrowseView()
          Among the multiple views that a handler may generate, one view is identified as the default view, which is used to render the contents, if UI is not specified.
 String getDefaultEditView()
          Among the multiple views that a handler may generate, one view is identified as the default view, which is used to edit the contents, if UI is not specified.
 String getDefaultNewView()
          Among the multiple views that a handler may generate, one view is identified as the default view, which is used to render the new resource creation UI, if UI is not specified.
 Resource getEditView(String editViewKey, RequestContext requestContext)
          Implementations of this method should generate a HTML UI for editing the resource content and set it as the content of the returned resource.
abstract  String[] getEditViews()
          Implementations have to implement this, if they provide more than edit browse view.
 Resource getNewView(String newViewKey, RequestContext requestContext)
          Implementations of this method should generate a HTML UI for creating a new resource content and set it as the content of the returned resource.
 String[] getNewViews()
          Implementations have to implement this, if they provide more than one new view.
 Resource getRawResource(RequestContext requestContext)
          Returns a Resource instance specified in the requestContext.
protected  void setDefaultBrowseView(String viewName)
          Method to set the default browse view.
protected  void setDefaultEditView(String viewName)
          Method to set the default edit view.
protected  void setDefaultNewView(String viewName)
          Method to set the default new view.
 
Methods inherited from class org.wso2.carbon.registry.core.jdbc.handlers.Handler
addAssociation, addComment, applyTag, copy, createLink, createVersion, delete, dump, dumpLite, editComment, equals, executeQuery, getAllAssociations, getAssociations, getAverageRating, getComments, getRating, getRegistryContext, getResourcePathsWithTag, getTags, getVersions, hashCode, importChild, importResource, invokeAspect, move, put, putChild, rateResource, removeAssociation, removeComment, removeLink, removeTag, rename, resourceExists, restore, restoreVersion, searchContent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIEnabledHandler

public UIEnabledHandler()
Method Detail

get

public Resource get(RequestContext requestContext)
             throws RegistryException
Implementation of the Handler.get(org.wso2.carbon.registry.core.jdbc.handlers.RequestContext) method of the Handler class. UIEnabledHandler implementations should not implement (override) this method. Instead, they should implement getBrowseView(java.lang.String, org.wso2.carbon.registry.core.jdbc.handlers.RequestContext), getEditView(java.lang.String, org.wso2.carbon.registry.core.jdbc.handlers.RequestContext) and getNewView(java.lang.String, org.wso2.carbon.registry.core.jdbc.handlers.RequestContext) methods to generate corresponding UIs.

Overrides:
get in class Handler
Parameters:
requestContext - Details of the request.
Returns:
If valid custom UI is specified in the resource path, this will return a Resource instance with content filled as a HTML UI that can be rendered. If not, this will return a Resource instance with raw content for resources and child list for collections.
Throws:
RegistryException

getRawResource

public Resource getRawResource(RequestContext requestContext)
                        throws RegistryException
Returns a Resource instance specified in the requestContext. Resource is set with raw resource content. UIEnabledHandler implementations may override this method to provide alternative contents for the raw resource.

Parameters:
requestContext - Request details.
Returns:
Resource instance.
Throws:
RegistryException - if an error occurs while getting the raw resource.

getBrowseViews

public abstract String[] getBrowseViews()
Implementations have to implement this, if they provide more than one browse view.

Implementations can provide the identification key and a descriptive name for all browse UIs they provide by implementing this method. These information has to be provided as a string array, where each string contains information about one UI. Information of a UI should be in the form of ":".

For example, an implementation of this method may look like:

public String[] getBrowseViews() { return new String[] { "text:Text view", "summary:Summary", "details:Detailed view"}; }

Above example indicates that the handler provides three browse views with keys text, summary and details.

Returns:
String array containing the information about available UIs.

getEditViews

public abstract String[] getEditViews()
Implementations have to implement this, if they provide more than edit browse view. Provides information about edit view UIs. Details are similar to getBrowseViews() method.

Returns:
String array containing the information about available UIs.

getNewViews

public String[] getNewViews()
Implementations have to implement this, if they provide more than one new view. Provides information about new resource view UIs. Details are similar to getBrowseViews() method.

Returns:
String array containing the information about available UIs.

getDefaultBrowseView

public String getDefaultBrowseView()
Among the multiple views that a handler may generate, one view is identified as the default view, which is used to render the contents, if UI is not specified. It is set to raw view by default. Handler implementations may override this method to provide alternative default view for browsing the resource content.

Returns:
UI key of the default UI.

setDefaultBrowseView

protected void setDefaultBrowseView(String viewName)
Method to set the default browse view.

Parameters:
viewName - UI key of the default browse UI

getDefaultEditView

public String getDefaultEditView()
Among the multiple views that a handler may generate, one view is identified as the default view, which is used to edit the contents, if UI is not specified. It is set to raw view by default. Handler implementations may override this method to provide alternative default view for editing the resource content.

Returns:
UI key of the default UI.

setDefaultEditView

protected void setDefaultEditView(String viewName)
Method to set the default edit view.

Parameters:
viewName - UI key of the default edit UI

getDefaultNewView

public String getDefaultNewView()
Among the multiple views that a handler may generate, one view is identified as the default view, which is used to render the new resource creation UI, if UI is not specified. It is set to undefined view by default. This is to support handlers with only one view.

Handler implementations that provide multiple new views should override this method to provide default view for adding new resources.

Returns:
UI key of the default UI.

setDefaultNewView

protected void setDefaultNewView(String viewName)
Method to set the default new view.

Parameters:
viewName - UI key of the default new UI

getBrowseView

public Resource getBrowseView(String browseViewKey,
                              RequestContext requestContext)
                       throws RegistryException
Implementations of this method should generate a HTML UI for rendering the resource content and set it as the content of the returned resource.

Parameters:
browseViewKey - UI key of the browse UI.
requestContext - Details of the request.
Returns:
Resource filled with HTML UI as the content.
Throws:
RegistryException - if an error occurs while getting the browse view.

getEditView

public Resource getEditView(String editViewKey,
                            RequestContext requestContext)
                     throws RegistryException
Implementations of this method should generate a HTML UI for editing the resource content and set it as the content of the returned resource.

Generated UI should pass following parameters as HTTP request parameters to the custom edit/new processing servlet. A common method to pass these parameters is to write them as hidden input values in the generated HTML form.

editProcessor: Name of the EditProcessor to process the request viewType: This should be set to "edit". viewKey: Key of the view. EditProcessor implementation may have to act differently according to the view key. resourcePath: Path of the resource to be updated redirectURL: Request will be redirected to this URL after processing is complete. If this is not given request will be redirected to resourcePath.

Parameters:
editViewKey - UI key of the edit UI.
requestContext - Details of the request.
Returns:
Resource filled with HTML UI as the content.
Throws:
RegistryException - if an error occurs while getting the edit view.

getNewView

public Resource getNewView(String newViewKey,
                           RequestContext requestContext)
                    throws RegistryException
Implementations of this method should generate a HTML UI for creating a new resource content and set it as the content of the returned resource.

Generated UI should pass following parameters as HTTP request parameters to the custom edit/new processing servlet. A common method to pass these parameters is to write them as hidden input values in the generated HTML form.

editProcessor: Name of the EditProcessor to process the request viewType: This should be set to "new". viewKey: Key of the view. EditProcessor implementation may have to act differently according to the view key. parentPath: Path of the parent collection of the new resource resourceName: Name of the new resource redirectURL: Request will be redirected to this URL after processing is complete. If this is not given request will be redirected to parentPath

Parameters:
newViewKey - UI key of the new resource UI.
requestContext - Details of the request.
Returns:
Resource filled with HTML UI as the content.
Throws:
RegistryException - if an error occurs while getting the new view.


Copyright © 2014 WSO2 Inc. All Rights Reserved.