git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[utils]
/
security
/
impl
/
src
/
main
/
java
/
org
/
wamblee
/
usermgt
/
InMemoryGroupSet.java
diff --git
a/security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
b/security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
index 609b114c5966de866414944f86cc525210caa2c4..227e8853bca8b980e8821c571eb268da5c247dc9 100644
(file)
--- a/
security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
+++ b/
security/impl/src/main/java/org/wamblee/usermgt/InMemoryGroupSet.java
@@
-15,8
+15,11
@@
*/
package org.wamblee.usermgt;
*/
package org.wamblee.usermgt;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicLong;
/**
* In-memory group set implementation.
/**
* In-memory group set implementation.
@@
-24,16
+27,19
@@
import java.util.TreeSet;
* @author Erik Brakkee
*/
public class InMemoryGroupSet implements GroupSet {
* @author Erik Brakkee
*/
public class InMemoryGroupSet implements GroupSet {
+
+ private AtomicLong pk = new AtomicLong(1l);
+
/**
* Groups.
*/
/**
* Groups.
*/
- private
Se
t<Group> groups;
+ private
Lis
t<Group> groups;
/**
* Constructs an empty group set.
*/
public InMemoryGroupSet() {
/**
* Constructs an empty group set.
*/
public InMemoryGroupSet() {
- groups = new
TreeSe
t<Group>();
+ groups = new
ArrayLis
t<Group>();
}
/*
}
/*
@@
-43,8
+49,13
@@
public class InMemoryGroupSet implements GroupSet {
* org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
*/
public void groupModified(Group aGroup) {
* org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
*/
public void groupModified(Group aGroup) {
- groups.remove(aGroup);
- groups.add(aGroup);
+ for (int i = 0; i < groups.size(); i++) {
+ if (groups.get(i).getPrimaryKey().equals(aGroup.getPrimaryKey())) {
+ groups.remove(i);
+ groups.add(aGroup);
+ return;
+ }
+ }
}
/*
}
/*
@@
-55,7
+66,7
@@
public class InMemoryGroupSet implements GroupSet {
public Group find(String aName) {
for (Group group : groups) {
if (group.getName().equals(aName)) {
public Group find(String aName) {
for (Group group : groups) {
if (group.getName().equals(aName)) {
- return
new Group(group)
;
+ return
group
;
}
}
}
}
@@
-77,6
+88,10
@@
public class InMemoryGroupSet implements GroupSet {
* @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group)
*/
public boolean add(Group aGroup) {
* @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group)
*/
public boolean add(Group aGroup) {
+ aGroup.setPrimaryKey(pk.getAndIncrement());
+ if ( find(aGroup.getName()) != null ) {
+ return false;
+ }
return groups.add(aGroup);
}
return groups.add(aGroup);
}