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
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static AuthSessionprotected static intstatic final byteHTTP Verb DELETEprotected static booleanprotected booleanprotected static final Stringprotected static final Stringstatic final byteHTTP Verb GETstatic final byteHTTP Verb HEADprotected static intMaximum size of uploads, defaults to 1GB if not set in property filestatic final byteHTTP Verb POSTprotected Stringstatic final byteHTTP Verb PUTprotected javax.servlet.http.HttpServletRequestprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected javax.servlet.http.HttpServletResponseprotected org.dataone.service.types.v1.Session -
Constructor Summary
ConstructorsConstructorDescriptionD1ResourceHandler(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 voidParse string parameters from the mime multipart entity of the request.protected MultipartRequestWithSysmetaParse the request by the streaming multiple part handler.static StringA method to decode the given string which is a part of a uri.protected voidGet the session from the header of the request.protected static Filereturn the directory where temp files are storedvoidhandle(byte httpVerb) This function is called from REST API servlet and handles each requestprotected voidCollect the multipart params from the requestprotected voidcopies request parameters to a hashtable which is given as argument to native metacathandler functionsprotected booleansubclasses should provide a more useful implementationprotected StringparseTrailing(String resource, String token) protected voidprintError(String message, javax.servlet.http.HttpServletResponse response) Prints xml responseprotected voidserializeException(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:
-
ATTACHMENT
- 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:
IOExceptionorg.apache.commons.fileupload.FileUploadExceptionException
-
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.ServiceFailureorg.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:
IOExceptionorg.apache.commons.fileupload.FileUploadExceptionInstantiationExceptionIllegalAccessExceptionNoSuchAlgorithmExceptionorg.dataone.exceptions.MarshallingExceptionInterruptedExceptionRuntimeExceptionorg.dataone.service.exceptions.ServiceFailureorg.dataone.service.exceptions.InvalidRequestorg.dataone.service.exceptions.InvalidSystemMetadataInvocationTargetException
-
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
-