Skip to content

Commit

Permalink
feat: add delete calendar group.
Browse files Browse the repository at this point in the history
  • Loading branch information
drazen04 committed Nov 11, 2024
1 parent 41e453a commit ccb8b1e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ private MailConstants() {}
public static final String E_GET_CALENDAR_GROUPS_RESPONSE = "GetCalendarGroupsResponse";
public static final String E_CREATE_CALENDAR_GROUP_REQUEST = "CreateCalendarGroupRequest";
public static final String E_CREATE_CALENDAR_GROUP_RESPONSE = "CreateCalendarGroupResponse";
public static final String E_DELETE_CALENDAR_GROUP_REQUEST = "DeleteCalendarGroupRequest";
public static final String E_DELETE_CALENDAR_GROUP_RESPONSE = "DeleteCalendarGroupResponse";

// noop
public static final QName NO_OP_REQUEST = QName.get(E_NO_OP_REQUEST, NAMESPACE);
Expand Down Expand Up @@ -460,6 +462,11 @@ private MailConstants() {}
QName.get(E_CREATE_CALENDAR_GROUP_REQUEST, NAMESPACE);
public static final QName CREATE_CALENDAR_GROUP_RESPONSE =
QName.get(E_CREATE_CALENDAR_GROUP_RESPONSE, NAMESPACE);
public static final QName DELETE_CALENDAR_GROUP_REQUEST =
QName.get(E_DELETE_CALENDAR_GROUP_REQUEST, NAMESPACE);
public static final QName DELETE_CALENDAR_GROUP_RESPONSE =
QName.get(E_DELETE_CALENDAR_GROUP_RESPONSE, NAMESPACE);

public static final QName GET_APPT_SUMMARIES_REQUEST =
QName.get(E_GET_APPT_SUMMARIES_REQUEST, NAMESPACE);
public static final QName GET_APPOINTMENT_REQUEST =
Expand Down
2 changes: 2 additions & 0 deletions soap/src/main/java/com/zimbra/soap/JaxbUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ public final class JaxbUtil {
com.zimbra.soap.mail.message.GetCalendarGroupsResponse.class,
com.zimbra.soap.mail.message.CreateCalendarGroupRequest.class,
com.zimbra.soap.mail.message.CreateCalendarGroupResponse.class,
com.zimbra.soap.mail.message.DeleteCalendarGroupRequest.class,
com.zimbra.soap.mail.message.DeleteCalendarGroupResponse.class,
com.zimbra.soap.mail.message.GetCalendarItemSummariesRequest.class,
com.zimbra.soap.mail.message.GetCalendarItemSummariesResponse.class,
com.zimbra.soap.mail.message.GetContactsRequest.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2022 Synacor, Inc.
// SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
//
// SPDX-License-Identifier: GPL-2.0-only

package com.zimbra.soap.mail.message;

import com.zimbra.common.soap.MailConstants;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

/**
* @zm-api-command-auth-required true
* @zm-api-command-admin-auth-required false
* @zm-api-command-description Delete a new Calendar Group
*/
@XmlRootElement(name = MailConstants.E_DELETE_CALENDAR_GROUP_REQUEST)
public class DeleteCalendarGroupRequest {
/** no-argument constructor wanted by JAXB */
public DeleteCalendarGroupRequest() {}

/**
* @zm-api-field-tag id
* @zm-api-field-description Calendar Group id
*/
@XmlAttribute(name = "id" /* id */, required = true)
private String id;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-FileCopyrightText: 2022 Synacor, Inc.
// SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
//
// SPDX-License-Identifier: GPL-2.0-only

package com.zimbra.soap.mail.message;

import com.zimbra.common.soap.MailConstants;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = MailConstants.E_DELETE_CALENDAR_GROUP_RESPONSE)
public class DeleteCalendarGroupResponse {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.zimbra.cs.service.mail;

import com.zimbra.common.service.ServiceException;
import com.zimbra.common.soap.Element;
import com.zimbra.common.soap.MailConstants;
import com.zimbra.soap.mail.message.DeleteCalendarGroupRequest;

import java.util.Map;

public class DeleteCalendarGroup extends MailDocumentHandler {

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
final var zsc = getZimbraSoapContext(context);
final var account = getRequestedAccount(zsc);

if (!canAccessAccount(zsc, account))
throw ServiceException.PERM_DENIED("can not access account");

final var mbox = getRequestedMailbox(zsc);
final var octxt = getOperationContext(zsc, context);

DeleteCalendarGroupRequest req = zsc.elementToJaxb(request);

mbox.deleteFolder(octxt, req.getId());

return zsc.createElement(MailConstants.DELETE_CALENDAR_GROUP_RESPONSE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public void registerHandlers(DocumentDispatcher dispatcher) {
// Calendar
dispatcher.registerHandler(MailConstants.GET_CALENDAR_GROUPS_REQUEST, new GetCalendarGroups());
dispatcher.registerHandler(MailConstants.CREATE_CALENDAR_GROUP_REQUEST, new CreateCalendarGroup());
dispatcher.registerHandler(MailConstants.DELETE_CALENDAR_GROUP_REQUEST, new DeleteCalendarGroup());
dispatcher.registerHandler(MailConstants.GET_APPT_SUMMARIES_REQUEST, new GetApptSummaries());
dispatcher.registerHandler(MailConstants.GET_APPOINTMENT_REQUEST, new GetAppointment());
dispatcher.registerHandler(MailConstants.SET_APPOINTMENT_REQUEST, new SetAppointment());
Expand Down

0 comments on commit ccb8b1e

Please sign in to comment.