Search in sources :

Example 6 with Property

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

the class RegisterUserActionHandler method handle.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
	 * gson.web.service.shared.Request,
	 * com.willshex.gson.web.service.shared.Response) */
@Override
protected void handle(RegisterUserRequest input, RegisterUserResponse output) throws Exception {
    ApiValidator.request(input, RegisterUserRequest.class);
    ApiValidator.accessCode(input.accessCode, "input.accessCode");
    if (input.session != null) {
        try {
            output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
            UserValidator.authorisation(input.session.user, Arrays.asList(PermissionServiceProvider.provide().getCodePermission(PermissionHelper.MANAGE_USERS)), "input.session.user");
        } catch (InputValidationException ex) {
            output.session = input.session = null;
        }
    } else {
        PropertyValidator.ensureTrue(PropertyHelper.ALLOW_USER_REGISTRATION);
    }
    input.user = UserValidator.validate(input.user, "input.user");
    List<String> codes;
    List<Permission> permissions = null;
    Property property = PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.NEW_USER_PERMISSIONS);
    if (!PropertyHelper.isEmpty(property) && !PropertyHelper.NONE_VALUE.equals(property.value)) {
        codes = TagHelper.convertToTagList(property.value, true);
        for (String code : codes) {
            if (permissions == null) {
                permissions = new ArrayList<Permission>();
            }
            permissions.add(new Permission().code(code.toUpperCase()));
        }
        permissions = PermissionValidator.lookupAll(permissions, PropertyHelper.NEW_USER_PERMISSIONS);
    }
    List<Role> roles = null;
    property = PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.NEW_USER_ROLES);
    if (!PropertyHelper.isEmpty(property) && !PropertyHelper.NONE_VALUE.equals(property.value)) {
        codes = TagHelper.convertToTagList(property.value, true);
        for (String code : codes) {
            if (roles == null) {
                roles = new ArrayList<Role>();
            }
            roles.add(new Role().code(code.toUpperCase()));
        }
        roles = RoleValidator.lookupAll(roles, PropertyHelper.NEW_USER_ROLES);
    }
    input.user.permissions = permissions;
    input.user.roles = roles;
    output.user = UserServiceProvider.provide().addUser(input.user);
    UserServiceProvider.provide().verifyAccount(output.user);
}
Also used : Role(com.willshex.blogwt.shared.api.datatype.Role) Permission(com.willshex.blogwt.shared.api.datatype.Permission) InputValidationException(com.willshex.gson.web.service.server.InputValidationException) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 7 with Property

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

the class UpdatePropertiesResponse method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("properties")) {
        JsonElement jsonProperties = jsonObject.get("properties");
        if (jsonProperties != null) {
            properties = new ArrayList<Property>();
            Property item = null;
            for (int i = 0; i < jsonProperties.getAsJsonArray().size(); i++) {
                if (jsonProperties.getAsJsonArray().get(i) != null) {
                    (item = new Property()).fromJson(jsonProperties.getAsJsonArray().get(i).getAsJsonObject());
                    properties.add(item);
                }
            }
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 8 with Property

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

the class UserService method getSalt.

private String getSalt() {
    String salt = SALT;
    Property hashSaltProperty;
    if ((hashSaltProperty = PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.PASSWORD_HASH_SALT)) != null) {
        salt = hashSaltProperty.value;
    }
    return salt;
}
Also used : Property(com.willshex.blogwt.shared.api.datatype.Property)

Example 9 with Property

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

the class PropertyService method addProperty.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.services.property.IPropertyService
	 * #addProperty(com.willshex.blogwt.shared.api.datatypes.Property ) */
@Override
public Property addProperty(Property property) {
    if (property.created == null) {
        property.created = new Date();
    }
    Key<Property> key = provide().save().entity(property).now();
    property.id = keyToId(key);
    return property;
}
Also used : Property(com.willshex.blogwt.shared.api.datatype.Property) Date(java.util.Date)

Example 10 with Property

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

the class SetupBlogRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("properties")) {
        JsonElement jsonProperties = jsonObject.get("properties");
        if (jsonProperties != null) {
            properties = new ArrayList<Property>();
            Property item = null;
            for (int i = 0; i < jsonProperties.getAsJsonArray().size(); i++) {
                if (jsonProperties.getAsJsonArray().get(i) != null) {
                    (item = new Property()).fromJson(jsonProperties.getAsJsonArray().get(i).getAsJsonObject());
                    properties.add(item);
                }
            }
        }
    }
    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);
                }
            }
        }
    }
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement) Property(com.willshex.blogwt.shared.api.datatype.Property)

Aggregations

Property (com.willshex.blogwt.shared.api.datatype.Property)19 JsonElement (com.google.gson.JsonElement)4 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)4 IPropertyService (com.willshex.blogwt.server.service.property.IPropertyService)2 HTTPMethod (com.google.appengine.api.urlfetch.HTTPMethod)1 JsonArray (com.google.gson.JsonArray)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 Widget (com.google.gwt.user.client.ui.Widget)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 FeedException (com.rometools.rome.io.FeedException)1 SyndFeedOutput (com.rometools.rome.io.SyndFeedOutput)1 GetPropertiesFailure (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesFailure)1 GetPropertiesSuccess (com.willshex.blogwt.client.api.blog.event.GetPropertiesEventHandler.GetPropertiesSuccess)1 UpdatePropertiesFailure (com.willshex.blogwt.client.api.blog.event.UpdatePropertiesEventHandler.UpdatePropertiesFailure)1 UpdatePropertiesSuccess (com.willshex.blogwt.client.api.blog.event.UpdatePropertiesEventHandler.UpdatePropertiesSuccess)1 HttpHelper (com.willshex.blogwt.server.helper.HttpHelper)1 InlineHelper (com.willshex.blogwt.server.helper.InlineHelper)1 PersistenceHelper (com.willshex.blogwt.server.helper.PersistenceHelper)1 ServletHelper (com.willshex.blogwt.server.helper.ServletHelper)1 ArchiveEntryServiceProvider (com.willshex.blogwt.server.service.archiveentry.ArchiveEntryServiceProvider)1