org.cmis.interopserver.services.capv2
Class CAPv2Handler

java.lang.Object
  extended by org.cmis.interopserver.services.capv2.CAPv2Handler
Direct Known Subclasses:
CAP1_1Handler

public class CAPv2Handler
extends java.lang.Object


Nested Class Summary
(package private)  class CAPv2Handler.CAPErrorHandler
           
 
Field Summary
(package private)  boolean addNoteElement
          whether we're adding a "note" element that says who posted this attachment and when.
protected static org.cmis.common.alerts.AlertsConstants alertsConstants
           
static java.lang.String INTEROP_CONFIG_FILE_NAME
           
 java.lang.String INTEROP_SERVER
           
(package private)  java.lang.String lastTime
          This holds the time of the most recent request.
(package private) static java.util.logging.Logger log
           
protected  org.cmis.client.common.ThinRPCLayer proxy
           
(package private)  boolean verifyAgainstSchema
          whether we'll verify incoming cap messages against the schema (the location of which is hardcoded, by the way)
 
Constructor Summary
CAPv2Handler(org.cmis.client.common.ThinRPCLayer proxy)
          normal constructor
 
Method Summary
 java.lang.String addResourceElement(org.w3c.dom.Document doc, org.cmis.interopserver.beans.capv2.CAPAttachmentDescriptor ad, org.cmis.client.app.attachments.AttachmentObject attachObj)
          Adds a resource tag containing the information from this attachObj and attachment descriptor.
 CAPAlert getCAPAlertById(java.lang.String messageid, long cogId)
          gets the CAP that corresponds to this ID, or null if it isn't there.
 org.cmis.interopserver.beans.capv2.Alert[] getCAPAlertsByDate(java.util.Calendar lastupdate, long cogId)
          Gets all cap alerts on or after the given date.
 java.lang.String[] getCAPAlertsByMultiSearch(java.util.List searchTerms, long cogId)
           
 java.lang.String[] getCAPAlertsByXPath(java.lang.String query, long cogId)
          Returns a list of all cap alerts (in XML form that match a given xpath expression.
 org.cmis.interopserver.beans.capv2.Alert getCAPById(java.lang.String messageid, long cogId)
          gets the CAP that corresponds to this ID, or null if it isn't there.
 java.lang.String getCOGName(long cogId)
          gets the cog name that corresponds to this cog id.
 org.w3c.dom.Document[] getDocumentArrayFromStringArray(java.lang.String[] strings)
           
static org.w3c.dom.Document getDocumentFromString(java.lang.String capXML)
           
 java.lang.String getLastTime()
           
 java.lang.String getPrettyXMLFromDocument(org.w3c.dom.Document doc)
           
protected  org.cmis.client.common.ThinRPCLayer getProxy()
           
 long getUniqueId()
          fetch a new unique id in the standard DMIS way.
 org.w3c.dom.Document getValidatedDocumentFromString(java.lang.String capXML)
           
 java.lang.String getXMLFromDocument(org.w3c.dom.Document doc)
           
protected  void handleAttachments(long dmisId, long cogId, org.w3c.dom.Document cap, java.util.List attachments, java.util.List descriptors, java.util.List mailList)
          "handles" attachments.
 boolean isAddNoteElement()
           
 boolean isVerifyAgainstSchema()
           
 java.lang.String pingServerTime()
          pings the server to find what time it thinks it is.
 long postCAPAlert(org.w3c.dom.Document cap)
           
 long postCAPAlert(org.w3c.dom.Document cap, java.util.List attachObjects)
           
 long postCAPAlert(org.w3c.dom.Document cap, java.lang.String messageId, java.util.List mailList)
          post a cap to the given list of COGs.
 long postCAPAlert(org.w3c.dom.Document cap, java.lang.String messageId, java.util.List mailList, java.util.List attachmentDescriptors, java.util.List dataHandlers)
          Posts a cap alert.
 void postMultipleCAPAlerts(java.util.List alertList, java.util.List cogList)
           
 void postMultipleCAPAlerts(java.util.List alertList, java.util.List cogList, java.util.List attachObjects)
          see CapMessage for usage example.
protected  org.w3c.dom.Document processCAPForPosting(org.w3c.dom.Document doc, long cogId)
           
 void setAddNoteElement(boolean b)
           
 void setLastTime(java.lang.String newTime)
           
 void setVerifyAgainstSchema(boolean b)
           
 org.w3c.dom.Document verifyCAPAlert(org.w3c.dom.Document doc)
          This is quite inefficient.
protected  org.cmis.interopserver.beans.capv2.Alert XMLToAlert(java.lang.String string)
          Alert objects are rarely (if ever) used anymore, but they were used early on in CAPdom and so this method is still here.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTEROP_CONFIG_FILE_NAME

public static final java.lang.String INTEROP_CONFIG_FILE_NAME
See Also:
Constant Field Values

INTEROP_SERVER

public java.lang.String INTEROP_SERVER

alertsConstants

protected static final org.cmis.common.alerts.AlertsConstants alertsConstants

log

static java.util.logging.Logger log

proxy

protected org.cmis.client.common.ThinRPCLayer proxy

lastTime

java.lang.String lastTime
This holds the time of the most recent request. Generally gets returned to the user in a soap header.


verifyAgainstSchema

boolean verifyAgainstSchema
whether we'll verify incoming cap messages against the schema (the location of which is hardcoded, by the way)


addNoteElement

boolean addNoteElement
whether we're adding a "note" element that says who posted this attachment and when. It was for debugging purposes during the beta phase.

Constructor Detail

CAPv2Handler

public CAPv2Handler(org.cmis.client.common.ThinRPCLayer proxy)
normal constructor

Method Detail

getProxy

protected org.cmis.client.common.ThinRPCLayer getProxy()
Returns:

getCAPById

public org.cmis.interopserver.beans.capv2.Alert getCAPById(java.lang.String messageid,
                                                           long cogId)
                                                    throws java.lang.Exception
gets the CAP that corresponds to this ID, or null if it isn't there.

Parameters:
messageid -
cogId - cog ID of the COG we're looking up.
Returns:
NULL if it isn't there.
Throws:
a - TransportException if there are communication problems; if the TransportException wraps another exception, it throws that exception instead.
java.lang.Exception

getCAPAlertById

public CAPAlert getCAPAlertById(java.lang.String messageid,
                                long cogId)
                         throws java.lang.Exception
gets the CAP that corresponds to this ID, or null if it isn't there.

Parameters:
messageid -
cogId - cog ID of the COG we're looking up.
Returns:
NULL if it isn't there.
Throws:
a - TransportException if there are communication problems; if the TransportException wraps another exception, it throws that exception instead.
java.lang.Exception

pingServerTime

public java.lang.String pingServerTime()
                                throws java.lang.Exception
pings the server to find what time it thinks it is.

Parameters:
messageid -
cogId - cog ID of the COG we're looking up.
Returns:
the time in SOAP (ISOwhatever) format (use Translator.convert() to get a calendar object from it).
Throws:
java.lang.Exception

getCAPAlertsByMultiSearch

public java.lang.String[] getCAPAlertsByMultiSearch(java.util.List searchTerms,
                                                    long cogId)
                                             throws java.lang.Exception
Parameters:
searchTerms -
cogId -
Returns:
list of caps (in XML format) that match the given format.
Throws:
java.lang.Exception
org.cmis.transport.common.TransportException

getCAPAlertsByDate

public org.cmis.interopserver.beans.capv2.Alert[] getCAPAlertsByDate(java.util.Calendar lastupdate,
                                                                     long cogId)
                                                              throws java.lang.Exception
Gets all cap alerts on or after the given date.

Parameters:
lastupdate -
cogId - cog ID of the COG we're looking up.
Throws:
java.lang.Exception

getCAPAlertsByXPath

public java.lang.String[] getCAPAlertsByXPath(java.lang.String query,
                                              long cogId)
                                       throws java.lang.Exception
Returns a list of all cap alerts (in XML form that match a given xpath expression. Note that not all XPath expressions are supported, but all common ones are.

Parameters:
query -
cogId -
Returns:
Throws:
java.lang.Exception

postCAPAlert

public long postCAPAlert(org.w3c.dom.Document cap,
                         java.lang.String messageId,
                         java.util.List mailList)
                  throws org.cmis.transport.common.TransportException,
                         org.xml.sax.SAXException,
                         java.lang.Exception
post a cap to the given list of COGs.

Parameters:
cap -
messageId -
mailList -
Returns:
Throws:
org.cmis.transport.common.TransportException
SAXException
java.lang.Exception

getUniqueId

public long getUniqueId()
                 throws org.cmis.transport.common.TransportException
fetch a new unique id in the standard DMIS way.

Returns:
Throws:
org.cmis.transport.common.TransportException

handleAttachments

protected void handleAttachments(long dmisId,
                                 long cogId,
                                 org.w3c.dom.Document cap,
                                 java.util.List attachments,
                                 java.util.List descriptors,
                                 java.util.List mailList)
                          throws java.lang.IllegalArgumentException,
                                 org.xml.sax.SAXException,
                                 java.rmi.RemoteException,
                                 org.cmis.client.app.attachments.AttachmentFTPException
"handles" attachments. Does the following: Takes attachments listed in attachmentList, copies them to the proper place on the Tomcat server, and adds the resource tags to the CAP message that include the correct URL to access the attachments. The URL depends on an entry in the INTEROP_CONFIG_FILE file.

Parameters:
dmisId - -- needed to place the attachments in the proper place.
cogId -
cap -
attachments - -- the attachment objects from the message. I think they must be DataHandlers, but don't quote me. Check what BaseSoapBindingImpl.addAttachments is expecting. Man, I'll be happy when java has typesafe lists.
descriptors - -- describe the above attachments, must match 1 to 1 in proper order.
Throws:
java.lang.IllegalArgumentException
SAXException
java.rmi.RemoteException
org.cmis.client.app.attachments.AttachmentFTPException

postCAPAlert

public long postCAPAlert(org.w3c.dom.Document cap,
                         java.lang.String messageId,
                         java.util.List mailList,
                         java.util.List attachmentDescriptors,
                         java.util.List dataHandlers)
                  throws org.cmis.transport.common.TransportException,
                         org.xml.sax.SAXException,
                         java.lang.Exception
Posts a cap alert. Can take attachments; datahandlers and attachmentDescriptors must match 1 to 1. If mailList is empty the cap will be posted globally.

Parameters:
cap -
messageId -
mailList -
attachmentDescriptors -
dataHandlers -
Returns:
Throws:
org.cmis.transport.common.TransportException
SAXException
java.lang.Exception

postCAPAlert

public long postCAPAlert(org.w3c.dom.Document cap)
                  throws org.cmis.transport.common.TransportException,
                         org.xml.sax.SAXException,
                         java.lang.Exception
Parameters:
cap -
cogId -
Throws:
org.cmis.transport.common.TransportException
org.xml.sax.SAXException
java.lang.Exception

postCAPAlert

public long postCAPAlert(org.w3c.dom.Document cap,
                         java.util.List attachObjects)
                  throws org.cmis.transport.common.TransportException,
                         org.xml.sax.SAXException,
                         java.lang.Exception
Parameters:
cap -
attachObjects -
Returns:
Throws:
org.cmis.transport.common.TransportException
SAXException
java.lang.Exception

getCOGName

public java.lang.String getCOGName(long cogId)
                            throws java.lang.Exception
gets the cog name that corresponds to this cog id.

Parameters:
cogId -
Returns:
Throws:
java.lang.Exception
org.cmis.transport.common.TransportException

postMultipleCAPAlerts

public void postMultipleCAPAlerts(java.util.List alertList,
                                  java.util.List cogList)
                           throws org.cmis.transport.common.TransportException
Parameters:
alertList -
cogList -
Throws:
org.cmis.transport.common.TransportException

postMultipleCAPAlerts

public void postMultipleCAPAlerts(java.util.List alertList,
                                  java.util.List cogList,
                                  java.util.List attachObjects)
                           throws org.cmis.transport.common.TransportException
see CapMessage for usage example.

Parameters:
alertList -
cogList -
attachObjects -
Throws:
org.cmis.transport.common.TransportException

XMLToAlert

protected org.cmis.interopserver.beans.capv2.Alert XMLToAlert(java.lang.String string)
                                                       throws java.io.IOException
Alert objects are rarely (if ever) used anymore, but they were used early on in CAPdom and so this method is still here.

Parameters:
string -
Returns:
Throws:
java.io.IOException

getLastTime

public java.lang.String getLastTime()

setLastTime

public void setLastTime(java.lang.String newTime)
Parameters:
newTime -

verifyCAPAlert

public org.w3c.dom.Document verifyCAPAlert(org.w3c.dom.Document doc)
                                    throws java.lang.Exception
This is quite inefficient. Use with care. When the DOM 3 support is in Xerces, it should be much more efficient. At least I hope.

Parameters:
w3cDoc -
cogid -
Returns:
Throws:
SAXException
java.io.IOException
java.lang.Exception

processCAPForPosting

protected org.w3c.dom.Document processCAPForPosting(org.w3c.dom.Document doc,
                                                    long cogId)
                                             throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

isAddNoteElement

public boolean isAddNoteElement()
Returns:

isVerifyAgainstSchema

public boolean isVerifyAgainstSchema()
Returns:

setAddNoteElement

public void setAddNoteElement(boolean b)
Parameters:
b -

setVerifyAgainstSchema

public void setVerifyAgainstSchema(boolean b)
Parameters:
b -

addResourceElement

public java.lang.String addResourceElement(org.w3c.dom.Document doc,
                                           org.cmis.interopserver.beans.capv2.CAPAttachmentDescriptor ad,
                                           org.cmis.client.app.attachments.AttachmentObject attachObj)
                                    throws org.xml.sax.SAXException
Adds a resource tag containing the information from this attachObj and attachment descriptor. If the messageID of the CAP doesn't match the messageId in the attachment descriptor, it will throw a sax exception. If it can't find the info object described in the attachment descriptor, it will throw a sax exception. If it has some other problem, it will throw a sax exception.

Parameters:
attachObj -
Throws:
org.xml.sax.SAXException

getDocumentFromString

public static org.w3c.dom.Document getDocumentFromString(java.lang.String capXML)
                                                  throws org.xml.sax.SAXException,
                                                         java.io.IOException
Parameters:
capXML -
Returns:
Throws:
SAXException
java.io.IOException

getPrettyXMLFromDocument

public java.lang.String getPrettyXMLFromDocument(org.w3c.dom.Document doc)
                                          throws java.io.IOException
Parameters:
doc -
Returns:
Throws:
java.io.IOException

getXMLFromDocument

public java.lang.String getXMLFromDocument(org.w3c.dom.Document doc)
Parameters:
doc -
Returns:

getValidatedDocumentFromString

public org.w3c.dom.Document getValidatedDocumentFromString(java.lang.String capXML)
                                                    throws java.lang.Exception
Throws:
java.lang.Exception

getDocumentArrayFromStringArray

public org.w3c.dom.Document[] getDocumentArrayFromStringArray(java.lang.String[] strings)
                                                       throws org.xml.sax.SAXException,
                                                              java.io.IOException
Parameters:
strings -
Returns:
Throws:
org.xml.sax.SAXException
java.io.IOException