GUACAMOLE-36: Provide access to modeled object within beforeUpdate().

This commit is contained in:
Michael Jumper
2016-08-22 13:14:12 -07:00
parent ec34449fd0
commit 14e8c6fc50
6 changed files with 19 additions and 13 deletions

View File

@@ -184,9 +184,9 @@ public abstract class ModeledChildDirectoryObjectService<InternalType extends Mo
@Override @Override
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
ModelType model) throws GuacamoleException { InternalType object, ModelType model) throws GuacamoleException {
super.beforeUpdate(user, model); super.beforeUpdate(user, object, model);
// Validate that we can update all applicable parents // Validate that we can update all applicable parents
if (!canUpdateModifiedParents(user, model.getIdentifier(), model)) if (!canUpdateModifiedParents(user, model.getIdentifier(), model))

View File

@@ -250,6 +250,9 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
* @param user * @param user
* The user updating the existing object. * The user updating the existing object.
* *
* @param object
* The object being updated.
*
* @param model * @param model
* The model of the object being updated. * The model of the object being updated.
* *
@@ -258,7 +261,7 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
* object. * object.
*/ */
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
ModelType model) throws GuacamoleException { InternalType object, ModelType model) throws GuacamoleException {
// By default, do nothing. // By default, do nothing.
if (!hasObjectPermission(user, model.getIdentifier(), ObjectPermission.Type.UPDATE)) if (!hasObjectPermission(user, model.getIdentifier(), ObjectPermission.Type.UPDATE))
@@ -470,7 +473,7 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
throws GuacamoleException { throws GuacamoleException {
ModelType model = object.getModel(); ModelType model = object.getModel();
beforeUpdate(user, model); beforeUpdate(user, object, model);
// Update object // Update object
getObjectMapper().update(model); getObjectMapper().update(model);

View File

@@ -174,9 +174,10 @@ public class ConnectionService extends ModeledChildDirectoryObjectService<Modele
@Override @Override
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
ConnectionModel model) throws GuacamoleException { ModeledConnection object, ConnectionModel model)
throws GuacamoleException {
super.beforeUpdate(user, model); super.beforeUpdate(user, object, model);
// Name must not be blank // Name must not be blank
if (model.getName() == null || model.getName().trim().isEmpty()) if (model.getName() == null || model.getName().trim().isEmpty())

View File

@@ -157,9 +157,10 @@ public class ConnectionGroupService extends ModeledChildDirectoryObjectService<M
@Override @Override
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
ConnectionGroupModel model) throws GuacamoleException { ModeledConnectionGroup object, ConnectionGroupModel model)
throws GuacamoleException {
super.beforeUpdate(user, model); super.beforeUpdate(user, object, model);
// Name must not be blank // Name must not be blank
if (model.getName() == null || model.getName().trim().isEmpty()) if (model.getName() == null || model.getName().trim().isEmpty())

View File

@@ -157,9 +157,10 @@ public class SharingProfileService
@Override @Override
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
SharingProfileModel model) throws GuacamoleException { ModeledSharingProfile object, SharingProfileModel model)
throws GuacamoleException {
super.beforeUpdate(user, model); super.beforeUpdate(user, object, model);
// Name must not be blank // Name must not be blank
if (model.getName() == null || model.getName().trim().isEmpty()) if (model.getName() == null || model.getName().trim().isEmpty())

View File

@@ -203,9 +203,9 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
@Override @Override
protected void beforeUpdate(ModeledAuthenticatedUser user, protected void beforeUpdate(ModeledAuthenticatedUser user,
UserModel model) throws GuacamoleException { ModeledUser object, UserModel model) throws GuacamoleException {
super.beforeUpdate(user, model); super.beforeUpdate(user, object, model);
// Username must not be blank // Username must not be blank
if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty()) if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())