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());
|
||||
for (int attempts = 0; attempts < 30; attempts++) {
|
||||
int upperBound = (int) Math.pow(2, attempts + 13);
|
||||
uri = namespace + ("n" + random.nextInt(upperBound));
|
||||
errMsg = getWebappDaoFactory().checkURI(uri);
|
||||
if (errMsg == null) {
|
||||
uri = namespace + ("u" + random.nextInt(upperBound));
|
||||
if (!isUriUsed(uri)) {
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
@ -368,6 +367,10 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
|||
throw new InsertException("Could not create URI for individual: "
|
||||
+ errMsg);
|
||||
}
|
||||
|
||||
private boolean isUriUsed(String uri) {
|
||||
return (getOntModel().getOntResource(uri) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Since there is no reasoner on the UserAccountModel, this will return a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue