Class D1ResourceHandler
java.lang.Object
edu.ucsb.nceas.metacat.restservice.D1ResourceHandler
- Direct Known Subclasses:
CNResourceHandler
,CNResourceHandler
,MNResourceHandler
,MNResourceHandler
Base class for handling D1 REST calls in Metacat
- Author:
- leinfelder
-
Field Summary
Modifier and TypeFieldDescriptionprotected static AuthSession
protected static int
static final byte
HTTP Verb DELETEprotected static boolean
protected boolean
protected static final String
protected static final String
static final byte
HTTP Verb GETstatic final byte
HTTP Verb HEADprotected static int
Maximum size of uploads, defaults to 1GB if not set in property filestatic final byte
HTTP Verb POSTprotected String
static final byte
HTTP Verb PUTprotected javax.servlet.http.HttpServletRequest
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected javax.servlet.http.HttpServletResponse
protected org.dataone.service.types.v1.Session
-
Constructor Summary
ConstructorDescriptionD1ResourceHandler
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Initializes new instance by setting servlet context,request and response -
Method Summary
Modifier and TypeMethodDescriptionProcess the MMP request that includes files for each paramprotected void
Parse string parameters from the mime multipart entity of the request.protected MultipartRequestWithSysmeta
Parse the request by the streaming multiple part handler.static String
A method to decode the given string which is a part of a uri.protected void
Get the session from the header of the request.protected static File
return the directory where temp files are storedvoid
handle
(byte httpVerb) This function is called from REST API servlet and handles each requestprotected void
Collect the multipart params from the requestprotected void
copies request parameters to a hashtable which is given as argument to native metacathandler functionsprotected boolean
subclasses should provide a more useful implementationprotected String
parseTrailing
(String resource, String token) protected void
printError
(String message, javax.servlet.http.HttpServletResponse response) Prints xml responseprotected void
serializeException
(org.dataone.service.exceptions.BaseException e, OutputStream out) serialize a D1 exception using jibx
-
Field Details
-
GET
public static final byte GETHTTP Verb GET- See Also:
-
POST
public static final byte POSTHTTP Verb POST- See Also:
-
PUT
public static final byte PUTHTTP Verb PUT- See Also:
-
DELETE
public static final byte DELETEHTTP Verb DELETE- See Also:
-
HEAD
public static final byte HEADHTTP Verb HEAD- See Also:
-
MAX_UPLOAD_SIZE
protected static int MAX_UPLOAD_SIZEMaximum size of uploads, defaults to 1GB if not set in property file -
RESOURCE_BASE_URL
- See Also:
-
RESOURCE_OBJECTS
- See Also:
-
RESOURCE_META
- See Also:
-
RESOURCE_LOG
- See Also:
-
RESOURCE_QUERY
- See Also:
-
RESOURCE_IS_AUTHORIZED
- See Also:
-
RESOURCE_ACCESS_RULES
- See Also:
-
RESOURCE_VIEWS
- See Also:
-
FUNCTION_NAME_INSERT
- See Also:
-
FUNCTION_NAME_UPDATE
- See Also:
-
auth
-
authCacheSize
protected static int authCacheSize -
enableAppendLdapGroups
protected static boolean enableAppendLdapGroups -
request
protected javax.servlet.http.HttpServletRequest request -
response
protected javax.servlet.http.HttpServletResponse response -
enableSessionFromHeader
protected boolean enableSessionFromHeader -
proxyKey
-
params
-
multipartparams
-
session
protected org.dataone.service.types.v1.Session session
-
-
Constructor Details
-
D1ResourceHandler
public D1ResourceHandler(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Initializes new instance by setting servlet context,request and response- Parameters:
request
- the request that the handler will handleresponse
- the response that the handler will send back
-
-
Method Details
-
handle
public void handle(byte httpVerb) This function is called from REST API servlet and handles each request- Parameters:
httpVerb
- (GET, POST, PUT or DELETE)
-
isD1Enabled
protected boolean isD1Enabled()subclasses should provide a more useful implementation- Returns:
-
parseTrailing
-
collectMultipartParams
protected void collectMultipartParams() throws IOException, org.apache.commons.fileupload.FileUploadException, ExceptionParse string parameters from the mime multipart entity of the request. Populates the multipartparams map- Throws:
IOException
org.apache.commons.fileupload.FileUploadException
Exception
-
collectMultipartFiles
protected Map<String,File> collectMultipartFiles() throws org.dataone.service.exceptions.ServiceFailure, org.dataone.service.exceptions.InvalidRequestProcess the MMP request that includes files for each param- Returns:
- map of param key and the temp file that contains the encoded information
- Throws:
org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.InvalidRequest
-
collectObjectFiles
protected MultipartRequestWithSysmeta collectObjectFiles() throws IOException, org.apache.commons.fileupload.FileUploadException, InstantiationException, IllegalAccessException, NoSuchAlgorithmException, org.dataone.exceptions.MarshallingException, org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure, RuntimeException, InterruptedException, org.dataone.service.exceptions.InvalidSystemMetadata, InvocationTargetExceptionParse the request by the streaming multiple part handler. This method is good for the cn.create and mn.create/update methods.- Returns:
- the MultipartRequestWithSysmeta object which includes the stored object file with its checksum and the system metadata about this object
- Throws:
IOException
org.apache.commons.fileupload.FileUploadException
InstantiationException
IllegalAccessException
NoSuchAlgorithmException
org.dataone.exceptions.MarshallingException
InterruptedException
RuntimeException
org.dataone.service.exceptions.ServiceFailure
org.dataone.service.exceptions.InvalidRequest
org.dataone.service.exceptions.InvalidSystemMetadata
InvocationTargetException
-
initParams
protected void initParams()copies request parameters to a hashtable which is given as argument to native metacathandler functions -
initMultipartParams
Collect the multipart params from the request- Throws:
Exception
-
getTempDirectory
return the directory where temp files are stored- Returns:
-
printError
Prints xml response- Parameters:
message
- Message to be displayedresponse
- Servlet response that xml message will be printed
-
serializeException
serialize a D1 exception using jibx- Parameters:
e
-out
-
-
decode
A method to decode the given string which is a part of a uri. The default encoding is utf-8. If the utf-8 is not support in this system, the default one in the systme will be used.- Parameters:
s
-- Returns:
- null if the given string is null
-
getSessionFromHeader
protected void getSessionFromHeader()Get the session from the header of the request. This mechanism is disabled by default due to network security conditions needed for it to be secure
-