Results 1 to 4 of 4

Thread: How to create a new calendar using classes in package com.zimbra.cs.zclient

  1. #1
    Join Date
    Nov 2007
    Posts
    17
    Rep Power
    8

    Default 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

  2. #2
    Join Date
    Nov 2007
    Posts
    17
    Rep Power
    8

    Default 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

  3. #3
    Join Date
    Aug 2005
    Posts
    228
    Rep Power
    10

    Default

    the best way to see how to use zclient APIs is look at ZMailboxUtil.java, which exercises just about all of them.

    The call you are looking for is "createFolder":

    Code:
    ZFolder calendar = mailbox.createFolder(
      ZFolder.ID_USER_ROOT, 
     name, 
     ZFolder.View.appointment,  
     ZFolder.Color.blue, 
     ZFolder.Flag.checkedInUI, 
    null);
    Bugzilla - Wiki - Downloads - Before posting... Search!

  4. #4
    Join Date
    Nov 2007
    Posts
    17
    Rep Power
    8

    Default Thank you very much for your reply

    Thank you very much for your reply .

    Regards,

    Gil

Similar Threads

  1. Changing Calendar Organizer script
    By snsparrish in forum Administrators
    Replies: 4
    Last Post: 05-02-2011, 05:41 AM
  2. Can't create an appointement in shared calendar
    By mjeanson in forum Administrators
    Replies: 1
    Last Post: 01-17-2008, 05:40 AM
  3. Replies: 2
    Last Post: 01-15-2008, 05:27 AM
  4. Opensource backup Question.
    By nfear24 in forum Administrators
    Replies: 3
    Last Post: 04-01-2007, 12:47 AM
  5. Outlook/Zimbra Private Appointments Issue
    By Smurthey in forum Zimbra Connector for Outlook
    Replies: 0
    Last Post: 03-09-2007, 07:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •