Search in sources :

Example 11 with ShareInfoData

use of com.zimbra.cs.account.ShareInfoData in project zm-mailbox by Zimbra.

the class SendShareNotification method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    OperationContext octxt = getOperationContext(zsc, context);
    Account account = getRequestedAccount(zsc);
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    // validate the share specified in the request and build a share info if all is valid
    Collection<ShareInfoData> shareInfos = validateRequest(zsc, context, octxt, mbox, request);
    // grab notes if there is one
    Element eNotes = request.getOptionalElement(MailConstants.E_NOTES);
    Action action = Action.fromString(request.getAttribute(MailConstants.A_ACTION, null));
    String notes = eNotes == null ? null : eNotes.getText();
    // send the messages
    try {
        Account authAccount = getAuthenticatedAccount(zsc);
        Collection<ShareInfoData> sharesWithGroupGrantee = Lists.newArrayList();
        for (ShareInfoData sid : shareInfos) {
            // set aside shares to groups
            if (ACL.GRANTEE_GROUP == sid.getGranteeTypeCode()) {
                sharesWithGroupGrantee.add(sid);
            } else {
                sendNotificationEmail(octxt, mbox, authAccount, account, sid, notes, action, null, null);
            }
        }
        // send to group grantees
        sendNotificationEmailToGroupGrantees(octxt, mbox, authAccount, account, sharesWithGroupGrantee, notes, action);
    } catch (MessagingException e) {
        throw ServiceException.FAILURE("Messaging Exception while sending share notification message", e);
    }
    return zsc.createElement(MailConstants.SEND_SHARE_NOTIFICATION_RESPONSE);
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) Action(com.zimbra.soap.mail.message.SendShareNotificationRequest.Action) Mailbox(com.zimbra.cs.mailbox.Mailbox) MessagingException(javax.mail.MessagingException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) ShareInfoData(com.zimbra.cs.account.ShareInfoData) Element(com.zimbra.common.soap.Element)

Example 12 with ShareInfoData

use of com.zimbra.cs.account.ShareInfoData in project zm-mailbox by Zimbra.

the class AclPushSerializer method deserialize.

public static ShareInfoData deserialize(String sharedItemInfo) throws ServiceException {
    String[] parts = sharedItemInfo.split(";");
    Map<String, String> attrs = new HashMap<String, String>();
    String key = null;
    for (String part : parts) {
        String[] x = part.split(":", 2);
        if (x.length == 2) {
            attrs.put(x[0], x[1]);
            key = x[0];
        } else {
            String value = attrs.get(key);
            attrs.put(key, value + ";" + x[0]);
        }
    }
    ShareInfoData obj = new ShareInfoData();
    String granteeId = attrs.get("granteeId");
    obj.setGranteeId("null".equals(granteeId) ? null : granteeId);
    String granteeName = attrs.get("granteeName");
    obj.setGranteeName("null".equals(granteeName) ? null : granteeName);
    obj.setGranteeType(ACL.stringToType(attrs.get("granteeType")));
    obj.setItemId(Integer.valueOf(attrs.get("folderId")));
    String uuid = attrs.get("folderUuid");
    obj.setItemUuid("null".equals(uuid) ? null : uuid);
    if (attrs.get("folderPath").contains(SEMICOLON_ESCAPE_SEQ)) {
        String temp = attrs.get("folderPath").replaceAll("\\*ASCII59\\*", ";");
        obj.setPath(temp);
    } else {
        obj.setPath(attrs.get("folderPath"));
    }
    obj.setFolderDefaultView(MailItem.Type.of(attrs.get("folderDefaultView")));
    obj.setRights(ACL.stringToRights(attrs.get("rights")));
    String type = attrs.get("type");
    if (type != null) {
        obj.setType(MailItem.Type.of(type));
    } else {
        obj.setType(MailItem.Type.FOLDER);
    }
    String expiry = attrs.get("expiry");
    if (expiry != null) {
        obj.setExpiry(Long.valueOf(expiry));
    }
    return obj;
}
Also used : HashMap(java.util.HashMap) ShareInfoData(com.zimbra.cs.account.ShareInfoData)

Example 13 with ShareInfoData

use of com.zimbra.cs.account.ShareInfoData in project zm-mailbox by Zimbra.

the class GetShareInfo method fetchRemoteShareInfo.

private void fetchRemoteShareInfo(Map<String, Object> context, Element request, String ownerId, ShareInfoVisitor visitor) throws ServiceException {
    /*
         * hack, there is no way to tell the proxying code to set
         * the <targetServer> element in the SOAP context so the
         * request won't be proxied again back to this server.
         *
         * mark the proxy request "internal" to indicate to the
         * handler to:
         *
         * 1. Do not proxy the request again (normal flow would be to
         *    proxy to the home server of the requested account, which is this server)
         *
         * 2. Do not get the mounted info of the requesting account, because
         *    it won't be able to access the mailbox of the requested account,
         *    which lives on this server.
         */
    request.addAttribute(AccountConstants.A_INTERNAL, true);
    Element response = proxyRequest(request, context, getServer(ownerId));
    for (Element eShare : response.listElements(AccountConstants.E_SHARE)) {
        ShareInfoData sid = ShareInfoData.fromXML(eShare);
        visitor.visit(sid);
    }
}
Also used : Element(com.zimbra.common.soap.Element) ShareInfoData(com.zimbra.cs.account.ShareInfoData)

Aggregations

ShareInfoData (com.zimbra.cs.account.ShareInfoData)13 Account (com.zimbra.cs.account.Account)6 Provisioning (com.zimbra.cs.account.Provisioning)5 ServiceException (com.zimbra.common.service.ServiceException)4 MailItem (com.zimbra.cs.mailbox.MailItem)4 Mountpoint (com.zimbra.cs.mailbox.Mountpoint)4 Element (com.zimbra.common.soap.Element)3 Domain (com.zimbra.cs.account.Domain)3 GuestAccount (com.zimbra.cs.account.GuestAccount)3 Mailbox (com.zimbra.cs.mailbox.Mailbox)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ZMailbox (com.zimbra.client.ZMailbox)2 ZMountpoint (com.zimbra.client.ZMountpoint)2 AuthTokenException (com.zimbra.cs.account.AuthTokenException)2 Group (com.zimbra.cs.account.Group)2 NamedEntry (com.zimbra.cs.account.NamedEntry)2 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)2 Folder (com.zimbra.cs.mailbox.Folder)2 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)2