コード例 #1
0
  @Test
  public void cloud928() {
    final NodeRef node =
        testNodes.createNodeWithTextContent(
            userHome,
            "CLOUD-928 Test Node",
            ContentModel.TYPE_CONTENT,
            user1.getUsername(),
            "Quick Share Test Node Content");

    QuickShareDTO dto = share(node, user1.getUsername());

    attributeService.removeAttribute(QuickShareServiceImpl.ATTR_KEY_SHAREDIDS_ROOT, dto.getId());

    AuthenticationUtil.runAs(
        new RunAsWork<Object>() {

          @Override
          public Object doWork() throws Exception {
            nodeService.deleteNode(node);
            return null;
          }
        },
        user1.getUsername());

    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    Assert.assertFalse(nodeService.exists(node));
  }
コード例 #2
0
  @Test
  public void getMetadataFromShareId() {
    QuickShareDTO dto = share(testNode, user1.getUsername());

    Map<String, Object> metadata = quickShareService.getMetaData(dto.getId());

    assertNotNull(metadata);
    assertTrue(metadata.size() > 0);
  }
コード例 #3
0
  @Test
  public void unshare() {
    final QuickShareDTO dto = share(testNode, user1.getUsername());
    unshare(dto.getId(), user1.getUsername());
    AuthenticationUtil.runAsSystem(
        new RunAsWork<Void>() {

          @Override
          public Void doWork() throws Exception {
            assertFalse(nodeService.getAspects(testNode).contains(QuickShareModel.ASPECT_QSHARE));
            assertNull(nodeService.getProperty(testNode, QuickShareModel.PROP_QSHARE_SHAREDID));
            assertNull(nodeService.getProperty(testNode, QuickShareModel.PROP_QSHARE_SHAREDBY));
            return null;
          }
        });
  }
コード例 #4
0
  /**
   * Content types that extend cm:content should be shareable.
   *
   * <p>See https://issues.alfresco.com/jira/browse/ALF-16274.
   */
  @Test
  public void testWithCustomContentType() {
    ByteArrayInputStream modelStream = new ByteArrayInputStream(MODEL.getBytes());
    temporaryModels.loadModel(modelStream);

    QName sharableType = QName.createQName("{http://bugtestmodel}doc");
    QName unsharableType = QName.createQName("{http://bugtestmodel}doc2");

    final NodeRef sharableNode =
        testNodes.createNodeWithTextContent(
            userHome,
            "Quick Share Custom Type Sharable Test Node",
            sharableType,
            user1.getUsername(),
            "Quick Share Test Node Content");

    Map<String, Object> metadata = getMetadata(sharableNode, user1);

    assertTrue((Boolean) metadata.get("sharable"));

    QuickShareDTO dto = share(sharableNode, user1.getUsername());
    unshare(dto.getId(), user1.getUsername());

    final NodeRef unsharableNode =
        testNodes.createNodeWithTextContent(
            userHome,
            "Quick Share Custom Type Unsharable Test Node",
            unsharableType,
            user1.getUsername(),
            "Quick Share Test Node Content");

    metadata = getMetadata(unsharableNode, user1);
    assertFalse((Boolean) metadata.get("sharable"));

    boolean exceptionThrown = false;
    try {
      // Prior to fixing ALF-16274, this would throw an InvalidNodeRefException.
      share(unsharableNode, user1.getUsername());
    } catch (InvalidNodeRefException ex) {
      exceptionThrown = true;
    }
    assertTrue(
        "InvalidNodeRefException not thrown on trying to share an unsharable content type",
        exceptionThrown);
  }