Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
8e68c40c
Commit
8e68c40c
authored
Oct 06, 2017
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app-blocks:1.3-SNAPSHOT requires #getDefaultUserRole, #listAvailableRoles
parent
05ec1688
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
37 deletions
+8
-37
src/main/java/org/genesys2/server/service/UserService.java
src/main/java/org/genesys2/server/service/UserService.java
+0
-5
src/main/java/org/genesys2/server/service/impl/UserServiceImpl.java
...ava/org/genesys2/server/service/impl/UserServiceImpl.java
+6
-26
src/main/java/org/genesys2/server/servlet/controller/rest/UsersController.java
...esys2/server/servlet/controller/rest/UsersController.java
+0
-6
src/main/java/org/genesys2/spring/config/SpringDataBaseConfig.java
...java/org/genesys2/spring/config/SpringDataBaseConfig.java
+2
-0
No files found.
src/main/java/org/genesys2/server/service/UserService.java
View file @
8e68c40c
...
...
@@ -32,11 +32,6 @@ import org.springframework.security.core.userdetails.UserDetails;
public
interface
UserService
extends
BasicUserService
<
UserRole
,
User
>
{
List
<
UserRole
>
listAvailableRoles
();
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
User
addUser
(
User
user
)
throws
UserException
,
PasswordPolicyException
;
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
void
removeUserById
(
long
userId
)
throws
UserException
;
...
...
src/main/java/org/genesys2/server/service/impl/UserServiceImpl.java
View file @
8e68c40c
...
...
@@ -80,6 +80,11 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
return
availableRoles
;
}
@Override
public
UserRole
getDefaultUserRole
()
{
return
UserRole
.
USER
;
}
@Override
@Transactional
public
User
createUser
(
String
email
,
String
fullName
,
String
password
,
AccountType
accountType
)
throws
UserException
{
...
...
@@ -90,7 +95,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
user
.
setAccountType
(
accountType
);
user
.
getRoles
().
add
(
UserRole
.
USER
);
super
.
setPassword
(
user
,
password
);
return
addUser
(
user
);
return
userRepository
.
save
(
user
);
}
@Transactional
...
...
@@ -171,31 +176,6 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
return
userWrapper
;
}
/**
* @param user
* @return
* @throws UserException
* @throws PasswordPolicyException
*/
@Override
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@Transactional
(
readOnly
=
false
,
rollbackFor
=
NotUniqueUserException
.
class
)
public
User
addUser
(
User
user
)
throws
UserException
,
PasswordPolicyException
{
try
{
if
(
user
.
getAccountType
()
==
AccountType
.
LOCAL
)
{
changePassword
(
user
,
user
.
getPassword
());
}
// save user
return
userRepository
.
save
(
user
);
}
catch
(
final
DataIntegrityViolationException
e
)
{
throw
new
NotUniqueUserException
(
e
,
user
.
getEmail
());
}
catch
(
final
EmptyResultDataAccessException
e
)
{
throw
new
NoUserFoundException
(
e
,
user
.
getId
());
}
catch
(
final
RuntimeException
e
)
{
throw
new
UserException
(
e
);
}
}
protected
void
updateUser
(
User
user
)
throws
UserException
{
try
{
userRepository
.
save
(
user
);
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/UsersController.java
View file @
8e68c40c
...
...
@@ -90,12 +90,6 @@ public class UsersController extends RestController {
return
userService
.
getUserByUuid
(
id
);
}
@RequestMapping
(
value
=
"/user"
,
method
=
RequestMethod
.
PUT
,
consumes
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@ResponseBody
public
void
saveUser
(
@RequestBody
@Validated
User
user
)
throws
UserException
,
PasswordPolicyException
{
userService
.
addUser
(
user
);
}
@RequestMapping
(
value
=
"/user/data"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@ResponseBody
public
ApiResult
updateData
(
@RequestBody
UserChangedDataJson
userData
)
throws
PasswordPolicyException
,
UserException
{
...
...
src/main/java/org/genesys2/spring/config/SpringDataBaseConfig.java
View file @
8e68c40c
...
...
@@ -87,6 +87,8 @@ public class SpringDataBaseConfig {
@Bean
public
DataSource
dataSource
()
{
System
.
err
.
println
(
"Genesys is connecting to "
+
dbUrl
);
final
DataSource
dataSource
=
new
DataSource
();
dataSource
.
setDefaultReadOnly
(
false
);
dataSource
.
setUrl
(
dbUrl
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment