[Bedework-commit] webapps r787 - releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon

svnadmin at bedework.org svnadmin at bedework.org
Thu Aug 14 15:31:50 EDT 2008


Author: douglm
Date: 2008-08-14 15:31:49 -0400 (Thu, 14 Aug 2008)
New Revision: 787

Modified:
   releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
   releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwActionFormBase.java
Log:
Fix processing of locations for web submit tool

Modified: releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
===================================================================
--- releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwAbstractAction.java	2008-08-14 19:31:34 UTC (rev 786)
+++ releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwAbstractAction.java	2008-08-14 19:31:49 UTC (rev 787)
@@ -1755,25 +1755,33 @@
       owner = svci.getUser();
     }
 
-    String a = Util.checkNull(form.getLocationAddress().getValue());
-    if (a != null) {
-      // explicitly provided location overrides all others
-      loc = BwLocation.makeLocation();
-      BwString addr = new BwString(null, a);
-      loc.setAddress(addr);
+    if (!webSubmit) {
+      /* Check for user typing a new location into a text area.
+       */
+      String a = Util.checkNull(form.getLocationAddress().getValue());
+      if (a != null) {
+        // explicitly provided location overrides all others
+        loc = BwLocation.makeLocation();
+        BwString addr = new BwString(null, a);
+        loc.setAddress(addr);
+      }
     }
 
+    /* No new location supplied - try to retrieve by uid
+     */
     if (loc == null) {
       if (form.getLocationUid() != null) {
-        if (webSubmit) {
+        if (webSubmit || getPublicAdmin(form)) {
           loc = svci.getLocationsHandler().getPublic(form.getLocationUid());
         } else {
-          loc = svci.getLocationsHandler().get(form.getLocationUid());
+          loc = svci.getLocationsHandler().get(form.getLocationUid(), owner);
         }
       }
     }
 
     if (loc != null) {
+      loc.setLink(Util.checkNull(loc.getLink()));
+
       EnsureEntityExistsResult<BwLocation> eeerl = svci.getLocationsHandler().ensureExists(loc, owner);
 
       loc = eeerl.entity;
@@ -1801,7 +1809,12 @@
                                     BwEvent event,
                                     boolean webSubmit) throws Throwable {
     BwContact c = null;
+    BwUser owner = event.getOwner();
 
+    if (owner == null) {
+      owner = svci.getUser();
+    }
+
     if (!form.retrieveCtctId().getChanged()) {
       if (form.retrieveConfig().getAutoCreateContacts()) {
         c = form.getContact();
@@ -1811,7 +1824,7 @@
           return false;
         }
 
-        svci.getContactsHandler().ensureExists(c, null);
+        svci.getContactsHandler().ensureExists(c, owner);
 
         event.setContact(c);
         form.setContact(c);
@@ -1831,11 +1844,10 @@
 
     if (uid != null) {
       try {
-        c = svci.getContactsHandler().get(uid);
-        if (webSubmit) {
+        if (webSubmit || getPublicAdmin(form)) {
           c = svci.getContactsHandler().getPublic(uid);
         } else {
-          c = svci.getContactsHandler().get(uid);
+          c = svci.getContactsHandler().get(uid, owner);
         }
       } catch (Throwable t) {
         form.getErr().emit(t);

Modified: releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwActionFormBase.java
===================================================================
--- releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwActionFormBase.java	2008-08-14 19:31:34 UTC (rev 786)
+++ releases/bedework-3.4.1.1a/webcommon/src/org/bedework/webcommon/BwActionFormBase.java	2008-08-14 19:31:49 UTC (rev 787)
@@ -2657,7 +2657,7 @@
    * @return Collection    of BwCategory
    */
   public Collection<BwCategory> getCategories() {
-    return getCategoryCollection(ownersEntity);
+    return getCategoryCollection(ownersEntity, true);
   }
 
   /** Get the list of editable categories for this user. Return a null list for
@@ -2666,7 +2666,7 @@
    * @return Collection    of BwCategory
    */
   public Collection<BwCategory> getEditableCategories() {
-    return getCategoryCollection(editableEntity);
+    return getCategoryCollection(editableEntity, false);
   }
 
   /* ====================================================================
@@ -2889,18 +2889,19 @@
     return locationUid;
   }
 
-  /**
+  /** Called by jsp when editing an event
+   *
    * @return locations
    */
   public Collection<BwLocation> getLocations() {
-    return getLocations(ownersEntity);
+    return getLocations(ownersEntity, true);
   }
 
   /**
    * @return editable locations
    */
   public Collection<BwLocation> getEditableLocations() {
-    return getLocations(editableEntity);
+    return getLocations(editableEntity, false);
   }
 
   /* ====================================================================
@@ -3724,7 +3725,8 @@
     return calsvci.getUsersHandler().get(getSyspars().getPublicUser());
   }
   // ENUM
-  private Collection<BwCategory> getCategoryCollection(int kind) {
+  private Collection<BwCategory> getCategoryCollection(int kind,
+                                                       boolean forEventUpdate) {
     try {
       Collection<BwCategory> vals = null;
 
@@ -3735,6 +3737,16 @@
         } else {
           // Current owner
           vals = calsvci.getCategoriesHandler().get();
+
+          if (!publicAdmin() && forEventUpdate &&
+              (getEvent() != null) &&
+              (getEvent().getCategories() != null)) {
+            for (BwCategory cat: getEvent().getCategories()) {
+              if (!cat.getOwner().equals(fetchSvci().getUser())) {
+                vals.add(cat);
+              }
+            }
+          }
         }
       } else if (kind == editableEntity) {
         vals = calsvci.getCategoriesHandler().getEditable();
@@ -3755,7 +3767,8 @@
     }
   }
 
-  private Collection<BwLocation> getLocations(int kind) {
+  private Collection<BwLocation> getLocations(int kind,
+                                              boolean forEventUpdate) {
     try {
       Collection<BwLocation> vals = null;
 
@@ -3766,6 +3779,15 @@
         } else {
           // Current owner
           vals = calsvci.getLocationsHandler().get();
+
+          if (!publicAdmin() && forEventUpdate && (getEvent() != null)) {
+            BwLocation loc = getEvent().getLocation();
+
+            if ((loc != null) &&
+                (!loc.getOwner().equals(fetchSvci().getUser()))) {
+              vals.add(loc);
+            }
+          }
         }
       } else if (kind == editableEntity) {
         vals = calsvci.getLocationsHandler().getEditable();
@@ -3848,4 +3870,13 @@
 
     return locationCollator;
   }
+
+  private boolean publicAdmin() {
+    try {
+      return getEnv().getAppBoolProperty("publicadmin");
+    } catch (Throwable t) {
+      t.printStackTrace();
+      return false;
+    }
+  }
 }



More information about the Bedework-commit mailing list