use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class SendShareNotification method sendNotificationEmailToGroupGrantees.
private void sendNotificationEmailToGroupGrantees(OperationContext octxt, Mailbox mbox, Account authAccount, Account ownerAccount, Collection<ShareInfoData> sids, String notes, Action action) throws ServiceException, MessagingException {
Provisioning prov = Provisioning.getInstance();
for (ShareInfoData sid : sids) {
String granteeId = sid.getGranteeId();
Group group = prov.getGroupBasic(DistributionListBy.id, granteeId);
if (group == null) {
// huh? grantee type is GROUP but the group cannot be found by id.
// just log a warning and do not send.
// This is not likely to happen because validateRequest had already
// checked existance of the grantee.
sLog.warn("Group not found for sending share notificaiton to: " + granteeId + "(" + sid.getGranteeNotifName() + ")" + ", share notification not sent");
continue;
}
/*
* send to group members
*/
GroupMemberEmailAddrs addrs = prov.getMemberAddrs(group);
if (addrs.groupAddr() != null) {
// just send to the group's address, no treatment needed for recipients
sendNotificationEmail(octxt, mbox, authAccount, ownerAccount, sid, notes, action, null, null);
} else {
// send one common notif email to all internal members,
if (addrs.internalAddrs() != null) {
sendNotificationEmail(octxt, mbox, authAccount, ownerAccount, sid, notes, action, addrs.internalAddrs(), null);
}
// send one personalized notif email to each external member
Collection<String> extMembers = addrs.externalAddrs();
if (extMembers != null) {
if (extMembers.size() <= DebugConfig.sendGroupShareNotificationSynchronouslyThreshold) {
// send synchronously
sendNotificationEmailToGroupExternalMembers(octxt, mbox, authAccount, ownerAccount, sid, notes, action, extMembers);
} else {
// send asynchronously in a separate thread to avoid holding up the request
sendNotificationEmailToGroupExternalMembersAsync(octxt, mbox, authAccount, ownerAccount, sid, notes, action, extMembers);
}
}
}
}
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class GetDistributionList method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
GetDistributionListRequest req = JaxbUtil.elementToJaxb(request);
int limit = (req.getLimit() == null) ? 0 : req.getLimit();
if (limit < 0) {
throw ServiceException.INVALID_REQUEST("limit" + limit + " is negative", null);
}
int offset = (req.getOffset() == null) ? 0 : req.getOffset();
if (offset < 0) {
throw ServiceException.INVALID_REQUEST("offset" + offset + " is negative", null);
}
boolean sortAscending = !Boolean.FALSE.equals(req.isSortAscending());
Set<String> reqAttrs = getReqAttrs(req.getAttrs(), AttributeClass.distributionList);
DistributionListSelector dlSel = req.getDl();
DistributionListBy dlBy = dlSel.getBy().toKeyDistributionListBy();
AttrRightChecker arc = null;
Group group = getGroupFromContext(context);
if (group == null) {
if (DistributionListBy.name.equals(dlBy)) {
Entry pseudoTarget = pseudoTargetInSameDomainAsEmail(TargetType.dl, dlSel.getKey());
if (null != pseudoTarget) {
AdminAccessControl aac = checkDistributionListRight(zsc, (DistributionList) pseudoTarget, AdminRight.PR_ALWAYS_ALLOW);
arc = aac.getAttrRightChecker(pseudoTarget);
}
}
if (arc != null) {
defendAgainstGroupHarvestingWhenAbsent(dlBy, dlSel.getKey(), zsc, new GroupHarvestingCheckerUsingGetAttrsPerms(zsc, arc, Arrays.asList(minimumAttrs)));
} else {
defendAgainstGroupHarvestingWhenAbsent(dlBy, dlSel.getKey(), zsc, Admin.R_getDistributionList);
}
} else if (group.isDynamic()) {
AdminAccessControl aac = checkDynamicGroupRight(zsc, (DynamicGroup) group, AdminRight.PR_ALWAYS_ALLOW);
arc = aac.getAttrRightChecker(group);
} else {
AdminAccessControl aac = checkDistributionListRight(zsc, (DistributionList) group, AdminRight.PR_ALWAYS_ALLOW);
arc = aac.getAttrRightChecker(group);
}
defendAgainstGroupHarvesting(group, dlBy, dlSel.getKey(), zsc, new GroupHarvestingCheckerUsingGetAttrsPerms(zsc, arc, Arrays.asList(minimumAttrs)));
Element response = zsc.createElement(AdminConstants.GET_DISTRIBUTION_LIST_RESPONSE);
Element eDL = encodeDistributionList(response, group, true, false, reqAttrs, arc);
// return member info only if the authed has right to see zimbraMailForwardingAddress
boolean allowMembers = true;
if (group.isDynamic()) {
allowMembers = arc == null ? true : arc.allowAttr(Provisioning.A_member);
} else {
allowMembers = arc == null ? true : arc.allowAttr(Provisioning.A_zimbraMailForwardingAddress);
}
if (allowMembers) {
encodeMembers(response, eDL, group, offset, limit, sortAscending);
}
return response;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class RemoveDistributionListMember method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
List<String> memberList = getMemberList(request, context);
Group group = getGroupFromContext(context);
String id = request.getAttribute(AdminConstants.E_ID);
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_removeGroupMember, Admin.R_removeDistributionListMember);
memberList = addMembersFromAccountElements(request, memberList, group);
String[] members = memberList.toArray(new String[0]);
prov.removeGroupMembers(group, members);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListMember", "name", group.getName(), "member", Arrays.deepToString(members) }));
return zsc.jaxbToElement(new RemoveDistributionListMemberResponse());
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class RemoveDistributionListAlias method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
RemoveDistributionListAliasRequest req = JaxbUtil.elementToJaxb(request);
String id = req.getId();
String alias = req.getAlias();
Group group = getGroupFromContext(context);
String dlName = "";
try {
defendAgainstGroupHarvesting(group, DistributionListBy.id, id, zsc, Admin.R_removeGroupAlias, Admin.R_removeDistributionListAlias);
} catch (AccountServiceException ase) {
// still may want to remove the alias, even if it doesn't point at anything
// note: if we got a permission denied instead of AccountServiceException,
// means we don't have the rights so shouldn't get any further
}
if (group != null) {
dlName = group.getName();
}
// if the admin can remove an alias in the domain
checkDomainRightByEmail(zsc, alias, Admin.R_deleteAlias);
// even if dl is null, we still invoke removeAlias and throw an exception afterwards.
// this is so dangling aliases can be cleaned up as much as possible
prov.removeGroupAlias(group, alias);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "RemoveDistributionListAlias", "name", dlName, "alias", alias }));
if (group == null) {
throw AccountServiceException.NO_SUCH_DISTRIBUTION_LIST(id);
}
return zsc.jaxbToElement(new RemoveDistributionListAliasResponse());
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class RemoveDistributionListMember method getMemberList.
@Override
protected List<String> getMemberList(Element request, Map<String, Object> context) throws ServiceException {
List<String> memberList = super.getMemberList(request, context);
Group group = getGroupFromContext(context);
memberList = addMembersFromAccountElements(request, memberList, group);
return memberList;
}
Aggregations