Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Orion » Retrieve Files from other Domain
Retrieve Files from other Domain [message #991179] Mon, 17 December 2012 10:46 Go to next message
Marc Gille is currently offline Marc Gille
Messages: 16
Registered: May 2011
Location: Frankfurt
Junior Member
I had asked:

I am running a site (let say on localhost:8080) hosting an editor which in turn is accessible from ORION (let say running on localhost:9090) via a corresponding plugin.

This editor requires JS access to the Orion server.

Using Ajax and the ORION Server API to get files from Orion editor will result not entirely surprising - in "cannot load http://localhost:9090/file/motu/Test/CustomerOnboarding.xpdl. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin."

Simon Kaegi kindly responded offline:

1) Have a copy of the Orion plugin registry loaded in your page
2) Have the file plugin from localhost:9090/plugins/fileClientPlugin.html installed in your PM's plugin registry
3) You then can access the files and their contents using the Orion File Service API - http://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Core_client_services#orion.core.file - the File Client Plugin will handle the Ajax details

Question in turn:

Is there any coding example/documentation on how to do 1.)-3.).
Re: Retrieve Files from other Domain [message #991182 is a reply to message #991179] Mon, 17 December 2012 11:05 Go to previous messageGo to next message
Marc Gille is currently offline Marc Gille
Messages: 16
Registered: May 2011
Location: Frankfurt
Junior Member
May be I should be more precise with my question:

Are there any coding examples showing which JS modules to load and how loading the fileClientPlugin.html can be performed programmatically?

3.) seems straightforward.
Re: Retrieve Files from other Domain [message #991463 is a reply to message #991182] Wed, 19 December 2012 05:46 Go to previous message
Marc Gille is currently offline Marc Gille
Messages: 16
Registered: May 2011
Location: Frankfurt
Junior Member
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);
									});
				};
Previous Topic:Commit failed. Ref must be HEAD and is HEAD
Next Topic:is there a debug plugin available for eclipse orion ?
Goto Forum:
  


Current Time: Mon Apr 21 03:17:04 EDT 2014

Powered by FUDForum. Page generated in 0.01898 seconds