public class PluginUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
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 and Description |
|---|
PluginUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
debug(java.lang.String txt)
log statements with level = debug.
|
static void |
error(java.lang.String txt)
log statements with level <= error.
|
static void |
fatal(java.lang.String txt)
log statements with level = fatal
|
static java.lang.String |
formatElapsedTimeMillis(long elapsedTime,
java.lang.String lang,
boolean shortform)
Formats the specified number of milliseconds into the format "days, hours, minutes, seconds, milliseconds." and drops 0-values.
|
static java.lang.String |
getCharacterEncoding()
Gets the system character encoding (from setup screen)
|
static int |
getDaysUntilExpiration()
Return days until expirations for the current license.
|
static int |
getEdition() |
static java.lang.String |
getEditionName(java.lang.String language)
Get the edition name of the current license
|
static java.lang.String |
getExportFileExtension()
Gets the preferred file extension when exporting files.
|
static java.lang.String |
getExportKeepFiles()
Gets the preferred keep file property.
|
static java.lang.String |
getHostId()
Get the host ID for the current Opinio installation.
|
static long |
getLongTime()
Get long time: return the date attribute of the SystemTime object
|
static int |
getMaxUsers()
Returns max allowed users for the current license.
|
static java.lang.String |
getMessage(java.lang.String key,
java.lang.String language)
Get message from i18n resources
|
static java.lang.String |
getMessage(java.lang.String key,
java.lang.String[] params,
java.lang.String language)
Get message from i18n resources
|
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 java.lang.String |
getSystemUrl(javax.servlet.http.HttpServletRequest request)
Get system url: Usually looks like
http://server-address/opinio |
static User |
getSystemUser()
Get system user.
|
static long |
getUploadSurveyFolderSize(long surveyId)
Get the total capacity of bytes of the upload folder for a specific survey (including subfolders).
|
static User |
getUserFromSession(javax.servlet.http.HttpServletRequest request)
Get the user object from session.
|
static void |
info(java.lang.String txt)
log statements with level <= info.
|
static boolean |
isDebugEnabled()
Return true if debug is enabled.
|
static boolean |
isLockedByAnotherUser(long userId,
long surveyId)
Check if survey is locked by another user.
|
static boolean |
isNullOrEmpty(java.lang.String string)
Returns true if string is null or empty
|
static boolean |
isUnix()
Returns true current OS is Unix or Unix-like (For example Linux).
|
static boolean |
isWindows()
Returns true current OS is Windows
|
static void |
log(java.lang.String logText,
int level)
Deprecated.
This log method is no longer used. Will not log to any file! Use log.debug(),
log.info(), log.warn(), log.error(), log.fatal() instead.
|
static void |
log(java.lang.Throwable e)
Deprecated.
This log method is no longer used. Will not log to any file! Use log.debug(),
log.info(), log.warn(), log.error(), log.fatal() instead.
|
static void |
sendEmail(Email email)
Send email.
|
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 |
setLicenseCode(java.lang.String licenseCode)
Sets the Opinio license code.
|
static boolean |
stopAllThreads()
Stop All Threads: Gets the stop all threads attribute of the System Globals object
|
static void |
storeProps(java.util.Properties properties,
java.io.File file)
Stores a property object to an output stream
|
static void |
warn(java.lang.String txt)
log statements with level <= warn
|
public static final int LOGGING_LEVEL_ERROR
public static final int LOGGING_LEVEL_MESSAGE
public static final int LOGGING_LEVEL_WARNING
public static java.lang.String getPluginVersion()
public static java.lang.String getSurveySystemVersion()
public static int getEdition()
public static java.lang.String getEditionName(java.lang.String language)
language - public static int getMaxUsers()
public static int getDaysUntilExpiration()
public static java.lang.String getSurveyUrl(javax.servlet.http.HttpServletRequest request,
long surveyId)
throws SurveySystemException
http://server-address/opinio/s?s=surveyId (or customId)request - Request objectsurveyId - Survey idSurveySystemException - If any error occurs.public static User getSystemUser()
public static boolean isLockedByAnotherUser(long userId,
long surveyId)
throws SurveySystemException
userId - id of current user.surveyId - id of survey to check lock for.SurveySystemExceptionpublic static User getUserFromSession(javax.servlet.http.HttpServletRequest request)
request - The HttpServletRequest objectpublic static void log(java.lang.String logText,
int level)
logText - Message to log.level - Logging level(defined above)public static void info(java.lang.String txt)
log4j.logger.com.objectplanet.survey.plugin.api=info
txt - The text to logpublic static boolean isDebugEnabled()
public static void debug(java.lang.String txt)
log4j.logger.com.objectplanet.survey.plugin.api=debug
txt - The text to logpublic static void warn(java.lang.String txt)
txt - The text to logpublic static void error(java.lang.String txt)
log4j.logger.com.objectplanet.survey.plugin.api=error
txt - The text to log.public static void fatal(java.lang.String txt)
txt - Description of the Parameterpublic static java.lang.String formatElapsedTimeMillis(long elapsedTime,
java.lang.String lang,
boolean shortform)
elapsedTime - The elapsed time in milliseconds.lang - The language code, used to format the value to correct format.shortform - true will produce the string in a shorter format (ignores the language parameter)public static void log(java.lang.Throwable e)
e - Exception to log.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
fromName - Who sends the message (name)fromEmail - Who sends the message(email address)toEmail - Recipient's addresssubject - The subject of the emailmessage - The body of the messageemailType - The type and the mmessage (text:"text/plain" or html:"text/html")javax.mail.internet.AddressException - If invalid fromEmail or toEmailSurveySystemException - If error occurs.java.lang.IllegalArgumentException - If illegal parameters.public static void sendEmail(Email email) throws java.lang.IllegalArgumentException, javax.mail.internet.AddressException, SurveySystemException
Email - Email objectSurveySystemException - If error occurs.java.lang.IllegalArgumentExceptionjavax.mail.internet.AddressExceptionpublic static void storeProps(java.util.Properties properties,
java.io.File file)
throws java.io.IOException
properties - The property object to storefile - File to store properties tojava.io.IOException - IOExceptionpublic static long getUploadSurveyFolderSize(long surveyId)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String getExportFileExtension()
public static java.lang.String getExportKeepFiles()
public static java.lang.String getSystemHome()
public static java.lang.String getSystemUrl(javax.servlet.http.HttpServletRequest request)
http://server-address/opiniopublic static long getLongTime()
public static boolean stopAllThreads()
public static void setLicenseCode(java.lang.String licenseCode)
licenseCode - The new license code.public static java.lang.String getHostId()
public static java.lang.String getCharacterEncoding()
public static java.lang.String getMessage(java.lang.String key,
java.lang.String language)
message - keylanguage - public static java.lang.String getMessage(java.lang.String key,
java.lang.String[] params,
java.lang.String language)
message - keylanguage - parameters - to the messagepublic static boolean isNullOrEmpty(java.lang.String string)
string - String to checkpublic static boolean isWindows()
public static boolean isUnix()
Built on July 29 2025