create new id if null id is set
[jSite2.git] / src / net / pterodactylus / jsite / core / Project.java
index d250af1..9ddada5 100644 (file)
@@ -127,7 +127,11 @@ public class Project extends AbstractBean {
         *            The internal ID
         */
        void setId(String id) {
-               this.id = id;
+               if (id == null) {
+                       this.id = Hex.toHex(IdGenerator.generateId());
+               } else {
+                       this.id = id;
+               }
        }
 
        /**
@@ -399,6 +403,14 @@ public class Project extends AbstractBean {
                fireIfPropertyChanged(PROPERTY_NODE, oldNode, node);
        }
 
+       /**
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               return getClass().getName() + "[id=" + id + ",name=" + name + ",description=" + description + ",publicKey=" + publicKey + ",privateKey=" + privateKey + ",basePath=" + basePath + ",defaultFile=" + defaultFile + ",node=" + node + "]";
+       }
+
        //
        // PRIVATE METHODS
        //