Package org.eclipse.rdf4j.workbench.util
Class WorkbenchRequest
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- org.eclipse.rdf4j.workbench.util.WorkbenchRequest
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
public class WorkbenchRequest extends javax.servlet.http.HttpServletRequestWrapper
Request wrapper used byTransformationServlet
.
-
-
Constructor Summary
Constructors Constructor Description WorkbenchRequest(Repository repository, javax.servlet.http.HttpServletRequest request, Map<String,String> defaults)
Wrap a request with an object aware of the current repository and application defaults.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getContentFileName()
Get the name of any uploaded file that is part of this request.InputStream
getContentParameter()
Get the content of any uploaded file that is part of this request.int
getInt(String name)
Get the integer value associated with the given parameter name.String
getParameter(String name)
String[]
getParameterValues(String name)
Resource
getResource(String name)
Returns aResource
corresponding to the value of the given parameter name.Map<String,String>
getSingleParameterMap()
Gets a map of the all parameters with values, also caching them in thisWorkbenchRequest
.String
getTypeParameter()
Gets the value of the 'type' parameter.IRI
getURI(String name)
Gets the URI referred to by the parameter value.URL
getUrl(String name)
Gets the URL referred to by the parameter value.Value
getValue(String name)
Gets theValue
referred to by the parameter value.boolean
isParameterPresent(String name)
Returns whether a non-null, non-empty value is available for the given parameter name.-
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole, login, logout, upgrade
-
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getParameterNames, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterMap, getParameterNames, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
-
-
-
Constructor Detail
-
WorkbenchRequest
public WorkbenchRequest(Repository repository, javax.servlet.http.HttpServletRequest request, Map<String,String> defaults) throws RepositoryException, IOException, org.apache.commons.fileupload.FileUploadException
Wrap a request with an object aware of the current repository and application defaults.- Parameters:
repository
- currently connected repositoryrequest
- current requestdefaults
- application default parameter values- Throws:
RepositoryException
- if there is an issue retrieving the parameter mapIOException
- if there is an issue retrieving the parameter maporg.apache.commons.fileupload.FileUploadException
- if there is an issue retrieving the parameter map
-
-
Method Detail
-
getContentParameter
public InputStream getContentParameter()
Get the content of any uploaded file that is part of this request.- Returns:
- the uploaded file contents, or null if not applicable
-
getContentFileName
public String getContentFileName()
Get the name of any uploaded file that is part of this request.- Returns:
- the uploaded file name, or null if not applicable
-
getInt
public int getInt(String name) throws BadRequestException
Get the integer value associated with the given parameter name. Internally uses getParameter(String), so looks in this order: 1. the query parameters that were parsed at construction, using the last value if multiple exist. 2. Request cookies. 3. The defaults.- Returns:
- the value of the parameter, or zero if it is not present
- Throws:
BadRequestException
- if the parameter is present but does not parse as an integer
-
getParameter
public String getParameter(String name)
- Specified by:
getParameter
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameter
in classjavax.servlet.ServletRequestWrapper
-
getParameterValues
public String[] getParameterValues(String name)
- Specified by:
getParameterValues
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterValues
in classjavax.servlet.ServletRequestWrapper
-
isParameterPresent
public boolean isParameterPresent(String name)
Returns whether a non-null, non-empty value is available for the given parameter name.- Parameters:
name
- parameter name to check- Returns:
- true if a non-null, non-empty value exists, false otherwise
-
getResource
public Resource getResource(String name) throws BadRequestException, RepositoryException
Returns aResource
corresponding to the value of the given parameter name.- Parameters:
name
- of parameter to retrieve resource from- Returns:
- value corresponding to the given parameter name
- Throws:
BadRequestException
- if a problem occurs parsing the parameter valueRepositoryException
-
getSingleParameterMap
public Map<String,String> getSingleParameterMap()
Gets a map of the all parameters with values, also caching them in thisWorkbenchRequest
.- Returns:
- a map of all parameters with values
-
getTypeParameter
public String getTypeParameter()
Gets the value of the 'type' parameter.- Returns:
- the value of the 'type' parameter
-
getURI
public IRI getURI(String name) throws BadRequestException, RepositoryException
Gets the URI referred to by the parameter value.- Parameters:
name
- of the parameter to check- Returns:
- the URI, or null if the parameter has no value, is only whitespace, or equals "null"
- Throws:
BadRequestException
- if the value doesn't parse as a URIRepositoryException
- if the name space prefix is not resolvable
-
getUrl
public URL getUrl(String name) throws BadRequestException
Gets the URL referred to by the parameter value.- Parameters:
name
- of the parameter to check- Returns:
- the URL
- Throws:
BadRequestException
- if the value doesn't parse as a URL
-
getValue
public Value getValue(String name) throws BadRequestException, RepositoryException
Gets theValue
referred to by the parameter value.- Parameters:
name
- of the parameter to check- Returns:
- the value, or null if the parameter has no value, is only whitespace, or equals "null"
- Throws:
BadRequestException
- if the value doesn't parse as a URIRepositoryException
- if any name space prefix is not resolvable
-
-