public static AppointmentItem importFromSOAP(Element GetAppointmentResponse) throws HarnessException { if (GetAppointmentResponse == null) throw new HarnessException("Element cannot be null"); AppointmentItem appt = null; try { // Make sure we only have the GetMsgResponse part Element getAppointmentResponse = ZimbraAccount.SoapClient.selectNode( GetAppointmentResponse, "//mail:GetAppointmentResponse"); if (getAppointmentResponse == null) throw new HarnessException("Element does not contain GetAppointmentResponse"); Element m = ZimbraAccount.SoapClient.selectNode(getAppointmentResponse, "//mail:appt"); if (m == null) throw new HarnessException("Element does not contain an appt element"); // Create the object appt = new AppointmentItem(); if (m != null) { // Appointment id appt.dApptID = m.getAttribute("id"); } String parentFolder = m.getAttribute("l"); if (parentFolder != null) { // Parent folder appt.dFolder = parentFolder; } Element sElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:s"); if (sElement != null) { // Start time appt.dStartTime = new ZDate(sElement); } Element eElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:e"); if (eElement != null) { // End time appt.dEndTime = new ZDate(eElement); } Element compElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:comp"); if (compElement != null) { // Subject appt.dSubject = compElement.getAttribute("name"); // Location appt.dLocation = compElement.getAttribute("loc"); // Display appt.dDisplay = compElement.getAttribute("fb"); } Element oElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:or"); if (oElement != null) { // Organizer appt.dOrganizer = oElement.getAttribute("a"); } Element mpElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:mp"); if (mpElement != null) { // Get multipart appt.dMultipart = mpElement; } // Parse the required attendees ArrayList<String> attendees = new ArrayList<String>(); Element[] requiredElements = ZimbraAccount.SoapClient.selectNodes(m, "//mail:at[@role='REQ']"); for (Element e : requiredElements) { attendees.add(e.getAttribute("a")); } if (attendees.size() > 0) { appt.dAttendees = AppointmentItem.StringListToCommaSeparated(attendees); } // Parse the optional attendees ArrayList<String> optionals = new ArrayList<String>(); Element[] optionalElements = ZimbraAccount.SoapClient.selectNodes(m, "//mail:at[@role='OPT']"); for (Element e : optionalElements) { optionals.add(e.getAttribute("a")); } if (optionals.size() > 0) { appt.dOptionals = AppointmentItem.StringListToCommaSeparated(optionals); } if (appt.dLocation == "") { Element equipElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:at[@cutype='RES']"); if (equipElement != null) { // Equipment appt.dEquipment = equipElement.getAttribute("a"); } } else if (appt.dLocation != null) { Element equipElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:at[@cutype='RES'][2]"); if (equipElement != null) { // Equipment appt.dEquipment = equipElement.getAttribute("a"); } } Element descElement = ZimbraAccount.SoapClient.selectNode(m, "//mail:fr"); if (descElement != null) { // Body appt.dContent = descElement.getTextTrim(); } return (appt); } catch (Exception e) { throw new HarnessException( "Could not parse GetMsgResponse: " + GetAppointmentResponse.prettyPrint(), e); } finally { if (appt != null) logger.info(appt.prettyPrint()); } }