1 22 23 28 29 package org.xquark.mapper.storage; 30 31 import java.sql.SQLException ; 32 33 import org.xml.sax.InputSource ; 34 import org.xquark.mapper.RepositoryException; 35 import org.xquark.mapper.dbms._RepositoryConnection; 36 import org.xquark.mapper.mapping.MappingFactory; 37 import org.xquark.mapper.util.DestructionToken; 38 import org.xquark.schema.validation.SchemaValidationContext; 39 import org.xquark.xml.xdbc.XMLDBCException; 40 41 44 public class MappingSAXHandler extends CollectionFiler 45 { 46 private static final String RCSRevision = "$Revision: 1.1 $"; 47 private static final String RCSName = "$Name: $"; 48 49 public MappingSAXHandler(_RepositoryCollection collection, 50 SchemaValidationContext schemaContext, 51 DestructionToken destructor) 52 throws XMLDBCException 53 { 54 super(collection, schemaContext, true, destructor); 55 } 57 58 protected void startParsing() throws RepositoryException, SQLException 59 { 60 if (!performCommit) 61 throw new RepositoryException(RepositoryException.NOT_ALLOWED, 62 "The XML connection must be autocommit mode in order to store mapping files."); 63 super.startParsing(); 64 } 65 protected void endParsing() throws Exception 66 { 67 super.endParsing(); 68 flushBuffer(); connection.commit(); 72 RepositoryReader reader = collection.getReader(); 74 _RepositoryConnection repConn = collection.getRepositoryConnection(); 75 try 76 { 77 78 org.xquark.mapper.mapping.Loader loader = 79 new org.xquark.mapper.mapping.Loader 80 ( 81 reader, 82 repConn.getConnection(), 83 repConn.getSchemaManager(), 84 false 85 ); 86 87 MappingFactory factory = new MappingFactory 88 ( 89 collection.getMetadata().getRepository(), 90 repConn.getSchemaManager(), 91 repConn 92 ); 93 factory.createTree(); 94 loader.load(new InputSource (getDocumentId()), factory, getXMLErrorHandler(), false); 95 } 96 catch (Exception e) { 97 ((MappingXMLCollection)collection).removeDocument(getDocumentId()); 99 throw e; 100 } 101 finally 102 { 103 if (reader != null) 104 reader.close(); 105 106 } 107 } 108 } 109 | Popular Tags |