Author: natalia Date: Sun Mar 23 18:09:05 2008 New Revision: 640282 URL: http://svn.apache.org/viewvc?rev=640282&view=rev Log: Add methods for updating resources
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java?rev=640282&r1=640281&r2=640282&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java Sun Mar 23 18:09:05 2008 @@ -1127,8 +1127,8 @@ /** * insertBinary inserts a new binary object into a Xindice Collection. * - * @param docKey The document Key - * @param bytes The document to insert + * @param docKey The resource Key + * @param bytes The resource to insert * @return key for the inserted binary * @throws DBException if inline-metadata is not enabled, the key is * already in the database, or an error occurs while saving. @@ -1192,8 +1192,8 @@ /** * setBinary inserts or updates binary object into a Xindice Collection. * - * @param docKey The document Key - * @param bytes The document to insert + * @param docKey The resource Key + * @param bytes The resource to store * @return true if new binary was created, false otherwise * @throws DBException if inline-metadata is not enabled, the key is * already in the database, or an error occurs while saving. @@ -1215,6 +1215,47 @@ } return res; + } + + /** + * updateDocument updates existing Document in a Xindice Collection. + * + * @param docKey The document Key + * @param document The document to update + * @throws DBException if the key does not exist in the database, or an + * error occurs while saving. + */ + public void updateDocument(Object docKey, Document document) throws DBException { + if (log.isInfoEnabled()) { + log.info(debugHeader() + "Update document: " + docKey); + } + putDocument(createNewKey(docKey), document, ACTION_UPDATE); + + // update the meta information if necessary + updateCollectionMeta(); + } + + /** + * updateDocument updates existing binary object in a Xindice Collection. + * + * @param docKey The resource Key + * @param bytes The resource to update + * @throws DBException if inline-metadata is not enabled, the key does not + * exist in the database, or an error occurs while saving. + */ + public void updateBinary(Object docKey, byte[] bytes) throws DBException { + if (inlineMetaService == null) { + throw new DBException(FaultCodes.COL_CANNOT_STORE, + "Cannot insert a binary resource in '" + getCanonicalName() + + "' (inline-metadata is not enabled)"); + } + + if (log.isInfoEnabled()) { + log.info(debugHeader() + "Set binary " + docKey); + } + + putBinary(createNewKey(docKey), bytes, ACTION_UPDATE); + updateCollectionMeta(); } /**