paulsp 2002/09/15 07:26:19 Modified: xdocs changes.xml src/java/org/apache/jetspeed/services/registry CastorRegistryService.java docs/site changes.html Log: .xreg files are now read and written in UTF-8 encoding PR: 10484 Submitted by: Shinsuke (shinsuke at yahoo.co.jp) Revision Changes Path 1.76 +5 -2 jakarta-jetspeed/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- changes.xml 15 Sep 2002 00:49:54 -0000 1.75 +++ changes.xml 15 Sep 2002 14:26:19 -0000 1.76 @@ -23,7 +23,10 @@ -->
This is an implementation of the RegistryService
@@ -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);
@@ -505,10 +510,6 @@
{
Log.error( "Could not unmarshal: " + file, t );
}
- finally
- {
- try { reader.close(); } catch (Exception e) {};
- }
}
@@ -522,7 +523,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 +542,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 +553,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);
1.58 +4 -1 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- changes.html 15 Sep 2002 00:49:54 -0000 1.57
+++ changes.html 15 Sep 2002 14:26:19 -0000 1.58
@@ -129,7 +129,10 @@