use of org.alfresco.service.cmr.site.SiteMemberInfo in project alfresco-remote-api by Alfresco.
the class SitesImpl method isMemberOfSite.
private SiteMemberInfo isMemberOfSite(String siteId, String id) {
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
logger.debug("Site does not exist: " + siteId);
throw new EntityNotFoundException(siteId);
}
validateGroup(id);
SiteMemberInfo memberInfo = this.siteService.getMembersRoleInfo(siteId, id);
if (memberInfo == null) {
logger.debug("Given authority is not a member of the site");
throw new InvalidArgumentException("Given authority is not a member of the site");
}
if (memberInfo.getMemberRole() == null) {
logger.debug("Getting authority role but role is null");
throw new RelationshipResourceNotFoundException(memberInfo.getMemberName(), siteId);
}
return memberInfo;
}
use of org.alfresco.service.cmr.site.SiteMemberInfo in project alfresco-remote-api by Alfresco.
the class SitesImpl method addSiteGroupMembership.
@Override
public SiteGroup addSiteGroupMembership(String siteId, SiteGroup group) {
SiteInfo siteInfo = validateSite(siteId);
if (siteInfo == null) {
logger.debug("Site does not exist: " + siteId);
throw new EntityNotFoundException(siteId);
}
validateGroup(group.getId());
SiteMemberInfo groupInfo = siteService.getMembersRoleInfo(siteId, group.getId());
if (groupInfo != null) {
logger.debug("addSiteGroupMembership: " + group.getId() + " is already a member of site " + siteId);
throw new ConstraintViolatedException(group.getId() + " is already a member of site " + siteId);
}
if (group.getRole() == null) {
logger.debug("Getting member role but role is null");
throw new RelationshipResourceNotFoundException(group.getId(), siteId);
}
siteService.setMembership(siteId, group.getId(), group.getRole());
return group;
}
use of org.alfresco.service.cmr.site.SiteMemberInfo in project alfresco-repository by Alfresco.
the class SiteServiceImpl method listMembersImpl.
protected Map<String, String> listMembersImpl(String shortName, String nameFilter, String roleFilter, int size, boolean expandGroups) {
List<SiteMemberInfo> list = listMembersInfoImpl(shortName, nameFilter, roleFilter, size, expandGroups);
Map<String, String> members = new HashMap<String, String>(list.size());
for (SiteMemberInfo info : list) members.put(info.getMemberName(), info.getMemberRole());
return members;
}
use of org.alfresco.service.cmr.site.SiteMemberInfo in project alfresco-repository by Alfresco.
the class Site method isMemberOfGroup.
/**
* Indicates whether a user belongs to a group with access rights to the site or not
*
* @param authorityName user name
* @return boolean true if the user belongs to a group with access rights, false otherwise
*/
public boolean isMemberOfGroup(String authorityName) {
boolean isMemberOfGroup = false;
SiteMemberInfo membersRoleInfo = getMembersRoleInfo(authorityName);
if (membersRoleInfo != null) {
isMemberOfGroup = membersRoleInfo.isMemberOfGroup();
}
return isMemberOfGroup;
}
use of org.alfresco.service.cmr.site.SiteMemberInfo in project alfresco-remote-api by Alfresco.
the class SiteMembershipsGet method executeImpl.
@Override
protected Map<String, Object> executeImpl(SiteInfo site, WebScriptRequest req, Status status, Cache cache) {
// Grab out filters
String nameFilter = req.getParameter("nf");
if (nameFilter != null) {
nameFilter = nameFilter.endsWith("*") ? nameFilter : nameFilter + "*";
}
String roleFilter = req.getParameter("rf");
String authorityType = req.getParameter("authorityType");
String sizeS = req.getParameter("size");
boolean collapseGroups = false;
// Sanity check the types
if (authorityType != null) {
if ("USER".equals(authorityType)) {
collapseGroups = true;
} else if ("GROUP".equals(authorityType)) {
// No extra settings needed
} else {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "The Authority must be one of USER or GROUP");
}
}
// Figure out what to limit to, if anythign
int limit = 0;
if (sizeS != null) {
try {
limit = Integer.parseInt(sizeS);
} catch (NumberFormatException e) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid size specified");
}
}
// Fetch the membership details of the site
List<SiteMemberInfo> members = this.siteService.listMembersInfo(site.getShortName(), nameFilter, roleFilter, limit, collapseGroups);
// Process it ready for FreeMarker
// Note that as usernames may be all numbers, we need to
// prefix them with an underscore otherwise FTL can get confused!
Map<String, Object> authorities = new HashMap<String, Object>(members.size());
Map<String, Object> memberInfo = new LinkedHashMap<String, Object>(members.size());
for (SiteMemberInfo authorityObj : members) {
String ftlSafeName = "_" + authorityObj.getMemberName();
if (authorityObj.getMemberName().startsWith("GROUP_")) {
if (authorityType == null || authorityType.equals("GROUP")) {
// Record the details
authorities.put(ftlSafeName, scriptAuthorityService.getGroupForFullAuthorityName(authorityObj.getMemberName()));
memberInfo.put(ftlSafeName, authorityObj);
}
} else {
if (authorityType == null || authorityType.equals("USER")) {
// Record the details
authorities.put(ftlSafeName, personService.getPerson(authorityObj.getMemberName()));
memberInfo.put(ftlSafeName, authorityObj);
}
}
}
// Pass the details to freemarker
Map<String, Object> model = new HashMap<String, Object>();
model.put("site", site);
model.put("authorities", authorities);
model.put("memberInfo", memberInfo);
return model;
}
Aggregations