diff options
author | Nils Schwabe | 2014-04-28 18:18:59 +0200 |
---|---|---|
committer | Nils Schwabe | 2014-04-28 18:18:59 +0200 |
commit | 287ad92152c530b400a5405a4672a41d92e4d368 (patch) | |
tree | 42dcb2c698672ae371d70a81ea5c49f3280db9c6 /src/main/java/org/openslx/imagemaster/server | |
parent | Add remove image from process list (when user gets deleted after timeout) (diff) | |
download | masterserver-287ad92152c530b400a5405a4672a41d92e4d368.tar.gz masterserver-287ad92152c530b400a5405a4672a41d92e4d368.tar.xz masterserver-287ad92152c530b400a5405a4672a41d92e4d368.zip |
Add ftp users and images in processing list are remembered
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/server')
-rw-r--r-- | src/main/java/org/openslx/imagemaster/server/ApiServer.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java index 31bb712..4080f75 100644 --- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java +++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java @@ -167,35 +167,32 @@ public class ApiServer /** * Tell the masterserver that the image upload finished. * - * @param serverSessionId The session id of the hs/uni server + * @param ftpUser the user that was used to upload * @param imageDescription the description of the uploaded image * @return if nothing went wrong * @throws AuthorizationException if no valid session exists */ - public static boolean finishedUpload( String serverSessionId, - ImageData imageDescription ) throws AuthorizationException + public static boolean finishedUpload( String ftpUser, ImageData imageDescription ) { - // check if valid session exists - if ( ServerSessionManager.getSession( serverSessionId ) == null ) { - throw new AuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "No valid serverSessionData" ); + // check if user is valid + synchronized ( App.ftpServer.users ) { + if (!App.ftpServer.users.containsKey( ftpUser )) return false; } - + // process the image - String username = App.ftpServer.getCredentialsFromSessionId( serverSessionId ).username; - - File userDirectory = new File( Globals.getPropertyString( Globals.PropString.FTPBASEDIR ) + "/" + username ); + File userDirectory = new File( Globals.getPropertyString( Globals.PropString.FTPBASEDIR ) + "/" + ftpUser ); File[] list = userDirectory.listFiles(); if ( list.length != 1 ) return false; - log.info( username + " is done with upload" ); + log.info( ftpUser + " is done with upload" ); - ImageProcessor.processImageAfterUpload( username, list[0].getName() ); + ImageProcessor.processImageAfterUpload( ftpUser, list[0].getName() ); // remove user that is not needed anymore - App.ftpServer.removeUser( serverSessionId ); - log.info( "Removed user: " + username ); + App.ftpServer.removeUser( ftpUser ); + log.info( "Removed user: " + ftpUser ); return true; } |