bloritsch    01/03/09 07:07:30

  Modified:    lib      Tag: xml-cocoon2 avalonapi.jar
               src/org/apache/cocoon/reading Tag: xml-cocoon2
                        DatabaseReader.java
  Log:
  Update avalonapi with fixes in datasource code.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.20  +514 -235  xml-cocoon/lib/Attic/avalonapi.jar
  
        <<Binary file>>
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +21 -3     
xml-cocoon/src/org/apache/cocoon/reading/Attic/DatabaseReader.java
  
  Index: DatabaseReader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/reading/Attic/DatabaseReader.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DatabaseReader.java       2001/02/23 21:36:37     1.1.2.1
  +++ DatabaseReader.java       2001/03/09 15:07:29     1.1.2.2
  @@ -96,6 +96,7 @@
           try {
               datasource = (DataSourceComponent) dbselector.select(dsn);
               con = datasource.getConnection();
  +            con.setAutoCommit(false);
               PreparedStatement statement = con.prepareStatement(getQuery());
               statement.setString(1, this.source);
               ResultSet set = statement.executeQuery();
  @@ -104,14 +105,27 @@
               HttpServletResponse res = (HttpServletResponse) 
objectModel.get(Constants.RESPONSE_OBJECT);
               HttpServletRequest req = (HttpServletRequest) 
objectModel.get(Constants.REQUEST_OBJECT);
   
  -            if (this.modifiedSince(set, req, res) == false) {
  -                
res.setContentType(this.parameters.getParameter("content-type", null));
  -                
this.serialize(set.getBlob(this.parameters.getParameter("image", null)), res);
  +            if (this.modifiedSince(set, req, res)) {
  +                Blob object = set.getBlob(1);
  +
  +                if (object == null) {
  +                    throw new ResourceNotFoundException("There is no image 
with that key");
  +                }
  +
  +                
res.setContentType(this.parameters.getParameter("content-type", ""));
  +                this.serialize(object, res);
               }
  +
  +            con.commit();
           } catch (IOException ioe) {
               getLogger().debug("Assuming client reset stream");
  +
  +            if (con != null) try {con.rollback();} catch (SQLException se) {}
           } catch (Exception e) {
               getLogger().warn("Could not get resource from Database", e);
  +
  +            if (con != null) try {con.rollback();} catch (SQLException se) {}
  +
               throw new ResourceNotFoundException("DatabaseReader error:", e);
           } finally {
               if (con != null) {
  @@ -189,6 +203,10 @@
        */
       public void serialize(Blob object, HttpServletResponse response)
       throws IOException, SQLException {
  +        if (object == null) {
  +            throw new SQLException("The Blob is empty!");
  +        }
  +
           InputStream is = object.getBinaryStream();
           OutputStream os = response.getOutputStream();
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to