portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Spencer <pau...@apache.org>
Subject Re: patch for CastorRegistryService.java
Date Mon, 09 Sep 2002 11:12:45 GMT
Shinsuke,
This problem has been on my to-do list for a while.  Thank you for the 
patch.  I should be able to commit it this week.

Paul Spencer


Shinsuke SUGAYA wrote:

> Hi, 
> 
> Jetspeed ignores an encoding attribute in XML(.xreg) files...
> So I created the patch for fixing this issue. Using this patch,
> I think that Jetspeed can read data by using correct encoding
> and write it by UTF-8. In my environment, Jetspeed can process 
> Japanese characters in .xreg files and display it correctly:-)
> 
> Please integrate this patch if there is no problem.
> 
> Best regards,
>  shinsuke
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --- jakarta-jetspeed.org/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
Sun Aug 25 22:44:17 2002
> +++ jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
Thu Sep  5 23:28:12 2002
> @@ -72,12 +72,14 @@
>  import org.apache.xml.serialize.Serializer;
>  import org.apache.xml.serialize.XMLSerializer;
>  import org.apache.xml.serialize.OutputFormat;
> +import org.w3c.dom.*;
>  
>  //java stuff
>  import java.util.*;
>  import java.io.*;
>  import java.net.*;
>  import javax.servlet.ServletConfig;
> +import javax.xml.parsers.*;
>  
>  /**
>   * <p>This is an implementation of the <code>RegistryService</code>
> @@ -490,12 +492,15 @@
>       */
>      public void loadFragment(String file)
>      {
> -        FileReader reader = null;
>          try
>          {
> +            DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
> +            DocumentBuilder builder = dbfactory.newDocumentBuilder();
> +
> +            Document d = builder.parse(file);
> +
>              Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
> -            reader = new FileReader(file);
> -            RegistryFragment fragment = (RegistryFragment)unmarshaller.unmarshal(reader);
> +            RegistryFragment fragment = (RegistryFragment)unmarshaller.unmarshal((Node)d);
>  
>              // if we get here, we successfully loaded the new fragment            
>              updateFragment(file, fragment);
> @@ -507,7 +512,6 @@
>          }
>          finally
>          {
> -            try { reader.close(); } catch (Exception e) {};
>          }
>          
>      }
> @@ -522,7 +526,6 @@
>      public void createFragment(String name, Reader reader, boolean persistent)
>      {
>          String file = new File( directory, name+extension ).getAbsolutePath();
> -        FileWriter writer = null;
>          try
>          {
>              Unmarshaller unmarshaller = new Unmarshaller(this.mapping);
> @@ -542,7 +545,6 @@
>          finally
>          {
>              try { reader.close(); } catch (Exception e) {};
> -            try { writer.close(); } catch (Exception e) {};
>          }
>          
>          // refresh all regsitries to take the new entries into account
> @@ -554,14 +556,16 @@
>       * @param file the absolute file path storing this fragment
>       */
>      public void saveFragment(String file) {
> -        FileWriter writer = null;
> +        OutputStreamWriter writer = null;
> +        String encoding = new String("UTF-8");
>          RegistryFragment fragment = (RegistryFragment)fragments.get(file);
>          
>          if (fragment != null)
>          {
>              try
>              {
> -                writer = new FileWriter(file);
> +                writer = new OutputStreamWriter(new FileOutputStream(file),encoding);
> +                format.setEncoding(encoding);
>                  Serializer serializer = new XMLSerializer(writer, format);         
      
>                  Marshaller marshaller = new Marshaller(serializer.asDocumentHandler());
>                  marshaller.setMapping(this.mapping);
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>
> 



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


Mime
View raw message