src/org/nixos/disnix/client/DisnixInterface.java
/**
	 * Retrieves a set of snapshots from the remote machine.
	 * 
	 * @param snapshots Absolute paths to the snapshots to retrieve
	 * @return Path to a temp directory containing the retrieved snapshots
	 * @throws AxisFault If an error occurs with the transport
	 * @throws IOException If an error occurs with writing the snapshot
	 * @throws FileNotFoundException If the file cannot be found
	 */
Retrieves a set of snapshots from the remote machine.


Retrieves a set of snapshots from the remote machine .
public String exportRemoteSnapshots(String[] snapshots) throws AxisFault, IOException, FileNotFoundException
	{
		try
		{	
			File tempDir = File.createTempFile("disnix_snapshot_", null);
			tempDir.delete();
			tempDir.mkdir();
			for(int i = 0; i < snapshots.length; i++)
			{
				/* Retrieves the absolute paths to the snapshots */
				String[] paths;
				{
					QName operation = new QName(NAME_SPACE, "exportRemoteSnapshotPaths");
					Object[] args = { snapshots[i] };
					Class<?>[] returnTypes = { String[].class };
					Object[] response = serviceClient.invokeBlocking(operation, args, returnTypes);
					paths = (String[])response[0];
				}
				/* Fetch the snapshots themselves */
				DataHandler[] dataHandlers;
				{
					QName operation = new QName(NAME_SPACE, "exportRemoteSnapshots");
					Object[] args = { snapshots[i] };
					Class<?>[] returnTypes = { DataHandler[].class };
					Object[] response = serviceClient.invokeBlocking(operation, args, returnTypes);
					dataHandlers = (DataHandler[])response[0];
				}	
				String relativePath = paths[i].substring(snapshots[i].length());
				String snapshotName = new File(snapshots[i]).getName();
				File targetFile = new File(tempDir.getAbsolutePath() + File.separator + snapshotName + File.separator + relativePath);
				if(targetFile.getParentFile() != null) 
					targetFile.getParentFile().mkdirs();
				FileOutputStream fos = new FileOutputStream(targetFile);
				dataHandlers[i].writeTo(fos);
				fos.flush();
				fos.close();
			}
			/* Return the path to the tempdir containing the retrieved snapshot */
			return tempDir.getAbsolutePath();
		}
		catch(AxisFault ex)
		{
			throw ex;
		}
		finally
		{
			serviceClient.cleanup();
			serviceClient.cleanupTransport();
		}
	}
public String exportRemoteSnapshots ( String [ ] snapshots ) throws AxisFault , IOException , FileNotFoundException { try { File tempDir = File . createTempFile ( "disnix_snapshot_" , null ) ; tempDir . delete ( ) ; tempDir . mkdir ( ) ; for ( int i = 0 ; i < snapshots . length ; i ++ ) { /* Retrieves the absolute paths to the snapshots */ String [ ] paths ; { QName operation = new QName ( NAME_SPACE , "exportRemoteSnapshotPaths" ) ; Object [ ] args = { snapshots [ i ] } ; Class < ? > [ ] returnTypes = { String [ ] . class } ; Object [ ] response = serviceClient . invokeBlocking ( operation , args , returnTypes ) ; paths = ( String [ ] ) response [ 0 ] ; } /* Fetch the snapshots themselves */ DataHandler [ ] dataHandlers ; { QName operation = new QName ( NAME_SPACE , "exportRemoteSnapshots" ) ; Object [ ] args = { snapshots [ i ] } ; Class < ? > [ ] returnTypes = { DataHandler [ ] . class } ; Object [ ] response = serviceClient . invokeBlocking ( operation , args , returnTypes ) ; dataHandlers = ( DataHandler [ ] ) response [ 0 ] ; } String relativePath = paths [ i ] . substring ( snapshots [ i ] . length ( ) ) ; String snapshotName = new File ( snapshots [ i ] ) . getName ( ) ; File targetFile = new File ( tempDir . getAbsolutePath ( ) + File . separator + snapshotName + File . separator + relativePath ) ; if ( targetFile . getParentFile ( ) != null ) targetFile . getParentFile ( ) . mkdirs ( ) ; FileOutputStream fos = new FileOutputStream ( targetFile ) ; dataHandlers [ i ] . writeTo ( fos ) ; fos . flush ( ) ; fos . close ( ) ; } /* Return the path to the tempdir containing the retrieved snapshot */ return tempDir . getAbsolutePath ( ) ; } catch ( AxisFault ex ) { throw ex ; } finally { serviceClient . cleanup ( ) ; serviceClient . cleanupTransport ( ) ; } }
Retrieves a set of snapshots from the remote machine.
Retrieves a set of snapshots from the remote machine .
// If the file is part of a directory then create it first