mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-5: Validate that data was provided when creating/updating resources.
This commit is contained in:
@@ -27,6 +27,7 @@ import javax.ws.rs.GET;
|
|||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import org.apache.guacamole.GuacamoleClientException;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.net.auth.Directory;
|
import org.apache.guacamole.net.auth.Directory;
|
||||||
import org.apache.guacamole.net.auth.Identifiable;
|
import org.apache.guacamole.net.auth.Identifiable;
|
||||||
@@ -120,8 +121,15 @@ public class DirectoryObjectResource<InternalType extends Identifiable, External
|
|||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
public void updateObject(ExternalType modifiedObject) throws GuacamoleException {
|
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);
|
translator.applyExternalChanges(object, modifiedObject);
|
||||||
directory.update(object);
|
directory.update(object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -222,6 +222,10 @@ public class DirectoryResource<InternalType extends Identifiable, ExternalType>
|
|||||||
public ExternalType createObject(ExternalType object)
|
public ExternalType createObject(ExternalType object)
|
||||||
throws GuacamoleException {
|
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
|
// Create the new object within the directory
|
||||||
directory.add(translator.toInternalObject(object));
|
directory.add(translator.toInternalObject(object));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user