Author: vgritsenko Date: Fri Nov 7 12:08:48 2008 New Revision: 712249 URL: http://svn.apache.org/viewvc?rev=712249&view=rev Log: In Collection.getEntry, return null instead of throwing exception. This is consistent with behavior of listDocuments method.
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Get.java xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Head.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=712249&r1=712248&r2=712249&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 Fri Nov 7 12:08:48 2008 @@ -837,9 +837,9 @@ * and in case of header corruption */ public final Entry getEntry(Object id) throws DBException { - // I would prefer to throw an exception (NPE) in this case, - // but we have a test indicating a null return... - if (id == null) { + // Test requires null result for null key. + // Read on filer-less collection should result in null too. + if (id == null || filer == null) { return null; } Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Get.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Get.java?rev=712249&r1=712248&r2=712249&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Get.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Get.java Fri Nov 7 12:08:48 2008 @@ -61,7 +61,6 @@ Entry resource = col.getEntry(name); if (resource != null) { - byte[] resultBytes; if (resource.getEntryType() == Entry.DOCUMENT) { resultBytes = TextWriter.toString((Document) resource.getValue()).getBytes("utf-8"); @@ -79,6 +78,7 @@ OutputStream output = res.getOutputStream(); output.write(resultBytes); output.flush(); + } else { res.sendError(HttpServletResponse.SC_NOT_FOUND); } Modified: xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Head.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Head.java?rev=712249&r1=712248&r2=712249&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Head.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/webadmin/webdav/components/Head.java Fri Nov 7 12:08:48 2008 @@ -68,7 +68,6 @@ Entry resource = col.getEntry(name); if (resource != null) { - byte[] resultBytes; if (resource.getEntryType() == Entry.DOCUMENT) { resultBytes = TextWriter.toString((Document) resource.getValue()).getBytes(); @@ -82,6 +81,7 @@ res.addDateHeader("Last-Modified", resource.getModificationTime()); } res.setContentLength(resultBytes.length); + } else { res.setStatus(HttpServletResponse.SC_NOT_FOUND); }