View Javadoc

1   /*
2    * Copyright 2011 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.fatwire.gst.foundation.controller.action.support;
18  
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  
22  import COM.FutureTense.Interfaces.ICS;
23  import COM.FutureTense.Util.ftErrors;
24  
25  import com.fatwire.gst.foundation.CSRuntimeException;
26  import com.fatwire.gst.foundation.controller.action.Action;
27  import com.fatwire.gst.foundation.controller.action.ActionLocator;
28  
29  /**
30   * ActionLocator that looks at an attribute of a WRA and retrieves the
31   * 'gstaction' attribute, then determines what to do.
32   * 
33   * @author Tony Field
34   * @since Mar 24, 2011
35   */
36  final class AttributeActionLocator implements ActionLocator {
37      protected static final Log LOG = LogFactory.getLog(AttributeActionLocator.class.getPackage().getName());
38      public static final String GST_ACTION_ATTR_NAME = "gstaction";
39      public static final String ACTION_TYPE_SPRING_BEAN_PREFIX = "spring-bean:";
40  
41      public Action getAction(final ICS ics) {
42          final String attribute = getAttribute(ics);
43          final Action action = getAction(ics, attribute);
44          if (action == null) {
45              throw new CSRuntimeException("No action configured for attribute: " + attribute, ftErrors.badparams);
46          }
47          return action;
48  
49      }
50  
51      public Action getAction(final ICS ics, final String name) {
52          final Action result = getAction(name);
53  
54          return result;
55      }
56  
57      private String getAttribute(final ICS ics) {
58          return null; // todo: high: figure out if it's even possible to access
59          // the WRA yet - we haven't resolved the pretty URLs yet
60      }
61  
62      private Action getAction(final String attribute) {
63          return null; // todo: high: implement
64      }
65  }