Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@apache.org Received: (qmail 8972 invoked from network); 6 Sep 2002 15:53:08 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 6 Sep 2002 15:53:08 -0000 Received: (qmail 10473 invoked by uid 97); 6 Sep 2002 15:53:41 -0000 Delivered-To: qmlist-jakarta-archive-jetspeed-dev@jakarta.apache.org Received: (qmail 10429 invoked by uid 97); 6 Sep 2002 15:53:40 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jetspeed Developers List" Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 10382 invoked by uid 98); 6 Sep 2002 15:53:38 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-Apparently-From: Subject: patch for CastorRegistryService.java From: Shinsuke SUGAYA To: jetspeed-dev@jakarta.apache.org Content-Type: multipart/mixed; boundary="=-PtvbBd3LLPx/yKdSAmVI" X-Mailer: Ximian Evolution 1.0.8 Date: 07 Sep 2002 00:53:25 +0900 Message-Id: <1031327606.1193.38.camel@MountainView.SiliconValley.marevol.com> Mime-Version: 1.0 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --=-PtvbBd3LLPx/yKdSAmVI Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-PtvbBd3LLPx/yKdSAmVI Content-Disposition: attachment; filename=CastorRegistryService.patch Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; name=CastorRegistryService.patch; charset=ISO-2022-JP --- jakarta-jetspeed.org/src/java/org/apache/jetspeed/services/registry/Cas= torRegistryService.java Sun Aug 25 22:44:17 2002 +++ jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorR= egistryService.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.*; =20 //java stuff import java.util.*; import java.io.*; import java.net.*; import javax.servlet.ServletConfig; +import javax.xml.parsers.*; =20 /** *

This is an implementation of the RegistryService @@ -490,12 +492,15 @@ */ public void loadFragment(String file) { - FileReader reader =3D null; try { + DocumentBuilderFactory dbfactory =3D DocumentBuilderFactory.ne= wInstance(); + DocumentBuilder builder =3D dbfactory.newDocumentBuilder(); + + Document d =3D builder.parse(file); + Unmarshaller unmarshaller =3D new Unmarshaller(this.mapping); - reader =3D new FileReader(file); - RegistryFragment fragment =3D (RegistryFragment)unmarshaller.u= nmarshal(reader); + RegistryFragment fragment =3D (RegistryFragment)unmarshaller.u= nmarshal((Node)d); =20 // if we get here, we successfully loaded the new fragment = =20 updateFragment(file, fragment); @@ -507,7 +512,6 @@ } finally { - try { reader.close(); } catch (Exception e) {}; } =20 } @@ -522,7 +526,6 @@ public void createFragment(String name, Reader reader, boolean persist= ent) { String file =3D new File( directory, name+extension ).getAbsoluteP= ath(); - FileWriter writer =3D null; try { Unmarshaller unmarshaller =3D new Unmarshaller(this.mapping); @@ -542,7 +545,6 @@ finally { try { reader.close(); } catch (Exception e) {}; - try { writer.close(); } catch (Exception e) {}; } =20 // 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 =3D null; + OutputStreamWriter writer =3D null; + String encoding =3D new String("UTF-8"); RegistryFragment fragment =3D (RegistryFragment)fragments.get(file= ); =20 if (fragment !=3D null) { try { - writer =3D new FileWriter(file); + writer =3D new OutputStreamWriter(new FileOutputStream(fil= e),encoding); + format.setEncoding(encoding); Serializer serializer =3D new XMLSerializer(writer, format= ); =20 Marshaller marshaller =3D new Marshaller(serializer.asDocu= mentHandler()); marshaller.setMapping(this.mapping); --=-PtvbBd3LLPx/yKdSAmVI Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: --=-PtvbBd3LLPx/yKdSAmVI-- __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/