deyanTG / caldav4j

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

Problem (or help) connecting with bedework #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

1. I have modified CaldavCollectionManager (at org/osaf/caldav4j/example) 

addEvent works fine but when trying to modify it i get an error trying to
get calendar of event (getCalendarForEventUID) with null pointer exception

The code 

public static void main(String[] args) throws CalDAV4JException,
                                               SocketException, 
                                               URISyntaxException 
{

 final String CALDAV_SERVER = CaldavCredential.CALDAV_SERVER_HOST;
 final String CALDAV_PORT =
String.valueOf(CaldavCredential.CALDAV_SERVER_PORT); 
 final String CALDAV_USER = CaldavCredential.CALDAV_SERVER_USERNAME; 
 final String CALDAV_PASS = CaldavCredential.CALDAV_SERVER_PASSWORD;

 System.out.println("Creando Cliente Caldav ..");
 BaseCaldavClient cli = new BaseCaldavClient(CALDAV_SERVER, CALDAV_PORT,
                                   CaldavCredential.CALDAV_SERVER_PROTOCOL,
                                CaldavCredential.CALDAV_SERVER_WEBDAV_ROOT,
CALDAV_USER, CALDAV_PASS);

 System.out.println("Abriendo una collection..");
 CalDavCollectionManager cdm = new CalDavCollectionManager(cli);
 cdm.setRelativePath("calPrue");

 System.out.println("Creando un evento sencillo ...");
 // create date for event
 // anyo, mes (1 menos), dia, hora (2 horas menos), minutos
 Date beginDate = ICalendarUtils.createDateTime(2009, 3, 16, 16 ,0, null,
true);
  Date endDate = ICalendarUtils.createDateTime(2009, 4, 6, null, true);
  Dur duration = new Dur("3H");
  String MyUid ="2009_00010_01_444_caldav4j";

  // create new event
  VEvent nve = new VEvent(beginDate, duration, "Evento Nuevo CalDav4j");
  cdm.addEvent(nve, null, MyUid);

  /* Fine so far, I can see the event on bedework web interface (and
through lightning too)

  /////////////////////////////////////////////////////////

  System.out.println("Voy a modicar el evento..");
  // modify event
  System.out.println("--Voy a por el calendar..");

  Calendar pippo =  cdm.getCalendarForEventUID(nve.getUid().getValue());

  /* Not get here yet. Null pointer exception above */

  System.out.println("Master event..");
  VEvent ve = ICalendarUtils.getMasterEvent(pippo,MyUid);

  System.out.println("Cambio el sumario");
  ICalendarUtils.addOrReplaceProperty(ve, new Summary("I changed the
summary!"));
  System.out.println("Voy a actualizar..");
  cdm.updateMasterEvent(((HttpClient) cdm.client),ve,null);

 }

The error is

Exception in thread "main" org.osaf.caldav4j.CalDAV4JException: Problem
executing method
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalDAVResourceForEventUID(CalDAVCa
lendarCollection.java:643)
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalendarForEventUID(CalDAVCalendar
Collection.java:123)
        at
org.osaf.caldav4j.example.CalDavCollectionManager.getCalendarForEventUID(CalDavC
ollectionManager.java:283)
        at
org.osaf.caldav4j.example.CalDavCollectionManager.main(CalDavCollectionManager.j
ava:404)
Caused by: java.lang.NullPointerException
        at
org.osaf.caldav4j.xml.OutputsDOMBase.createNewDocument(OutputsDOMBase.java:67)
        at
org.osaf.caldav4j.methods.CalDAVReportMethod.generateRequestBody(CalDAVReportMet
hod.java:127)
        at
org.apache.webdav.lib.methods.XMLResponseMethodBase.getRequestContentLength(XMLR
esponseMethodBase.java:237)
        at
org.apache.webdav.lib.methods.HttpRequestBodyMethodBase.addRequestHeaders(HttpRe
questBodyMethodBase.java:248)
        at
org.osaf.caldav4j.methods.CalDAVReportMethod.addRequestHeaders(CalDAVReportMetho
d.java:103)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequestHeaders(HttpMethodBase.
java:2036)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:19
19)
        at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDire
ctor.java:397)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirecto
r.java:170)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at
org.osaf.caldav4j.methods.HttpClient.executeMethod(HttpClient.java:103)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalDAVResourceForEventUID(CalDAVCa
lendarCollection.java:641)

Original issue reported on code.google.com by izena...@gmail.com on 17 Apr 2009 at 11:28

GoogleCodeExporter commented 8 years ago
Which java version are you using?

Original comment by robipo...@gmail.com on 17 Apr 2009 at 11:44

GoogleCodeExporter commented 8 years ago
Caldav4j requires Java 1.6

Original comment by robipo...@gmail.com on 17 Apr 2009 at 12:21

GoogleCodeExporter commented 8 years ago
Helo
I hav the same problem : addEvent works fine but this instruction : 

Calendar pippo =  cdm.getCalendarForEventUID( ((HttpClient
cdm.client),nve.getUid().getValue() );

i have an exception :
  Exception in thread "main" org.osaf.caldav4j.CalDAV4JException: Problem executing
method
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalDAVResourceForEventUID(CalDAVCa
lendarCollection.java:642)
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalendarForEventUID(CalDAVCalendar
Collection.java:123)
        at com.nqi.test.test3.main(test3.java:82)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
        at org.osaf.caldav4j.util.XMLUtils.toPrettyXML(XMLUtils.java:96)
        at
org.osaf.caldav4j.methods.CalDAVReportMethod.generateRequestBody(CalDAVReportMet
hod.java:133)
        at
org.apache.webdav.lib.methods.XMLResponseMethodBase.getRequestContentLength(XMLR
esponseMethodBase.java:226)
        at
org.apache.webdav.lib.methods.XMLResponseMethodBase.writeRequestBody(XMLResponse
MethodBase.java:291)
        at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:21
14)
        at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDire
ctor.java:398)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirecto
r.java:171)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at org.osaf.caldav4j.methods.HttpClient.executeMethod(HttpClient.java:103)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
        at
org.osaf.caldav4j.CalDAVCalendarCollection.getCalDAVResourceForEventUID(CalDAVCa
lendarCollection.java:640)
        ... 2 more
Caused by: java.lang.NullPointerException
        at
org.apache.xml.serialize.XMLSerializer.serializeElement(XMLSerializer.java:687)
        at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer
.java:1239)
        at
org.apache.xml.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer
.java:1307)
        at
org.apache.xml.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.jav
a:501)
        at org.osaf.caldav4j.util.XMLUtils.toPrettyXML(XMLUtils.java:94)
        ... 13 more
Java Result: 1

I use Java 1.6 i don't now why he does'nt works , i use xercesImpl.jar . Maybe 
the
problem com from this jar file. Help me !!!

Original comment by as.lan...@gmail.com on 17 Jul 2009 at 1:47

GoogleCodeExporter commented 8 years ago
Hi,

I'm also facing the same problem. Add event works fine, but as instruction :
Calendar pippo =  cdm.getCalendarForEventUID( ((HttpClient
cdm.client),nve.getUid().getValue() );

execute it throws:

Exception in thread "main" 
org.osaf.caldav4j.exceptions.ResourceNotFoundException: Could not find resource 
for the UID 'my_id'
at 
org.osaf.caldav4j.CalDAVCalendarCollection.getPathToResourceForEventId(CalDAVCal
endarCollection.java:587)
at CalDavCollectionManager.main(CalDavCollectionManager.java:398) 

Please help me out from this problem.

Also if i tried to retrieved calendar using getResponseBodyAsString() it works 
fine but as i changed it to getReaponseBodyAsCalendar() it again throwing 
exception saying
Content type expected text/calendar. Was text/html....

Now what i can do to solve this????????

Original comment by 77testte...@gmail.com on 15 Sep 2011 at 7:52