use of com.salesmanager.shop.model.security.ReadablePermission in project shopizer by shopizer-ecommerce.
the class UserFacadeImpl method convertUserToReadableUser.
private ReadableUser convertUserToReadableUser(Language lang, User user) {
ReadableUserPopulator populator = new ReadableUserPopulator();
try {
ReadableUser readableUser = new ReadableUser();
readableUser = populator.populate(user, readableUser, user.getMerchantStore(), lang);
List<Integer> groupIds = readableUser.getGroups().stream().map(ReadableGroup::getId).map(Long::intValue).collect(Collectors.toList());
List<ReadablePermission> permissions = findPermissionsByGroups(groupIds);
readableUser.setPermissions(permissions);
return readableUser;
} catch (ConversionException e) {
throw new ConversionRuntimeException(e);
}
}
use of com.salesmanager.shop.model.security.ReadablePermission in project shopizer by shopizer-ecommerce.
the class SecurityApi method permissions.
/**
* Permissions Requires service user authentication
*
* @return
*/
@GetMapping("/private/permissions")
public List<ReadablePermission> permissions() {
List<Permission> permissions = permissionService.list();
List<ReadablePermission> readablePermissions = new ArrayList<ReadablePermission>();
for (Permission permission : permissions) {
ReadablePermission readablePermission = new ReadablePermission();
readablePermission.setName(permission.getPermissionName());
readablePermission.setId(permission.getId());
readablePermissions.add(readablePermission);
}
return readablePermissions;
}
use of com.salesmanager.shop.model.security.ReadablePermission in project shopizer by shopizer-ecommerce.
the class SecurityApi method listPermissions.
@ResponseStatus(HttpStatus.OK)
@GetMapping({ "/private/{group}/permissions" })
@ApiOperation(httpMethod = "GET", value = "Get permissions by group", notes = "", produces = MediaType.APPLICATION_JSON_VALUE, response = List.class)
public List<ReadablePermission> listPermissions(@PathVariable String group) {
Group g = null;
try {
g = groupService.findByName(group);
if (g == null) {
throw new ResourceNotFoundException("Group [" + group + "] does not exist");
}
} catch (Exception e) {
LOGGER.error("An error occured while getting group [" + group + "]", e);
throw new ServiceRuntimeException("An error occured while getting group [" + group + "]");
}
Set<Permission> permissions = g.getPermissions();
List<ReadablePermission> readablePermissions = new ArrayList<ReadablePermission>();
for (Permission permission : permissions) {
ReadablePermission readablePermission = new ReadablePermission();
readablePermission.setName(permission.getPermissionName());
readablePermission.setId(permission.getId());
readablePermissions.add(readablePermission);
}
return readablePermissions;
}
use of com.salesmanager.shop.model.security.ReadablePermission in project shopizer by shopizer-ecommerce.
the class UserFacadeImpl method convertPermissionToReadablePermission.
private ReadablePermission convertPermissionToReadablePermission(Permission permission) {
ReadablePermission readablePermission = new ReadablePermission();
readablePermission.setId(permission.getId());
readablePermission.setName(permission.getPermissionName());
return readablePermission;
}
Aggregations