@Test public void testHasPermission() { Resource resource = new Resource(); assertFalse(resource.hasPermission(guest, PermissionType.DOWNLOAD)); assertFalse(resource.hasPermission(guest, PermissionType.EDIT_LAYER)); resource.addPermission(getPermision(PermissionType.DOWNLOAD, guest)); resource.addPermission(getPermision(PermissionType.DOWNLOAD, admin)); assertTrue(resource.hasPermission(guest, PermissionType.DOWNLOAD)); assertFalse(resource.hasPermission(guest, PermissionType.EDIT_LAYER)); resource.removePermissionsOfType(PermissionType.DOWNLOAD, PermissionExternalType.ROLE, (int) guest.getId()); assertFalse(resource.hasPermission(guest, PermissionType.DOWNLOAD)); assertFalse(resource.hasPermission(guest, PermissionType.EDIT_LAYER)); resource.addPermission(getPermision(PermissionType.EDIT_LAYER, guest)); assertFalse(resource.hasPermission(guest, PermissionType.DOWNLOAD)); assertTrue(resource.hasPermission(guest, PermissionType.EDIT_LAYER)); User user = new User(); user.setId(1); assertFalse(resource.hasPermission(user, PermissionType.EDIT_LAYER)); assertFalse(resource.hasPermission(user, PermissionType.DOWNLOAD)); user.addRole(guest); assertFalse(resource.hasPermission(user, PermissionType.DOWNLOAD)); assertTrue(resource.hasPermission(user, PermissionType.EDIT_LAYER)); user.clearRoles(); assertFalse(resource.hasPermission(user, PermissionType.DOWNLOAD)); assertFalse(resource.hasPermission(user, PermissionType.EDIT_LAYER)); user.addRole(admin); assertTrue(resource.hasPermission(user, PermissionType.DOWNLOAD)); assertTrue(resource.hasPermission(user, PermissionType.EDIT_LAYER)); }
public boolean hasPermission(User user, PermissionType permissionType) { return hasPermission(user, permissionType.name()); }
Resource { public boolean hasPermission(User user, PermissionType permissionType) { return hasPermission(user, permissionType.name()); } }
Resource { public boolean hasPermission(User user, PermissionType permissionType) { return hasPermission(user, permissionType.name()); }  }
Resource { public boolean hasPermission(User user, PermissionType permissionType) { return hasPermission(user, permissionType.name()); }  int getId(); void setId(int id); String getType(); void setType(String type); void setType(ResourceType type); String getMapping(); void setMapping(String mapping); void setMapping(String namespace, String name); List<Permission> getPermissions(); void setPermissions(List<Permission> permissions); void addPermission(Permission permission); Set<String> getPermissionTypes(); boolean hasPermission(User user, PermissionType permissionType); boolean hasPermission(User user, String permissionType); boolean hasPermission(Role role, PermissionType permissionType); boolean hasPermission(Role role, String permissionType); boolean hasRolePermission(long roleId, String permissionType); void removePermissionsOfType(PermissionType permissionType, PermissionExternalType idType, int externalId); void removePermissionsOfType(String permissionType, PermissionExternalType idType, int externalId); void removePermissionsForExternalType(PermissionExternalType idType, int externalId); void removePermissionsFromAllUsers(String permissionType); boolean isOfType(ResourceType type); boolean isOfType(String permissionType); }
Resource { public boolean hasPermission(User user, PermissionType permissionType) { return hasPermission(user, permissionType.name()); }  int getId(); void setId(int id); String getType(); void setType(String type); void setType(ResourceType type); String getMapping(); void setMapping(String mapping); void setMapping(String namespace, String name); List<Permission> getPermissions(); void setPermissions(List<Permission> permissions); void addPermission(Permission permission); Set<String> getPermissionTypes(); boolean hasPermission(User user, PermissionType permissionType); boolean hasPermission(User user, String permissionType); boolean hasPermission(Role role, PermissionType permissionType); boolean hasPermission(Role role, String permissionType); boolean hasRolePermission(long roleId, String permissionType); void removePermissionsOfType(PermissionType permissionType, PermissionExternalType idType, int externalId); void removePermissionsOfType(String permissionType, PermissionExternalType idType, int externalId); void removePermissionsForExternalType(PermissionExternalType idType, int externalId); void removePermissionsFromAllUsers(String permissionType); boolean isOfType(ResourceType type); boolean isOfType(String permissionType);  }