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

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


{

   public void testTwoRestores() throws Exception
   {
      {
         SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws1");

         sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured").setProperty("data", "data_1");
         sessionWS1.save();

         // 1-st export
         File f1 = new File("target/1.xml");
         sessionWS1.exportWorkspaceSystemView(new FileOutputStream(f1), false, false);

         // 1-st import
         WorkspaceEntry ws1_restore_1 =
            makeWorkspaceEntry("ws1_restore_1", isMultiDB(session) ? "jdbcjcr2export1" : "jdbcjcr", f1);
         repository.configWorkspace(ws1_restore_1);
         repository.createWorkspace(ws1_restore_1.getName());

         // check
         SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
         assertNotNull(back1.getRootNode().getNode("asdasdasda").getProperty("data"));

         // add date to restored workspace
         back1.getRootNode().addNode("gdfgrghfhf", "nt:unstructured").setProperty("data", "data_2");
         back1.save();
      }

      {
         // 2-st export
         SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
         File f2 = new File("target/2.xml");
         back1.exportWorkspaceSystemView(new FileOutputStream(f2), false, false);

         // 2-st import
         WorkspaceEntry ws1_restore_2 =
            makeWorkspaceEntry("ws1_restore_2", isMultiDB(session) ? "jdbcjcr2export2" : "jdbcjcr", f2);
         repository.configWorkspace(ws1_restore_2);
         repository.createWorkspace(ws1_restore_2.getName());

         // check
         SessionImpl back2 = (SessionImpl)repository.login(credentials, "ws1_restore_2");
         assertNotNull(back2.getRootNode().getNode("gdfgrghfhf").getProperty("data"));
      }
   }
View Full Code Here


      testRoot.removePermission(IdentityConstants.ANY);
      accessTestRoot.save();

      AccessManager accessManager = ((SessionImpl)accessTestRoot.getSession()).getAccessManager();

      SessionImpl session1 = (SessionImpl)repository.login(new CredentialsImpl("john", "exo".toCharArray()));

      assertTrue(accessManager.hasPermission(testRoot.getACL(), new String[]{PermissionType.READ,
         PermissionType.ADD_NODE}, session1.getUserState().getIdentity()));

      assertTrue(accessManager.hasPermission(testRoot.getACL(), new String[]{PermissionType.READ,
         PermissionType.SET_PROPERTY}, session1.getUserState().getIdentity()));

      assertTrue(accessManager.hasPermission(testRoot.getACL(), new String[]{PermissionType.ADD_NODE,
         PermissionType.SET_PROPERTY}, session1.getUserState().getIdentity()));

      assertFalse(accessManager.hasPermission(testRoot.getACL(), new String[]{PermissionType.READ,
         PermissionType.REMOVE}, session1.getUserState().getIdentity()));
   }
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

      catch (UnsupportedRepositoryOperationException e)
      {
         fail("Node isn't a referenceable, but must. Access from Session.geItem()");
      }

      SessionImpl anotherSession = (SessionImpl)repository.login(this.credentials);
      NodeImpl anotherRoot = (NodeImpl)anotherSession.getRootNode();

      try
      {
         NodeImpl aNode = (NodeImpl)anotherRoot.getNode(TEST_NODE_NAME);
         assertEquals("UUIDs must equals", uuid, aNode.getUUID());
      }
      catch (UnsupportedRepositoryOperationException e)
      {
         fail("Node isn't a referenceable, but must");
      }

      try
      {
         NodeImpl aNode = (NodeImpl)anotherSession.getItem("/" + TEST_NODE_NAME);
         assertEquals("UUIDs must equals. Access from Session.geItem()", uuid, aNode.getUUID());
      }
      catch (UnsupportedRepositoryOperationException e)
      {
         fail("Node isn't a referenceable, but must. Access from Session.geItem()");
View Full Code Here

      catch (UnsupportedRepositoryOperationException e)
      {
         // ok
      }

      SessionImpl anotherSession = (SessionImpl)repository.login(this.credentials /*
                                                                                                   * session.getCredentials
                                                                                                   * ()
                                                                                                   */);
      NodeImpl anotherRoot = (NodeImpl)anotherSession.getRootNode();

      NodeImpl aNode = (NodeImpl)anotherRoot.getNode(TEST_NODE_NAME);
      try
      {
         aNode.getUUID();
         fail("Node must be not referenceable, but it such.");
      }
      catch (UnsupportedRepositoryOperationException e)
      {
         // ok
      }

      aNode = (NodeImpl)anotherSession.getItem("/" + TEST_NODE_NAME);
      try
      {
         aNode.getUUID();
         fail("Node must be not referenceable, but it such. Access from Session.geItem().");
      }
View Full Code Here

      this.testNode.lock(true, false);

      checkMixins(mixins, (NodeImpl)session.getRootNode().getNode(TEST_NODE_NAME));
      checkMixins(mixins, (NodeImpl)session.getItem("/" + TEST_NODE_NAME));

      SessionImpl anotherSession = (SessionImpl)repository.login(this.credentials /*
                                                                                                   * session.getCredentials
                                                                                                   * ()
                                                                                                   */);

      checkMixins(mixins, (NodeImpl)anotherSession.getRootNode().getNode(TEST_NODE_NAME));
      checkMixins(mixins, (NodeImpl)anotherSession.getItem("/" + TEST_NODE_NAME));
   }
View Full Code Here

      this.session.save();

      checkMixins(finalMixins, (NodeImpl)session.getRootNode().getNode(TEST_NODE_NAME));
      checkMixins(finalMixins, (NodeImpl)session.getItem("/" + TEST_NODE_NAME));

      SessionImpl anotherSession = (SessionImpl)repository.login(this.credentials /*
                                                                                                   * session.getCredentials
                                                                                                   * ()
                                                                                                   */);

      checkMixins(finalMixins, (NodeImpl)anotherSession.getRootNode().getNode(TEST_NODE_NAME));
      checkMixins(finalMixins, (NodeImpl)anotherSession.getItem("/" + TEST_NODE_NAME));
   }
View Full Code Here

   @Override
   protected void tearDown() throws Exception
   {
      try
      {
         SessionImpl session1 = (SessionImpl)repository.login(credentials, "ws");
         session1.getRootNode().getNode("my").remove();
         session1.save();
         session1.logout();

         SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws2");
         session2.getRootNode().getNode("my").remove();
         session2.save();
         session2.logout();
      }
      catch (Throwable e)
      {
         log.error("tearDown error " + e, e);
      }
View Full Code Here

   {

      try
      {
         // delete and add /my/path/node in ws
         SessionImpl session1 = (SessionImpl)repository.login(credentials, "ws");
         session1.getRootNode().getNode("my/path/node").remove();
         session1.save();
         // add...
         session1.getRootNode().addNode("my");
         session1.save();
         session1.getRootNode().getNode("my").addNode("path");
         session1.save();
         session1.getRootNode().getNode("my").getNode("path").addNode("node");
         session1.save();
         session1.logout();

         // clone on 2nd ws
         Session session2 = (SessionImpl)repository.login(credentials, "ws2");
         Workspace workspace1 = session2.getWorkspace();
         workspace1.clone("ws", "/my/path/node", "/my/path/node", true);
View Full Code Here

         @Override
         public void run()
         {

            SessionImpl userSession;
            try
            {
               userSession = (SessionImpl)frepository.login(fcredentials, "ws");
               chlog[0] = new SessionChangesLogInfo(new SessionChangesLog(userSession), userSession.getId());
            }
            catch (RepositoryException e)
            {
               throw new RuntimeException("testSessionLinkGCedSession(), " + e, e);
            }
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.