vgritsenko 2003/08/13 11:51:15
Modified: java/src/org/apache/xindice/client/xmldb
XindiceCollection.java
java/src/org/apache/xindice/client/xmldb/embed
CollectionImpl.java
java/src/org/apache/xindice/client/xmldb/services
MetaService.java
java/src/org/apache/xindice/client/xmldb/xmlrpc
CollectionImpl.java
Log:
Expose setMetaData() via MetaService
Revision Changes Path
1.12 +12 -2
xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java
Index: XindiceCollection.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XindiceCollection.java 7 Aug 2003 20:13:20 -0000 1.11
+++ XindiceCollection.java 13 Aug 2003 18:51:15 -0000 1.12
@@ -375,4 +375,14 @@
* @exception XMLDBException thrown if unable to obtain meta information
*/
public abstract MetaData getMetaData(String name) throws XMLDBException;
+
+ /**
+ * Updates [EMAIL PROTECTED] MetaData} object for the specified document
or the current
+ * collection
+ * @param name name of document to update meta, or <code>null</code> to
update meta
+ * of the collection.
+ * @param meta meta data object
+ * @exception XMLDBException thrown if unable to obtain meta information
+ */
+ public abstract void setMetaData(String name, MetaData meta) throws
XMLDBException;
}
1.21 +19 -6
xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
Index: CollectionImpl.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- CollectionImpl.java 9 Aug 2003 02:33:30 -0000 1.20
+++ CollectionImpl.java 13 Aug 2003 18:51:15 -0000 1.21
@@ -367,13 +367,14 @@
public void removeResource(Resource res) throws XMLDBException {
if (!(res instanceof XMLResource)) {
- throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Only XML
resources supported");
+ throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
+ "Only XML resources supported");
}
if (res.getId() == null) {
- throw new XMLDBException(
- ErrorCodes.VENDOR_ERROR,
- "This resource is a query result and can " + "not be removed
from the database.");
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
+ "This resource is a query result and
can " +
+ "not be removed from the database.");
}
checkOpen();
@@ -621,6 +622,18 @@
return col.getCollectionMeta();
} else {
return col.getDocumentMeta(id);
+ }
+ } catch (Exception e) {
+ throw FaultCodes.createXMLDBException(e);
+ }
+ }
+
+ public void setMetaData(String id, MetaData meta) throws XMLDBException {
+ try {
+ if (id == null) {
+ col.setCollectionMeta(meta);
+ } else {
+ col.setDocumentMeta(id, meta);
}
} catch (Exception e) {
throw FaultCodes.createXMLDBException(e);
1.4 +10 -2
xml-xindice/java/src/org/apache/xindice/client/xmldb/services/MetaService.java
Index: MetaService.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/services/MetaService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MetaService.java 7 Aug 2003 20:13:20 -0000 1.3
+++ MetaService.java 13 Aug 2003 18:51:15 -0000 1.4
@@ -96,8 +96,16 @@
return ((XindiceCollection) collection).getMetaData(null);
}
+ public void setMetaData(MetaData meta) throws XMLDBException {
+ ((XindiceCollection) collection).setMetaData(null, meta);
+ }
+
public MetaData getMetaData(String id) throws XMLDBException {
return ((XindiceCollection) collection).getMetaData(id);
+ }
+
+ public void setMetaData(String id, MetaData meta) throws XMLDBException {
+ ((XindiceCollection) collection).setMetaData(id, meta);
}
public long getLastModifiedTime() throws XMLDBException {
1.32 +38 -8
xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java
Index: CollectionImpl.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- CollectionImpl.java 9 Aug 2003 02:49:15 -0000 1.31
+++ CollectionImpl.java 13 Aug 2003 18:51:15 -0000 1.32
@@ -71,6 +71,7 @@
import org.apache.xindice.util.SymbolDeserializer;
import org.apache.xindice.xml.TextWriter;
import org.apache.xindice.xml.dom.DOMParser;
+import org.apache.xindice.xml.dom.DocumentImpl;
import org.apache.xmlrpc.XmlRpc;
import org.apache.xmlrpc.XmlRpcClient;
@@ -479,12 +480,14 @@
public void removeResource(Resource res) throws XMLDBException {
if (!(res instanceof XMLResource)) {
-
- throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "Only XML
resources supported");
+ throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
+ "Only XML resources supported");
}
if (res.getId() == null) {
- throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "This resource
is a query result and can " + "not be removed from the database.");
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
+ "This resource is a query result and
can " +
+ "not be removed from the database.");
}
checkOpen();
@@ -654,7 +657,7 @@
/* see superclass for documentation */
public void removeCollection(String childName) throws XMLDBException {
-// todo: shortcut the call and fail immediatly if the collection name is
null or empty
+ // TODO: shortcut the call and fail immediatly if the collection
name is null or empty
checkOpen();
try {
@@ -666,14 +669,16 @@
if (!result.equals("yes")) {
- throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
"Cannot remove child collection[" + childName + "]");
+ throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
+ "Cannot remove child collection[" +
childName + "]");
}
} catch (XMLDBException x) {
throw x; // propagate any xmldb exception.
} catch (Exception e) {
- throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "Cannot
remove child collection[" + childName + "]", e);
+ throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
+ "Cannot remove child collection[" +
childName + "]", e);
}
}
@@ -746,6 +751,31 @@
MetaData meta = new MetaData(id);
meta.streamFromXML(metaDoc.getDocumentElement(), true);
return meta;
+ } catch (Exception e) {
+ throw FaultCodes.createXMLDBException(e);
+ }
+ }
+
+ public void setMetaData(String id, MetaData meta) throws XMLDBException {
+ checkOpen();
+ try {
+ Hashtable params = new Hashtable();
+ params.put(RPCDefaultMessage.COLLECTION, collPath);
+ if (id != null) {
+ params.put(RPCDefaultMessage.NAME, id);
+ }
+ params.put(RPCDefaultMessage.COMPRESSED, "true");
+
+ Document doc = new DocumentImpl();
+ doc.appendChild(meta.streamToXML(doc, true));
+ params.put(RPCDefaultMessage.META, TextWriter.toString(doc));
+
+ // Object result =
+ runRemoteCommand(id == null ? "SetCollectionMeta" :
"SetDocumentMeta", params);
+ // Document metaDoc = DOMParser.toDocument(result.toString());
+ // meta = new MetaData(id);
+ // meta.streamFromXML(metaDoc.getDocumentElement(), true);
+ // return meta;
} catch (Exception e) {
throw FaultCodes.createXMLDBException(e);
}