How to create a new calendar using classes in package com.zimbra.cs.zclient
Hello,
I am just looking at the package com.zimbra.cs.zclient in the ZimbraServer 5.0 sources and was wondering, if there is a way to create a new calendar using any of the classes in this package.
Does anyone know how you can create a new calendar via SOAP and the zclient classes?
Best regards,
Gil
Calendars are folders in Zimbra
After analysing the communication between the client and the server, when I was creating a calendar, I found out that calendars are nothing else than folders with the "appointment" view in Zimbra. Here is the XML I captured during a create calendar request:
Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra">
<userAgent name="ZimbraWebClient - FF2.0 (Win)" version="5.0.1_GA_1902.RHEL4"/>
<sessionId id="1165"/>
<account by="name">
admin@gil.zimbra
</account>
<format type="js"/>
<authToken>
0_9a2320ce76bd67ea7bc529916972c9aac481ff28_69643d33363a32373338626565612d613563622d346566362d396230332d3039643265363865666438623b6578703d31333a313230323438353634363733373b747970653d363a7a696d6272613b6d61696c686f73743d31353a3139322e3136382e302e35333a38303b
</authToken>
</context>
</soap:Header>
<soap:Body>
<CreateFolderRequest xmlns="urn:zimbraMail">
<folder l="1" name="test3" color="1" f="#" view="appointment"/>
</CreateFolderRequest>
</soap:Body>
</soap:Envelope>
So I have now created some code not using some other classes I found in the Zimbra distribution which creates successfully the calendar:
Code:
/**
* Creates calendar resource via SOAP.
* @param name The name of the calendar.
* @return The calendar identifier.
* @throws ServiceException Thrown in case that the service does not work.
* @throws IOException Thrown in case the communication with the server fails.
* @throws LmcSoapClientException
* @throws SoapParseException Thrown in case the SOAP request cannot be parsed.
*/
public String createCalendar(String name)
throws ServiceException, SoapParseException, LmcSoapClientException, IOException
{
LOG.info("==== CREATE CALENDAR ======");
LmcCreateFolderRequest cfReq = new LmcCreateFolderRequest();
cfReq.setSession(session);// this is LmcSession
cfReq.setName(name);
cfReq.setView(APPOINTMENT); // "appointment"
cfReq.setParentID(this.getRootFolder().getFolderID()); // The root folder identifier for the user that is logged in.
LmcCreateFolderResponse cfResp = (LmcCreateFolderResponse) cfReq.invoke(serverURL);
String newID = cfResp.getFolder().getFolderID();
LOG.info("created new folder with ID " + newID);
return newID;
}
Regards,
Gil
Thank you very much for your reply
Thank you very much for your reply :D.
Regards,
Gil