org.fosstrak.epcis.repository.capture
Class CaptureOperationsModule

java.lang.Object
  extended by org.fosstrak.epcis.repository.capture.CaptureOperationsModule

public class CaptureOperationsModule
extends Object

CaptureOperationsModule implements the core capture operations. Converts XML events delivered by HTTP POST into SQL and inserts them into the database.

TODO: the parsing of the xml inputstream should be done in the CaptureOperationsServlet; this class should implement EpcisCaptureInterface such that CaptureOperationsServlet can call its capture method and provide it with the parsed events.

Author:
David Gubler, Alain Remund, Marco Steybe, Nikos Kefalakis (nkef)

Constructor Summary
CaptureOperationsModule()
           
 
Method Summary
protected  void checkEpc(String textContent)
          Check EPC according to 'pure identity' URI as specified in Tag Data Standard.
protected  boolean checkEpcOrUri(String epcOrUri, boolean epcRequired)
           
protected  String checkEventTimeZoneOffset(String textContent)
          TODO: javadoc!
 void doCapture(InputStream in, Principal principal)
          Implements the EPCIS capture operation.
 void doDbReset()
          Resets the database.
 Schema getMasterDataSchema()
           
 VocabularyAttributeElement getOrEditVocabularyAttributeElement(org.hibernate.Session session, String vocabularyType, Long vocabularyElementID, String vocabularyAttributeElement, String vocabularyAttributeElementValue, String mode)
          (nkef) Inserts vocabulary attribute into the database by searching for already existing entries; if found, the corresponding ID is returned.
 VocabularyElement getOrEditVocabularyElement(org.hibernate.Session session, String vocabularyType, String vocabularyElementURI, String mode)
          (changed by nkef to support MasterDataCapture.
 VocabularyElement getOrInsertVocabularyElement(org.hibernate.Session session, String vocabularyType, String vocabularyElement)
          (depricated) Inserts vocabulary into the database by searching for already existing entries; if found, the corresponding ID is returned.
 Schema getSchema()
           
 org.hibernate.SessionFactory getSessionFactory()
           
 boolean isDbResetAllowed()
           
 boolean isInsertMissingVoc()
           
 void setDbResetAllowed(boolean dbResetAllowed)
           
 void setDbResetScript(String dbResetScript)
           
 void setEpcisMasterdataSchemaFile(String epcisMasterdataSchemaFile)
           
 void setEpcisSchemaFile(String epcisSchemaFile)
           
 void setInsertMissingVoc(boolean insertMissingVoc)
           
 void setMasterDataSchema(Schema masterDataSchema)
           
 void setSchema(Schema schema)
           
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptureOperationsModule

public CaptureOperationsModule()
Method Detail

doDbReset

public void doDbReset()
               throws SQLException,
                      IOException,
                      UnsupportedOperationException
Resets the database.

Throws:
SQLException - If something goes wrong resetting the database.
IOException - If something goes wrong reading the reset script.
UnsupportedOperationsException - If database resets are not allowed.
UnsupportedOperationException

doCapture

public void doCapture(InputStream in,
                      Principal principal)
               throws SAXException,
                      InternalBusinessException,
                      InvalidFormatException
Implements the EPCIS capture operation. Takes an input stream, extracts the payload into an XML document, validates the document against the EPCIS schema, and captures the EPCIS events given in the document.

Throws:
IOException - If an error occurred while validating the request or writing the response.
ParserConfigurationException
SAXException - If the XML document is malformed or invalid
InvalidFormatException
InternalBusinessException

checkEpcOrUri

protected boolean checkEpcOrUri(String epcOrUri,
                                boolean epcRequired)
                         throws InvalidFormatException
Parameters:
epcOrUri - The EPC or URI to check.
epcRequired - true if an EPC is required (will throw an InvalidFormatException if the given epcOrUri is an invalid EPC, but might be a valid URI), false otherwise.
Returns:
true if the given epcOrUri is a valid EPC, false otherwise.
Throws:
InvalidFormatException

getOrInsertVocabularyElement

public VocabularyElement getOrInsertVocabularyElement(org.hibernate.Session session,
                                                      String vocabularyType,
                                                      String vocabularyElement)
                                               throws SAXException
(depricated) Inserts vocabulary into the database by searching for already existing entries; if found, the corresponding ID is returned. If not found, the vocabulary is extended if "insertmissingvoc" is true; otherwise an SQLException is thrown

Parameters:
tableName - The name of the vocabulary table.
uri - The vocabulary adapting the URI to be inserted into the vocabulary table.
Returns:
The ID of an already existing vocabulary table with the given uri.
Throws:
UnsupportedOperationException - If we are not allowed to insert a missing vocabulary.
SAXException

getOrEditVocabularyElement

public VocabularyElement getOrEditVocabularyElement(org.hibernate.Session session,
                                                    String vocabularyType,
                                                    String vocabularyElementURI,
                                                    String mode)
                                             throws SAXException
(changed by nkef to support MasterDataCapture. Previusly known as "getOrInsertVocabularyElement") Inserts vocabulary into the database by searching for already existing entries; if found, the corresponding ID is returned. If not found, the vocabulary is extended if "insertmissingvoc" is true; otherwise an SQLException is thrown

Parameters:
tableName - The name of the vocabulary table.
uri - The vocabulary adapting the URI to be inserted into the vocabulary table.
Returns:
The ID of an already existing vocabulary table with the given uri.
Throws:
UnsupportedOperationException - If we are not allowed to insert a missing vocabulary.
SAXException

getOrEditVocabularyAttributeElement

public VocabularyAttributeElement getOrEditVocabularyAttributeElement(org.hibernate.Session session,
                                                                      String vocabularyType,
                                                                      Long vocabularyElementID,
                                                                      String vocabularyAttributeElement,
                                                                      String vocabularyAttributeElementValue,
                                                                      String mode)
                                                               throws SAXException
(nkef) Inserts vocabulary attribute into the database by searching for already existing entries; if found, the corresponding ID is returned. If not found, the vocabulary is extended if "insertmissingvoc" is true; otherwise an SQLException is thrown

Parameters:
tableName - The name of the vocabulary table.
uri - The vocabulary adapting the URI to be inserted into the vocabulary table.
Returns:
The ID of an already existing vocabulary table with the given uri.
Throws:
UnsupportedOperationException - If we are not allowed to insert a missing vocabulary.
SAXException

checkEventTimeZoneOffset

protected String checkEventTimeZoneOffset(String textContent)
                                   throws InvalidFormatException
TODO: javadoc!

Parameters:
textContent -
Returns:
Throws:
InvalidFormatException

checkEpc

protected void checkEpc(String textContent)
                 throws InvalidFormatException
Check EPC according to 'pure identity' URI as specified in Tag Data Standard.

Parameters:
textContent -
Throws:
InvalidFormatException

getSessionFactory

public org.hibernate.SessionFactory getSessionFactory()

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)

isDbResetAllowed

public boolean isDbResetAllowed()

setDbResetAllowed

public void setDbResetAllowed(boolean dbResetAllowed)

setDbResetScript

public void setDbResetScript(String dbResetScript)

isInsertMissingVoc

public boolean isInsertMissingVoc()

setInsertMissingVoc

public void setInsertMissingVoc(boolean insertMissingVoc)

getSchema

public Schema getSchema()

setSchema

public void setSchema(Schema schema)

setEpcisSchemaFile

public void setEpcisSchemaFile(String epcisSchemaFile)

setEpcisMasterdataSchemaFile

public void setEpcisMasterdataSchemaFile(String epcisMasterdataSchemaFile)

getMasterDataSchema

public Schema getMasterDataSchema()

setMasterDataSchema

public void setMasterDataSchema(Schema masterDataSchema)


Copyright © 2010. All Rights Reserved.