com.nurelm.util
Class NuPlatformUtil

java.lang.Object
  extended bycom.nurelm.util.NuPlatformUtil

public class NuPlatformUtil
extends java.lang.Object

Contains special items related to the NuRelm development platform. For example, the siteId for all sites is obtained by reading the path in which the site is located. The method to obtain the siteId is located in this class.


Field Summary
static java.lang.String chkErrorMsg
          Logs Exception and Error Message with more information like site ID
static java.lang.String LOGGING_DEBUG_PREFIX
           
static java.lang.String LOGGING_ERROR_PREFIX
          Prefix used for all error logs.
static java.lang.String LOGGING_INFO_PREFIX
          Prefix used for all info logs.
static java.lang.String UNIX_STYLE_PREFIX
          Represent the absolute path prefix that indicates where the virtual domains live on the host machine.
static java.lang.String WINDOWS_STYLE_PREFIX
          Represent the absolute path prefix that indicates where the virtual domains live on the host machine.
 
Constructor Summary
NuPlatformUtil()
          Creates a new NuPlatformUtil object.
 
Method Summary
static java.lang.String createActionForwardPath(java.lang.String basePath, java.lang.String pageId, boolean isRepeatContent, java.lang.String startItem, java.lang.String restrictids, java.lang.String restrictvalues, java.lang.String searchids, java.lang.String searchvalues, java.lang.String sortbyids, java.lang.String sortbydirections, java.lang.String repeatItemId)
          Creates a path for an ActionForward instantiation that includes the common NuRelm parameters that need to be passed around.
static java.lang.String getEmailDomain(javax.servlet.ServletContext sc, javax.servlet.http.HttpServletRequest request)
          Returns the site's e-mail domain name.
static java.lang.String getFilteredHtml(javax.servlet.ServletContext sc, java.lang.String content)
          Runs the NuRelm HTML filter based on the init parameters htmlFilterAllowedAttributes, htmlFilterAllowedTags, and htmlFilterDropEmptyParas.
static java.lang.String getHtmlFilterAllowedAttributes(javax.servlet.ServletContext sc)
          Gets htmlFilterAllowedAttributes init parameter (set in web.xml).
static java.lang.String getHtmlFilterAllowedTags(javax.servlet.ServletContext sc)
          Gets htmlFilterAllowedTags init parameter (set in web.xml).
static boolean getHtmlFilterDropEmptyParas(javax.servlet.ServletContext sc)
          Gets htmlFilterDropEmptyParas init parameter (set in web.xml).
static java.lang.String getLockingURL(java.lang.String originatingPageURL, Site site)
          Makes sure that the URL passed in specifies a Locking pageId, rather than the ID of a working page.
static Node getNodeDoNotLock(javax.servlet.http.HttpServletRequest request)
          Returns the requested Node, but never locks it first.
static Node getNodeDoNotLock(javax.servlet.http.HttpServletRequest request, java.lang.String pageId)
           
static Node getNodeLockIfNeeded(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, java.lang.String pageURI)
          Returns the requested Node, but locks it and returns the working copy instead if necessary.
static Node getNodeLockIfNeeded(java.lang.String id, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, java.lang.String pageURI)
          Returns the requested Node, but locks it and returns the working copy instead if necessary.
static Page getPage(javax.servlet.http.HttpServletRequest request)
          Returns the requested page, does not lock it ever.
static Page getPageLockIfNeeded(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, java.lang.String pageURI)
          Returns the requested Page, but locks it and returns the working copy instead if necessary.
static boolean getRequireLocking(javax.servlet.ServletContext sc)
          Gets requireLocking init parameter (set in web.xml).
static java.lang.String getReviewType(javax.servlet.ServletContext sc)
          Gets reviewType init parameter (set in web.xml).
static java.lang.String getSiteId(javax.servlet.ServletContext sc)
          Gets siteId init parameter (set in web.xml).
static java.lang.String getSiteInfoString(javax.servlet.http.HttpServletRequest request)
          Gets a string with the current site's ID and logged in user.
static java.lang.String getStackTraceAsString(java.lang.Throwable e)
          Returns Exception stack trace as String.
static java.lang.String[] getUsersHavingReviewAccess(javax.servlet.http.HttpServletRequest request)
          Gets Users who has Review Permisson as String Array.
static UserValueObject getUserVO(javax.servlet.http.HttpServletRequest request)
           
static boolean IsPageHasReviewersfromReviewGroup(Site site, Page page)
          Checks the page in this site has reviewers from reviewer group return true if page has.
static boolean isReviewTypeAdminExtTurnedOn(javax.servlet.ServletContext sc)
          Returns true if review type extension turn on (set in web.xml).
static boolean isUserExistsInGroup(javax.servlet.http.HttpServletRequest request, java.lang.String username, java.lang.String groupName)
          Checks the user exisats in the group in the site return true if page has.
static boolean isUserExistsInGroup(Site site, java.lang.String username, java.lang.String groupName)
          Checks the user exisats in the group in the site return true if page has.
static boolean isUserHasReviewPermissionOnPage(Page page, java.lang.String userName)
          Checks the page in this site has reviewers from reviewer group return true if page has.
static void logAndThrowDataAccessException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, javax.servlet.http.HttpServletRequest request, java.lang.String errorMsg)
          Logs Data Access Exception And throw is with more ingformation like site ID
static void logAndThrowDataAccessException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.String errorMsg)
          Logs Data Access Exception And throw is with more ingformation like site ID
static void logAndThrowException(java.util.logging.Logger LOG, java.lang.String error)
          Logs an error message to a logger, then throws a DataAccessException with the same error.
static void logAndThrowRuntimeException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.Throwable exception, java.lang.String errorMsg)
          Log exception and throw Runtime Exception with more ingformation like site ID
static void logAndThrowSystemException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.Throwable error, javax.servlet.http.HttpServletRequest request, java.lang.String errorMsg)
          Logs Exception And throw System Exception with more ingformation like site ID
static void logAndThrowSystemException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.Throwable exception, java.lang.String errorMsg)
          Log exception and throw System Exception with more ingformation like site ID
static void logDebug(org.apache.log4j.Logger LOG, java.lang.String debugMsg)
          Logs debug message.
static void logErrorMsg(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, javax.servlet.http.HttpServletRequest request, java.lang.String errorMsg)
          Logs Error Message with more information like site ID
static void logErrorMsg(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.String errorMsg)
          Logs Error Message with more ingformation like site ID
static void logException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.Throwable exp, javax.servlet.http.HttpServletRequest request, java.lang.String errorMsg)
           
static void logException(org.apache.log4j.Logger LOG, org.apache.log4j.Level logLevel, java.lang.Throwable exp, java.lang.String errorMsg)
          Logs Exception and Error Message with more information like site ID
static void removeFile(javax.servlet.ServletContext sc, File file)
           
static void removeImageFile(javax.servlet.ServletContext sc, Image image)
           
static boolean theFileExists(java.lang.String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_INFO_PREFIX

public static final java.lang.String LOGGING_INFO_PREFIX
Prefix used for all info logs.

See Also:
Constant Field Values

LOGGING_ERROR_PREFIX

public static final java.lang.String LOGGING_ERROR_PREFIX
Prefix used for all error logs.

See Also:
Constant Field Values

LOGGING_DEBUG_PREFIX

public static final java.lang.String LOGGING_DEBUG_PREFIX
See Also:
Constant Field Values

WINDOWS_STYLE_PREFIX

public static final java.lang.String WINDOWS_STYLE_PREFIX
Represent the absolute path prefix that indicates where the virtual domains live on the host machine.

See Also:
Constant Field Values

UNIX_STYLE_PREFIX

public static final java.lang.String UNIX_STYLE_PREFIX
Represent the absolute path prefix that indicates where the virtual domains live on the host machine.

See Also:
Constant Field Values

chkErrorMsg

public static java.lang.String chkErrorMsg
Logs Exception and Error Message with more information like site ID

Constructor Detail

NuPlatformUtil

public NuPlatformUtil()
Creates a new NuPlatformUtil object.

Method Detail

getLockingURL

public static java.lang.String getLockingURL(java.lang.String originatingPageURL,
                                             Site site)
Makes sure that the URL passed in specifies a Locking pageId, rather than the ID of a working page.

Returns:
The URL modified if necessary to use a pageId of a locking page.

logAndThrowException

public static void logAndThrowException(java.util.logging.Logger LOG,
                                        java.lang.String error)
                                 throws DataAccessException
Logs an error message to a logger, then throws a DataAccessException with the same error.

Parameters:
error - The error message to log and include with the exception
Throws:
DataAccessException - Thrown by this method no matter what.

getFilteredHtml

public static java.lang.String getFilteredHtml(javax.servlet.ServletContext sc,
                                               java.lang.String content)
Runs the NuRelm HTML filter based on the init parameters htmlFilterAllowedAttributes, htmlFilterAllowedTags, and htmlFilterDropEmptyParas.

Parameters:
sc - The current context.
content - The content to be filtered.
Returns:
Filtered content.

getHtmlFilterAllowedAttributes

public static java.lang.String getHtmlFilterAllowedAttributes(javax.servlet.ServletContext sc)
Gets htmlFilterAllowedAttributes init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
htmlFilterAllowedAttributes parameter. If not set, return empty string.

getHtmlFilterAllowedTags

public static java.lang.String getHtmlFilterAllowedTags(javax.servlet.ServletContext sc)
Gets htmlFilterAllowedTags init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
htmlFilterAllowedTags parameter. If not set, return empty string.

getHtmlFilterDropEmptyParas

public static boolean getHtmlFilterDropEmptyParas(javax.servlet.ServletContext sc)
Gets htmlFilterDropEmptyParas init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
htmlFilterAllowedTags parameter. If not set, return empty string.

getRequireLocking

public static boolean getRequireLocking(javax.servlet.ServletContext sc)
Gets requireLocking init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
requireLocking init parameter. If not set, return false

getReviewType

public static java.lang.String getReviewType(javax.servlet.ServletContext sc)
Gets reviewType init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
reviewType init parameter. If not set, return null

isReviewTypeAdminExtTurnedOn

public static boolean isReviewTypeAdminExtTurnedOn(javax.servlet.ServletContext sc)
Returns true if review type extension turn on (set in web.xml).

Parameters:
sc - The current context.
Returns:
true reviewTypeExt set as init parameter. If not set, return false

getSiteInfoString

public static java.lang.String getSiteInfoString(javax.servlet.http.HttpServletRequest request)
Gets a string with the current site's ID and logged in user. Most often used to provide detail in logging statements.

Parameters:
request - The current HttpServletRequest
Returns:
A string of the form " siteId = thisSiteId, user = loggedInUser"

getSiteId

public static java.lang.String getSiteId(javax.servlet.ServletContext sc)
                                  throws NuPlatformException
Gets siteId init parameter (set in web.xml).

Parameters:
sc - The current context.
Returns:
siteId string.
Throws:
NuPlatformException - Thrown if siteId was not set.

getUsersHavingReviewAccess

public static java.lang.String[] getUsersHavingReviewAccess(javax.servlet.http.HttpServletRequest request)
                                                     throws DataAccessException
Gets Users who has Review Permisson as String Array.

Parameters:
request - (HttpServlet Request).
Returns:
string array of users.
Throws:
Data - Access Exception .
DataAccessException

getUserVO

public static UserValueObject getUserVO(javax.servlet.http.HttpServletRequest request)

getPage

public static Page getPage(javax.servlet.http.HttpServletRequest request)
Returns the requested page, does not lock it ever.

Parameters:
request - The current request.
Returns:
The page indicated in the request.

getPageLockIfNeeded

public static Page getPageLockIfNeeded(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.ServletContext servletContext,
                                       java.lang.String pageURI)
Returns the requested Page, but locks it and returns the working copy instead if necessary.

Parameters:
request - The current request.
servletContext - The current servlet context.
Returns:
If necessary, the page returned is the working copy of a now locked page.

getNodeLockIfNeeded

public static Node getNodeLockIfNeeded(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.ServletContext servletContext,
                                       java.lang.String pageURI)
Returns the requested Node, but locks it and returns the working copy instead if necessary.

Parameters:
request - The current request, which should contain the required pageId.
servletContext - The current servlet context.
Returns:
If necessary, the node returned is the working copy of a now locked node.

getNodeLockIfNeeded

public static Node getNodeLockIfNeeded(java.lang.String id,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.ServletContext servletContext,
                                       java.lang.String pageURI)
Returns the requested Node, but locks it and returns the working copy instead if necessary.

Parameters:
id - The id of the node to be returned.
request - The current request.
servletContext - The current servlet context.
Returns:
If necessary, the node returned is the working copy of a now locked node.

getNodeDoNotLock

public static Node getNodeDoNotLock(javax.servlet.http.HttpServletRequest request)
Returns the requested Node, but never locks it first.

Parameters:
request - The current request, which should contain the required pageId.
Returns:
The exact Node specified, never a locked version (unless a locked one was specified).

getNodeDoNotLock

public static Node getNodeDoNotLock(javax.servlet.http.HttpServletRequest request,
                                    java.lang.String pageId)

theFileExists

public static boolean theFileExists(java.lang.String filename)

getEmailDomain

public static java.lang.String getEmailDomain(javax.servlet.ServletContext sc,
                                              javax.servlet.http.HttpServletRequest request)
                                       throws NuPlatformException
Returns the site's e-mail domain name. To determine it, we do the following... 1. If an attribute is set in the web.xml file with a name of "emailDomain", then its value is returned. 2. If the above is not set, then we determine the domain name via request.getServerName(). This is fine in most cases, but occassionally you may have multiple domains that point to the same site (e.g. fusesports.com & fuseyouthmarketing.com), which could lead to problems if we don't explicitly specify the correct domain.

Parameters:
sc - Current site context.
request - Current request.
Returns:
Email domain name.
Throws:
NuPlatformException

createActionForwardPath

public static java.lang.String createActionForwardPath(java.lang.String basePath,
                                                       java.lang.String pageId,
                                                       boolean isRepeatContent,
                                                       java.lang.String startItem,
                                                       java.lang.String restrictids,
                                                       java.lang.String restrictvalues,
                                                       java.lang.String searchids,
                                                       java.lang.String searchvalues,
                                                       java.lang.String sortbyids,
                                                       java.lang.String sortbydirections,
                                                       java.lang.String repeatItemId)
Creates a path for an ActionForward instantiation that includes the common NuRelm parameters that need to be passed around. These include restrictids, restrictvalues, sortbyids, sortbydirections, startItem, and an anchor to a specific repeatItem's id.

Parameters:
basePath - The path to which parameter values will be added.
pageId - The ID of the destination page
isRepeatContent - true if path is being created for content in a repeat block.
startItem - If repeat content, the start itemm for the current "chunk"
restrictids - From the current repeat block parameters
restrictvalues - From the current repeat block parameters
searchids - From the current repeat block parameters
searchvalues - From the current repeat block parameters
sortbyids - From the current repeat block parameters
repeatItemId - From the current repeat block parameters
Returns:
The full path needed for most of NuContent's ActionForward constructions.

getStackTraceAsString

public static java.lang.String getStackTraceAsString(java.lang.Throwable e)
Returns Exception stack trace as String.

Returns:
String Stack trace of Exception.

logAndThrowDataAccessException

public static void logAndThrowDataAccessException(org.apache.log4j.Logger LOG,
                                                  org.apache.log4j.Level logLevel,
                                                  java.lang.String errorMsg)
                                           throws DataAccessException
Logs Data Access Exception And throw is with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
errorMsg - String error message to log
Throws:
DataAcessException
DataAccessException

logAndThrowSystemException

public static void logAndThrowSystemException(org.apache.log4j.Logger LOG,
                                              org.apache.log4j.Level logLevel,
                                              java.lang.Throwable exception,
                                              java.lang.String errorMsg)
                                       throws NuContentSystemException
Log exception and throw System Exception with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
exception - The Exception object to be logged.
errorMsg - String error message to log
Throws:
NuContentSystemException

logAndThrowRuntimeException

public static void logAndThrowRuntimeException(org.apache.log4j.Logger LOG,
                                               org.apache.log4j.Level logLevel,
                                               java.lang.Throwable exception,
                                               java.lang.String errorMsg)
                                        throws java.lang.RuntimeException
Log exception and throw Runtime Exception with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
exception - The Exception object to be logged.
errorMsg - String error message to log
Throws:
java.lang.RuntimeException

logErrorMsg

public static void logErrorMsg(org.apache.log4j.Logger LOG,
                               org.apache.log4j.Level logLevel,
                               java.lang.String errorMsg)
Logs Error Message with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
errorMsg - String error message to log

logException

public static void logException(org.apache.log4j.Logger LOG,
                                org.apache.log4j.Level logLevel,
                                java.lang.Throwable exp,
                                java.lang.String errorMsg)
Logs Exception and Error Message with more information like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
errorMsg - String error message to log

logDebug

public static void logDebug(org.apache.log4j.Logger LOG,
                            java.lang.String debugMsg)
Logs debug message.

Parameters:
LOG - Logger object of the class.
debugMsg - String error message to log

logAndThrowDataAccessException

public static void logAndThrowDataAccessException(org.apache.log4j.Logger LOG,
                                                  org.apache.log4j.Level logLevel,
                                                  javax.servlet.http.HttpServletRequest request,
                                                  java.lang.String errorMsg)
                                           throws DataAccessException
Logs Data Access Exception And throw is with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
request - current request object to get site Id
logLevel - Logging Level like INFO,WARN
errorMsg - String error message to log
Throws:
DataAcessException
DataAccessException

logAndThrowSystemException

public static void logAndThrowSystemException(org.apache.log4j.Logger LOG,
                                              org.apache.log4j.Level logLevel,
                                              java.lang.Throwable error,
                                              javax.servlet.http.HttpServletRequest request,
                                              java.lang.String errorMsg)
                                       throws NuContentSystemException
Logs Exception And throw System Exception with more ingformation like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
request - current request object to get site Id
errorMsg - String error message to log
Throws:
NuContentSystemException

logErrorMsg

public static void logErrorMsg(org.apache.log4j.Logger LOG,
                               org.apache.log4j.Level logLevel,
                               javax.servlet.http.HttpServletRequest request,
                               java.lang.String errorMsg)
Logs Error Message with more information like site ID

Parameters:
LOG - Logger object of the class.
logLevel - Logging Level like INFO,WARN
request - current request object to get site Id
errorMsg - String error message to log

logException

public static void logException(org.apache.log4j.Logger LOG,
                                org.apache.log4j.Level logLevel,
                                java.lang.Throwable exp,
                                javax.servlet.http.HttpServletRequest request,
                                java.lang.String errorMsg)

IsPageHasReviewersfromReviewGroup

public static boolean IsPageHasReviewersfromReviewGroup(Site site,
                                                        Page page)
                                                 throws DataAccessException
Checks the page in this site has reviewers from reviewer group return true if page has.

Parameters:
site - object of Site class.
page - object of Page class
Returns:
true if page has reviewers from reviewer group of thsi site.
Throws:
DataAcessException
DataAccessException

isUserHasReviewPermissionOnPage

public static boolean isUserHasReviewPermissionOnPage(Page page,
                                                      java.lang.String userName)
                                               throws DataAccessException
Checks the page in this site has reviewers from reviewer group return true if page has.

Parameters:
page - object of Page class
Returns:
true if page has reviewers from reviewer group of thsi site.
Throws:
DataAcessException
DataAccessException

isUserExistsInGroup

public static boolean isUserExistsInGroup(Site site,
                                          java.lang.String username,
                                          java.lang.String groupName)
                                   throws DataAccessException
Checks the user exisats in the group in the site return true if page has.

Parameters:
site - object of Site class.
Returns:
true if user exist in the group.
Throws:
DataAcessException
DataAccessException

isUserExistsInGroup

public static boolean isUserExistsInGroup(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String username,
                                          java.lang.String groupName)
                                   throws DataAccessException
Checks the user exisats in the group in the site return true if page has.

Returns:
true if user exist in the group.
Throws:
DataAcessException
DataAccessException

removeImageFile

public static void removeImageFile(javax.servlet.ServletContext sc,
                                   Image image)

removeFile

public static void removeFile(javax.servlet.ServletContext sc,
                              File file)