| 1 | <!--- |
|---|
| 2 | Fusebox Software License |
|---|
| 3 | Version 1.0 |
|---|
| 4 | |
|---|
| 5 | Copyright (c) 2003, 2004, 2005, 2006 The Fusebox Corporation. All rights reserved. |
|---|
| 6 | |
|---|
| 7 | Redistribution and use in source and binary forms, with or without modification, are permitted |
|---|
| 8 | provided that the following conditions are met: |
|---|
| 9 | |
|---|
| 10 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions |
|---|
| 11 | and the following disclaimer. |
|---|
| 12 | |
|---|
| 13 | 2. Redistributions in binary form or otherwise encrypted form must reproduce the above copyright |
|---|
| 14 | notice, this list of conditions and the following disclaimer in the documentation and/or other |
|---|
| 15 | materials provided with the distribution. |
|---|
| 16 | |
|---|
| 17 | 3. The end-user documentation included with the redistribution, if any, must include the following |
|---|
| 18 | acknowledgment: |
|---|
| 19 | |
|---|
| 20 | "This product includes software developed by the Fusebox Corporation (http://www.fusebox.org/)." |
|---|
| 21 | |
|---|
| 22 | Alternately, this acknowledgment may appear in the software itself, if and wherever such |
|---|
| 23 | third-party acknowledgments normally appear. |
|---|
| 24 | |
|---|
| 25 | 4. The names "Fusebox" and "Fusebox Corporation" must not be used to endorse or promote products |
|---|
| 26 | derived from this software without prior written (non-electronic) permission. For written |
|---|
| 27 | permission, please contact fusebox@fusebox.org. |
|---|
| 28 | |
|---|
| 29 | 5. Products derived from this software may not be called "Fusebox", nor may "Fusebox" appear in |
|---|
| 30 | their name, without prior written (non-electronic) permission of the Fusebox Corporation. For |
|---|
| 31 | written permission, please contact fusebox@fusebox.org. |
|---|
| 32 | |
|---|
| 33 | If one or more of the above conditions are violated, then this license is immediately revoked and |
|---|
| 34 | can be re-instated only upon prior written authorization of the Fusebox Corporation. |
|---|
| 35 | |
|---|
| 36 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 37 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|---|
| 38 | DISCLAIMED. IN NO EVENT SHALL THE FUSEBOX CORPORATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
|---|
| 39 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 40 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|---|
| 41 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
|---|
| 42 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 43 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 44 | |
|---|
| 45 | ------------------------------------------------------------------------------- |
|---|
| 46 | |
|---|
| 47 | This software consists of voluntary contributions made by many individuals on behalf of the |
|---|
| 48 | Fusebox Corporation. For more information on Fusebox, please see <http://www.fusebox.org/>. |
|---|
| 49 | |
|---|
| 50 | ---> |
|---|
| 51 | <cfcomponent output="false" |
|---|
| 52 | hint="I represent a fuseaction within a circuit."> |
|---|
| 53 | |
|---|
| 54 | <cffunction name="init" returntype="any" access="public" output="false" |
|---|
| 55 | hint="I am the constructor."> |
|---|
| 56 | <cfargument name="circuit" type="any" required="false" |
|---|
| 57 | hint="I am the circuit to which this fuseaction belongs. I am required but it's faster to specify that I am not required." /> |
|---|
| 58 | <cfargument name="name" type="any" required="false" |
|---|
| 59 | hint="I am the name of the fuseaction. I am required but it's faster to specify that I am not required." /> |
|---|
| 60 | <cfargument name="access" type="any" required="false" |
|---|
| 61 | hint="I am the access criteria for the fuseaction. I am required but it's faster to specify that I am not required." /> |
|---|
| 62 | <cfargument name="children" type="any" required="false" |
|---|
| 63 | hint="I am the verbs for this fuseaction. I am required but it's faster to specify that I am not required." /> |
|---|
| 64 | <cfargument name="global" type="any" default="false" |
|---|
| 65 | hint="I indicate whether or not this is a globalfuseaction in fusebox.xml." /> |
|---|
| 66 | <cfargument name="customAttribs" type="any" default="#structNew()#" |
|---|
| 67 | hint="I hold the custom (namespace-qualified) attributes in the fuseaction tag." /> |
|---|
| 68 | |
|---|
| 69 | <cfset var i = 0 /> |
|---|
| 70 | <cfset var verb = "" /> |
|---|
| 71 | <cfset var factory = arguments.circuit.getApplication().getFuseactionFactory() /> |
|---|
| 72 | |
|---|
| 73 | <cfset variables.circuit = arguments.circuit /> |
|---|
| 74 | <cfset variables.name = arguments.name /> |
|---|
| 75 | <cfset variables.customAttributes = arguments.customAttribs /> |
|---|
| 76 | <cfset variables.nChildren = arrayLen(arguments.children) /> |
|---|
| 77 | <cfset variables.actions = structNew() /> |
|---|
| 78 | |
|---|
| 79 | <cfset this.access = arguments.access /> |
|---|
| 80 | |
|---|
| 81 | <cfloop from="1" to="#variables.nChildren#" index="i"> |
|---|
| 82 | <cfset variables.actions[i] = factory.create(arguments.children[i].xmlName, |
|---|
| 83 | this,arguments.children[i].xmlAttributes,arguments.children[i].xmlChildren, |
|---|
| 84 | arguments.global) /> |
|---|
| 85 | </cfloop> |
|---|
| 86 | |
|---|
| 87 | <cfreturn this /> |
|---|
| 88 | |
|---|
| 89 | </cffunction> |
|---|
| 90 | |
|---|
| 91 | <cffunction name="compile" returntype="void" access="public" output="false" |
|---|
| 92 | hint="I compile this fuseaction."> |
|---|
| 93 | <cfargument name="writer" type="any" required="false" |
|---|
| 94 | hint="I am the writer object to which the compiled code should be written. I am required but it's faster to specify that I am not required." /> |
|---|
| 95 | |
|---|
| 96 | <cfset var i = 0 /> |
|---|
| 97 | <cfset var n = 0 /> |
|---|
| 98 | |
|---|
| 99 | <cfloop from="1" to="#variables.nChildren#" index="i"> |
|---|
| 100 | <cfset variables.actions[i].compile(arguments.writer) /> |
|---|
| 101 | </cfloop> |
|---|
| 102 | |
|---|
| 103 | </cffunction> |
|---|
| 104 | |
|---|
| 105 | <cffunction name="getName" returntype="string" access="public" output="false" |
|---|
| 106 | hint="I return the name of the fuseaction."> |
|---|
| 107 | |
|---|
| 108 | <cfreturn variables.name /> |
|---|
| 109 | |
|---|
| 110 | </cffunction> |
|---|
| 111 | |
|---|
| 112 | <cffunction name="getCircuit" returntype="any" access="public" output="false" |
|---|
| 113 | hint="I return the enclosing circuit object."> |
|---|
| 114 | |
|---|
| 115 | <cfreturn variables.circuit /> |
|---|
| 116 | |
|---|
| 117 | </cffunction> |
|---|
| 118 | |
|---|
| 119 | <cffunction name="getAccess" returntype="string" access="public" output="false" |
|---|
| 120 | hint="I am a convenience method to return this fuseaction's access attribute value."> |
|---|
| 121 | |
|---|
| 122 | <cfreturn this.access /> |
|---|
| 123 | |
|---|
| 124 | </cffunction> |
|---|
| 125 | |
|---|
| 126 | <cffunction name="getPermissions" returntype="string" access="public" output="false" |
|---|
| 127 | hint="I return the aggregated permissions for this fuseaction."> |
|---|
| 128 | <cfargument name="inheritFromCircuit" type="boolean" default="true" |
|---|
| 129 | hint="I indicate whether or not the circuit's permissions should be returned if this fuseaction has no permissions specified." /> |
|---|
| 130 | <cfargument name="useCircuitTrace" type="boolean" default="false" |
|---|
| 131 | hint="I indicate whether or not to inherit the parent circuit's permissions if this fuseaction's circuit has no permissions specified." /> |
|---|
| 132 | |
|---|
| 133 | <cfif this.permissions is "" and arguments.inheritFromCircuit> |
|---|
| 134 | <cfreturn getCircuit().getPermissions(arguments.useCircuitTrace) /> |
|---|
| 135 | <cfelse> |
|---|
| 136 | <cfreturn this.permissions /> |
|---|
| 137 | </cfif> |
|---|
| 138 | |
|---|
| 139 | </cffunction> |
|---|
| 140 | |
|---|
| 141 | <cffunction name="getCustomAttributes" returntype="struct" access="public" output="false" |
|---|
| 142 | hint="I return the custom (namespace-qualified) attributes for this fuseaction tag."> |
|---|
| 143 | <cfargument name="ns" type="string" required="true" |
|---|
| 144 | hint="I am the namespace prefix whose attributes should be returned." /> |
|---|
| 145 | |
|---|
| 146 | <cfif structKeyExists(variables.customAttributes,arguments.ns)> |
|---|
| 147 | <!--- we structCopy() this so folks can't poke values back into the metadata! ---> |
|---|
| 148 | <cfreturn structCopy(variables.customAttributes[arguments.ns]) /> |
|---|
| 149 | <cfelse> |
|---|
| 150 | <cfreturn structNew() /> |
|---|
| 151 | </cfif> |
|---|
| 152 | |
|---|
| 153 | </cffunction> |
|---|
| 154 | |
|---|
| 155 | </cfcomponent> |
|---|