Improve output: distinguish between failed assertions (failures) and unexpected exceptions (errors), and print a filtered stack trace for any exception.
This commit is contained in:
commit
4f2e303079
1839 changed files with 235630 additions and 0 deletions
145
webapp/web/src/storage/Storage.as
Normal file
145
webapp/web/src/storage/Storage.as
Normal file
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
import DojoExternalInterface;
|
||||
|
||||
class Storage {
|
||||
public static var SUCCESS = "success";
|
||||
public static var FAILED = "failed";
|
||||
public static var PENDING = "pending";
|
||||
|
||||
public var so;
|
||||
|
||||
public function Storage(){
|
||||
//getURL("javascript:dojo.debug('FLASH:Storage constructor')");
|
||||
DojoExternalInterface.initialize();
|
||||
DojoExternalInterface.addCallback("put", this, put);
|
||||
DojoExternalInterface.addCallback("get", this, get);
|
||||
DojoExternalInterface.addCallback("showSettings", this, showSettings);
|
||||
DojoExternalInterface.addCallback("clear", this, clear);
|
||||
DojoExternalInterface.addCallback("getKeys", this, getKeys);
|
||||
DojoExternalInterface.addCallback("remove", this, remove);
|
||||
DojoExternalInterface.loaded();
|
||||
|
||||
// preload the System Settings finished button movie for offline
|
||||
// access so it is in the cache
|
||||
_root.createEmptyMovieClip("_settingsBackground", 1);
|
||||
_root._settingsBackground.loadMovie(DojoExternalInterface.dojoPath + "storage_dialog.swf");
|
||||
}
|
||||
|
||||
public function put(keyName, keyValue, namespace){
|
||||
// Get the SharedObject for these values and save it
|
||||
so = SharedObject.getLocal(namespace);
|
||||
|
||||
// prepare a storage status handler
|
||||
var self = this;
|
||||
so.onStatus = function(infoObject:Object){
|
||||
//getURL("javascript:dojo.debug('FLASH: onStatus, infoObject="+infoObject.code+"')");
|
||||
|
||||
// delete the data value if the request was denied
|
||||
if (infoObject.code == "SharedObject.Flush.Failed"){
|
||||
delete self.so.data[keyName];
|
||||
}
|
||||
|
||||
var statusResults;
|
||||
if(infoObject.code == "SharedObject.Flush.Failed"){
|
||||
statusResults = Storage.FAILED;
|
||||
}else if(infoObject.code == "SharedObject.Flush.Pending"){
|
||||
statusResults = Storage.PENDING;
|
||||
}else if(infoObject.code == "SharedObject.Flush.Success"){
|
||||
statusResults = Storage.SUCCESS;
|
||||
}
|
||||
//getURL("javascript:dojo.debug('FLASH: onStatus, statusResults="+statusResults+"')");
|
||||
|
||||
// give the status results to JavaScript
|
||||
DojoExternalInterface.call("dojo.storage._onStatus", null, statusResults,
|
||||
keyName);
|
||||
}
|
||||
|
||||
// save the key and value
|
||||
so.data[keyName] = keyValue;
|
||||
var flushResults = so.flush();
|
||||
|
||||
// return results of this command to JavaScript
|
||||
var statusResults;
|
||||
if(flushResults == true){
|
||||
statusResults = Storage.SUCCESS;
|
||||
}else if(flushResults == "pending"){
|
||||
statusResults = Storage.PENDING;
|
||||
}else{
|
||||
statusResults = Storage.FAILED;
|
||||
}
|
||||
|
||||
DojoExternalInterface.call("dojo.storage._onStatus", null, statusResults,
|
||||
keyName);
|
||||
}
|
||||
|
||||
public function get(keyName, namespace){
|
||||
// Get the SharedObject for these values and save it
|
||||
so = SharedObject.getLocal(namespace);
|
||||
var results = so.data[keyName];
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public function showSettings(){
|
||||
// Show the configuration options for the Flash player, opened to the
|
||||
// section for local storage controls (pane 1)
|
||||
System.showSettings(1);
|
||||
|
||||
// there is no way we can intercept when the Close button is pressed, allowing us
|
||||
// to hide the Flash dialog. Instead, we need to load a movie in the
|
||||
// background that we can show a close button on.
|
||||
_root.createEmptyMovieClip("_settingsBackground", 1);
|
||||
_root._settingsBackground.loadMovie(DojoExternalInterface.dojoPath + "storage_dialog.swf");
|
||||
}
|
||||
|
||||
public function clear(namespace){
|
||||
so = SharedObject.getLocal(namespace);
|
||||
so.clear();
|
||||
so.flush();
|
||||
}
|
||||
|
||||
public function getKeys(namespace){
|
||||
// Returns a list of the available keys in this namespace
|
||||
|
||||
// get the storage object
|
||||
so = SharedObject.getLocal(namespace);
|
||||
|
||||
// get all of the keys
|
||||
var results = new Array();
|
||||
for(var i in so.data)
|
||||
results.push(i);
|
||||
|
||||
// join the keys together in a comma seperated string
|
||||
results = results.join(",");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public function remove(keyName, namespace){
|
||||
// Removes a key
|
||||
|
||||
// get the storage object
|
||||
so = SharedObject.getLocal(namespace);
|
||||
|
||||
// delete this value
|
||||
delete so.data[keyName];
|
||||
|
||||
// save the changes
|
||||
so.flush();
|
||||
}
|
||||
|
||||
static function main(mc){
|
||||
//getURL("javascript:dojo.debug('FLASH: storage loaded')");
|
||||
_root.app = new Storage();
|
||||
}
|
||||
}
|
||||
|
17
webapp/web/src/storage/__package__.js
Normal file
17
webapp/web/src/storage/__package__.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.kwCompoundRequire({
|
||||
common: ["dojo.storage"],
|
||||
browser: ["dojo.storage.browser"],
|
||||
dashboard: ["dojo.storage.dashboard"]
|
||||
});
|
||||
dojo.provide("dojo.storage.*");
|
||||
|
199
webapp/web/src/storage/browser.js
Normal file
199
webapp/web/src/storage/browser.js
Normal file
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.provide("dojo.storage.browser");
|
||||
dojo.provide("dojo.storage.browser.FlashStorageProvider");
|
||||
|
||||
dojo.require("dojo.storage");
|
||||
dojo.require("dojo.flash");
|
||||
dojo.require("dojo.json");
|
||||
dojo.require("dojo.uri.*");
|
||||
|
||||
/**
|
||||
Storage provider that uses features in Flash to achieve permanent storage.
|
||||
|
||||
@author Alex Russel, alex@dojotoolkit.org
|
||||
@author Brad Neuberg, bkn3@columbia.edu
|
||||
*/
|
||||
dojo.storage.browser.FlashStorageProvider = function(){
|
||||
}
|
||||
|
||||
dojo.inherits(dojo.storage.browser.FlashStorageProvider, dojo.storage);
|
||||
|
||||
// instance methods and properties
|
||||
dojo.lang.extend(dojo.storage.browser.FlashStorageProvider, {
|
||||
namespace: "default",
|
||||
initialized: false,
|
||||
_available: null,
|
||||
_statusHandler: null,
|
||||
|
||||
initialize: function(){
|
||||
if(djConfig["disableFlashStorage"] == true){
|
||||
return;
|
||||
}
|
||||
|
||||
// initialize our Flash
|
||||
var loadedListener = function(){
|
||||
dojo.storage._flashLoaded();
|
||||
}
|
||||
dojo.flash.addLoadedListener(loadedListener);
|
||||
var swfloc6 = dojo.uri.dojoUri("Storage_version6.swf").toString();
|
||||
var swfloc8 = dojo.uri.dojoUri("Storage_version8.swf").toString();
|
||||
dojo.flash.setSwf({flash6: swfloc6, flash8: swfloc8, visible: false});
|
||||
},
|
||||
|
||||
isAvailable: function(){
|
||||
if(djConfig["disableFlashStorage"] == true){
|
||||
this._available = false;
|
||||
}
|
||||
|
||||
return this._available;
|
||||
},
|
||||
|
||||
setNamespace: function(namespace){
|
||||
this.namespace = namespace;
|
||||
},
|
||||
|
||||
put: function(key, value, resultsHandler){
|
||||
if(this.isValidKey(key) == false){
|
||||
dojo.raise("Invalid key given: " + key);
|
||||
}
|
||||
|
||||
this._statusHandler = resultsHandler;
|
||||
|
||||
// serialize the value
|
||||
// Handle strings differently so they have better performance
|
||||
if(dojo.lang.isString(value)){
|
||||
value = "string:" + value;
|
||||
}else{
|
||||
value = dojo.json.serialize(value);
|
||||
}
|
||||
|
||||
dojo.flash.comm.put(key, value, this.namespace);
|
||||
},
|
||||
|
||||
get: function(key){
|
||||
if(this.isValidKey(key) == false){
|
||||
dojo.raise("Invalid key given: " + key);
|
||||
}
|
||||
|
||||
var results = dojo.flash.comm.get(key, this.namespace);
|
||||
|
||||
if(results == ""){
|
||||
return null;
|
||||
}
|
||||
|
||||
// destringify the content back into a
|
||||
// real JavaScript object
|
||||
// Handle strings differently so they have better performance
|
||||
if(!dojo.lang.isUndefined(results) && results != null
|
||||
&& /^string:/.test(results)){
|
||||
results = results.substring("string:".length);
|
||||
}else{
|
||||
results = dojo.json.evalJson(results);
|
||||
}
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
getKeys: function(){
|
||||
var results = dojo.flash.comm.getKeys(this.namespace);
|
||||
|
||||
if(results == ""){
|
||||
return new Array();
|
||||
}
|
||||
|
||||
// the results are returned comma seperated; split them
|
||||
results = results.split(",");
|
||||
|
||||
return results;
|
||||
},
|
||||
|
||||
clear: function(){
|
||||
dojo.flash.comm.clear(this.namespace);
|
||||
},
|
||||
|
||||
remove: function(key){
|
||||
},
|
||||
|
||||
isPermanent: function(){
|
||||
return true;
|
||||
},
|
||||
|
||||
getMaximumSize: function(){
|
||||
return dojo.storage.SIZE_NO_LIMIT;
|
||||
},
|
||||
|
||||
hasSettingsUI: function(){
|
||||
return true;
|
||||
},
|
||||
|
||||
showSettingsUI: function(){
|
||||
dojo.flash.comm.showSettings();
|
||||
dojo.flash.obj.setVisible(true);
|
||||
dojo.flash.obj.center();
|
||||
},
|
||||
|
||||
hideSettingsUI: function(){
|
||||
// hide the dialog
|
||||
dojo.flash.obj.setVisible(false);
|
||||
|
||||
// call anyone who wants to know the dialog is
|
||||
// now hidden
|
||||
if(dojo.storage.onHideSettingsUI != null &&
|
||||
!dojo.lang.isUndefined(dojo.storage.onHideSettingsUI)){
|
||||
dojo.storage.onHideSettingsUI.call(null);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
The provider name as a string, such as
|
||||
"dojo.storage.FlashStorageProvider".
|
||||
*/
|
||||
getType: function(){
|
||||
return "dojo.storage.FlashStorageProvider";
|
||||
},
|
||||
|
||||
/** Called when the Flash is finished loading. */
|
||||
_flashLoaded: function(){
|
||||
this.initialized = true;
|
||||
|
||||
// indicate that this storage provider is now loaded
|
||||
dojo.storage.manager.loaded();
|
||||
},
|
||||
|
||||
/**
|
||||
Called if the storage system needs to tell us about the status
|
||||
of a put() request.
|
||||
*/
|
||||
_onStatus: function(statusResult, key){
|
||||
//dojo.debug("_onStatus, statusResult="+statusResult+", key="+key);
|
||||
if(statusResult == dojo.storage.PENDING){
|
||||
dojo.flash.obj.center();
|
||||
dojo.flash.obj.setVisible(true);
|
||||
}else{
|
||||
dojo.flash.obj.setVisible(false);
|
||||
}
|
||||
|
||||
if(!dojo.lang.isUndefined(dojo.storage._statusHandler)
|
||||
&& dojo.storage._statusHandler != null){
|
||||
dojo.storage._statusHandler.call(null, statusResult, key);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// register the existence of our storage providers
|
||||
dojo.storage.manager.register("dojo.storage.browser.FlashStorageProvider",
|
||||
new dojo.storage.browser.FlashStorageProvider());
|
||||
|
||||
// now that we are loaded and registered tell the storage manager to initialize
|
||||
// itself
|
||||
dojo.storage.manager.initialize();
|
||||
|
52
webapp/web/src/storage/dashboard.js
Normal file
52
webapp/web/src/storage/dashboard.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
dojo.require("dojo.storage");
|
||||
dojo.require("dojo.json");
|
||||
dojo.provide("dojo.storage.dashboard");
|
||||
|
||||
dojo.storage.dashboard.StorageProvider = function(){
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
dojo.inherits(dojo.storage.dashboard.StorageProvider, dojo.storage.StorageProvider);
|
||||
|
||||
dojo.lang.extend(dojo.storage.dashboard.StorageProvider, {
|
||||
storageOnLoad: function(){
|
||||
this.initialized = true;
|
||||
},
|
||||
|
||||
set: function(key, value, ns){
|
||||
if (ns && widget.system){
|
||||
widget.system("/bin/mkdir " + ns);
|
||||
var system = widget.system("/bin/echo " + value + " >" + ns + "/" + key);
|
||||
if(system.errorString){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return widget.setPreferenceForKey(dojo.json.serialize(value), key);
|
||||
},
|
||||
|
||||
get: function(key, ns){
|
||||
if (ns && widget.system) {
|
||||
var system = widget.system("/bin/cat " + ns + "/" + key);
|
||||
if(system.errorString){
|
||||
return "";
|
||||
}
|
||||
return system.outputString;
|
||||
}
|
||||
|
||||
return dojo.json.evalJson(widget.preferenceForKey(key));
|
||||
}
|
||||
});
|
||||
|
||||
dojo.storage.setProvider(new dojo.storage.dashboard.StorageProvider());
|
BIN
webapp/web/src/storage/storage_dialog.fla
Normal file
BIN
webapp/web/src/storage/storage_dialog.fla
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue