Package nzilbb.labbcat.server.servlet
Class LabbcatServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- nzilbb.labbcat.server.servlet.LabbcatServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class LabbcatServlet extends javax.servlet.http.HttpServlet
Base class for other servlets.- Author:
- Robert Fromont robert@fromont.net.nz
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LabbcatServlet()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description File
getAnnotatorDir()
Returns the location of the annotators directory.File
getFilesDir()
Returns the root of the persistent file system.static String
GetSystemAttribute(String name, Connection db)
Gets the value of the given system attribute.File
getTranscriberDir()
Returns the location of the transcribers directory.ResourceBundle
inferResourceBundle(javax.servlet.http.HttpServletRequest request)
Localizes the given message to the language found in the "Accept-Language" header of the given request, substituting in the given arguments if any.void
init()
Initialise the servlet by loading the database connection settings.static boolean
IsUserInRole(String role, javax.servlet.http.HttpServletRequest request, Connection db)
Determines whether the logged-in user is in the given role.static void
ResponseAttachmentName(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String fileName)
Sets the Content-Disposition header of the given Response correctly for saving a file to the given name.
-
-
-
Method Detail
-
init
public void init()
Initialise the servlet by loading the database connection settings.- Overrides:
init
in classjavax.servlet.GenericServlet
-
IsUserInRole
public static boolean IsUserInRole(String role, javax.servlet.http.HttpServletRequest request, Connection db) throws SQLException
Determines whether the logged-in user is in the given role.Side effects:
- The session has a possibly new attribute called "security" which indicates what type of security is being used; one of "none", "JDBCRealm", "JNDIRealm"
- The session has a possibly new set of attributes called "group_role", one for each role the user has.
- The request may have a new attribute called "reset_password", if they are marked for resetting their password.
- Parameters:
role
- The desired role.request
- The request.db
- A connected database connection.- Returns:
- true if the user is in the given role, false otherwise.
- Throws:
SQLException
-
GetSystemAttribute
public static String GetSystemAttribute(String name, Connection db) throws SQLException
Gets the value of the given system attribute.- Parameters:
name
-db
-- Returns:
- Value for the given system attribute, or null if it's not set.
- Throws:
SQLException
-
ResponseAttachmentName
public static void ResponseAttachmentName(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String fileName)
Sets the Content-Disposition header of the given Response correctly for saving a file to the given name.This should handle special characters/spaces in the file name correctly.
- Parameters:
response
- The response to set the header of.fileName
- The file name to save the response body as.
-
inferResourceBundle
public ResourceBundle inferResourceBundle(javax.servlet.http.HttpServletRequest request)
Localizes the given message to the language found in the "Accept-Language" header of the given request, substituting in the given arguments if any.The message is assumed to be a MessageFormat template like "Row could not be added: {0}"
- Parameters:
request
- The request, for discovering the locale.- Returns:
- The resources to use for localization.
-
getFilesDir
public File getFilesDir()
Returns the root of the persistent file system.- Returns:
- The "files" directory.
-
getAnnotatorDir
public File getAnnotatorDir()
Returns the location of the annotators directory.- Returns:
- The annotator installation directory.
-
getTranscriberDir
public File getTranscriberDir()
Returns the location of the transcribers directory.- Returns:
- The transcriber installation directory.
-
-