@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;
  }
Пример #2
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;
  }
Пример #3
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);
  }
  @Before
  public void createTestData() {
    userHome = repository.getUserHome(user1.getPersonNode());

    testNode =
        testNodes.createNodeWithTextContent(
            userHome,
            "Quick Share Test Node",
            ContentModel.TYPE_CONTENT,
            user1.getUsername(),
            "Quick Share Test Node Content");
  }
Пример #5
0
  public List<Folder> getFolders() {
    List<Folder> folders = new ArrayList<>();

    NodeRef rootFolder = repository.getRootHome();

    // for (rootFolder.children)

    folders.add(new Folder(rootFolder.toString()));
    folders.add(new Folder("fofolder"));

    return folders;
  }
Пример #6
0
  private NodeRef getEmailTemplateNodeRef() {
    List<NodeRef> nodeRefs =
        searchService.selectNodes(
            repository.getRootHome(),
            "app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl",
            null,
            this.namespaceService,
            false);

    if (nodeRefs.size() == 1) {
      // Now localise this
      NodeRef base = nodeRefs.get(0);
      NodeRef local = fileFolderService.getLocalizedSibling(base);
      return local;
    } else {
      throw new InvitationException("Cannot find the email template!");
    }
  }
  protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {

    Map<String, String> templateArgs = req.getServiceMatch().getTemplateVars();

    String storeType = templateArgs.get("store_type");
    String storeId = templateArgs.get("store_id");
    String nodeId = templateArgs.get("id");

    String nodePath = storeType + "/" + storeId + "/" + nodeId;

    NodeRef folder = repository.findNodeRef("node", nodePath.split("/"));

    // validate that folder has been found
    if (folder == null) {
      throw new WebScriptException(Status.STATUS_NOT_FOUND, "Folder " + nodePath + " not found");
    }

    // construct model for response template to render
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("folder", folder);

    return model;
  }