com.jalios.jcms
Class JcmsUtil

java.lang.Object
  extended by com.jalios.jcms.JcmsUtil
All Implemented Interfaces:
JcmsConstants, JaliosConstants

public class JcmsUtil
extends Object
implements JcmsConstants

This class contains a set of utility static methods.

Version:
$Revision: 30867 $
Author:
Olivier Dedieu

Field Summary
static org.apache.oro.text.regex.Pattern DUPLICATE_PREFIX
           
static String REVISION
           
 
Fields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, CRYPT_MD5, CRYPT_UNDEFINED, CRYPT_UNIX, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, ICON_ARCHIVE, ICON_LOCK, ICON_LOCK_STRONG, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_DEEP_COPY, OP_DEEP_DELETE, OP_DELETE, OP_MERGE, OP_UPDATE, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
 
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 
Constructor Summary
JcmsUtil()
           
 
Method Summary
static void addData(TreeSet set, Class clazz, Collection coll)
          This methods adds data from a collection to the given set if the data is an instance of the given class.
static void addData(TreeSet set, Class clazz, Data data)
          This methods adds the given data to the given set if this data is an instance of the given class.
static void addData(TreeSet set, Class clazz, Data[] array)
          This methods adds data from an array to the given set if the data is an instance of the given class.
static void addData(TreeSet set, Class clazz, Map mlMap)
          This methods adds data from a ML Map to the given set if the data is an instance of the given class.
static void addFileDocument(Set<FileDocument> set, String... filenames)
          Adds the FileDocuments bound to the given filename array in the given set.
static void addFileDocument(Set<FileDocument> set, String filename)
          Adds the FileDocument bound to the given filename in the given set.
static void addFileDocument(Set<FileDocument> set, String[] filenamesMainLanguage, Map<String,String[]> mlMap)
          Adds the FileDocuments bound to the given array of filename and to the array of filename contains as value of mlMap in the given set.
static void addFileDocument(Set<FileDocument> set, String filenameMainLanguage, Map<String,String> mlMap)
          Adds the FileDocuments bound to the given filename and to the filename contains as value of mlMap in the given set.
static Collection applyDataSelector(Collection dataColl, DataSelector selector)
          Apply given DataSelector by removing non selected Data from the given Collection.
static boolean checkDataWriteDisabled(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String redirect, String userLang)
          Check is data writes are disabled.
static ControllerStatus checkFieldMLRequired(Publication pub, String fieldName, String value, HashMap valueML)
          This convenient method checks if the given multilingual field is required.
static ControllerStatus checkFieldRequired(Publication pub, String fieldName, Object value)
          This convenient method checks if the given field is required.
static ControllerStatus checkHtml(Map map, String field)
          Check if the values of given map of String do not contain forbidden HTML code
static ControllerStatus checkHtml(String[] array, String field)
          Check if the given array of String does not contain forbidden HTML code
static ControllerStatus checkHtml(String str, String field)
          Check if the given String does not contain forbidden HTML code.
static void checkJDBCConnection(String driver, String url, String user, String password)
          Check if the given JDBC connection can be established.
static boolean checkUrid(String urid)
          Returns true if the given urid is valid.
static String convertMultilingualFieldToXml(String mainValue, Map<String,String> valuesMap)
          Convert a multilingual field to an xml representation.
static org.jdom.Element convertMultilingualFieldToXmlElement(String mainValue, Map<String,String> valuesMap)
          Convert a multilingual field to an xml representation.
static Map<String,String> convertMultilingualFieldXmlToMap(String xml)
          Converts an xml string to an hashmap of values.
static String convertToCSV(String lang, boolean bool)
          Returns a CSV view of the given boolean value
static String convertToCSV(String lang, Object obj)
          Returns a CSV view of the given object in the given language.
static String convertToCSV(String lang, Object obj, boolean displayObjectId)
          Returns a CSV view of the given object in the specified language.
static String convertUri2Url(String text, String baseURL)
          Convert all relative URI in the given text to complete URL with the given base URL.
static Set<String> dataArrayToIdSet(Data[] datas)
          Convert a Data[] to a Set<String> composed by id
static String[] dataArrayToNameArray(Data[] datas, String lang)
          Convert a Data[] to a String[] composed of their name (label, title, name, ...)
static String[] dataArrayToStringArray(Data[] datas)
          Convert a Data[] to a String[] composed by id
static
<T extends Data>
List<String>
dataCollectionToIdList(Collection<T> dataColl)
          Returns the list of ids contained in the given collection of data.
static
<T extends Data>
Set<String>
dataCollectionToIdSet(Collection<T> dataColl)
          Returns the set of ids contained in the given collection of data.
static
<T extends Data>
String
dataListToString(Collection<T> list, String delim)
          Convert a Collection of Data into a String composed by id, separated by the specified delimiter.
static String dateSetToString(SortedSet<Date> dateSet)
          Create a new List of String time in millis from a SortedSet of Date.
static String escapeHtml(String str)
          Escape all "<" in the given String.
static Map expandArray(Map mlMap, Map main)
          This method will expand each String[] keys of a given map to a given length.
static String[] expandArray(String[] array, String[] main)
          This method will expand each String[] keys of a given map to a given length.
static void exportCSV(Set<? extends Data> dataSet, String lang, Writer writer)
          Export a dataSet to CSV
static void exportCSVIntegrityReport(Map<Data,ControllerStatus> report, String lang, Writer writer)
          Export a Data Integrity Report to CSV
static void exportCSVIntegrityReport(String lang, Writer writer)
          Export a Data Integrity Report to CSV
static Set extractExternalUrl(String text)
          Returns all the external URL contained in the given text.
static
<T extends Data>
void
fillIdCollectionWithDataCollection(Collection<String> idColl, Class<T> clazz, Collection<T> dataColl)
           
static String formatSchedule(String userLang, String schedule)
          Format a cron-like schedule.
static String getAbsDisplayUrlWithUpdatedParams(Data data, Locale locale, javax.servlet.http.HttpServletRequest request, String[] names, String[] newValues, String[] removePatterns, boolean escapeAmpersand)
          Return the absolute URL to access the given data in the front office, while updating/adding or removing a set of parameters.
static Class getClass(String className, Class defClass)
          Quietly returns the Class matching the given className or defClass if it doesn't exists.
static List<Class<?>> getClassList()
          Returns the list of the Jalios classes
static List<Class<?>> getClassList(String libDir, ClassLoader classLoader)
          Returns the list of the Jalios classes
static String getDisplayUrl()
          Return the display url of JCMS.
static String getDisplayUrl(Data data, Locale locale)
          Return the URL to access the given data in the front office.
static String getDisplayUrl(Data data, Locale locale, String params, boolean escapeAmpersand)
          Return the URL to access the given data in the front office with the added given param string.
static String getDisplayUrlWithAddedParam(Data data, Locale locale, javax.servlet.http.HttpServletRequest request, String name, String value, boolean escapeAmpersand)
          Return the URL to access the given data in the front office, while adding the given parameter.
static String getDisplayUrlWithUpdatedParams(Data data, Locale locale, javax.servlet.http.HttpServletRequest request, String[] names, String[] newValues, String[] removePatterns, boolean escapeAmpersand)
          Return the URL to access the given data in the front office, while updating/adding or removing a set of parameters.
static String getFieldLangAttributes(Data data, String fieldName, String userLang)
          Compute the real language used for the given field and retrieve the html language attributes to use for the this language.
static ObjectLongTreeMap getFileSizeMap()
          Returns the map file size for each content-type.
static ObjectLongTreeMap getFileSizeMap(Workspace ws)
          Returns the map file size for each content-type for the given workspace.
static String getFriendlyDate(Date date, int style, boolean showTime, Locale locale)
          Returns a friendly textual representation for the given date (e.g.
static String getFriendlyDate(Date date, int style, boolean showTime, Locale locale, boolean beginSentence)
          Returns a friendly textual representation for the given date (e.g.
static String getFriendlyPeriod(Date startDate, Date endDate, Locale locale)
          Returns a friendly textual representation of a time period defined by two dates.
static String getId(Data data)
          This convenient method return the id of the given data.
static FileFilter getIgnoredResourcesFileFiler()
          Retrieves a new instance of FileFilter used to skip resources that should be ignored, as defined by property "file.regexp.ignore".
static FileFilter getIgnoredResourcesFileFiler(boolean accept)
          Retrieves a new instance of FileFilter to either refuse or accept resources that should be ignored, as defined by property "file.regexp.ignore".
static String getIgnoreFileRegexp()
           
static String getIgnoreSignRegexp()
           
static String getLangAttributes(String lang)
          Retrieve the html language attributes to use for the given language.
static Map<String,String> getLangChildrenMap(org.jdom.Element elt, String childName, String info)
          Returns the map of the children of elt with their xml:lang as key.
static String[] getLanguageArray(Map map)
          Returns a String[] which contains all the values of the given map.
static Map<String,String> getLanguageMap(String propKey)
          Returns a map {lang, value} build from the given property key.
static Map<String,String> getLanguageMap(String[] values)
          Returns a map {lang, value} with the given localized values.
static List getLanguageMapList(String[] values)
          Returns a list of map {lang, value} with the given localized values.
static String getLangValue(Map map, String lang)
          Returns the localized value mapped to the given language.
static Set<Member> getMemberSetFromGroups(String[] gids)
          Return all the members represented by an Array of Group ids
static String getNewDirectory(File baseDir, String subDir)
          Returns the relative path of directory to use for the new document to be created.
static String getPrefixedTitle(String prefix, String title, boolean replaceOnly)
          Contruct a String with prefix + title or replace a $NAME$ by this prefix
static String getPubIcon(Publication pub)
          Returns the HTML code for the icon of the given publication
static String getPubImg(Publication pub)
          Returns the image of the icon of the given publication
static int[] getPublicationDetails(Class clazz, Member mbr, Workspace ws)
          Returns some statistics about a given publication type.
static String getReleasedRevision(Class clazz)
          Returns the value of static variable REVISION when it was packaged for this release.
static String getRevision(Class clazz)
          Returns the value of static variable REVISION of the given class.
static Date[] getScheduleDate(Date reference, Date targetDate, Date[] toUpdate, long schedule, boolean forward)
          Calculate loops to do between reference date and target date then apply loops on all toUpdate Dates.
static Date getScheduleDate(Date reference, Date targetDate, long schedule, boolean forward)
          Return the next schedule date after/before now (if reference date is before/after now)

If Reference 04/05/1977 and targetDate 04/08/1977 and schedule is 2 Month the method will forward to 04/09/1977.
static Date getScheduleDate(Date reference, long schedule, boolean forward)
          Return the next schedule date after/before reference date.
static int[] getScheduleModifier(long schedule, boolean forward)
          Parse schedule to return an array of modifiers for calendar roll with the given values:
modifiers[0] month
modifiers[1] weeks
modifiers[2] days
modifiers[3] hours
modifiers[4] minutes
modifiers[5] seconds
modifiers[6] millis
static TreeSet getSortedClass(Collection subTypeList, Workspace workspace, String userLang)
          Return a Set of classes of Types sorted alphabetically according to the title.
static String getUntranslatedZoneAttribute(String lang)
          Retrieve the HTML attributes to use for any HTML element surrounding feature/s which are not translated in the current user language (eg : ctx menu, glp, ...) : When the current user language is not a JCMS localization (eg: "es", "ar", ...), this variable will set the proper language and directionnality (eg lang="en" dir="ltr"), When the current user language is a valid JCMS localization (eg : "en", "fr"), this variable is an empty string.the html language attributes to use for the given language.
static TreeSet getUpdatedData(Collection old, Map dataMap)
          Convert an old set of Data to a new Set of data using a Map
static TreeSet getUpdatedData(Collection old, Map dataMap, boolean retrieveAll)
          Convert an old set of Data to a new Set of data using a Map
static Data[] getUpdatedData(Data[] old, Map dataMap)
          Convert an old array of Data to a new array of data using a Map
static String getVirtualId(String virtualId, String id)
          Retrieves the virtual id corresponding to the specified data id.
static String getVirtualIdList(String stringWithPossiblyVirtualIds, String stringOfRealIds)
          Convenient method to keep virtual id when set.
static String getWebappClasspath()
          Return the Classpath of the webapp
static String getWebHelpHome(javax.servlet.http.HttpServletRequest request)
          Returns the webhelp URI of the user's guide home page.
static String getWebHelpUri(javax.servlet.http.HttpServletRequest request, String entry)
          Returns the webhelp URI of the given entry.
static String[] getWebHelpUriAndIcon(javax.servlet.http.HttpServletRequest request, String entry, boolean home)
          Returns a String[] which contains the webhelp URI and the webhelp icon.
static int getWorkerCount()
          Returns the count of members having the worker ability.
static String getXHtmlMetaHttpEquivTag(String httpEquiv, String content)
          Generates an XHtml meta http-equiv tag (i.e.
static String getXHtmlMetaTag(String name, String content)
          Generates an XHtml meta tag (i.e.
static String getXHtmlMetaTag(String keyName, String key, String content)
          Generates a generic XHtml meta tag (key name is configurable).
static String glp(String lang, LangProperty prop)
          Resolve a language property in the given language.
static String glp(String lang, String prop, Object... params)
          Resolve a language property in the given language.
static String glpd(String prop)
          Resolve a language property in the default site language.
Warning: You should always prefer the use of 'glp' methods receiving a language parameter in order to resolve the property in the language of the end user.
static
<T extends Data>
T[]
idCollectionToDataArray(Collection<String> idColl, Class<T> clazz)
           
static
<T extends Data>
HashSet<T>
idCollectionToDataHashSet(Collection<String> idColl, Class<T> clazz)
          Returns a HashSet of Data from a Collection of data's id.
static
<T extends Data>
LinkedHashSet<T>
idCollectionToDataLinkedHashSet(Collection<String> idColl, Class<T> clazz)
          Returns a LinkedHashSet of Data from a Collection of data's id.
static
<T extends Data>
List<T>
idCollectionToDataList(Collection<String> idColl, Class<T> clazz)
          Returns a List of Data from a Collection of data's id.
static
<T extends Data>
Set<T>
idCollectionToDataSet(Collection<String> idColl, Class<T> clazz)
          Returns a Set of Data from a Collection of data's id.
static
<T extends Data>
TreeSet<T>
idCollectionToDataTreeSet(Collection<String> idColl, Class<T> clazz)
          Returns a TreeSet of Data from a Collection of data's id.
static boolean isAuthorizedToAccessStatusInfo(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
          Check if the given request is allowed to access jcms status page, (admin/admin.jsp, admin/statusXml.jsp).

This method can be called even if JCMS has not been started, as long as a valid ServletContext is given.
Valid IPs addresses are read from the file "WEB-INF/data/status.prop" the first time this method is called.
static boolean isLegalFile(String relativePath)
          Returns true if the given file is a real file under the webapp's directory but not under the WEB-INF sub-directory.
static boolean isPersisted(Data data)
          Check if the given data has been persisted (either in JStore or in the database).
static boolean isSameId(Data d1, Data d2)
          Returns true if the 2 data have the same and non null ID.
static boolean isStored(Data data)
          Check if the given data is not null and stored
static String join(Collection<? extends Data> coll, String sep, String userLang)
          Joins a collection of Object with the given separator into a String.
static String join(Iterator it, String sep, String userLang)
          Joins a collection of Object with the given separator into a String.
static void jsp2File(String jsp, String filename, HashMap sessionAttributeMap)
          Render a JSP into a File.
static void jsp2File(String jsp, String filename, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, Member loggedMember)
          Render a JSP into a File.
static void jsp2File(String jsp, String filename, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, Member loggedMember, boolean clean)
          Render a JSP into a File.
static void jsp2FileCleanTrash()
          Convenient method that clean the generated files by template engine.
static void jsp2OutputStream(String jsp, OutputStream out, HashMap sessionAttributeMap)
          Render a JSP into an OutputStream
static void jsp2OutputStream(String jsp, OutputStream out, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, Member loggedMember)
          Render a JSP into an OutputStream
static void jsp2OutputStream(String jsp, OutputStream out, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, Member loggedMember, boolean clean)
          Render a JSP into an OutputStream
static void jsp2OutputStream(String jsp, OutputStream out, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, String trashPath, String rootPath, ClassLoader classloader, String classpath)
          Render a JSP into an OutputStream
static void jsp2OutputStream(String jsp, OutputStream out, HashMap requestParameterMap, HashMap requestAttributeMap, HashMap sessionAttributeMap, HashMap contextAttributeMap, HashMap initParameterMap, String trashPath, String rootPath, ClassLoader classloader, String classpath, boolean clean)
          Render a JSP into an OutputStream
static void logForbiddenAccess(javax.servlet.http.HttpServletRequest request)
          Log a forbidden message to the given request, at the WARN level using the JcmsUtil logger.
static void logForbiddenAccess(org.apache.log4j.Logger lgr, javax.servlet.http.HttpServletRequest request)
          Log a forbidden message to the given request, at the WARN level using the given logger.
static void logForbiddenAccess(org.apache.log4j.Logger lgr, org.apache.log4j.Level level, javax.servlet.http.HttpServletRequest request)
          Log a forbidden access message (using the logSecurityIssue method) A forbidden acces to the jsp http://www.mysite.com/admin.jsp, with a pattern layout "%x %m", would output: [SECURITY] Forbidden access to http://www.mysite.com/admin.jsp
static void logSecurityIssue(org.apache.log4j.Logger lgr, org.apache.log4j.Level level, Object obj)
          Log the given message (object), at a the given level, with the constant JcmsConstants.LOG_TOPIC_SECURITY as a log4j NDC using the given logger.
static void logSecurityIssue(org.apache.log4j.Logger lgr, Object obj)
          Log the given message (object), at a the WARN level using the given logger.
static void logSecurityIssue(Object obj)
          Log the given message (object), at a the WARN level using the JcmsUtil logger.
static int loopScheduleDate(Calendar refCal, Calendar nowCal, int[] modifiers, boolean forward)
          Loop the reference calendar
static int loopScheduleDate(Calendar refCal, int[] modifiers, boolean forward, int maxloop)
          Loop the reference calendar
static void mergeMLMap(Map mlCopy, Map mlMain)
          Merges a multilingual (ML) map of a work copy with the corresponding ML map of its main instance.
static String parseSchedule(String schedule, String period, String lang)
          Parse the JCMS schedules
static void restartWebapp(File file)
           
static
<T> TreeSet<T>
select(Collection<? extends T> dataColl, DataSelector selector, Comparator comparator)
          Perform a selection on a Collection of Data using the given DataSelector, and return a TreeSet sorted using the given Comparator.
static void setDataWriteDisabledMsg(javax.servlet.http.HttpServletRequest request, String userLang)
           
static void setLog4jMDC()
          Initialize log4j MDC variables for the current thread.
static void setLog4jNDCMemberInfo(javax.servlet.http.HttpServletRequest request, Member loggedMember)
          Initialize log4j NDC with the given logged member information.
static
<T extends Data>
T[]
stringArrayToDataArray(Class<T> clazz, String[] ids)
          Convert a Data[] to a String[] composed by id
static Data[] stringArrayToDataArray(String[] ids)
          Convert a Data[] to a String[] composed by id
static List<Data> stringToDataList(String str, String delim)
          Convert a String of Data ids into a List of Data.
static
<T extends Data>
List<T>
stringToDataList(String str, String delim, Class<T> clazz)
          Convert a String of Data ids into a List of Data.
static SortedSet<Date> stringToDateSet(String timesString)
          Create a new SortedSet of Date from a comma seperated time in millisecond.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

DUPLICATE_PREFIX

public static final org.apache.oro.text.regex.Pattern DUPLICATE_PREFIX
Constructor Detail

JcmsUtil

public JcmsUtil()
Method Detail

isLegalFile

public static boolean isLegalFile(String relativePath)
Returns true if the given file is a real file under the webapp's directory but not under the WEB-INF sub-directory.

Parameters:
relativePath - the path to be tested
Returns:
true if the given file is a real file under the webapp's directory but not under the WEB-INF sub-directory.

convertToCSV

public static String convertToCSV(String lang,
                                  boolean bool)
Returns a CSV view of the given boolean value

Parameters:
lang - the language of the output
bool - the boolean value
Returns:
a CSV view of the given boolean value
Since:
jcms-5.7.0

convertToCSV

public static String convertToCSV(String lang,
                                  Object obj)
Returns a CSV view of the given object in the given language.

Parameters:
lang - the language of the output
obj - the object
Returns:
a CSV view of the given object
Since:
jcms-5.7.0

convertToCSV

public static String convertToCSV(String lang,
                                  Object obj,
                                  boolean displayObjectId)
Returns a CSV view of the given object in the specified language.

Parameters:
lang - the language of the output
obj - the object
displayObjectId - if true, the object's id will be appended to the data's name.
Returns:
a CSV view of the given object

exportCSV

public static void exportCSV(Set<? extends Data> dataSet,
                             String lang,
                             Writer writer)
Export a dataSet to CSV

Parameters:
dataSet - the set of data to be exported
lang - the language
writer - the writer where to print the export
Since:
jcms-5.0.0

exportCSVIntegrityReport

public static void exportCSVIntegrityReport(String lang,
                                            Writer writer)
Export a Data Integrity Report to CSV

Parameters:
lang - the language
writer - the writer where to print the export
Since:
jcms-5.5.0

exportCSVIntegrityReport

public static void exportCSVIntegrityReport(Map<Data,ControllerStatus> report,
                                            String lang,
                                            Writer writer)
Export a Data Integrity Report to CSV

Parameters:
report - the report to be exported
lang - the language
writer - the writer where to print the export
Since:
jcms-5.5.0

getSortedClass

public static TreeSet getSortedClass(Collection subTypeList,
                                     Workspace workspace,
                                     String userLang)
Return a Set of classes of Types sorted alphabetically according to the title. Two classes with the same label are sorted with the technical name of the java class. Labels are localized according the given language.

Parameters:
subTypeList - the collection that contain Class
workspace - the workspace used to get the label associated to the class.
userLang - the current language of the user logged
Returns:
a Map Label/Class of Types sorted alphabetically.

getClass

public static Class getClass(String className,
                             Class defClass)
Quietly returns the Class matching the given className or defClass if it doesn't exists.

Parameters:
className - the name of the class
defClass - the default class if class name do not match
Returns:
Class the matching class

getMemberSetFromGroups

public static Set<Member> getMemberSetFromGroups(String[] gids)
Return all the members represented by an Array of Group ids

Parameters:
gids -
Returns:
Set of Member

stringToDataList

public static List<Data> stringToDataList(String str,
                                          String delim)
Convert a String of Data ids into a List of Data.

Parameters:
str - of id seperated with specified delimiter ie.
delim - a delimiter (required, no default value is used)
Returns:
List a list of Data, never return null.
Since:
jcms-4.0
See Also:
to perform the opposite operation, for generic method

stringToDataList

public static <T extends Data> List<T> stringToDataList(String str,
                                                        String delim,
                                                        Class<T> clazz)
Convert a String of Data ids into a List of Data.

Type Parameters:
T - any type of Data to retrieve
Parameters:
str - of id seperated with specified delimiter ie.
delim - a delimiter (required, no default value is used)
clazz - the Class of object to retrieve
Returns:
List a list of Data, never return null.
Since:
jcms-6.0
See Also:
to perform the opposite operation

dataListToString

public static <T extends Data> String dataListToString(Collection<T> list,
                                                       String delim)
Convert a Collection of Data into a String composed by id, separated by the specified delimiter.

Example :

 List<Data> list = new ArrayList<Data>();
 list.add(channel.getDefaultAdmin());
 list.add(channel.getDefaultGroup());
 String ids = dataListToString(list, ",");
 
will return the following string : "j2,j_36"

Type Parameters:
T - any class extending Data
Parameters:
list - a Collection of Data
delim - a delimiter (required, no default value is used)
Returns:
String a string of id seperated with specified delimiter ie.
Since:
jcms-4.0
See Also:
to perform the opposite operation

dataArrayToNameArray

public static String[] dataArrayToNameArray(Data[] datas,
                                            String lang)
Convert a Data[] to a String[] composed of their name (label, title, name, ...)

Parameters:
datas - Data[] an array of data to convert
lang - the ISO-639 language code to be used to retrieve the localized Data's name
Returns:
String[] an array of labels
Since:
jcms-5.7.0

dataArrayToStringArray

public static String[] dataArrayToStringArray(Data[] datas)
Convert a Data[] to a String[] composed by id

Parameters:
datas - Data[] an array of data to convert
Returns:
String[] an array of ids
Since:
jcms-5.0

stringArrayToDataArray

public static Data[] stringArrayToDataArray(String[] ids)
Convert a Data[] to a String[] composed by id

Parameters:
ids - an array of ids
Returns:
String[]
Since:
jcms-5.0

stringArrayToDataArray

public static <T extends Data> T[] stringArrayToDataArray(Class<T> clazz,
                                                          String[] ids)
Convert a Data[] to a String[] composed by id

Parameters:
ids - an array of ids
Returns:
String[]
Since:
jcms-5.0

dataCollectionToIdSet

public static <T extends Data> Set<String> dataCollectionToIdSet(Collection<T> dataColl)
Returns the set of ids contained in the given collection of data.

Parameters:
dataColl - a collection of Data
Returns:
the set of ids contained in the given collection of data (never return null).
Since:
jcms-6.0.0
See Also:
to perform the opposite operation

dataCollectionToIdList

public static <T extends Data> List<String> dataCollectionToIdList(Collection<T> dataColl)
Returns the list of ids contained in the given collection of data.

Parameters:
dataColl - a collection of Data
Returns:
the list of ids contained in the given collection of data (never return null).
Since:
jcms-6.1.0
See Also:
to perform the opposite operation

dataArrayToIdSet

public static Set<String> dataArrayToIdSet(Data[] datas)
Convert a Data[] to a Set<String> composed by id

Parameters:
datas - Data[] an array of data to convert
Returns:
the set of ids contained in the given array of data (never return null).
Since:
jcms-6.1.0
See Also:
to perform the opposite operation

idCollectionToDataSet

public static <T extends Data> Set<T> idCollectionToDataSet(Collection<String> idColl,
                                                            Class<T> clazz)
Returns a Set of Data from a Collection of data's id.

Type Parameters:
T - any type of Data to retrieve
Parameters:
idColl - a Collection of data id
clazz - the Class of object to retrieve
Returns:
a new Set of Data (never return null).
Since:
jcms-6.1.0
See Also:
to perform the opposite operation

idCollectionToDataLinkedHashSet

public static <T extends Data> LinkedHashSet<T> idCollectionToDataLinkedHashSet(Collection<String> idColl,
                                                                                Class<T> clazz)
Returns a LinkedHashSet of Data from a Collection of data's id.

Type Parameters:
T - any type of Data to retrieve
Parameters:
idColl - a Collection of data id
clazz - the Class of object to retrieve
Returns:
a new LinkedHashSet of Data (never return null).
Since:
jcms-6.2.0
See Also:
to perform the opposite operation

idCollectionToDataTreeSet

public static <T extends Data> TreeSet<T> idCollectionToDataTreeSet(Collection<String> idColl,
                                                                    Class<T> clazz)
Returns a TreeSet of Data from a Collection of data's id.

Type Parameters:
T - any type of Data to retrieve
Parameters:
idColl - a Collection of data id
clazz - the Class of object to retrieve
Returns:
a new TreeSet of Data (never return null).
Since:
jcms-6.2.0
See Also:
to perform the opposite operation

idCollectionToDataHashSet

public static <T extends Data> HashSet<T> idCollectionToDataHashSet(Collection<String> idColl,
                                                                    Class<T> clazz)
Returns a HashSet of Data from a Collection of data's id.

Type Parameters:
T - any type of Data to retrieve
Parameters:
idColl - a Collection of data id
clazz - the Class of object to retrieve
Returns:
a new HashSet of Data (never return null).
Since:
jcms-6.2.0
See Also:
to perform the opposite operation

idCollectionToDataList

public static <T extends Data> List<T> idCollectionToDataList(Collection<String> idColl,
                                                              Class<T> clazz)
Returns a List of Data from a Collection of data's id.

Type Parameters:
T - any type of Data to retrieve
Parameters:
idColl - a Collection of data id
clazz - the Class of object to retrieve
Returns:
a new List of Data (never return null).
Since:
jcms-6.1.0
See Also:
to perform the opposite operation

fillIdCollectionWithDataCollection

public static <T extends Data> void fillIdCollectionWithDataCollection(Collection<String> idColl,
                                                                       Class<T> clazz,
                                                                       Collection<T> dataColl)

idCollectionToDataArray

public static <T extends Data> T[] idCollectionToDataArray(Collection<String> idColl,
                                                           Class<T> clazz)

join

public static String join(Collection<? extends Data> coll,
                          String sep,
                          String userLang)
Joins a collection of Object with the given separator into a String. Uses the getDataName(userLang) method for each iterated Data.

Parameters:
coll - the collection
sep - the separator
userLang - the ISO-639 language code to be used to retrieve localized titles
Returns:
a String which contains all the iterated objects.
Since:
jcms-4.0
See Also:
Util.join(Iterator,String,int,String)

join

public static String join(Iterator it,
                          String sep,
                          String userLang)
Joins a collection of Object with the given separator into a String. Uses the getDataName(userLang) method for each iterated Data.

Parameters:
it - the iterator of the collection
sep - the separator
userLang - the ISO-639 language code to be used to retrieve localized titles
Returns:
a String which contains all the iterated objects.
Since:
jcms-4.0
See Also:
Util.join(Iterator,String,int,String)

expandArray

public static Map expandArray(Map mlMap,
                              Map main)
This method will expand each String[] keys of a given map to a given length.

Parameters:
mlMap - Map of key / String[]
main - Map of key / String[] used to calculate String[] length
Returns:
Map the modified mlMap

expandArray

public static String[] expandArray(String[] array,
                                   String[] main)
This method will expand each String[] keys of a given map to a given length.

Parameters:
array - String[]
main - String[] used to calculate String[] length
Returns:
String[] a copy of the orifgianl array

getScheduleDate

public static Date getScheduleDate(Date reference,
                                   long schedule,
                                   boolean forward)
Return the next schedule date after/before reference date.

If Reference 04/05/1977 and schedule is 2 Month the method will forward to 04/07/1977 If Reference 04/05/1977 and schedule is 2 Month the method will backward to 04/03/1977

Parameters:
reference - the reference starting date
forward - forward to now or backward before now
schedule - the time to add to reference date.
Returns:
the next schedule Date, never return null

getScheduleDate

public static Date getScheduleDate(Date reference,
                                   Date targetDate,
                                   long schedule,
                                   boolean forward)
Return the next schedule date after/before now (if reference date is before/after now)

If Reference 04/05/1977 and targetDate 04/08/1977 and schedule is 2 Month the method will forward to 04/09/1977.

Parameters:
reference - the reference starting date
targetDate - the target date
schedule - the time to add to reference date.
forward - should forward or backward to targetDate
Returns:
the next schedule Date, never return null

getScheduleDate

public static Date[] getScheduleDate(Date reference,
                                     Date targetDate,
                                     Date[] toUpdate,
                                     long schedule,
                                     boolean forward)
Calculate loops to do between reference date and target date then apply loops on all toUpdate Dates.
long l1 is a schedule to apply Date d1 is a schedule date Date d2 is now Date d3 and d4 are dates to loop on.
This method first calculate the quantity of schedule between d1 and d2 then apply this loop on d3 and d4.

Parameters:
reference - the reference starting date
targetDate - the target date
toUpdate - the date to update
schedule - the time to add to reference date.
forward - should forward or backward to targetDate

loopScheduleDate

public static int loopScheduleDate(Calendar refCal,
                                   Calendar nowCal,
                                   int[] modifiers,
                                   boolean forward)
Loop the reference calendar

Parameters:
refCal - the reference starting calendar
nowCal - the target calendar
modifiers - the modifier provides by getScheduleModifier()
forward - should forward or backward to targetDate
Returns:
the number of iteration

loopScheduleDate

public static int loopScheduleDate(Calendar refCal,
                                   int[] modifiers,
                                   boolean forward,
                                   int maxloop)
Loop the reference calendar

Parameters:
refCal - the reference starting calendar
modifiers - the modifier provides by getScheduleModifier()
forward - should forward or backward to targetDate
maxloop - the loop to do or -1
Returns:
the number of iteration

getScheduleModifier

public static int[] getScheduleModifier(long schedule,
                                        boolean forward)
Parse schedule to return an array of modifiers for calendar roll with the given values:
modifiers[0] month
modifiers[1] weeks
modifiers[2] days
modifiers[3] hours
modifiers[4] minutes
modifiers[5] seconds
modifiers[6] millis

Parameters:
schedule - the time to add to reference date.
forward - should forward or backward to targetDate

parseSchedule

public static String parseSchedule(String schedule,
                                   String period,
                                   String lang)
Parse the JCMS schedules

Since:
jcms-5.7.0

formatSchedule

public static String formatSchedule(String userLang,
                                    String schedule)
Format a cron-like schedule. Example : schedule 30 20 * * 3 * will be formatted as Every Tuesday at 8:30 PM.

Parameters:
userLang - the user language
schedule - the cron schedule to be formatted.
Returns:
a localized description of the schedule
Since:
jcms-5.5.0

stringToDateSet

public static SortedSet<Date> stringToDateSet(String timesString)
Create a new SortedSet of Date from a comma seperated time in millisecond.

Parameters:
timesString - a String with comma sperated times in millissecond
Returns:
a new SortedSet, never return null.
Since:
jcms-6.1.0

dateSetToString

public static String dateSetToString(SortedSet<Date> dateSet)
Create a new List of String time in millis from a SortedSet of Date.

Parameters:
dateSet - a SortedSet of Date.
Returns:
a new String, never return null.
Since:
jcms-6.1.0

getWebappClasspath

public static String getWebappClasspath()
Return the Classpath of the webapp

Returns:
String

getIgnoredResourcesFileFiler

public static FileFilter getIgnoredResourcesFileFiler()
Retrieves a new instance of FileFilter used to skip resources that should be ignored, as defined by property "file.regexp.ignore".

Current implementation uses a reversed file filter of a regexp file filer. If the regexp defined by the property could not be compiled, a warning message is logged and a TrueFileFilter (accepting all files) is returned.

Returns:
a new instance of FileFilter, never return null.
Since:
jcms-5.7.3
See Also:
getIgnoredResourcesFileFiler(boolean)

getIgnoredResourcesFileFiler

public static FileFilter getIgnoredResourcesFileFiler(boolean accept)
Retrieves a new instance of FileFilter to either refuse or accept resources that should be ignored, as defined by property "file.regexp.ignore".

If accept parameter is set to false, uses a reversed file filter of a regexp file filer.
If the regexp defined by the property could not be compiled, a warning message is logged and a TrueFileFilter (accepting all files) is returned.

Parameters:
accept - true to accept ignored Files and refuse all other, false to refuse ignored Files and accept all others.
Returns:
a new instance of FileFilter, never return null.
Since:
jcms-5.7.3

getPrefixedTitle

public static String getPrefixedTitle(String prefix,
                                      String title,
                                      boolean replaceOnly)
Contruct a String with prefix + title or replace a $NAME$ by this prefix

Parameters:
prefix - the prefix to append
title -
Returns:
the String correctly formated
Since:
jcms-4.1

jsp2File

public static void jsp2File(String jsp,
                            String filename,
                            HashMap sessionAttributeMap)
                     throws Exception
Render a JSP into a File.

Parameters:
jsp - the JSP to be rendered. It must start with "/".
filename - the output file where the jsp process is written
sessionAttributeMap - the session attributes
Throws:
Exception

jsp2File

public static void jsp2File(String jsp,
                            String filename,
                            HashMap requestParameterMap,
                            HashMap requestAttributeMap,
                            HashMap sessionAttributeMap,
                            HashMap contextAttributeMap,
                            HashMap initParameterMap,
                            Member loggedMember)
                     throws Exception
Render a JSP into a File.

Parameters:
jsp - the JSP to be rendered. It must start with "/".
filename - the output file where the jsp process is written
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
loggedMember - the logged member used to process the JSP
Throws:
Exception

jsp2File

public static void jsp2File(String jsp,
                            String filename,
                            HashMap requestParameterMap,
                            HashMap requestAttributeMap,
                            HashMap sessionAttributeMap,
                            HashMap contextAttributeMap,
                            HashMap initParameterMap,
                            Member loggedMember,
                            boolean clean)
                     throws Exception
Render a JSP into a File.

Parameters:
jsp - the JSP to be rendered. It must start with "/".
filename - the output file where the jsp process is written
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
loggedMember - the logged member used to process the JSP
clean - if true the compiled servlet is removed once processed.
Throws:
Exception
Since:
jcms-4.0

jsp2OutputStream

public static void jsp2OutputStream(String jsp,
                                    OutputStream out,
                                    HashMap sessionAttributeMap)
                             throws Exception
Render a JSP into an OutputStream

Parameters:
jsp - the JSP to be rendered. It must start with "/".
out - the outputstream
sessionAttributeMap - the session attributes
Throws:
Exception

jsp2OutputStream

public static void jsp2OutputStream(String jsp,
                                    OutputStream out,
                                    HashMap requestParameterMap,
                                    HashMap requestAttributeMap,
                                    HashMap sessionAttributeMap,
                                    HashMap contextAttributeMap,
                                    HashMap initParameterMap,
                                    Member loggedMember)
                             throws Exception
Render a JSP into an OutputStream

Parameters:
jsp - the JSP to be rendered. It must start with "/".
out - the outputstream
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
loggedMember - the logged member used to process the JSP
Throws:
Exception

jsp2OutputStream

public static void jsp2OutputStream(String jsp,
                                    OutputStream out,
                                    HashMap requestParameterMap,
                                    HashMap requestAttributeMap,
                                    HashMap sessionAttributeMap,
                                    HashMap contextAttributeMap,
                                    HashMap initParameterMap,
                                    Member loggedMember,
                                    boolean clean)
                             throws Exception
Render a JSP into an OutputStream

Parameters:
jsp - the JSP to be rendered. It must start with "/".
out - the outputstream
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
loggedMember - the logged member used to process the JSP
clean - if true the compiled servlet is removed once processed.
Throws:
Exception
Since:
jcms-4.0

jsp2OutputStream

public static void jsp2OutputStream(String jsp,
                                    OutputStream out,
                                    HashMap requestParameterMap,
                                    HashMap requestAttributeMap,
                                    HashMap sessionAttributeMap,
                                    HashMap contextAttributeMap,
                                    HashMap initParameterMap,
                                    String trashPath,
                                    String rootPath,
                                    ClassLoader classloader,
                                    String classpath)
                             throws Exception
Render a JSP into an OutputStream

Parameters:
jsp - the JSP to be rendered. It must start with "/".
out - the outputstream
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
trashPath -
rootPath -
classloader -
classpath -
Throws:
Exception

jsp2OutputStream

public static void jsp2OutputStream(String jsp,
                                    OutputStream out,
                                    HashMap requestParameterMap,
                                    HashMap requestAttributeMap,
                                    HashMap sessionAttributeMap,
                                    HashMap contextAttributeMap,
                                    HashMap initParameterMap,
                                    String trashPath,
                                    String rootPath,
                                    ClassLoader classloader,
                                    String classpath,
                                    boolean clean)
                             throws Exception
Render a JSP into an OutputStream

Parameters:
jsp - the JSP to be rendered. It must start with "/".
out - the outputstream
requestParameterMap - the request parameters
requestAttributeMap - the request attributes
sessionAttributeMap - the session attributes
contextAttributeMap - the context attributes
initParameterMap - the init parameters
trashPath -
rootPath -
classloader -
classpath -
clean - if true the compiled servlet is removed once processed.
Throws:
Exception

jsp2FileCleanTrash

public static void jsp2FileCleanTrash()
Convenient method that clean the generated files by template engine. Use before multiple jsp2file ....


restartWebapp

public static void restartWebapp(File file)

escapeHtml

public static String escapeHtml(String str)
Escape all "<" in the given String.

Parameters:
str - the string to be escaped
Returns:
the escaped string
Since:
jcms-5.0.0

checkHtml

public static ControllerStatus checkHtml(String str,
                                         String field)
Check if the given String does not contain forbidden HTML code. Checks with channel.forbidden-html regexp, then delegates to custom.RightPolicy.checkHtml().

Parameters:
str - the string to be checked
field - the name of the field which is checked
Returns:
a ControllerStatus
Since:
jcms-5.0.0
See Also:
BasicRightPolicyFilter.checkHtml(String,String)

checkHtml

public static ControllerStatus checkHtml(String[] array,
                                         String field)
Check if the given array of String does not contain forbidden HTML code

Parameters:
array - the array of string to be checked
field - the name of the field which is checked
Returns:
a ControllerStatus
Since:
jcms-5.0.0
See Also:
checkHtml(String,String)

checkHtml

public static ControllerStatus checkHtml(Map map,
                                         String field)
Check if the values of given map of String do not contain forbidden HTML code

Parameters:
map - the map with the values to be checked
field - the name of the field which is checked
Returns:
a ControllerStatus
Since:
jcms-5.0.0
See Also:
checkHtml(String,String)

getUpdatedData

public static Data[] getUpdatedData(Data[] old,
                                    Map dataMap)
Convert an old array of Data to a new array of data using a Map

Parameters:
old -
dataMap -
Returns:
a Data[] updated

getUpdatedData

public static TreeSet getUpdatedData(Collection old,
                                     Map dataMap,
                                     boolean retrieveAll)
Convert an old set of Data to a new Set of data using a Map

Parameters:
old - the old set of data
dataMap - the map
retrieveAll - if newdata doesn't exists then leave old data
Returns:
a Set of Data updated

getUpdatedData

public static TreeSet getUpdatedData(Collection old,
                                     Map dataMap)
Convert an old set of Data to a new Set of data using a Map

Parameters:
old - the old set of data
dataMap - the map
Returns:
a Set of Data updated
See Also:
getUpdatedData(Collection, Map, boolean)

checkFieldMLRequired

public static ControllerStatus checkFieldMLRequired(Publication pub,
                                                    String fieldName,
                                                    String value,
                                                    HashMap valueML)
This convenient method checks if the given multilingual field is required.

Parameters:
pub - the publication
fieldName - the name of the field
value - the value of the field
valueML - the ML value of the field
Returns:
a ControllerStatus
Since:
jcms-6.1.2

checkFieldRequired

public static ControllerStatus checkFieldRequired(Publication pub,
                                                  String fieldName,
                                                  Object value)
This convenient method checks if the given field is required.

Parameters:
pub - the publication
fieldName - the name of the field
value - the value of the field
Returns:
a ControllerStatus
Since:
jcms-6.1.2

glpd

public static String glpd(String prop)
Resolve a language property in the default site language.
Warning: You should always prefer the use of 'glp' methods receiving a language parameter in order to resolve the property in the language of the end user.

Parameters:
prop - the language property to resolve, for example "ui.com.lbl.contents"
Returns:
the resolved property
Since:
jcms-5.5.0

glp

public static String glp(String lang,
                         String prop,
                         Object... params)
Resolve a language property in the given language.

Example :

  String i18nStr = JcmsUtil.glp("ui.com.lbl.byte", "en", 6);
 

Parameters:
lang - the language in which you want the given property
prop - the language property to resolve, for example "ui.com.lbl.contents"
params - an array of parameters to use to for the format of property
Returns:
the resolved property
Since:
jcms-5.0.0

glp

public static String glp(String lang,
                         LangProperty prop)
Resolve a language property in the given language.

Parameters:
lang - the language in which you want the given property
prop - the LangProperty instance corresponding to the property you want to resolve.
Returns:
the resolved property
Since:
jcms-5.5.0

setLog4jMDC

public static void setLog4jMDC()
Initialize log4j MDC variables for the current thread.
  • {ChannelName} => current site name

  • setLog4jNDCMemberInfo

    public static void setLog4jNDCMemberInfo(javax.servlet.http.HttpServletRequest request,
                                             Member loggedMember)
    Initialize log4j NDC with the given logged member information.
    This methods also logs the current delegate Member when available (Channel.getCurrentDelegateMember()].

    Parameters:
    request - the current HttpServletRequest
    loggedMember - the Member currently logged

    logForbiddenAccess

    public static void logForbiddenAccess(org.apache.log4j.Logger lgr,
                                          org.apache.log4j.Level level,
                                          javax.servlet.http.HttpServletRequest request)
    Log a forbidden access message (using the logSecurityIssue method) A forbidden acces to the jsp http://www.mysite.com/admin.jsp, with a pattern layout "%x %m", would output: [SECURITY] Forbidden access to http://www.mysite.com/admin.jsp

    Parameters:
    lgr - the logger to use
    level - the level of the log message
    request - the request where the forbidden is issued from
    Since:
    jcms-5.0.0

    logForbiddenAccess

    public static void logForbiddenAccess(org.apache.log4j.Logger lgr,
                                          javax.servlet.http.HttpServletRequest request)
    Log a forbidden message to the given request, at the WARN level using the given logger.

    See Also:
    logForbiddenAccess(Logger lgr, Level level, HttpServletRequest request)

    logForbiddenAccess

    public static void logForbiddenAccess(javax.servlet.http.HttpServletRequest request)
    Log a forbidden message to the given request, at the WARN level using the JcmsUtil logger.

    See Also:
    logForbiddenAccess(Logger lgr, Level level, HttpServletRequest request)

    logSecurityIssue

    public static void logSecurityIssue(org.apache.log4j.Logger lgr,
                                        org.apache.log4j.Level level,
                                        Object obj)
    Log the given message (object), at a the given level, with the constant JcmsConstants.LOG_TOPIC_SECURITY as a log4j NDC using the given logger. The output with a pattern layout "%x %m" would be : [SECURITY] message

    Parameters:
    lgr - the logger to use
    level - the level of the log message
    obj - the object (message) to log
    Since:
    jcms-5.0.0

    logSecurityIssue

    public static void logSecurityIssue(org.apache.log4j.Logger lgr,
                                        Object obj)
    Log the given message (object), at a the WARN level using the given logger.

    See Also:
    logSecurityIssue(Logger lgr, Level level, Object obj)

    logSecurityIssue

    public static void logSecurityIssue(Object obj)
    Log the given message (object), at a the WARN level using the JcmsUtil logger.

    See Also:
    logSecurityIssue(Logger lgr, Level level, Object obj)

    getPubImg

    public static String getPubImg(Publication pub)
    Returns the image of the icon of the given publication

    Parameters:
    pub - the publication
    Returns:
    the relative path of the icon or null if no icon
    Since:
    jcms-5.0.1

    getPubIcon

    public static String getPubIcon(Publication pub)
    Returns the HTML code for the icon of the given publication

    Parameters:
    pub - the publication
    Returns:
    the html code of the image or null if no icon
    Since:
    jcms-5.0.1

    isStored

    public static boolean isStored(Data data)
    Check if the given data is not null and stored

    Parameters:
    data - the data to be checked
    Returns:
    true if data is not null and stored.
    Since:
    jcms-5.0.2

    isPersisted

    public static boolean isPersisted(Data data)
    Check if the given data has been persisted (either in JStore or in the database).

    Parameters:
    data - the data to be checked
    Returns:
    true if data is not null and has been persisted.
    Since:
    jcms-6.1.0

    select

    public static <T> TreeSet<T> select(Collection<? extends T> dataColl,
                                        DataSelector selector,
                                        Comparator comparator)
    Perform a selection on a Collection of Data using the given DataSelector, and return a TreeSet sorted using the given Comparator.
    If no Comparator is given, CdateComparator is used.

    Parameters:
    dataColl - the Collection of Data to select.
    selector - the DataSelector to use.
    comparator - the Comparator to use.
    Returns:
    a NEW or CLONED TreeSet of Data.
    Since:
    jcms-5.5.0

    applyDataSelector

    public static Collection applyDataSelector(Collection dataColl,
                                               DataSelector selector)
    Apply given DataSelector by removing non selected Data from the given Collection.
    This method DOES NOT create any new Collection, modify the existing one.

    Parameters:
    dataColl - a Collection of Data from which to remove non selected data.
    selector - the DataSelector to apply
    Returns:
    the SAME Collection that was given but modified.
    Since:
    jcms-5.5.0

    mergeMLMap

    public static void mergeMLMap(Map mlCopy,
                                  Map mlMain)
    Merges a multilingual (ML) map of a work copy with the corresponding ML map of its main instance.

    Parameters:
    mlCopy - A ML map of the work copy
    mlMain - A ML map of the main instance
    Since:
    jcms-5.5.0

    getLangValue

    public static String getLangValue(Map map,
                                      String lang)
    Returns the localized value mapped to the given language.

    Parameters:
    map - the language map {lang, value}
    lang - the language. If null use the main language. If result null, use an arbitrary one.
    Returns:
    the localized value mapped to the given language.
    Since:
    jcms-5.7.0

    getLanguageMap

    public static Map<String,String> getLanguageMap(String[] values)
    Returns a map {lang, value} with the given localized values.

    Parameters:
    values - the values sorted according the language list.
    Returns:
    a map {lang, value} with the given localized values.
    Since:
    jcms-5.7.0

    getLanguageMap

    public static Map<String,String> getLanguageMap(String propKey)
    Returns a map {lang, value} build from the given property key.

    Parameters:
    propKey - the property key
    Returns:
    a map {lang, value} build from the given property key.
    Since:
    jcms-5.7.0

    getLanguageMapList

    public static List getLanguageMapList(String[] values)
    Returns a list of map {lang, value} with the given localized values. Example : getLanguageMapList(new String[] {"english1", "french1", "english2", "french2"}) returns a list of 2 maps : m1: ({en, english1} {fr, french1}) and m2: ({en, english2} {fr, french2})

    Parameters:
    values - the values sorted according the order then according the language list.
    Returns:
    a list of map {lang, value} with the given localized values.
    Since:
    jcms-5.7.0

    getLanguageArray

    public static String[] getLanguageArray(Map map)
    Returns a String[] which contains all the values of the given map.

    Parameters:
    map - the language map {lang, value}
    Returns:
    a String[] which contains all the values of the given map.
    Since:
    jcms-5.7.0

    addData

    public static void addData(TreeSet set,
                               Class clazz,
                               Data data)
    This methods adds the given data to the given set if this data is an instance of the given class. It is mainly used by Publication.getLinkDataSet().

    Parameters:
    set - the Set
    clazz - the class used to filter data
    data - the data to be added
    Since:
    jcms-5.0.3

    addData

    public static void addData(TreeSet set,
                               Class clazz,
                               Data[] array)
    This methods adds data from an array to the given set if the data is an instance of the given class. It is mainly used by Publication.getLinkDataSet().

    Parameters:
    set - the Set
    clazz - the class used to filter data
    array - the array of data to be added
    Since:
    jcms-5.0.3

    addData

    public static void addData(TreeSet set,
                               Class clazz,
                               Collection coll)
    This methods adds data from a collection to the given set if the data is an instance of the given class. It is mainly used by Publication.getLinkDataSet().

    Parameters:
    set - the Set
    clazz - the class used to filter data
    coll - the collection of data to be added
    Since:
    jcms-5.7.0

    addData

    public static void addData(TreeSet set,
                               Class clazz,
                               Map mlMap)
    This methods adds data from a ML Map to the given set if the data is an instance of the given class. It is mainly used by Publication.getLinkDataSet().

    Parameters:
    set - the Set
    clazz - the class used to filter data
    mlMap - the ML map of data to be added
    Since:
    jcms-5.7.0

    addFileDocument

    public static void addFileDocument(Set<FileDocument> set,
                                       String filename)
    Adds the FileDocument bound to the given filename in the given set.

    Parameters:
    set - a set of FileDocument
    filename - the filename
    Since:
    jcms-6.0.1

    addFileDocument

    public static void addFileDocument(Set<FileDocument> set,
                                       String... filenames)
    Adds the FileDocuments bound to the given filename array in the given set.

    Parameters:
    set - a set of FileDocument
    filenames - an array of filename
    Since:
    jcms-6.0.1

    addFileDocument

    public static void addFileDocument(Set<FileDocument> set,
                                       String filenameMainLanguage,
                                       Map<String,String> mlMap)
    Adds the FileDocuments bound to the given filename and to the filename contains as value of mlMap in the given set.

    Parameters:
    set - a set of FileDocument
    filenameMainLanguage - a filename
    mlMap - a map which contains filename as values
    Since:
    jcms-6.0.1

    addFileDocument

    public static void addFileDocument(Set<FileDocument> set,
                                       String[] filenamesMainLanguage,
                                       Map<String,String[]> mlMap)
    Adds the FileDocuments bound to the given array of filename and to the array of filename contains as value of mlMap in the given set.

    Parameters:
    set - a set of FileDocument
    filenamesMainLanguage - an array of filename
    mlMap - a map which contains array of filename as values
    Since:
    jcms-6.0.1

    getId

    public static String getId(Data data)
    This convenient method return the id of the given data.

    Parameters:
    data - the data (may be null)
    Returns:
    the id of the data or null if the given data is null.
    Since:
    jcms-6.0.0

    isSameId

    public static boolean isSameId(Data d1,
                                   Data d2)
    Returns true if the 2 data have the same and non null ID.

    Parameters:
    d1 - the first data
    d2 - the second data
    Returns:
    true if the 2 data have the same and non null ID.
    Since:
    jcms-6.1.0

    getFieldLangAttributes

    public static String getFieldLangAttributes(Data data,
                                                String fieldName,
                                                String userLang)
    Compute the real language used for the given field and retrieve the html language attributes to use for the this language.

    For example given this SmallNews:
    English ("en")Arabic ("ar")
    Introduction ("intro")an introduction
    Content ("content")some contentألف
    If you want to display the introduction in arabic, because the field is only available in english, this will return the english language attribute:
    getFieldLangAttributes(theSmallNews, "intro", userLang); // userLang='ar'
    returns lang="en" xml:lang="en" dir="ltr".

    But if you want to display the content, it is available in the userLanguage and therefore will return the arabic language attributes:
    getFieldLangAttributes(theSmallNews, "content", userLang); // userLang='ar'
    returns lang="ar" xml:lang="ar" dir="rtl".
    BUT because the userLang is already used to define lang attributes of the html page, if the real field lang is the same, we return an empty string to prevent uneeded html.

    Parameters:
    data - the Publication or Data of which to check field value in given language
    fieldName - the name of the field to check.
    userLang - the language in which the field was should be displayed
    Returns:
    a string containing the html 'lang' and 'dir' attributes without any surrounding spaces, or an empty string if advanced I18N is not enabled in JCMS.
    See Also:
    Channel.isUsingAdvancedI18N(), Channel.getUsedLanguage(Data, String, String), getLangAttributes(String)

    getLangAttributes

    public static String getLangAttributes(String lang)
    Retrieve the html language attributes to use for the given language.

    For example : lang="fr" xml:lang="fr" dir="ltr"

    Parameters:
    lang - the language of which to generate html attributes or null to use default jcms language
    Returns:
    a string containing the html 'lang' and 'dir' attributes without any surrounding spaces, or an empty string if advanced I18N is not enabled in JCMS.
    See Also:
    Channel.getLanguageDirection(String)

    getUntranslatedZoneAttribute

    public static String getUntranslatedZoneAttribute(String lang)
    Retrieve the HTML attributes to use for any HTML element surrounding feature/s which are not translated in the current user language (eg : ctx menu, glp, ...) :

    Parameters:
    lang - the current language (ISO-639)
    Returns:
    a string containing the html 'lang' and 'dir' attributes without any surrounding spaces, or an empty string if the specified language is a JCMS localized language.
    Since:
    jcms-7.0.0
    See Also:
    Channel.getLanguageDirection(String)

    getRevision

    public static String getRevision(Class clazz)
    Returns the value of static variable REVISION of the given class.

    Parameters:
    clazz - the class to get the revision.
    Returns:
    the value of static variable REVISION
    Since:
    jcms-5.5.0

    getReleasedRevision

    public static String getReleasedRevision(Class clazz)
    Returns the value of static variable REVISION when it was packaged for this release.

    Parameters:
    clazz - the class to get the revision.
    Returns:
    the value of static variable REVISION
    Since:
    jcms-5.5.0

    getClassList

    public static List<Class<?>> getClassList()
    Returns the list of the Jalios classes

    Returns:
    the list of the Jalios classes.
    Since:
    jcms-5.5.0

    getClassList

    public static List<Class<?>> getClassList(String libDir,
                                              ClassLoader classLoader)
    Returns the list of the Jalios classes

    Parameters:
    libDir - the path for lib directory
    classLoader - the classLoader to be used
    Returns:
    the list of the Jalios classes.
    Since:
    jcms-5.5.0

    getXHtmlMetaTag

    public static String getXHtmlMetaTag(String name,
                                         String content)
    Generates an XHtml meta tag (i.e.

    Parameters:
    name - the name attribute
    content - the content attribute
    Returns:
    an XHtml meta tag.
    Since:
    jcms-5.5.0

    getXHtmlMetaHttpEquivTag

    public static String getXHtmlMetaHttpEquivTag(String httpEquiv,
                                                  String content)
    Generates an XHtml meta http-equiv tag (i.e.

    Parameters:
    httpEquiv - the httpEquiv attribute
    content - the content attribute
    Returns:
    an XHtml http-equiv meta tag.
    Since:
    jcms-5.7.0

    getXHtmlMetaTag

    public static String getXHtmlMetaTag(String keyName,
                                         String key,
                                         String content)
    Generates a generic XHtml meta tag (key name is configurable).

    Parameters:
    keyName - the name of the key (eg "name", or "http-equiv")
    key - the key attribute
    content - the content attribute
    Returns:
    an XHtml meta tag.
    Since:
    jcms-5.7.0

    getPublicationDetails

    public static int[] getPublicationDetails(Class clazz,
                                              Member mbr,
                                              Workspace ws)
    Returns some statistics about a given publication type. The returns array contains
  • [0]: the publication count
  • [1]: in-progress publication count
  • [2]: scheduled publication count
  • [3]: published publication count
  • [4]: expired publication count
  • [5]: restricted publication count
  • [6]: audienced publication count

    Parameters:
    clazz - the class
    mbr - the member who performs the request
    ws - the workspace
    Returns:
    an int[] which contains the informations.
    Since:
    jcms-5.5.0

  • extractExternalUrl

    public static Set extractExternalUrl(String text)
    Returns all the external URL contained in the given text.

    Parameters:
    text - the text to be parsed.
    Returns:
    all the external URL contained in the given text.
    Since:
    jcms-5.5.0

    isAuthorizedToAccessStatusInfo

    public static boolean isAuthorizedToAccessStatusInfo(javax.servlet.ServletContext context,
                                                         javax.servlet.http.HttpServletRequest request)
    Check if the given request is allowed to access jcms status page, (admin/admin.jsp, admin/statusXml.jsp).

    This method can be called even if JCMS has not been started, as long as a valid ServletContext is given.
    Valid IPs addresses are read from the file "WEB-INF/data/status.prop" the first time this method is called.

    Parameters:
    context - a required ServletContext (used to retrieve file path of the status.prop file inside the webapp).
    request - the request of which to check access to status, must not be null.
    Returns:
    true if the request is allowed, false otherwise.

    getWebHelpHome

    public static String getWebHelpHome(javax.servlet.http.HttpServletRequest request)
    Returns the webhelp URI of the user's guide home page.

    Parameters:
    request - the HttpRequest
    Returns:
    the webhelp URI of the user's guide home page.
    Since:
    jcms-5.6.1

    getWebHelpUri

    public static String getWebHelpUri(javax.servlet.http.HttpServletRequest request,
                                       String entry)
    Returns the webhelp URI of the given entry.

    Parameters:
    request - the HttpRequest
    entry - the entry to display the documentation
    Returns:
    the webhelp URI of the user's guide of the given entry
    Since:
    jcms-5.6.1

    getWebHelpUriAndIcon

    public static String[] getWebHelpUriAndIcon(javax.servlet.http.HttpServletRequest request,
                                                String entry,
                                                boolean home)
    Returns a String[] which contains the webhelp URI and the webhelp icon.

    Parameters:
    request - the HttpRequest (to determine the JSP)
    entry - the WebHelp entry to access (if empty, find the entry from the request)
    home - if true display user's guide home page
    Returns:
    a String[] which contains the webhelp URI and the webhelp icon.
    Since:
    jcms-5.6.1

    getDisplayUrl

    public static String getDisplayUrl()
    Return the display url of JCMS. For example, "jcms/" if descriptive URLs are enabled, "display.jsp" otherwise).

    Returns:
    a path relative to the webapp path, (no '/' at begining).
    Since:
    jcms-5.7.0

    getDisplayUrl

    public static String getDisplayUrl(Data data,
                                       Locale locale)
    Return the URL to access the given data in the front office.
    If descriptive URLs are enabled in JCMS (DescriptiveURLs) the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale) otherwise, a standard "display.jsp?id=" URL is generated.

    If the given data is null, the returned url will be direct access to servlet path (for example, "jcms/" if descriptive URLs are enabled, "display.jsp" otherwise), see getDisplayUrl().

    Warning: The return url may or may not contains a query string

    Parameters:
    data - the data for which the URL will be generated
    locale - the Locale to use for I18N and localized operations
    Returns:
    a path relative to the webapp path, (no '/' at begining).
    Since:
    jcms-5.7.0
    See Also:
    Data.getDisplayUrl(Locale)

    getDisplayUrl

    public static String getDisplayUrl(Data data,
                                       Locale locale,
                                       String params,
                                       boolean escapeAmpersand)
    Return the URL to access the given data in the front office with the added given param string.
    If descriptive URLs are enabled in JCMS (DescriptiveURLs) the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale) otherwise, a standard "display.jsp?id=" URL is generated.

    Examples :
       String link = JcmsUtil.getDisplayUrl(myFileDoc, userLocale,
                                            "details=true&a=b", true);
     
       String redirect = JcmsUtil.getDisplayUrl(homeCat, locale,
                        "mid=" + mbr.getId() +
                        "&jsp=" + ResourceHelper.getMemberDisplay(),
                        false);
     

    Parameters:
    data - the data for which the URL will be generated
    locale - the Locale to use for I18N and localized operations
    params - the parameter string to add, it should not start with any ampersand ('&' or '&amp;') as it will be added automatically
    escapeAmpersand - will use "&amp; true, "&" if false
    Returns:
    a path relative to the webapp path, (no '/' at begining).
    Since:
    jcms-5.7.0

    getDisplayUrlWithUpdatedParams

    public static String getDisplayUrlWithUpdatedParams(Data data,
                                                        Locale locale,
                                                        javax.servlet.http.HttpServletRequest request,
                                                        String[] names,
                                                        String[] newValues,
                                                        String[] removePatterns,
                                                        boolean escapeAmpersand)
    Return the URL to access the given data in the front office, while updating/adding or removing a set of parameters.
    If descriptive URLs are enabled in JCMS (DescriptiveURLs) the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale) otherwise, a standard "display.jsp?id=" URL is generated.

    Parameters:
    data - the data for which the URL will be generated
    locale - the Locale to use for I18N and localized operations
    request - the current HttpServletRequest of which to update/add/remove params. If null, this method as the same behavior as getDisplayUrl(Data, Locale).
    names - an array of String which contains the name of the parameters
    newValues - an array of String which contains the values of the parameters (if newValue[i] is null the names[i] parameter is removed)
    removePatterns - any parameter name containing one of the given Strings will be removed from the parameters' list
    escapeAmpersand - will use "&amp; true, "&" if false
    Returns:
    a path relative to the webapp path, (no '/' at begining).
    Since:
    jcms-5.7.0

    getAbsDisplayUrlWithUpdatedParams

    public static String getAbsDisplayUrlWithUpdatedParams(Data data,
                                                           Locale locale,
                                                           javax.servlet.http.HttpServletRequest request,
                                                           String[] names,
                                                           String[] newValues,
                                                           String[] removePatterns,
                                                           boolean escapeAmpersand)
    Return the absolute URL to access the given data in the front office, while updating/adding or removing a set of parameters.
    If descriptive URLs are enabled in JCMS (DescriptiveURLs) the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale) otherwise, a standard "display.jsp?id=" URL is generated.

    Parameters:
    data - the data for which the URL will be generated
    locale - the Locale to use for I18N and localized operations
    request - the current HttpServletRequest of which to update/add/remove params. If null, this method as the same behavior as getDisplayUrl(Data, Locale).
    names - an array of String which contains the name of the parameters
    newValues - an array of String which contains the values of the parameters (if newValue[i] is null the names[i] parameter is removed)
    removePatterns - any parameter name containing one of the given Strings will be removed from the parameters' list
    escapeAmpersand - will use "&amp; true, "&" if false
    Returns:
    a full and absolute URL
    Since:
    jcms-5.7.0

    getDisplayUrlWithAddedParam

    public static String getDisplayUrlWithAddedParam(Data data,
                                                     Locale locale,
                                                     javax.servlet.http.HttpServletRequest request,
                                                     String name,
                                                     String value,
                                                     boolean escapeAmpersand)
    Return the URL to access the given data in the front office, while adding the given parameter.
    If descriptive URLs are enabled in JCMS (DescriptiveURLs) the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale) otherwise, a standard "display.jsp?id=" URL is generated.

    Parameters:
    data - the data for which the URL will be generated
    locale - the Locale to use for I18N and localized operations
    request - the current HttpServletRequest of which to update/add/remove params. If null, this method as the same behavior as getDisplayUrl(Data, Locale).
    name - a String which contains the name of the parameter to add
    value - a String which contains the value of the parameter to add (if value is null the parameter is not added, but it wont be removed from existing params)
    escapeAmpersand - will use "&amp; true, "&" if false
    Returns:
    a path relative to the webapp path, (no '/' at begining).
    Since:
    jcms-5.7.0

    getLangChildrenMap

    public static Map<String,String> getLangChildrenMap(org.jdom.Element elt,
                                                        String childName,
                                                        String info)
    Returns the map of the children of elt with their xml:lang as key. If the entry for main language does not exists, an error message is append in the logs and the value "???" is assigned for the main language

    Parameters:
    elt - the Element
    childName - the name of the child
    Returns:
    a map of {lang, elt}.
    Since:
    jcms-5.7.0
    See Also:
    XmlUtil.getLangChildrenMap(Element, String)

    getNewDirectory

    public static String getNewDirectory(File baseDir,
                                         String subDir)
    Returns the relative path of directory to use for the new document to be created.

    Parameters:
    baseDir - the base directory (eg /usr/local/tomcat/webapps/jcms/)
    subDir - an optionnal sub directory, may be null (eg upload/docs/image/gif/)
    Returns:
    String the directory path, relative to the webapp, with the trailing slash ("/"). e.g: upload/docs/image/gif/2006/11/
    Since:
    jcms-5.7.0
    See Also:
    IOUtil.getNewDirectory(File, String, long)

    setDataWriteDisabledMsg

    public static void setDataWriteDisabledMsg(javax.servlet.http.HttpServletRequest request,
                                               String userLang)

    checkDataWriteDisabled

    public static boolean checkDataWriteDisabled(javax.servlet.http.HttpServletRequest request,
                                                 javax.servlet.http.HttpServletResponse response,
                                                 String redirect,
                                                 String userLang)
                                          throws IOException
    Check is data writes are disabled. If data writes are disabled, set in session a warning msg and returns true. If data writes are disabled and redirect not empty, a redirect is done to this url.

    Parameters:
    request - The current request
    response - The current response
    redirect - The wished redirect
    userLang - The lang of the current user
    Returns:
    true is data writes are enabled
    Throws:
    IOException

    convertMultilingualFieldToXml

    public static String convertMultilingualFieldToXml(String mainValue,
                                                       Map<String,String> valuesMap)
    Convert a multilingual field to an xml representation.

    Example :

      String xml = convertMultilingualFieldToXml(pub.getTitle(), pub.getTitleML());
     
    Will lead to the following xml :
      <?xml version='1.0' encoding='UTF-8'?>
      <ml>
       <value xml:lang="en">Title</value>
       <value xml:lang="fr">Titre</value>
      </ml>
     

    Parameters:
    mainValue - the value of the field in the channel main language.
    valuesMap - the values of the field in other languages (ISO-639 language code as the key, value of field in value)
    Returns:
    an xml string.
    Since:
    jcms-6.0

    convertMultilingualFieldToXmlElement

    public static org.jdom.Element convertMultilingualFieldToXmlElement(String mainValue,
                                                                        Map<String,String> valuesMap)
    Convert a multilingual field to an xml representation.

    Example :

      String xml = convertMultilingualFieldToXml(pub.getTitle(), pub.getTitleML());
     
    Will lead to the following xml :
      <?xml version='1.0' encoding='UTF-8'?>
      <ml>
       <value xml:lang="en">Title</value>
       <value xml:lang="fr">Titre</value>
      </ml>
     

    Parameters:
    mainValue - the value of the field in the channel main language.
    valuesMap - the values of the field in other languages (ISO-639 language code as the key, value of field in value)
    Returns:
    a JDOM xml Element.
    Since:
    jcms-6.0

    convertMultilingualFieldXmlToMap

    public static Map<String,String> convertMultilingualFieldXmlToMap(String xml)
    Converts an xml string to an hashmap of values.

    Example given the following text :

      <?xml version='1.0' encoding='UTF-8'?>
      <ml>
       <value xml:lang="en">Title</value>
       <value xml:lang="es">Titulo</value>
       <value xml:lang="fr">Titre</value>
      </ml>
     
    Returns a map containing all values :
     {
       "en" => "Title",
       "fr" => "Titre",
       "es" => "Titulo"
     }
     

    Parameters:
    xml - an xml representation of a multilingual field, as returned by convertMultilingualFieldToXml(String, Map)
    Returns:
    a map withy language code as the key and field value as the value. Return null if no field value could be found or if the xml could not be parsed.
    Since:
    jcms-6.0

    checkJDBCConnection

    public static void checkJDBCConnection(String driver,
                                           String url,
                                           String user,
                                           String password)
                                    throws Exception
    Check if the given JDBC connection can be established.

    Parameters:
    driver - the class name of the JDBC driver
    url - a database url of the form jdbc:subprotocol:subname
    user - the database user on whose behalf the connection is being made
    password - the user's password
    Throws:
    Exception - exception
    Since:
    jcms-6.0.0

    checkUrid

    public static boolean checkUrid(String urid)
    Returns true if the given urid is valid.

    Parameters:
    urid - the urid
    Returns:
    true if the given urid is valid.
    Since:
    jcms-6.0.0

    getVirtualId

    public static String getVirtualId(String virtualId,
                                      String id)
    Retrieves the virtual id corresponding to the specified data id.

    Example :
    JcmsUtil.getVirtualId("$jcmsplugin.myplugin.my-virtual-id", "c_42"); will returns :

    Parameters:
    virtualId - a virtual id such as "$jcmsplugin.myplugin.my-virtual-id" (if anything else than a virtual id is specified, the realId is returned)
    id - a data id
    Returns:
    the virtual id if it matches the specified id, otherwise, the id.
    Since:
    jcms-5.7.5

    getVirtualIdList

    public static String getVirtualIdList(String stringWithPossiblyVirtualIds,
                                          String stringOfRealIds)
    Convenient method to keep virtual id when set. It allows to keep virtual Ids in a list (actually a string of id seperated by '|') if these ids has not been modified in a form. A new String is constructed form the two in parameters. If the number of items in the list is not the same, the second parameter is returned. If the first parameter is a virtual ID, corresponding to the id in second parameter, the first parameter is returned.

    Parameters:
    stringWithPossiblyVirtualIds - it is a value already used, possibly a virtual id
    stringOfRealIds - it is the value newly set. updated or not.
    Returns:
    one of the two parameter
    Since:
    jcms-5.7.5

    getWorkerCount

    public static int getWorkerCount()
    Returns the count of members having the worker ability.

    Returns:
    the count of members having the worker ability.
    Since:
    jcms-6.0.0

    getIgnoreFileRegexp

    public static String getIgnoreFileRegexp()
    Returns:
    the regexp that contains all the path to ignore when copying a webapp.
    Since:
    jcms-6.0.1

    getIgnoreSignRegexp

    public static String getIgnoreSignRegexp()
    Returns:
    the regexp that contains all the path to ignore when signing a webapp.
    Since:
    jcms-6.0.1

    getFriendlyDate

    public static String getFriendlyDate(Date date,
                                         int style,
                                         boolean showTime,
                                         Locale locale)
    Returns a friendly textual representation for the given date (e.g. "15 min ago", "today", "yesterday at 8:12 PM", "tomorrow at 8:12 PM", ...)

    Parameters:
    date - the date
    style - the date and time format style (e.g. DateFormat.SHORT)
    showTime - if true show the time
    locale - the locale
    Returns:
    a friendly textual representation for the given date.
    Since:
    jcms-6.0.1

    getFriendlyDate

    public static String getFriendlyDate(Date date,
                                         int style,
                                         boolean showTime,
                                         Locale locale,
                                         boolean beginSentence)
    Returns a friendly textual representation for the given date (e.g. "15 min ago", "today", "yesterday at 8:12 PM", "tomorrow at 8:12 PM", ...)

    Parameters:
    date - the date
    style - the date and time format style (e.g. DateFormat.SHORT)
    showTime - if true show the time
    locale - the locale
    beginSentence - if true returns a string suitable for a sentence beginning.
    Returns:
    a friendly textual representation for the given date.
    Since:
    jcms-6.0.1

    getFriendlyPeriod

    public static String getFriendlyPeriod(Date startDate,
                                           Date endDate,
                                           Locale locale)
    Returns a friendly textual representation of a time period defined by two dates.

    Parameters:
    startDate - the start date (must not be null)
    endDate - the end date (may be null)
    locale - the locale
    Returns:
    a friendly textual representation of a time period defined by two dates.
    Since:
    jcms-6.1.0

    convertUri2Url

    public static String convertUri2Url(String text,
                                        String baseURL)
    Convert all relative URI in the given text to complete URL with the given base URL.

    Parameters:
    text -
    baseURL -
    Returns:
    the text with only complete URL

    getFileSizeMap

    public static ObjectLongTreeMap getFileSizeMap()
    Returns the map file size for each content-type.

    Returns:
    the map file size for each content-type.
    Since:
    jcms-7.0.0

    getFileSizeMap

    public static ObjectLongTreeMap getFileSizeMap(Workspace ws)
    Returns the map file size for each content-type for the given workspace.

    Parameters:
    ws - the workspace
    Returns:
    the map file size for each content-type.
    Since:
    jcms-7.0.0


    Copyright © 2001-2010 Jalios SA. All Rights Reserved.