Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
a9b01246
Commit
a9b01246
authored
Oct 26, 2015
by
michael.simon
Browse files
Groups are now rolled correctly
parent
9be83c7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/service/GroupService.java
View file @
a9b01246
...
...
@@ -33,7 +33,7 @@ public interface GroupService extends BaseService<GroupEntity, Long> {
void
removeUserGromGroup
(
UserEntity
user
,
GroupEntity
group
);
Set
<
GroupEntity
>
findByUserWith
Pa
ren
ts
(
UserEntity
user
);
Set
<
GroupEntity
>
findByUserWith
Child
ren
(
UserEntity
user
);
ServiceBasedGroupEntity
persistWithServiceFlags
(
ServiceBasedGroupEntity
entity
);
...
...
bwreg-service/src/main/java/edu/kit/scc/webreg/service/impl/GroupServiceImpl.java
View file @
a9b01246
...
...
@@ -17,6 +17,8 @@ import java.util.Set;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
org.slf4j.Logger
;
import
edu.kit.scc.webreg.dao.BaseDao
;
import
edu.kit.scc.webreg.dao.GroupDao
;
import
edu.kit.scc.webreg.dao.UserDao
;
...
...
@@ -31,6 +33,9 @@ public class GroupServiceImpl extends BaseServiceImpl<GroupEntity, Long> impleme
private
static
final
long
serialVersionUID
=
1L
;
@Inject
private
Logger
logger
;
@Inject
private
GroupDao
groupDao
;
...
...
@@ -98,17 +103,19 @@ public class GroupServiceImpl extends BaseServiceImpl<GroupEntity, Long> impleme
}
@Override
public
Set
<
GroupEntity
>
findByUserWith
Pa
ren
ts
(
UserEntity
user
)
{
public
Set
<
GroupEntity
>
findByUserWith
Child
ren
(
UserEntity
user
)
{
Set
<
GroupEntity
>
groups
=
new
HashSet
<
GroupEntity
>(
groupDao
.
findByUser
(
user
));
Set
<
GroupEntity
>
targetGroups
=
new
HashSet
<
GroupEntity
>();
roll
Pa
ren
ts
(
targetGroups
,
groups
,
0
,
3
);
return
g
roups
;
roll
Child
ren
(
targetGroups
,
groups
,
0
,
3
);
return
targetG
roups
;
}
private
void
roll
Pa
ren
ts
(
Set
<
GroupEntity
>
targetGroups
,
Set
<
GroupEntity
>
groups
,
int
depth
,
int
maxDepth
)
{
private
void
roll
Child
ren
(
Set
<
GroupEntity
>
targetGroups
,
Set
<
GroupEntity
>
groups
,
int
depth
,
int
maxDepth
)
{
if
(
depth
<=
maxDepth
)
{
for
(
GroupEntity
group
:
groups
)
{
rollParents
(
targetGroups
,
group
.
getParents
(),
depth
+
1
,
maxDepth
);
if
(
logger
.
isTraceEnabled
())
logger
.
trace
(
"Inspecting group {} with children count {}"
,
group
.
getName
(),
group
.
getParents
().
size
());
rollChildren
(
targetGroups
,
group
.
getParents
(),
depth
+
1
,
maxDepth
);
targetGroups
.
add
(
group
);
}
}
...
...
bwreg-webapp/src/main/java/edu/kit/scc/webreg/sec/AuthorizationBean.java
View file @
a9b01246
...
...
@@ -106,12 +106,13 @@ public class AuthorizationBean implements Serializable {
if
(
sessionManager
.
getGroupSetCreated
()
==
null
||
(
System
.
currentTimeMillis
()
-
sessionManager
.
getGroupSetCreated
())
>
groupsTimeout
)
{
start
=
System
.
currentTimeMillis
();
Set
<
GroupEntity
>
groupList
=
groupService
.
findByUserWith
Pa
ren
ts
(
user
);
Set
<
GroupEntity
>
groupList
=
groupService
.
findByUserWith
Child
ren
(
user
);
sessionManager
.
clearGroups
();
sessionManager
.
getGroups
().
addAll
(
groupList
);
for
(
GroupEntity
g
:
groupList
)
for
(
GroupEntity
g
:
groupList
)
{
sessionManager
.
getGroupNames
().
add
(
g
.
getName
());
}
sessionManager
.
setGroupSetCreated
(
System
.
currentTimeMillis
());
end
=
System
.
currentTimeMillis
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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