Package org.exoplatform.services.jcr.impl.core

Examples of org.exoplatform.services.jcr.impl.core.NodeImpl$NodesOrderComparator


    * @throws Exception
    */
   public void testFulltextAllNodes() throws Exception
   {
      Node doc1 = root.addNode("document1", "nt:file");
      NodeImpl cont1 = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
      cont1.setProperty("jcr:mimeType", "text/plain");
      cont1.setProperty("jcr:lastModified", Calendar.getInstance());
      cont1.setProperty("jcr:data", "The quick brown fox jump over the lazy dog");
      session.save();

      Node doc2 = root.addNode("document2", "nt:file");
      NodeImpl cont2 = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont2.setProperty("jcr:mimeType", "text/plain");
      cont2.setProperty("jcr:lastModified", Calendar.getInstance());
      cont2.setProperty("jcr:data", "Dogs do not like cats.");

      Node doc3 = root.addNode("document3", "nt:file");
      NodeImpl cont3 = (NodeImpl)doc3.addNode("jcr:content", "nt:resource");
      cont3.setProperty("jcr:mimeType", "text/plain");
      cont3.setProperty("jcr:lastModified", Calendar.getInstance());
      cont3.setProperty("jcr:data", "Cats jumping high.");
      session.save();

      // make SQL query
      QueryManager qman = this.workspace.getQueryManager();

View Full Code Here


      Node doc2 = root.addNode("document2", "nt:file");
      doc2.addMixin("mix:title");
      doc2.setProperty("jcr:title", "Prison break.");
      doc2.setProperty("jcr:description", "Run, Forest, run ))");

      NodeImpl cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", "text");

      Node doc3 = root.addNode("document3", "nt:unstructured");
      doc3.addMixin("mix:title");
      doc3.setProperty("jcr:title", "Titanic");
      doc3.setProperty("jcr:description", "The aisberg break ship.");
View Full Code Here

      Node doc2 = root.addNode("document2", "nt:file");
      doc2.addMixin("mix:title");
      doc2.setProperty("jcr:title", "Prison break");
      doc2.setProperty("jcr:description", "Brown fox live in forest.");

      NodeImpl cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", "text");

      Node doc3 = root.addNode("document3", "nt:unstructured");
      doc3.addMixin("mix:title");
      doc3.setProperty("jcr:title", "Star wars");
      doc3.setProperty("jcr:description", "fox is a nice animal.");
View Full Code Here

      Node doc2 = root.addNode("document2", "nt:file");
      doc2.addMixin("mix:title");
      doc2.setProperty("jcr:title", "Prison break");
      doc2.setProperty("jcr:description", "Run, Forest, run ))");

      NodeImpl cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", "text");

      Node doc3 = root.addNode("document3", "nt:unstructured");
      doc3.addMixin("mix:title");
      doc3.setProperty("jcr:title", "Panopticum");
      doc3.setProperty("jcr:description", "It's imagine film )");
View Full Code Here

      Node doc2 = root.addNode("document2", "nt:file");
      doc2.addMixin("mix:title");
      doc2.setProperty("jcr:title", "Prison break");
      doc2.setProperty("jcr:description", "Brown fox live in forest.");

      NodeImpl cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", "text");

      Node doc3 = root.addNode("document3", "nt:unstructured");
      doc3.addMixin("mix:title");
      doc3.setProperty("jcr:title", "Star wars");
      doc3.setProperty("jcr:description", "fox is a nice animal.");
View Full Code Here

    */
   public void testAclImportDocumentView() throws Exception
   {
      AccessManager accessManager = ((SessionImpl)root.getSession()).getAccessManager();

      NodeImpl testRoot = (NodeImpl)root.addNode("TestRoot", "exo:article");

      testRoot.addMixin("exo:owneable");
      testRoot.addMixin("exo:privilegeable");
      testRoot.setProperty("exo:title", "test");

      session.save();
      assertTrue(accessManager.hasPermission(testRoot.getACL(), PermissionType.SET_PROPERTY, new Identity("exo")));

      testRoot.setPermission(testRoot.getSession().getUserID(), PermissionType.ALL);
      testRoot.setPermission("exo", new String[]{PermissionType.SET_PROPERTY});
      testRoot.removePermission(SystemIdentity.ANY);
      session.save();
      assertTrue(accessManager.hasPermission(testRoot.getACL(), PermissionType.SET_PROPERTY, new Identity("exo")));
      assertFalse(accessManager.hasPermission(testRoot.getACL(), PermissionType.READ, new Identity("exo")));

      File tmp = File.createTempFile("testAclImpormt", "tmp");
      tmp.deleteOnExit();
      serialize(testRoot, false, true, tmp);
      testRoot.remove();
      session.save();

      NodeImpl importRoot = (NodeImpl)root.addNode("ImportRoot");

      deserialize(importRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
         new BufferedInputStream(new FileInputStream(tmp)));
      session.save();
      Node n1 = importRoot.getNode("TestRoot");
      assertTrue("Wrong ACL", accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.SET_PROPERTY,
         new Identity("exo")));
      assertFalse("Wrong ACL", accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.READ, new Identity(
         "exo")));
      importRoot.remove();
      session.save();
   }
View Full Code Here

   }

   public void testSearchByName() throws Exception
   {
      Node doc1 = root.addNode("document1", "nt:file");
      NodeImpl cont1 = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
      cont1.setProperty("jcr:mimeType", "text/plain");
      cont1.setProperty("jcr:lastModified", Calendar.getInstance());
      cont1.setProperty("jcr:data", "The quick brown fox jump over the lazy dog");
      session.save();

      Node doc2 = root.addNode("document2", "nt:file");
      NodeImpl cont2 = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
      cont2.setProperty("jcr:mimeType", "text/plain");
      cont2.setProperty("jcr:lastModified", Calendar.getInstance());
      cont2.setProperty("jcr:data", "Dogs do not like cats.");

      Node doc3 = root.addNode("document1", "nt:file");
      NodeImpl cont3 = (NodeImpl)doc3.addNode("jcr:content", "nt:resource");
      cont3.setProperty("jcr:mimeType", "text/plain");
      cont3.setProperty("jcr:lastModified", Calendar.getInstance());
      cont3.setProperty("jcr:data", "Cats jumping high.");
      session.save();

      // make SQL query
      QueryManager qman = this.workspace.getQueryManager();
View Full Code Here

    */
   public void testAclImportSystemView() throws Exception
   {
      AccessManager accessManager = ((SessionImpl)root.getSession()).getAccessManager();

      NodeImpl testRoot = (NodeImpl)root.addNode("TestRoot", "exo:article");

      testRoot.addMixin("exo:owneable");
      testRoot.addMixin("exo:privilegeable");
      testRoot.setProperty("exo:title", "test");

      session.save();
      assertTrue(accessManager.hasPermission(testRoot.getACL(), PermissionType.SET_PROPERTY, new Identity("exo")));

      testRoot.setPermission(testRoot.getSession().getUserID(), PermissionType.ALL);
      testRoot.setPermission("exo", new String[]{PermissionType.SET_PROPERTY});
      testRoot.removePermission(SystemIdentity.ANY);
      session.save();
      assertTrue(accessManager.hasPermission(testRoot.getACL(), PermissionType.SET_PROPERTY, new Identity("exo")));
      assertFalse(accessManager.hasPermission(testRoot.getACL(), PermissionType.READ, new Identity("exo")));

      File tmp = File.createTempFile("testAclImpormt", "tmp");
      tmp.deleteOnExit();
      serialize(testRoot, true, true, tmp);
      testRoot.remove();
      session.save();

      NodeImpl importRoot = (NodeImpl)root.addNode("ImportRoot");

      deserialize(importRoot, XmlSaveType.SESSION, true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING,
         new BufferedInputStream(new FileInputStream(tmp)));
      session.save();
      Node n1 = importRoot.getNode("TestRoot");
      assertTrue("Wrong ACL", accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.SET_PROPERTY,
         new Identity("exo")));
      assertFalse("Wrong ACL", accessManager.hasPermission(((NodeImpl)n1).getACL(), PermissionType.READ, new Identity(
         "exo")));
      importRoot.remove();
      session.save();
   }
View Full Code Here

   }
  
   private void contentWithCustomPrivilege(boolean isSystemViewExport) throws Exception
   {
      // prepare content
      NodeImpl testRoot = (NodeImpl)root.addNode("restricted", "nt:unstructured");
      testRoot.addMixin("exo:privilegeable");
      HashMap<String, String[]> perm = new HashMap<String, String[]>();
      perm.put("john", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("*:/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      ((ExtendedNode)testRoot).setPermissions(perm);
      session.save();
     
      Node file = testRoot.addNode("accept.gif", "nt:file");
      file.addMixin("exo:privilegeable");
      perm = new HashMap<String, String[]>();
      perm.put("*:/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("root", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("*:/organization/management/executive-board", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("any", new String[]{"read"});
      ((ExtendedNode)file).setPermissions(perm);
          
      Node cont = (NodeImpl)file.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", new FileInputStream(createBLOBTempFile(1)));
      session.save();
     
      Credentials cred = new CredentialsImpl("demo", "exo".toCharArray());
      Session sess = repository.login(cred, "ws");
      assertNotNull(sess.getItem("/restricted/accept.gif"));
      assertNotNull(sess.getItem("/restricted/accept.gif/jcr:content"));
      sess.logout();
     
      // system view export
      File exportFile = isSystemViewExport ? File.createTempFile("sys-export", ".xml") : File.createTempFile("doc-export", ".xml");
      exportFile.deleteOnExit();
      if (isSystemViewExport)
      {
         sess.exportSystemView(file.getPath(), new FileOutputStream(exportFile), false, false);
      }
      else
      {
         sess.exportDocumentView(file.getPath(), new FileOutputStream(exportFile), false, false);
      }
     
      // remove existed node
      file.remove();
      session.save();
     
      try
      {
         testRoot.getNode("accept.gif");
         fail();
      }
      catch (PathNotFoundException e) {
         //ok
      }
View Full Code Here

   }
   private void contentWithCustomOwnerAndPrivilege(boolean isSystemViewExport) throws Exception
   {
   // prepare content
      NodeImpl testRoot = (NodeImpl)root.addNode("restricted", "nt:unstructured");
      testRoot.addMixin("exo:privilegeable");
      HashMap<String, String[]> perm = new HashMap<String, String[]>();
      perm.put("john", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("*:/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      ((ExtendedNode)testRoot).setPermissions(perm);
      session.save();
     
      testRoot.addMixin("exo:owneable");
      assertEquals("admin", testRoot.getProperty("exo:owner").getString());
      assertEquals("admin", testRoot.getACL().getOwner());
     
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()), "ws");
      Node file = sessJohn.getRootNode().getNode("restricted").addNode("accept.gif", "nt:file");
      file.addMixin("exo:privilegeable");
      perm = new HashMap<String, String[]>();
      perm.put("*:/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("root", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("*:/organization/management/executive-board", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("/platform/administrators", new String[]{"read", "add_node", "set_property", "remove"});
      perm.put("any", new String[]{"read"});
      ((ExtendedNode)file).setPermissions(perm);
     
      file.addMixin("exo:owneable");
      assertEquals("john", file.getProperty("exo:owner").getString());
      assertEquals("john", ((ExtendedNode)file).getACL().getOwner());
     
          
      Node cont = (NodeImpl)file.addNode("jcr:content", "nt:resource");
      cont.setProperty("jcr:mimeType", "text/plain");
      cont.setProperty("jcr:lastModified", Calendar.getInstance());
      cont.setProperty("jcr:data", new FileInputStream(createBLOBTempFile(1)));
      sessJohn.save();
     
       assertEquals("john", ((ExtendedNode)cont).getACL().getOwner());
     
      Credentials cred = new CredentialsImpl("demo", "exo".toCharArray());
      Session sess = repository.login(cred, "ws");
      assertNotNull(sess.getItem("/restricted/accept.gif"));
      assertNotNull(sess.getItem("/restricted/accept.gif/jcr:content"));
      sess.logout();
     
      // export
      File exportFile = isSystemViewExport ? File.createTempFile("sys-export", ".xml") : File.createTempFile("doc-export", ".xml");
      exportFile.deleteOnExit();
      if (isSystemViewExport)
      {
         sess.exportSystemView(file.getPath(), new FileOutputStream(exportFile), false, false);
      }
      else
      {
         sess.exportDocumentView(file.getPath(), new FileOutputStream(exportFile), false, false);
      }
     
      // remove existed node
      file.remove();
      sessJohn.save();
     
      try
      {
         testRoot.getNode("accept.gif");
         fail();
      }
      catch (PathNotFoundException e) {
         //ok
      }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.NodeImpl$NodesOrderComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.