com.objectplanet.survey.plugin.api
Class PluginUtil

java.lang.Object
  |
  +--com.objectplanet.survey.plugin.api.PluginUtil

public class PluginUtil
extends java.lang.Object

Utility class for the plugins.

Author:
Irina Brun
Created:
24. march 2003

Field Summary
static int LOGGING_LEVEL_ERROR
          Loggs only errors.
static int LOGGING_LEVEL_MESSAGE
          Loggs all messages, warnings and errors
static int LOGGING_LEVEL_WARNING
          Loggs all warnings and errors
 
Constructor Summary
PluginUtil()
           
 
Method Summary
static java.lang.String getPluginVersion()
          Return the version of the plugin api.
static java.lang.String getSurveySystemVersion()
          Return the version of the survey system.
static java.lang.String getSurveyUrl(javax.servlet.http.HttpServletRequest request, long surveyId)
          Gets the url to the survey module (where respondent answer the survey).
static java.lang.String getSystemHome()
          Get system home: location of the opinio files.
static User getSystemUser()
          Get system user.
static void log(java.lang.String logText, int level)
          Loggs a message.
static void log(java.lang.Throwable e)
          Loggs an error with level LOGGING_LEVEL_ERROR
static void sendEmail(java.lang.String fromName, java.lang.String fromEmail, java.lang.String toEmail, java.lang.String subject, java.lang.String message, java.lang.String emailType)
          Send email.
static void storeProps(java.util.Properties properties, java.io.File file)
          Stores a property object to an output stream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_LEVEL_ERROR

public static final int LOGGING_LEVEL_ERROR
Loggs only errors.

See Also:
Constant Field Values

LOGGING_LEVEL_MESSAGE

public static final int LOGGING_LEVEL_MESSAGE
Loggs all messages, warnings and errors

See Also:
Constant Field Values

LOGGING_LEVEL_WARNING

public static final int LOGGING_LEVEL_WARNING
Loggs all warnings and errors

See Also:
Constant Field Values
Constructor Detail

PluginUtil

public PluginUtil()
Method Detail

getPluginVersion

public static java.lang.String getPluginVersion()
Return the version of the plugin api.

Returns:
The plugin version

getSurveySystemVersion

public static java.lang.String getSurveySystemVersion()
Return the version of the survey system.

Returns:
The version

getSurveyUrl

public static java.lang.String getSurveyUrl(javax.servlet.http.HttpServletRequest request,
                                            long surveyId)
                                     throws SurveySystemException
Gets the url to the survey module (where respondent answer the survey). Usually looks like http://server-address/opinio/s?s=surveyId (or customId)

Parameters:
request - Request object
surveyId - Survey id
Returns:
The survey url
Throws:
SurveySystemException - If any error occurs.

getSystemUser

public static User getSystemUser()
Get system user. The user has with full access to all resources.

Returns:
The systemUser value

log

public static void log(java.lang.String logText,
                       int level)
Loggs a message.

Parameters:
logText - Message to log.
level - Logging level(defined above)

log

public static void log(java.lang.Throwable e)
Loggs an error with level LOGGING_LEVEL_ERROR

Parameters:
e - Exception to log.

sendEmail

public static void sendEmail(java.lang.String fromName,
                             java.lang.String fromEmail,
                             java.lang.String toEmail,
                             java.lang.String subject,
                             java.lang.String message,
                             java.lang.String emailType)
                      throws java.lang.IllegalArgumentException,
                             javax.mail.internet.AddressException,
                             SurveySystemException
Send email. Main email server should be set before calling this methos or IllegalArgumentException will be thrown.

Parameters:
fromName - Who sends the message (name)
fromEmail - Who sends the message(email address)
toEmail - Recipient's addresse
subject - The subject of the email
message - The body of the message
emailType - The type og th emessage (text or html)
Throws:
javax.mail.internet.AddressException - If invalid fromEmail or toEmail
SurveySystemException - If error occurs.
java.lang.IllegalArgumentException - If illegal parameters.

storeProps

public static void storeProps(java.util.Properties properties,
                              java.io.File file)
                       throws java.io.IOException
Stores a property object to an output stream

Parameters:
properties - The property object to store
file - File to store properties to
Throws:
java.io.IOException - IOException

getSystemHome

public static java.lang.String getSystemHome()
Get system home: location of the opinio files.

Returns:
The system home

Copyright © ObjectPlanet Inc. All Rights Reserved.

Built on May 7 2003