use of com.zimbra.cs.dav.resource.MailItemResource in project zm-mailbox by Zimbra.
the class Acl method handle.
public void handle(DavContext ctxt) throws DavException, IOException, ServiceException {
DavResource rs = ctxt.getRequestedResource();
if (!rs.isCollection() || !(rs instanceof MailItemResource))
throw new DavException("acl not implemented for non-collection resource", HttpServletResponse.SC_NOT_IMPLEMENTED);
if (!ctxt.hasRequestMessage())
throw new DavException("empty request", HttpServletResponse.SC_BAD_REQUEST);
Document reqMsg = ctxt.getRequestMessage();
Element acl = reqMsg.getRootElement();
if (!acl.getQName().equals(DavElements.E_ACL))
throw new DavException("request does not start with acl element", HttpServletResponse.SC_BAD_REQUEST);
List<Element> aceElements = acl.elements(DavElements.E_ACE);
ArrayList<Ace> aceList = new ArrayList<Ace>();
for (Element ace : aceElements) aceList.add(new Ace(ace));
MailItemResource mir = (MailItemResource) rs;
mir.setAce(ctxt, aceList);
}
use of com.zimbra.cs.dav.resource.MailItemResource in project zm-mailbox by Zimbra.
the class AclReports method getAclPrincipals.
private ArrayList<DavResource> getAclPrincipals(DavContext ctxt) throws DavException, ServiceException {
ArrayList<DavResource> ret = new ArrayList<DavResource>();
DavResource res = ctxt.getRequestedResource();
if (!(res instanceof MailItemResource))
return ret;
List<Ace> aces = ((MailItemResource) res).getAce(ctxt);
Provisioning prov = Provisioning.getInstance();
for (Ace ace : aces) {
if (ace.hasHref()) {
Account acct = prov.get(Key.AccountBy.id, ace.getZimbraId());
if (acct != null)
ret.add(UrlNamespace.getPrincipal(ctxt, acct));
}
}
return ret;
}
use of com.zimbra.cs.dav.resource.MailItemResource in project zm-mailbox by Zimbra.
the class Move method checkPrecondition.
@Override
public void checkPrecondition(DavContext ctxt) throws DavException, ServiceException {
super.checkPrecondition(ctxt);
DavResource rs = ctxt.getRequestedResource();
if (!(rs instanceof MailItemResource))
throw new DavException("cannot move", HttpServletResponse.SC_BAD_REQUEST, null);
col = ctxt.getDestinationCollection();
mir = (MailItemResource) rs;
if (!mir.isCollection()) {
Collection srcCollection = ctxt.getRequestedParentCollection();
if (srcCollection.getDefaultView() != MailItem.Type.UNKNOWN && srcCollection.getDefaultView() != col.getDefaultView())
throw new DavException("cannot move to incompatible collection", HttpServletResponse.SC_FORBIDDEN, null);
} else {
// allow moving of collections of type document or unknown only.
if (!(((Collection) mir).getDefaultView() == MailItem.Type.DOCUMENT || ((Collection) mir).getDefaultView() == MailItem.Type.UNKNOWN))
throw new DavException("cannot move non-document collection", HttpServletResponse.SC_FORBIDDEN, null);
// do not allow moving of collection if destination type is not document or unknown.
if (!(col.getDefaultView() == MailItem.Type.UNKNOWN || col.getDefaultView() == MailItem.Type.DOCUMENT))
throw new DavException("cannot move to incompatible collection", HttpServletResponse.SC_FORBIDDEN, null);
}
}
Aggregations