summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-02 18:50:15 +0200
committerSimon Rettberg2014-10-02 18:50:15 +0200
commit397af7dbf782e39809b78074699c3a125412e62f (patch)
tree8276806175cb73a476436fe1228cae080bac95c4
parentMerge branch 'master' of dnbd3:bwlp/masterserver (diff)
downloadmasterserver-397af7dbf782e39809b78074699c3a125412e62f.tar.gz
masterserver-397af7dbf782e39809b78074699c3a125412e62f.tar.xz
masterserver-397af7dbf782e39809b78074699c3a125412e62f.zip
Implement API methods getPublicImages, getOrganizations
-rw-r--r--src/main/java/org/openslx/imagemaster/App.java3
-rw-r--r--src/main/java/org/openslx/imagemaster/Globals.java4
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbImage.java137
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbSatellite.java31
-rw-r--r--src/main/java/org/openslx/imagemaster/db/DbUser.java16
-rw-r--r--src/main/java/org/openslx/imagemaster/db/LdapUser.java4
-rw-r--r--src/main/java/org/openslx/imagemaster/server/ApiServer.java29
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java16
-rw-r--r--src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java2
-rw-r--r--src/main/java/org/openslx/imagemaster/serversession/ServerAuthenticator.java8
-rw-r--r--src/main/java/org/openslx/imagemaster/session/Session.java2
-rw-r--r--src/main/java/org/openslx/imagemaster/session/User.java10
-rw-r--r--src/main/java/org/openslx/imagemaster/thrift/server/ImageServerHandler.java29
13 files changed, 150 insertions, 141 deletions
diff --git a/src/main/java/org/openslx/imagemaster/App.java b/src/main/java/org/openslx/imagemaster/App.java
index 5a325ba..7a6a1ad 100644
--- a/src/main/java/org/openslx/imagemaster/App.java
+++ b/src/main/java/org/openslx/imagemaster/App.java
@@ -29,9 +29,6 @@ public class App
// Init logging
log.info( "Starting Application" );
- // Init the properties and load uploading images from database
- Globals.init();
-
// Create binary listener
Thread t;
t = new Thread( new BinaryListener(), "BinaryListener" );
diff --git a/src/main/java/org/openslx/imagemaster/Globals.java b/src/main/java/org/openslx/imagemaster/Globals.java
index 78ecd70..8933c00 100644
--- a/src/main/java/org/openslx/imagemaster/Globals.java
+++ b/src/main/java/org/openslx/imagemaster/Globals.java
@@ -24,10 +24,6 @@ public class Globals
*/
public final static int blockSize = 16 * 1024 * 1024;
- public static void init()
- {
- }
-
/**
* Loads the properties from config/global.properties
*/
diff --git a/src/main/java/org/openslx/imagemaster/db/DbImage.java b/src/main/java/org/openslx/imagemaster/db/DbImage.java
index 5070c0d..ca3265f 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbImage.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbImage.java
@@ -15,19 +15,19 @@ public class DbImage
{
public final String uuid;
- public final int imageVersion;
- public final String imageName;
+ public final int revision;
+ public final String title;
/**
* Relative path of image file (relative to Globals.getImageDir())
*/
- public final String imagePath;
- public final long imageCreateTime;
- public final long imageUpdateTime;
- public final int imageOwnerId;
- public final String contentOperatingSystem;
+ public final String relativePath;
+ public final long createTime;
+ public final long updateTime;
+ public final int ownerId;
+ public final String ownerLogin;
+ public final String operatingSystem;
public final boolean isValid;
public final boolean isDeleted;
- public final String shortDescription;
public final String longDescription;
public final long fileSize;
public final int[] blockStatus;
@@ -35,37 +35,37 @@ public class DbImage
public DbImage( String uuid )
{
this.uuid = uuid;
- this.imageVersion = 0;
- this.imageName = null;
- this.imagePath = null;
- this.imageCreateTime = 0;
- this.imageUpdateTime = 0;
- this.imageOwnerId = 0;
- this.contentOperatingSystem = null;
+ this.revision = 0;
+ this.title = null;
+ this.relativePath = null;
+ this.createTime = 0;
+ this.updateTime = 0;
+ this.ownerId = 0;
+ this.ownerLogin = null;
+ this.operatingSystem = null;
this.isValid = false;
this.isDeleted = false;
- this.shortDescription = null;
this.longDescription = null;
this.fileSize = 0;
this.blockStatus = null;
}
public DbImage( String uuid, int imageVersion, String imageName, String imagePath,
- long imageCreateTime, long imageUpdateTime, int imageOwnerId, String contentOperatingSystem,
- boolean isValid, boolean isDeleted, String shortDescription, String longDescription,
+ long imageCreateTime, long imageUpdateTime, int imageOwnerId, String imageOwnerLogin, String contentOperatingSystem,
+ boolean isValid, boolean isDeleted, String longDescription,
long fileSize, String missingBlocksList )
{
this.uuid = uuid;
- this.imageVersion = imageVersion;
- this.imageName = imageName;
- this.imagePath = imagePath;
- this.imageCreateTime = imageCreateTime;
- this.imageUpdateTime = imageUpdateTime;
- this.imageOwnerId = imageOwnerId;
- this.contentOperatingSystem = contentOperatingSystem;
+ this.revision = imageVersion;
+ this.title = imageName;
+ this.relativePath = imagePath;
+ this.createTime = imageCreateTime;
+ this.updateTime = imageUpdateTime;
+ this.ownerId = imageOwnerId;
+ this.ownerLogin = imageOwnerLogin;
+ this.operatingSystem = contentOperatingSystem;
this.isValid = isValid;
this.isDeleted = isDeleted;
- this.shortDescription = shortDescription;
this.longDescription = longDescription;
this.fileSize = fileSize;
@@ -106,19 +106,18 @@ public class DbImage
for ( int i = 0; i < numBlocks; i++ ) {
missingBlocksList = missingBlocksList + String.valueOf( i ) + ";";
}
- DbUser user = DbUser.forLogin( imageData.imageOwner );
+ DbUser user = DbUser.forLogin( imageData.ownerLogin );
int owner = 0;
- if (user != null)
+ if ( user != null )
owner = user.userId;
return MySQL
.update(
- "INSERT INTO images (UUID, image_version, image_name, image_path, image_createTime, image_updateTime, image_owner, content_operatingSystem, status_isValid, status_isDeleted, image_shortDescription, image_longDescription, fileSize, missingBlocks) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- imageData.uuid, imageData.imageVersion, imageData.imageName, filepath,
- imageData.imageCreateTime, imageData.imageUpdateTime, owner,
- imageData.contentOperatingSystem, imageData.statusIsValid,
- imageData.statusIsDeleted, imageData.imageShortDescription,
- imageData.imageLongDescription, imageData.fileSize,
+ "INSERT INTO image (uuid, revision, title, path, createtime, updatetime, ownerid, operatingsystem, isvalid, isdeleted, description, filesize, missingblocks) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ imageData.uuid, imageData.revision, imageData.title, filepath,
+ imageData.createTime, imageData.updateTime, owner,
+ imageData.operatingSystem, imageData.isValid,
+ imageData.isDeleted, imageData.description, imageData.fileSize,
missingBlocksList );
}
@@ -136,24 +135,7 @@ public class DbImage
missingBlocksList = missingBlocksList + String.valueOf( block ) + ";";
}
}
- return MySQL.update( "UPDATE images SET images.missingBlocks = ? WHERE images.UUID = ?", missingBlocksList, uuid );
- }
-
- /**
- * Updates the database with a new version of an image and its missing blocks.
- *
- * @param version
- * @param amountBlocks
- */
- public void updateVersion( int version, int amountBlocks )
- {
- if ( version <= 0 || amountBlocks <= 0 )
- return;
- String missingBlocksList = "";
- for ( int i = 0; i < amountBlocks; i++ ) {
- missingBlocksList = missingBlocksList + String.valueOf( i ) + ";";
- }
- MySQL.update( "UPDATE images SET images.missingBlocks, images.version VALUES (?, ?)", missingBlocksList, version );
+ return MySQL.update( "UPDATE image SET image.missingblocks = ? WHERE image.uuid = ?", missingBlocksList, uuid );
}
/**
@@ -163,7 +145,7 @@ public class DbImage
*/
public int delete()
{
- return MySQL.update( "UPDATE images SET images.isDeleted=? WHERE images.UUID=?", true, uuid );
+ return MySQL.update( "UPDATE image SET image.isdeleted = 1 WHERE image.uuid = ?", this.uuid );
}
/**
@@ -176,8 +158,10 @@ public class DbImage
return MySQL
.findAll(
DbImage.class,
- "SELECT images.UUID, images.image_version, images.image_name, images.image_path, images.image_createTime, images.image_updateTime, images.image_owner, images.content_operatingSystem, images.status_isValid, images.status_isDeleted, images.image_shortDescription, images.image_longDescription, images.timestamp, images.fileSize, images.token, images.missingBlocks, images.serverSessionId FROM images WHERE missingBlocks != ?",
- "" );
+ "SELECT image.uuid, image.revision, image.title, image.path, image.createtime, image.updatetime, image.ownerid, user.login, image.operatingsystem, image.isvalid, image.isdeleted, image.description, image.filesize, image.missingblocks"
+ + " FROM image"
+ + " INNER JOIN user ON (image.ownerid = user.userid)"
+ + " WHERE missingBlocks != ''" );
}
/**
@@ -191,11 +175,34 @@ public class DbImage
return MySQL
.findUniqueOrNull(
DbImage.class,
- "SELECT images.UUID, images.image_version, images.image_name, images.image_path, images.image_createTime, images.image_updateTime, images.image_owner, images.content_operatingSystem, images.status_isValid, images.status_isDeleted, images.image_shortDescription, images.image_longDescription, images.fileSize, images.missingBlocks FROM images WHERE uuid = ?",
+ "SELECT image.uuid, image.revision, image.title, image.path, image.createtime, image.updatetime, image.ownerid, user.login, image.operatingsystem, image.isvalid, image.isdeleted, image.description, image.filesize, image.missingblocks"
+ + " FROM image"
+ + " INNER JOIN user ON (image.ownerid = user.userid)"
+ + " WHERE uuid = ?",
uuid );
}
/**
+ * Return all public images as ImageData list, which can be directly
+ * used by the thrift API.
+ *
+ * @param start
+ * @param limit
+ * @return
+ */
+ public static List<ImageData> asImageDataList( int start, int limit )
+ {
+ return MySQL
+ .findAll(
+ ImageData.class,
+ "SELECT image.uuid, image.revision, image.title, image.createtime, image.updatetime, user.login, image.operatingsystem, image.isvalid, image.isdeleted, image.description, image.filesize"
+ + " FROM image"
+ + " INNER JOIN user ON (image.ownerid = user.userid)"
+ + " ORDER BY uuid, revision"
+ + " LIMIT " + start + ", " + limit );
+ }
+
+ /**
* Creates an instance of the thrift ImageData class of this DbImage object.
*
* @return The corresponding image data
@@ -203,22 +210,22 @@ public class DbImage
public ImageData getImageData()
{
String owner = "unknown";
- DbUser user = DbUser.forLogin( this.imageOwnerId );
- if (user != null)
+ DbUser user = DbUser.forLogin( this.ownerId );
+ if ( user != null )
owner = user.getLogin();
- return new ImageData( this.uuid, this.imageVersion, this.imageName, this.imageCreateTime,
- this.imageUpdateTime, owner, this.contentOperatingSystem, this.isValid,
- this.isDeleted, this.shortDescription, this.longDescription, this.fileSize );
+ return new ImageData( this.uuid, this.revision, this.title, this.createTime,
+ this.updateTime, owner, this.operatingSystem, this.isValid,
+ this.isDeleted, this.longDescription, this.fileSize );
}
-
+
/**
* Get absolute path of this image
- *
+ *
* @return absolute path
*/
public String getAbsolutePath()
{
- return Globals.getImageDir() + "/" + this.imagePath;
+ return Globals.getImageDir() + "/" + this.relativePath;
}
-
+
}
diff --git a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
index a1c9b1a..d9c4366 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java
@@ -6,8 +6,10 @@ import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPublicKeySpec;
+import java.util.List;
import org.apache.log4j.Logger;
+import org.openslx.imagemaster.thrift.iface.OrganizationData;
/**
* Represents a satellite in the database.
@@ -32,8 +34,7 @@ public class DbSatellite
keyFact = kf;
}
- // needs to be public in order to be found by MySQL
- public DbSatellite( String organizationId, String address, String name, String prefix, String publickeyString )
+ public DbSatellite( String organizationId, String address, String name, String publickeyString )
{
this.organizationId = organizationId;
this.address = address;
@@ -56,23 +57,31 @@ public class DbSatellite
.findUniqueOrNull(
DbSatellite.class,
"SELECT satellite.organizationid, satellite.address, satellite.name, satellite.publickey FROM satellite"
- + " INNER JOIN satellite_suffix USING (organizationid)"
- + " WHERE satellite_suffix.suffix = ? LIMIT 1",
+ + " INNER JOIN satellite_suffix USING (organizationid)"
+ + " WHERE satellite_suffix.suffix = ? LIMIT 1",
suffix );
}
+ /**
+ * Return all known satellites/organizations as List of {@link OrganizationData}, which can be
+ * used directly by the thrift API.
+ *
+ * @return list of all known organizations/satellites
+ */
+ public static List<OrganizationData> asOrganizationDataList()
+ {
+ return MySQL.findAll( OrganizationData.class, "SELECT satellite.organizationid, satellite.name FROM satellite" );
+ }
+
public static DbSatellite fromPrefix( String prefix )
{
- /*
- return MySQL
- .findUniqueOrNull(
- DbSatellite.class,
- "SELECT satellite.organization, satellite.address, satellite.name, satellite.publickey FROM satellite WHERE satellite.prefix = ? LIMIT 1",
- prefix );
- */
return null;
}
+ /*
+ * Member methods
+ */
+
public String getAddress()
{
return address;
diff --git a/src/main/java/org/openslx/imagemaster/db/DbUser.java b/src/main/java/org/openslx/imagemaster/db/DbUser.java
index b822e4d..6d9fe0a 100644
--- a/src/main/java/org/openslx/imagemaster/db/DbUser.java
+++ b/src/main/java/org/openslx/imagemaster/db/DbUser.java
@@ -12,11 +12,11 @@ public class DbUser extends User
private static Logger log = Logger.getLogger( DbUser.class );
- public DbUser( int userId, String eppn, String password, String organizationId,
+ public DbUser( int userId, String login, String password, String organizationId,
String firstName, String lastName, String eMail,
String satelliteAddress )
{
- super( userId, eppn, password, organizationId, firstName, lastName, eMail,
+ super( userId, login, password, organizationId, firstName, lastName, eMail,
satelliteAddress );
}
@@ -33,9 +33,9 @@ public class DbUser extends User
return MySQL
.findUniqueOrNull(
DbUser.class,
- "SELECT user.userid, user.eppn, user.password, user.organizationid, user.firstname, user.lastname, user.email, satellite.address FROM user"
+ "SELECT user.userid, user.login, user.password, user.organizationid, user.firstname, user.lastname, user.email, satellite.address FROM user"
+ " LEFT JOIN satellite USING (organizationid)"
- + " WHERE user.eppn = ? LIMIT 1",
+ + " WHERE user.login = ? LIMIT 1",
login );
}
@@ -51,7 +51,7 @@ public class DbUser extends User
return MySQL
.findUniqueOrNull(
DbUser.class,
- "SELECT user.userid, user.eppn, user.password, user.organizationid, user.firstname, user.lastname, user.email, satellite.address FROM user"
+ "SELECT user.userid, user.login, user.password, user.organizationid, user.firstname, user.lastname, user.email, satellite.address FROM user"
+ " LEFT JOIN satellite USING (organizationid)"
+ " WHERE user.userid = ? LIMIT 1",
userid );
@@ -72,10 +72,10 @@ public class DbUser extends User
public static boolean insertOrUpdate( User user )
{
- log.debug( "Inserted user '" + user.eppn + "' into db." );
+ log.debug( "Inserted user '" + user.login + "' into db." );
MySQL.update(
- "INSERT INTO user (eppn, password, organizationid, firstname, lastname, email) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE password=VALUES(password), organizationid=VALUES(organizationid), firstname=VALUES(firstname), lastname=VALUES(lastname), email=VALUES(email)",
- user.eppn, user.password, user.organizationId, user.firstName, user.lastName, user.eMail );
+ "INSERT INTO user (login, password, organizationid, firstname, lastname, email) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE password=VALUES(password), organizationid=VALUES(organizationid), firstname=VALUES(firstname), lastname=VALUES(lastname), email=VALUES(email)",
+ user.login, user.password, user.organizationId, user.firstName, user.lastName, user.eMail );
return false;
}
diff --git a/src/main/java/org/openslx/imagemaster/db/LdapUser.java b/src/main/java/org/openslx/imagemaster/db/LdapUser.java
index b026e7e..988f43a 100644
--- a/src/main/java/org/openslx/imagemaster/db/LdapUser.java
+++ b/src/main/java/org/openslx/imagemaster/db/LdapUser.java
@@ -150,7 +150,7 @@ public class LdapUser extends User
/**
* Login user locally if external Ldap server is not available
- * @param eppn Must be in form "username@organization"
+ * @param login Must be in form "username@organization"
* @param password The user's password
*/
private static LdapUser localLogin( String login, String password )
@@ -162,7 +162,7 @@ public class LdapUser extends User
if (!Sha512Crypt.verifyPassword( password, user.password )) return null;
// return ldapuser if valid
- return new LdapUser( user.userId, user.eppn, Sha512Crypt.Sha512_crypt( password, null, 0 ), user.organizationId, user.firstName,
+ return new LdapUser( user.userId, user.login, Sha512Crypt.Sha512_crypt( password, null, 0 ), user.organizationId, user.firstName,
user.lastName, user.eMail, user.satelliteAddress );
}
}
diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
index 6c5413f..aaad0db 100644
--- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java
+++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
@@ -3,7 +3,6 @@ package org.openslx.imagemaster.server;
import java.nio.ByteBuffer;
import java.util.List;
-import org.apache.thrift.TException;
import org.openslx.imagemaster.db.DbImage;
import org.openslx.imagemaster.db.DbSatellite;
import org.openslx.imagemaster.serverconnection.ImageProcessor;
@@ -25,8 +24,6 @@ import org.openslx.imagemaster.thrift.iface.ImageDataError;
import org.openslx.imagemaster.thrift.iface.ImageDataException;
import org.openslx.imagemaster.thrift.iface.InvalidTokenException;
import org.openslx.imagemaster.thrift.iface.OrganizationData;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationError;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.imagemaster.thrift.iface.ServerSessionData;
import org.openslx.imagemaster.thrift.iface.SessionData;
import org.openslx.imagemaster.thrift.iface.UploadData;
@@ -121,16 +118,16 @@ public class ApiServer
* @throws ServerAuthenticationException when organization is invalid/unknown
*/
public static ByteBuffer startServerAuthentication( String organizationId )
- throws ServerAuthenticationException
+ throws AuthenticationException
{
if ( organizationId == null || organizationId.isEmpty() )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Empty organization" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Empty organization" );
DbSatellite satellite = DbSatellite.fromOrganizationId( organizationId );
if ( satellite == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Unknown organization: '" + organizationId + "'" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Unknown organization: '" + organizationId + "'" );
if ( satellite.getPubkey() == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
+ throw new AuthenticationException( AuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
return ServerAuthenticator.startServerAuthentication( organizationId );
}
@@ -141,20 +138,18 @@ public class ApiServer
* @param challengeResponse the encrypted string
* @return session data iff the authentication was successful
* @throws AuthenticationException
- * @throws TException
*/
public static ServerSessionData serverAuthenticate( String organizationId,
- ByteBuffer challengeResponse ) throws ServerAuthenticationException,
- TException
+ ByteBuffer challengeResponse ) throws AuthenticationException
{
if ( organizationId == null || challengeResponse == null ) {
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Empty organization or challengeResponse" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Empty organization or challengeResponse" );
}
DbSatellite satellite = DbSatellite.fromOrganizationId( organizationId );
if ( satellite == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Unknown organization" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Unknown organization" );
if ( satellite.getPubkey() == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
+ throw new AuthenticationException( AuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
final ServerUser serverUser = ServerAuthenticator.serverAuthenticate( satellite, challengeResponse );
@@ -181,7 +176,11 @@ public class ApiServer
public static List<OrganizationData> getOrganizations()
{
- // TODO Auto-generated method stub
- return null;
+ return DbSatellite.asOrganizationDataList();
+ }
+
+ public static List<ImageData> getPublicImages( String sessionId, int page )
+ {
+ return DbImage.asImageDataList( page * 100, ( page + 1 ) * 100 );
}
}
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
index 81a3e75..1d627fc 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/ImageProcessor.java
@@ -57,11 +57,11 @@ public class ImageProcessor
throws UploadException, ImageDataException
{
// check image data
- if ( imageData.imageName == null || imageData.imageName.isEmpty() )
+ if ( imageData.title == null || imageData.title.isEmpty() )
throw new ImageDataException( ImageDataError.INVALID_DATA, "Image name not set." );
- if ( imageData.imageOwner == null || !DbUser.exists( imageData.imageOwner ) )
+ if ( imageData.ownerLogin == null || !DbUser.exists( imageData.ownerLogin ) )
throw new ImageDataException( ImageDataError.INVALID_DATA, "Invalid image owner." );
- if ( imageData.contentOperatingSystem == null || imageData.contentOperatingSystem.isEmpty() )
+ if ( imageData.operatingSystem == null || imageData.operatingSystem.isEmpty() )
throw new ImageDataException( ImageDataError.INVALID_DATA, "Content operating system not set." );
if ( imageData.fileSize <= 0 )
throw new ImageDataException( ImageDataError.INVALID_DATA, "File size is too small." );
@@ -71,7 +71,7 @@ public class ImageProcessor
final String uuid = imageData.uuid;
final String filepathRelative;
final CrcFile crcFile;
- if ( crcSums == null) {
+ if ( crcSums == null ) {
crcFile = null;
} else {
crcFile = new CrcFile( crcSums );
@@ -123,13 +123,13 @@ public class ImageProcessor
public static void removeFinishedUploads()
{
- for (Iterator<UploadingImage> it = uploadingImages.values().iterator(); it.hasNext(); ) {
+ for ( Iterator<UploadingImage> it = uploadingImages.values().iterator(); it.hasNext(); ) {
UploadingImage image = it.next();
- if (image.allBlocksValid()) {
+ if ( image.allBlocksValid() ) {
synchronized ( imagesToCheck ) {
imagesToCheck.remove( image.getUuid() );
image.updateMissingBlocks( null );
- }
+ }
it.remove();
}
}
@@ -163,7 +163,7 @@ public class ImageProcessor
*/
public static String generateFilepathOfImage( ImageData imageData )
{
- return generateFilePathOfImage( imageData.uuid, imageData.imageName, imageData.imageVersion );
+ return generateFilePathOfImage( imageData.uuid, imageData.title, imageData.revision );
}
public static String generateFilePathOfImage( String uuid, String imageName, int imageVersion )
diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
index fb3d3d9..46e6c91 100644
--- a/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
+++ b/src/main/java/org/openslx/imagemaster/serverconnection/UploadingImage.java
@@ -216,7 +216,7 @@ public class UploadingImage
@Override
public String toString()
{
- return "UUID: " + dbImage.uuid + ", filename " + dbImage.imagePath + "\nmissing blocks " + getAmountOfBlocksNeedingRequest() +
+ return "UUID: " + dbImage.uuid + ", filename " + dbImage.relativePath + "\nmissing blocks " + getAmountOfBlocksNeedingRequest() +
", number of blocks " + getNumberOfBlocks();
}
diff --git a/src/main/java/org/openslx/imagemaster/serversession/ServerAuthenticator.java b/src/main/java/org/openslx/imagemaster/serversession/ServerAuthenticator.java
index 4ec5acf..88697bf 100644
--- a/src/main/java/org/openslx/imagemaster/serversession/ServerAuthenticator.java
+++ b/src/main/java/org/openslx/imagemaster/serversession/ServerAuthenticator.java
@@ -8,8 +8,8 @@ import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.openslx.encryption.AsymEncryptionHandler;
import org.openslx.imagemaster.db.DbSatellite;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationError;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
+import org.openslx.imagemaster.thrift.iface.AuthenticationError;
+import org.openslx.imagemaster.thrift.iface.AuthenticationException;
import org.openslx.imagemaster.util.RandomString;
/**
@@ -53,7 +53,7 @@ public class ServerAuthenticator
* @throws TException
*/
public static ServerUser serverAuthenticate( DbSatellite satellite, ByteBuffer challengeResponse )
- throws ServerAuthenticationException
+ throws AuthenticationException
{
byte[] encryptedBytes = new byte[ challengeResponse.remaining() ];
challengeResponse.get( encryptedBytes );
@@ -61,7 +61,7 @@ public class ServerAuthenticator
AsymEncryptionHandler verifier = new AsymEncryptionHandler( satellite.getPubkey() );
if ( !verifier.verifyMessage( encryptedBytes, authenticatingServers.get( satellite.getOrganizationId() ) ) )
- throw new ServerAuthenticationException( ServerAuthenticationError.CHALLENGE_FAILED, "You failed the encryption challenge. private and public key don't seem to match." );
+ throw new AuthenticationException( AuthenticationError.CHALLENGE_FAILED, "You failed the encryption challenge. private and public key don't seem to match." );
log.info( "Server of organinzation " + satellite.getName() + " (" + satellite.getOrganizationId() + ") authenticated." );
diff --git a/src/main/java/org/openslx/imagemaster/session/Session.java b/src/main/java/org/openslx/imagemaster/session/Session.java
index 54a2757..f91a3ae 100644
--- a/src/main/java/org/openslx/imagemaster/session/Session.java
+++ b/src/main/java/org/openslx/imagemaster/session/Session.java
@@ -39,7 +39,7 @@ public class Session
public String getLogin()
{
- return user.eppn;
+ return user.login;
}
public String getFirstName()
diff --git a/src/main/java/org/openslx/imagemaster/session/User.java b/src/main/java/org/openslx/imagemaster/session/User.java
index bbbe8c7..a64ab5b 100644
--- a/src/main/java/org/openslx/imagemaster/session/User.java
+++ b/src/main/java/org/openslx/imagemaster/session/User.java
@@ -7,18 +7,18 @@ package org.openslx.imagemaster.session;
*/
public abstract class User
{
- public final String eppn, organizationId;
+ public final String login, organizationId;
public final String password;
public final String firstName, lastName;
public final String eMail;
public final String satelliteAddress;
public final int userId;
- protected User( int userId, String eppn, String password, String organization, String firstName, String lastName, String eMail,
+ protected User( int userId, String login, String password, String organization, String firstName, String lastName, String eMail,
String satelliteAddress )
{
this.userId = userId;
- this.eppn = eppn;
+ this.login = login;
this.organizationId = organization;
this.password = password;
this.firstName = firstName;
@@ -30,7 +30,7 @@ public abstract class User
@Override
public String toString()
{
- final StringBuilder sb = new StringBuilder( this.eppn );
+ final StringBuilder sb = new StringBuilder( this.login );
sb.append( " (" );
sb.append( this.organizationId );
sb.append( "): " );
@@ -48,7 +48,7 @@ public abstract class User
public String getLogin()
{
- return eppn;
+ return login;
}
}
diff --git a/src/main/java/org/openslx/imagemaster/thrift/server/ImageServerHandler.java b/src/main/java/org/openslx/imagemaster/thrift/server/ImageServerHandler.java
index fe878ce..3b9ffc1 100644
--- a/src/main/java/org/openslx/imagemaster/thrift/server/ImageServerHandler.java
+++ b/src/main/java/org/openslx/imagemaster/thrift/server/ImageServerHandler.java
@@ -3,8 +3,6 @@ package org.openslx.imagemaster.thrift.server;
import java.nio.ByteBuffer;
import java.util.List;
-import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
import org.openslx.imagemaster.server.ApiServer;
import org.openslx.imagemaster.thrift.iface.AuthenticationException;
import org.openslx.imagemaster.thrift.iface.AuthorizationException;
@@ -14,7 +12,6 @@ import org.openslx.imagemaster.thrift.iface.ImageDataException;
import org.openslx.imagemaster.thrift.iface.ImageServer;
import org.openslx.imagemaster.thrift.iface.InvalidTokenException;
import org.openslx.imagemaster.thrift.iface.OrganizationData;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.imagemaster.thrift.iface.ServerSessionData;
import org.openslx.imagemaster.thrift.iface.SessionData;
import org.openslx.imagemaster.thrift.iface.UploadData;
@@ -25,9 +22,8 @@ public class ImageServerHandler implements ImageServer.Iface
{
@Override
- public boolean ping() throws TException
+ public boolean ping()
{
- // Return false if service unavailable but running
return true;
}
@@ -47,53 +43,58 @@ public class ImageServerHandler implements ImageServer.Iface
@Override
public ByteBuffer startServerAuthentication( String organization )
- throws ServerAuthenticationException
+ throws AuthenticationException
{
return ApiServer.startServerAuthentication( organization );
}
@Override
public ServerSessionData serverAuthenticate( String organization,
- ByteBuffer challengeResponse ) throws AuthenticationException,
- TException
+ ByteBuffer challengeResponse ) throws AuthenticationException
{
return ApiServer.serverAuthenticate( organization, challengeResponse );
}
@Override
public UploadData submitImage( String serverSessionId, ImageData imageDescription, List<Integer> crcSums )
- throws AuthorizationException, ImageDataException, UploadException, TException
+ throws AuthorizationException, ImageDataException, UploadException
{
return ApiServer.submitImage( serverSessionId, imageDescription, crcSums );
}
@Override
- public DownloadData getImage( String serverSessionId, String uuid ) throws AuthorizationException, ImageDataException, TException
+ public DownloadData getImage( String serverSessionId, String uuid ) throws AuthorizationException, ImageDataException
{
return ApiServer.getImage( uuid, serverSessionId );
}
@Override
- public boolean isServerAuthenticated( String serverSessionId ) throws TException
+ public boolean isServerAuthenticated( String serverSessionId )
{
return ApiServer.isServerAuthenticated( serverSessionId );
}
@Override
- public List<OrganizationData> getOrganizations() throws TException
+ public List<OrganizationData> getOrganizations()
{
return ApiServer.getOrganizations();
}
@Override
- public List<UserInfo> findUser( String sessionId, String organizationId, String searchTerm ) throws TException
+ public List<UserInfo> findUser( String sessionId, String organizationId, String searchTerm )
{
return ApiServer.findUser( sessionId, organizationId, searchTerm );
}
@Override
- public boolean publishUser( String serverSessionId, UserInfo user ) throws TException
+ public boolean publishUser( String serverSessionId, UserInfo user )
{
return ApiServer.publishUser( serverSessionId, user );
}
+
+ @Override
+ public List<ImageData> getPublicImages( String sessionId, int page )
+ {
+ return ApiServer.getPublicImages( sessionId, page );
+ }
}