From: Giulio V. <gva...@us...> - 2005-03-29 00:00:29
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25471/src/org/exist/xmlrpc Modified Files: RpcAPI.java RpcConnection.java RpcServer.java Log Message: Initial code for restore date of creation and last date of modify Index: RpcServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcServer.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** RpcServer.java 18 Mar 2005 13:09:17 -0000 1.52 --- RpcServer.java 29 Mar 2005 00:00:19 -0000 1.53 *************** *** 720,723 **** --- 720,744 ---- } + public boolean parse(User user, byte[] xmlData, String docName, + int overwrite, Date created, Date modified) throws EXistException, PermissionDeniedException { + // some clients (Perl) encode strings with a \0 at the end. + // remove it ... + if (xmlData[xmlData.length - 1] == 0) { + byte[] temp = new byte[xmlData.length - 1]; + System.arraycopy(xmlData, 0, temp, 0, xmlData.length - 1); + xmlData = temp; + } + RpcConnection con = pool.get(); + try { + return con.parse(user, xmlData, docName, (overwrite != 0), created, modified); + } catch (Exception e) { + handleException(e); + return false; + } finally { + con.synchronize(); + pool.release(con); + } + } + public boolean parse(User user, String xml, String docName, int overwrite) throws EXistException, PermissionDeniedException { *************** *** 748,754 **** boolean replace) throws EXistException, PermissionDeniedException, SAXException { RpcConnection con = pool.get(); try { ! return con.parseLocal(user, localFile, docName, replace); } catch (Exception e) { handleException(e); --- 769,781 ---- boolean replace) throws EXistException, PermissionDeniedException, SAXException { + return parseLocal (user, localFile, docName, replace, null, null); + } + + public boolean parseLocal(User user, String localFile, String docName, + boolean replace, Date created, Date modified) throws EXistException, PermissionDeniedException, + SAXException { RpcConnection con = pool.get(); try { ! return con.parseLocal(user, localFile, docName, replace, created , modified); } catch (Exception e) { handleException(e); *************** *** 760,763 **** --- 787,792 ---- } + + public String uploadCompressed(User user, byte[] data, int length) throws EXistException, PermissionDeniedException { *************** *** 807,813 **** public boolean storeBinary(User user, byte[] data, String docName, String mimeType, boolean replace) throws EXistException, PermissionDeniedException { RpcConnection con = pool.get(); try { ! return con.storeBinary(user, data, docName, mimeType, replace); } catch (Exception e) { handleException(e); --- 836,848 ---- public boolean storeBinary(User user, byte[] data, String docName, String mimeType, boolean replace) throws EXistException, PermissionDeniedException { + return storeBinary(user, data, docName, mimeType, replace, null, null); + } + + + public boolean storeBinary(User user, byte[] data, String docName, String mimeType, + boolean replace, Date created, Date modified) throws EXistException, PermissionDeniedException { RpcConnection con = pool.get(); try { ! return con.storeBinary(user, data, docName, mimeType, replace, created, modified); } catch (Exception e) { handleException(e); *************** *** 819,822 **** --- 854,859 ---- } + + /* * (non-Javadoc) Index: RpcAPI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcAPI.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** RpcAPI.java 18 Mar 2005 13:09:16 -0000 1.47 --- RpcAPI.java 29 Mar 2005 00:00:18 -0000 1.48 *************** *** 452,455 **** --- 452,458 ---- throws EXistException, PermissionDeniedException; + boolean parse(User user, byte[] xmlData, String docName, int overwrite, Date created, Date modified) + throws EXistException, PermissionDeniedException; + boolean parse(User user, String xml, String docName, int overwrite) throws EXistException, PermissionDeniedException; *************** *** 509,512 **** --- 512,518 ---- throws EXistException, PermissionDeniedException, SAXException; + public boolean parseLocal(User user, String localFile, String docName, boolean replace, Date created, Date modified) + throws EXistException, PermissionDeniedException, SAXException; + /** * Store data as a binary resource. *************** *** 523,526 **** --- 529,535 ---- throws EXistException, PermissionDeniedException; + public boolean storeBinary(User user, byte[] data, String docName, String mimeType, boolean replace, Date created, Date modified) + throws EXistException, PermissionDeniedException; + /** * Remove a document from the database. Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** RpcConnection.java 18 Mar 2005 13:09:17 -0000 1.95 --- RpcConnection.java 29 Mar 2005 00:00:19 -0000 1.96 *************** *** 104,108 **** import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; - import antlr.collections.AST; --- 104,107 ---- *************** *** 1073,1076 **** --- 1072,1080 ---- public boolean parse(User user, byte[] xml, String path, boolean replace) throws Exception { + return parse(user, xml,path, replace, null, null); + } + + public boolean parse(User user, byte[] xml, String path, + boolean replace, Date created, Date modified) throws Exception { DBBroker broker = null; Collection collection = null; *************** *** 1103,1106 **** --- 1107,1119 ---- collection.release(); } + + if (created != null) + info.getDocument().setCreated( created.getTime()); + + + if (modified != null) + info.getDocument().setLastModified( modified.getTime()); + + collection.store(broker, info, source, false); LOG.debug("parsing " + path + " took " *************** *** 1116,1119 **** --- 1129,1134 ---- } + + /** * Parse a file previously uploaded with upload. *************** *** 1129,1132 **** --- 1144,1154 ---- boolean replace) throws EXistException, PermissionDeniedException, LockException, SAXException, TriggerException { + return parseLocal(user, localFile, docName, replace, null, null); + } + + + public boolean parseLocal(User user, String localFile, String docName, + boolean replace, Date created, Date modified) throws EXistException, PermissionDeniedException, LockException, + SAXException, TriggerException { File file = new File(localFile); if (!file.canRead()) *************** *** 1161,1164 **** --- 1183,1193 ---- collection.release(); } + + if (created != null) + info.getDocument().setCreated(created.getTime()); + + if (modified != null) + info.getDocument().setLastModified(modified.getTime()); + collection.store(broker, info, source, false); } finally { *************** *** 1170,1175 **** --- 1199,1213 ---- } + + + + public boolean storeBinary(User user, byte[] data, String docName, String mimeType, boolean replace) throws EXistException, PermissionDeniedException, LockException { + return storeBinary(user, data, docName, mimeType, replace, null, null); + } + + public boolean storeBinary(User user, byte[] data, String docName, String mimeType, + boolean replace, Date created, Date modified) throws EXistException, PermissionDeniedException, LockException { DBBroker broker = null; DocumentImpl doc = null; *************** *** 1194,1197 **** --- 1232,1240 ---- LOG.debug("Storing binary resource to collection " + collection.getName()); doc = collection.addBinaryResource(broker, docName, data, mimeType); + if (created != null) + doc.setCreated(created.getTime()); + if (modified != null) + doc.setLastModified(modified.getTime()); + } finally { if(collection != null) *************** *** 1203,1206 **** --- 1246,1253 ---- } + + + + public String upload(User user, byte[] chunk, int length, String fileName) throws EXistException, IOException { |