Package org.exoplatform.services.command.impl

Examples of org.exoplatform.services.command.impl.CommandService


      SessionProviderService sessionProviderService =
         (SessionProviderService)container.getComponentInstanceOfType(SessionProviderService.class);

      RepositoryService repositoryService =
         (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      GenericWebAppContext ctx;
      try
      {
         ctx =
            new GenericWebAppContext(getServletContext(), request, response, sessionProviderService
               .getSessionProvider(null), // null for
               // ThreadLocalSessionProvider
               repositoryService.getDefaultRepository());
      }
      catch (final RepositoryException e)
      {
         throw new IOException()
         {
            @Override
            public Throwable getCause()
            {
               return e;
            }
         };
      }
      catch (final RepositoryConfigurationException e)
      {
         throw new IOException()
         {
            @Override
            public Throwable getCause()
            {
               return e;
            }
         };
      }

      String catalogName = (String)ctx.get(WebConstants.CATALOG_NAME);

      String wsName = (String)ctx.get("workspace");
      if (wsName != null)
         ctx.setCurrentWorkspace(wsName);

      String currentPath = (String)ctx.get("path");

      if (currentPath == null)
         throw new ServletException("Path undefined " + request.getParameter("path") + " Request: "
            + request.getRequestURI());

      try
      {
         Command cmd;
         if (catalogName == null)
            cmd = commandService.getCatalog().getCommand("displayResource");
         else
            cmd = commandService.getCatalog(catalogName).getCommand("displayResource");

         if (cmd == null)
            throw new Exception("No 'displayResource' command found");
         ctx.put("path", currentPath);
         ctx.put("cache-control-max-age", getServletConfig().getInitParameter("cache-control-max-age"));
View Full Code Here


               return e;
            }
         };
      }

      CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      String catalogName = (String)ctx.get(WebConstants.CATALOG_NAME);

      // command from context
      String commandName = (String)ctx.get("Command");
      if (commandName == null)
         throw new ServletException("No Command found at the Context");
      Command cmd;
      if (catalogName == null)
         cmd = commandService.getCatalog().getCommand(commandName);
      else
         cmd = commandService.getCatalog(catalogName).getCommand(commandName);

      if (cmd == null)
         throw new ServletException("No Command found " + commandName);
      try
      {
View Full Code Here

               return e;
            }
         };
      }

      CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      String catalogName = (String)ctx.get(WebConstants.CATALOG_NAME);

      // command from context
      String commandName = (String)ctx.get("Command");
      if (commandName == null)
         throw new ServletException("No Command found at the Context");
      Command cmd;
      if (catalogName == null)
         cmd = commandService.getCatalog().getCommand(commandName);
      else
         cmd = commandService.getCatalog(catalogName).getCommand(commandName);

      if (cmd == null)
         throw new ServletException("No Command found " + commandName);
      try
      {
View Full Code Here

   }

   public void testPluginConf() throws Exception
   {

      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      assertNotNull(cservice);

      // preconfigured commands
      assertTrue(cservice.getCatalog().getNames().hasNext());
      assertNotNull(cservice.getCatalog().getNames().next());

   }
View Full Code Here

   }

   public void testStringConf() throws Exception
   {
      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      Catalog c = cservice.getCatalog();

      assertNull(c.getCommand("StrCommand"));
      cservice.putCatalog(new ByteArrayInputStream(IS.getBytes()));
      Catalog c1 = cservice.getCatalog();
      assertNotNull(c1.getCommand("StrCommand"));

   }
View Full Code Here

   }

   public void testInitWithFile() throws Exception
   {
      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      cservice.putCatalog(getClass().getResourceAsStream("/conf/test-commands3.xml"));
      assertTrue(cservice.getCatalogNames().hasNext());
      Catalog c1 = cservice.getCatalog("catalog1");
      assertNotNull(c1.getCommand("Command2"));

   }
View Full Code Here

   }

   public void testExcecute() throws Exception
   {

      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      Command c1 = cservice.getCatalog().getCommand("Execute2");
      Command c2 = cservice.getCatalog().getCommand("Command1");

      Catalog c = cservice.getCatalog();

      Context ctx = new ContextBase();
      ctx.put("test", Integer.valueOf(0));
      c1.execute(ctx);
      c2.execute(ctx);
View Full Code Here

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

      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      assertNotNull(cservice);

      assertTrue(cservice.getCatalogNames().hasNext());

      Iterator commands = cservice.getCatalog().getNames();
      int cnt = 0;
      while (commands.hasNext())
      {
         commands.next();
         cnt++;
      }

      assertEquals(NUMBER_OF_COMMANDS_IN_DEF, cnt);

      commands = cservice.getCatalog("catalog1").getNames();
      cnt = 0;
      while (commands.hasNext())
      {
         commands.next();
         cnt++;
View Full Code Here

   }

   public void testIfPutCatalogDoesNotRemoveCommands() throws Exception
   {

      CommandService cservice = (CommandService)container.getComponentInstanceOfType(CommandService.class);
      assertNotNull(cservice);

      assertTrue(cservice.getCatalogNames().hasNext());
      Iterator commands = cservice.getCatalog().getNames();
      int cnt = 0;
      while (commands.hasNext())
      {
         commands.next();
         cnt++;
      }

      ByteArrayInputStream is = new ByteArrayInputStream(IS.getBytes());

      cservice.putCatalog(is);

      assertTrue(cservice.getCatalogNames().hasNext());
      commands = cservice.getCatalog().getNames();
      cnt = 0;
      while (commands.hasNext())
      {
         commands.next();
         cnt++;
      }

      commands = cservice.getCatalog("fromput").getNames();
      cnt = 0;
      while (commands.hasNext())
      {
         commands.next();
         cnt++;
View Full Code Here

      SessionProviderService sessionProviderService =
         (SessionProviderService)container.getComponentInstanceOfType(SessionProviderService.class);

      RepositoryService repositoryService =
         (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
      CommandService commandService = (CommandService)container.getComponentInstanceOfType(CommandService.class);

      GenericWebAppContext ctx;
      try
      {
         ctx =
            new GenericWebAppContext(getServletContext(), request, response, sessionProviderService
               .getSessionProvider(null), // null for
               // ThreadLocalSessionProvider
               repositoryService.getDefaultRepository());
      }
      catch (final RepositoryException e)
      {
         throw new IOException()
         {
            @Override
            public Throwable getCause()
            {
               return e;
            }
         };
      }
      catch (final RepositoryConfigurationException e)
      {
         throw new IOException()
         {
            @Override
            public Throwable getCause()
            {
               return e;
            }
         };
      }

      String catalogName = (String)ctx.get(WebConstants.CATALOG_NAME);

      String wsName = (String)ctx.get("workspace");
      if (wsName != null)
         ctx.setCurrentWorkspace(wsName);

      String currentPath = (String)ctx.get("path");

      if (currentPath == null)
         throw new ServletException("Path undefined " + request.getParameter("path") + " Request: "
            + request.getRequestURI());

      try
      {
         Command cmd;
         if (catalogName == null)
            cmd = commandService.getCatalog().getCommand("displayResource");
         else
            cmd = commandService.getCatalog(catalogName).getCommand("displayResource");

         if (cmd == null)
            throw new Exception("No 'displayResource' command found");
         ctx.put("path", currentPath);
         ctx.put("cache-control-max-age", getServletConfig().getInitParameter("cache-control-max-age"));
View Full Code Here

TOP

Related Classes of org.exoplatform.services.command.impl.CommandService

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.