From 314adf6c235f59feaa117132424118fabe82e0f1 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Tue, 7 Feb 2023 00:31:06 +0000 Subject: [PATCH] GUACAMOLE-926: Remove patch update functionality. It's needed for batch import, and it's a can of worms. --- .../ActiveConnectionService.java | 8 -- .../jdbc/base/DirectoryObjectService.java | 18 ---- .../base/ModeledDirectoryObjectService.java | 14 --- .../guacamole/auth/jdbc/base/ObjectModel.java | 29 +----- .../jdbc/connection/ConnectionDirectory.java | 14 +-- .../auth/jdbc/connection/ConnectionModel.java | 5 + .../jdbc/connection/ConnectionService.java | 7 +- .../connectiongroup/ConnectionGroupModel.java | 6 ++ .../ConnectionGroupService.java | 7 +- .../sharingprofile/SharingProfileModel.java | 6 ++ .../sharingprofile/SharingProfileService.java | 7 +- .../guacamole/auth/jdbc/user/UserService.java | 4 - .../auth/jdbc/usergroup/UserGroupService.java | 4 - .../rest/directory/DirectoryResource.java | 94 ++++--------------- 14 files changed, 39 insertions(+), 184 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/activeconnection/ActiveConnectionService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/activeconnection/ActiveConnectionService.java index 80c75dbbb..046cee1e2 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/activeconnection/ActiveConnectionService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/activeconnection/ActiveConnectionService.java @@ -166,14 +166,6 @@ public class ActiveConnectionService } - @Override - public void updateExternalObject(ModeledAuthenticatedUser user, ActiveConnection object) throws GuacamoleException { - - // Updating active connections is not implemented - throw new GuacamoleSecurityException("Permission denied."); - - } - /** * Retrieve the permission set for the specified user that relates * to access to active connections. diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/DirectoryObjectService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/DirectoryObjectService.java index 29d40cc49..590e01e9f 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/DirectoryObjectService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/DirectoryObjectService.java @@ -116,24 +116,6 @@ public interface DirectoryObjectService { void deleteObject(ModeledAuthenticatedUser user, String identifier) throws GuacamoleException; - /** - * Updates the object corresponding to the given external representation, - * applying any changes that have been made. If no such object exists, - * this function has no effect. - * - * @param user - * The user updating the object. - * - * @param object - * The external object to apply updates from. - * - * @throws GuacamoleException - * If the user lacks permission to update the object, or an error - * occurs while updating the object. - */ - void updateExternalObject(ModeledAuthenticatedUser user, ExternalType object) - throws GuacamoleException; - /** * Updates the given object, applying any changes that have been made. If * no such object exists, this function has no effect. diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java index 75c25926b..80bc7eb5c 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java @@ -511,20 +511,6 @@ public abstract class ModeledDirectoryObjectService getIdentifiers(ModeledAuthenticatedUser user) throws GuacamoleException { diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ObjectModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ObjectModel.java index 69eb1fd36..c3052b1b4 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ObjectModel.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ObjectModel.java @@ -21,8 +21,6 @@ package org.apache.guacamole.auth.jdbc.base; import java.util.Collection; -import org.apache.guacamole.GuacamoleException; - /** * Object representation of a Guacamole object, such as a user or connection, * as represented in the database. @@ -77,7 +75,7 @@ public abstract class ObjectModel { * * @return * The ID of this object in the database, or null if this object was - * not retrieved from or intended to update the database. + * not retrieved from the database. */ public Integer getObjectID() { return objectID; @@ -93,31 +91,6 @@ public abstract class ObjectModel { this.objectID = objectID; } - /** - * Given a text identifier, attempt to convert to an integer database ID. - * If the identifier is valid, the database ID will be set to this value. - * Otherwise, a GuacamoleException will be thrown. - * - * @param identifier - * The identifier to convert to an integer and set on the database - * model, if valid. - * - * @throws GuacamoleException - * If the provided identifier is not a valid integer. - */ - public void setObjectID(String identifier) throws GuacamoleException { - - // Try to convert the provided identifier to an integer ID - try { - setObjectID(Integer.parseInt(identifier)); - } - - catch (NumberFormatException e) { - throw new GuacamoleException( - "Database identifiers must be integers."); - } - } - /** * Returns a map of attribute name/value pairs for all attributes associated * with this model which do not have explicit mappings to actual model diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionDirectory.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionDirectory.java index b2f3e2bea..3e364f509 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionDirectory.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionDirectory.java @@ -68,18 +68,8 @@ public class ConnectionDirectory extends JDBCDirectory { @Override @Transactional public void update(Connection object) throws GuacamoleException { - - // If the provided connection is already an internal type, update - // using the internal method - if (object instanceof ModeledConnection) - connectionService.updateObject( - getCurrentUser(), (ModeledConnection) object); - - // If the type is not already the expected internal type, use the - // external update method - else - connectionService.updateExternalObject(getCurrentUser(), object); - + ModeledConnection connection = (ModeledConnection) object; + connectionService.updateObject(getCurrentUser(), connection); } @Override diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java index 03413650b..da454025d 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionModel.java @@ -387,4 +387,9 @@ public class ConnectionModel extends ChildObjectModel { } + @Override + public void setIdentifier(String identifier) { + throw new UnsupportedOperationException("Connection identifiers are derived from IDs. They cannot be set."); + } + } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java index cdf2afb76..b3ed89ce8 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java @@ -110,19 +110,14 @@ public class ConnectionService extends ModeledChildDirectoryObjectService addedObjects = new ArrayList<>(); - Collection updatedObjects = new ArrayList<>(); Collection removedIdentifiers = new ArrayList<>(); // A list of all responses associated with the successful @@ -527,64 +526,6 @@ public abstract class DirectoryResource updatedIterator = updatedObjects.iterator(); - while (updatedIterator.hasNext()) { - - InternalType internal = updatedIterator.next(); - fireDirectorySuccessEvent( - DirectoryEvent.Operation.UPDATE, - internal.getIdentifier(), internal); - - } - // Fire directory success events for each removed object Iterator removedIterator = removedIdentifiers.iterator(); while (removedIterator.hasNext()) { String identifier = removedIterator.next(); fireDirectorySuccessEvent( - DirectoryEvent.Operation.UPDATE, + DirectoryEvent.Operation.REMOVE, identifier, null); }