[Bedework-commit] bwtools r58 - trunk/src/org/bedework/tools/cmdutil

svnadmin at bedework.org svnadmin at bedework.org
Fri Feb 20 09:59:42 EST 2009


Author: douglm
Date: 2009-02-20 09:59:42 -0500 (Fri, 20 Feb 2009)
New Revision: 58

Modified:
   trunk/src/org/bedework/tools/cmdutil/CmdUtilHelper.java
   trunk/src/org/bedework/tools/cmdutil/ProcessCreate.java
   trunk/src/org/bedework/tools/cmdutil/ProcessList.java
   trunk/src/org/bedework/tools/cmdutil/ProcessMove.java
Log:
Change schema to avoid repeated fetch of owner/creator with entities.

Owner/creator is now stored in the db as a principal hierarchy path, a string value. The system then retrieves and caches the actual db entries as they are needed.

This should result in less jvm churn. It also solves a number of problems in allowing groups to own entities. The move to a principal object is not complete but should be relatively simple.

Almost no visible changes as a result of this change. The only exception is where owners/creators appear in the generated xml. They are now a full principal path rather than just the account.

Modified: trunk/src/org/bedework/tools/cmdutil/CmdUtilHelper.java
===================================================================
--- trunk/src/org/bedework/tools/cmdutil/CmdUtilHelper.java	2009-02-13 15:51:05 UTC (rev 57)
+++ trunk/src/org/bedework/tools/cmdutil/CmdUtilHelper.java	2009-02-20 14:59:42 UTC (rev 58)
@@ -29,7 +29,6 @@
 import org.bedework.calfacade.BwCalendar;
 import org.bedework.calfacade.BwCategory;
 import org.bedework.calfacade.BwString;
-import org.bedework.calfacade.BwUser;
 import org.bedework.calfacade.exc.CalFacadeException;
 import org.bedework.calsvci.CalSvcI;
 import org.bedework.tools.cmdutil.CmdUtil.ProcessState;
@@ -87,7 +86,7 @@
     return cal;
   }
 
-  protected BwCategory getCat(BwUser owner)  throws Throwable {
+  protected BwCategory getCat(String ownerHref)  throws Throwable {
     String catVal = wordOrQuotedVal();
 
     if (catVal == null) {
@@ -95,16 +94,16 @@
       return null;
     }
 
-    return getCat(owner, catVal);
+    return getCat(ownerHref, catVal);
   }
 
-  protected BwCategory getCat(BwUser owner,
+  protected BwCategory getCat(String ownerHref,
                               String catVal)  throws Throwable {
     BwCategory cat = getSvci().getCategoriesHandler().find(new BwString(null, catVal),
-                                                           owner);
+                                                           ownerHref);
 
     if (cat == null) {
-      error("Unable to access category " + catVal);
+      error("Unable to access category " + catVal + " for owner " + ownerHref);
     }
 
     return cat;

Modified: trunk/src/org/bedework/tools/cmdutil/ProcessCreate.java
===================================================================
--- trunk/src/org/bedework/tools/cmdutil/ProcessCreate.java	2009-02-13 15:51:05 UTC (rev 57)
+++ trunk/src/org/bedework/tools/cmdutil/ProcessCreate.java	2009-02-20 14:59:42 UTC (rev 58)
@@ -165,25 +165,26 @@
       }
 
       String ownerAccount = word();
-      BwUser owner;
+      String ownerHref;
 
       if (ownerAccount != null) {
-        owner = getSvci().getUsersHandler().get(ownerAccount);
+        BwUser owner = getSvci().getUsersHandler().getUser(ownerAccount);
 
         if (owner == null) {
           error("No owner with account" + ownerAccount);
           return false;
         }
 
-        cal.setOwner(owner);
-        cal.setCreator(owner);
+        ownerHref = owner.getPrincipalRef();
+        cal.setOwnerHref(ownerHref);
+        cal.setCreatorHref(ownerHref);
       } else {
-        owner = getSvci().getUser();
+        ownerHref = getSvci().getUser().getPrincipalRef();
       }
 
       /* Now we have the owner find or add the categories */
       for (String catStr: cats) {
-        BwCategory cat = getCat(owner, catStr);
+        BwCategory cat = getCat(ownerHref, catStr);
 
         if (cat != null) {
           cal.addCategory(cat);

Modified: trunk/src/org/bedework/tools/cmdutil/ProcessList.java
===================================================================
--- trunk/src/org/bedework/tools/cmdutil/ProcessList.java	2009-02-13 15:51:05 UTC (rev 57)
+++ trunk/src/org/bedework/tools/cmdutil/ProcessList.java	2009-02-20 14:59:42 UTC (rev 58)
@@ -101,9 +101,9 @@
 
     Formatter fmt = new Formatter(sb);
 
-    fmt.format("%40s %10s ",
+    fmt.format("%40s %50s ",
                cat.getWordVal(),
-               cat.getOwner().getAccount());
+               cat.getOwnerHref());
 
     info(sb.toString());
   }

Modified: trunk/src/org/bedework/tools/cmdutil/ProcessMove.java
===================================================================
--- trunk/src/org/bedework/tools/cmdutil/ProcessMove.java	2009-02-13 15:51:05 UTC (rev 57)
+++ trunk/src/org/bedework/tools/cmdutil/ProcessMove.java	2009-02-20 14:59:42 UTC (rev 58)
@@ -103,7 +103,7 @@
       Collection<BwCategory> cats = new ArrayList<BwCategory>();
 
       while (!cmdEnd()) {
-        BwCategory cat = getCat(to.getOwner());
+        BwCategory cat = getCat(to.getOwnerHref());
 
         if (cat == null) {
           if (pstate.debug) {
@@ -124,7 +124,7 @@
         if (pathEls.length > 2) {
           for (int i = 2; i < pathEls.length; i++) {
             String catVal = pathEls[i];
-            BwCategory cat = getCat(to.getOwner(), catVal);
+            BwCategory cat = getCat(to.getOwnerHref(), catVal);
 
             if (cat == null) {
               return false;



More information about the Bedework-commit mailing list