InputStream connectionsInputStream = importFile.getInputStream( connectionsEntry );
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
Set<ConnectionParameter> connectionParametersSet = ConnectionIO.load( connectionsInputStream );
for ( ConnectionParameter connectionParameter : connectionParametersSet )
{
connectionManager.addConnection( new Connection( connectionParameter ) );
}
}
// Loading the ConnectionFolders
ZipEntry connectionFoldersEntry = importFile.getEntry( "connectionFolders.xml" );
ConnectionFolder rootConnectionFolder = null;
if ( connectionFoldersEntry != null )
{
InputStream connectionFoldersInputStream = importFile.getInputStream( connectionFoldersEntry );
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
Set<ConnectionFolder> connectionFoldersSet = ConnectionIO
.loadConnectionFolders( connectionFoldersInputStream );
for ( ConnectionFolder connectionFolder : connectionFoldersSet )
{
if ( !"0".equals( connectionFolder.getId() ) )
{
connectionFolderManager.addConnectionFolder( connectionFolder );
}
else
{
rootConnectionFolder = connectionFolder;
}
}
// Root ConnectionFolder must be the last one to be loaded
if ( rootConnectionFolder != null )
{
ConnectionFolder realRootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
// Adding subfolders
List<String> realSubFolderIds = realRootConnectionFolder.getSubFolderIds();
for ( String subFolderId : rootConnectionFolder.getSubFolderIds() )
{
if ( !realSubFolderIds.contains( subFolderId ) )
{
realRootConnectionFolder.addSubFolderId( subFolderId );
}
}
// Adding connections
List<String> realConnectionIds = realRootConnectionFolder.getConnectionIds();
for ( String connectionId : rootConnectionFolder.getConnectionIds() )
{
if ( !realConnectionIds.contains( connectionId ) )
{
realRootConnectionFolder.addConnectionId( connectionId );
}
}
}
}
// Loading the BrowserConnections
ZipEntry browserConnectionsEntry = importFile.getEntry( "browserconnections.xml" );
if ( browserConnectionsEntry != null )
{
InputStream browserConnectionsInputStream = importFile.getInputStream( browserConnectionsEntry );
Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
Map<String, IBrowserConnection> connectionsMap = new HashMap<String, IBrowserConnection>();
for ( int i = 0; i < connections.length; i++ )
{
Connection connection = connections[i];
BrowserConnection browserConnection = new BrowserConnection( connection );
connectionsMap.put( connection.getId(), browserConnection );
}
BrowserConnectionIO.load( browserConnectionsInputStream, connectionsMap );
}
}