Search in sources :

Example 11 with User

use of com.willshex.blogwt.shared.api.datatype.User in project blogwt by billy1380.

the class UserService method indexAll.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.user.IUserService#indexAll() */
@Override
public void indexAll() {
    Pager pager = PagerHelper.createDefaultPager();
    List<User> users = null;
    do {
        users = getUsers(pager.start, pager.count, null, null);
        for (User user : users) {
            SearchHelper.queueToIndex(getName(), user.id);
        }
        PagerHelper.moveForward(pager);
    } while (users != null && users.size() >= pager.count.intValue());
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) Pager(com.willshex.blogwt.shared.api.Pager)

Example 12 with User

use of com.willshex.blogwt.shared.api.datatype.User 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;
}
Also used : Role(com.willshex.blogwt.shared.api.datatype.Role) User(com.willshex.blogwt.shared.api.datatype.User) Permission(com.willshex.blogwt.shared.api.datatype.Permission) Date(java.util.Date) Key(com.googlecode.objectify.Key)

Example 13 with User

use of com.willshex.blogwt.shared.api.datatype.User in project blogwt by billy1380.

the class SendAdhocNotificationRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("content")) {
        JsonElement jsonContent = jsonObject.get("content");
        if (jsonContent != null) {
            content = jsonContent.getAsString();
        }
    }
    if (jsonObject.has("users")) {
        JsonElement jsonUsers = jsonObject.get("users");
        if (jsonUsers != null) {
            users = new ArrayList<User>();
            User item = null;
            for (int i = 0; i < jsonUsers.getAsJsonArray().size(); i++) {
                if (jsonUsers.getAsJsonArray().get(i) != null) {
                    (item = new User()).fromJson(jsonUsers.getAsJsonArray().get(i).getAsJsonObject());
                    users.add(item);
                }
            }
        }
    }
    if (jsonObject.has("mode")) {
        JsonElement jsonMode = jsonObject.get("mode");
        if (jsonMode != null) {
            mode = NotificationModeType.fromString(jsonMode.getAsString());
        }
    }
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement)

Example 14 with User

use of com.willshex.blogwt.shared.api.datatype.User in project blogwt by billy1380.

the class BlockUsersRequest 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("others")) {
        JsonElement jsonOthers = jsonObject.get("others");
        if (jsonOthers != null) {
            others = new ArrayList<User>();
            User item = null;
            for (int i = 0; i < jsonOthers.getAsJsonArray().size(); i++) {
                if (jsonOthers.getAsJsonArray().get(i) != null) {
                    (item = new User()).fromJson(jsonOthers.getAsJsonArray().get(i).getAsJsonObject());
                    others.add(item);
                }
            }
        }
    }
    if (jsonObject.has("un")) {
        JsonElement jsonUn = jsonObject.get("un");
        if (jsonUn != null) {
            un = Boolean.valueOf(jsonUn.getAsBoolean());
        }
    }
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement)

Example 15 with User

use of com.willshex.blogwt.shared.api.datatype.User 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());
        }
    }
}
Also used : Role(com.willshex.blogwt.shared.api.datatype.Role) User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement) Permission(com.willshex.blogwt.shared.api.datatype.Permission) Date(java.util.Date)

Aggregations

User (com.willshex.blogwt.shared.api.datatype.User)46 JsonElement (com.google.gson.JsonElement)19 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)10 Pager (com.willshex.blogwt.shared.api.Pager)6 Permission (com.willshex.blogwt.shared.api.datatype.Permission)5 Page (com.willshex.blogwt.shared.api.datatype.Page)4 Post (com.willshex.blogwt.shared.api.datatype.Post)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Key (com.googlecode.objectify.Key)3 Role (com.willshex.blogwt.shared.api.datatype.Role)3 Date (java.util.Date)3 HeadingElement (com.google.gwt.dom.client.HeadingElement)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 UiHandler (com.google.gwt.uibinder.client.UiHandler)2 MetaNotification (com.willshex.blogwt.shared.api.datatype.MetaNotification)2 Relationship (com.willshex.blogwt.shared.api.datatype.Relationship)2 BlobKey (com.google.appengine.api.blobstore.BlobKey)1 ScoredDocument (com.google.appengine.api.search.ScoredDocument)1 JsonObject (com.google.gson.JsonObject)1