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);
}
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);
}
}
}
}
}
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;
}
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;
}
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);
}
}
}
}
}
Aggregations