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

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

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

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