use of org.alfresco.repo.template.TemplateNode in project alfresco-remote-api by Alfresco.
the class Invites method getPersonIfAllowed.
private TemplateNode getPersonIfAllowed(final String userName) {
final PersonService personService = serviceRegistry.getPersonService();
NodeRef inviterRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>() {
public NodeRef doWork() throws Exception {
if (!personService.personExists(userName)) {
return null;
}
return personService.getPerson(userName, false);
}
}, AuthenticationUtil.getSystemUserName());
if (inviterRef != null && serviceRegistry.getPermissionService().hasPermission(inviterRef, PermissionService.READ_PROPERTIES).equals(AccessStatus.ALLOWED)) {
return new TemplateNode(inviterRef, serviceRegistry, null);
}
return null;
}
use of org.alfresco.repo.template.TemplateNode in project alfresco-remote-api by Alfresco.
the class Invites method toInviteInfo.
private InviteInfo toInviteInfo(Map<String, SiteInfo> siteInfoCache, final NominatedInvitation invitation) {
// get the site info
String resourceName = invitation.getResourceName();
SiteInfo siteInfo = siteInfoCache.get(resourceName);
if (siteInfo == null) {
siteInfo = siteService.getSite(resourceName);
siteInfoCache.put(resourceName, siteInfo);
}
String invitationStatus = InviteInfo.INVITATION_STATUS_PENDING;
TemplateNode inviterPerson = getPersonIfAllowed(invitation.getInviterUserName());
// fetch the person node for the invitee
TemplateNode inviteePerson = getPersonIfAllowed(invitation.getInviteeUserName());
InviteInfo ret = new InviteInfo(invitationStatus, invitation.getInviterUserName(), inviterPerson, invitation.getInviteeUserName(), inviteePerson, invitation.getRoleName(), invitation.getResourceName(), siteInfo, invitation.getSentInviteDate(), invitation.getInviteId());
return ret;
}
use of org.alfresco.repo.template.TemplateNode in project alfresco-remote-api by Alfresco.
the class InviteByTicket method toInviteInfo.
private InviteInfo toInviteInfo(NominatedInvitation invitation) {
final PersonService personService = serviceRegistry.getPersonService();
// get the site info
SiteInfo siteInfo = siteService.getSite(invitation.getResourceName());
String invitationStatus = getInvitationStatus(invitation);
NodeRef inviterRef = personService.getPerson(invitation.getInviterUserName());
TemplateNode inviterPerson = null;
if (inviterRef != null) {
inviterPerson = new TemplateNode(inviterRef, serviceRegistry, null);
}
// fetch the person node for the invitee
NodeRef inviteeRef = personService.getPerson(invitation.getInviteeUserName());
TemplateNode inviteePerson = null;
if (inviteeRef != null) {
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
}
InviteInfo ret = new InviteInfo(invitationStatus, invitation.getInviterUserName(), inviterPerson, invitation.getInviteeUserName(), inviteePerson, invitation.getRoleName(), invitation.getResourceName(), siteInfo, invitation.getSentInviteDate(), invitation.getInviteId());
return ret;
}
use of org.alfresco.repo.template.TemplateNode in project acs-community-packaging by Alfresco.
the class NodeInfoBean method getModel.
// ------------------------------------------------------------------------------
// Helper methods
private Map<String, Object> getModel(NodeRef nodeRef, Map<String, String> requestMap) throws ContentIOException {
FacesContext context = FacesContext.getCurrentInstance();
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
I18NUtil.registerResourceBundle("alfresco.messages.webclient");
// create api methods
model.put("date", new Date());
model.put("msg", new I18NMessageMethod());
model.put("url", new BaseTemplateContentServlet.URLHelper(context));
model.put("locale", I18NUtil.getLocale());
if (nodeRef != null) {
model.put("node", new TemplateNode(nodeRef, Repository.getServiceRegistry(context), this.imageResolver));
}
// add URL arguments as a map called 'args' to the root of the model
Map<String, String> args = new HashMap<String, String>(4, 1.0f);
for (String name : requestMap.keySet()) {
args.put(name, requestMap.get(name));
}
model.put("args", args);
return model;
}
Aggregations