public class JcmsUtil extends java.lang.Object implements JcmsConstants
Modifier and Type | Field and Description |
---|---|
static org.apache.oro.text.regex.Pattern |
DUPLICATE_PREFIX |
static java.lang.String |
REVISION |
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, 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_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, 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, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
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 and Description |
---|
JcmsUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addData(java.util.TreeSet set,
java.lang.Class clazz,
java.util.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(java.util.TreeSet set,
java.lang.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(java.util.TreeSet set,
java.lang.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(java.util.TreeSet set,
java.lang.Class clazz,
java.util.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(java.util.Set<FileDocument> set,
java.util.Collection<java.lang.String> filenameColl)
Adds the FileDocuments bound to the given filename collection in the given set.
|
static void |
addFileDocument(java.util.Set<FileDocument> set,
java.lang.String... filenames)
Adds the FileDocuments bound to the given filename array in the given set.
|
static void |
addFileDocument(java.util.Set<FileDocument> set,
java.lang.String filename)
Adds the FileDocument bound to the given filename in the given set.
|
static void |
addFileDocument(java.util.Set<FileDocument> set,
java.lang.String[] filenamesMainLanguage,
java.util.Map<java.lang.String,java.lang.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(java.util.Set<FileDocument> set,
java.lang.String filenameMainLanguage,
java.util.Map<java.lang.String,java.lang.String> mlMap)
Adds the FileDocuments bound to the given filename and to the filename contains as value of mlMap in the given set.
|
static java.util.Collection |
applyDataSelector(java.util.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,
java.lang.String redirect,
java.lang.String userLang)
Check is data writes are disabled.
|
static ControllerStatus |
checkFieldMLRequired(Publication pub,
java.lang.String fieldName,
java.lang.String value,
java.util.HashMap valueML)
This convenient method checks if the given multilingual field is required.
|
static ControllerStatus |
checkFieldRequired(Publication pub,
java.lang.String fieldName,
java.lang.Object value)
This convenient method checks if the given field is required.
|
static ControllerStatus |
checkHtml(java.util.Map map,
java.lang.String field)
Check if the values of given map of String do not contain forbidden HTML code
|
static ControllerStatus |
checkHtml(java.lang.String[] array,
java.lang.String field)
Check if the given array of String does not contain forbidden HTML code
|
static ControllerStatus |
checkHtml(java.lang.String str,
java.lang.String field)
Check if the given String does not contain forbidden HTML
code.
|
static void |
checkJDBCConnection(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Check if the given JDBC connection can be established.
|
static boolean |
checkUrid(java.lang.String urid)
Returns true if the given urid is valid.
|
static java.lang.String |
convertMultilingualFieldToXml(java.lang.String mainValue,
java.util.Map<java.lang.String,java.lang.String> valuesMap)
Convert a multilingual field to an xml representation.
|
static org.jdom.Element |
convertMultilingualFieldToXmlElement(java.lang.String mainValue,
java.util.Map<java.lang.String,java.lang.String> valuesMap)
Convert a multilingual field to an xml representation.
|
static java.util.Map<java.lang.String,java.lang.String> |
convertMultilingualFieldXmlToMap(java.lang.String xml)
Converts an xml string to an hashmap of values.
|
static java.lang.String |
convertToCSV(java.lang.String lang,
boolean bool)
Returns a CSV view of the given boolean value
|
static java.lang.String |
convertToCSV(java.lang.String lang,
java.lang.Object obj)
Returns a CSV view of the given object in the given language.
|
static java.lang.String |
convertToCSV(java.lang.String lang,
java.lang.Object obj,
boolean displayObjectId)
Returns a CSV view of the given object in the specified language.
|
static java.lang.String |
convertUri2Url(java.lang.String text,
java.lang.String baseURL)
Convert all relative URI in the given text to complete URL with the given base URL.
|
static java.util.Set<java.lang.String> |
dataArrayToIdSet(Data[] datas)
Convert a Data[] to a Set<String> composed by id
|
static java.lang.String[] |
dataArrayToNameArray(Data[] datas,
java.lang.String lang)
Convert a Data[] to a String[] composed of
their name (label, title, name, ...)
|
static java.lang.String[] |
dataArrayToStringArray(Data[] datas)
Convert a Data[] to a String[] composed by id
|
static <T extends Data> |
dataCollectionToIdList(java.util.Collection<T> dataColl)
Returns the list of ids contained in the given collection of data.
|
static <T extends Data> |
dataCollectionToIdSet(java.util.Collection<T> dataColl)
Returns the set of ids contained in the given collection of data.
|
static <T extends Data> |
dataListToString(java.util.Collection<T> list,
java.lang.String delim)
Convert a Collection of Data into a String composed by id, separated by the specified delimiter.
|
static java.lang.String |
dateSetToString(java.util.SortedSet<java.util.Date> dateSet)
Create a new List of String time in millis from a SortedSet of Date.
|
static java.lang.String |
escapeHtml(java.lang.String str)
Replace "<" and "&" with their corresponding HTML entities
(< and &) in the specified String.
|
static java.util.Map |
expandArray(java.util.Map mlMap,
java.util.Map main)
This method will expand each String[] keys
of a given map to a given length.
|
static java.lang.String[] |
expandArray(java.lang.String[] array,
java.lang.String[] main)
This method will expand each String[] keys
of a given map to a given length.
|
static void |
exportCSV(java.util.Set<? extends Data> dataSet,
java.lang.String lang,
java.io.Writer writer)
Export a dataSet to CSV
|
static void |
exportCSVIntegrityReport(java.util.Map<Data,ControllerStatus> report,
java.lang.String lang,
java.io.Writer writer)
Export a Data Integrity Report to CSV
|
static void |
exportCSVIntegrityReport(java.lang.String lang,
java.io.Writer writer)
Export a Data Integrity Report to CSV
|
static java.util.Set |
extractExternalUrl(java.lang.String text)
Returns all the external URL contained in the given text.
|
static <T extends Data> |
fillIdCollectionWithDataCollection(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz,
java.util.Collection<T> dataColl) |
static java.lang.String |
formatSchedule(java.lang.String userLang,
java.lang.String schedule)
Format a cron-like schedule.
|
static java.lang.String |
getAbsDisplayUrlWithUpdatedParams(Data data,
java.util.Locale locale,
javax.servlet.http.HttpServletRequest request,
java.lang.String[] names,
java.lang.String[] newValues,
java.lang.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 Member[] |
getAllMembers(Group[] groups,
Member[] members,
Member... removeMembers)
|
static java.lang.Class |
getClass(java.lang.String className,
java.lang.Class defClass)
Quietly returns the Class matching the given className or defClass if it doesn't exists.
|
static java.lang.String |
getClassIcon(java.lang.Class<?> clazz)
Gets the icon source from a
Class object. |
static java.util.List<java.lang.Class<?>> |
getClassList()
Returns the list of the Jalios classes
|
static java.util.List<java.lang.Class<?>> |
getClassList(java.lang.String libDir,
java.lang.ClassLoader classLoader)
Returns the list of the Jalios classes
|
static java.lang.String |
getDisplayUrl()
Return the display url of JCMS.
|
static java.lang.String |
getDisplayUrl(Data data,
java.util.Locale locale)
Return the URL to access the given data in the front office.
|
static java.lang.String |
getDisplayUrl(Data data,
java.util.Locale locale,
java.lang.String params,
boolean escapeAmpersand)
Return the URL to access the given data in the front office with the added given param string.
|
static java.lang.String |
getDisplayUrlWithAddedParam(Data data,
java.util.Locale locale,
javax.servlet.http.HttpServletRequest request,
java.lang.String name,
java.lang.String value,
boolean escapeAmpersand)
Return the URL to access the given data in the front office, while
adding the given parameter.
|
static java.lang.String |
getDisplayUrlWithUpdatedParams(Data data,
java.util.Locale locale,
javax.servlet.http.HttpServletRequest request,
java.lang.String[] names,
java.lang.String[] newValues,
java.lang.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 java.lang.String |
getEscapedEmailName(java.lang.String value)
Remove from a value characters which should not be in email headers (like : or ,)
|
static java.lang.String |
getFieldLangAttributes(Data data,
java.lang.String fieldName,
java.lang.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()
Deprecated.
since jcms-7.1.0, use Channel.getGlobalFileAnalyzer method to have more information about satellites files
|
static ObjectLongTreeMap |
getFileSizeMap(Workspace ws)
Deprecated.
since jcms-7.1.0, use Workspace.getFileAnalyzer method to have more information about satellites files
|
static java.lang.String |
getFriendlyDate(java.util.Date date,
int style,
boolean showTime,
java.util.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", ...)
|
static java.lang.String |
getFriendlyDate(java.util.Date date,
int style,
boolean showTime,
java.util.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", ...)
|
static java.lang.String |
getFriendlyPeriod(java.util.Date startDate,
java.util.Date endDate,
java.util.Locale locale)
Returns a friendly textual representation of a time period defined by two dates.
|
static java.lang.String |
getHtmlIcon(java.lang.Class<?> clazz)
Build an icon from a
Class object. |
static java.lang.String |
getId(Data data)
This convenient method return the id of the given data.
|
static java.io.FileFilter |
getIgnoredResourcesFileFiler()
Retrieves a new instance of FileFilter used to skip resources that
should be ignored, as defined by property
"file.regexp.ignore" . |
static java.io.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 java.lang.String |
getIgnoreFileRegexp() |
static java.lang.String |
getIgnoreSignRegexp() |
static java.lang.String |
getLangAttributes(java.lang.String lang)
Retrieve the html language attributes to use for the given language.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLangChildrenMap(org.jdom.Element elt,
java.lang.String childName,
java.lang.String info)
Returns the map of the children of
elt with their xml:lang as key. |
static java.util.Map<java.lang.String,java.lang.String> |
getLangMap(org.jdom.Element xmlElt,
java.lang.String xmlChildrenName,
java.lang.String langProperty,
boolean forceMainLanguageValue,
java.lang.String missingMainValueInfo)
Retrieve I18N strings from XML and properties.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLangMapUpdatedFromProperties(java.util.Map<java.lang.String,java.lang.String> langMap,
java.lang.String property)
Update the specified map of I18N string (lang to string) with values
read from the specified property (if available), for all localized languages of the site.
|
static java.lang.String[] |
getLanguageArray(java.util.Map map)
Returns a String[] which contains values of the given language map in the current site languages.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLanguageMap(java.lang.String propKey)
Returns a map {lang, value} build from the given property key.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLanguageMap(java.lang.String[] values)
Returns a map {lang, value} with the given localized values.
|
static java.util.Map<java.lang.String,java.lang.String> |
getLanguageMap(java.lang.String[] values,
boolean escapeHtml)
Returns a map {lang, value} with the given localized values.
|
static java.util.List |
getLanguageMapList(java.lang.String[] values)
Returns a list of map {lang, value} with the given localized values.
|
static java.lang.String |
getLangValue(java.util.Map map,
java.lang.String lang)
Returns the localized value mapped to the given language.
|
static java.util.Set<Member> |
getMemberSetFromGroups(java.lang.String[] gids)
Return all the members represented by an Array of Group ids
|
static java.lang.String |
getNewDirectory(java.io.File baseDir,
java.lang.String subDir)
Returns the relative path of directory to use for the new document to be created.
|
static java.lang.String |
getPrefixedTitle(java.lang.String prefix,
java.lang.String title,
boolean replaceOnly)
Contruct a String with prefix + title or replace a $NAME$ by this prefix
|
static java.lang.String |
getPubIcon(Publication pub)
Returns the HTML code for the icon of the given publication
|
static java.lang.String |
getPubImg(Publication pub)
Returns the image of the icon of the given publication
|
static int[] |
getPublicationDetails(java.lang.Class clazz,
Member mbr,
Workspace ws)
Returns some statistics about a given publication type.
|
static java.lang.String |
getReleasedRevision(java.lang.Class clazz)
Returns the value of static variable REVISION when it was packaged for this release.
|
static java.lang.String |
getRevision(java.lang.Class clazz)
Returns the value of static variable REVISION of the given class.
|
static java.util.Date[] |
getScheduleDate(java.util.Date reference,
java.util.Date targetDate,
java.util.Date[] toUpdate,
long schedule,
boolean forward)
Calculate loops to do between reference date and target date then apply
loops on all toUpdate Dates.
|
static java.util.Date |
getScheduleDate(java.util.Date reference,
java.util.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 java.util.Date |
getScheduleDate(java.util.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 java.util.TreeSet |
getSortedClass(java.util.Collection subTypeList,
Workspace workspace,
java.lang.String userLang)
Return a Set of classes of Types sorted alphabetically according to the title.
|
static java.lang.String |
getUntranslatedZoneAttribute(java.lang.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 java.util.TreeSet |
getUpdatedData(java.util.Collection old,
java.util.Map dataMap)
Convert an old set of Data to a new Set of data using a Map
|
static java.util.TreeSet |
getUpdatedData(java.util.Collection old,
java.util.Map dataMap,
boolean retrieveAll)
Convert an old set of Data to a new Set of data using a Map
|
static Data[] |
getUpdatedData(Data[] old,
java.util.Map dataMap)
Convert an old array of Data to a new array of data using a Map
|
static java.lang.String |
getVirtualId(java.lang.String virtualId,
java.lang.String id)
Retrieves the virtual id corresponding to the specified data id.
|
static java.lang.String |
getVirtualIdList(java.lang.String stringWithPossiblyVirtualIds,
java.lang.String stringOfRealIds)
Convenient method to keep virtual id when set.
|
static java.lang.String |
getWebappClasspath()
Return the Classpath of the webapp
|
static java.lang.String |
getWebHelpHome(javax.servlet.http.HttpServletRequest request)
Returns the webhelp URI of the user's guide home page.
|
static java.lang.String |
getWebHelpUri(javax.servlet.http.HttpServletRequest request,
java.lang.String entry)
Returns the webhelp URI of the given entry.
|
static java.lang.String[] |
getWebHelpUriAndIcon(javax.servlet.http.HttpServletRequest request,
java.lang.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 java.lang.String |
getXHtmlMetaHttpEquivTag(java.lang.String httpEquiv,
java.lang.String content)
Generates an XHtml meta http-equiv tag (i.e.
|
static java.lang.String |
getXHtmlMetaTag(java.lang.String name,
java.lang.String content)
Generates an XHtml meta tag (i.e.
|
static java.lang.String |
getXHtmlMetaTag(java.lang.String keyName,
java.lang.String key,
java.lang.String content)
Generates a generic XHtml meta tag (key name is configurable).
|
static java.lang.String |
glp(java.lang.String lang,
LangProperty prop)
Resolve a language property in the given language.
|
static java.lang.String |
glp(java.lang.String lang,
java.lang.String prop,
java.util.Map<java.lang.String,java.lang.String> paramMap)
Resolve a language property in the given language, using named parameters.
|
static java.lang.String |
glp(java.lang.String lang,
java.lang.String prop,
java.lang.Object... params)
Resolve a language property in the given language.
|
static java.lang.String |
glpd(java.lang.String prop)
Resolve a language property in the default site language.
|
static java.lang.String |
glpdNoDefault(java.lang.String prop)
Resolve a language property in the default site language, defaulting
to a null string if the property's value could not be found (instead of
defaulting to the property's name which is the default behavior when accessing
properties).
|
static java.lang.String |
glpNoDefault(java.lang.String lang,
java.lang.String prop,
java.lang.Object... params)
Resolve a language property in the given language, defaulting
to a null value if the property's value could not be found (instead of
defaulting to the property's name which is the default behavior when accessing
properties).
|
static <T extends Data> |
idCollectionToDataArray(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz) |
static <T extends Data> |
idCollectionToDataHashSet(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz)
Returns a HashSet of Data from a Collection of data's id.
|
static <T extends Data> |
idCollectionToDataLinkedHashSet(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz)
Returns a LinkedHashSet of Data from a Collection of data's id.
|
static <T extends Data> |
idCollectionToDataList(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz)
Returns a List of Data from a Collection of data's id.
|
static <T extends Data> |
idCollectionToDataSet(java.util.Collection<java.lang.String> idColl,
java.lang.Class<T> clazz)
Returns a Set of Data from a Collection of data's id.
|
static <T extends Data> |
idCollectionToDataTreeSet(java.util.Collection<java.lang.String> idColl,
java.lang.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).
|
static boolean |
isLegalFile(java.lang.String relativePath)
Returns true if the file is authorized for JSP inclusion.
|
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 java.lang.String |
join(java.util.Collection<? extends Data> coll,
java.lang.String sep,
java.lang.String userLang)
Joins a collection of Object with the given separator into a
String.
|
static java.lang.String |
join(java.util.Iterator it,
java.lang.String sep,
java.lang.String userLang)
Joins a collection of Object with the given separator into a
String.
|
static void |
jsp2File(java.lang.String jsp,
java.lang.String filename,
java.util.HashMap sessionAttributeMap)
Render a JSP into a File.
|
static void |
jsp2File(java.lang.String jsp,
java.lang.String filename,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.HashMap initParameterMap,
Member loggedMember)
Render a JSP into a File.
|
static void |
jsp2File(java.lang.String jsp,
java.lang.String filename,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.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(java.lang.String jsp,
java.io.OutputStream out,
java.util.HashMap sessionAttributeMap)
Render a JSP into an OutputStream
|
static void |
jsp2OutputStream(java.lang.String jsp,
java.io.OutputStream out,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.HashMap initParameterMap,
Member loggedMember)
Render a JSP into an OutputStream
|
static void |
jsp2OutputStream(java.lang.String jsp,
java.io.OutputStream out,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.HashMap initParameterMap,
Member loggedMember,
boolean clean)
Render a JSP into an OutputStream
|
static void |
jsp2OutputStream(java.lang.String jsp,
java.io.OutputStream out,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.HashMap initParameterMap,
java.lang.String trashPath,
java.lang.String rootPath,
java.lang.ClassLoader classloader,
java.lang.String classpath)
Render a JSP into an OutputStream
|
static void |
jsp2OutputStream(java.lang.String jsp,
java.io.OutputStream out,
java.util.HashMap requestParameterMap,
java.util.HashMap requestAttributeMap,
java.util.HashMap sessionAttributeMap,
java.util.HashMap contextAttributeMap,
java.util.HashMap initParameterMap,
java.lang.String trashPath,
java.lang.String rootPath,
java.lang.ClassLoader classloader,
java.lang.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,
java.lang.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,
java.lang.Object obj)
Log the given message (object), at a the WARN level using the given logger.
|
static void |
logSecurityIssue(java.lang.Object obj)
Log the given message (object), at a the WARN level using the JcmsUtil logger.
|
static int |
loopScheduleDate(java.util.Calendar refCal,
java.util.Calendar nowCal,
int[] modifiers,
boolean forward)
Loop the reference calendar
|
static int |
loopScheduleDate(java.util.Calendar refCal,
int[] modifiers,
boolean forward,
int maxloop)
Loop the reference calendar
|
static void |
mergeMLMap(java.util.Map mlCopy,
java.util.Map mlMain)
Merges a multilingual (ML) map of a work copy with
the corresponding ML map of its main instance.
|
static java.lang.String |
parseSchedule(java.lang.String schedule,
java.lang.String period,
java.lang.String lang)
Parse the JCMS schedules
|
static void |
restartWebapp(java.io.File file) |
static <T> java.util.TreeSet<T> |
select(java.util.Collection<? extends T> dataColl,
DataSelector selector,
java.util.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,
java.lang.String userLang) |
static void |
setLog4jMDC()
Deprecated.
uses of log4j MDC cannot easily be guaranteed without memory leak
instead, use
JcmsPatternLayout in log4j.xml with the pattern %s |
static void |
setLog4jNDCMemberInfo(javax.servlet.http.HttpServletRequest request,
Member loggedMember)
Initialize log4j
NDC with the given
logged member information. |
static <T extends Data> |
stringArrayToDataArray(java.lang.Class<T> clazz,
java.lang.String[] ids)
Convert a Data[] to a String[] composed by id
|
static Data[] |
stringArrayToDataArray(java.lang.String[] ids)
Convert a Data[] to a String[] composed by id
|
static java.util.List<Data> |
stringToDataList(java.lang.String str,
java.lang.String delim)
Convert a String of Data ids into a List of Data.
|
static <T extends Data> |
stringToDataList(java.lang.String str,
java.lang.String delim,
java.lang.Class<T> clazz)
Convert a String of Data ids into a List of Data.
|
static java.util.SortedSet<java.util.Date> |
stringToDateSet(java.lang.String timesString)
Create a new SortedSet of Date from a comma seperated time in millisecond.
|
static java.lang.String |
unescapeHtml(java.lang.String str)
Replace HTML entities "<" and "&" with their corresponding charaters
(< and &) in the specified String.
|
public static final java.lang.String REVISION
public static final org.apache.oro.text.regex.Pattern DUPLICATE_PREFIX
public static boolean isLegalFile(java.lang.String relativePath)
It must match the following criteria :
If property channel.security.authorized-jsp-whitelist
is set to true,
the previous blacklist criteria are still verified, but relative path is only
authorized if its value is one of the value specified value through
properties channel.security.authorized-jsp.*:
relativePath
- the path to be testedpublic static java.lang.String convertToCSV(java.lang.String lang, boolean bool)
lang
- the language of the outputbool
- the boolean valuepublic static java.lang.String convertToCSV(java.lang.String lang, java.lang.Object obj)
lang
- the language of the outputobj
- the objectpublic static java.lang.String convertToCSV(java.lang.String lang, java.lang.Object obj, boolean displayObjectId)
lang
- the language of the outputobj
- the objectdisplayObjectId
- if true, the object's id will be appended to the data's name.public static void exportCSV(java.util.Set<? extends Data> dataSet, java.lang.String lang, java.io.Writer writer)
dataSet
- the set of data to be exportedlang
- the languagewriter
- the writer where to print the exportpublic static void exportCSVIntegrityReport(java.lang.String lang, java.io.Writer writer)
lang
- the languagewriter
- the writer where to print the exportpublic static void exportCSVIntegrityReport(java.util.Map<Data,ControllerStatus> report, java.lang.String lang, java.io.Writer writer)
report
- the report to be exportedlang
- the languagewriter
- the writer where to print the exportpublic static java.util.TreeSet getSortedClass(java.util.Collection subTypeList, Workspace workspace, java.lang.String userLang)
subTypeList
- the collection that contain Classworkspace
- the workspace used to get the label associated to the class.userLang
- the current language of the user loggedpublic static java.lang.Class getClass(java.lang.String className, java.lang.Class defClass)
className
- the name of the classdefClass
- the default class if class name do not matchpublic static java.util.Set<Member> getMemberSetFromGroups(java.lang.String[] gids)
gids
- an array of Group ids.public static Member[] getAllMembers(Group[] groups, Member[] members, Member... removeMembers)
public static java.util.List<Data> stringToDataList(java.lang.String str, java.lang.String delim)
str
- of id seperated with specified delimiter ie.delim
- a delimiter (required, no default value is used)to perform the opposite operation
,
for generic method
public static <T extends Data> java.util.List<T> stringToDataList(java.lang.String str, java.lang.String delim, java.lang.Class<T> clazz)
T
- any type of Data to retrievestr
- of id seperated with specified delimiter ie.delim
- a delimiter (required, no default value is used)clazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> java.lang.String dataListToString(java.util.Collection<T> list, java.lang.String delim)
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"
T
- any class extending Datalist
- a Collection of Datadelim
- a delimiter (required, no default value is used)to perform the opposite operation
public static java.lang.String[] dataArrayToNameArray(Data[] datas, java.lang.String lang)
datas
- Data[] an array of data to convertlang
- the ISO-639 language code to be used to retrieve the localized Data's namepublic static java.lang.String[] dataArrayToStringArray(Data[] datas)
datas
- Data[] an array of data to convertpublic static Data[] stringArrayToDataArray(java.lang.String[] ids)
ids
- an array of idspublic static <T extends Data> T[] stringArrayToDataArray(java.lang.Class<T> clazz, java.lang.String[] ids)
T
- any Data typeclazz
- the Data classids
- an array of idspublic static <T extends Data> java.util.Set<java.lang.String> dataCollectionToIdSet(java.util.Collection<T> dataColl)
T
- any Data typedataColl
- a collection of Datato perform the opposite operation
public static <T extends Data> java.util.List<java.lang.String> dataCollectionToIdList(java.util.Collection<T> dataColl)
T
- any Data typedataColl
- a collection of Datato perform the opposite operation
public static java.util.Set<java.lang.String> dataArrayToIdSet(Data[] datas)
datas
- Data[] an array of data to convertto perform the opposite operation
public static <T extends Data> java.util.Set<T> idCollectionToDataSet(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
T
- any type of Data to retrieveidColl
- a Collection of data idclazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> java.util.LinkedHashSet<T> idCollectionToDataLinkedHashSet(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
T
- any type of Data to retrieveidColl
- a Collection of data idclazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> java.util.TreeSet<T> idCollectionToDataTreeSet(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
T
- any type of Data to retrieveidColl
- a Collection of data idclazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> java.util.HashSet<T> idCollectionToDataHashSet(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
T
- any type of Data to retrieveidColl
- a Collection of data idclazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> java.util.List<T> idCollectionToDataList(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
T
- any type of Data to retrieveidColl
- a Collection of data idclazz
- the Class of object to retrieveto perform the opposite operation
public static <T extends Data> void fillIdCollectionWithDataCollection(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz, java.util.Collection<T> dataColl)
public static <T extends Data> T[] idCollectionToDataArray(java.util.Collection<java.lang.String> idColl, java.lang.Class<T> clazz)
public static java.lang.String join(java.util.Collection<? extends Data> coll, java.lang.String sep, java.lang.String userLang)
getDataName(userLang)
method for each iterated
Data.coll
- the collectionsep
- the separatoruserLang
- the ISO-639 language code to be used to retrieve localized titlesUtil.join(Iterator,String,int,String)
public static java.lang.String join(java.util.Iterator it, java.lang.String sep, java.lang.String userLang)
getDataName(userLang)
method for each iterated
Data.it
- the iterator of the collectionsep
- the separatoruserLang
- the ISO-639 language code to be used to retrieve localized titlesUtil.join(Iterator,String,int,String)
public static java.util.Map expandArray(java.util.Map mlMap, java.util.Map main)
mlMap
- Map of key / String[]main
- Map of key / String[] used to calculate String[] lengthpublic static java.lang.String[] expandArray(java.lang.String[] array, java.lang.String[] main)
array
- String[]main
- String[] used to calculate String[] lengthpublic static java.util.Date getScheduleDate(java.util.Date reference, long schedule, boolean forward)
reference
- the reference starting dateforward
- forward to now or backward before nowschedule
- the time to add to reference date.public static java.util.Date getScheduleDate(java.util.Date reference, java.util.Date targetDate, long schedule, boolean forward)
reference
- the reference starting datetargetDate
- the target dateschedule
- the time to add to reference date.forward
- should forward or backward to targetDatepublic static java.util.Date[] getScheduleDate(java.util.Date reference, java.util.Date targetDate, java.util.Date[] toUpdate, long schedule, boolean forward)
reference
- the reference starting datetargetDate
- the target datetoUpdate
- the date to updateschedule
- the time to add to reference date.forward
- should forward or backward to targetDatepublic static int loopScheduleDate(java.util.Calendar refCal, java.util.Calendar nowCal, int[] modifiers, boolean forward)
refCal
- the reference starting calendarnowCal
- the target calendarmodifiers
- the modifier provides by getScheduleModifier()forward
- should forward or backward to targetDatepublic static int loopScheduleDate(java.util.Calendar refCal, int[] modifiers, boolean forward, int maxloop)
refCal
- the reference starting calendarmodifiers
- the modifier provides by getScheduleModifier()forward
- should forward or backward to targetDatemaxloop
- the loop to do or -1public static int[] getScheduleModifier(long schedule, boolean forward)
schedule
- the time to add to reference date.forward
- should forward or backward to targetDatepublic static java.lang.String parseSchedule(java.lang.String schedule, java.lang.String period, java.lang.String lang)
schedule
- the scheduleperiod
- the period ("everyhour", "everyday", "everyweek", "everymonth")lang
- the language to format the resultpublic static java.lang.String formatSchedule(java.lang.String userLang, java.lang.String schedule)
30 20 * * 3 *
will be
formatted as Every Tuesday at 8:30 PM.userLang
- the user languageschedule
- the cron schedule to be formatted.public static java.util.SortedSet<java.util.Date> stringToDateSet(java.lang.String timesString)
timesString
- a String with comma sperated times in millissecondpublic static java.lang.String dateSetToString(java.util.SortedSet<java.util.Date> dateSet)
dateSet
- a SortedSet of Date.public static java.lang.String getWebappClasspath()
public static java.io.FileFilter getIgnoredResourcesFileFiler()
"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.
getIgnoredResourcesFileFiler(boolean)
public static java.io.FileFilter getIgnoredResourcesFileFiler(boolean accept)
"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.
accept
- true to accept ignored Files and refuse all other,
false to refuse ignored Files and accept all others.public static java.lang.String getPrefixedTitle(java.lang.String prefix, java.lang.String title, boolean replaceOnly)
prefix
- the prefix to appendtitle
- the titlereplaceOnly
- if true does not append the prefixpublic static void jsp2File(java.lang.String jsp, java.lang.String filename, java.util.HashMap sessionAttributeMap) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".filename
- the output file where the jsp process is writtensessionAttributeMap
- the session attributesjava.lang.Exception
- If an error occurspublic static void jsp2File(java.lang.String jsp, java.lang.String filename, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, Member loggedMember) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".filename
- the output file where the jsp process is writtenrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parametersloggedMember
- the logged member used to process the JSPjava.lang.Exception
- If an error occurspublic static void jsp2File(java.lang.String jsp, java.lang.String filename, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, Member loggedMember, boolean clean) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".filename
- the output file where the jsp process is writtenrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parametersloggedMember
- the logged member used to process the JSPclean
- if true the compiled servlet is removed once processed.java.lang.Exception
- If an error occurspublic static void jsp2OutputStream(java.lang.String jsp, java.io.OutputStream out, java.util.HashMap sessionAttributeMap) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".out
- the outputstreamsessionAttributeMap
- the session attributesjava.lang.Exception
- If an error occurspublic static void jsp2OutputStream(java.lang.String jsp, java.io.OutputStream out, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, Member loggedMember) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".out
- the outputstreamrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parametersloggedMember
- the logged member used to process the JSPjava.lang.Exception
- If an error occurspublic static void jsp2OutputStream(java.lang.String jsp, java.io.OutputStream out, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, Member loggedMember, boolean clean) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".out
- the outputstreamrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parametersloggedMember
- the logged member used to process the JSPclean
- if true the compiled servlet is removed once processed.java.lang.Exception
- If an error occurspublic static void jsp2OutputStream(java.lang.String jsp, java.io.OutputStream out, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, java.lang.String trashPath, java.lang.String rootPath, java.lang.ClassLoader classloader, java.lang.String classpath) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".out
- the outputstreamrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parameterstrashPath
- the trash pathrootPath
- the root pathclassloader
- the classloaderclasspath
- the classpathjava.lang.Exception
- If an error occurspublic static void jsp2OutputStream(java.lang.String jsp, java.io.OutputStream out, java.util.HashMap requestParameterMap, java.util.HashMap requestAttributeMap, java.util.HashMap sessionAttributeMap, java.util.HashMap contextAttributeMap, java.util.HashMap initParameterMap, java.lang.String trashPath, java.lang.String rootPath, java.lang.ClassLoader classloader, java.lang.String classpath, boolean clean) throws java.lang.Exception
jsp
- the JSP to be rendered. It must start with "/".out
- the outputstreamrequestParameterMap
- the request parametersrequestAttributeMap
- the request attributessessionAttributeMap
- the session attributescontextAttributeMap
- the context attributesinitParameterMap
- the init parameterstrashPath
- the trash pathrootPath
- the root pathclassloader
- the classloaderclasspath
- the classpathclean
- if true the compiled servlet is removed once processed.java.lang.Exception
- If an error occurspublic static void jsp2FileCleanTrash()
public static void restartWebapp(java.io.File file)
public static java.lang.String escapeHtml(java.lang.String str)
The side effect of using this method is that the resulting content can only be
outputed to an HTML stream. If the content is printed in a plaintext, csv, mail
or other non HTML stream, characters "<" and "&" will appear as HTML entity.
To limit this side effect, ampersand are only escaped when they would match
an HTML entity (thus being interpreted by browser at display/re-edition).
This method perform 2 pattern replacements :
s/ &([^\s;]{2,20}); / &$1; /g s/ < / < /gAmpersand (&) are converted in the corresponding HTML entity since JCMS 7.0.4 and 7.1.1.
str
- the string to be escapedpublic static java.lang.String unescapeHtml(java.lang.String str)
This method does the opposite work of escapeHtml(String)
.
str
- the string to be escapedpublic static ControllerStatus checkHtml(java.lang.String str, java.lang.String field)
str
- the string to be checkedfield
- the name of the field which is checkedBasicRightPolicyFilter.checkHtml(String,String)
public static ControllerStatus checkHtml(java.lang.String[] array, java.lang.String field)
array
- the array of string to be checkedfield
- the name of the field which is checkedcheckHtml(String,String)
public static ControllerStatus checkHtml(java.util.Map map, java.lang.String field)
map
- the map with the values to be checkedfield
- the name of the field which is checkedcheckHtml(String,String)
public static Data[] getUpdatedData(Data[] old, java.util.Map dataMap)
old
- an array of DatadataMap
- the data map to fillpublic static java.util.TreeSet getUpdatedData(java.util.Collection old, java.util.Map dataMap, boolean retrieveAll)
old
- the old set of datadataMap
- the mapretrieveAll
- if newdata doesn't exists then leave old datapublic static java.util.TreeSet getUpdatedData(java.util.Collection old, java.util.Map dataMap)
old
- the old set of datadataMap
- the mapgetUpdatedData(Collection, Map, boolean)
public static ControllerStatus checkFieldMLRequired(Publication pub, java.lang.String fieldName, java.lang.String value, java.util.HashMap valueML)
pub
- the publicationfieldName
- the name of the fieldvalue
- the value of the fieldvalueML
- the ML value of the fieldpublic static ControllerStatus checkFieldRequired(Publication pub, java.lang.String fieldName, java.lang.Object value)
pub
- the publicationfieldName
- the name of the fieldvalue
- the value of the fieldpublic static java.lang.String glpd(java.lang.String prop)
prop
- the language property to resolve, for example "ui.com.lbl.contents"public static java.lang.String glpdNoDefault(java.lang.String prop)
prop
- the language property to resolve, for example "ui.com.lbl.contents"public static java.lang.String glp(java.lang.String lang, java.lang.String prop, java.lang.Object... params)
Example :
assertEquals("1 byte", JcmsUtil.glpNull("en", "ui.com.lbl.byte", 1)); assertEquals("6 bytes", JcmsUtil.glpNull("en", "ui.com.lbl.byte", 6)); assertEquals("non.existing.property", JcmsUtil.glpNull("en", "non.existing.property"));
lang
- the language in which you want the given propertyprop
- the language property to resolve, for example "ui.com.lbl.contents"params
- an array of parameters to use to for the format of propertypublic static java.lang.String glp(java.lang.String lang, java.lang.String prop, java.util.Map<java.lang.String,java.lang.String> paramMap)
Example :
Mapwith the given property:paramMap = new HashMap (); paramMap.put("firstName", "John"); paramMap.put("lastName", "Doe"); String i18nStr = getExplicitLangProperty("my.property", "en", paramMap);
my.property: Hello {firstName} {lastName}
lang
- the language in which you want the given propertyprop
- the language property to resolve, for example "ui.com.lbl.contents"paramMap
- an map of parameters, where the key is the name of the parameter in the propertypublic static java.lang.String glp(java.lang.String lang, LangProperty prop)
lang
- the language in which you want the given propertyprop
- the LangProperty
instance corresponding to the property you want to resolve.public static java.lang.String glpNoDefault(java.lang.String lang, java.lang.String prop, java.lang.Object... params)
Example :
assertEquals("1 byte", JcmsUtil.glpNull("en", "ui.com.lbl.byte", 1)); assertEquals("6 bytes", JcmsUtil.glpNull("en", "ui.com.lbl.byte", 6)); assertNull(JcmsUtil.glpNull("en", "non.existing.property"));
lang
- the language in which you want the given propertyprop
- the language property to resolve, for example "ui.com.lbl.contents"params
- an array of parameters to use to for the format of propertypublic static void setLog4jMDC()
JcmsPatternLayout
in log4j.xml with the pattern %s
MDC
variables for the current thread.
Important Do not use this method anymore as it cannot be easily guaranteed to be memory leak free.
public static void setLog4jNDCMemberInfo(javax.servlet.http.HttpServletRequest request, Member loggedMember)
NDC
with the given
logged member information. Channel.getCurrentDelegateMember()
].request
- the current HttpServletRequestloggedMember
- the Member currently loggedpublic static void logForbiddenAccess(org.apache.log4j.Logger lgr, org.apache.log4j.Level level, javax.servlet.http.HttpServletRequest request)
lgr
- the logger to uselevel
- the level of the log messagerequest
- the request where the forbidden is issued frompublic static void logForbiddenAccess(org.apache.log4j.Logger lgr, javax.servlet.http.HttpServletRequest request)
lgr
- the Loggerrequest
- the requestlogForbiddenAccess(Logger lgr, Level level, HttpServletRequest request)
public static void logForbiddenAccess(javax.servlet.http.HttpServletRequest request)
request
- the requestlogForbiddenAccess(Logger lgr, Level level, HttpServletRequest request)
public static void logSecurityIssue(org.apache.log4j.Logger lgr, org.apache.log4j.Level level, java.lang.Object obj)
lgr
- the logger to uselevel
- the level of the log messageobj
- the object (message) to logpublic static void logSecurityIssue(org.apache.log4j.Logger lgr, java.lang.Object obj)
lgr
- the Loggerobj
- the objectlogSecurityIssue(Logger lgr, Level level, Object obj)
public static void logSecurityIssue(java.lang.Object obj)
obj
- the objectlogSecurityIssue(Logger lgr, Level level, Object obj)
public static java.lang.String getPubImg(Publication pub)
pub
- the publicationpublic static java.lang.String getPubIcon(Publication pub)
pub
- the publicationpublic static java.lang.String getClassIcon(java.lang.Class<?> clazz)
Class
object.clazz
- Class
public static java.lang.String getHtmlIcon(java.lang.Class<?> clazz)
Class
object.clazz
- Class
public static boolean isStored(Data data)
data
- the data to be checkedpublic static boolean isPersisted(Data data)
data
- the data to be checkedpublic static <T> java.util.TreeSet<T> select(java.util.Collection<? extends T> dataColl, DataSelector selector, java.util.Comparator comparator)
Collection
of Data
using
the given DataSelector
, and return a TreeSet sorted using the
given Comparator
. Comparator
is given, CdateComparator
is used. T
- any Data typedataColl
- the Collection
of Data
to select.selector
- the DataSelector
to use.comparator
- the Comparator
to use.TreeSet
of Data
.public static java.util.Collection applyDataSelector(java.util.Collection dataColl, DataSelector selector)
DataSelector
by removing non selected Data
from the given Collection
. dataColl
- a Collection
of Data
from which to remove non selected data.selector
- the DataSelector
to applyCollection
that was given but modified.public static void mergeMLMap(java.util.Map mlCopy, java.util.Map mlMain)
mlCopy
- A ML map of the work copymlMain
- A ML map of the main instancepublic static java.lang.String getLangValue(java.util.Map map, java.lang.String lang)
map
- the language map {lang, value}lang
- the language. If null use the main language. If result null, use an arbitrary one.public static java.util.Map<java.lang.String,java.lang.String> getLanguageMap(java.lang.String[] values)
escapeHtml(String)
).values
- the values sorted according the language list.public static java.util.Map<java.lang.String,java.lang.String> getLanguageMap(java.lang.String[] values, boolean escapeHtml)
values
- the values sorted according the language list.escapeHtml
- true to invoke escapeHtml method on each value stored in map, false to leave text as is.public static java.util.Map<java.lang.String,java.lang.String> getLanguageMap(java.lang.String propKey)
propKey
- the property keypublic static java.util.List getLanguageMapList(java.lang.String[] values)
values
- the values sorted according the order then according the language list.public static java.lang.String[] getLanguageArray(java.util.Map map)
null or missing values in the map are replaced with empty string in the array.
map
- the language map {lang, value}Channel.getLanguageList()
. return null if specified map is nullpublic static void addData(java.util.TreeSet set, java.lang.Class clazz, Data data)
set
- the Setclazz
- the class used to filter datadata
- the data to be addedpublic static void addData(java.util.TreeSet set, java.lang.Class clazz, Data[] array)
set
- the Setclazz
- the class used to filter dataarray
- the array of data to be addedpublic static void addData(java.util.TreeSet set, java.lang.Class clazz, java.util.Collection coll)
set
- the Setclazz
- the class used to filter datacoll
- the collection of data to be addedpublic static void addData(java.util.TreeSet set, java.lang.Class clazz, java.util.Map mlMap)
set
- the Setclazz
- the class used to filter datamlMap
- the ML map of data to be addedpublic static void addFileDocument(java.util.Set<FileDocument> set, java.lang.String filename)
set
- a set of FileDocumentfilename
- the filenamepublic static void addFileDocument(java.util.Set<FileDocument> set, java.lang.String... filenames)
set
- a set of FileDocumentfilenames
- an array of filenamepublic static void addFileDocument(java.util.Set<FileDocument> set, java.util.Collection<java.lang.String> filenameColl)
set
- a set of FileDocumentfilenameColl
- a collection of filenamepublic static void addFileDocument(java.util.Set<FileDocument> set, java.lang.String filenameMainLanguage, java.util.Map<java.lang.String,java.lang.String> mlMap)
set
- a set of FileDocumentfilenameMainLanguage
- a filenamemlMap
- a map which contains filename as valuespublic static void addFileDocument(java.util.Set<FileDocument> set, java.lang.String[] filenamesMainLanguage, java.util.Map<java.lang.String,java.lang.String[]> mlMap)
set
- a set of FileDocumentfilenamesMainLanguage
- an array of filenamemlMap
- a map which contains array of filename as valuespublic static java.lang.String getId(Data data)
data
- the data (may be null)public static boolean isSameId(Data d1, Data d2)
d1
- the first datad2
- the second datapublic static java.lang.String getFieldLangAttributes(Data data, java.lang.String fieldName, java.lang.String userLang)
English ("en") | Arabic ("ar") | |
Introduction ("intro") | an introduction | |
Content ("content") | some content | ألف |
getFieldLangAttributes(theSmallNews, "intro", userLang); // userLang='ar'
lang="en" xml:lang="en" dir="ltr"
.getFieldLangAttributes(theSmallNews, "content", userLang); // userLang='ar'
lang="ar" xml:lang="ar" dir="rtl"
.data
- the Publication or Data of which to check field value in given languagefieldName
- the name of the field to check.userLang
- the language in which the field was should be displayedChannel.isUsingAdvancedI18N()
,
Channel.getUsedLanguage(Data, String, String)
,
getLangAttributes(String)
public static java.lang.String getLangAttributes(java.lang.String lang)
For example : lang="fr" xml:lang="fr" dir="ltr"
lang
- the language of which to generate html attributes or null to use default jcms languageChannel.getLanguageDirection(String)
public static java.lang.String getUntranslatedZoneAttribute(java.lang.String lang)
lang
- the current language (ISO-639)Channel.getLanguageDirection(String)
public static java.lang.String getRevision(java.lang.Class clazz)
clazz
- the class to get the revision.public static java.lang.String getReleasedRevision(java.lang.Class clazz)
clazz
- the class to get the revision.public static java.util.List<java.lang.Class<?>> getClassList()
public static java.util.List<java.lang.Class<?>> getClassList(java.lang.String libDir, java.lang.ClassLoader classLoader)
libDir
- the path for lib directoryclassLoader
- the classLoader to be usedpublic static java.lang.String getXHtmlMetaTag(java.lang.String name, java.lang.String content)
name
- the name attributecontent
- the content attributepublic static java.lang.String getXHtmlMetaHttpEquivTag(java.lang.String httpEquiv, java.lang.String content)
httpEquiv
- the httpEquiv attributecontent
- the content attributepublic static java.lang.String getXHtmlMetaTag(java.lang.String keyName, java.lang.String key, java.lang.String content)
keyName
- the name of the key (eg "name", or "http-equiv")key
- the key attributecontent
- the content attributepublic static int[] getPublicationDetails(java.lang.Class clazz, Member mbr, Workspace ws)
clazz
- the classmbr
- the member who performs the requestws
- the workspacepublic static java.util.Set extractExternalUrl(java.lang.String text)
text
- the text to be parsed.public static boolean isAuthorizedToAccessStatusInfo(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
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.public static java.lang.String getWebHelpHome(javax.servlet.http.HttpServletRequest request)
request
- the HttpRequestpublic static java.lang.String getWebHelpUri(javax.servlet.http.HttpServletRequest request, java.lang.String entry)
request
- the HttpRequestentry
- the entry to display the documentationpublic static java.lang.String[] getWebHelpUriAndIcon(javax.servlet.http.HttpServletRequest request, java.lang.String entry, boolean home)
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 pagepublic static java.lang.String getDisplayUrl()
public static java.lang.String getDisplayUrl(Data data, java.util.Locale locale)
DescriptiveURLs
)
the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale)
otherwise, a standard "display.jsp?id=" URL is generated. getDisplayUrl()
.data
- the data for which the URL will be generatedlocale
- the Locale
to use for I18N and localized operationsData.getDisplayUrl(Locale)
public static java.lang.String getDisplayUrl(Data data, java.util.Locale locale, java.lang.String params, boolean escapeAmpersand)
DescriptiveURLs
)
the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale)
otherwise, a standard "display.jsp?id=" URL is generated. String link = JcmsUtil.getDisplayUrl(myFileDoc, userLocale, "details=true&a=b", true);
String redirect = JcmsUtil.getDisplayUrl(homeCat, locale, "mid=" + mbr.getId() + "&jsp=" + ResourceHelper.getMemberDisplay(), false);
data
- the data for which the URL will be generatedlocale
- the Locale
to use for I18N and localized operationsparams
- the parameter string to add, it should not start
with any ampersand ('&' or '&') as it will be added automaticallyescapeAmpersand
- will use "& true, "&" if falsepublic static java.lang.String getDisplayUrlWithUpdatedParams(Data data, java.util.Locale locale, javax.servlet.http.HttpServletRequest request, java.lang.String[] names, java.lang.String[] newValues, java.lang.String[] removePatterns, boolean escapeAmpersand)
DescriptiveURLs
)
the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale)
otherwise, a standard "display.jsp?id=" URL is generated. data
- the data for which the URL will be generatedlocale
- the Locale
to use for I18N and localized operationsrequest
- 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 parametersnewValues
- 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' listescapeAmpersand
- will use "& true, "&" if falsepublic static java.lang.String getAbsDisplayUrlWithUpdatedParams(Data data, java.util.Locale locale, javax.servlet.http.HttpServletRequest request, java.lang.String[] names, java.lang.String[] newValues, java.lang.String[] removePatterns, boolean escapeAmpersand)
DescriptiveURLs
)
the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale)
otherwise, a standard "display.jsp?id=" URL is generated. data
- the data for which the URL will be generatedlocale
- the Locale
to use for I18N and localized operationsrequest
- 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 parametersnewValues
- 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' listescapeAmpersand
- will use "& true, "&" if falsepublic static java.lang.String getDisplayUrlWithAddedParam(Data data, java.util.Locale locale, javax.servlet.http.HttpServletRequest request, java.lang.String name, java.lang.String value, boolean escapeAmpersand)
DescriptiveURLs
)
the url will be generated using DescriptiveURLs.getDescriptiveURL(Data, Locale)
otherwise, a standard "display.jsp?id=" URL is generated. data
- the data for which the URL will be generatedlocale
- the Locale
to use for I18N and localized operationsrequest
- 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 addvalue
- 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 "& true, "&" if falsepublic static java.util.Map<java.lang.String,java.lang.String> getLangMap(org.jdom.Element xmlElt, java.lang.String xmlChildrenName, java.lang.String langProperty, boolean forceMainLanguageValue, java.lang.String missingMainValueInfo)
Build a map containing ISO-639 language code as the key, and I18N strings as the value :
<foobar> <label xml:lang="en"> A foo bar</label> <label xml:lang="fr"> Un foo bar</label> </foobar> [es.prop] whatever.foobar.label: Uno foo bar [de.prop] whatever.foobar.label: Ein foo barThis invocation :
JcmsUtil.getLangMap(foobarXmlElement, "label", "whatever.foobar.label", false null);will result in the following map (if the site has been configure in en/fr/es/de/it languages)
{ "en" -> "A foo bar", "fr" -> "Un foo bar", "es" -> "Uno foo bar", "de" -> "Ein foo bar" }If
forceMainLanguageValue
is set to false
, this method is the same as :
MapSettinglangMap = XmlUtil.getLangChildrenMap(xmlElt, xmlChildName); langMap = JcmsUtil.getLangMapUpdatedFromProperties(langMap, langProperty);
forceMainLanguageValue
argument to true
will
ensure that a non null value is defined for the main language of the site,
either by using another arbitrary language value if possible, or else by
setting string value "???". missingMainValueInfo
is used as a log error message prefix.xmlElt
- the JDOM XML Element in which to look for I18N stringsxmlChildrenName
- the name of the XML children tags to readlangProperty
- the name of the property to readforceMainLanguageValue
- set to true to ensure that a value has been defined for the main languagemissingMainValueInfo
- information message to include in log if value was missing in main language (used only when forceMainLanguageValue is true)XmlUtil.getLangChildrenMap(Element, String)
,
getLangMapUpdatedFromProperties(Map, String)
public static java.util.Map<java.lang.String,java.lang.String> getLangChildrenMap(org.jdom.Element elt, java.lang.String childName, java.lang.String info)
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 languageelt
- the ElementchildName
- the name of the childinfo
- the string to prepend in the error log messagelang
, elt
}.XmlUtil.getLangChildrenMap(Element, String)
public static java.util.Map<java.lang.String,java.lang.String> getLangMapUpdatedFromProperties(java.util.Map<java.lang.String,java.lang.String> langMap, java.lang.String property)
langMap
- the map to update (if null a new one is created and returned)property
- the property to readpublic static java.lang.String getNewDirectory(java.io.File baseDir, java.lang.String subDir)
baseDir
- the base directory (eg /usr/local/tomcat/webapps/jcms/)subDir
- an optionnal sub directory, may be null (eg upload/docs/image/gif/)IOUtil.getNewDirectory(File, String, long)
public static void setDataWriteDisabledMsg(javax.servlet.http.HttpServletRequest request, java.lang.String userLang)
public static boolean checkDataWriteDisabled(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String redirect, java.lang.String userLang) throws java.io.IOException
request
- The current requestresponse
- The current responseredirect
- The wished redirectuserLang
- The lang of the current userjava.io.IOException
- If an error occurspublic static java.lang.String convertMultilingualFieldToXml(java.lang.String mainValue, java.util.Map<java.lang.String,java.lang.String> valuesMap)
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>
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)public static org.jdom.Element convertMultilingualFieldToXmlElement(java.lang.String mainValue, java.util.Map<java.lang.String,java.lang.String> valuesMap)
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>
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)public static java.util.Map<java.lang.String,java.lang.String> convertMultilingualFieldXmlToMap(java.lang.String xml)
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" }
xml
- an xml representation of a multilingual field, as returned by convertMultilingualFieldToXml(String, Map)
public static void checkJDBCConnection(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password) throws java.lang.Exception
driver
- the class name of the JDBC driverurl
- a database url of the form jdbc:subprotocol:subnameuser
- the database user on whose behalf the connection is being madepassword
- the user's passwordjava.lang.Exception
- exceptionpublic static boolean checkUrid(java.lang.String urid)
urid
- the uridpublic static java.lang.String getVirtualId(java.lang.String virtualId, java.lang.String id)
Example :
JcmsUtil.getVirtualId("$jcmsplugin.myplugin.my-virtual-id", "c_42");
will returns :
"$jcmsplugin.myplugin.my-virtual-id"
if this virtual could be resolved to id "c_42"
"c_42"
otherwisevirtualId
- 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 idpublic static java.lang.String getVirtualIdList(java.lang.String stringWithPossiblyVirtualIds, java.lang.String stringOfRealIds)
stringWithPossiblyVirtualIds
- it is a value already used, possibly a virtual idstringOfRealIds
- it is the value newly set. updated or not.public static int getWorkerCount()
public static java.lang.String getIgnoreFileRegexp()
public static java.lang.String getIgnoreSignRegexp()
public static java.lang.String getFriendlyDate(java.util.Date date, int style, boolean showTime, java.util.Locale locale)
date
- the datestyle
- the date and time format style (e.g. DateFormat.SHORT)showTime
- if true show the timelocale
- the localepublic static java.lang.String getFriendlyDate(java.util.Date date, int style, boolean showTime, java.util.Locale locale, boolean beginSentence)
date
- the datestyle
- the date and time format style (e.g. DateFormat.SHORT)showTime
- if true show the timelocale
- the localebeginSentence
- if true returns a string suitable for a sentence beginning.public static java.lang.String getFriendlyPeriod(java.util.Date startDate, java.util.Date endDate, java.util.Locale locale)
startDate
- the start date (must not be null)endDate
- the end date (may be null)locale
- the localepublic static java.lang.String convertUri2Url(java.lang.String text, java.lang.String baseURL)
text
- the text to processbaseURL
- the base URLpublic static ObjectLongTreeMap getFileSizeMap()
public static ObjectLongTreeMap getFileSizeMap(Workspace ws)
ws
- the workspacepublic static java.lang.String getEscapedEmailName(java.lang.String value)
value
- the value to checkCopyright © 2001-2010 Jalios SA. All Rights Reserved.