@SuppressWarnings("unchecked")
  @Override
  protected Object buildModel(RenderingContext context) {
    // The templateNode can be null.
    NodeRef companyHome = repository.getCompanyHome();
    NodeRef templateNode = getTemplateNode(context);
    Map<String, Serializable> paramMap = context.getCheckedParam(PARAM_MODEL, Map.class);
    TemplateImageResolver imgResolver =
        context.getCheckedParam(PARAM_IMAGE_RESOLVER, TemplateImageResolver.class);

    // The fully authenticated user below is the username of the person who logged in and
    // who requested the execution of the current rendition. This will not be the
    // same person as the current user as renditions are executed by the system user.
    String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
    NodeRef person = serviceRegistry.getPersonService().getPerson(fullyAuthenticatedUser);

    NodeRef userHome = repository.getUserHome(person);
    Map<String, Object> model =
        getTemplateService()
            .buildDefaultModel(person, companyHome, userHome, templateNode, imgResolver);

    TemplateNode sourceTemplateNode =
        new TemplateNode(context.getSourceNode(), serviceRegistry, imgResolver);
    // TODO Add xml dom here.
    // model.put("xml", NodeModel.wrap(null));
    model.put(KEY_NODE, sourceTemplateNode);
    if (paramMap != null) model.putAll(paramMap);
    return model;
  }
Esempio n. 2
0
  @Override
  public void setUp() throws Exception {
    super.setUp();

    this.fileFolderService = (FileFolderService) ctx.getBean("FileFolderService");
    this.repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
    this.nodeService = (NodeService) ctx.getBean("NodeService");
    this.transactionService = (TransactionService) ctx.getBean("transactionService");

    server.setServletAuthenticatorFactory(new LocalTestRunAsAuthenticatorFactory());

    NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
    String guid = GUID.generate();

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());

    folderWithoutAspect =
        fileFolderService
            .create(companyHomeNodeRef, "folder_" + guid, ContentModel.TYPE_FOLDER)
            .getNodeRef();
    assertNotNull("Doesn't create folder", folderWithoutAspect);

    folderWithAspect =
        fileFolderService
            .create(companyHomeNodeRef, "folder_aspect_" + guid, ContentModel.TYPE_FOLDER)
            .getNodeRef();
    assertNotNull("Doesn't create folder", folderWithoutAspect);
    // add 'dublincore' aspect
    Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>(1);
    aspectProps.put(ContentModel.PROP_SUBJECT, "Test subject");
    nodeService.addAspect(folderWithAspect, ContentModel.ASPECT_DUBLINCORE, aspectProps);
  }
Esempio n. 3
0
  private Map<String, Serializable> buildMailTextModel(
      Map<String, String> properties, NodeRef inviter, NodeRef invitee) {
    // Set the core model parts
    // Note - the user part is skipped, as that's implied via the run-as
    Map<String, Serializable> model = new HashMap<String, Serializable>();
    model.put(TemplateService.KEY_COMPANY_HOME, repository.getCompanyHome());
    model.put(TemplateService.KEY_USER_HOME, repository.getUserHome(repository.getPerson()));
    model.put(TemplateService.KEY_PRODUCT_NAME, ModelUtil.getProductName(repoAdminService));

    // Build up the args for rendering inside the template
    Map<String, String> args = buildArgs(properties, inviter, invitee);
    model.put("args", (Serializable) args);

    // All done
    return model;
  }