|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.objectplanet.survey.plugin.Plugin
public abstract class Plugin
Plugin is an abstract class that all plugins must implement. The methods required is interface between the system and a plugin.
Nested Class Summary | |
---|---|
static class |
Plugin.Broken
A placeholder for a plugin that didn't load. |
static class |
Plugin.JAR
A JAR file. |
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_SETUP_HTML
Deprecated. Will be made private when getSetupHTML() is removed |
Constructor Summary | |
---|---|
Plugin()
|
Method Summary | |
---|---|
java.lang.String |
getClassName()
Returns the plugin's class name. |
java.lang.String |
getErrorMsg()
Deprecated. from version 6.0 The ProcessResult object is used instead of error message. |
boolean |
getFailedToLoad()
Return true if plugin failed to load |
int |
getFunctionCount()
Gets the number of functions provided by the plugin. |
java.lang.String |
getFunctionHTML(int functionNo,
java.util.HashMap resources)
Gets the HTML code for plugin function. |
java.lang.String |
getFunctionIconBig(int functionNo,
java.util.HashMap resources)
Gets page icon for the plugin function. |
java.lang.String |
getFunctionIconSmall(int functionNo,
java.util.HashMap resources)
Gets icon for the plugin function menu item. |
java.lang.String |
getFunctionLabel(int functionNo,
java.util.HashMap resources)
Gets the link label to the plugin function. |
java.lang.String |
getFunctionUrl(int functionNo,
java.util.HashMap resources)
Url to go to when link with label getFunctionLabel(int functionNo, HashMap resources) is clicked. |
java.lang.String |
getHelpHTML()
NOTE: this method is not yet used by Opinio. Gets the HTML code for displaying help. |
java.lang.String |
getHelpURL()
Gets the help url for linking the plugin's help page to the plugin setup screen and the pluginMenuHook.jsp. |
Plugin.JAR |
getJAR()
Returns the JAR file containing this plugin. |
java.lang.String |
getProperty(java.lang.String propertyName)
Method for getting a plugin property value that is stored in the database. |
java.lang.String |
getSetupHTML()
Deprecated. from version 6.0 Use getSetupHTML(HashMap resources) NOTE that <form> element and pluginName hidden field must be removed. |
java.lang.String |
getSetupHTML(java.util.HashMap resources)
Gets the HTML code for plugin setup screen. |
boolean |
hasFunctionAccess(long userId,
int functionNo,
java.util.HashMap resources)
Checks if user with userId has access to the plugin function number functionNo. |
boolean |
isMultipartFunctionData(int functionNo,
java.util.HashMap resources)
Should function be processed as "multipart/form-data"? Overwrite and return true for functions that need form content type "multipart/form-data". |
ProcessResult |
processFunctionHTML(int functionNo,
java.util.HashMap resources)
Method for processing the plugin function html. |
java.lang.String |
processSetup(java.util.Map values)
Deprecated. from version 6.0 Use processSetupHTML(HashMap resources) |
ProcessResult |
processSetupHTML(java.util.HashMap resources)
Method for processing the plugin setup html. |
void |
removeProperty(java.lang.String propertyName)
Method for removing a plugin property value in the database. |
void |
setErrorMsg(java.lang.String errorMsg)
Deprecated. from version 6.0 The ProcessResult object is used instead of error message. |
void |
setProperty(java.lang.String propertyName,
java.lang.String propertyValue)
Method for saving a plugin property value in the database. |
void |
start()
Any PluginBus registrations should be done here. |
void |
stop()
Method called by the system before exiting. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_SETUP_HTML
getSetupHTML()
is removed
Constructor Detail |
---|
public Plugin()
Method Detail |
---|
public java.lang.String getClassName()
public final boolean getFailedToLoad()
value
- public Plugin.JAR getJAR()
public final void setErrorMsg(java.lang.String errorMsg)
errorMsg
- The error messagepublic final java.lang.String getErrorMsg()
public java.lang.String getSetupHTML()
pluginName
hidden field must be removed.
public java.lang.String getFunctionHTML(int functionNo, java.util.HashMap resources)
String html = "Name: <input type=text name=plugin_name length=10><br>" + "Address: <input type=password name=plugin_address length=10>" + "<input type=submit value="save" name=plugin_savebutton>"; return html;As can be seen from this example code, all input field names must start with "plugin". This is to avoid any conflicts with any fields produced by Opinio. The example includes two fields: "plugin_name" and "plugin_address". When the user enters the values and clicks the button (must also be provided in the code), Opinio will receive the form and return it through a call to the
processFunctionHTML(int functionNo, HashMap resources)
method. It is then up to the plugin to process the html.hasFunctionAccess()
If you need to upload files to you funtions note the following:
PluginConstants.PARAM_UPLOAD_FILE_NAME_1
,
PluginConstants.PARAM_UPLOAD_FILE_NAME_2
, ..
functionNo
- Number of the plugin function Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public int getFunctionCount()
public java.lang.String getFunctionUrl(int functionNo, java.util.HashMap resources)
getFunctionLabel(int functionNo, HashMap resources)
is clicked. This is an url
to the plugin function implementation and will be available from page actions box (from
Opinio 6.0). Default implementation returns url to Opinio action which checks user login and
permissions and displays plugin action html returned by getFunctionHTML(int functionNo,
HashMap resources).
functionNo
- Number of the function for this url, will be added to the link. Function
number is int value between 1 and getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");Then these objects should contain the values needed to produce the url link. In most cases, no values are needed at all, but you may want to send some parameters to the plugin.
is clicked)
public boolean hasFunctionAccess(long userId, int functionNo, java.util.HashMap resources)
getFunctionHTML()
method never be called (even if user tries to manipulate
url) - processFunctionHTML()
will never be called (even if user tries to
manipulate url)
Default implementation returns true (all functions are available for all users)
See UserManager class, hasSurveyPermission()
and
hasFolderPermission(
) methods
userId
- Id of the currenlty logged userfunctionNo
- Function number of this plugin Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");Then these objects contain values that might be needed to check the function access.
public java.lang.String getFunctionLabel(int functionNo, java.util.HashMap resources)
plugin.#className#.name
) or class name if plugin name is not found
or set in the properties file.
functionNo
- Number of the plugin function. Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public java.lang.String getFunctionIconSmall(int functionNo, java.util.HashMap resources)
functionNo
- Number of the plugin function. Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public java.lang.String getFunctionIconBig(int functionNo, java.util.HashMap resources)
functionNo
- Number of the plugin function. Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public boolean isMultipartFunctionData(int functionNo, java.util.HashMap resources)
functionNo
- Number of the plugin function. Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get(PluginConstants.RESOURCE_HTTP_REQUEST); HttpResponse response = (HttpResponse) resources.get(PluginConstants.RESOURCE_HTTP_RESPONSE);
public java.lang.String getSetupHTML(java.util.HashMap resources)
As can be seen from this example code, all input field names must start with "plugin". This is to avoid any conflicts with any fields produced by Opinio. The example includes two fields: "plugin_name" and "plugin_address". When the user enters the values and clicks the button (must also be provided in the code), Opinio will receive the form and return it through a call to theString html = "Name: <input type=text name=plugin_name length=10><br>" + "Address: <input type=password name=plugin_address length=10>" + "<input type=submit value=Save name=plugin_savebutton>"; return html;
processSetupHTML(HashMap resources)
method. It is then
up to the plugin to process the setup html.
resources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public ProcessResult processFunctionHTML(int functionNo, java.util.HashMap resources)
hasFunctionAccess()
functionNo
- Number of the plugin function Function number is int value between 1 and
getFunctionCount() inclusiveresources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:
HttpRequest request = (HttpRequest) resources.get("HttpRequest");
HttpResponse response = (HttpResponse) resources.get("HttpResponse");
If you set the function data to be "multipart/form-data" (method isMultipartFunctionData()
returns true), and add uploaded files to the html function page, then the uploaded files can
be retrieved like this:
FormFile is struts interface for uploaded files: org.apache.struts.upload.FormFileArrayList uploadFiles = (ArrayList) resources.get(PluginConstants.RESOURCE_UPLOAD_FILES); if (uploadFiles != null && uploadFiles.size() > 0) { FormFile firstUploadedFile = (FormFile) uploadFiles.get(0); }
public ProcessResult processSetupHTML(java.util.HashMap resources)
resources
- This HashMap contains both the HttpRequest and HttpResponse objects, if the
current survey is web based. In future versions, other types of objects must be
retrieved, if other protocols are used - WAP, for example. The HTTP objects must
be retrieved this way:These objects should contain the values needed to process the plugin function.HttpRequest request = (HttpRequest) resources.get("HttpRequest"); HttpResponse response = (HttpResponse) resources.get("HttpResponse");
public java.lang.String getHelpHTML()
public java.lang.String getHelpURL()
""plugin_SurveyMenuItemPlugin/Help.html"
.
It is not required, but very useful. If the plugin doesn't have a help page, this method will
return null and a default plugin help will be displayed.
public void start()
public void stop()
public java.lang.String processSetup(java.util.Map values)
values
- The values entered by the user in the setup screen.
public void setProperty(java.lang.String propertyName, java.lang.String propertyValue) throws java.lang.Exception
propertyName
- The property namepropertyValue
- The property value
java.lang.Exception
public java.lang.String getProperty(java.lang.String propertyName) throws java.lang.Exception
propertyName
- The property name
java.lang.Exception
public void removeProperty(java.lang.String propertyName) throws java.lang.Exception
propertyName
- The property name
java.lang.Exception
|
Copyright ? ObjectPlanet Inc. All Rights Reserved. | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |