use of com.zimbra.cs.mailbox.Mountpoint in project zm-mailbox by Zimbra.
the class SendShareNotification method getMatchingGrantLocal.
private MatchingGrant getMatchingGrantLocal(OperationContext octxt, MailItem item, byte granteeType, String granteeId, Account ownerAcct) throws ServiceException {
if (item instanceof Mountpoint) {
Mailbox ownerMbox = MailboxManager.getInstance().getMailboxByAccount(ownerAcct, false);
if (ownerMbox == null) {
throw ServiceException.FAILURE("mailbox not found for account " + ownerAcct.getId(), null);
}
item = ownerMbox.getItemById(octxt, ((Mountpoint) item).getRemoteId(), MailItem.Type.UNKNOWN);
}
ACL acl = item.getEffectiveACL();
if (acl == null) {
return null;
}
for (ACL.Grant grant : acl.getGrants()) {
if (grant.getGranteeType() == granteeType && grant.getGranteeId().equals(granteeId)) {
return new MatchingGrant(grant);
}
}
return null;
}
use of com.zimbra.cs.mailbox.Mountpoint in project zm-mailbox by Zimbra.
the class SendShareNotification method validateShareRecipient.
@Deprecated
private ShareInfoData validateShareRecipient(ZimbraSoapContext zsc, Map<String, Object> context, OperationContext octxt, Mailbox mbox, Element eShare) throws ServiceException {
Provisioning prov = Provisioning.getInstance();
//
// grantee
//
byte granteeType = ACL.stringToType(eShare.getAttribute(MailConstants.A_GRANT_TYPE));
String granteeId = eShare.getAttribute(MailConstants.A_ZIMBRA_ID, null);
String granteeName = eShare.getAttribute(MailConstants.A_DISPLAY, null);
// grantee id to match grant
String matchingId;
// email of the grantee, will be he recipient or the share notif message
String granteeEmail;
// display name, if set, of the grantee
String granteeDisplayName;
if (granteeType == ACL.GRANTEE_GUEST) {
if (granteeName == null) {
throw ServiceException.INVALID_REQUEST("must specify grantee name for guest grantee type", null);
}
// if guest, matchingId is the same as granteeEmail
matchingId = granteeName;
granteeEmail = granteeName;
granteeDisplayName = granteeEmail;
} else {
Pair<NamedEntry, String> grantee;
try {
grantee = getGrantee(zsc, granteeType, granteeId, granteeName);
} catch (ServiceException e) {
if (e.getCode().equals(MailServiceException.NO_SUCH_GRANTEE)) {
throw ServiceException.INVALID_REQUEST("no such grantee", e);
}
throw e;
}
NamedEntry granteeEntry = grantee.getFirst();
matchingId = granteeEntry.getId();
granteeEmail = granteeEntry.getName();
granteeDisplayName = grantee.getSecond();
}
//
// folder
//
Account account = getRequestedAccount(zsc);
Folder folder = getFolder(octxt, account, mbox, eShare);
Account ownerAcct = account;
// if the folder is a mountpoint, set correct ownerAcct and the folder id in the owner's mailbox
if (folder instanceof Mountpoint) {
Mountpoint mp = (Mountpoint) folder;
ownerAcct = prov.get(AccountBy.id, mp.getOwnerId());
folder = mp;
}
return getShareInfoData(zsc, context, ownerAcct, octxt, granteeType, granteeEmail, matchingId, granteeDisplayName, folder, false);
}
use of com.zimbra.cs.mailbox.Mountpoint in project zm-mailbox by Zimbra.
the class SendShareNotification method validateRequest.
private Collection<ShareInfoData> validateRequest(ZimbraSoapContext zsc, Map<String, Object> context, OperationContext octxt, Mailbox mbox, Element request) throws ServiceException {
Element eShare = request.getOptionalElement(MailConstants.E_SHARE);
if (eShare != null) {
return Arrays.asList(validateShareRecipient(zsc, context, octxt, mbox, eShare));
}
String action = request.getAttribute(MailConstants.A_ACTION, null);
ArrayList<ShareInfoData> shareInfos = new ArrayList<ShareInfoData>();
SendShareNotificationRequest req = zsc.elementToJaxb(request);
ItemId iid = new ItemId(req.getItem().getId(), zsc);
MailItem item = mbox.getItemById(octxt, iid.getId(), MailItem.Type.UNKNOWN);
Provisioning prov = Provisioning.getInstance();
Account account = getRequestedAccount(zsc);
if (item instanceof Mountpoint) {
Mountpoint mp = (Mountpoint) item;
account = prov.get(AccountBy.id, mp.getOwnerId());
}
for (EmailAddrInfo email : req.getEmailAddresses()) {
// add the non-existing grantee as type GRANTEE_GUEST for share notification.
// for revoke notifications return the non-existing grantees only
Pair<NamedEntry, String> grantee;
boolean guestGrantee = false;
byte granteeType = ACL.GRANTEE_USER;
String granteeId = null;
String granteeEmail = email.getAddress();
String granteeDisplayName = null;
try {
grantee = getGrantee(zsc, granteeType, granteeId, granteeEmail);
NamedEntry entry = grantee.getFirst();
if (entry instanceof MailTarget) {
Domain domain = prov.getDomain(account);
String granteeDomainName = ((MailTarget) entry).getDomainName();
if (domain.isInternalSharingCrossDomainEnabled() || domain.getName().equals(granteeDomainName) || Sets.newHashSet(domain.getInternalSharingDomain()).contains(granteeDomainName)) {
if (entry instanceof Group) {
granteeType = ACL.GRANTEE_GROUP;
}
granteeId = entry.getId();
granteeDisplayName = grantee.getSecond();
} else {
guestGrantee = true;
}
}
} catch (ServiceException e) {
if (!e.getCode().equals(MailServiceException.NO_SUCH_GRANTEE)) {
throw e;
}
guestGrantee = true;
}
if (guestGrantee) {
granteeType = ACL.GRANTEE_GUEST;
// if guest, granteeId is the same as granteeEmail
granteeId = granteeEmail;
}
shareInfos.add(getShareInfoData(zsc, context, account, octxt, granteeType, granteeEmail, granteeId, granteeDisplayName, item, REVOKE.equals(action)));
}
return shareInfos;
}
Aggregations