diff options
author | Björn Hagemeister | 2014-10-20 16:10:53 +0200 |
---|---|---|
committer | Björn Hagemeister | 2014-10-20 16:10:53 +0200 |
commit | 121a858846572418133d5adf9167f00f47d0f6ce (patch) | |
tree | 20e1708885bd72fe23510e23090d368778c4e5cb | |
parent | Update db dump (diff) | |
download | masterserver-121a858846572418133d5adf9167f00f47d0f6ce.tar.gz masterserver-121a858846572418133d5adf9167f00f47d0f6ce.tar.xz masterserver-121a858846572418133d5adf9167f00f47d0f6ce.zip |
Implemented updateAddress - method.
-rw-r--r-- | src/main/java/org/openslx/imagemaster/db/DbSatellite.java | 7 | ||||
-rw-r--r-- | 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; } } |