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);
}
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;
}
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);
}
}
Aggregations