View Javadoc
1   /*
2    * Copyright 2010 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  package com.fatwire.gst.foundation.controller;
17  
18  import COM.FutureTense.Interfaces.FTVAL;
19  import COM.FutureTense.Interfaces.FTValList;
20  import COM.FutureTense.Interfaces.IPS;
21  import COM.FutureTense.XML.Template.Seed2;
22  
23  /**
24   * <p>
25   * This is the controller (dispatcher) that dispatches the request to the
26   * correct asset/template combination based on the path field for a Web
27   * Referenceable Asset.
28   * </p>
29   * <p/>
30   * This controller should be called from an outer XML element via the
31   * <tt>CALLJAVA</tt> tag:
32   * <code>&lt;CALLJAVA CLASS="com.fatwire.gst.foundation.controller.BaseController" /&gt;
33   * </code>
34   * 
35   * @author Tony Field
36   * @author Dolf Dijkstra
37   * @since Jun 10, 2010
38   */
39  public class BaseController implements Seed2 {
40  
41      private RenderPageAdapter delegate;
42      private FTValList vIn;
43  
44      /* (non-Javadoc)
45       * @see COM.FutureTense.XML.Template.Seed2#SetAppLogic(COM.FutureTense.Interfaces.IPS)
46       */
47      @Override
48      public void SetAppLogic(IPS ips) {
49          delegate = new RenderPageAdapter(ips.GetICSObject());
50      }
51  
52      /*
53       * (non-Javadoc)
54       * 
55       * @see
56       * COM.FutureTense.XML.Template.Seed#Execute(COM.FutureTense.Interfaces.
57       * FTValList, COM.FutureTense.Interfaces.FTValList)
58       */
59  
60      public final String Execute(final FTValList vIn, final FTValList vOut) {
61          this.vIn = vIn;
62          try {
63              doExecute();
64          } catch (final Exception e) {
65              handleException(e);
66          }
67  
68          return "";
69      }
70  
71      protected final FTVAL getInputArgument(String name) {
72          return vIn == null ? null : vIn.getVal(name);
73      }
74  
75      protected final String getInputArgumentAsString(String name) {
76          return vIn == null ? null : vIn.getValString(name);
77      }
78  
79  
80      protected void doExecute() {
81          delegate.doExecute();
82      }
83  
84      protected void handleException(final Exception e) {
85          delegate.handleException(e);
86      }
87  
88  }