Java Doc for ServletUtil.java in  » Wiki-Engine » JAMWiki » org » jamwiki » servlets » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JAMWiki » org.jamwiki.servlets 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jamwiki.servlets.ServletUtil

ServletUtil
public class ServletUtil (Code)
Utility methods useful when processing JAMWiki servlet requests.


Field Summary
final protected static  StringJSP_ERROR
    
final protected static  StringJSP_LOGIN
    
final public static  StringPARAMETER_PAGE_INFO
    
final public static  StringPARAMETER_TOPIC_OBJECT
    


Method Summary
protected static  StringcachedContent(String context, Locale locale, String virtualWiki, String topicName, boolean cook)
     Retrieve the content of a topic from the cache, or if it is not yet in the cache then add it to the cache.
Parameters:
  context - The servlet context for the topic being retrieved.
protected static  StringcheckForSpam(HttpServletRequest request, String topicName, String contents)
     This is a utility method that will check topic content for spam, and return null if no matching values are found, or if a spam pattern is found then that pattern will be returned.
public static  WikiUserAuthcurrentUser()
     Retrieve the current WikiUserAuth from Acegi SecurityContextHolder.
public static  WatchlistcurrentWatchlist(HttpServletRequest request, String virtualWiki)
     Retrieve the current logged-in user's watchlist from the session.
public static  StringgetIpAddress(HttpServletRequest request)
     Duplicate the functionality of the request.getRemoteAddr() method, but for IPv6 addresses strip off any local interface information (anything following a "%").
Parameters:
  request - the HTTP request object.
protected static  TopicinitializeTopic(String virtualWiki, String topicName)
     Initialize topic values for a Topic object.
protected static  booleanisEditable(String virtualWiki, String topicName, WikiUserAuth user)
     Determine if a user has permission to edit a topic.
Parameters:
  virtualWiki - The virtual wiki name for the topic in question.
Parameters:
  topicName - The name of the topic in question.
Parameters:
  user - The current Wiki user, or null if there isno current user.
protected static  booleanisMoveable(String virtualWiki, String topicName, WikiUserAuth user)
     Determine if a user has permission to move a topic.
Parameters:
  virtualWiki - The virtual wiki name for the topic in question.
Parameters:
  topicName - The name of the topic in question.
Parameters:
  user - The current Wiki user, or null if there isno current user.
protected static  booleanisTopic(HttpServletRequest request, String value)
     Examine the request object, and see if the requested topic or page matches a given value.
Parameters:
  request - The servlet request object.
Parameters:
  value - The value to match against the current topic or page name.
protected static  voidloadCategoryContent(ModelAndView next, String virtualWiki, String topicName)
     Utility method for adding categories associated with the current topic to the ModelAndView object.
protected static  voidloadDefaults(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo)
     This method ensures that values required for rendering a JSP page have been loaded into the ModelAndView object.
public static  PaginationloadPagination(HttpServletRequest request, ModelAndView next)
     Create a Pagination object and load all necessary values into the request for processing by a JSP.
Parameters:
  request - The servlet request object.
Parameters:
  next - A ModelAndView object corresponding to the page beingconstructed.
public static  IteratorprocessMultipartRequest(HttpServletRequest request, String uploadDirectory, long maxFileSize)
     Utility method for parsing a multipart servlet request.
protected static  voidredirect(ModelAndView next, String virtualWiki, String destination)
     Modify the current ModelAndView object to create a Spring redirect response, meaning that the view name becomes "redirect:" followed by the redirection target.
Parameters:
  next - The current ModelAndView object, which will be reset bythis method.
Parameters:
  virtualWiki - The virtual wiki name for the page being redirectedto.
Parameters:
  destination - The topic or page name that is the redirectiontarget.
public static  LocaleretrieveUserLocale(HttpServletRequest request)
     Users can specify a default locale in their preferences, so determine if the current user is logged-in and has chosen a locale.
public static  VirtualWikiretrieveVirtualWiki(String virtualWikiName)
     Given a virtual wiki name, return a VirtualWiki object. If there is no virtual wiki available with the given name then the default virtual wiki is returned.
Parameters:
  virtualWikiName - The name of the virtual wiki that is beingretrieved.
protected static  VectorvalidateSystemSettings(Properties props)
     Validate that vital system properties, such as database connection settings, have been specified properly.
Parameters:
  props - The property object to validate against.
protected static  ModelAndViewviewError(HttpServletRequest request, Throwable t)
     Utility method used when redirecting to an error page.
Parameters:
  request - The servlet request object.
Parameters:
  t - The exception that is the source of the error.
protected static  ModelAndViewviewLogin(HttpServletRequest request, WikiPageInfo pageInfo, String topic, WikiMessage messageObject)
     Utility method used when redirecting to a login page.
Parameters:
  request - The servlet request object.
Parameters:
  pageInfo - The current WikiPageInfo object, which containsinformation needed for rendering the final JSP page.
Parameters:
  topic - The topic to be redirected to.
protected static  voidviewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, String topicName)
     Utility method used when viewing a topic.
Parameters:
  request - The current servlet request object.
Parameters:
  next - The current Spring ModelAndView object.
Parameters:
  pageInfo - The current WikiPageInfo object, which containsinformation needed for rendering the final JSP page.
Parameters:
  topicName - The topic being viewed.
protected static  voidviewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, WikiMessage pageTitle, Topic topic, boolean sectionEdit)
     Utility method used when viewing a topic.

Field Detail
JSP_ERROR
final protected static String JSP_ERROR(Code)



JSP_LOGIN
final protected static String JSP_LOGIN(Code)



PARAMETER_PAGE_INFO
final public static String PARAMETER_PAGE_INFO(Code)



PARAMETER_TOPIC_OBJECT
final public static String PARAMETER_TOPIC_OBJECT(Code)





Method Detail
cachedContent
protected static String cachedContent(String context, Locale locale, String virtualWiki, String topicName, boolean cook)(Code)
Retrieve the content of a topic from the cache, or if it is not yet in the cache then add it to the cache.
Parameters:
  context - The servlet context for the topic being retrieved. Maybe null if the cook parameter is set tofalse.
Parameters:
  locale - The locale for the topic being retrieved. May benull if the cook parameter is set tofalse.
Parameters:
  virtualWiki - The virtual wiki for the topic being retrieved.
Parameters:
  topicName - The name of the topic being retrieved.
Parameters:
  cook - A parameter indicating whether or not the content should beparsed before it is added to the cache. Stylesheet content (CSS) is notparsed, but most other content is parsed. The parsed or unparsed (depending on the cookparameter) topic content.



checkForSpam
protected static String checkForSpam(HttpServletRequest request, String topicName, String contents) throws Exception(Code)
This is a utility method that will check topic content for spam, and return null if no matching values are found, or if a spam pattern is found then that pattern will be returned. It will also log information about the offending spam and user to the logs.
Parameters:
  request - The current servlet request.
Parameters:
  topicName - The name of the current topic being edited.
Parameters:
  contents - The text for the current topic that the user is trying toadd. null if nothing in the topic content matches a currentspam pattern, or the text that matches a spam pattern if one is found.



currentUser
public static WikiUserAuth currentUser() throws AuthenticationCredentialsNotFoundException(Code)
Retrieve the current WikiUserAuth from Acegi SecurityContextHolder. If the current user is not logged-in then this method will return an empty WikiUserAuth object. The current logged-in WikiUserAuth, or an emptyWikiUserAuth if there is no user currently logged in.This method will never return null.
throws:
  AuthenticationCredentialsNotFoundException - If authenticationcredentials are unavailable.



currentWatchlist
public static Watchlist currentWatchlist(HttpServletRequest request, String virtualWiki) throws Exception(Code)
Retrieve the current logged-in user's watchlist from the session. If there is no watchlist return an empty watchlist.
Parameters:
  request - The servlet request object.
Parameters:
  virtualWiki - The virtual wiki for the watchlist being parsed. The current logged-in user's watchlist, or an empty watchlistif there is no watchlist in the session.



getIpAddress
public static String getIpAddress(HttpServletRequest request)(Code)
Duplicate the functionality of the request.getRemoteAddr() method, but for IPv6 addresses strip off any local interface information (anything following a "%").
Parameters:
  request - the HTTP request object. The IP address that the request originated from, or 0.0.0.0 ifthe originating address cannot be determined.



initializeTopic
protected static Topic initializeTopic(String virtualWiki, String topicName) throws Exception(Code)
Initialize topic values for a Topic object. This method will check to see if a topic with the specified name exists, and if it does exist then that topic will be returned. Otherwise a new topic will be initialized, setting initial parameters such as topic name, virtual wiki, and topic type.
Parameters:
  virtualWiki - The virtual wiki name for the topic beinginitialized.
Parameters:
  topicName - The name of the topic being initialized. A new topic object with basic fields initialized, or if a topicwith the given name already exists then the pre-existing topic isreturned.
throws:
  Exception - Thrown if any error occurs while retrieving orinitializing the topic object.



isEditable
protected static boolean isEditable(String virtualWiki, String topicName, WikiUserAuth user) throws Exception(Code)
Determine if a user has permission to edit a topic.
Parameters:
  virtualWiki - The virtual wiki name for the topic in question.
Parameters:
  topicName - The name of the topic in question.
Parameters:
  user - The current Wiki user, or null if there isno current user. true if the user is allowed to edit the topic,false otherwise.



isMoveable
protected static boolean isMoveable(String virtualWiki, String topicName, WikiUserAuth user) throws Exception(Code)
Determine if a user has permission to move a topic.
Parameters:
  virtualWiki - The virtual wiki name for the topic in question.
Parameters:
  topicName - The name of the topic in question.
Parameters:
  user - The current Wiki user, or null if there isno current user. true if the user is allowed to move the topic,false otherwise.



isTopic
protected static boolean isTopic(HttpServletRequest request, String value)(Code)
Examine the request object, and see if the requested topic or page matches a given value.
Parameters:
  request - The servlet request object.
Parameters:
  value - The value to match against the current topic or page name. true if the value matches the current topic orpage name, false otherwise.



loadCategoryContent
protected static void loadCategoryContent(ModelAndView next, String virtualWiki, String topicName) throws Exception(Code)
Utility method for adding categories associated with the current topic to the ModelAndView object. This method adds a hashmap of category names and sort keys to the session that can then be retrieved for display during rendering.
Parameters:
  next - The current ModelAndView object used to return renderinginformation.
Parameters:
  virtualWiki - The virtual wiki name for the topic being rendered.
Parameters:
  topicName - The name of the topic that is being rendered.



loadDefaults
protected static void loadDefaults(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception(Code)
This method ensures that values required for rendering a JSP page have been loaded into the ModelAndView object. Examples of values that may be handled by this method include topic name, username, etc.
Parameters:
  request - The current servlet request object.
Parameters:
  next - The current ModelAndView object.
Parameters:
  pageInfo - The current WikiPageInfo object, containing basic pagerendering information.



loadPagination
public static Pagination loadPagination(HttpServletRequest request, ModelAndView next)(Code)
Create a Pagination object and load all necessary values into the request for processing by a JSP.
Parameters:
  request - The servlet request object.
Parameters:
  next - A ModelAndView object corresponding to the page beingconstructed. A Pagination object constructed from parameters found in therequest object.



processMultipartRequest
public static Iterator processMultipartRequest(HttpServletRequest request, String uploadDirectory, long maxFileSize) throws Exception(Code)
Utility method for parsing a multipart servlet request. This method returns an iterator of FileItem objects that corresponds to the request.
Parameters:
  request - The servlet request containing the multipart request.
Parameters:
  uploadDirectory - The directory into which files will be uploaded.
Parameters:
  maxFileSize - The maximum allowed file size in bytes. Returns an iterator of FileItem objects the corresponds to the request.
throws:
  Exception - Thrown if any problems occur while processing the request.



redirect
protected static void redirect(ModelAndView next, String virtualWiki, String destination) throws Exception(Code)
Modify the current ModelAndView object to create a Spring redirect response, meaning that the view name becomes "redirect:" followed by the redirection target.
Parameters:
  next - The current ModelAndView object, which will be reset bythis method.
Parameters:
  virtualWiki - The virtual wiki name for the page being redirectedto.
Parameters:
  destination - The topic or page name that is the redirectiontarget. An example might be "Special:Login".



retrieveUserLocale
public static Locale retrieveUserLocale(HttpServletRequest request)(Code)
Users can specify a default locale in their preferences, so determine if the current user is logged-in and has chosen a locale. If not, use the default locale from the request object.
Parameters:
  request - The request object for the HTTP request. Either the user's default locale (for logged-in users) or thelocale specified in the request if no default locale is available.



retrieveVirtualWiki
public static VirtualWiki retrieveVirtualWiki(String virtualWikiName)(Code)
Given a virtual wiki name, return a VirtualWiki object. If there is no virtual wiki available with the given name then the default virtual wiki is returned.
Parameters:
  virtualWikiName - The name of the virtual wiki that is beingretrieved. A VirtualWiki object. If there is no virtualwiki available with the given name then the default virtual wiki isreturned.



validateSystemSettings
protected static Vector validateSystemSettings(Properties props)(Code)
Validate that vital system properties, such as database connection settings, have been specified properly.
Parameters:
  props - The property object to validate against. A Vector of WikiMessage objects containing any errors encountered,or an empty Vector if no errors are encountered.



viewError
protected static ModelAndView viewError(HttpServletRequest request, Throwable t)(Code)
Utility method used when redirecting to an error page.
Parameters:
  request - The servlet request object.
Parameters:
  t - The exception that is the source of the error. Returns a ModelAndView object corresponding to the error page display.



viewLogin
protected static ModelAndView viewLogin(HttpServletRequest request, WikiPageInfo pageInfo, String topic, WikiMessage messageObject) throws Exception(Code)
Utility method used when redirecting to a login page.
Parameters:
  request - The servlet request object.
Parameters:
  pageInfo - The current WikiPageInfo object, which containsinformation needed for rendering the final JSP page.
Parameters:
  topic - The topic to be redirected to. Valid examples are"Special:Admin", "StartingPoints", etc.
Parameters:
  messageObject - A WikiMessage object to be displayed on the loginpage. Returns a ModelAndView object corresponding to the login pagedisplay.
throws:
  Exception - Thrown if any error occurs during processing.



viewTopic
protected static void viewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, String topicName) throws Exception(Code)
Utility method used when viewing a topic.
Parameters:
  request - The current servlet request object.
Parameters:
  next - The current Spring ModelAndView object.
Parameters:
  pageInfo - The current WikiPageInfo object, which containsinformation needed for rendering the final JSP page.
Parameters:
  topicName - The topic being viewed. This value must be a validtopic that can be loaded as a org.jamwiki.model.Topic object.
throws:
  Exception - Thrown if any error occurs during processing.



viewTopic
protected static void viewTopic(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, WikiMessage pageTitle, Topic topic, boolean sectionEdit) throws Exception(Code)
Utility method used when viewing a topic.
Parameters:
  request - The current servlet request object.
Parameters:
  next - The current Spring ModelAndView object.
Parameters:
  pageInfo - The current WikiPageInfo object, which containsinformation needed for rendering the final JSP page.
Parameters:
  pageTitle - The title of the page being rendered.
Parameters:
  topic - The Topic object for the topic being displayed.
Parameters:
  sectionEdit - Set to true if edit links should be displayedfor each section of the topic.
throws:
  Exception - Thrown if any error occurs during processing.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.