Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-06-2008, 05:18 AM
Intermediate Member
 
Posts: 17
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
Reply With Quote
  #2 (permalink)  
Old 02-06-2008, 08:19 AM
Intermediate Member
 
Posts: 17
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
Reply With Quote
  #3 (permalink)  
Old 02-06-2008, 09:08 AM
Zimbra Employee
 
Posts: 228
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!
Reply With Quote
  #4 (permalink)  
Old 02-06-2008, 09:21 AM
Intermediate Member
 
Posts: 17
Default Thank you very much for your reply

Thank you very much for your reply .

Regards,

Gil
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.