|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectokapi.tools.OkapiToolUtilities
public class OkapiToolUtilities
Collection of static methods providing common services to tools
Field Summary | |
---|---|
static java.lang.String[] |
hours
|
static java.util.Hashtable |
kindFormattedTable
|
static java.util.Hashtable |
mimeTypesReverseSuffixTable
|
static java.util.Hashtable |
mimeTypesSuffixTable
|
static java.util.Hashtable |
mimeTypesTable
|
static java.lang.String[] |
monthNames
|
static java.lang.String[] |
monthShortNames
|
static java.lang.String[] |
weekdayShortNames
|
Constructor Summary | |
---|---|
OkapiToolUtilities()
|
Method Summary | |
---|---|
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
boolean includeContent,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody)
Same as addArc(xml, arc, pathToParent, pathSegment, user, includeBody); but adds option to exclude content. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
boolean includeContent,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml,
boolean includeCreationDate,
java.util.List timezones,
java.util.Date firstDateWithContent,
java.util.Date lastDateWithContent)
Same as addArc(xml, arc, true, pathToParent, pathSegment, user, includeBody, includeBodyEscapedXml, false, timezones, firstDateWithContent, lastDateWithContent) but also adds includeCreationDate if creation date of Arc and Content should be included. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
boolean includeContent,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml,
boolean includeCreationDate,
java.util.List timezones,
java.util.Date firstDateWithContent,
java.util.Date lastDateWithContent,
java.util.SortedSet allDatesWithContent)
Same as addArc(xml, arc, true, pathToParent, pathSegment, user, includeBody, includeBodyEscapedXml, includeCreationDate, false, timezones, firstDateWithContent, lastDateWithContent) but also adds allDatesWithContent set. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
boolean includeContent,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml,
java.util.List timezones,
java.util.Date firstDateWithContent,
java.util.Date lastDateWithContent)
Same as addArc(xml, arc, includeContent, pathToParent, pathSegment, user, includeBody, includeBodyEscapedXml) but also adds onDateZoned elements for each arc based on the list of timezones and sets firstDateWithContent and lastDateWithContent to the first and last start dates of the arc and its children, for use in calendar tools. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody)
Adds an arc and all of its content and arc children to the xml document. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml)
Same as addArc(xml, arc, pathToParent, pathSegment, user, includeBody) but also adds the body of content atoms as escaped XML even if the body is XML, to facilitate editing of the content atom body. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml,
java.util.List timezones,
java.util.Date firstDateWithContent,
java.util.Date lastDateWithContent)
Same as addArc(xml, arc, pathToParent, pathSegment, user, includeBody, includeBodyEscapedXml) but also adds onDateZoned elements for each arc based on the list of timezones and sets firstDateWithContent and lastDateWithContent to the first and last start dates of the arc and its children, for use in calendar tools. |
static void |
addArc(OkapiXMLDocument xml,
OkapiArc arc,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
java.util.List timezones,
java.util.Date firstDateWithContent,
java.util.Date lastDateWithContent)
Same as addArc(xml, arc, pathToParent, pathSegment, user, includeBody) but also adds onDateZoned elements for each arc based on the list of timezones and sets firstDateWithContent and lastDateWithContent to the first and last start dates of the arc and its children, for use in calendar tools. |
static void |
addBackInfo(OkapiXMLDocument xml,
javax.servlet.http.HttpServletRequest request)
Adds the href of the refering page, based on the backURL parameter of the referer head if the parameter is not set. |
static void |
addBasicSubjectInfo(OkapiXMLDocument xml,
OkapiNexus nexus)
Adds basic subject info with no enclosing tags to the xml document, to be used when additional elements are needed so addSubjectInfo() cannot be used. |
static void |
addBasicSubjectInfo(OkapiXMLDocument xml,
OkapiNexus nexus,
boolean omitDescription)
Adds basic subject info with no enclosing tags to the xml document, to be used when additional elements are needed so addSubjectInfo() cannot be used. |
static void |
addBasicUserInfo(OkapiXMLDocument xml,
OkapiUser user)
Adds basic user info with no enclosing tags to the xml dcoument, to be used when additional elements are needed so addUserInfo() cannot be used. |
static void |
addContent(OkapiXMLDocument xml,
OkapiContent content,
java.lang.String pathToParent,
java.lang.String pathSegment,
OkapiUser user,
boolean includeBody,
boolean includeBodyEscapedXml,
boolean includeCreationDate)
Adds a content and its children and atoms to the xml document. |
static void |
addCrumbsAndNexusHref(OkapiXMLDocument xml,
javax.servlet.http.HttpServletRequest request,
java.util.List nexusHistory,
java.lang.String toolName)
Adds a full breadCrumbTrail element and a nexusHref element to the xml document. |
static void |
addCrumbsAndNexusHrefWithSublist(OkapiXMLDocument xml,
javax.servlet.http.HttpServletRequest request,
java.util.List nexusHistory,
java.util.List toolHistory,
java.lang.String toolName)
Adds a full breadCrumbTrail element and a nexusHref element to the xml document. |
static void |
addDateTag(OkapiXMLDocument xml,
java.util.Date date)
Adds a date tag to the xml document for the specified date. |
static java.lang.String |
addNexusCrumbs(OkapiXMLDocument xml,
javax.servlet.http.HttpServletRequest request,
java.util.List nexusHistory)
Adds crumbs elements for all the nexuses in the nexusHistory with no enclosing tag, to be used when addCrumbsAndNexusHref() does not provide the necessary complete breadcrumb trail. |
static void |
addPageIntroText(OkapiXMLDocument xml,
OkapiNexus thisNexus,
java.lang.String pageName)
Method addPageIntroText |
static void |
addRequestParameters(OkapiXMLDocument xml,
javax.servlet.http.HttpServletRequest request)
Also adds all request parameters to the XML. |
static void |
addSubjectInfo(OkapiXMLDocument xml,
OkapiNexus nexus)
Adds a subject tag to the xml document containing basic subject data provided by addBasicSubjectInfo(). |
static void |
addSubjectInfoAndSections(OkapiXMLDocument xml,
OkapiNexus nexus)
Adds a subject tag to the xml document containing all the data from addSubjectInfo() with additional elements for the sections in this nexus and its children. |
static void |
addSubjectInfoAndSections(OkapiXMLDocument xml,
OkapiNexus nexus,
boolean includeDecativatedSections)
Adds a subject tag to the xml document containing all the data from addSubjectInfo() with additional elements for the sections in this nexus and its children. |
static void |
addUserEReservesAccess(OkapiXMLDocument xml,
OkapiUser user,
OkapiNexus thisNexus)
Add EReserves, or generally third-party, fair-use copyright material access tags. |
static void |
addUserInfo(OkapiXMLDocument xml,
OkapiUser user)
Adds a user tag to the xml document containing basic user data provided by addBasicUserInfo(). |
static void |
addUserInfo(OkapiXMLDocument xml,
OkapiUser user,
boolean canModify,
boolean showToolset)
Same as addUserInfo(xml, user) but adds additional canModify and showToolset elements. |
static void |
addUserInfo(OkapiXMLDocument xml,
OkapiUser user,
boolean canModify,
boolean hasModify,
boolean showToolset)
Same as addUserInfo(xml, user) but adds additional canModify, hasModify, and showToolset elements. |
static boolean |
canModify(OkapiUser user,
OkapiNexus nexus)
Determines whether the user should be allowed to modify the nexus by checking the users authorization and overriding if the nexus is read only. |
static java.util.Date |
convertToDate(java.lang.Object year,
java.lang.Object month,
java.lang.Object day,
java.lang.Object hour,
java.lang.Object minute)
return date given year, month, day, hour, and minute as strings. |
static java.lang.String |
errorHtml()
Method errorHtml |
static java.lang.String |
errorHtml(java.lang.String header,
java.lang.String addBody)
Method errorHtml |
static java.lang.String |
fixFileName(java.lang.String filepath)
Generates a sql safe filename from a filepath by attempting to find the last path segment in the filepath, removing unsafe characters, and shortening to under 50 characters. |
static OkapiArc |
getArc(OkapiNexus nexus,
java.lang.String[] path)
Returns the arc at the specified path within the specified nexus, or null if there is no such arc. |
static OkapiContent |
getContent(java.util.List pathVector,
java.lang.String pathSegment,
javax.servlet.http.HttpServletRequest request,
OkapiNexus thisNexus)
Finds the content located in the last nexus in this nexusHistory at the arc indicated by pathSegment at the path indicated by pathVector. |
static int |
getHourNumber(java.lang.String hourString)
Returns the int value for hour expressed as 12am, 1am, etc. |
static int |
getMonthNumber(java.lang.String monthName)
Returns the java.util.Calendar constant for the given month name. |
static java.lang.String |
getPath(java.util.List pathVector)
Creates a path string from a vector of path segments by joining each segment with a forward slash. |
static java.lang.String |
getPath(OkapiNexus nexus)
Reconstruct parentage of nexus, with no preceding or following /. |
static java.util.Vector |
getPathVector(java.lang.String path)
Creates a vector of path segments from a path by tokenizing on forward slash. |
static OkapiStore |
getStore(java.util.List pathVector,
java.lang.String pathSegment,
OkapiNexus thisNexus)
Finds the store located in the last nexus in this nexusHistory at the arc indicated by pathSegment at the path indicated by pathVector. |
static java.lang.String |
getStoreAsString(OkapiStore store)
Returns the text of a store as a String. |
static boolean |
hasModify(OkapiUser user,
OkapiNexus nexus)
Determines whether the user should be allowed to modify the nexus by checking the users authorization, but not overriding if the nexus is read only. |
static java.lang.String |
tidy(java.io.BufferedInputStream in)
Returns a 'tidy' version of the characters read from the input stream or null if tidy finds any errors. |
static java.lang.String |
tidy(java.io.BufferedInputStream in,
boolean notEncloseText)
Returns a 'tidy' version of the characters read from the input stream, or null if tidy find any errors. |
static java.lang.String |
tidy(java.lang.String s)
Returns a 'tidy' version of the String, or null if tidy finds any errors. |
static java.lang.String |
tidy(java.lang.String s,
boolean notEncloseText)
Returns a 'tidy' version of the String, or null if tidy finds any errors. |
static java.lang.String |
tidy(java.lang.String s,
boolean notEncloseText,
boolean notConvertNewlines)
Returns a 'tidy' version of the String, or null if tidy finds any errors. |
static java.lang.String |
tidy(java.lang.String s,
boolean notEncloseText,
boolean notConvertNewlines,
boolean autoConvertUrls)
Returns a 'tidy' version of the String, or null if tidy finds any errors. |
static java.lang.String |
turnHttpToLink(java.lang.String raw)
Method turnHttpToLink replace lone http, mailto, news, or ftp to link |
static boolean |
updateToolsetStatus(javax.servlet.http.HttpServletRequest request)
Updates the status of the toolset by looking for a current status stored in the session and a new value in the request. |
static java.lang.String |
urlDecode(java.lang.String uri)
Decode URL using java.net.URLDecoder.decode Convenience method which catches a java.io.UnsupportedEncodingException |
static java.lang.String |
urlEncode(java.lang.String uri)
Encode URL using java.net.URLEncoder.encode Convenience method which catches a java.io.UnsupportedEncodingException |
static boolean |
userHasGraderRole(OkapiUser user,
OkapiNexus nexus)
Return true if user has role of GRADER in this nexus. |
static boolean |
userHasManagerRole(OkapiUser user,
OkapiNexus nexus)
Return true if user has role of MANAGER in this nexus. |
static boolean |
userIsClassStaff(OkapiUser user,
OkapiNexus nexus)
Return true if user has role of COURSE_ADMIN or better in this nexus. |
static boolean |
userIsStudentOrLearner(OkapiUser user,
OkapiNexus nexus)
Return true if one of the user's role is as a STUDENT or LEARNER in this nexus. |
static OkapiToolUserNexusRoleInfo |
userNexusRoleInfo(OkapiUser user,
OkapiNexus nexus)
Return OkapiToolUserNexusRoleInfo object for user in this nexus; provides highest role info, etc. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] monthNames
public static final java.lang.String[] monthShortNames
public static final java.lang.String[] hours
public static final java.lang.String[] weekdayShortNames
public static final java.util.Hashtable mimeTypesTable
public static java.util.Hashtable mimeTypesSuffixTable
public static java.util.Hashtable mimeTypesReverseSuffixTable
public static final java.util.Hashtable kindFormattedTable
Constructor Detail |
---|
public OkapiToolUtilities()
Method Detail |
---|
public static boolean updateToolsetStatus(javax.servlet.http.HttpServletRequest request)
public static boolean canModify(OkapiUser user, OkapiNexus nexus)
public static boolean hasModify(OkapiUser user, OkapiNexus nexus)
public static OkapiToolUserNexusRoleInfo userNexusRoleInfo(OkapiUser user, OkapiNexus nexus)
public static boolean userIsStudentOrLearner(OkapiUser user, OkapiNexus nexus)
public static boolean userIsClassStaff(OkapiUser user, OkapiNexus nexus)
public static boolean userHasGraderRole(OkapiUser user, OkapiNexus nexus)
public static boolean userHasManagerRole(OkapiUser user, OkapiNexus nexus)
public static void addSubjectInfoAndSections(OkapiXMLDocument xml, OkapiNexus nexus)
public static void addSubjectInfoAndSections(OkapiXMLDocument xml, OkapiNexus nexus, boolean includeDecativatedSections)
public static void addSubjectInfo(OkapiXMLDocument xml, OkapiNexus nexus)
public static void addBasicSubjectInfo(OkapiXMLDocument xml, OkapiNexus nexus)
public static void addBasicSubjectInfo(OkapiXMLDocument xml, OkapiNexus nexus, boolean omitDescription)
public static void addUserInfo(OkapiXMLDocument xml, OkapiUser user)
public static void addUserInfo(OkapiXMLDocument xml, OkapiUser user, boolean canModify, boolean showToolset)
public static void addUserInfo(OkapiXMLDocument xml, OkapiUser user, boolean canModify, boolean hasModify, boolean showToolset)
public static void addBasicUserInfo(OkapiXMLDocument xml, OkapiUser user)
public static void addUserEReservesAccess(OkapiXMLDocument xml, OkapiUser user, OkapiNexus thisNexus)
public static java.lang.String getPath(OkapiNexus nexus)
public static java.lang.String getPath(java.util.List pathVector)
public static java.util.Vector getPathVector(java.lang.String path)
public static OkapiArc getArc(OkapiNexus nexus, java.lang.String[] path)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, boolean includeContent, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, java.util.List timezones, java.util.Date firstDateWithContent, java.util.Date lastDateWithContent)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml, java.util.List timezones, java.util.Date firstDateWithContent, java.util.Date lastDateWithContent)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, boolean includeContent, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml, java.util.List timezones, java.util.Date firstDateWithContent, java.util.Date lastDateWithContent)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, boolean includeContent, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml, boolean includeCreationDate, java.util.List timezones, java.util.Date firstDateWithContent, java.util.Date lastDateWithContent)
public static void addArc(OkapiXMLDocument xml, OkapiArc arc, boolean includeContent, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml, boolean includeCreationDate, java.util.List timezones, java.util.Date firstDateWithContent, java.util.Date lastDateWithContent, java.util.SortedSet allDatesWithContent)
public static void addContent(OkapiXMLDocument xml, OkapiContent content, java.lang.String pathToParent, java.lang.String pathSegment, OkapiUser user, boolean includeBody, boolean includeBodyEscapedXml, boolean includeCreationDate)
public static void addBackInfo(OkapiXMLDocument xml, javax.servlet.http.HttpServletRequest request)
public static void addRequestParameters(OkapiXMLDocument xml, javax.servlet.http.HttpServletRequest request)
public static java.lang.String addNexusCrumbs(OkapiXMLDocument xml, javax.servlet.http.HttpServletRequest request, java.util.List nexusHistory)
public static void addCrumbsAndNexusHref(OkapiXMLDocument xml, javax.servlet.http.HttpServletRequest request, java.util.List nexusHistory, java.lang.String toolName)
public static void addCrumbsAndNexusHrefWithSublist(OkapiXMLDocument xml, javax.servlet.http.HttpServletRequest request, java.util.List nexusHistory, java.util.List toolHistory, java.lang.String toolName)
public static void addDateTag(OkapiXMLDocument xml, java.util.Date date)
public static void addPageIntroText(OkapiXMLDocument xml, OkapiNexus thisNexus, java.lang.String pageName)
xml
- thisNexus
- pageName
- public static OkapiContent getContent(java.util.List pathVector, java.lang.String pathSegment, javax.servlet.http.HttpServletRequest request, OkapiNexus thisNexus) throws OkapiPermissionDeniedException, OkapiAuthenticationRequiredException
OkapiPermissionDeniedException
OkapiAuthenticationRequiredException
public static OkapiStore getStore(java.util.List pathVector, java.lang.String pathSegment, OkapiNexus thisNexus)
public static java.lang.String getStoreAsString(OkapiStore store)
public static java.lang.String fixFileName(java.lang.String filepath)
public static java.lang.String errorHtml()
public static java.lang.String errorHtml(java.lang.String header, java.lang.String addBody)
header
- addBody
-
public static java.lang.String turnHttpToLink(java.lang.String raw)
raw
-
public static java.lang.String tidy(java.lang.String s)
public static java.lang.String tidy(java.lang.String s, boolean notEncloseText)
public static java.lang.String tidy(java.lang.String s, boolean notEncloseText, boolean notConvertNewlines)
public static java.lang.String tidy(java.lang.String s, boolean notEncloseText, boolean notConvertNewlines, boolean autoConvertUrls)
public static java.lang.String tidy(java.io.BufferedInputStream in)
public static java.lang.String tidy(java.io.BufferedInputStream in, boolean notEncloseText)
public static int getHourNumber(java.lang.String hourString)
public static int getMonthNumber(java.lang.String monthName)
public static java.util.Date convertToDate(java.lang.Object year, java.lang.Object month, java.lang.Object day, java.lang.Object hour, java.lang.Object minute) throws OkapiToolException
OkapiToolException
public static java.lang.String urlEncode(java.lang.String uri)
public static java.lang.String urlDecode(java.lang.String uri)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |