Search in sources :

Example 1 with TemplateNode

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;
}
Also used : TemplateNode(org.alfresco.repo.template.TemplateNode) NodeRef(org.alfresco.service.cmr.repository.NodeRef) PersonService(org.alfresco.service.cmr.security.PersonService) WebScriptException(org.springframework.extensions.webscripts.WebScriptException)

Example 2 with TemplateNode

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;
}
Also used : TemplateNode(org.alfresco.repo.template.TemplateNode) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) InviteInfo(org.alfresco.repo.invitation.site.InviteInfo)

Example 3 with TemplateNode

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;
}
Also used : TemplateNode(org.alfresco.repo.template.TemplateNode) SiteInfo(org.alfresco.service.cmr.site.SiteInfo) NodeRef(org.alfresco.service.cmr.repository.NodeRef) InviteInfo(org.alfresco.repo.invitation.site.InviteInfo) PersonService(org.alfresco.service.cmr.security.PersonService)

Example 4 with TemplateNode

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;
}
Also used : TemplateNode(org.alfresco.repo.template.TemplateNode) FacesContext(javax.faces.context.FacesContext) I18NMessageMethod(org.alfresco.repo.template.I18NMessageMethod) HashMap(java.util.HashMap) BaseTemplateContentServlet(org.alfresco.web.app.servlet.BaseTemplateContentServlet) Date(java.util.Date)

Aggregations

TemplateNode (org.alfresco.repo.template.TemplateNode)4 InviteInfo (org.alfresco.repo.invitation.site.InviteInfo)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 PersonService (org.alfresco.service.cmr.security.PersonService)2 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 FacesContext (javax.faces.context.FacesContext)1 I18NMessageMethod (org.alfresco.repo.template.I18NMessageMethod)1 BaseTemplateContentServlet (org.alfresco.web.app.servlet.BaseTemplateContentServlet)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1