Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [geclipse-dev] File Transfer

Hi Pod,

> Should that work? I just get the File Store with that Uri and should
print > out all children = all dirs and files?   

No, that will not work, forgot about this, sorry, my fault.

So let me give a more detailed and more reliable description of how you
can access remote files/directories with g-Eclipse.

Basically there is an element in our model that represents any remote
file/folder, i.e. IGridConnectionElement. And it is in fact much better
to work with this than to directly work with the wrapper EFS
implementation. In fact the IGridConnectionElement internally makes use
of the wrapper EFS.

So now the question is how to create such a connection. Actually there
are two ways. You may either create a local or a global connection.
Local connections have to be created within a project, very similar to a
project folder or a JSDLJobDescription. The code to create such a local
connection would be:

IFolder folder =
*some_folder_in_a_project_that_will_be_linked_to_the_connection*;
URI slaveURI = *your_uri*;
GEclipseURI geclURI = new GEclipseURI( slaveURI );
folder.createLink( geclURI.toMasterURI(), IResource.ALLOW_MISSING_LOCAL,
null );

Now the grid model (asynchronously) creates the IGridConnectionElement
for you that can be accessed with

IGridConnectionElement connection = ( IGridConnectionElement )
GridModel.getRoot().findElement( folder );

Since the element is created asynchronously it may not be there right
after the folder linking and you rather would have to wait for it to
appear.

Here is the code for creating a global connection:

URI slaveURI = *your_uri*;
GEclipseURI geclURI = new GEclipseURI( slaveURI );
IGridPreferences preferences = GridModel.getPreferences();
preferences.createGlobalConnection( name, geclURI.toMasterURI() );

To now get access to a global connection you may make use of the
connection manager (which holds links to ALL formerly defined
connections):

IGridConnectionManager cManager = GridModel.getConnectionManager();

Now from the connection manager there are several possibilities to get
your connection(s). You could either use getGlobalConnections() to get a
list of only global connections or getChildren() to get a list of all
connections or even findChild( String name ) to get a specific
connection with a specific name.

Finally there is a last method to create a connection element. This has
to be handled with care since it only creates a temporary connection:

URI slaveURI = *your_uri*;
GEclipseURI geclURI = new GEclipseURI( slaveURI );
IGridPreferences preferences = GridModel.getPreferences();
IGridConnectionElement connection =
preferences.createTemporaryConnection( geclURI.toMasterURI() );

There you'll directly get the connection element back without having to
search for it. Nevertheless this connection does only live as long as
createTemporaryConnection is not called again since this would overwrite
the formerly created temp connection.

Note that all these methods need a workspace!

Hope that helps (and I did not forget about something now ;-),

Mathias


Back to the top