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
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
if (!canUpdateModifiedParents(user, model.getIdentifier(), model))

View File

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

View File

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

View File

@@ -157,9 +157,10 @@ public class ConnectionGroupService extends ModeledChildDirectoryObjectService<M
@Override
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
if (model.getName() == null || model.getName().trim().isEmpty())

View File

@@ -157,9 +157,10 @@ public class SharingProfileService
@Override
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
if (model.getName() == null || model.getName().trim().isEmpty())

View File

@@ -203,9 +203,9 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
@Override
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
if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())