Package org.exoplatform.services.jcr.impl.ext.action

Examples of org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog


   }

   public void testMatchWorkspace() throws Exception
   {
      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      //
      SessionEventMatcher matcher =
         new SessionEventMatcher(Event.NODE_ADDED, null, true, new String[]{"production"}, null, ntHolder);
      catalog.addAction(matcher, new DummyAction());
      Condition cond = new Condition();
      cond.put(SessionEventMatcher.EVENTTYPE_KEY, Event.NODE_ADDED);

      // test for this ws
      cond.put(SessionEventMatcher.WORKSPACE_KEY, "production");
      assertEquals(1, catalog.getActions(cond).size());

      cond.put(SessionEventMatcher.WORKSPACE_KEY, "draft");
      assertEquals(0, catalog.getActions(cond).size());

   }
View Full Code Here


      op.setObject(actions);
      op.setName("actions");
      params.addParameter(op);
      AddActionsPlugin aap = new AddActionsPlugin(params);

      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      catalog.addPlugin(aap);
      assertEquals(1, aap.getActions().size());
      assertEquals(1, catalog.getAllActions().size());
      ActionConfiguration ac1 = aap.getActions().get(0);
      assertEquals("org.exoplatform.services.jcr.usecases.action.DummyAction", ac1.getActionClassName());
      assertEquals("/test,/exo:test1", ac1.getPath());

      Condition cond = new Condition();
      cond.put(SessionEventMatcher.EVENTTYPE_KEY, Event.NODE_ADDED);

      assertEquals(1, catalog.getActions(cond).size());
   }
View Full Code Here

   }

   public void testReadAction() throws ItemExistsException, PathNotFoundException, VersionException,
      ConstraintViolationException, LockException, RepositoryException
   {
      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      // test by path

      Node testNode = root.addNode("testNode");
      PropertyImpl prop = (PropertyImpl)testNode.setProperty("test", "test");
      root.save();

      SessionEventMatcher matcher =
         new SessionEventMatcher(ExtendedEvent.READ, new QPath[]{prop.getData().getQPath()}, true, null,
            new InternalQName[]{Constants.NT_UNSTRUCTURED}, ntHolder);
      DummyAction dAction = new DummyAction();

      catalog.addAction(matcher, dAction);

      assertEquals(0, dAction.getActionExecuterCount());
      String val = testNode.getProperty("test").getValue().getString();
      assertEquals(1, dAction.getActionExecuterCount());
View Full Code Here

   }

   public void testAddMixinAction() throws Exception
   {
      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      // test by path
      SessionEventMatcher matcher =
         new SessionEventMatcher(ExtendedEvent.ADD_MIXIN, null, true, null, new InternalQName[]{
            Constants.MIX_REFERENCEABLE, Constants.EXO_OWNEABLE}, ntHolder);
      DummyAction dAction = new DummyAction();
      catalog.addAction(matcher, dAction);

      assertEquals(0, dAction.getActionExecuterCount());
      Node tnode = root.addNode("testnode");
      assertEquals(0, dAction.getActionExecuterCount());
      tnode.addMixin("exo:owneable");
View Full Code Here

      assertEquals(2, dAction.getActionExecuterCount());
   }

   public void testRemoveMixinAction() throws Exception
   {
      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      // test by path
      SessionEventMatcher matcher =
         new SessionEventMatcher(ExtendedEvent.REMOVE_MIXIN, null, true, null,
            new InternalQName[]{Constants.EXO_OWNEABLE}, ntHolder);
      DummyAction dAction = new DummyAction();
      catalog.addAction(matcher, dAction);

      assertEquals(0, dAction.getActionExecuterCount());
      Node tnode = root.addNode("testnode");
      tnode.addMixin("exo:owneable");
      assertEquals(0, dAction.getActionExecuterCount());
View Full Code Here

      assertEquals(1, dAction.getActionExecuterCount());
   }

   public void testMoveAction() throws  RepositoryException
   {
      SessionActionCatalog catalog =container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      Node n1 = root.addNode("n1");
      Node n2 = n1.addNode("n2");
      Node n3 = root.addNode("n3");
      Node n4 = root.addNode("n4");
      Node n5 = root.addNode("n5");
      root.save();

      SessionEventMatcher matcher =
                new SessionEventMatcher(ExtendedEvent.NODE_MOVED, new QPath[]{((NodeImpl)root).getInternalPath()}, true, null,
                        new InternalQName[]{Constants.NT_UNSTRUCTURED}, ntHolder);
      DummyAction dAction = new DummyAction();
      catalog.addAction(matcher, dAction);

      assertEquals(0, dAction.getActionExecuterCount());
      session.move(n4.getPath(), n2.getPath());
      session.save();
      assertEquals(1, dAction.getActionExecuterCount());
      assertEquals("/n4", ((NodeImpl)dAction.getInfo().get(InvocationContext.PREVIOUS_ITEM)).getPath());
      assertEquals("/n1/n2[2]", ((NodeImpl)dAction.getInfo().get(InvocationContext.CURRENT_ITEM)).getPath());


      Condition cond = new Condition();
      cond.put(SessionEventMatcher.EVENTTYPE_KEY, ExtendedEvent.NODE_MOVED);
      assertEquals(1, catalog.getActions(cond).size());

      session.move(n1.getPath(), n3.getPath() + "/n6");
      session.save();
      assertEquals(2, dAction.getActionExecuterCount());
      assertEquals("/n1", ((NodeImpl)dAction.getInfo().get(InvocationContext.PREVIOUS_ITEM)).getPath());
View Full Code Here

      assertEquals("/n3/n7[2]", ((NodeImpl) dAction.getInfo().get(InvocationContext.CURRENT_ITEM)).getPath());
   }

   public void testOrderAction() throws  RepositoryException
   {
      SessionActionCatalog catalog =container.getComponentInstanceOfType(SessionActionCatalog.class);
      catalog.clear();

      root.addNode("n1");
      root.addNode("n2");
      root.addNode("n2");
      root.addNode("n3");
      session.save();

      SessionEventMatcher matcher =
               new SessionEventMatcher(ExtendedEvent.NODE_MOVED, new QPath[]{((NodeImpl) root).getInternalPath()}, true, null,
                       new InternalQName[]{Constants.NT_UNSTRUCTURED}, ntHolder);
      DummyAction dAction = new DummyAction();
      catalog.addAction(matcher, dAction);

      root.orderBefore("n2[2]", "n2");
      session.save();
      assertEquals(1, dAction.getActionExecuterCount());
      assertEquals("/n2[2]", ((NodeImpl)dAction.getInfo().get(InvocationContext.PREVIOUS_ITEM)).getPath());
View Full Code Here

      this.lifecycleListeners = new ArrayList<SessionLifecycleListener>();
      this.registerLifecycleListener((ObservationManagerImpl)observationManager);
      this.registerLifecycleListener(lockManager);

      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      actionHandler = new SessionActionInterceptor(catalog, container, workspaceName);

      sessionRegistry = (SessionRegistry)container.getComponentInstanceOfType(SessionRegistry.class);
View Full Code Here

      this.lifecycleListeners = new ArrayList<SessionLifecycleListener>();
      this.registerLifecycleListener((ObservationManagerImpl)observationManager);
      this.registerLifecycleListener(lockManager);

      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      actionHandler = new SessionActionInterceptor(catalog, container);

      sessionRegistry = (SessionRegistry)container.getComponentInstanceOfType(SessionRegistry.class);
View Full Code Here

      this.lifecycleListeners = new ArrayList<SessionLifecycleListener>();
      this.registerLifecycleListener((ObservationManagerImpl)observationManager);
      this.registerLifecycleListener(lockManager);

      SessionActionCatalog catalog =
         (SessionActionCatalog)container.getComponentInstanceOfType(SessionActionCatalog.class);
      actionHandler = new SessionActionInterceptor(catalog, container, workspaceName);

      sessionRegistry = (SessionRegistry)container.getComponentInstanceOfType(SessionRegistry.class);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog

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.