|
|
Re: Retrieve Files from other Domain [message #991463 is a reply to message #991182] |
Wed, 19 December 2012 05:46  |
Eclipse User |
|
|
|
I eventually got this working. Here is the approach for everybody who intends to load Orion-managed files from another web application:
Make sure that you can load the transient closure of orion/bootstrap.js (orion.core plugin) into your JS code. I did this with adding the corresponding JS files to a Utility plugin named 'orion' to allow requirejs to resolve dependencies. There may be other, more elegant ways.
Code to load the plugin and retrieve the file is below whereby
* uri is the file URI and
* Utils is a auxiliary class for logging. You may use console.log() instead.
bootstrap
.startup()
.then(
function(core) {
installPlugin = core.pluginRegistry
.installPlugin(
"http://localhost:9090/plugins/fileClientPlugin.html")
.then(
function(plugin) {
plugin
.start()
.then(
function() {
var fileService = core.serviceRegistry
.getService("orion.core.file");
fileService.read(uri).then(function(content){
modelManager.modelFiles["bla"] = data;
modelManager.uploadModelFileContent(
successCallback, errorCallback);
}, function(error){
Utils
.debug("Content retrieval failed:");
Utils
.debug(error);
});
},
function(error) {
Utils
.debug("Plugin Start failed:");
Utils
.debug(error);
});
},
function(error) {
Utils
.debug("Plugin Install failed:");
Utils.debug(error);
});
}, function(error) {
Utils.debug("Startup failed");
Utils.debug(error);
});
};
|
|
|
Powered by
FUDForum. Page generated in 0.04247 seconds