diff artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 177:77cd37a93fca

Backend: isIdentifierValid more symmetric to new newIndentifier artifacts/trunk@1403 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 06 Mar 2011 10:03:53 +0000
parents a0eff2227588
children 535e4ea2ef9b
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Fri Mar 04 17:51:15 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java	Sun Mar 06 10:03:53 2011 +0000
@@ -336,6 +336,10 @@
         return StringUtils.newUUID();
     }
 
+    public boolean isValidIdentifier(String identifier) {
+        return StringUtils.checkUUID(identifier);
+    }
+
     /**
      * Stores a new artifact into the database.
      * @param artifact The artifact to be stored
@@ -445,7 +449,7 @@
         final String         identifer,
         final ArtifactLoader loader
     ) {
-        if (!StringUtils.checkUUID(identifer)) {
+        if (!isValidIdentifier(identifer)) {
             return null;
         }
 
@@ -549,7 +553,7 @@
     ) {
         final String uuid = artifact.identifier();
 
-        if (!StringUtils.checkUUID(uuid)) {
+        if (!isValidIdentifier(uuid)) {
             throw new RuntimeException("No valid UUID");
         }
 
@@ -781,7 +785,7 @@
 
     public boolean deleteUser(final String identifier) {
 
-        if (!StringUtils.checkUUID(identifier)) {
+        if (!isValidIdentifier(identifier)) {
             return false;
         }
 
@@ -844,7 +848,7 @@
         final UserFactory factory,
         final Object      context
     ) {
-        if (!StringUtils.checkUUID(identifier)) {
+        if (!isValidIdentifier(identifier)) {
             logger.debug("Invalid UUID: '" + identifier + "'");
             return null;
         }
@@ -917,7 +921,7 @@
             return null;
         }
 
-        if (!StringUtils.checkUUID(ownerIdentifier)) {
+        if (!isValidIdentifier(ownerIdentifier)) {
             logger.debug("Invalid owner id: '" + ownerIdentifier + "'");
             return null;
         }
@@ -1008,7 +1012,7 @@
         final Object                    context
     ) {
         if (ownerIdentifier != null 
-        && !StringUtils.checkUUID(ownerIdentifier)) {
+        && !isValidIdentifier(ownerIdentifier)) {
             logger.debug("Invalid owner id: '" + ownerIdentifier + "'");
             return null;
         }
@@ -1063,7 +1067,7 @@
 
 
     public boolean deleteCollection(final String collectionId) {
-        if (!StringUtils.checkUUID(collectionId)) {
+        if (!isValidIdentifier(collectionId)) {
             logger.debug("Invalid collection id: '" + collectionId + "'");
             return false;
         }
@@ -1126,12 +1130,12 @@
         final String   artifactId,
         final Document attribute
     ) {
-        if (!StringUtils.checkUUID(collectionId)) {
+        if (!isValidIdentifier(collectionId)) {
             logger.debug("Invalid collection id: '" + collectionId + "'");
             return false;
         }
 
-        if (!StringUtils.checkUUID(artifactId)) {
+        if (!isValidIdentifier(artifactId)) {
             logger.debug("Invalid artifact id: '" + artifactId + "'");
             return false;
         }

http://dive4elements.wald.intevation.org