71 lines
1.6 KiB
Java
71 lines
1.6 KiB
Java
|
/**
|
||
|
*
|
||
|
*/
|
||
|
package org.gcube.portlets.user.workspace;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.InputStream;
|
||
|
|
||
|
import org.apache.commons.io.IOUtils;
|
||
|
import org.gcube.common.core.scope.GCUBEScope;
|
||
|
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.Workspace;
|
||
|
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ExternalFile;
|
||
|
import org.gcube.portlets.user.homelibrary.jcr.repository.external.GCUBEStorage;
|
||
|
|
||
|
/**
|
||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||
|
* @Jun 18, 2013
|
||
|
*
|
||
|
*/
|
||
|
public class DonwloadServletTest {
|
||
|
|
||
|
public static void main(String[] args) {
|
||
|
|
||
|
InputStream is = null;
|
||
|
|
||
|
System.out.println("start");
|
||
|
|
||
|
is = GCUBEStorage.getRemoteFile("/Home/francesco.mangiacrapa/Workspace284ee688-e6fb-4080-bbcb-cc7c8cc5c381");
|
||
|
|
||
|
try {
|
||
|
|
||
|
// Workspace ws = HomeLibrary
|
||
|
// .getHomeManagerFactory()
|
||
|
// .getHomeManager()
|
||
|
// .getHome("francesco.mangiacrapa",
|
||
|
// GCUBEScope.getScope("/gcube/devsec"))
|
||
|
// .getWorkspace();
|
||
|
// //
|
||
|
// ExternalFile f = (ExternalFile) ws.getItem("8ad4e104-0f34-413e-a88c-e754a81104e7");
|
||
|
//
|
||
|
FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||
|
// // byte[] buffer = new byte[1024];
|
||
|
// // int len;
|
||
|
// // while ((len = is.read(buffer)) != -1) {
|
||
|
// // out.write(buffer, 0, len);
|
||
|
// // }
|
||
|
//
|
||
|
|
||
|
|
||
|
// is = f.getData();
|
||
|
|
||
|
|
||
|
IOUtils.copy(is, out);
|
||
|
is.close();
|
||
|
|
||
|
out.close();
|
||
|
|
||
|
// System.out.println("Sleeping");
|
||
|
// Thread.sleep(20000);
|
||
|
// System.out.println("Alive");
|
||
|
|
||
|
System.out.println("end");
|
||
|
} catch (Exception e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|