portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shins...@apache.org
Subject cvs commit: jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/document CastorFileSystemDocumentHandler.java
Date Tue, 21 Sep 2004 22:47:58 GMT
shinsuke    2004/09/21 15:47:58

  Modified:    components/page-manager/src/java/org/apache/jetspeed/page/document
                        CastorFileSystemDocumentHandler.java
  Log:
  Fixed JS2-123
  http://nagoya.apache.org/jira/browse/JS2-123
  
  Revision  Changes    Path
  1.5       +18 -13    jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/document/CastorFileSystemDocumentHandler.java
  
  Index: CastorFileSystemDocumentHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/page-manager/src/java/org/apache/jetspeed/page/document/CastorFileSystemDocumentHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CastorFileSystemDocumentHandler.java	8 Sep 2004 20:48:06 -0000	1.4
  +++ CastorFileSystemDocumentHandler.java	21 Sep 2004 22:47:58 -0000	1.5
  @@ -17,11 +17,14 @@
   
   import java.io.File;
   import java.io.FileNotFoundException;
  -import java.io.FileReader;
   import java.io.FileWriter;
   import java.io.IOException;
   import java.io.InputStream;
   
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.ParserConfigurationException;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.cache.file.FileCache;
  @@ -40,6 +43,7 @@
   import org.exolab.castor.xml.Unmarshaller;
   import org.exolab.castor.xml.ValidationException;
   import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
   
   /**
    * <p>
  @@ -237,13 +241,15 @@
               throw new PageNotFoundException("Document not found: " + path);
           }
   
  -        FileReader reader = null;
  -
           try
           {
  -            reader = new FileReader(f);
  +            DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
  +            DocumentBuilder builder = dbfactory.newDocumentBuilder();
  +
  +            org.w3c.dom.Document d = builder.parse(f);
  +
               Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
  -            document = (Document) unmarshaller.unmarshal(reader);
  +            document = (Document) unmarshaller.unmarshal((org.w3c.dom.Node) d);
               document.setId(path);
               document.setPath(path);
           }
  @@ -263,16 +269,15 @@
           {
               throw new DocumentNotFoundException("Document " + f.getAbsolutePath() + " is
not valid", e);
           }
  -        finally
  -        {
  -            try
  +        catch (SAXException e)
               {
  -                reader.close();
  +            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(),
e);
               }
  -            catch (IOException e)
  +        catch (ParserConfigurationException e)
               {
  +            throw new PageNotFoundException("Could not unmarshal the file " + f.getAbsolutePath(),
e);
               }
  -        }
  +        
   
           if (document == null)
           {
  @@ -450,4 +455,4 @@
       {
           return documentType;
       }
  -}
  \ No newline at end of file
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message