From: Wolfgang M. M. <wol...@us...> - 2004-08-12 16:07:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11583/src/org/exist/xmldb Modified Files: LocalXMLResource.java RemoteBinaryResource.java EXistResource.java RemoteXMLResource.java Log Message: Added getContentLength() method to XMLDB resource implementations. Index: EXistResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/EXistResource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EXistResource.java 3 Aug 2004 15:25:58 -0000 1.3 --- EXistResource.java 12 Aug 2004 16:07:17 -0000 1.4 *************** *** 42,45 **** --- 42,47 ---- Permission getPermissions() throws XMLDBException; + + int getContentLength() throws XMLDBException; } Index: LocalXMLResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXMLResource.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** LocalXMLResource.java 10 Aug 2004 20:06:03 -0000 1.39 --- LocalXMLResource.java 12 Aug 2004 16:07:17 -0000 1.40 *************** *** 312,315 **** --- 312,335 ---- } } + + /* (non-Javadoc) + * @see org.exist.xmldb.EXistResource#getContentLength() + */ + public int getContentLength() throws XMLDBException { + DBBroker broker = null; + try { + broker = pool.get(user); + DocumentImpl document = getDocument(broker, false); + if (!document.getPermissions().validate(user, Permission.READ)) + throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, + "permission denied to read resource"); + return document.getContentLength(); + } catch (EXistException e) { + throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), + e); + } finally { + pool.release(broker); + } + } /** Index: RemoteBinaryResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RemoteBinaryResource.java 21 Jun 2004 15:27:36 -0000 1.2 --- RemoteBinaryResource.java 12 Aug 2004 16:07:17 -0000 1.3 *************** *** 49,53 **** --- 49,55 ---- private RemoteCollection parent; private byte[] data = null; + private Permission permissions = null; + private int contentLen = 0; public RemoteBinaryResource(RemoteCollection parent, String documentName) throws XMLDBException { *************** *** 176,178 **** --- 178,188 ---- return permissions; } + + public void setContentLength(int len) { + this.contentLen = len; + } + + public int getContentLength() throws XMLDBException { + return contentLen; + } } Index: RemoteXMLResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteXMLResource.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** RemoteXMLResource.java 21 Jun 2004 15:27:36 -0000 1.14 --- RemoteXMLResource.java 12 Aug 2004 16:07:17 -0000 1.15 *************** *** 58,62 **** --- 58,65 ---- protected String content = null; protected File file = null; + protected Permission permissions = null; + protected int contentLen = 0; + protected Properties outputProperties = null; *************** *** 348,351 **** --- 351,362 ---- } + public void setContentLength(int len) { + this.contentLen = len; + } + + public int getContentLength() throws XMLDBException { + return contentLen; + } + public void setPermissions(Permission perms) { permissions = perms; |