From 397af7dbf782e39809b78074699c3a125412e62f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 2 Oct 2014 18:50:15 +0200 Subject: Implement API methods getPublicImages, getOrganizations --- .../org/openslx/imagemaster/db/DbSatellite.java | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/main/java/org/openslx/imagemaster/db/DbSatellite.java') 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 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; -- cgit v1.2.3-55-g7522