diff options
author | Simon Rettberg | 2015-08-13 15:45:10 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-13 15:45:10 +0200 |
commit | 9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7 (patch) | |
tree | fc32e08b30d5643cf1bbd1753ec6f1cc076a8217 /dozentenmodul/src/main/java/org/openslx/dozmod/permissions | |
parent | [client] Fix positioning of Wizard (diff) | |
download | tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.gz tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.tar.xz tutor-module-9693e1a8484cc7ab05e6d62bad7bfa561d4aa3d7.zip |
[client] Layout tweaks, Change owner feature
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/permissions')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/permissions/ImagePerms.java | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/permissions/ImagePerms.java b/dozentenmodul/src/main/java/org/openslx/dozmod/permissions/ImagePerms.java index e53abbc8..198de7cd 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/permissions/ImagePerms.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/permissions/ImagePerms.java @@ -2,8 +2,6 @@ package org.openslx.dozmod.permissions; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; -import org.openslx.bwlp.thrift.iface.ImagePermissions; -import org.openslx.dozmod.thrift.Session; /** * Class for checking, whether user can edit given image @@ -12,21 +10,12 @@ public class ImagePerms { private final static Logger LOGGER = Logger.getLogger(ImagePerms.class); - public static boolean canEdit(final ImageDetailsRead image){ - // check if we are the owner of the image - if(image.getOwnerId().equals(Session.getUserId())) - return true; - // we are not, lets see which permissions we have - ImagePermissions perms = image.getUserPermissions(); - if(perms != null) { - LOGGER.debug("You can: " + perms); - } else { - // no user specific permissions, check defaults - perms = image.getDefaultPermissions(); - if (perms != null) { - LOGGER.debug("Everybody can: " + perms); - } - } - return perms != null && (perms.admin || perms.edit); + public static boolean canEdit(final ImageDetailsRead image) { + return image != null && image.userPermissions != null + && (image.userPermissions.admin || image.userPermissions.edit); + } + + public static boolean canAdmin(ImageDetailsRead image) { + return image != null && image.userPermissions != null && image.userPermissions.admin; } } |