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

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


         if (lock.isSessionScoped() && !pendingLocks.contains(nodeId))
         {
            try
            {
               NodeImpl node =
                  ((NodeImpl)sessionImpl.getTransientNodesManager()
                     .getItemByIdentifier(lock.getNodeIdentifier(), false));

               if (node != null)
               {
                  node.unlock();
               }

            }
            catch (UnsupportedRepositoryOperationException e)
            {
View Full Code Here


   {

      checkInitialized();
      JCRPath path = session.getLocationFactory().parseAbsPath(absPath);
      QPath qpath = path.getInternalPath();
      NodeImpl parent = (NodeImpl) session.getTransientNodesManager().getItem(qpath.makeParentPath(), false);
      if (parent == null)
         throw new PathNotFoundException("Parent not found for " + path.getAsString(false));

      // validate as on parent child node
      parent.validateChildNode(qpath.getName(), Constants.NT_QUERY);

      NodeData queryData =
               TransientNodeData.createNodeData((NodeData) parent.getData(), qpath.getName(), Constants.NT_QUERY);
      NodeImpl queryNode =
               (NodeImpl) session.getTransientNodesManager().update(ItemState.createAddedState(queryData), false);

      NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
      PlainChangesLog changes =
               ntmanager.makeAutoCreatedItems((NodeData) queryNode.getData(), Constants.NT_QUERY, session
                        .getTransientNodesManager(), session.getUserID());
      for (ItemState autoCreatedState : changes.getAllStates())
      {
         session.getTransientNodesManager().update(autoCreatedState, false);
      }
View Full Code Here

   {
      if (next == null)
      {
         throw new NoSuchElementException();
      }
      NodeImpl n = next;
      fetchNext();
      return n;
   }
View Full Code Here

    * @throws Exception
    */
   public void testPropfindPropOwnerAndAclOnNode() throws Exception
   {

      NodeImpl testNode = (NodeImpl)root.addNode("test_acl_property", "nt:folder");
      testNode.addMixin("exo:owneable");
      testNode.addMixin("exo:privilegeable");
      session.save();

      Map<String, String[]> permissions = new HashMap<String, String[]>();

      String userName = USER_JOHN;
      permissions.put(userName, PermissionType.ALL);

      testNode.setPermissions(permissions);
      testNode.getSession().save();

      MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      headers.putSingle("Depth", "1");
      headers.putSingle(HttpHeaders.CONTENT_TYPE, "text/xml; charset=\"utf-8\"");

      EnvironmentContext ctx = new EnvironmentContext();

      Set<String> adminRoles = new HashSet<String>();
      adminRoles.add("administrators");

      DummySecurityContext adminSecurityContext = new DummySecurityContext(new Principal()
      {
         public String getName()
         {
            return USER_ROOT;
         }
      }, adminRoles);

      ctx.put(SecurityContext.class, adminSecurityContext);

      RequestHandlerImpl handler = (RequestHandlerImpl)container.getComponentInstanceOfType(RequestHandlerImpl.class);
      ResourceLauncher launcher = new ResourceLauncher(handler);

      String request =
         "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<D:propfind xmlns:D=\"DAV:\">" + "<D:prop>" + "<D:owner/>"
            + "<D:acl/>" + "</D:prop>" + "</D:propfind>";

      ContainerResponse cres =
         launcher.service(WebDAVMethods.PROPFIND, getPathWS() + testNode.getPath(), BASE_URI, headers,
            request.getBytes(), null, ctx);

      assertEquals(HTTPStatus.MULTISTATUS, cres.getStatus());

      HierarchicalPropertyEntityProvider provider = new HierarchicalPropertyEntityProvider();
      InputStream inputStream = TestUtils.getResponseAsStream(cres);
      HierarchicalProperty multistatus = provider.readFrom(null, null, null, null, null, inputStream);

      assertEquals(new QName("DAV:", "multistatus"), multistatus.getName());
      assertEquals(1, multistatus.getChildren().size());

      HierarchicalProperty resourceProp = multistatus.getChildren().get(0);

      HierarchicalProperty resourceHref = resourceProp.getChild(new QName("DAV:", "href"));
      assertNotNull(resourceHref);
      assertEquals(BASE_URI + getPathWS() + testNode.getPath() + "/", resourceHref.getValue());

      HierarchicalProperty propstatProp = resourceProp.getChild(new QName("DAV:", "propstat"));
      HierarchicalProperty propProp = propstatProp.getChild(new QName("DAV:", "prop"));

      HierarchicalProperty aclProp = propProp.getChild(ACLProperties.ACL);
View Full Code Here

         initialize();
         if (next == null)
         {
            throw new NoSuchElementException();
         }
         NodeImpl n = next;
         fetchNext();
         return n;
      }
View Full Code Here

         }
         String pathStr = excerptCall.substring(idx + EXCERPT_FUNC_LPAR.length(), end).trim();
         String decodedPath = ISO9075.decode(pathStr);
         try
         {
            NodeImpl n = (NodeImpl) node.getNode(decodedPath);
            return createExcerpt(n.getInternalIdentifier());
         }
         catch (PathNotFoundException e)
         {
            // does not exist or references a property
            try
View Full Code Here

       * @inheritDoc
       */
      public NodeImpl nextNodeImpl()
      {
         init();
         NodeImpl n = (NodeImpl) selfAndChildren.next();
         position++;
         return n;
      }
View Full Code Here

   public void testUpdateWhenParentHasRightsButChildNot() throws Exception
   {
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));

      NodeImpl subNode = (NodeImpl)sessJohn.getRootNode().getNode("testRoot").addNode("testNode");
      subNode.addMixin("exo:privilegeable");
      sessJohn.save();

      NodeImpl testRoot = (NodeImpl)sessJohn.getRootNode().getNode("testRoot");

      testRoot.setPermission("mary", PermissionType.ALL);
      testRoot.setPermission("john", PermissionType.ALL);
      testRoot.removePermission(SystemIdentity.ANY);

      subNode.setPermission("mary", new String[]{PermissionType.READ, PermissionType.SET_PROPERTY});
      subNode.removePermission(SystemIdentity.ANY);
      sessJohn.save();
      sessJohn.logout();
View Full Code Here

      TesterItemsPersistenceListener pl = new TesterItemsPersistenceListener(this.session);

      for (int i = 0; i < nodes; i++)
      {
         NodeImpl node = (NodeImpl)root.addNode("fileName" + i, "nt:file");
         NodeImpl cont = (NodeImpl)node.addNode("jcr:content", "nt:resource");
         cont.setProperty("jcr:mimeType", "text/plain");
         cont.setProperty("jcr:lastModified", Calendar.getInstance());
         cont.setProperty("jcr:encoding", "UTF-8");

         cont.setProperty("jcr:data", new ByteArrayInputStream(createBLOBTempData(300)));
      }
      root.save();

      // Serialize with JCR
      File jcrfile = File.createTempFile("jcr", "test");
View Full Code Here

   public void testUpdateWhenChildHasRightsButParentNot() throws Exception
   {
      Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));

      NodeImpl subNode = (NodeImpl)sessJohn.getRootNode().getNode("testRoot").addNode("testNode");
      subNode.addMixin("exo:privilegeable");
      sessJohn.save();

      NodeImpl testRoot = (NodeImpl)sessJohn.getRootNode().getNode("testRoot");

      testRoot.setPermission("mary", new String[]{PermissionType.READ});
      testRoot.setPermission("john", PermissionType.ALL);
      testRoot.removePermission(SystemIdentity.ANY);

      subNode.setPermission("mary", PermissionType.ALL);
      subNode.removePermission(SystemIdentity.ANY);
      sessJohn.save();
      sessJohn.logout();
View Full Code Here

TOP

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

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.