diff options
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/server/ApiServer.java')
-rw-r--r-- | src/main/java/org/openslx/imagemaster/server/ApiServer.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java index 53ddc71..ab1b88a 100644 --- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java +++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java @@ -7,8 +7,10 @@ import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.imagemaster.App; import org.openslx.imagemaster.Globals; +import org.openslx.imagemaster.db.DbImage; import org.openslx.imagemaster.db.DbSatellite; import org.openslx.imagemaster.ftp.ImageProcessor; +import org.openslx.imagemaster.ftp.MasterFtpServer; import org.openslx.imagemaster.serversession.ServerAuthenticator; import org.openslx.imagemaster.serversession.ServerSession; import org.openslx.imagemaster.serversession.ServerSessionManager; @@ -103,7 +105,7 @@ public class ApiServer } // create new user - FtpCredentials ftpCredentials = App.ftpServer.addUser( serverSessionId ); + FtpCredentials ftpCredentials = App.ftpServer.addUser( serverSessionId , MasterFtpServer.Mode.UPLOADING, ""); if ( ftpCredentials == null ) { log.error( "Could not create ftp credentials" ); @@ -111,7 +113,7 @@ public class ApiServer } try { - ImageProcessor.addImageDataToProcess( imageDescription, ftpCredentials.username ); + ImageProcessor.addImageDataToProcess( imageDescription, ftpCredentials.username, ftpCredentials.password ); } catch (ImageDataException e) { App.ftpServer.removeUser( serverSessionId ); throw new ImageDataException( ImageDataError.INVALID_DATA, e.getMessage() ); @@ -205,4 +207,23 @@ public class ApiServer return true; } + public static FtpCredentials getImage( String uuid, String serverSessionId ) throws AuthorizationException, ImageDataException + { + if ( ServerSessionManager.getSession( serverSessionId ) == null ) { + throw new AuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "No valid serverSessionData" ); + } + + // check if image exists + DbImage image = DbImage.getImageByUUID( uuid ); + + if (image == null) throw new ImageDataException( ImageDataError.UNKNOWN_IMAGE, "No image found with uuid '" + uuid + "'"); + + FtpCredentials ftpCredentials = App.ftpServer.addUser( serverSessionId, MasterFtpServer.Mode.DOWNLOADING, image.imagePath ); + + // TODO: what is happening here? + if (ftpCredentials == null) return null; + + return ftpCredentials; + } + } |