use of org.alfresco.repo.invitation.InvitationSearchCriteriaImpl in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getSiteInvitation.
private Invitation getSiteInvitation(String inviteeId, String siteId) {
// Is there an outstanding site invite request for the invitee?
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationType.MODERATED);
criteria.setInvitee(inviteeId);
criteria.setResourceName(siteId);
criteria.setResourceType(ResourceType.WEB_SITE);
List<Invitation> invitations = invitationService.searchInvitation(criteria);
if (invitations.size() > 1) {
// TODO exception
throw new AlfrescoRuntimeException("There should be only one outstanding site invitation");
}
return (invitations.size() == 0 ? null : invitations.get(0));
}
use of org.alfresco.repo.invitation.InvitationSearchCriteriaImpl in project alfresco-remote-api by Alfresco.
the class Invites method executeImpl.
/*
* (non-Javadoc)
*
* @see
* org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco
* .web.scripts.WebScriptRequest,
* org.alfresco.web.scripts.WebScriptResponse)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status) {
// initialise model to pass on for template to render
Map<String, Object> model = new HashMap<String, Object>();
// Get parameter names
String[] paramNames = req.getParameterNames();
// handle no parameters given on URL
if ((paramNames == null) || (paramNames.length == 0)) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "No parameters have been provided on URL");
}
// get URL request parameters, checking if at least one has been provided
// check if 'inviterUserName' parameter provided
String inviterUserName = req.getParameter(PARAM_INVITER_USER_NAME);
boolean inviterUserNameProvided = (inviterUserName != null) && (inviterUserName.length() != 0);
// check if 'inviteeUserName' parameter provided
String inviteeUserName = req.getParameter(PARAM_INVITEE_USER_NAME);
boolean inviteeUserNameProvided = (inviteeUserName != null) && (inviteeUserName.length() != 0);
// check if 'siteShortName' parameter provided
String siteShortName = req.getParameter(PARAM_SITE_SHORT_NAME);
boolean siteShortNameProvided = (siteShortName != null) && (siteShortName.length() != 0);
// check if 'inviteId' parameter provided
String inviteId = req.getParameter(PARAM_INVITE_ID);
boolean inviteIdProvided = (inviteId != null) && (inviteId.length() != 0);
// 'inviteId' URL request parameters has not been provided
if (!(inviterUserNameProvided || inviteeUserNameProvided || siteShortNameProvided || inviteIdProvided)) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "At least one of the following URL request parameters must be provided in URL " + "'inviterUserName', 'inviteeUserName', 'siteShortName' or 'inviteId'");
}
// InviteInfo List to place onto model
List<InviteInfo> inviteInfoList = new ArrayList<InviteInfo>();
// query properties
if (inviteIdProvided) {
NominatedInvitation invitation = (NominatedInvitation) invitationService.getInvitation(inviteId);
Map<String, SiteInfo> siteInfoCache = new HashMap<String, SiteInfo>(2);
inviteInfoList.add(toInviteInfo(siteInfoCache, invitation));
} else // 'inviteId' has not been provided, so create the query properties from
// the invite URL request
// parameters
// - because this web script class will terminate with a web script
// exception if none of the required
// request parameters are provided, at least one of these query
// properties will be set
// at this point
{
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationSearchCriteria.InvitationType.NOMINATED);
criteria.setResourceType(Invitation.ResourceType.WEB_SITE);
if (inviterUserNameProvided) {
criteria.setInviter(inviterUserName);
}
if (inviteeUserNameProvided) {
criteria.setInvitee(inviteeUserName);
}
if (siteShortNameProvided) {
criteria.setResourceName(siteShortName);
}
// MNT-9905 Pending Invites created by one site manager aren't visible to other site managers
String currentUser = AuthenticationUtil.getRunAsUser();
List<Invitation> invitations;
if (siteShortNameProvided == true && (SiteModel.SITE_MANAGER).equals(siteService.getMembersRole(siteShortName, currentUser)) && inviterUserNameProvided == false && inviteeUserNameProvided == false) {
final InvitationSearchCriteriaImpl crit = criteria;
RunAsWork<List<Invitation>> runAsSystem = new RunAsWork<List<Invitation>>() {
@Override
public List<Invitation> doWork() throws Exception {
return invitationService.searchInvitation(crit);
}
};
invitations = AuthenticationUtil.runAs(runAsSystem, AuthenticationUtil.getSystemUserName());
} else {
invitations = invitationService.searchInvitation(criteria);
}
// Put InviteInfo objects (containing workflow path properties
// wf:inviterUserName, wf:inviteeUserName, wf:siteShortName,
// and invite id property (from workflow instance id))
// onto model for each invite workflow task returned by the query
Map<String, SiteInfo> siteInfoCache = new HashMap<String, SiteInfo>(invitations.size() * 2);
for (Invitation invitation : invitations) {
inviteInfoList.add(toInviteInfo(siteInfoCache, (NominatedInvitation) invitation));
}
}
// put the list of invite infos onto model to be passed onto template
// for rendering
model.put(MODEL_KEY_NAME_INVITES, inviteInfoList);
return model;
}
use of org.alfresco.repo.invitation.InvitationSearchCriteriaImpl in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getPagedSiteMembershipRequests.
@Override
public CollectionWithPagingInfo<SiteMembershipRequest> getPagedSiteMembershipRequests(final Parameters parameters) {
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationType.MODERATED);
criteria.setResourceType(ResourceType.WEB_SITE);
// Parse where clause properties.
Query q = parameters.getQuery();
if (q != null) {
// Filtering via "where" clause.
MapBasedQueryWalker propertyWalker = createSiteMembershipRequestQueryWalker();
QueryHelper.walk(q, propertyWalker);
String siteId = propertyWalker.getProperty(PARAM_SITE_ID, WhereClauseParser.EQUALS, String.class);
if (siteId != null && !siteId.isEmpty()) {
criteria.setResourceName(siteId);
}
String personId = propertyWalker.getProperty(PARAM_PERSON_ID, WhereClauseParser.EQUALS, String.class);
if (personId != null && !personId.isEmpty()) {
criteria.setInvitee(personId);
}
}
List<Invitation> invitations = invitationService.searchInvitation(criteria);
return createPagedSiteMembershipRequests(toSiteMembershipRequests(invitations, true), parameters.getPaging());
}
use of org.alfresco.repo.invitation.InvitationSearchCriteriaImpl in project alfresco-remote-api by Alfresco.
the class SiteMembershipRequestsImpl method getSiteInvitations.
private List<Invitation> getSiteInvitations(String inviteeId) {
InvitationSearchCriteriaImpl criteria = new InvitationSearchCriteriaImpl();
criteria.setInvitationType(InvitationType.MODERATED);
criteria.setInvitee(inviteeId);
criteria.setResourceType(ResourceType.WEB_SITE);
List<Invitation> invitations = invitationService.searchInvitation(criteria);
return invitations;
}
Aggregations