[Bedework-commit] webapps r1259 - in trunk: webadmin/war/docs/system webcommon/src/org/bedework/webcommon/event webcommon/src/org/bedework/webcommon/system

svnadmin at bedework.org svnadmin at bedework.org
Thu Feb 17 10:31:58 EST 2011


Author: douglm
Date: 2011-02-17 10:31:57 -0500 (Thu, 17 Feb 2011)
New Revision: 1259

Added:
   trunk/webcommon/src/org/bedework/webcommon/event/JsonAttendee.java
Modified:
   trunk/webadmin/war/docs/system/modSyspars.jsp
   trunk/webcommon/src/org/bedework/webcommon/event/AttendeeAction.java
   trunk/webcommon/src/org/bedework/webcommon/event/EventActionBase.java
   trunk/webcommon/src/org/bedework/webcommon/system/UpdateSysparsAction.java
Log:
Support adding group as attendee.

Modified: trunk/webadmin/war/docs/system/modSyspars.jsp
===================================================================
--- trunk/webadmin/war/docs/system/modSyspars.jsp	2011-02-17 15:31:54 UTC (rev 1258)
+++ trunk/webadmin/war/docs/system/modSyspars.jsp	2011-02-17 15:31:57 UTC (rev 1259)
@@ -46,6 +46,7 @@
 
   <bw:emitText name="systemParams" property="maxInstances"/>
   <bw:emitText name="systemParams" property="maxYears"/>
+  <bw:emitText name="systemParams" property="maxAttendees"/>
 
   <bw:emitText name="systemParams" property="userauthClass"/>
   <bw:emitText name="systemParams" property="mailerClass"/>

Modified: trunk/webcommon/src/org/bedework/webcommon/event/AttendeeAction.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/event/AttendeeAction.java	2011-02-17 15:31:54 UTC (rev 1258)
+++ trunk/webcommon/src/org/bedework/webcommon/event/AttendeeAction.java	2011-02-17 15:31:57 UTC (rev 1259)
@@ -25,6 +25,7 @@
 */
 package org.bedework.webcommon.event;
 
+import org.bedework.appcommon.ClientError;
 import org.bedework.webcommon.BwActionFormBase;
 import org.bedework.webcommon.BwRequest;
 
@@ -59,41 +60,6 @@
  * </ul>
  */
 public class AttendeeAction extends EventActionBase {
-  /**
-   * @author douglm
-   */
-  public class JsonAttendee {
-    String uri;
-    String role;
-    String cn;
-    String cutype;
-
-    /**
-     *
-     */
-    public JsonAttendee() {}
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("JsonAttendee{");
-
-      sb.append("uri=");
-      sb.append(uri);
-
-      sb.append(", role=");
-      sb.append(role);
-
-      sb.append(", cn=");
-      sb.append(cn);
-
-      sb.append(", cutype=");
-      sb.append(cutype);
-
-      sb.append("}");
-
-      return sb.toString();
-    }
-  }
   /* (non-Javadoc)
    * @see org.bedework.webcommon.BwAbstractAction#doAction(org.bedework.webcommon.BwRequest, org.bedework.webcommon.BwActionFormBase)
    */
@@ -112,40 +78,64 @@
       gotoDateView(form, form.getDate(), form.getViewTypeI(), debug);
     }
 
+    /* If we were sent a bunch of json use that */
+
+    int res = forwardSuccess;
+
     Collection<String> attjson = request.getReqPars("attjson");
-    if ((attjson != null) && debug) {
-      // Try a bit of json
+    if (attjson != null) {
       Gson gson = new Gson();
 
       for (String s: attjson) {
-        debugMsg("json=" + s);
+        if (debug) {
+          debugMsg("json=" + s);
+        }
+
         try {
           JsonAttendee att = gson.fromJson(s, JsonAttendee.class);
 
-          debugMsg(att.toString());
+          if (debug) {
+            debugMsg(att.toString());
+          }
+          res = doAttendee(form, request.present("delete"),
+                           request.present("update"),
+                           false,            // recipient
+                           true,             // attendee
+                           false,
+                           request.getReqPar("partstat"),
+                           request.getReqPar("role"),
+                           att.uri,
+                           att.cn,
+                           null,             // lang
+                           att.cutype,
+                           null);             // dir
+
+          if (res != forwardSuccess) {
+            return res;
+          }
         } catch (Throwable t) {
-          debugMsg("Exception parsing json");
-          error(t);
+          form.getErr().emit(ClientError.unknownAttendee, s);
+          return forwardNoAction;
         }
       }
-    }
+    } else {
+      /* Try for a uri */
+      String uri = request.getReqPar("uri");
 
-    String uri = request.getReqPar("uri");
-    int res = forwardSuccess;
-
-    if (uri != null) {
-      res = doAttendee(form, request.present("delete"),
-                       request.present("update"),
-                       request.present("recipient"),
-                       request.present("attendee"),
-                       false,
-                       request.getReqPar("partstat"),
-                       request.getReqPar("role"),
-                       uri,
-                       request.getReqPar("cn"),
-                       request.getReqPar("lang"),
-                       request.getReqPar("cutype"),
-                       request.getReqPar("dir"));
+      if (uri != null) {
+        res = doAttendee(form, request.present("delete"),
+                         request.present("update"),
+                         request.present("recipient"),
+                         request.present("attendee"),
+                         false,
+                         request.getReqPar("partstat"),
+                         request.getReqPar("role"),
+                         uri,
+                         request.getReqPar("cn"),
+                         request.getReqPar("lang"),
+                         request.getReqPar("cutype"),
+                         request.getReqPar("dir"));
+      }
     }
 
     if ((res != forwardSuccess) || noFb) {

Modified: trunk/webcommon/src/org/bedework/webcommon/event/EventActionBase.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/event/EventActionBase.java	2011-02-17 15:31:54 UTC (rev 1258)
+++ trunk/webcommon/src/org/bedework/webcommon/event/EventActionBase.java	2011-02-17 15:31:57 UTC (rev 1259)
@@ -774,6 +774,13 @@
       }
     }
 
+    int maxAttendees = svc.getSysparsHandler().get().getMaxAttendees();
+
+    if (atts.getAttendees().size() == maxAttendees) {
+      form.getErr().emit(ValidationError.tooManyAttendees, uri);
+      return forwardNoAction;
+    }
+
     att.setRole(role);
 
     if (partstat != null) {

Added: trunk/webcommon/src/org/bedework/webcommon/event/JsonAttendee.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/event/JsonAttendee.java	                        (rev 0)
+++ trunk/webcommon/src/org/bedework/webcommon/event/JsonAttendee.java	2011-02-17 15:31:57 UTC (rev 1259)
@@ -0,0 +1,62 @@
+/* **********************************************************************
+    Copyright 2011 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+
+    Redistribution and use of this distribution in source and binary forms,
+    with or without modification, are permitted provided that:
+       The above copyright notice and this permission notice appear in all
+        copies and supporting documentation;
+
+        The name, identifiers, and trademarks of Rensselaer Polytechnic
+        Institute are not used in advertising or publicity without the
+        express prior written permission of Rensselaer Polytechnic Institute;
+
+    DISCLAIMER: The software is distributed" AS IS" without any express or
+    implied warranty, including but not limited to, any implied warranties
+    of merchantability or fitness for a particular purpose or any warrant)'
+    of non-infringement of any current or pending patent rights. The authors
+    of the software make no representations about the suitability of this
+    software for any particular purpose. The entire risk as to the quality
+    and performance of the software is with the user. Should the software
+    prove defective, the user assumes the cost of all necessary servicing,
+    repair or correction. In particular, neither Rensselaer Polytechnic
+    Institute, nor the authors of the software are liable for any indirect,
+    special, consequential, or incidental damages related to the software,
+    to the maximum extent the law permits.
+*/
+package org.bedework.webcommon.event;
+
+/**
+ * Represent attendees passed in request as json.
+ */
+public class JsonAttendee {
+  String uri;
+  String role;
+  String cn;
+  String cutype;
+
+  /**
+   *
+   */
+  public JsonAttendee() {}
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("JsonAttendee{");
+
+    sb.append("uri=");
+    sb.append(uri);
+
+    sb.append(", role=");
+    sb.append(role);
+
+    sb.append(", cn=");
+    sb.append(cn);
+
+    sb.append(", cutype=");
+    sb.append(cutype);
+
+    sb.append("}");
+
+    return sb.toString();
+  }
+}

Modified: trunk/webcommon/src/org/bedework/webcommon/system/UpdateSysparsAction.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/system/UpdateSysparsAction.java	2011-02-17 15:31:54 UTC (rev 1258)
+++ trunk/webcommon/src/org/bedework/webcommon/system/UpdateSysparsAction.java	2011-02-17 15:31:57 UTC (rev 1259)
@@ -286,6 +286,11 @@
       return forwardBadRequest;
     }
 
+    changed = changedInteger(request, form, syspars, "maxAttendees", changed);
+    if (changed == null) {
+      return forwardBadRequest;
+    }
+
     changed = changedString(request, form, syspars, "userauthClass", changed);
     if (changed == null) {
       return forwardBadRequest;



More information about the Bedework-commit mailing list