Package org.apache.commons.chain

Examples of org.apache.commons.chain.Command


         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"));
         cmd.execute(ctx);
      }
      catch (Exception e)
      {
         e.printStackTrace();
         throw new ServletException(e);
View Full Code Here


      // 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
      {
         cmd.execute(ctx);
      }
      catch (Exception e)
      {
         e.printStackTrace();
         throw new ServletException(e);
View Full Code Here

   }

   public void testSetProperty() throws Exception
   {

      Command c = cservice.getCatalog().getCommand("setProperty");
      ctx.put("currentNode", "/test");
      ctx.put("name", "testProperty");
      ctx.put("propertyType", PropertyType.TYPENAME_STRING);
      ctx.put("values", "testValue");
      ctx.put("multiValued", Boolean.FALSE);

      c.execute(ctx);

      Command save = cservice.getCatalog().getCommand("save");
      save.execute(ctx);

   }
View Full Code Here

   }

   public void testGetNodes() throws Exception
   {

      Command c = cservice.getCatalog().getCommand("getNodes");
      ctx.put("currentNode", "/");
      c.execute(ctx);

      assertTrue(ctx.get("result") instanceof NodeIterator);
      NodeIterator nodes = (NodeIterator)ctx.get("result");

      // System.out.println("> getNodes >> "+nodes.getSize());
View Full Code Here

   }

   public void testAddResourceFile() throws Exception
   {

      Command c = cservice.getCatalog().getCommand("addResourceFile");
      ctx.put("currentNode", "/");
      ctx.put("path", "resource");
      ctx.put("data", "Node data");
      ctx.put("mimeType", "text/html");

      c.execute(ctx);

      Command save = cservice.getCatalog().getCommand("save");
      ctx.put("path", "/");
      save.execute(ctx);

   }
View Full Code Here

   }

   public void testGetNodeChain() throws Exception
   {
      Command cmd = cservice.getCatalog().getCommand("retrieveNodeCommand");
      ctx.put("currentNode", "/");
      ctx.put("path", "test");
      cmd.execute(ctx);
   }
View Full Code Here

            if (exceptionCommand == null) {
                log.error("No exceptionCommand property specified");
                throw new IllegalStateException
                    ("No exceptionCommand property specfied");
            }
            Command command = catalog.getCommand(exceptionCommand);
            if (command == null) {
                log.error("Cannot find exceptionCommand '" +
                          exceptionCommand + "'");
                throw new IllegalStateException
                    ("Cannot find exceptionCommand '" +
                     exceptionCommand + "'");
            }
            if (log.isTraceEnabled()) {
                log.trace("Calling exceptionCommand '" + exceptionCommand
                          + "'");
            }
            command.execute(context);
        } catch (Exception e) {
            log.warn("Exception from exceptionCommand '" +
                     exceptionCommand + "'", e);
            throw new IllegalStateException("Exception chain threw exception");
        }
View Full Code Here

        context.put("mapping", mapping);
        context.put("form", form);

        // Delegate to the specified command
        String name = mapping.getParameter();
        Command command = getCatalog().getCommand(request.getParameter(name));
        command.execute(context); // Ignore return state

        // Return results as appropriate
        Exception exception = null;
        try {
            exception = (Exception) context.get("exception");
View Full Code Here

            (getServlet().getServletContext(), request, response);
        context.put("mapping", mapping);
        context.put("form", form);

        // Delegate to the specified command
        Command command = getCatalog().getCommand(mapping.getParameter());
        command.execute(context); // Ignore return state

        // Return results as appropriate
        Exception exception = null;
        try {
            exception = (Exception) context.get("exception");
View Full Code Here

   * @throws Exception
   *             on any error
   */
  public boolean execute(ActionContext actionCtx) throws Exception {
    if (shouldProcess(actionCtx)) {
      Command command = getCommand(actionCtx);

      if (command != null) {
        return (command.execute(actionCtx));
      }
    }

    return (false);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.chain.Command

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.