Author: keith Date: Thu Mar 19 00:57:40 2009 New Revision: 32260 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=32260
Log: adding the version sample Added: trunk/mashup/java/modules/samples/version/ trunk/mashup/java/modules/samples/version/version.js trunk/mashup/java/modules/samples/version/version.resources/ trunk/mashup/java/modules/samples/version/version.resources/version.xml trunk/mashup/java/modules/samples/version/version.resources/www/ trunk/mashup/java/modules/samples/version/version.resources/www/index.html Added: trunk/mashup/java/modules/samples/version/version.js URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/samples/version/version.js?pathrev=32260 ============================================================================== --- (empty file) +++ trunk/mashup/java/modules/samples/version/version.js Thu Mar 19 00:57:40 2009 @@ -0,0 +1,93 @@ +/* + * Copyright 2005-2007 WSO2, Inc. http://www.wso2.org + * + * 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. + */ + +this.serviceName = "version"; +this.documentation = "Mashup Server version service."; + +getVersion.documentation = "Returns the extended version string (major).(minor).(builddate)"; +getVersion.inputTypes = {}; +getVersion.outputType = "string"; +getVersion.safe = true; +function getVersion() +{ + var version = getVersionElement(); + var buildDateValue = version.attribute("build-date").toString(); + var buildDate = new Date(buildDateValue); + var versionString = versi...@number + "." + xsDate(buildDate); + return versionString; +} + +versionNumber.documentation = "Returns the major.minor version number as a string."; +versionNumber.inputTypes = {}; +versionNumber.outputType = "string"; +versionNumber.safe = true; +function versionNumber() +{ + var version = getVersionElement(); + return versi...@number; +} + +isNightly.documentation = "Returns true if the build is a nightly build."; +isNightly.inputTypes = {}; +isNightly.outputType = "boolean"; +isNightly.safe = true; +function isNightly() +{ + var version = getVersionElement(); + return (versi...@nightly == 'true'); +} + +buildDate.documentation = "Returns the build date"; +buildDate.inputTypes = {}; +buildDate.outputType = "date"; +buildDate.safe = true; +function buildDate() +{ + var version = getVersionElement(); + var buildDateValue = version.attribute("build-date").toString(); + return new Date(buildDateValue); +} + +friendlyBuildDate.documentation = "Returns the build date in human-readable (English, Sri Lanka time) format." +friendlyBuildDate.inputTypes = {}; +friendlyBuildDate.outputType = "string"; +friendlyBuildDate.safe = true; +function friendlyBuildDate() +{ + var version = getVersionElement(); + return version.attribute("build-date").toString(); +} + +getVersionElement.visible = false; +function getVersionElement() +{ + var file = new File("version.xml"); + file.openForReading(); + var value = new XML(file.readAll()); + file.close(); + return new XML(value); +} + +xsDate.visible = false; +function xsDate(d) +{ + return d.getUTCFullYear() + "-" + + (d.getUTCMonth() < 9 ? "0": "" ) + (d.getUTCMonth() + 1) + "-" + + (d.getUTCDate() < 10 ? "0": "" ) + d.getUTCDate() + "T" + + (d.getUTCHours() < 10 ? "0" : "") + d.getUTCHours() + ":" + + (d.getUTCMinutes() < 10 ? "0" : "") + d.getUTCMinutes() + ":" + + (d.getUTCSeconds() < 10 ? "0" : "") + d.getUTCSeconds(); +} Added: trunk/mashup/java/modules/samples/version/version.resources/version.xml URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/samples/version/version.resources/version.xml?pathrev=32260 ============================================================================== --- (empty file) +++ trunk/mashup/java/modules/samples/version/version.resources/version.xml Thu Mar 19 00:57:40 2009 @@ -0,0 +1 @@ +<version number="@mashup_version@" build-date="@release_date@" nightly="@is_nightly@"/> \ No newline at end of file Added: trunk/mashup/java/modules/samples/version/version.resources/www/index.html URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/samples/version/version.resources/www/index.html?pathrev=32260 ============================================================================== --- (empty file) +++ trunk/mashup/java/modules/samples/version/version.resources/www/index.html Thu Mar 19 00:57:40 2009 @@ -0,0 +1,83 @@ +<!-- + ~ Copyright 2007 WSO2, Inc. (http://wso2.com) + ~ + ~ 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. + --> + +<html> +<head> +<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>WSO2 Mashup Server 'version' Service</title> +<style type="text/css"> + body {font: 75%/1.5 "Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode",verdana,sans-serif,"trebuchet ms"; color: #111; } + img {margin-bottom: 0.5em} + span {font-weight: bold} + .template {margin-left:1em; margin-bottom:1em; font-size:125%} + #console {color:red; font-weight:bold} +</style> +<script type="text/javascript" src="../../../js/wso2/WSRequest.js"></script> +<script type="text/javascript" src="../version?stub"></script> +<script type="text/javascript"> + function load() { + //IE6 cannot understand the SOAP12 content-type and it fails. So we fallback to SOAP1.1 + if (version.endpoint == "versionSOAP12Endpoint") { + version.endpoint = "versionSOAP11Endpoint"; + } else if (version.endpoint == "SecureVersionSOAP12Endpoint") { + version.endpoint = "SecureVersionSOAP11Endpoint"; + } + + // Insert version number + version.getVersion.callback = function (payload) { + document.getElementById("number").innerHTML = payload; + }; + version.getVersion.onError = handleError; + version.getVersion(); + + // Insert build date + version.friendlyBuildDate.callback = function (payload) { + document.getElementById("date").innerHTML = payload; + }; + version.friendlyBuildDate.onError = handleError; + version.friendlyBuildDate(); + + // If release version, hide the word "nightly." + version.isNightly.callback = function (payload) { + document.getElementById("nightly").innerHTML = (payload ? "nightly build" : "release"); + }; + version.isNightly.onError = handleError; + version.isNightly(); + } + + function handleError(error) { + log (document.getElementById('console'), "Fault: " + error.reason + "\n\n" + error.detail); + }; + + function log(console, data) { + var browser = WSRequest.util._getBrowser(); + if (browser == "ie" || browser == "ie7") + console.innerText = data; + else + console.textContent = data; + } +</script> +</head> +<body onload="load()"> +<img src="/images/wso2_mashup_logo.gif" alt="WSO2 Mashup Server logo"/> +<div>This <span id="nightly">release</span> is version:</div> +<div class="template"><span id="number"></span></div> +<div>This version was built on:</div> +<div class="template"><span id="date"></span>.</div> +<div>Access all the operations of the version service through the <a href="../version?tryit">Try-it page</a>.</div> +<div style="font-style:italic">Download the latest version from the <a href="http://dist.wso2.org/products/mashup/nightly-build/" alt="WSO2 Mashup Server, Nightly Build">WSO2 Oxygen Tank</a>.</div> +<div id="console"></div></body> +</html> _______________________________________________ Mashup-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
