chg: replaced ant with gradle
This commit is contained in:
parent
ced560f0c7
commit
7eebeee1d0
615 changed files with 87626 additions and 638 deletions
85
modules/jala/util/XmlRpcClient/Global/Feedback.js
Normal file
85
modules/jala/util/XmlRpcClient/Global/Feedback.js
Normal file
|
@ -0,0 +1,85 @@
|
|||
//
|
||||
// Jala Project [http://opensvn.csie.org/traccgi/jala]
|
||||
//
|
||||
// Copyright 2004 ORF Online und Teletext GmbH
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $HeadURL$
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Error- and Confirmation message container
|
||||
* @class Instances of this class can contain numerous error- and confirm messages
|
||||
* and function as a macro handler object.
|
||||
* @constructor
|
||||
* @returns A newly created Feedback instance
|
||||
* @type Feedback
|
||||
*/
|
||||
var Feedback = function() {
|
||||
this.errors = {};
|
||||
this.messages = {};
|
||||
this.isError = false;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the message with the given name to the list of errors and
|
||||
* sets the isError flag to true.
|
||||
* @param {String} name The name of the message
|
||||
* @param {msg} msg The message to use
|
||||
*/
|
||||
Feedback.prototype.setError = function(name, msg) {
|
||||
this.errors[name] = msg;
|
||||
this.isError = true;
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the message with the given name to the list of confirmation messages
|
||||
* and sets the isError flag to true.
|
||||
* @param {String} name The name of the message
|
||||
* @param {msg} msg The message to use
|
||||
*/
|
||||
Feedback.prototype.setMessage = function(name, msg) {
|
||||
this.messages[name] = msg;
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the message with the given name
|
||||
* @returns The message with the given name
|
||||
* @type String
|
||||
*/
|
||||
Feedback.prototype.message_macro = function(param) {
|
||||
if (param.name != null) {
|
||||
return this.messages[param.name];
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the error message with the given name
|
||||
* @returns The error message with the given name
|
||||
* @type String
|
||||
*/
|
||||
Feedback.prototype.error_macro = function(param) {
|
||||
if (param.name != null) {
|
||||
return this.errors[param.name];
|
||||
}
|
||||
return;
|
||||
};
|
362
modules/jala/util/XmlRpcClient/Global/Global.js
Normal file
362
modules/jala/util/XmlRpcClient/Global/Global.js
Normal file
|
@ -0,0 +1,362 @@
|
|||
//
|
||||
// Jala Project [http://opensvn.csie.org/traccgi/jala]
|
||||
//
|
||||
// Copyright 2004 ORF Online und Teletext GmbH
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $HeadURL$
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
app.addRepository("modules/core/String.js");
|
||||
app.addRepository(getProperty("jala.dir", "modules/jala") +
|
||||
"/code/XmlRpcRequest.js");
|
||||
|
||||
/**
|
||||
* A safe eval method that uses a standard Javascript scope
|
||||
* without any Helma specifics for evaluation. This method
|
||||
* does a double evaluation: first it evaluates the code
|
||||
* in a separate javascript scope without any Helma specifics, and only
|
||||
* if that doesn't throw an exception it evaluates the expression in the
|
||||
* application scope, so that objects constructed during evaluation
|
||||
* belong to the correct scope (and eg. testing with instanceof returns
|
||||
* the expected result). Keep in mind that due to the double
|
||||
* evaluation using this method is quite costly.
|
||||
* @param {String} code The code to evaluate
|
||||
* @returns The result of the evaluated code
|
||||
*/
|
||||
var safeEval = function(code) {
|
||||
var context = new Packages.org.mozilla.javascript.Context();
|
||||
try {
|
||||
context.enter();
|
||||
// first evaluation in separate scope
|
||||
context.evaluateString(safeEval.SCOPE, code, null, 0, null);
|
||||
return eval(code);
|
||||
} finally {
|
||||
context.exit();
|
||||
}
|
||||
};
|
||||
safeEval.SCOPE = Packages.org.mozilla.javascript.Context.getCurrentContext().initStandardObjects();
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is a string. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is a string, false otherwise
|
||||
*/
|
||||
var isString = function(val) {
|
||||
return typeof(val) == "string" ||
|
||||
val instanceof java.lang.String ||
|
||||
val instanceof String;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is a boolean. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is a boolean, false otherwise
|
||||
*/
|
||||
var isBoolean = function(val) {
|
||||
return typeof(val) == "boolean" ||
|
||||
val instanceof Boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is a number. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is a number, false otherwise
|
||||
*/
|
||||
var isNumber = function(val) {
|
||||
return typeof(val) == "number" ||
|
||||
val instanceof java.lang.Integer ||
|
||||
val instanceof Number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is null.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is null, false otherwise
|
||||
*/
|
||||
var isNull = function(val) {
|
||||
return val === null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is undefined.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is undefined, false otherwise
|
||||
*/
|
||||
var isUndefined = function(val) {
|
||||
return val === undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is an array. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is an array, false otherwise
|
||||
*/
|
||||
var isArray = function(val) {
|
||||
return val instanceof Array;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is a date. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is a date, false otherwise
|
||||
*/
|
||||
var isDate = function(val) {
|
||||
return val instanceof Date ||
|
||||
val instanceof java.util.Date;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the value passed as argument is an object. Since
|
||||
* this value might be constructed using the safeEval's scope
|
||||
* this method tests both the application's scope and the safe one.
|
||||
* @param {Object} val The value to test
|
||||
* @returns True if the value is an object, false otherwise
|
||||
*/
|
||||
var isObject = function(val) {
|
||||
return val instanceof Object ||
|
||||
val instanceof java.lang.Object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the argument string passed into an array containing
|
||||
* evaluated arguments. The string can contain object and array literals,
|
||||
* strings, numbers and dates (using standard Javascript syntax).
|
||||
* @param {String} str The string to parse
|
||||
* @returns The parsed arguments
|
||||
* @type Array
|
||||
*/
|
||||
var parseArguments = function(str) {
|
||||
var result = [];
|
||||
var c, literalLevel = 0;
|
||||
var buf = new java.lang.StringBuffer();
|
||||
for (var i=0;i<str.length;i++) {
|
||||
c = str.charAt(i);
|
||||
if (c == "," && literalLevel == 0) {
|
||||
result.push(evalArgument(buf.toString()));
|
||||
buf.setLength(0);
|
||||
} else {
|
||||
if (c == "[" || c == "{") {
|
||||
literalLevel += 1;
|
||||
} else if (c == "]" || c == "}") {
|
||||
literalLevel -= 1;
|
||||
}
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
if (buf.length() > 0) {
|
||||
result.push(evalArgument(buf.toString()));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a single argument string using the safeEval's method
|
||||
* eval(). This way users can't do any harm since all they have is
|
||||
* a plain Javascript environment without any Helma specifics.
|
||||
* @param {String} str The string to evaluate
|
||||
* @returns The evaluated argument
|
||||
*/
|
||||
var evalArgument = function(str) {
|
||||
if (str) {
|
||||
str = str.trim();
|
||||
return safeEval("(" + str + ")");
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the object passed as argument as formatted JSOn compatible
|
||||
* string.
|
||||
* @param {Object} obj The object to format as string
|
||||
* @returns The formatted string
|
||||
*/
|
||||
var prettyPrint = function(obj) {
|
||||
|
||||
var pad = function(str) {
|
||||
return " ".repeat((lvl) * 6) + str;
|
||||
};
|
||||
|
||||
var printString = function(str) {
|
||||
return '"' + encode(str) + '"';
|
||||
};
|
||||
|
||||
var printInteger = function(nr) {
|
||||
return nr.toString();
|
||||
};
|
||||
|
||||
var printBoolean = function(bool) {
|
||||
return bool.toString();
|
||||
};
|
||||
|
||||
var printUndefined = function() {
|
||||
return "undefined";
|
||||
};
|
||||
|
||||
var printNull = function() {
|
||||
return "null";
|
||||
};
|
||||
|
||||
var printDate = function(date) {
|
||||
return date.toString();
|
||||
};
|
||||
|
||||
var printArray = function(arr) {
|
||||
var buf = new java.lang.StringBuffer();
|
||||
buf.append("[");
|
||||
lvl += 1;
|
||||
for (var i=0;i<arr.length;i++) {
|
||||
if (i > 0) {
|
||||
buf.append(",");
|
||||
}
|
||||
buf.append("\n");
|
||||
buf.append(pad(printValue(arr[i])));
|
||||
}
|
||||
lvl -= 1;
|
||||
buf.append("\n");
|
||||
buf.append(pad("]"));
|
||||
return buf.toString();
|
||||
};
|
||||
|
||||
var printObject = function(obj) {
|
||||
var buf = new java.lang.StringBuffer();
|
||||
buf.append("{");
|
||||
lvl += 1;
|
||||
var first = true;
|
||||
for (var i in obj) {
|
||||
if (first) {
|
||||
first = !first;
|
||||
} else {
|
||||
buf.append(",");
|
||||
}
|
||||
buf.append("\n");
|
||||
buf.append(pad(printString(i) + ": "));
|
||||
buf.append(printValue(obj[i]));
|
||||
}
|
||||
lvl -= 1;
|
||||
buf.append("\n");
|
||||
buf.append(pad("}"));
|
||||
return buf.toString();
|
||||
};
|
||||
|
||||
var printValue = function(val) {
|
||||
if (isArray(val)) {
|
||||
return printArray(val);
|
||||
} else if (isDate(val)) {
|
||||
return printDate(val);
|
||||
} else if (isString(val)) {
|
||||
return printString(val);
|
||||
} else if (isNumber(val)) {
|
||||
return printInteger(val);
|
||||
} else if (isBoolean(val)) {
|
||||
return printBoolean(val);
|
||||
} else if (isNull(val)) {
|
||||
return printNull();
|
||||
} else if (isUndefined(val)) {
|
||||
return printUndefined();
|
||||
} else if (isObject(val)) {
|
||||
return printObject(val);
|
||||
} else if (val.toString != null) {
|
||||
return val.toString();
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
var lvl = 0;
|
||||
return printValue(obj);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the xml source passed as argument as readable string
|
||||
* with appropriate linefeeds and indents. This method uses a
|
||||
* regular expression instead of converting the xml source into
|
||||
* a DOM tree to be able to format invalid xml which might be useful
|
||||
* for debugging.
|
||||
* @param {String} xmlSource The XML source for format
|
||||
* @returns The formatted source
|
||||
*/
|
||||
var prettyPrintXml = function(xmlSource) {
|
||||
var pad = function(str) {
|
||||
res.write(" ".repeat((lvl) * 6) + encode(str));
|
||||
};
|
||||
|
||||
// remove all linefeeds and carriage returns
|
||||
var xml = xmlSource.replace(/\r\n|\n\r|\n|\r/g, "");
|
||||
var re = /<(\/?)([^>]+)[^<]+(?=<|$)/gm;
|
||||
var lvl = 0;
|
||||
var match;
|
||||
var tag, prevTag;
|
||||
res.push();
|
||||
while (match = re.exec(xml)) {
|
||||
tag = match[2];
|
||||
if (!match[1]) {
|
||||
// opening or contentless tag
|
||||
if (match.index > 0) {
|
||||
res.write("\n");
|
||||
lvl += 1;
|
||||
}
|
||||
pad(match[0]);
|
||||
if (tag.indexOf("/") > -1) {
|
||||
lvl -= 1;
|
||||
}
|
||||
} else {
|
||||
// closing tag
|
||||
if (tag == prevTag) {
|
||||
lvl -= 1;
|
||||
res.encode(match[0]);
|
||||
} else {
|
||||
res.write("\n");
|
||||
pad(match[0]);
|
||||
lvl -= 1;
|
||||
}
|
||||
}
|
||||
prevTag = tag;
|
||||
}
|
||||
return res.pop();
|
||||
};
|
||||
|
||||
/**
|
||||
* Basic selection macro useable for checkboxes
|
||||
* and select dropdowns. This macro checks if
|
||||
* req.data[param.name] equals param.value, and if
|
||||
* true it writes the specified param.attribute in
|
||||
* the form 'attribute="attribute"' to response.
|
||||
*/
|
||||
var selection_macro = function(param) {
|
||||
if (req.data[param.name] == param.value) {
|
||||
res.write(" ");
|
||||
res.write(param.attribute);
|
||||
res.write('="');
|
||||
res.write(param.attribute);
|
||||
res.write('"');
|
||||
}
|
||||
return;
|
||||
};
|
146
modules/jala/util/XmlRpcClient/Global/XmlRpcCall.js
Normal file
146
modules/jala/util/XmlRpcClient/Global/XmlRpcCall.js
Normal file
|
@ -0,0 +1,146 @@
|
|||
//
|
||||
// Jala Project [http://opensvn.csie.org/traccgi/jala]
|
||||
//
|
||||
// Copyright 2004 ORF Online und Teletext GmbH
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $HeadURL$
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper for making XmlRpc calls to remote servers.
|
||||
* @class Instances of this class can make calls to remote
|
||||
* XmlRpc servers, plus function as macro handlers for displaying
|
||||
* results, errors etc.
|
||||
* @param {String} url The url of the entry-point
|
||||
* @param {String} methodName The name of the method to call (eg. "xmlrpcclient.echo")
|
||||
* @param {Array} args An array containing arguments to pass to the remote function
|
||||
* @returns A newly created XmlRpcCall instance
|
||||
* @type XmlRpcCall
|
||||
*/
|
||||
var XmlRpcCall = function(url, methodName) {
|
||||
this.request = new jala.XmlRpcRequest(url, methodName);
|
||||
this.result = null;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the XmlRpc call
|
||||
*/
|
||||
XmlRpcCall.prototype.execute = function() {
|
||||
this.args = arguments;
|
||||
this.response = jala.XmlRpcRequest.prototype.execute.apply(this.request, arguments);
|
||||
return;
|
||||
};
|
||||
|
||||
/** @ignore */
|
||||
XmlRpcCall.prototype.toString = function() {
|
||||
return "[XmlRpcCall]";
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the Url of this XmlRpcCall instance.
|
||||
* @returns The url of this call
|
||||
* @type String
|
||||
*/
|
||||
XmlRpcCall.prototype.url_macro = function() {
|
||||
return this.url;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the method name of this XmlRpcCall instance.
|
||||
* @returns The method name of this call
|
||||
* @type String
|
||||
*/
|
||||
XmlRpcCall.prototype.method_macro = function() {
|
||||
return this.methodName;
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the arguments of this XmlRpcCall instance.
|
||||
*/
|
||||
XmlRpcCall.prototype.arguments_macro = function() {
|
||||
var arg;
|
||||
for (var i=0;i<this.args.length;i++) {
|
||||
arg = this.args[i];
|
||||
res.write('<div class="argument ' + (i%2 == 0 ? "even" : "odd") + '">');
|
||||
res.write('<div class="type">' + i + " ");
|
||||
if (isArray(arg)) {
|
||||
res.write("(Array)");
|
||||
} else if (isDate(arg)) {
|
||||
res.write("(Date)");
|
||||
} else if (isString(arg)) {
|
||||
res.write("(String)");
|
||||
} else if (isNumber(arg)) {
|
||||
res.write("(Integer)");
|
||||
} else if (isBoolean(arg)) {
|
||||
res.write("(Boolean)");
|
||||
} else if (isNull(arg)) {
|
||||
res.write("(null)");
|
||||
} else if (isUndefined(arg)) {
|
||||
res.write("(undefined)");
|
||||
} else if (isObject(arg)) {
|
||||
res.write("(Object)");
|
||||
} else {
|
||||
res.write("(unknown type)");
|
||||
}
|
||||
res.write('</div>\n<div class="value"><pre>');
|
||||
res.write(prettyPrint(arg));
|
||||
res.write("</pre></div></div>");
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the result of this XmlRpcCall instance.
|
||||
* @returns The result as human readable string
|
||||
* @type String
|
||||
*/
|
||||
XmlRpcCall.prototype.result_macro = function() {
|
||||
if (this.response.result != null) {
|
||||
return prettyPrint(this.response.result);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the error of this XmlRpcCall instance, if any.
|
||||
* @returns The error string
|
||||
* @type String
|
||||
*/
|
||||
XmlRpcCall.prototype.error_macro = function() {
|
||||
if (this.response.error != null) {
|
||||
return this.response.error;
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the xml source of either request or response
|
||||
* @param {Object} param A parameter object containing the
|
||||
* macro attributes
|
||||
*/
|
||||
XmlRpcCall.prototype.xml_macro = function(param) {
|
||||
var xml = this.response[param.of + "Xml"];
|
||||
if (xml != null) {
|
||||
res.write("<pre>");
|
||||
res.write(prettyPrintXml(xml));
|
||||
res.write("</pre>");
|
||||
}
|
||||
return;
|
||||
};
|
59
modules/jala/util/XmlRpcClient/README
Normal file
59
modules/jala/util/XmlRpcClient/README
Normal file
|
@ -0,0 +1,59 @@
|
|||
This is the README file for the XmlRpcClient application as part of
|
||||
version 1.0 of the Jala Javascript Library.
|
||||
|
||||
|
||||
About XmlRpcClient
|
||||
------------------
|
||||
|
||||
The XmlRpcClient is a small Helma application useful to test and debug XmlRpc
|
||||
requests.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install the application add the following to the apps.properties file in
|
||||
your Helma installation directory:
|
||||
|
||||
xmlrpcclient
|
||||
xmlrpcclient.repository.0 = ./modules/jala/util/XmlRpcClient
|
||||
|
||||
|
||||
Usage Instructions
|
||||
------------------
|
||||
|
||||
To access the XmlRpcClient point your browser to the URL
|
||||
|
||||
http://your.server.domain[:port]/xmlrpcclient
|
||||
|
||||
(replace "your.server.domain" with the domain of your server, and the ":port"
|
||||
section with the port number if not 80). Then fill out the form with at least
|
||||
the URL of the XmlRpc service and the method name (both are required).
|
||||
|
||||
Optionally you can pass various arguments to the remote method using standard
|
||||
Javascript literal notation, eg.:
|
||||
|
||||
String: "a string"
|
||||
Number: 1
|
||||
Boolean: true|false
|
||||
Objec: {name: "jala"}
|
||||
Array: [1, 2, "three", 4]
|
||||
Date: new Date(2007, 0, 22, 15, 10)
|
||||
|
||||
By default the XmlRpc client uses UTF-8 as encoding for request and response,
|
||||
which you can change to ISO-8859-1 if necessary. If you select the "Show Xml"
|
||||
checkbox the result shown will also contain the Xml source of the request and
|
||||
response, which is useful for debugging.
|
||||
|
||||
At last you can tell the client to use a specific HTTP proxy for the requests,
|
||||
which you must define in the form "fqdn:port", eg. "my.proxy.com:3128".
|
||||
|
||||
|
||||
Contact, Bugs and Feedback
|
||||
--------------------------
|
||||
|
||||
The Jala Project is currently hosted at https://OpenSVN.csie.org/traccgi/jala/
|
||||
providing all necessary information about Subversion access, Ticketing, Releases
|
||||
etc.
|
||||
|
||||
For immediate contact you can reach the developers via jaladev AT gmail.com.
|
84
modules/jala/util/XmlRpcClient/Root/Root.js
Normal file
84
modules/jala/util/XmlRpcClient/Root/Root.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
//
|
||||
// Jala Project [http://opensvn.csie.org/traccgi/jala]
|
||||
//
|
||||
// Copyright 2004 ORF Online und Teletext GmbH
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $HeadURL$
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Main action
|
||||
*/
|
||||
Root.prototype.main_action = function() {
|
||||
res.handlers.xmlrpc = {};
|
||||
res.handlers.feedback = new Feedback();
|
||||
if (req.isPost()) {
|
||||
if (!req.data.url) {
|
||||
res.handlers.feedback.setError("url", "Please enter the URL of the XmlRpc entry point");
|
||||
}
|
||||
if (!req.data.method) {
|
||||
res.handlers.feedback.setError("method", "Please specify the method to call");
|
||||
}
|
||||
try {
|
||||
var args = parseArguments(req.data.args);
|
||||
} catch (e) {
|
||||
res.handlers.feedback.setError("arguments", "The method arguments are invalid");
|
||||
}
|
||||
if (!res.handlers.feedback.isError) {
|
||||
var xmlRpcCall = new XmlRpcCall(req.data.url, req.data.method);
|
||||
xmlRpcCall.request.setEncoding(req.data.encoding);
|
||||
xmlRpcCall.request.setProxy(req.data.proxy);
|
||||
xmlRpcCall.request.setDebug(req.data.debug == 1);
|
||||
if (app.properties.username != null && app.properties.password != null) {
|
||||
xmlRpcCall.request.setCredentials(app.properties.username, app.properties.password);
|
||||
}
|
||||
XmlRpcCall.prototype.execute.apply(xmlRpcCall, args);
|
||||
res.handlers.xmlrpc = xmlRpcCall;
|
||||
}
|
||||
}
|
||||
this.renderSkin("main");
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Main XmlRpc action. The only supported method name is "echo".
|
||||
* If no additional arguments are given this action
|
||||
* returns "echo" to the client. A single additional argument is returned
|
||||
* as-is, multiple additional arguments are returned as array.
|
||||
*/
|
||||
Root.prototype.main_action_xmlrpc = function(methodName) {
|
||||
switch (methodName) {
|
||||
case "echo":
|
||||
if (arguments.length == 1) {
|
||||
return "echo";
|
||||
} else if (arguments.length == 2) {
|
||||
return arguments[1];
|
||||
} else {
|
||||
var result = [];
|
||||
for (var i=1;i<arguments.length;i++) {
|
||||
result.push(arguments[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
throw "Unknown XmlRpc method '" + methodName + "'";
|
||||
break;
|
||||
}
|
||||
return;
|
||||
};
|
182
modules/jala/util/XmlRpcClient/Root/main.skin
Normal file
182
modules/jala/util/XmlRpcClient/Root/main.skin
Normal file
|
@ -0,0 +1,182 @@
|
|||
<%
|
||||
//
|
||||
// Jala Project [http://opensvn.csie.org/traccgi/jala]
|
||||
//
|
||||
// Copyright 2004 ORF Online und Teletext GmbH
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an ``AS IS'' BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $HeadURL$
|
||||
//
|
||||
%>
|
||||
<html>
|
||||
<head>
|
||||
<title>Jala XmlRpc Client</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
||||
body {
|
||||
font-family: Verdana, Arial, Helvetica;
|
||||
font-size: 0.85em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.header {
|
||||
background-color: #aaa;
|
||||
border-bottom: 1px solid #333;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #ddd;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
div.main {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
form div {
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
form div label {
|
||||
display: block;
|
||||
float: left;
|
||||
clear: left;
|
||||
width: 100px;
|
||||
padding: 3px 5px 3px 0;
|
||||
margin: 0px 0px 5px 0px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
form div.required label, label.required {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
form span.example {
|
||||
font-size: 0.7em;
|
||||
line-height: 15px;
|
||||
}
|
||||
|
||||
form input {
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
color: #000000;
|
||||
border: 1px solid grey;
|
||||
padding: 3px;
|
||||
line-height:0.9em;
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
form select {
|
||||
border: 1px solid grey;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
form input.checkbox {
|
||||
border:none;
|
||||
width:auto;
|
||||
}
|
||||
|
||||
form .submit {
|
||||
width: auto;
|
||||
padding: 3px 20px;
|
||||
}
|
||||
|
||||
div.argument div.type {
|
||||
float: left;
|
||||
clear: left;
|
||||
width: 130px;
|
||||
padding: 3px 5px;
|
||||
}
|
||||
|
||||
div.argument div.value {
|
||||
padding: 3px 5px;
|
||||
margin-left: 140px;
|
||||
}
|
||||
|
||||
div.even {
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
border-top: 1px solid #aaa;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
border-bottom: none;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
font-weight: bold;
|
||||
color: #aaa;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
fieldset legend.result {
|
||||
color: #00bb00;
|
||||
}
|
||||
|
||||
fieldset legend.error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: Verdana, Arial, Helvetica;
|
||||
font-size: 1em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.error {
|
||||
color: #ff0000;
|
||||
font-weight: bold;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
//-->
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="header">Jala XmlRpc Client</div>
|
||||
<div class="main">
|
||||
<form method="post" action="<% request.action %>">
|
||||
<div><% feedback.error name="url" prefix='<div class="error">' suffix="</div>" %><label for="url" class="required">Url*</label><input id="host" type="text" name="url" value="<% request.url encoding="form" %>" /><br />
|
||||
<span class="example">Example: http://localhost:8080/xmlrpcclient/</span></div>
|
||||
<div><% feedback.error name="method" prefix='<div class="error">' suffix="</div>" %><label for="method" class="required">Method*</label><input id="method" type="text" name="method" value="<% request.method encoding="form" %>" /><br />
|
||||
<span class="example">Example: echo</span></div>
|
||||
<div><% feedback.error name="arguments" prefix='<div class="error">' suffix="</div>" %><label for="args">Arguments </label><input id="args" type="text" name="args" value="<% request.args encoding="form" %>" /><br />
|
||||
<span class="example">Example: "eins", 123, true, new Date(), {test: {me: "please"}}, ["a", ["b", "c"]]</span></div>
|
||||
<div><label for="encoding">Encoding</label><select id="encoding" name="encoding"><option<% selection name="encoding" value="UTF-8" attribute="selected" %>>UTF-8</option><option<% selection name="encoding" value="ISO-8859-1" attribute="selected" %>>ISO-8859-1</option></select></div>
|
||||
<div><label for="debug">Show Xml</label><input id="debug" class="checkbox" type="checkbox" name="debug" value="1"<% selection name="debug" value="1" attribute="checked" %>/></div>
|
||||
<div><label for="proxy">Proxy</label><input id="proxy" type="text" name="proxy" value="<% request.proxy %>" /><br />
|
||||
<span class="example">Example: my.proxy.com:3128</span></div>
|
||||
<div><label> </label><input class="submit" type="submit" name="test" value="Test" /><br /><span class="example">(* = required)</span></div>
|
||||
|
||||
<% xmlrpc.arguments prefix="<fieldset><legend>Arguments</legend>" suffix="</fieldset>" %>
|
||||
|
||||
<% xmlrpc.error prefix='<fieldset><legend class="error">Error</legend>' suffix="</fieldset>" %>
|
||||
|
||||
<% xmlrpc.result prefix='<fieldset><legend class="result">Result</legend><pre>' suffix="</pre></fieldset>" %>
|
||||
|
||||
<% xmlrpc.xml of="request" prefix="<fieldset><legend>Request XML</legend>" suffix="</fieldset>" %>
|
||||
|
||||
<% xmlrpc.xml of="response" prefix="<fieldset><legend>Response XML</legend>" suffix="</fieldset>" %>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue