guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmuehl...@apache.org
Subject [03/24] incubator-guacamole-client git commit: GUACAMOLE-5: Validate that data was provided when creating/updating resources.
Date Wed, 13 Jul 2016 05:09:41 GMT
GUACAMOLE-5: Validate that data was provided when creating/updating resources.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/f440f558
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/f440f558
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/f440f558

Branch: refs/heads/master
Commit: f440f558230e474032948f52f04f17bf4f17192a
Parents: e579eae
Author: Michael Jumper <mjumper@apache.org>
Authored: Tue Jul 12 00:20:36 2016 -0700
Committer: Michael Jumper <mjumper@apache.org>
Committed: Tue Jul 12 00:20:36 2016 -0700

----------------------------------------------------------------------
 .../guacamole/rest/directory/DirectoryObjectResource.java    | 8 ++++++++
 .../apache/guacamole/rest/directory/DirectoryResource.java   | 4 ++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f440f558/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
index 298f76b..7e45b2b 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
@@ -27,6 +27,7 @@ import javax.ws.rs.GET;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import org.apache.guacamole.GuacamoleClientException;
 import org.apache.guacamole.GuacamoleException;
 import org.apache.guacamole.net.auth.Directory;
 import org.apache.guacamole.net.auth.Identifiable;
@@ -120,8 +121,15 @@ public class DirectoryObjectResource<InternalType extends Identifiable,
External
      */
     @PUT
     public void updateObject(ExternalType modifiedObject) throws GuacamoleException {
+
+        // Validate that data was provided
+        if (modifiedObject == null)
+            throw new GuacamoleClientException("Data must be submitted when updating objects.");
+
+        // Perform update
         translator.applyExternalChanges(object, modifiedObject);
         directory.update(object);
+
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/f440f558/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
index 8c748b0..5f726f6 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
@@ -222,6 +222,10 @@ public class DirectoryResource<InternalType extends Identifiable,
ExternalType>
     public ExternalType createObject(ExternalType object)
             throws GuacamoleException {
 
+        // Validate that data was provided
+        if (object == null)
+            throw new GuacamoleClientException("Data must be submitted when creating objects.");
+
         // Create the new object within the directory
         directory.add(translator.toInternalObject(object));
 


Mime
View raw message