use of com.willshex.blogwt.shared.api.datatype.Permission in project blogwt by billy1380.
the class UserService method addUser.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.services.user.IUserService#addUser
* (com.willshex.blogwt.shared.api.datatypes.User) */
@Override
public User addUser(User user) {
if (user.created == null) {
user.added = user.created = new Date();
}
user.password = generatePassword(user.password);
if (user.roles != null) {
user.roleKeys = new ArrayList<Key<Role>>();
for (Role role : user.roles) {
user.roleKeys.add(Key.create(role));
}
}
if (user.permissions != null) {
user.permissionKeys = new ArrayList<Key<Permission>>();
for (Permission permission : user.permissions) {
user.permissionKeys.add(Key.create(permission));
}
}
Key<User> key = provide().save().entity(user).now();
user.id = keyToId(key);
SearchHelper.queueToIndex(getName(), user.id);
return user;
}
use of com.willshex.blogwt.shared.api.datatype.Permission in project blogwt by billy1380.
the class ChangeUserAccessRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("user")) {
JsonElement jsonUser = jsonObject.get("user");
if (jsonUser != null) {
user = new User();
user.fromJson(jsonUser.getAsJsonObject());
}
}
if (jsonObject.has("roles")) {
JsonElement jsonRoles = jsonObject.get("roles");
if (jsonRoles != null) {
roles = new ArrayList<Role>();
Role item = null;
for (int i = 0; i < jsonRoles.getAsJsonArray().size(); i++) {
if (jsonRoles.getAsJsonArray().get(i) != null) {
(item = new Role()).fromJson(jsonRoles.getAsJsonArray().get(i).getAsJsonObject());
roles.add(item);
}
}
}
}
if (jsonObject.has("permissions")) {
JsonElement jsonPermissions = jsonObject.get("permissions");
if (jsonPermissions != null) {
permissions = new ArrayList<Permission>();
Permission item = null;
for (int i = 0; i < jsonPermissions.getAsJsonArray().size(); i++) {
if (jsonPermissions.getAsJsonArray().get(i) != null) {
(item = new Permission()).fromJson(jsonPermissions.getAsJsonArray().get(i).getAsJsonObject());
permissions.add(item);
}
}
}
}
if (jsonObject.has("revoke")) {
JsonElement jsonRevoke = jsonObject.get("revoke");
if (jsonRevoke != null) {
revoke = Boolean.valueOf(jsonRevoke.getAsBoolean());
}
}
if (jsonObject.has("suspend")) {
JsonElement jsonSuspend = jsonObject.get("suspend");
if (jsonSuspend != null) {
suspend = Boolean.valueOf(jsonSuspend.getAsBoolean());
}
}
if (jsonObject.has("suspendUntil")) {
JsonElement jsonSuspendUntil = jsonObject.get("suspendUntil");
if (jsonSuspendUntil != null) {
suspendUntil = new Date(jsonSuspendUntil.getAsLong());
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Permission in project blogwt by billy1380.
the class GetRolesAndPermissionsResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("roles")) {
JsonElement jsonRoles = jsonObject.get("roles");
if (jsonRoles != null) {
roles = new ArrayList<Role>();
Role item = null;
for (int i = 0; i < jsonRoles.getAsJsonArray().size(); i++) {
if (jsonRoles.getAsJsonArray().get(i) != null) {
(item = new Role()).fromJson(jsonRoles.getAsJsonArray().get(i).getAsJsonObject());
roles.add(item);
}
}
}
}
if (jsonObject.has("permissions")) {
JsonElement jsonPermissions = jsonObject.get("permissions");
if (jsonPermissions != null) {
permissions = new ArrayList<Permission>();
Permission item = null;
for (int i = 0; i < jsonPermissions.getAsJsonArray().size(); i++) {
if (jsonPermissions.getAsJsonArray().get(i) != null) {
(item = new Permission()).fromJson(jsonPermissions.getAsJsonArray().get(i).getAsJsonObject());
permissions.add(item);
}
}
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Permission in project blogwt by billy1380.
the class IsAuthorisedRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("roles")) {
JsonElement jsonRoles = jsonObject.get("roles");
if (jsonRoles != null) {
roles = new ArrayList<Role>();
Role item = null;
for (int i = 0; i < jsonRoles.getAsJsonArray().size(); i++) {
if (jsonRoles.getAsJsonArray().get(i) != null) {
(item = new Role()).fromJson(jsonRoles.getAsJsonArray().get(i).getAsJsonObject());
roles.add(item);
}
}
}
}
if (jsonObject.has("permissions")) {
JsonElement jsonPermissions = jsonObject.get("permissions");
if (jsonPermissions != null) {
permissions = new ArrayList<Permission>();
Permission item = null;
for (int i = 0; i < jsonPermissions.getAsJsonArray().size(); i++) {
if (jsonPermissions.getAsJsonArray().get(i) != null) {
(item = new Permission()).fromJson(jsonPermissions.getAsJsonArray().get(i).getAsJsonObject());
permissions.add(item);
}
}
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Permission in project blogwt by billy1380.
the class GetPermissionsResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("permissions")) {
JsonElement jsonPermissions = jsonObject.get("permissions");
if (jsonPermissions != null) {
permissions = new ArrayList<Permission>();
Permission item = null;
for (int i = 0; i < jsonPermissions.getAsJsonArray().size(); i++) {
if (jsonPermissions.getAsJsonArray().get(i) != null) {
(item = new Permission()).fromJson(jsonPermissions.getAsJsonArray().get(i).getAsJsonObject());
permissions.add(item);
}
}
}
}
if (jsonObject.has("pager")) {
JsonElement jsonPager = jsonObject.get("pager");
if (jsonPager != null) {
pager = new Pager();
pager.fromJson(jsonPager.getAsJsonObject());
}
}
}
Aggregations