Class ClientViewHelper
java.lang.Object
edu.ucsb.nceas.metacat.clientview.ClientViewHelper
- Author:
- barteau
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientViewHelper(String host, String context, ClientView bean) Creates a new instance of ClientViewHelper, using parameter values for initializing.ClientViewHelper(javax.servlet.http.HttpServletRequest request) Creates a new instance of ClientViewHelper, using info in an HttpServletRequest for initializing. -
Method Summary
Modifier and TypeMethodDescriptionclientRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Main web API method for handling various actions.static ClientViewHelperclientViewHelperInstance(javax.servlet.http.HttpServletRequest request) This is a convenience method to reduce the amount of code in a Metacat Client.static Nodestatic StringgetNodeText(XPath xPath, String expression, Node root) static String[]getNodeTextList(XPath xPath, String expression, Node root) static StackgetNodeTextStack(XPath xpathInstance, String xpathExpr, Node parentNode) Queries Metacat for document listings, and returns the results in a TreeMap, where the key is the Doc Id, and the value is the Create Date.static Stringstatic StringgetTextContent(XPath xPath, Node elementNode) handleClientRequest(com.oreilly.servlet.multipart.MultipartParser multipartParser) Main method for handling various actions.handleFileUpdate(com.oreilly.servlet.multipart.MultipartParser multipartParser) handlePackageUpload(ClientView clientViewBean, com.oreilly.servlet.multipart.MultipartParser multipartParser) Handles metadata file and data file uploads for inserting new Metacat data packages.static booleanisElementContentWhitespace(Text textNode) booleanA convenience method to be used by client code that requires the user to be logged in.nextVersion(String lastDocId, String xPathQuery) static String[]parseFileInfo(String fileName) Query metacat for documents that 'CONTAINS' the value at the specified XPath expression.voidsetLoggedIn(boolean isLoggedIn) voidsetLoggedIn(String serverResponse) After calling "login(ldapUserName, pwd)", call this with the username and servers response message.voidsetMetadataDoc(InputStream ioStream) voidsetMetadataDoc(String docId) voidsetMetadataDoc(Document doc) static voidsetTextContent(XPath xPath, Node elementNode, String content) voidsetUserName(String userName) static StringtoZipFileName(String fileName) static voidupdateNodeText(Node root, XPath xPath, String expression, String text)
-
Field Details
-
DOWNLOAD_ACTION
- See Also:
-
PERMISSION_TYPE_ALLOW
- See Also:
-
PERMISSION_TYPE_DISALLOW
- See Also:
-
-
Constructor Details
-
ClientViewHelper
public ClientViewHelper(javax.servlet.http.HttpServletRequest request) throws MetacatInaccessibleException Creates a new instance of ClientViewHelper, using info in an HttpServletRequest for initializing.- Parameters:
request- HttpServletRequest, sent from the client browser.- Throws:
MetacatInaccessibleException- Thrown
-
ClientViewHelper
public ClientViewHelper(String host, String context, ClientView bean) throws MetacatInaccessibleException Creates a new instance of ClientViewHelper, using parameter values for initializing. This constructor is plain java code so it's the portal of choice for JUnit testing.- Parameters:
host- The host with port (if needed), such as "localhost:8084".context- The application root context.bean- ClientView instance, with pre-populated values.- Throws:
MetacatInaccessibleException- thrown
-
-
Method Details
-
clientRequest
public String clientRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Main web API method for handling various actions.- Parameters:
request- HttpServletRequestresponse- HttpServletResponse- Returns:
- String message
-
handleClientRequest
public HashMap<String,Object> handleClientRequest(com.oreilly.servlet.multipart.MultipartParser multipartParser) Main method for handling various actions. Note: This is mostly plain java code so it is JUnit friendly (pass null as the MulipartParser).- Parameters:
multipartParser- Only needed if the action is "Upload".- Returns:
- HashMap containing "message", and possibly several other values. If the action is Download, than this will contain all needed values to pass to handleDownloadResponse.
-
clientViewHelperInstance
public static ClientViewHelper clientViewHelperInstance(javax.servlet.http.HttpServletRequest request) This is a convenience method to reduce the amount of code in a Metacat Client. It handles creating/reusing (per session) an instance of a ClientViewHelper.- Parameters:
request- Since this is intended to be used by an Http client, it is passed the available "request" variable (the HttpServletRequest).- Returns:
- ClientViewHelper instance.
- Throws:
MetacatInaccessibleException- Received by MetacatFactory.
-
isLoggedIn
public boolean isLoggedIn()A convenience method to be used by client code that requires the user to be logged in. NOTE: setUser() must have been called first, otherwise it will always return false.- Returns:
- boolean true if user has logged in for this session, false otherwise.
-
setLoggedIn
After calling "login(ldapUserName, pwd)", call this with the username and servers response message. You can than use isLoggedIn() to determine if the user is logged in, getLoginResponseElement(), etc. The user name will also used by calls to doMetadataUpload() for Document Id creation (scope).- Parameters:
userName- User nameserverResponse- XML login response sent from Metacat.
-
setLoggedIn
public void setLoggedIn(boolean isLoggedIn) -
setUserName
-
parseXml
-
handleDocIdSelect
-
handlePackageUpload
public String handlePackageUpload(ClientView clientViewBean, com.oreilly.servlet.multipart.MultipartParser multipartParser) throws Exception Handles metadata file and data file uploads for inserting new Metacat data packages. Note: if content type is not "multipart/form-data", nothing will happen.- Parameters:
request- HTTP request.- Returns:
- A 1-line status message for the user.
- Throws:
Exception
-
handleFileUpdate
public String handleFileUpdate(com.oreilly.servlet.multipart.MultipartParser multipartParser) throws Exception - Throws:
Exception
-
getSelectQueryMap
Queries Metacat for document listings, and returns the results in a TreeMap, where the key is the Doc Id, and the value is the Create Date. If the document contains the specified 'returnfield', an addtional entry will be created with the value being a Vector of sub-DocId's. The key of this entry will be the original DocId with some addtional text added. Reads bean properties 'pathExpr' (String[]), 'pathValue' (String) and 'returnfield' (String).- Returns:
- TreeMap
-
query
Query metacat for documents that 'CONTAINS' the value at the specified XPath expression. Additionally, returns another non-standard field value. Standard info contains: DocId, DocName, DocType, CreateDate, and UpdateDate.- Parameters:
pathExpr- String contianing an XPath expression.pathValue- String containing a comparison value at the XPath expression.returnFld- String containing an XPath expression to a field which will be returned in addition to the standard info.- Returns:
- DOM Document containing the results.
-
setMetadataDoc
-
setMetadataDoc
- Throws:
Exception
-
setMetadataDoc
- Throws:
IOException
-
getMetadataDoc
-
nextVersion
- Throws:
XPathExpressionException
-
getMetacatClient
-
parseFileInfo
-
updateNodeText
-
getNode
-
getNodeText
-
getNodeTextList
-
getNodeTextStack
-
getStringFromInputStream
-
makeRedirectUrl
-
toZipFileName
-
setTextContent
public static void setTextContent(XPath xPath, Node elementNode, String content) throws DOMException - Throws:
DOMException
-
getTextContent
- Throws:
DOMException
-
isElementContentWhitespace
-