-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathexecute.cfc
138 lines (104 loc) · 3.44 KB
/
execute.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/**
* Execute Service : Executes a ColdFusion developer-specified process on a server computer.
* @name execute
* @displayname ColdFusion Execute(Command Line) Service
* @output false
* @accessors true
*/
component extends="base"
{
property string name;
property string arguments;
property string outputFile;
property numeric timeout;
//service tag to invoke
variables.tagName = "CFEXECUTE";
//valid ldap tag attributes
variables.tagAttributes = getSupportedTagAttributes(getTagName());
/**
* Initialization routine. Returns an instance of this component
* @output false
*/
public execute function init()
{
if(!structisempty(arguments))
{
structappend(variables,arguments,"yes");
}
/*
Special case for cfdump:
If attributes is not set in the contructor, we set it to an empty string.
If this is not done, value for attributes in dump will be a struct containing all properties set in cfc variables scope.
*/
/*
if(!structkeyexists(variables,"attributes")){
this.setAttributes("");
}
*/
return this;
}
/**
* Used to set "attributes" property.
* Note that implicit setter setAttributes() is not used since a method with the same name is defined in base.cfc
* @output false
*/
public void function setLdapAttributes(String attributes)
{
variables.attributes = attributes;
}
/**
* Returns the "attributes" property, if defined, or an empty string
* Note that implicit getter getAttributes() is not used since a method with the same name is defined in base.cfc
* @output false
*/
public function getLdapAttributes()
{
return structkeyexists(variables,"attributes") ? variables.attributes : "";
}
/**
* Removes tag attributes from variables scope. Accepts a list of tag attributes
* If no attributes are specified, all attributes are removed from CFC variables scope
* @output false
*/
public void function clearAttributes(string tagAttributesToClear="")
{
//delegate call to clearAttributes in base.cfc
super.clearAttributes(tagAttributesToClear);
//required since we explicitly set attributes to "" (see init method)
if(!structkeyexists(variables,"attributes"))
this.setAttributes("");
}
/**
* Removes tag attributes
* @output false
*/
public void function clear()
{
//delegate call to clearAttributes
clearAttributes();
}
/* ************************ BEGIN :: EXECUTE SERVICES *************************************** */
/**
* Invoke the cfexecute tag to provide the command line access in cfscript
* @output true
*/
public result function execute()
{
//store tag attributes to be passed to the service tag in a local variable
var tagAttributes = duplicate(getTagAttributes());
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
if(!structisempty(arguments))
{
structappend(tagAttributes,arguments,"yes");
}
//if a result attribute is specified, we ignore it so that we can always return the result struct
if(structkeyexists(tagAttributes,"result"))
{
structdelete(tagAttributes, "result");
}
//trim attribute values
tagAttributes = trimAttributes(tagAttributes);
return super.invokeTag(getTagName(),tagAttributes);
}
/* ************************ END :: EXECUTE SERVICES *************************************** */
}