mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUACAMOLE-926: Remove patch update functionality. It's needed for batch import, and it's a can of worms.
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
| @@ -116,24 +116,6 @@ public interface DirectoryObjectService<InternalType, ExternalType> { | ||||
|     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. | ||||
|   | ||||
| @@ -511,20 +511,6 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Transactional | ||||
|     public void updateExternalObject(ModeledAuthenticatedUser user, ExternalType object) | ||||
|         throws GuacamoleException { | ||||
|  | ||||
|         // Convert to the internal type | ||||
|         InternalType internalObject = getObjectInstance( | ||||
|                 user, getModelInstance(user, object)); | ||||
|  | ||||
|         // Delegate to the standard internal update functionality | ||||
|         updateObject(user, internalObject); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<String> getIdentifiers(ModeledAuthenticatedUser user) | ||||
|         throws GuacamoleException { | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -68,18 +68,8 @@ public class ConnectionDirectory extends JDBCDirectory<Connection> { | ||||
|     @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 | ||||
|   | ||||
| @@ -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."); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -110,19 +110,14 @@ public class ConnectionService extends ModeledChildDirectoryObjectService<Modele | ||||
|  | ||||
|     @Override | ||||
|     protected ConnectionModel getModelInstance(ModeledAuthenticatedUser currentUser, | ||||
|             final Connection object) throws GuacamoleException { | ||||
|             final Connection object) { | ||||
|  | ||||
|         // Create new ModeledConnection backed by blank model | ||||
|         ConnectionModel model = new ConnectionModel(); | ||||
|         ModeledConnection connection = getObjectInstance(currentUser, model); | ||||
|  | ||||
|         // If the provided connection has an identifier, set it on the model | ||||
|         if (object.getIdentifier() != null) | ||||
|             model.setObjectID(object.getIdentifier()); | ||||
|  | ||||
|         // Set model contents through ModeledConnection, copying the provided connection | ||||
|         connection.setParentIdentifier(object.getParentIdentifier()); | ||||
|         connection.setIdentifier(object.getIdentifier()); | ||||
|         connection.setName(object.getName()); | ||||
|         connection.setConfiguration(object.getConfiguration()); | ||||
|         connection.setAttributes(object.getAttributes()); | ||||
|   | ||||
| @@ -266,4 +266,10 @@ public class ConnectionGroupModel extends ChildObjectModel { | ||||
|         return id.toString(); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         throw new UnsupportedOperationException("Connection group identifiers are derived from IDs. They cannot be set."); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -92,19 +92,14 @@ public class ConnectionGroupService extends ModeledChildDirectoryObjectService<M | ||||
|  | ||||
|     @Override | ||||
|     protected ConnectionGroupModel getModelInstance(ModeledAuthenticatedUser currentUser, | ||||
|             final ConnectionGroup object) throws GuacamoleException { | ||||
|             final ConnectionGroup object) { | ||||
|  | ||||
|         // Create new ModeledConnectionGroup backed by blank model | ||||
|         ConnectionGroupModel model = new ConnectionGroupModel(); | ||||
|         ModeledConnectionGroup connectionGroup = getObjectInstance(currentUser, model); | ||||
|  | ||||
|         // If the provided connection has an identifier, set it on the model | ||||
|         if (object.getIdentifier() != null) | ||||
|             model.setObjectID(object.getIdentifier()); | ||||
|  | ||||
|         // Set model contents through ModeledConnectionGroup, copying the provided connection group | ||||
|         connectionGroup.setParentIdentifier(object.getParentIdentifier()); | ||||
|         connectionGroup.setIdentifier(object.getIdentifier()); | ||||
|         connectionGroup.setName(object.getName()); | ||||
|         connectionGroup.setType(object.getType()); | ||||
|         connectionGroup.setAttributes(object.getAttributes()); | ||||
|   | ||||
| @@ -71,4 +71,10 @@ public class SharingProfileModel extends ChildObjectModel { | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setIdentifier(String identifier) { | ||||
|         throw new UnsupportedOperationException("Sharing profile identifiers " | ||||
|                 + "are derived from IDs. They cannot be set."); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -90,20 +90,15 @@ public class SharingProfileService | ||||
|  | ||||
|     @Override | ||||
|     protected SharingProfileModel getModelInstance(ModeledAuthenticatedUser currentUser, | ||||
|             final SharingProfile object) throws GuacamoleException { | ||||
|             final SharingProfile object) { | ||||
|  | ||||
|         // Create new ModeledSharingProfile backed by blank model | ||||
|         SharingProfileModel model = new SharingProfileModel(); | ||||
|         ModeledSharingProfile sharingProfile = getObjectInstance(currentUser, model); | ||||
|  | ||||
|         // If the provided connection has an identifier, set it on the model | ||||
|         if (object.getIdentifier() != null) | ||||
|             model.setObjectID(object.getIdentifier()); | ||||
|  | ||||
|         // Set model contents through ModeledSharingProfile, copying the | ||||
|         // provided sharing profile | ||||
|         sharingProfile.setPrimaryConnectionIdentifier(object.getPrimaryConnectionIdentifier()); | ||||
|         sharingProfile.setIdentifier(object.getIdentifier()); | ||||
|         sharingProfile.setName(object.getName()); | ||||
|         sharingProfile.setParameters(object.getParameters()); | ||||
|         sharingProfile.setAttributes(object.getAttributes()); | ||||
|   | ||||
| @@ -202,10 +202,6 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User | ||||
|         UserModel model = new UserModel(); | ||||
|         ModeledUser user = getObjectInstance(currentUser, model); | ||||
|  | ||||
|         // If the provided connection has an identifier, set it on the model | ||||
|         if (object.getIdentifier() != null) | ||||
|             model.setObjectID(object.getIdentifier()); | ||||
|  | ||||
|         // Set model contents through ModeledUser, copying the provided user | ||||
|         user.setIdentifier(object.getIdentifier()); | ||||
|         user.setPassword(object.getPassword()); | ||||
|   | ||||
| @@ -107,10 +107,6 @@ public class UserGroupService extends ModeledDirectoryObjectService<ModeledUserG | ||||
|         UserGroupModel model = new UserGroupModel(); | ||||
|         ModeledUserGroup group = getObjectInstance(currentUser, model); | ||||
|  | ||||
|         // If the provided connection has an identifier, set it on the model | ||||
|         if (object.getIdentifier() != null) | ||||
|             model.setObjectID(object.getIdentifier()); | ||||
|  | ||||
|         // Set model contents through ModeledUser, copying the provided group | ||||
|         group.setIdentifier(object.getIdentifier()); | ||||
|         group.setAttributes(object.getAttributes()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user