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

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


      }
   }

   public void testSearchBinaryContentAnotherSessionQueryManader() throws Exception
   {
      SessionImpl querySession = (SessionImpl)repository.login(credentials, "ws");

      Node rootNode = session.getRootNode();
      Node queryNode = rootNode.addNode("queryNode", "nt:unstructured");

      if (!queryNode.canAddMixin("rma:record"))
         throw new RepositoryException("Cannot add mixin node");
      else
      {
         queryNode.addMixin("rma:record");
         queryNode.setProperty("rma:recordIdentifier", "testIdentificator");
         queryNode.setProperty("rma:originatingOrganization", "testProperty2");
      }

      Node node1 = queryNode.addNode("Test1", "nt:file");
      Node content1 = node1.addNode("jcr:content", "nt:resource");
      content1.setProperty("jcr:lastModified", Calendar.getInstance());
      content1.setProperty("jcr:mimeType", "text/plain");
      content1.setProperty("jcr:data", new ByteArrayInputStream("ABBA AAAA".getBytes()));
      node1.addMixin("rma:record");
      node1.setProperty("rma:recordIdentifier", "testIdentificator");
      node1.setProperty("rma:originatingOrganization", "testProperty2");

      Node node2 = queryNode.addNode("Test2", "nt:file");
      Node content2 = node2.addNode("jcr:content", "nt:resource");
      content2.setProperty("jcr:lastModified", Calendar.getInstance());
      content2.setProperty("jcr:mimeType", "text/plain");
      content2.setProperty("jcr:data", new ByteArrayInputStream("ACDC EEEE".getBytes()));
      node2.addMixin("rma:record");
      node2.setProperty("rma:recordIdentifier", "testIdentificator");
      node2.setProperty("rma:originatingOrganization", "testProperty2");

      session.save();

      String sqlQuery = "SELECT * FROM rma:record WHERE jcr:path LIKE '/queryNode/%' ";
      QueryManager manager = querySession.getWorkspace().getQueryManager();
      Query query = manager.createQuery(sqlQuery, Query.SQL);

      QueryResult queryResult = query.execute();
      NodeIterator iter = queryResult.getNodes();

View Full Code Here


      catch (RepositoryException e)
      {
         fail("Error of 'Multivalued Property' length reading. Error: " + e.getMessage());
      }

      SessionImpl newSession = (SessionImpl)repository.login(credentials, WORKSPACE);
      Node test = (Node)newSession.getItem(testMultivalued.getPath());
      assertEquals("Node '" + TEST_MULTIVALUED + "' must have values length 2", 2, test.getProperty(
         "Multivalued Property").getValues().length);
      test = newSession.getRootNode().getNode(TEST_MULTIVALUED);
      assertEquals("Node '" + TEST_MULTIVALUED + "' must have values length 2", 2, test.getProperty(
         "Multivalued Property").getValues().length);
   }
View Full Code Here

      catch (RepositoryException e)
      {
         fail("Error of 'Multivalued Property' length reading. Error: " + e.getMessage());
      }

      SessionImpl newSession = (SessionImpl)repository.login(credentials, WORKSPACE);
      Node test = (Node)newSession.getItem(testMultivalued.getPath());
      assertEquals("Node '" + TEST_MULTIVALUED + "' must have values length 2", 2, test.getProperty(
         "Multivalued Property").getValues().length);
      test = newSession.getRootNode().getNode(TEST_MULTIVALUED);
      assertEquals("Node '" + TEST_MULTIVALUED + "' must have values length 2", 2, test.getProperty(
         "Multivalued Property").getValues().length);
   }
View Full Code Here

      // mix:versionable
      // we have to be sure that any versionable node somewhere in repository
      // doesn't refers to a VH of the node being deleted.
      for (String wsName : repository.getWorkspaceNames())
      {
         SessionImpl wsSession = repository.getSystemSession(wsName);
         try
         {
            for (PropertyData sref : wsSession.getTransientNodesManager().getReferencesData(vhID, false))
            {
               // Check if this VH isn't referenced from somewhere in workspace
               // or isn't contained in another one as a child history.
               // Ask ALL references incl. properties from version storage.
               if (sref.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
               {
                  if (!sref.getQPath().isDescendantOf(vhnode.getQPath())
                     && (containingHistory != null ? !sref.getQPath().isDescendantOf(containingHistory) : true))
                     // has a reference to the VH in version storage,
                     // it's a REFERENCE property jcr:childVersionHistory of
                     // nt:versionedChild
                     // i.e. this VH is a child history in an another history.
                     // We can't remove this VH now.
                     return;
               }
               else if (!currentWorkspaceName.equals(wsName))
               {
                  // has a reference to the VH in traversed workspace,
                  // it's not a version storage, i.e. it's a property of versionable
                  // node somewhere in ws.
                  // We can't remove this VH now.
                  return;
               } // else -- if we has a references in workspace where the VH is being
               // deleted we can remove VH now.
            }
         }
         finally
         {
            wsSession.logout();
         }
      }

      // remove child versions from VH (if found)
      // ChildVersionRemoveVisitor cvremover = new
View Full Code Here

         {

            PlainChangesLog subLog = logIterator.nextLog();
            String sessionId = subLog.getSessionId();

            SessionImpl userSession = sessionRegistry.getSession(sessionId);

            if (userSession != null)
               for (ItemState itemState : subLog.getAllStates())
               {
                  if (itemState.isEventFire())
                  {

                     ItemData item = itemState.getData();
                     try
                     {
                        int eventType = eventType(itemState);
                        if (eventType != SKIP_EVENT && isTypeMatch(criteria, eventType)
                           && isPathMatch(criteria, item, userSession) && isIdentifierMatch(criteria, item)
                           && isNodeTypeMatch(criteria, item, userSession, subLog)
                           && isSessionMatch(criteria, sessionId))
                        {

                           String path =
                              userSession.getLocationFactory().createJCRPath(item.getQPath()).getAsString(false);

                           events.add(new EventImpl(eventType, path, userSession.getUserID()));
                        }
                     }
                     catch (RepositoryException e)
                     {
                        log.error("Can not fire ActionLauncher.onSaveItems() for " + item.getQPath().getAsString()
View Full Code Here

   /**
    * {@inheritDoc}
    */
   public void onCloseSession(ExtendedSession session)
   {
      SessionImpl sessionImpl = (SessionImpl)session;

      String[] nodeIds = new String[lockedNodes.size()];
      lockedNodes.keySet().toArray(nodeIds);

      for (String nodeId : nodeIds)
      {
         LockData lock = lockedNodes.remove(nodeId);

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

               if (node != null)
               {
                  node.unlock();
View Full Code Here

      index++;

      ManageableRepository repository = repositoryService.getRepository(repositoryName);
      for (String wsName : repository.getWorkspaceNames())
      {
         SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
         try
         {
            Node rootNode = session.getRootNode().addNode("test" + index);
            rootNode.addNode("node1").setProperty("prop1", "value1");
            session.save();
         }
         finally
         {
            session.logout();
         }
      }
   }
View Full Code Here

   protected void checkConent(String repositoryName) throws Exception
   {
      ManageableRepository repository = repositoryService.getRepository(repositoryName);
      for (String wsName : repository.getWorkspaceNames())
      {
         SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
         try
         {
            Node rootNode = session.getRootNode().getNode("test" + index);
            assertEquals(rootNode.getNode("node1").getProperty("prop1").getString(), "value1");
         }
         finally
         {
            session.logout();
         }
      }
   }
View Full Code Here

      index++;

      ManageableRepository repository = repositoryService.getRepository(repositoryName);
      for (String wsName : repository.getWorkspaceNames())
      {
         SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
         try
         {
            Node rootNode = session.getRootNode().addNode("test" + index);

            rootNode.addNode("node1").setProperty("prop1", "value1");
            session.save();
         }
         finally
         {
            session.logout();
         }
      }
   }
View Full Code Here

   protected void checkConent(String repositoryName) throws Exception
   {
      ManageableRepository repository = repositoryService.getRepository(repositoryName);
      for (String wsName : repository.getWorkspaceNames())
      {
         SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
         try
         {
            Node rootNode = session.getRootNode().getNode("test" + index);
            assertEquals(rootNode.getNode("node1").getProperty("prop1").getString(), "value1");
         }
         finally
         {
            session.logout();
         }
      }
   }
View Full Code Here

TOP

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

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.