added FTP Maanager
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@90272 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3d0cad18bd
commit
05c63f1d30
|
@ -7,6 +7,7 @@ import java.io.BufferedInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -32,6 +33,7 @@ public class FTPManager {
|
|||
*/
|
||||
private static String RUNTIME_RESOURCE_NAME = "SocialPortalStorage";
|
||||
private static String CATEGORY_NAME = "FTPServer";
|
||||
private static String UPLOAD_FOLDER_NAME = "previews";
|
||||
|
||||
private static FTPManager singleton;
|
||||
|
||||
|
@ -65,7 +67,7 @@ public class FTPManager {
|
|||
String user = "";
|
||||
String pwd = "";
|
||||
String httpBaseURL = "";
|
||||
String fileName = UUID.randomUUID() + "." + imageExtension.toString().toLowerCase();
|
||||
String fileName = UPLOAD_FOLDER_NAME + "/" + UUID.randomUUID() + "." + imageExtension.toString().toLowerCase();
|
||||
try {
|
||||
ServiceEndpoint res = endPoint;
|
||||
AccessPoint ac = res.profile().accessPoints().iterator().next();
|
||||
|
@ -99,11 +101,18 @@ public class FTPManager {
|
|||
_log.error( "Problem disconnecting from FTP server" );
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder().append(httpBaseURL).append("/").append(fileName);
|
||||
StringBuilder sb = new StringBuilder().append(httpBaseURL).append(fileName);
|
||||
_log.info( "Uploaded file FTP server: http url: " + sb );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getBaseURL() throws Exception {
|
||||
String httpBaseURL = endPoint.profile().runtime().hostedOn()+UPLOAD_FOLDER_NAME+"/";
|
||||
if (httpBaseURL != null) {
|
||||
return httpBaseURL;
|
||||
}
|
||||
else throw new ServiceConfigurationError("Could not find a valid FTP Server in the infrastructure");
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return the runtime resource of the FTP Server node
|
||||
|
|
Loading…
Reference in New Issue