NIHVIVO-2279 Insure that a UserAccount has a unique URI.
This commit is contained in:
parent
bffa48ed6b
commit
8f995412dd
1 changed files with 6 additions and 3 deletions
|
@ -358,9 +358,8 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
||||||
Random random = new Random(System.currentTimeMillis());
|
Random random = new Random(System.currentTimeMillis());
|
||||||
for (int attempts = 0; attempts < 30; attempts++) {
|
for (int attempts = 0; attempts < 30; attempts++) {
|
||||||
int upperBound = (int) Math.pow(2, attempts + 13);
|
int upperBound = (int) Math.pow(2, attempts + 13);
|
||||||
uri = namespace + ("n" + random.nextInt(upperBound));
|
uri = namespace + ("u" + random.nextInt(upperBound));
|
||||||
errMsg = getWebappDaoFactory().checkURI(uri);
|
if (!isUriUsed(uri)) {
|
||||||
if (errMsg == null) {
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,6 +368,10 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
||||||
+ errMsg);
|
+ errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isUriUsed(String uri) {
|
||||||
|
return (getOntModel().getOntResource(uri) != null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since there is no reasoner on the UserAccountModel, this will return a
|
* Since there is no reasoner on the UserAccountModel, this will return a
|
||||||
* false negative for a subtype of the specified type.
|
* false negative for a subtype of the specified type.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue