View Javadoc

1   package org.objectledge.modules.actions.logging;
2   
3   import org.apache.log4j.LogManager;
4   import org.apache.log4j.Logger;
5   import org.objectledge.context.Context;
6   import org.objectledge.parameters.RequestParameters;
7   import org.objectledge.pipeline.ProcessingException;
8   import org.objectledge.web.mvc.builders.PolicyProtectedAction;
9   import org.objectledge.web.mvc.security.PolicySystem;
10  
11  /***
12   * Creates a Log4j logger with the specified name.
13   *
14   * @author <a href="mailto:rafal@caltha.pl">RafaƂ Krzewski</a>
15   */
16  public class CreateLogger
17      extends PolicyProtectedAction
18  {
19      /***
20       * Creates a new CreateLogger action instance.
21       * 
22       * @param policySystemArg the PolicySystem component.
23       */
24      public CreateLogger(PolicySystem policySystemArg)
25      {
26          super(policySystemArg);
27      }
28  
29      /***
30       * {@inheritDoc}
31       */
32      public void process(Context context)
33          throws ProcessingException
34      {
35          RequestParameters requestParameters = RequestParameters.getRequestParameters(context);
36          String id = requestParameters.get("id");
37          Logger logger;
38          if(id.equals("root") || LogManager.exists(id) != null)
39          {
40              throw new ProcessingException("logger "+id+" already exists");
41          }
42          LogManager.getLogger(id);
43      }
44  }