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

Examples of org.exoplatform.services.jcr.impl.core.JCRPath$PathElement


      }
   }

   public void testCreateRoot() throws Exception
   {
      JCRPath path = factory.createRootLocation();
      assertEquals("/", path.getAsString(false));
      assertEquals("/", path.getAsString(true));
      assertEquals(1, path.getIndex());
      assertEquals("", path.getName().getName());
   }
View Full Code Here


   }

   public void testParsePath() throws Exception
   {

      JCRPath path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
      assertEquals("node2", path.getName().getName());
      assertEquals(1, path.getIndex());
      assertEquals("node2", path.getInternalPath().getName().getName());
      assertEquals(3, path.getDepth());
      assertEquals("/jcr:node/node1[2]/exo:node2", path.getAsString(false));
      assertEquals("/jcr:node[1]/node1[2]/exo:node2[1]", path.getAsString(true));

      // with index
      assertTrue(path.equals(factory.parseAbsPath("/jcr:node/node1[2]/exo:node2[1]")));
      assertFalse(path.equals(factory.parseAbsPath("/jcr:node/node1[1]/exo:node2[1]")));

      JCRPath path1 = factory.parseAbsPath("/jcr:node[3]");
      assertEquals(3, path1.getIndex());

   }
View Full Code Here

   }

   public void testCreatePath() throws Exception
   {
      JCRPath path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
      JCRPath parent = path.makeParentPath();
      assertEquals("/jcr:node/node1[2]", parent.getAsString(false));
      assertTrue(path.isDescendantOf(parent, true));
      assertTrue(path.isDescendantOf(parent.makeParentPath(), false));

      assertEquals("/jcr:node/node1[2]/exo:node2", factory.createJCRPath(parent, "exo:node2").getAsString(false));
      assertEquals("/jcr:node/node1[2]/exo:node2/node3", factory.createJCRPath(parent, "exo:node2/node3").getAsString(
         false));

      assertTrue(path.equals(factory.createJCRPath(parent, "exo:node2")));
      QPath qpath = path.getInternalPath();
      assertTrue(path.equals(factory.createJCRPath(qpath)));

      JCRPath sibs = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2[2]");
      assertTrue(path.isSameNameSibling(sibs));

      path = factory.parseAbsPath("/jcr:node/node1[2]/exo:node2");
      assertEquals("/jcr:node", path.makeAncestorPath(2).getAsString(false));
View Full Code Here

      // create ADD node itemState
      NodeData parent = (NodeData)((NodeImpl)this.root).getData();
      QPath ancestorToSave = parent.getQPath();

      JCRPath nodePath = session.getLocationFactory().parseRelPath("testNode");
      InternalQName primaryType = session.getLocationFactory().parseJCRName("nt:unstructured").getInternalName();

      String id = IdGenerator.generate();
      TransientNodeData newNode =
         new TransientNodeData(nodePath.getInternalPath(), id, -1, primaryType, new InternalQName[0], 0,
            ((NodeImpl)root).getInternalIdentifier(), ((NodeImpl)root).getACL());

      ItemState state = new ItemState(newNode, ItemState.ADDED, false, parent.getQPath());
      list.add(state);

      // add property

      // added big file property
      JCRPath propPath = session.getLocationFactory().parseRelPath("bigProp");

      File f = this.createBLOBTempFile(1024);
      TransientPropertyData newProperty =
         new TransientPropertyData(propPath.getInternalPath(), IdGenerator.generate(), -1, PropertyType.BINARY, newNode
            .getIdentifier(), false, new TransientValueData(new FileInputStream(f)));

      list.add(new ItemState(newProperty, ItemState.ADDED, false, parent.getQPath()));

      // crate broken node;
View Full Code Here

   {
      String str = "Inmemory WorkspaceContainer Data: \n";
      Iterator i = items.keySet().iterator();
      while (i.hasNext())
      {
         JCRPath d = (JCRPath)i.next();
         str += d.getInternalPath() + "\n";
      }
      return str;
   }
View Full Code Here

               Calendar cal = JCRDateFormat.parse(value);
               return createValue(cal);
            case PropertyType.PATH :
               try
               {
                  JCRPath path;
                  if (value.startsWith("/"))
                     path = locationFactory.parseAbsPath(value);
                  else
                     path = locationFactory.parseRelPath(value);
                  return createValue(path);
View Full Code Here

    * @throws RepositoryException
    */
   private JCRPathMatcher parsePathMatcher(LocationFactory locFactory, String path) throws RepositoryException
   {

      JCRPath knownPath = null;
      boolean forDescendants = false;
      boolean forAncestors = false;

      if (path.equals("*") || path.equals(".*"))
      {
         // any
         forDescendants = true;
         forAncestors = true;
      }
      else if (path.endsWith("*") && path.startsWith("*"))
      {
         forDescendants = true;
         forAncestors = true;
         knownPath = parsePath(path.substring(1, path.length() - 1), locFactory);
      }
      else if (path.endsWith("*"))
      {
         forDescendants = true;
         knownPath = parsePath(path.substring(0, path.length() - 1), locFactory);
      }
      else if (path.startsWith("*"))
      {
         forAncestors = true;
         knownPath = parsePath(path.substring(1), locFactory);
      }
      else
      {
         knownPath = parsePath(path, locFactory);
      }

      return new JCRPathMatcher(knownPath.getInternalPath(), forDescendants, forAncestors);

   }
View Full Code Here

      version.invalidate();
   }

   protected NodeData getVersionData(String versionName) throws VersionException, RepositoryException
   {
      JCRPath jcrPath = locationFactory.createJCRPath(getLocation(), versionName);

      NodeData version = getData().getVersionData(jcrPath.getName().getInternalName());

      if (version == null)
         throw new VersionException("Version is not found " + jcrPath.getAsString(false));

      return version;
   }
View Full Code Here

   public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException,
      ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException
   {

      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 =
View Full Code Here

               Calendar cal = JCRDateFormat.parse(value);
               return createValue(cal);
            case PropertyType.PATH :
               try
               {
                  JCRPath path;
                  if (value.startsWith("/"))
                     path = locationFactory.parseAbsPath(value);
                  else
                     path = locationFactory.parseRelPath(value);
                  return createValue(path);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.JCRPath$PathElement

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.