Blame SOURCES/ws-jaxme-remove-xmldb.patch

d084c2
diff -rauN ws-jaxme-0.5.2.old/build.xml ws-jaxme-0.5.2/build.xml
d084c2
--- ws-jaxme-0.5.2.old/build.xml	2006-10-24 17:38:01.000000000 -0400
d084c2
+++ ws-jaxme-0.5.2/build.xml	2012-02-08 10:29:55.000000000 -0500
d084c2
@@ -35,7 +35,6 @@
d084c2
                <include name="prerequisites/log4j*.jar"/>
d084c2
                <include name="prerequisites/xercesImpl.jar"/>
d084c2
                <include name="prerequisites/xml-apis-1.3.02.jar"/>
d084c2
-               <include name="prerequisites/xmldb-api-*.jar"/>
d084c2
 	       </tarfileset>
d084c2
 	       <tarfileset prefix="ws-jaxme-${version}/docs" dir="${build.site}"/>
d084c2
            <tarfileset prefix="ws-jaxme-${version}/lib" dir="dist">
d084c2
diff -rauN ws-jaxme-0.5.2.old/src/pm/org/apache/ws/jaxme/pm/xmldb/package.html ws-jaxme-0.5.2/src/pm/org/apache/ws/jaxme/pm/xmldb/package.html
d084c2
--- ws-jaxme-0.5.2.old/src/pm/org/apache/ws/jaxme/pm/xmldb/package.html	2004-07-23 03:18:09.000000000 -0400
d084c2
+++ ws-jaxme-0.5.2/src/pm/org/apache/ws/jaxme/pm/xmldb/package.html	1969-12-31 19:00:00.000000000 -0500
d084c2
@@ -1,31 +0,0 @@
d084c2
-
d084c2
-
d084c2
- Copyright 2004 The Apache Software Foundation.
d084c2
- 
d084c2
- Licensed under the Apache License, Version 2.0 (the "License");
d084c2
- you may not use this file except in compliance with the License.
d084c2
- You may obtain a copy of the License at
d084c2
- 
d084c2
-      http://www.apache.org/licenses/LICENSE-2.0
d084c2
- 
d084c2
- Unless required by applicable law or agreed to in writing, software
d084c2
- distributed under the License is distributed on an "AS IS" BASIS,
d084c2
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d084c2
- See the License for the specific language governing permissions and
d084c2
- limitations under the License.
d084c2
-
d084c2
--->
d084c2
-<html>
d084c2
-    <head>
d084c2
-        <title>
d084c2
-Package Documentation for org.apache.ws.jaxme.pm.xmldb Package
d084c2
-    </title>
d084c2
-</head>
d084c2
-    <body bgcolor="white">
d084c2
-        

d084c2
-Contains an implementation of
d084c2
-the JaxMe persistence management framework
d084c2
-targeting the XML::DB API.
d084c2
-    

d084c2
-</body>
d084c2
-</html>
d084c2
diff -rauN ws-jaxme-0.5.2.old/src/pm/org/apache/ws/jaxme/pm/xmldb/XmlDbPM.java ws-jaxme-0.5.2/src/pm/org/apache/ws/jaxme/pm/xmldb/XmlDbPM.java
d084c2
--- ws-jaxme-0.5.2.old/src/pm/org/apache/ws/jaxme/pm/xmldb/XmlDbPM.java	2005-03-04 05:41:53.000000000 -0500
d084c2
+++ ws-jaxme-0.5.2/src/pm/org/apache/ws/jaxme/pm/xmldb/XmlDbPM.java	1969-12-31 19:00:00.000000000 -0500
d084c2
@@ -1,338 +0,0 @@
d084c2
-/*
d084c2
- * Copyright 2003, 2004  The Apache Software Foundation
d084c2
- * 
d084c2
- * Licensed under the Apache License, Version 2.0 (the "License");
d084c2
- * you may not use this file except in compliance with the License.
d084c2
- * You may obtain a copy of the License at
d084c2
- * 
d084c2
- * http://www.apache.org/licenses/LICENSE-2.0
d084c2
- * 
d084c2
- * Unless required by applicable law or agreed to in writing, software
d084c2
- * distributed under the License is distributed on an "AS IS" BASIS,
d084c2
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d084c2
- * See the License for the specific language governing permissions and
d084c2
- * limitations under the License.
d084c2
-
d084c2
- */
d084c2
-package org.apache.ws.jaxme.pm.xmldb;
d084c2
-
d084c2
-import java.lang.reflect.InvocationTargetException;
d084c2
-import java.util.HashMap;
d084c2
-import java.util.Iterator;
d084c2
-import java.util.Map;
d084c2
-
d084c2
-import javax.xml.bind.Element;
d084c2
-import javax.xml.bind.JAXBException;
d084c2
-import javax.xml.bind.Marshaller;
d084c2
-
d084c2
-import org.apache.ws.jaxme.JMManager;
d084c2
-import org.apache.ws.jaxme.JMUnmarshallerHandler;
d084c2
-import org.apache.ws.jaxme.Observer;
d084c2
-import org.apache.ws.jaxme.PMException;
d084c2
-import org.apache.ws.jaxme.PMParams;
d084c2
-import org.apache.ws.jaxme.pm.impl.PMIdImpl;
d084c2
-import org.xml.sax.ContentHandler;
d084c2
-import org.xmldb.api.DatabaseManager;
d084c2
-import org.xmldb.api.base.Collection;
d084c2
-import org.xmldb.api.base.Database;
d084c2
-import org.xmldb.api.base.ResourceIterator;
d084c2
-import org.xmldb.api.base.ResourceSet;
d084c2
-import org.xmldb.api.base.XMLDBException;
d084c2
-import org.xmldb.api.modules.XMLResource;
d084c2
-import org.xmldb.api.modules.XPathQueryService;
d084c2
-
d084c2
-
d084c2
-/** This is a persistence manager for the XML::DB interface. In other
d084c2
- * words, using this persistence manager you may read documents from a
d084c2
- * database via the XML::DB API or write them into the database using the
d084c2
- * same API.
d084c2
- * This persistence manager is generic: The same manager works fine for
d084c2
- * any JAXB element.
d084c2
- */
d084c2
-public class XmlDbPM extends PMIdImpl {
d084c2
-  private Class driverClass;
d084c2
-  private String collection;
d084c2
-  private String user;
d084c2
-  private String password;
d084c2
-  private Map databaseProperties;
d084c2
-  private String xPathQueryService = "XPathQueryService";
d084c2
-  private String xPathQueryServiceVersion = "1.0";
d084c2
-
d084c2
-  /** Creates a new instance of XmlDbPM.
d084c2
-   */
d084c2
-  public XmlDbPM() {
d084c2
-  }
d084c2
-
d084c2
-  public void init(JMManager pManager) throws JAXBException {
d084c2
-    super.init(pManager);
d084c2
-
d084c2
-    String driverClassName = pManager.getProperty("xmldb.driver");
d084c2
-    if (driverClassName == null  ||  driverClassName.length() == 0) {
d084c2
-      throw new JAXBException("Missing property: 'xmldb.driver' (driver class name)");
d084c2
-    }
d084c2
-
d084c2
-    String coll = pManager.getProperty("xmldb.collection");
d084c2
-    if (coll == null  ||  coll.length() == 0) {
d084c2
-      throw new JAXBException("Missing property: 'xmldb.collection' (collection name)");
d084c2
-    }
d084c2
-    setCollection(coll);
d084c2
-    setUser(pManager.getProperty("xmldb.user"));
d084c2
-    setPassword(pManager.getProperty("xmldb.password"));
d084c2
-
d084c2
-    for (int i = 0;  ;  i++) {
d084c2
-      String p = "xmldb.property." + i;
d084c2
-      String v = pManager.getProperty(p);
d084c2
-      if (v == null) {
d084c2
-        break;
d084c2
-      }
d084c2
-      int offset = v.indexOf('=');
d084c2
-      if (offset == -1) {
d084c2
-        throw new JAXBException("Invalid database property value " + p + ": Expected name=value, got " + v);
d084c2
-      }
d084c2
-      String name = v.substring(0, offset);
d084c2
-      String value = v.substring(offset+1);
d084c2
-      if (databaseProperties != null) {
d084c2
-        databaseProperties = new HashMap();
d084c2
-      }
d084c2
-      databaseProperties.put(name, value);
d084c2
-    }
d084c2
-
d084c2
-    Class c;
d084c2
-    try {
d084c2
-      c = Class.forName(driverClassName);
d084c2
-    } catch (ClassNotFoundException e) {
d084c2
-      try {
d084c2
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
d084c2
-        if (cl == null) {
d084c2
-          cl = getClass().getClassLoader();   
d084c2
-        }
d084c2
-        c = cl.loadClass(driverClassName);
d084c2
-      } catch (ClassNotFoundException f) {
d084c2
-        throw new JAXBException("Failed to load driver class " + driverClassName, e);
d084c2
-      }
d084c2
-    }
d084c2
-    setDriverClass(c);
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the collection name.
d084c2
-   */
d084c2
-  public String getCollection() {
d084c2
-    return collection;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the collection name.
d084c2
-   */
d084c2
-  public void setCollection(String pCollection) {
d084c2
-    collection = pCollection;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the driver class.
d084c2
-   */
d084c2
-  public Class getDriverClass() {
d084c2
-    return driverClass;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the driver class.
d084c2
-   */
d084c2
-  public void setDriverClass(Class pDriverClass) {
d084c2
-    driverClass = pDriverClass;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the password.
d084c2
-   */
d084c2
-  public String getPassword() {
d084c2
-    return password;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the password.
d084c2
-   */
d084c2
-  public void setPassword(String pPassword) {
d084c2
-    password = pPassword;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the users name.
d084c2
-   */
d084c2
-  public String getUser() {
d084c2
-    return user;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the users name.
d084c2
-   */
d084c2
-  public void setUser(String pUser) {
d084c2
-    user = pUser;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the name of the XPathQueryService. Defaults to
d084c2
-   * "XPathQueryService".
d084c2
-   */
d084c2
-  public String getXPathQueryService() {
d084c2
-    return xPathQueryService;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the name of the XPathQueryService. Defaults to
d084c2
-   * "XPathQueryService".
d084c2
-   */
d084c2
-  public void setXPathQueryService(String pXpathQueryService) {
d084c2
-    xPathQueryService = pXpathQueryService;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the version of the XPathQueryService. Defaults to
d084c2
-   * "1.0".
d084c2
-   */
d084c2
-  public String getXPathQueryServiceVersion() {
d084c2
-    return xPathQueryServiceVersion;
d084c2
-  }
d084c2
-
d084c2
-  /** Sets the version of the XPathQueryService. Defaults to
d084c2
-   * "1.0".
d084c2
-   */
d084c2
-  public void setXPathQueryServiceVersion(String pXpathQueryServiceVersion) {
d084c2
-    xPathQueryServiceVersion = pXpathQueryServiceVersion;
d084c2
-  }
d084c2
-
d084c2
-  /** Returns the database collection by invoking
d084c2
-   * {@link DatabaseManager#getCollection(String)}.
d084c2
-   */
d084c2
-  protected Collection getXmlDbCollection()
d084c2
-      throws XMLDBException, IllegalAccessException, InstantiationException {
d084c2
-    Database database = (Database) getDriverClass().newInstance();
d084c2
-    if (databaseProperties != null) {
d084c2
-      for (Iterator iter = databaseProperties.entrySet().iterator();  iter.hasNext();  ) {
d084c2
-        Map.Entry entry = (Map.Entry) iter.next();
d084c2
-        database.setProperty((String) entry.getKey(), (String) entry.getValue());
d084c2
-      }
d084c2
-    }
d084c2
-    DatabaseManager.registerDatabase(database); 
d084c2
-    return DatabaseManager.getCollection(getCollection());
d084c2
-  }
d084c2
-
d084c2
-
d084c2
-  /* (non-Javadoc)
d084c2
-   * @see org.apache.ws.jaxme.PM#select(org.apache.ws.jaxme.Observer, java.lang.String, org.apache.ws.jaxme.PMParams)
d084c2
-   */
d084c2
-  public void select(Observer pObserver, String pQuery, PMParams pPlaceHolderArgs) throws JAXBException {
d084c2
-    if (pPlaceHolderArgs != null) {
d084c2
-      pQuery = super.parseQuery(pQuery, pPlaceHolderArgs);
d084c2
-    }
d084c2
-
d084c2
-    if (pQuery == null) {
d084c2
-      throw new IllegalArgumentException("A query must be specified");
d084c2
-    }
d084c2
-
d084c2
-	Collection col;
d084c2
-	try {
d084c2
-		col = getXmlDbCollection();
d084c2
-		XPathQueryService service = (XPathQueryService) col.getService(getXPathQueryService(),
d084c2
-																	   getXPathQueryServiceVersion());
d084c2
-		ResourceSet result = service.query(pQuery);
d084c2
-		if (result != null) {
d084c2
-			ResourceIterator i = result.getIterator();
d084c2
-			if (i.hasMoreResources()) {
d084c2
-				JMUnmarshallerHandler handler = (JMUnmarshallerHandler) getManager().getFactory().createUnmarshaller().getUnmarshallerHandler();
d084c2
-				handler.setObserver(pObserver);
d084c2
-				while(i.hasMoreResources()) {
d084c2
-					XMLResource r = (XMLResource) i.nextResource();
d084c2
-					r.getContentAsSAX(handler);
d084c2
-				}
d084c2
-			}
d084c2
-		}
d084c2
-	} catch (XMLDBException e) {
d084c2
-		throw new PMException(e);
d084c2
-	} catch (IllegalAccessException e) {
d084c2
-		throw new PMException(e);
d084c2
-	} catch (InstantiationException e) {
d084c2
-		throw new PMException(e);
d084c2
-	}
d084c2
-  }
d084c2
-
d084c2
-  /* (non-Javadoc)
d084c2
-   * @see org.apache.ws.jaxme.PM#insert(javax.xml.bind.Element)
d084c2
-   */
d084c2
-  public void insert(Element pElement) throws PMException {
d084c2
-    try {
d084c2
-      Collection col = getXmlDbCollection();
d084c2
-      String id = getId(pElement);
d084c2
-      XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
d084c2
-      ContentHandler ch = resource.setContentAsSAX();
d084c2
-      Marshaller marshaller = getManager().getFactory().createMarshaller();
d084c2
-      marshaller.marshal(pElement, ch);
d084c2
-      col.storeResource(resource);
d084c2
-    } catch (XMLDBException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (IllegalAccessException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (InstantiationException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (NoSuchMethodException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (InvocationTargetException e) {
d084c2
-      throw new PMException(e.getTargetException());
d084c2
-    } catch (JAXBException e) {
d084c2
-      if (e instanceof PMException) {
d084c2
-        throw (PMException) e;
d084c2
-      } else {
d084c2
-        throw new PMException(e);
d084c2
-      }
d084c2
-    }
d084c2
-  }
d084c2
-
d084c2
-  /* (non-Javadoc)
d084c2
-   * @see org.apache.ws.jaxme.PM#update(javax.xml.bind.Element)
d084c2
-   */
d084c2
-  public void update(Element pElement) throws PMException {
d084c2
-    try {
d084c2
-      Collection col = getXmlDbCollection();
d084c2
-      String id = getId(pElement);
d084c2
-      XMLResource resource = (XMLResource) col.getResource(id);
d084c2
-      ContentHandler ch = resource.setContentAsSAX();
d084c2
-      Marshaller marshaller = getManager().getFactory().createMarshaller();
d084c2
-      marshaller.marshal(pElement, ch);
d084c2
-      col.storeResource(resource);
d084c2
-    } catch (XMLDBException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (IllegalAccessException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (InstantiationException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (NoSuchMethodException e) {
d084c2
-      throw new PMException(e);
d084c2
-    } catch (InvocationTargetException e) {
d084c2
-      throw new PMException(e.getTargetException());
d084c2
-    } catch (JAXBException e) {
d084c2
-      if (e instanceof PMException) {
d084c2
-        throw (PMException) e;
d084c2
-      } else {
d084c2
-        throw new PMException(e);
d084c2
-      }
d084c2
-    }
d084c2
-  }
d084c2
-
d084c2
-  /* (non-Javadoc)
d084c2
-   * @see org.apache.ws.jaxme.PM#delete(javax.xml.bind.Element)
d084c2
-   */
d084c2
-  public void delete(Element pElement) throws PMException {
d084c2
-    try {
d084c2
-     Collection col = getXmlDbCollection();
d084c2
-     String id = getId(pElement);
d084c2
-     XMLResource resource = (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);
d084c2
-     col.removeResource(resource);
d084c2
-   } catch (XMLDBException e) {
d084c2
-     throw new PMException(e);
d084c2
-   } catch (IllegalAccessException e) {
d084c2
-     throw new PMException(e);
d084c2
-   } catch (InstantiationException e) {
d084c2
-     throw new PMException(e);
d084c2
-   } catch (InvocationTargetException e) {
d084c2
-     throw new PMException(e.getTargetException());
d084c2
-   } catch (NoSuchMethodException e) {
d084c2
-     throw new PMException(e);
d084c2
-    } catch (JAXBException e) {
d084c2
-      if (e instanceof PMException) {
d084c2
-        throw (PMException) e;
d084c2
-      } else {
d084c2
-        throw new PMException(e);
d084c2
-      }
d084c2
-   }
d084c2
-  }
d084c2
-
d084c2
-}