monkeyfdude / caldav4j

Automatically exported from code.google.com/p/caldav4j
0 stars 0 forks source link

Non-latin characters garbaged with PUT method #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Modify or create new event with non-latin characters in summry

What is the expected output? What do you see instead?

you will receive ???? symbols instead text

What version of the product are you using? On what operating system?

0.5-SNAPSHOT

Please provide any additional information below.
problem in PutMethod.generateRequestBody method: you need to use 
setRequestEntity instead 
of  setRequestBody

Index: src/main/java/org/osaf/caldav4j/methods/PutMethod.java
===========================================================
========
--- src/main/java/org/osaf/caldav4j/methods/PutMethod.java  (revision 131)
+++ src/main/java/org/osaf/caldav4j/methods/PutMethod.java  (working copy)
@@ -18,6 +18,8 @@

 import java.io.IOException;
 import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -33,6 +35,7 @@
 import org.apache.commons.httpclient.HttpConnection;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.osaf.caldav4j.CalDAVConstants;
@@ -171,7 +174,11 @@
                 log.error("Problem generating calendar: ", e);
                 throw new RuntimeException("Problem generating calendar. ", e);
             }
-            setRequestBody(writer.toString());
+            try {
+               setRequestEntity(new 
StringRequestEntity(writer.toString(),CalDAVConstants.CALENDAR_CONTENT_TYPE,Char
set.defaul
tCharset().toString()));
+           } catch (UnsupportedEncodingException e) {
+               //just ignore
+           }
         }
         return super.generateRequestBody();
     }

Original issue reported on code.google.com by vova...@gmail.com on 8 Sep 2008 at 3:30

GoogleCodeExporter commented 9 years ago
File version of patch

Original comment by vova...@gmail.com on 8 Sep 2008 at 3:31

Attachments:

GoogleCodeExporter commented 9 years ago
Can you provide a test method for junit? Each method should be properly tested 
to
avoid regression problems.

Thank you,
R.

Original comment by robipo...@gmail.com on 8 Sep 2008 at 10:36

GoogleCodeExporter commented 9 years ago
its a patch for CalDAVCalendarCollectionTest.java with testing 
creating/updating events with non-latin 
characters. This patch gives you ability to switch locales during test (see 
setUp)

Original comment by vova...@gmail.com on 9 Sep 2008 at 7:14

Attachments:

GoogleCodeExporter commented 9 years ago
When I got time I'll do the following:

1- compile the testCase for the
http://code.google.com/p/caldav4j/source/browse/trunk/src/test/java/org/osaf/cal
dav4j/methods/PutGetTest.java

2- create new test cases in CalDAVCalendarCollectionTest.java and
CalDAVCollectionTest.java so that users won't see changes in their old methods

Original comment by robipo...@gmail.com on 9 Sep 2008 at 2:20

GoogleCodeExporter commented 9 years ago
I added the test case in
http://code.google.com/p/caldav4j/source/browse/trunk/src/test/java/org/osaf/cal
dav4j/methods/PutGetTest.java

let me know if your patches succeed.
Peace, R.

Original comment by robipo...@gmail.com on 10 Sep 2008 at 5:57

GoogleCodeExporter commented 9 years ago
CReated a related test case.

Original comment by robipo...@gmail.com on 15 May 2009 at 4:36