From 121a858846572418133d5adf9167f00f47d0f6ce Mon Sep 17 00:00:00 2001 From: Björn Hagemeister Date: Mon, 20 Oct 2014 16:10:53 +0200 Subject: Implemented updateAddress - method. --- src/main/java/org/openslx/imagemaster/db/DbSatellite.java | 7 +++++++ src/main/java/org/openslx/imagemaster/server/ApiServer.java | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java index f882977..7a6ef2f 100644 --- a/src/main/java/org/openslx/imagemaster/db/DbSatellite.java +++ b/src/main/java/org/openslx/imagemaster/db/DbSatellite.java @@ -129,4 +129,11 @@ public class DbSatellite return publickey; } + public void updateAddress( String address, String organization ) + { + this.address = address; + this.organizationId = organization; + MySQL.update( "UPDATE satellite SET address = ? WHERE organizationid = ?", address, organization); + } + } diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java index e265045..5a88e8d 100644 --- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java +++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java @@ -236,9 +236,17 @@ public class ApiServer public static boolean updateSatelliteAddress( String serverSessionId, String address ) throws AuthorizationException { - if ( ServerSessionManager.getSession( serverSessionId ) == null ) + ServerSession session = ServerSessionManager.getSession( serverSessionId ); + if ( session == null ) throw new AuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "No valid serverSessionId" ); - // TODO: Implement + String organization = session.getOrganization(); + DbSatellite currentSatellite = DbSatellite.fromOrganizationId( organization ); + if (currentSatellite == null) { + // TODO: error. + } else { + currentSatellite.updateAddress(address, organization); + return true; + } return false; } } -- cgit v1.2.3-55-g7522