Changeset 128
- Timestamp:
- 02/09/06 14:32:07
- Files:
-
- trunk/calendar3/appcommon/src/org/bedework/appcommon/FormattedEvents.java (modified) (2 diffs)
- trunk/calendar3/calCore/resources/properties/hibernate.properties (modified) (1 diff)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java (modified) (2 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (modified) (6 diffs)
- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/HibSession.java (modified) (7 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwAlarm.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java (modified) (3 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/BwRecurrence.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwOwnedDbentity.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwShareableContainedDbentity.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwShareableDbentity.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Attendees.java (modified) (2 diffs)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/AttendeesI.java (modified) (1 diff)
- trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/EventInfo.java (modified) (3 diffs)
- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (modified) (2 diffs)
- trunk/calendar3/quickstartFiles/tomcat.conf/server.xml (modified) (5 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/PEAbstractAction.java (modified) (3 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/PEActionForm.java (modified) (12 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/admingroup/PEInitUpdateAGAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/category/PEInitAddCategoryAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/category/PEInitUpdateCategoryAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEFetchEventAction.java (modified) (2 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEGetFormattedEventsAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEInitAddAlertAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEInitAddEventAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java (modified) (7 diffs)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/location/PEInitAddLocationAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/location/PEInitUpdateLocationAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/sponsor/PEInitAddSponsorAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/sponsor/PEInitUpdateSponsorAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/src/org/bedework/webadmin/timezones/PEInitUploadTimezonesAction.java (modified) (1 diff)
- trunk/calendar3/webadmin/war/docs/event/emitEvent.jsp (modified) (2 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java (modified) (3 diffs)
- trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/calendar3/appcommon/src/org/bedework/appcommon/FormattedEvents.java
r27 r128 61 61 import java.util.Collection; 62 62 import java.util.Iterator; 63 import java.util.Vector; 63 64 64 65 /** Object to provide a Collection of formatted BwEvent. … … 79 80 public FormattedEvents(Collection events, 80 81 CalendarInfo calInfo, CalTimezones ctz) { 81 this.events = events; 82 if (events == null) { 83 this.events = new Vector(); 84 } else { 85 this.events = events; 86 } 82 87 this.calInfo = calInfo; 83 88 this.ctz = ctz; trunk/calendar3/calCore/resources/properties/hibernate.properties
r2 r128 282 282 ## the Transaction API abstracts application code from the underlying JTA or JDBC transactions 283 283 284 #hibernate.transaction.factory_class net.sf.hibernate.transaction.JTATransactionFactory285 #hibernate.transaction.factory_class net.sf.hibernate.transaction.JDBCTransactionFactory284 #hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory 285 hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory 286 286 287 287 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java
r99 r128 503 503 504 504 /* Just commit */ 505 sess.flush();506 505 sess.commit(); 506 // sess.flush(); 507 507 } 508 508 … … 528 528 public void refreshEvents() throws CalFacadeException { 529 529 checkOpen(); 530 sess.flush();530 // sess.flush(); 531 531 } 532 532 trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
r119 r128 96 96 */ 97 97 public class Events extends CalintfHelper { 98 private UUIDHexGenerator uuidGen;98 private transient UUIDHexGenerator uuidGen; 99 99 100 100 /** Constructor … … 107 107 public Events(Calintf cal, AccessUtil access, BwUser user, boolean debug) { 108 108 super(cal, access, user, debug); 109 110 Properties uidprops = new Properties();111 uidprops.setProperty("separator", "-");112 uuidGen = new UUIDHexGenerator();113 ((Configurable)uuidGen).configure(Hibernate.STRING, uidprops, null);114 109 } 115 110 … … 727 722 } 728 723 729 String guidPrefix = "CAL-" + (String) uuidGen.generate(null, null);724 String guidPrefix = "CAL-" + (String)getUuidGen().generate(null, null); 730 725 731 726 if (val.getName() == null) { … … 805 800 StringBuffer sb = new StringBuffer(); 806 801 807 //if (debug) { 808 // log.debug("getEvents for " + objTimestamp + " start=" + 809 // startDate + " end=" + endDate); 810 //} 802 if (debug) { 803 trace("getEvents for start=" + startDate + " end=" + endDate); 804 } 811 805 812 806 /* Name of the event in the query */ … … 872 866 flt.parPass(sess); 873 867 868 if (debug) { 869 trace(sess.getQueryString()); 870 } 871 874 872 Collection es = sess.getList(); 873 874 if (debug) { 875 trace("Found " + es.size() + " events"); 876 } 875 877 876 878 es = postGetEvents(es, privRead, noAccessReturnsNull); … … 1446 1448 } 1447 1449 } 1450 1451 private UUIDHexGenerator getUuidGen() { 1452 if (uuidGen != null) { 1453 return uuidGen; 1454 } 1455 1456 Properties uidprops = new Properties(); 1457 uidprops.setProperty("separator", "-"); 1458 uuidGen = new UUIDHexGenerator(); 1459 ((Configurable)uuidGen).configure(Hibernate.STRING, uidprops, null); 1460 return uuidGen; 1461 } 1448 1462 } trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/HibSession.java
r2 r128 238 238 239 239 tx = sess.beginTransaction(); 240 if (tx == null) { 241 throw new CalFacadeException("Transaction not started"); 242 } 240 243 } catch (Throwable t) { 241 244 exc = t; … … 254 257 } 255 258 259 try { 260 // if (tx != null && 261 // !tx.wasCommitted() && 262 // !tx.wasRolledBack()) { 263 if (getLogger().isDebugEnabled()) { 264 getLogger().debug("About to comnmit"); 265 } 266 tx.commit(); 267 // } 268 269 tx = null; 270 } catch (Throwable t) { 271 exc = t; 272 throw new CalFacadeException(t); 273 } 274 } 275 276 /** Rollback a transaction 277 * 278 * @throws CalFacadeException 279 */ 280 public void rollback() throws CalFacadeException { 281 /* if (exc != null) { 282 // Didn't hear me last time? 283 throw new CalFacadeException(exc); 284 } 285 */ 286 if (getLogger().isDebugEnabled()) { 287 getLogger().debug("Enter rollback"); 288 } 256 289 try { 257 290 if (tx != null && 258 291 !tx.wasCommitted() && 259 292 !tx.wasRolledBack()) { 260 tx.commit(); 293 if (getLogger().isDebugEnabled()) { 294 getLogger().debug("About to rollback"); 295 } 296 tx.rollback(); 261 297 } 262 298 … … 268 304 } 269 305 270 /** Rollback a transaction271 *272 * @throws CalFacadeException273 */274 public void rollback() throws CalFacadeException {275 /* if (exc != null) {276 // Didn't hear me last time?277 throw new CalFacadeException(exc);278 }279 */280 Logger log = getLogger();281 282 if (log.isDebugEnabled()) {283 log.debug("Enter rollback");284 }285 try {286 if (tx != null &&287 !tx.wasCommitted() &&288 !tx.wasRolledBack()) {289 if (log.isDebugEnabled()) {290 log.debug("About to rollback");291 }292 tx.rollback();293 }294 295 tx = null;296 } catch (Throwable t) {297 exc = t;298 throw new CalFacadeException(t);299 }300 }301 302 306 /** Create a Criteria ready for the additon of Criterion. 303 307 * … … 357 361 } catch (Throwable t) { 358 362 handleException(t); 363 } 364 } 365 366 /** 367 * @return query string 368 * @throws CalFacadeException 369 */ 370 public String getQueryString() throws CalFacadeException { 371 if (q == null) { 372 return "*** no query ***"; 373 } 374 375 try { 376 return q.getQueryString(); 377 } catch (Throwable t) { 378 handleException(t); 379 return null; 359 380 } 360 381 } … … 867 888 } 868 889 890 if (getLogger().isDebugEnabled()) { 891 getLogger().debug("About to flush"); 892 } 869 893 try { 870 894 sess.flush(); … … 912 936 private void handleException(Throwable t) throws CalFacadeException { 913 937 try { 914 Logger log = getLogger(); 915 916 if (log.isDebugEnabled()) { 917 log.debug("handleException called"); 918 log.error(this, t); 938 if (getLogger().isDebugEnabled()) { 939 getLogger().debug("handleException called"); 940 getLogger().error(this, t); 919 941 } 920 942 } catch (Throwable dummy) {} … … 946 968 */ 947 969 private void rollbackException(Throwable t) { 948 Logger log = getLogger(); 949 950 if (log.isDebugEnabled()) { 951 log.debug("HibSession: ", t); 952 } 953 log.error(this, t); 970 if (getLogger().isDebugEnabled()) { 971 getLogger().debug("HibSession: ", t); 972 } 973 getLogger().error(this, t); 954 974 } 955 975 trunk/calendar3/calFacade/src/org/bedework/calfacade/BwAlarm.java
r48 r128 591 591 592 592 /* (non-Javadoc) 593 * @see org.bedework.calfacade.ifs.AttendeesI#copyAttendees() 594 */ 595 public Collection copyAttendees() { 596 if (attendees == null) { 597 return null; 598 } 599 600 return attendeesHelper.copyAttendees(); 601 } 602 603 /* (non-Javadoc) 593 604 * @see org.bedework.calfacade.AttendeesI#cloneAttendees() 594 605 */ trunk/calendar3/calFacade/src/org/bedework/calfacade/BwEvent.java
r119 r128 864 864 865 865 /* (non-Javadoc) 866 * @see org.bedework.calfacade.ifs.AttendeesI#copyAttendees() 867 */ 868 public Collection copyAttendees() { 869 if (attendees == null) { 870 return null; 871 } 872 873 return attendeesHelper.copyAttendees(); 874 } 875 876 /* (non-Javadoc) 866 877 * @see org.bedework.calfacade.AttendeesI#cloneAttendees() 867 878 */ … … 981 992 } 982 993 994 /** Copy this objects fields into the parameter. Don't clone many of the 995 * referenced objects 996 * 997 * @param ev 998 */ 999 public void shallowCopyTo(BwEvent ev) { 1000 super.shallowCopyTo(ev); 1001 ev.setName(getName()); 1002 ev.setSummary(getSummary()); 1003 ev.setDescription(getDescription()); 1004 ev.setDtstart(getDtstart()); 1005 ev.setDtend(getDtend()); 1006 ev.setEndType(getEndType()); 1007 ev.setDuration(getDuration()); 1008 ev.setLink(getLink()); 1009 ev.setDeleted(getDeleted()); 1010 ev.setStatus(getStatus()); 1011 ev.setCost(getCost()); 1012 1013 ev.setOrganizer(getOrganizer()); 1014 1015 ev.setDtstamp(getDtstamp()); 1016 ev.setLastmod(getLastmod()); 1017 ev.setCreated(getCreated()); 1018 ev.setPriority(getPriority()); 1019 ev.setSequence(getSequence()); 1020 1021 ev.setSponsor(getSponsor()); 1022 1023 ev.setLocation(getLocation()); 1024 1025 ev.setGuid(getGuid()); 1026 ev.setTransparency(getTransparency()); 1027 1028 /* XXX shallow copy categories */ 1029 Iterator it = iterateCategories(); 1030 TreeSet cs = new TreeSet(); 1031 1032 while (it.hasNext()) { 1033 BwCategory c = (BwCategory)it.next(); 1034 1035 cs.add(c); 1036 } 1037 1038 ev.setCategories(cs); 1039 1040 ev.setAttendees(copyAttendees()); 1041 ev.setRecurring(getRecurring()); 1042 1043 ev.setRecurrence((BwRecurrence)getRecurrence().clone()); 1044 } 1045 983 1046 /** Copy this objects fields into the parameter 984 1047 * … … 1041 1104 ev.setRecurring(getRecurring()); 1042 1105 1043 /* This ought to be cloned but it brings with it a 1044 whole set of instances. Leave for the moment */ 1045 ev.setRecurrence(getRecurrence()); 1106 ev.setRecurrence((BwRecurrence)getRecurrence().clone()); 1046 1107 } 1047 1108 trunk/calendar3/calFacade/src/org/bedework/calfacade/BwRecurrence.java
r48 r128 350 350 351 351 public Object clone() { 352 return new BwRecurrence( (Collection)((TreeSet)getRrules()).clone(),353 (Collection)((TreeSet)getExrules()).clone(),354 (Collection)((TreeSet)getRdates()).clone(),355 (Collection)((TreeSet)getExdates()).clone(),352 return new BwRecurrence(clone(getRrules()), 353 clone(getExrules()), 354 clone(getRdates()), 355 clone(getExdates()), 356 356 getRecurrenceId(), 357 357 getLatestDate(), 358 358 getExpanded()); 359 359 } 360 361 /* ==================================================================== 362 * Private methods 363 * =================================================================== */ 364 365 private Collection clone(Collection c) { 366 if (c == null) { 367 return null; 368 } 369 370 Iterator cit = c.iterator(); 371 TreeSet ts = new TreeSet(); 372 373 while (cit.hasNext()) { 374 ts.add(cit.next()); 375 } 376 377 return ts; 378 } 360 379 } trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwOwnedDbentity.java
r2 r128 132 132 } 133 133 134 /** Copy this objects fields into the parameter. Don't clone many of the 135 * referenced objects 136 * 137 * @param val 138 */ 139 public void shallowCopyTo(BwOwnedDbentity val) { 140 val.setOwner((BwUser)getOwner()); 141 val.setPublick(getPublick()); 142 } 143 134 144 /** Copy this objects fields into the parameter 135 145 * trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwShareableContainedDbentity.java
r2 r128 123 123 } 124 124 125 /** Copy this objects fields into the parameter. Don't clone many of the 126 * referenced objects 127 * 128 * @param val 129 */ 130 public void shallowCopyTo(BwShareableContainedDbentity val) { 131 super.shallowCopyTo(val); 132 val.setCalendar((BwCalendar)getCalendar()); 133 } 134 125 135 /** Copy this objects fields into the parameter 126 136 * … … 129 139 public void copyTo(BwShareableContainedDbentity val) { 130 140 super.copyTo(val); 131 val.setCalendar((BwCalendar)getCalendar() );141 val.setCalendar((BwCalendar)getCalendar().clone()); 132 142 } 133 143 } trunk/calendar3/calFacade/src/org/bedework/calfacade/base/BwShareableDbentity.java
r2 r128 140 140 } 141 141 142 /** Copy this objects fields into the parameter. Don't clone many of the 143 * referenced objects 144 * 145 * @param val 146 */ 147 public void shallowCopyTo(BwShareableDbentity val) { 148 super.shallowCopyTo(val); 149 val.setCreator((BwUser)getCreator()); 150 val.setAccess(getAccess()); 151 } 152 142 153 /** Copy this objects fields into the parameter 143 154 * trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/Attendees.java
r2 r128 169 169 } 170 170 171 /** Return a c loneof the collection171 /** Return a copy of the collection 172 172 * 173 173 * @return Collection of BwAttendee 174 174 */ 175 public Collection c loneAttendees() {175 public Collection copyAttendees() { 176 176 TreeSet ts = new TreeSet(); 177 177 … … 180 180 BwAttendee att = (BwAttendee)it.next(); 181 181 182 ts.add(att); 183 } 184 185 return ts; 186 } 187 188 /** Return a clone of the collection 189 * 190 * @return Collection of BwAttendee 191 */ 192 public Collection cloneAttendees() { 193 TreeSet ts = new TreeSet(); 194 195 Iterator it = iterateAttendees(); 196 while (it.hasNext()) { 197 BwAttendee att = (BwAttendee)it.next(); 198 182 199 ts.add(att.clone()); 183 200 } trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/AttendeesI.java
r2 r128 69 69 public String[] getAttendeeEmailList(); 70 70 71 /** Return a copy of the collection 72 * 73 * @return Collection of BwAttendee 74 */ 75 public Collection copyAttendees(); 76 71 77 /** Return a clone of the collection 72 78 * trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/EventInfo.java
r2 r128 67 67 * session. 68 68 * 69 * <p>This is designed to avoid problems wih persistace engines. In particular70 * objects may be shared among many threads for different users in different71 * contexts. All information in an entity must be the same for any user.72 *73 69 * <p>This class allows us to handle thread, or user, specific information. 74 70 * … … 80 76 /** editable is set at retrieval to indicate an event owned by the current 81 77 * user. This only has significance for the personal calendar. 82 *83 * XXX - not applicable in a shared world?84 78 */ 85 79 protected boolean editable; … … 87 81 protected boolean fromRef; 88 82 89 /* XXX these need changing90 * 83 /* ENUM 84 * XXX these need changing 91 85 */ 92 86 trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
r119 r128 1440 1440 1441 1441 if (currentView != null) { 1442 if (debug) { 1443 trace("Use current view \"" + currentView.getName() + "\""); 1444 } 1445 1442 1446 it = currentView.iterateSubscriptions(); 1443 1447 } else { … … 1445 1449 if (subs == null) { 1446 1450 // Try set of users subscriptions. 1451 if (debug) { 1452 trace("Use user subscriptions"); 1453 } 1454 1447 1455 subs = getSubscriptions(); 1456 } else if (debug) { 1457 trace("Use current subscriptions"); 1448 1458 } 1449 1459 1450 1460 if (subs == null) { 1461 if (debug) { 1462 trace("Make up ALL events"); 1463 } 1464 1451 1465 sub = new BwSubscription(); 1452 1466 sub.setName("All events"); // XXX property? trunk/calendar3/quickstartFiles/tomcat.conf/server.xml
r2 r128 98 98 to -1 --> 99 99 100 <!-- Note : To use gzip compression you could set the following properties :101 102 compression="on"103 compressionMinSize="2048"104 noCompressionUserAgents="gozilla, traviata"105 compressableMimeType="text/html,text/xml"106 -->100 <!-- Note : To use gzip compression you could set the following properties : 101 102 compression="on" 103 compressionMinSize="2048" 104 noCompressionUserAgents="gozilla, traviata" 105 compressableMimeType="text/html,text/xml" 106 --> 107 107 108 108 <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> … … 359 359 360 360 <!-- make the cal DataSource available in all contexts --> 361 362 <!-- Uncomment to use p6spy - change settings in 363 common/classes/spy.properties, in particular the location 364 of the log file 361 365 <DefaultContext> 362 366 <Resource name="jdbc/calDB" auth="Container" … … 373 377 <parameter> 374 378 <name>driverClassName</name> 375 <value> org.hsqldb.jdbcDriver</value>379 <value>com.p6spy.engine.spy.P6SpyDriver</value> 376 380 </parameter> 377 381 <parameter> … … 389 393 </ResourceParams> 390 394 </DefaultContext> 395 --> 396 397 <!-- without p6spy--> 398 <DefaultContext> 399 <Resource name="jdbc/calDB" auth="Container" 400 type="javax.sql.DataSource"/> 401 <ResourceParams name="jdbc/calDB"> 402 <parameter> 403 <name>username</name> 404 <value>sa</value> 405 </parameter> 406 <parameter> 407 <name>password</name> 408 <value></value> 409 </parameter> 410 <parameter> 411 <name>driverClassName</name> 412 <value>org.hsqldb.jdbcDriver</value> 413 </parameter> 414 <parameter> 415 <name>url</name> 416 <value>jdbc:hsqldb:hsql://localhost:8887</value> 417 </parameter> 418 <parameter> 419 <name>maxActive</name> 420 <value>8</value> 421 </parameter> 422 <parameter> 423 <name>maxIdle</name> 424 <value>4</value> 425 </parameter> 426 <parameter> 427 <name>defaultAutoCommit</name> 428 <value>false</value> 429 </parameter> 430 </ResourceParams> 431 </DefaultContext> 391 432 392 433 <!-- turn off session persistence by supplying an empty pathname for 393 these contexts -->434 these contexts --> 394 435 <Context path="/caladmin" docBase="caladmin" debug="0"> 395 436 <Manager … … 406 447 <Context path="/ucal" docBase="ucal" debug="0"> 407 448 <Manager 408 className="org.apache.catalina.session.StandardManager"409 pathname="" />410 </Context>449 className="org.apache.catalina.session.StandardManager" 450 pathname="" /> 451 </Context> 411 452 412 453 </Host> trunk/calendar3/webadmin/src/org/bedework/webadmin/PEAbstractAction.java
r24 r128 56 56 57 57 58 import org.bedework.appcommon.IntSelectId; 59 import org.bedework.calfacade.BwCalendar; 60 import org.bedework.calfacade.BwCategory; 61 import org.bedework.calfacade.BwEvent; 62 import org.bedework.calfacade.BwLocation; 63 import org.bedework.calfacade.BwSponsor; 58 64 import org.bedework.webcommon.BwAbstractAction; 59 65 import org.bedework.webcommon.BwActionFormBase; … … 85 91 PEActionForm form = (PEActionForm)frm; 86 92 87 /*88 CalEnv env = getEnv(frm);89 90 / * Set some options from the environment * /91 form.setAutoCreateSponsors(env.getAppBoolProperty("app.autocreatesponsors"));92 form.setAutoCreateLocations(env.getAppBoolProperty("app.autocreatelocations"));93 form.setAutoDeleteSponsors(env.getAppBoolProperty("app.autodeletesponsors"));94 form.setAutoDeleteLocations(env.getAppBoolProperty("app.autodeletelocations"));95 96 if (debug) {97 logIt("form.getGroupSet()=" + form.getGroupSet());98 }99 100 / ** Show the owner we are administering * /101 form.setAdminUserId(form.getCalSvcI().getUser().getAccount());102 103 if (debug) {104 logIt("-------- isSuperUser: " + form.getUserAuth().isSuperUser());105 }106 107 if (!form.getAuthorisedUser()) {108 return "noAccess";109 }110 111 String temp = checkGroup(request, form, true);112 if (temp != null) {113 if (debug) {114 logIt("form.getGroupSet()=" + form.getGroupSet());115 }116 return temp;117 }118 119 / ** Ensure we have prefs and other values for the AuthUser120 * /121 setAuthUser(form);122 123 String reqpar = request.getParameter("cancelled");124 125 if (reqpar != null) {126 / ** Set the objects to null so we get new ones.127 * /128 form.initFields();129 form.setEvent(null);130 131 form.getMsg().emit("org.bedework.client.message.cancelled");132 return "cancelled";133 }134 */135 136 93 return doAction(request, sess, form); 137 94 } … … 149 106 PEActionForm form) throws Throwable; 150 107 151 /* ********************************************************************152 package methods153 ******************************************************************** */154 155 /* * Return null if group is chosen else return a forward name.156 *157 * @param request Needed to locate session158 * @param form Action form159 * @param initCheck true if this is a check to see if we're initialised,160 * otherwise this is an explicit request to change group.161 * @return String forward name162 * /163 protected String checkGroup(HttpServletRequest request,164 PEActionForm form,165 boolean initCheck) throws Throwable {166 if (form.getGroupSet()) {167 return null;168 }169 170 CalSvcI svci = form.getCalSvcI();171 172 try {173 Groups adgrps = svci.getGroups();174 175 if (form.retrieveChoosingGroup()) {176 /* * This should be the response to presenting a list of groups.177 We handle it here rather than in a separate action to ensure our178 client is not trying to bypass the group setting.179 * /180 181 String reqpar = request.getParameter("adminGroupName");182 if (reqpar == null) {183 // Make them do it again.184 185 return "chooseGroup";186 }187 188 return setGroup(request, form, adgrps, reqpar);189 }190 191 /* * If the user is in no group or in one group we just go with that,192 otherwise we ask them to select the group193 * /194 195 Collection adgs;196 197 BwUser user = svci.findUser(form.getCurrentUser());198 if (user == null) {199 return "noAccess";200 }201 202 if (initCheck || !form.getUserAuth().isSuperUser()) {203 // Always restrict to groups we're a member of204 adgs = adgrps.getGroups(user);205 } else {206 adgs = adgrps.getAll();207 }208 209 if (adgs.isEmpty()) {210 /* * If we require that all users be in a group we return to an error211 page. The only exception will be superUser.212 * /213 214 boolean noGroupAllowed =215 form.getEnv().getAppBoolProperty("app.nogroupallowed");216 if (form.getUserAuth().isSuperUser() || noGroupAllowed) {217 form.assignAdminGroup(null);218 return null;219 }220 221 return "noGroupAssigned";222 }223 224 if (adgs.size() == 1) {225 Iterator adgsit = adgs.iterator();226 227 BwAdminGroup adg = (BwAdminGroup)adgsit.next();228 229 form.assignAdminGroup(adg);230 String s = setAdminUser(request, form, adg.getOwner().getAccount(), true);231 232 if (s != null) {233 return s;234 }235 236 form.setAdminUserId(svci.getUser().getAccount());237 return null;238 }239 240 /* * Go ahead and present the possible groups241 * /242 form.setUserAdminGroups(adgs);243 form.assignChoosingGroup(true); // reset244 245 return "chooseGroup";246 } catch (Throwable t) {247 form.getErr().emit(t);248 return "error";249 }250 }*/251 108 252 109 /* ******************************************************************** 253 110 protected methods 254 111 ******************************************************************** */ 255 /*256 protected String setAdminUser(HttpServletRequest request,257 PEActionForm form,258 String user,259 boolean isMember) throws Throwable {260 int access = getAccess(request, getMessages());261 112 262 // if (form.getCalSvcI() != null) { 263 // form.getCalSvcI().close(); 264 // } 113 protected void initFields(BwActionFormBase frm) { 114 PEActionForm form = (PEActionForm)frm; 115 super.initFields(frm); 116 form.setEventInfo(null); 117 resetEvent(form); 265 118 266 if (!checkSvci(request, form, form.getSession(), access, user, true, 267 isMember, debug)) { 268 return "accessError"; 119 form.setCategory(null); 120 form.setSponsor(null); 121 form.setLocation(null); 122 form.setUpdGroupMember(null); 123 } 124 125 protected void resetEvent(PEActionForm form) { 126 BwEvent event = form.getEditEvent(); 127 128 /* Implant the current id(s) in new entries */ 129 int id = 0; 130 BwCategory k = event.getFirstCategory(); 131 if (k != null) { 132 id = k.getId(); 133 form.setCategory(k); 269 134 } 270 135 271 return null; 136 /* A is the All box, B is the user preferred values. */ 137 form.assignCategoryId(new IntSelectId(id, IntSelectId.AHasPrecedence)); 138 139 BwSponsor s = event.getSponsor(); 140 id = 0; 141 if (s != null) { 142 id = s.getId(); 143 form.setSponsor(s); 144 } 145 146 form.assignSpId(new IntSelectId(id, IntSelectId.AHasPrecedence)); 147 148 BwLocation l = event.getLocation(); 149 id = 0; 150 if (l != null) { 151 id = l.getId(); 152 form.setLocation(l); 153 } 154 155 form.assignLocId(new IntSelectId(id, IntSelectId.AHasPrecedence)); 156 157 BwCalendar c = event.getCalendar(); 158 id = 0; 159 if (c != null) { 160 id = c.getId(); 161 form.setCalendar(c); 162 } 163 164 form.assignCalendarId(new IntSelectId(id, IntSelectId.AHasPrecedence)); 272 165 } 273 166 274 protected BwAuthUser getAuthUser(PEActionForm form) throws CalFacadeException {275 UserAuth ua = form.retrieveUserAuth();276 return ua.getUser(form.getCurrentUser());277 }278 */279 /* ********************************************************************280 private methods281 ******************************************************************** */282 283 /*284 private boolean isMember(BwAdminGroup ag,285 PEActionForm form) throws Throwable {286 return ag.isMember(String.valueOf(form.getCurrentUser()));287 }288 289 / * Set information associated witht he current auth user.290 * Set the prefs on each request to reflect other session changes291 * /292 private void setAuthUser(PEActionForm form) throws CalFacadeException {293 BwAuthUser au = getAuthUser(form);294 BwAuthUserPrefs prefs = au.getPrefs();295 if (prefs == null) {296 prefs = new BwAuthUserPrefs();297 }298 299 form.setAuthUserPrefs(prefs);300 301 int rights = au.getUsertype();302 303 form.assignAuthUserAlerts((rights & UserAuth.alertUser) != 0);304 form.assignAuthUserPublicEvents((rights & UserAuth.publicEventUser) != 0);305 form.assignAuthUserSuperUser((rights & UserAuth.superUser) != 0);306 }307 308 private String setGroup(HttpServletRequest request,309 PEActionForm form,310 Groups adgrps,311 String groupName) throws Throwable {312 if (groupName == null) {313 // We require a name314 return "chooseGroup";315 }316 317 BwAdminGroup ag = (BwAdminGroup)adgrps.findGroup(groupName);318 319 if (debug) {320 if (ag == null) {321 logIt("No user admin group with name " + groupName);322 } else {323 logIt("Retrieved user admin group " + ag.getAccount());324 }325 }326 327 form.assignAdminGroup(ag);328 329 String s = setAdminUser(request, form, ag.getOwner().getAccount(),330 isMember(ag, form));331 332 if (s != null) {333 return s;334 }335 336 form.setAdminUserId(form.getCalSvcI().getUser().getAccount());337 338 return null;339 }340 */341 167 } 342 168 trunk/calendar3/webadmin/src/org/bedework/webadmin/PEActionForm.java
r55 r128 56 56 57 57 import org.bedework.appcommon.IntSelectId; 58 import org.bedework.calfacade.BwCalendar;59 58 import org.bedework.calfacade.BwCategory; 60 59 import org.bedework.calfacade.BwEvent; 61 import org.bedework.calfacade.BwEventObj;62 60 import org.bedework.calfacade.BwLocation; 63 61 import org.bedework.calfacade.BwSponsor; … … 66 64 import org.bedework.calfacade.svc.BwAdminGroup; 67 65 import org.bedework.calfacade.svc.BwAuthUser; 68 import org.bedework.calfacade.svc.EventInfo;69 66 import org.bedework.calfacade.svc.UserAuth; 70 67 import org.bedework.webcommon.BwActionFormBase; 71 import org.bedework.webcommon.BwWebUtil;72 68 73 69 import edu.rpi.sss.util.Util; 74 70 75 //import java.sql.Date;76 71 import java.util.Collection; 77 72 import java.util.HashMap; … … 96 91 * ................................................................... */ 97 92 98 private EventInfo eventInfo;99 private BwEvent event;100 93 101 94 /** True if we are adding an alert … … 293 286 * ==================================================================== */ 294 287 288 289 /** XXX Remove this when the jsp is pointed at the common actions. 290 * 291 * @param val 292 */ 293 public void setEvent(BwEvent val) { 294 setEditEvent(val); 295 } 296 297 /** 298 * @return event 299 */ 300 public BwEvent getEvent() { 301 return getEditEvent(); 302 } 303 295 304 /** Not set - invisible to jsp 296 305 */ … … 340 349 341 350 /** 342 * @param val343 */344 public void setEventInfo(EventInfo val) {345 eventInfo = val;346 if (val == null) {347 setEvent(null);348 } else {349 setEvent(val.getEvent());350 }351 }352 353 /**354 * @return EventInfo355 */356 public EventInfo getEventInfo() {357 return eventInfo;358 }359 360 /**361 * @param val362 */363 public void setEvent(BwEvent val) {364 event = val;365 366 try {367 if (val == null) {368 getEventDates().setNewEvent(getEvent(), fetchSvci().getTimezones());369 } else {370 getEventDates().setFromEvent(getEvent(), fetchSvci().getTimezones());371 }372 } catch (Throwable t) {373 err.emit(t);374 }375 376 if (debug) {377 debugMsg("setEvent(), dates=" + getEventDates());378 }379 380 resetEvent();381 }382 383 /**384 *385 */386 public void resetEvent() {387 getEvent(); // Make sure we have one388 389 /* Implant the current id(s) in new entries */390 int id = 0;391 BwCategory k = event.getFirstCategory();392 if (k != null) {393 id = k.getId();394 setCategory(k);395 }396 397 /* A is the All box, B is the user preferred values. */398 categoryId = new IntSelectId(id, IntSelectId.AHasPrecedence);399 400 BwSponsor s = event.getSponsor();401 id = 0;402 if (s != null) {403 id = s.getId();404 setSponsor(s);405 }406 407 spId = new IntSelectId(id, IntSelectId.AHasPrecedence);408 409 BwLocation l = event.getLocation();410 id = 0;411 if (l != null) {412 id = l.getId();413 setLocation(l);414 }415 416 locId = new IntSelectId(id, IntSelectId.AHasPrecedence);417 418 BwCalendar c = event.getCalendar();419 id = 0;420 if (c != null) {421 id = c.getId();422 setCalendar(c);423 }424 425 calendarId = new IntSelectId(id, IntSelectId.AHasPrecedence);426 }427 428 /** If an event object exists, return that otherwise create an empty one.429 *430 * @return BwEvent populated event value object431 */432 public BwEvent getEvent() {433 if (event == null) {434 event = new BwEventObj();435 eventInfo = new EventInfo(event);436 }437 return event;438 }439 440 /**441 351 * 442 352 * @param val Collection of formatted events … … 454 364 return formattedEvents; 455 365 } 456 457 /* * Get the i'th category id from the event object. Return < 0 for none.458 *459 * @param i int index into events vector of categories460 * @return int Category index or -1461 * /462 public int getEventCategoryId(int i) {463 CategoryVO k = getEvent().getCategory(i);464 465 if (k == null) {466 return -1;467 }468 469 return k.getId();470 }471 472 /* * Get the i'th category from the event object. Return null for none.473 *474 * @param i int index into events vector of keywors475 * @return CategoryVO Category object or null476 * /477 public CategoryVO getEventCategory(int i) {478 return getEvent().getCategory(i);479 }480 */481 366 482 367 /* ==================================================================== … … 516 401 517 402 return category; 403 } 404 405 /** 406 * @param val IntSelectId id object 407 */ 408 public void assignCategoryId(IntSelectId val) { 409 categoryId = val; 410 } 411 412 /** 413 * @return IntSelectId id object 414 */ 415 public IntSelectId retrieveCategoryId() { 416 return categoryId; 518 417 } 519 418 … … 632 531 } 633 532 533 /** 534 * @param val IntSelectId id object 535 */ 536 public void assignSpId(IntSelectId val) { 537 spId = val; 538 } 539 540 /** 541 * @return IntSelectId id object 542 */ 543 public IntSelectId retrieveSpId() { 544 return spId; 545 } 546 634 547 /** We have a preferred and all sponsors form field. One of them may be 635 548 * unset so we ignore negative values. … … 726 639 } 727 640 641 /** 642 * @param val IntSelectId id object 643 */ 644 public void assignLocId(IntSelectId val) { 645 locId = val; 646 } 647 648 /** 649 * @return IntSelectId id object 650 */ 651 public IntSelectId retrieveLocId() { 652 return locId; 653 } 654 728 655 /** We have a preferred and all locations form field. One of them will be 729 656 * unset so we ignore negative values. … … 779 706 * Calendars 780 707 * ==================================================================== */ 708 709 /** 710 * @param val IntSelectId id object 711 */ 712 public void assignCalendarId(IntSelectId val) { 713 calendarId = val; 714 } 715 716 /** 717 * @return IntSelectId id object 718 */ 719 public IntSelectId retrieveCalendarId() { 720 return calendarId; 721 } 781 722 782 723 /** We have a preferred and all calendars form field. One of them will be … … 1088 1029 * ==================================================================== */ 1089 1030 1090 /**1091 *1092 * @return boolean false means something wrong, message emitted1093 * @throws Throwable1094 */1095 public boolean validateEventCategory() throws Throwable {1096 int id = categoryId.getVal();1097 1098 if (id <= 0) {1099 if (getEnv().getAppBoolProperty("app.categoryOptional")) {1100 return true;1101 }1102 1103 err.emit("org.bedework.client.error.missingfield", "Category");1104 return false;1105 }1106 1107 try {1108 BwCategory k = fetchSvci().getCategory(id);1109 1110 if (k == null) {1111 err.emit("org.bedework.client.error.missingcategory", id);1112 return false;1113 }1114 1115 if (!categoryId.getChanged()) {1116 return true;1117 }1118 1119 // oldCategory = getEvent().getCategory(0);1120 1121 1122 /* Currently we replace the only category if it exists1123 */1124 BwEvent ev = getEvent();1125 ev.clearCategories();1126 ev.addCategory(k);1127 1128 setCategory(k);1129 1130 return true;1131 } catch (Throwable t) {1132 err.emit(t);1133 return false;1134 }1135 }1136 1137 /** Validate the sponsor provided for an event and embed it in the event and1138 * the form.1139 *1140 * @return boolean true OK, false not OK and message(s) emitted.1141 * @throws Throwable1142 */1143 public boolean validateEventSponsor() throws Throwable {1144 boolean ok = true;1145 1146 if (!spId.getChanged()) {1147 if (getAutoCreateSponsors()) {1148 BwSponsor s = getSponsor();1149 if (!BwWebUtil.validateSponsor(s, err)) {1150 return false;1151 }1152 1153 fetchSvci().ensureSponsorExists(s);1154 1155 setSponsor(s);1156 getEvent().setSponsor(s);1157 }1158 1159 if (event.getSponsor() == null) {1160 err.emit("org.bedework.client.error.missingfield", "Sponsor");1161 return false;1162 }1163 1164 return ok;1165 }1166 1167 // The user selected one from the list1168 int id = spId.getVal();1169 1170 try {1171 BwSponsor s = fetchSvci().getSponsor(id);1172 if (s == null) {1173 // Somebody's faking1174 setSponsor(null);1175 err.emit("org.bedework.client.error.missingfield", "Sponsor");1176 return false;1177 }1178 1179 getEvent().setSponsor(s);1180 1181 setSponsor(s);1182 return true;1183 } catch (Throwable t) {1184 err.emit(t);1185 return false;1186 }1187 }1188 1189 /** Validate the location provided for an event and embed it in the event and1190 * the form.1191 *1192 * @return boolean true OK, false not OK and message(s) emitted.1193 * @throws Throwable1194 */1195 public boolean validateEventLocation() throws Throwable {1196 boolean ok = true;1197 1198 if (!locId.getChanged()) {1199 if (getAutoCreateLocations()) {1200 BwLocation l = getLocation();1201 1202 if (!BwWebUtil.validateLocation(l, err)) {1203 return false;1204 }1205 1206 1207 fetchSvci().ensureLocationExists(l);1208 1209 setLocation(l);1210 getEvent().setLocation(l);1211 }1212 1213 if (event.getLocation() == null) {1214 err.emit("org.bedework.client.error.missingfield", "Location");1215 return false;1216 }1217 1218 return ok;1219 }1220 1221 // The user selected one from the list1222 1223 try {1224 int id = locId.getVal();1225 BwLocation l = fetchSvci().getLocation(id);1226 1227 if ((l == null) || !l.getPublick()) {1228 // Somebody's faking1229 setLocation(null);1230 err.emit("org.bedework.client.error.missingfield", "Location");1231 return false;1232 }1233 1234 getEvent().setLocation(l);1235 setLocation(l);1236 1237 return true;1238 } catch (Throwable t) {1239 err.emit(t);1240 return false;1241 }1242 }1243 1244 /** Validate the calendar provided for an event and embed it in the event and1245 * the form.1246 *1247 * @return boolean true OK, false not OK and message(s) emitted.1248 */1249 public boolean validateEventCalendar() {1250 boolean ok = true;1251 1252 if (!calendarId.getChanged()) {1253 if (event.getCalendar() == null) {1254 err.emit("org.bedework.client.error.missingfield", "Calendar");1255 return false;1256 }1257 1258 return ok;1259 }1260 1261 // The user selected one from the list1262 1263 try {1264 int id = calendarId.getVal();1265 1266 BwCalendar c = fetchSvci().getCalendar(id);1267 1268 if ((c == null) || !c.getPublick() || !c.getCalendarCollection()) {1269 // Somebody's faking1270 setCalendar(null);1271 err.emit("org.bedework.client.error.missingfield", "Calendar");1272 return false;1273 }1274 1275 getEvent().setCalendar(c);1276 setCalendar(c);1277 return true;1278 } catch (Throwable t) {1279 err.emit(t);1280 return false;1281 }1282 }1283 1284 1031 /** Validate a category entry after add/mod 1285 1032 * … … 1303 1050 } 1304 1051 1305 /**1306 *1307 */1308 public void initFields() {1309 super.initFields();1310 event = null;1311 category = null;1312 // oldCategory = null;1313 sponsor = null;1314 location = null;1315 updGroupMember = null;1316 }1317 1318 1052 /* ==================================================================== 1319 1053 * Private methods trunk/calendar3/webadmin/src/org/bedework/webadmin/admingroup/PEInitUpdateAGAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingAdmingroup(false); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/category/PEInitAddCategoryAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingCategory(true); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/category/PEInitUpdateCategoryAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingCategory(false); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEFetchEventAction.java
r55 r128 102 102 * the form so we can display the page 103 103 */ 104 int id = form.getEventId(); 104 // XXX Needs to change to use guid? 105 int id = this.getIntReqPar(request, "eventId", -1); 105 106 106 107 if (id <= 0) { … … 124 125 125 126 form.setEventInfo(einf); 127 resetEvent(form); 128 126 129 if (einf == null) { 127 130 form.getErr().emit("org.bedework.client.error.nosuchevent", id); trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEGetFormattedEventsAction.java
r55 r128 124 124 125 125 return form.fetchSvci().getEvents(null, filter, fromDate, null, 126 CalFacadeDefs.retrieveRecurExpanded);126 CalFacadeDefs.retrieveRecurExpanded); 127 127 } 128 128 trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEInitAddAlertAction.java
r2 r128 87 87 /** Set the objects to null so we get new ones. 88 88 */ 89 form.initFields(); 90 form.setEvent(null); 89 initFields(form); 91 90 form.assignAlertEvent(true); 92 91 form.assignAddingEvent(true); 93 form.resetEvent();94 92 95 93 return "continue"; trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEInitAddEventAction.java
r2 r128 87 87 /** Set the objects to null so we get new ones. 88 88 */ 89 form.initFields(); 90 form.setEvent(null); 89 initFields(form); 91 90 form.assignAlertEvent(false); 92 91 form.assignAddingEvent(true); 93 form.resetEvent();94 92 95 93 return "continue"; trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEUpdateEventAction.java
r55 r128 55 55 package org.bedework.webadmin.event; 56 56 57 import org.bedework.calfacade.BwCalendar; 58 import org.bedework.calfacade.BwCategory; 57 59 import org.bedework.calfacade.BwEvent; 58 60 import org.bedework.calfacade.BwEventObj; 61 import org.bedework.calfacade.BwLocation; 62 import org.bedework.calfacade.BwSponsor; 59 63 import org.bedework.calfacade.CalFacadeDefs; 64 import org.bedework.calfacade.svc.EventInfo; 60 65 import org.bedework.calsvci.CalSvcI; 61 66 import org.bedework.webadmin.PEAbstractAction; … … 63 68 import org.bedework.webcommon.BwSession; 64 69 import org.bedework.webcommon.BwWebUtil; 70 71 import edu.rpi.sss.util.log.MessageEmit; 65 72 66 73 … … 108 115 } 109 116 117 BwEvent event = form.getEditEvent(); 118 110 119 reqpar = request.getParameter("copy"); 111 120 112 121 if (reqpar != null) { 122 /* Refetch the event and switch it for a cloned copy. 123 * guid must be set to null to avoid dup guid. 124 */ 125 EventInfo ei = form.fetchSvci().getEvent(event.getId()); 113 126 BwEvent evcopy = new BwEventObj(); 114 form.getEvent().copyTo(evcopy);127 ei.getEvent().shallowCopyTo(evcopy); 115 128 116 129 evcopy.setId(CalFacadeDefs.unsavedItemKey); 117 form.setEvent(evcopy); 130 evcopy.setGuid(null); 131 132 if (debug) { 133 BwLocation l = evcopy.getLocation(); 134 if (l == null) { 135 debugMsg("Copied event has null location"); 136 } else { 137 debugMsg("Copied event has location with id " + l.getId()); 138 } 139 } 140 141 ei.setEvent(evcopy); 142 143 form.setEventInfo(ei); 144 resetEvent(form); 118 145 form.assignAddingEvent(true); 119 146 … … 122 149 123 150 CalSvcI svci = form.fetchSvci(); 124 if (!validateEvent(form )) {151 if (!validateEvent(form, svci, event, form.getErr())) { 125 152 return "retry"; 126 153 } … … 130 157 */ 131 158 132 BwEvent ev = form.getEvent(); 133 134 ev.setPublick(true); 159 event.setPublick(true); 135 160 136 161 if (form.getAddingEvent()) { 137 svci.addEvent(ev , null);162 svci.addEvent(event, null); 138 163 } else { 139 svci.updateEvent(ev );164 svci.updateEvent(event); 140 165 } 141 166 142 167 if (!alerts) { 143 updateAuthPrefs(form, ev.getCategories(), ev.getSponsor(), ev.getLocation(), 144 ev.getCalendar()); 145 } 146 147 form.resetEvent(); 148 149 form.assignAddingEvent(false); 168 updateAuthPrefs(form, event.getCategories(), event.getSponsor(), 169 event.getLocation(), 170 event.getCalendar()); 171 } 172 173 resetEvent(form); 150 174 151 175 if (form.getAddingEvent()) { … … 154 178 form.getMsg().emit("org.bedework.client.message.event.updated"); 155 179 } 180 181 form.assignAddingEvent(false); 182 156 183 return "continue"; 157 184 } … … 162 189 * categories and embed them in the form and event. 163 190 */ 164 private boolean validateEvent(PEActionForm form ) throws Throwable {165 boolean ok = form.validateEventCategory();166 BwEvent ev = form.getEvent();167 CalSvcI svci = form.fetchSvci();168 169 if (! form.validateEventSponsor()) {191 private boolean validateEvent(PEActionForm form, CalSvcI svci, 192 BwEvent event, MessageEmit err) 193 throws Throwable { 194 boolean ok = validateEventCategory(form, svci, event, err); 195 196 if (!validateEventSponsor(form, svci, event, err)) { 170 197 ok = false; 171 198 } 172 199 173 if (! form.validateEventLocation()) {200 if (!validateEventLocation(form, svci, event, err)) { 174 201 ok = false; 175 202 } 176 203 177 if (! form.validateEventCalendar()) {204 if (!validateEventCalendar(form, svci, event, err)) { 178 205 ok = false; 179 206 } 180 207 181 if (!form.getEventDates().updateEvent(ev , svci.getTimezones())) {208 if (!form.getEventDates().updateEvent(event, svci.getTimezones())) { 182 209 ok = false; 183 210 } else { 184 ok = BwWebUtil.validateEvent(svci, ev , true, //descriptionRequired185 form.getErr());211 ok = BwWebUtil.validateEvent(svci, event, true, // ENUM descriptionRequired 212 err); 186 213 } 187 214 188 215 return ok; 189 216 } 217 218 /** Validate the calendar provided for an event and embed it in the event and 219 * the form. 220 * 221 * @return boolean true OK, false not OK and message(s) emitted. 222 */ 223 private boolean validateEventCalendar(PEActionForm form, CalSvcI svci, 224 BwEvent event, MessageEmit err) 225 throws Throwable { 226 boolean ok = true; 227 228 if (!form.retrieveCalendarId().getChanged()) { 229 if (event.getCalendar() == null) { 230 err.emit("org.bedework.client.error.missingfield", "Calendar"); 231 return false; 232 } 233 234 return ok; 235 } 236 237 // The user selected one from the list 238 239 try { 240 int id = form.retrieveCalendarId().getVal(); 241 242 BwCalendar c = svci.getCalendar(id); 243 244 if ((c == null) || !c.getPublick() || !c.getCalendarCollection()) { 245 // Somebody's faking 246 form.setCalendar(null); 247 err.emit("org.bedework.client.error.missingfield", "Calendar"); 248 return false; 249 } 250 251 event.setCalendar(c); 252 form.setCalendar(c); 253 return true; 254 } catch (Throwable t) { 255 err.emit(t); 256 return false; 257 } 258 } 259 260 /** 261 * 262 * @return boolean false means something wrong, message emitted 263 * @throws Throwable 264 */ 265 private boolean validateEventCategory(PEActionForm form, CalSvcI svci, 266 BwEvent event, MessageEmit err) 267 throws Throwable { 268 int id = form.retrieveCategoryId().getVal(); 269 270 if (id <= 0) { 271 if (form.getEnv().getAppBoolProperty("app.categoryOptional")) { 272 return true; 273 } 274 275 err.emit("org.bedework.client.error.missingfield", "Category"); 276 return false; 277 } 278 279 try { 280 BwCategory cat = svci.getCategory(id); 281 282 if (cat == null) { 283 err.emit("org.bedework.client.error.missingcategory", id); 284 return false; 285 } 286 287 if (!form.retrieveCategoryId().getChanged()) { 288 return true; 289 } 290 291 // oldCategory = getEvent().getCategory(0); 292 293 294 /* Currently we replace the only category if it exists 295 */ 296 event.clearCategories(); 297 event.addCategory(cat); 298 299 form.setCategory(cat); 300 301 return true; 302 } catch (Throwable t) { 303 err.emit(t); 304 return false; 305 } 306 } 307 308 /** Validate the sponsor provided for an event and embed it in the event and 309 * the form. 310 * 311 * @return boolean true OK, false not OK and message(s) emitted. 312 * @throws Throwable 313 */ 314 private boolean validateEventSponsor(PEActionForm form, CalSvcI svci, 315 BwEvent event, MessageEmit err) 316 throws Throwable { 317 boolean ok = true; 318 319 if (!form.retrieveSpId().getChanged()) { 320 if (form.getAutoCreateSponsors()) { 321 BwSponsor s = form.getSponsor(); 322 if (!BwWebUtil.validateSponsor(s, err)) { 323 return false; 324 } 325 326 svci.ensureSponsorExists(s); 327 328 form.setSponsor(s); 329 event.setSponsor(s); 330 } 331 332 if (event.getSponsor() == null) { 333 err.emit("org.bedework.client.error.missingfield", "Sponsor"); 334 return false; 335 } 336 337 return ok; 338 } 339 340 // The user selected one from the list 341 int id = form.retrieveSpId().getVal(); 342 343 try { 344 BwSponsor s = svci.getSponsor(id); 345 if (s == null) { 346 // Somebody's faking 347 form.setSponsor(null); 348 err.emit("org.bedework.client.error.missingfield", "Sponsor"); 349 return false; 350 } 351 352 event.setSponsor(s); 353 354 form.setSponsor(s); 355 return true; 356 } catch (Throwable t) { 357 err.emit(t); 358 return false; 359 } 360 } 361 362 /** Validate the location provided for an event and embed it in the event and 363 * the form. 364 * 365 * @return boolean true OK, false not OK and message(s) emitted. 366 * @throws Throwable 367 */ 368 private boolean validateEventLocation(PEActionForm form, CalSvcI svci, 369 BwEvent event, MessageEmit err) 370 throws Throwable { 371 boolean ok = true; 372 373 if (!form.retrieveLocId().getChanged()) { 374 if (form.getAutoCreateLocations()) { 375 BwLocation l = form.getLocation(); 376 377 if (!BwWebUtil.validateLocation(l, err)) { 378 return false; 379 } 380 381 svci.ensureLocationExists(l); 382 383 form.setLocation(l); 384 event.setLocation(l); 385 } 386 387 if (event.getLocation() == null) { 388 err.emit("org.bedework.client.error.missingfield", "Location"); 389 return false; 390 } 391 392 return ok; 393 } 394 395 // The user selected one from the list 396 397 try { 398 int id = form.retrieveLocId().getVal(); 399 BwLocation l = svci.getLocation(id); 400 401 if ((l == null) || !l.getPublick()) { 402 // Somebody's faking 403 form.setLocation(null); 404 err.emit("org.bedework.client.error.missingfield", "Location"); 405 return false; 406 } 407 408 event.setLocation(l); 409 form.setLocation(l); 410 411 return true; 412 } catch (Throwable t) { 413 err.emit(t); 414 return false; 415 } 416 } 190 417 } 191 418 trunk/calendar3/webadmin/src/org/bedework/webadmin/location/PEInitAddLocationAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingLocation(true); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/location/PEInitUpdateLocationAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingLocation(false); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/sponsor/PEInitAddSponsorAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingSponsor(true); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/sponsor/PEInitUpdateSponsorAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignAddingSponsor(false); 90 90 trunk/calendar3/webadmin/src/org/bedework/webadmin/timezones/PEInitUploadTimezonesAction.java
r2 r128 86 86 /** Set the objects to null so we get new ones. 87 87 */ 88 form.initFields();88 initFields(form); 89 89 form.assignUploadingTimezones(true); 90 90 trunk/calendar3/webadmin/war/docs/event/emitEvent.jsp
r2 r128 1 <%@ taglib uri='struts-logic' prefix='logic' %> 2 1 3 <bean:define id="eventId" name="formattedEvent" property="event.id"/> 2 4 <% String rpitemp="/event/fetchForUpdate.do?eventId=" + eventId; %> … … 20 22 <link><bean:write name="formattedEvent" property="event.link" /></link> 21 23 <cost><bean:write name="formattedEvent" property="event.cost" /></cost> 22 <location><bean:write name="formattedEvent" property="event.location.address" /></location> 23 <sponsor><bean:write name="formattedEvent" property="event.sponsor.name" /></sponsor> 24 25 <logic:present name="event" property="location"> 26 <location><bean:write name="formattedEvent" property="event.location.address" /></location> 27 </logic:present> 28 <logic:notPresent name="event" property="location"> 29 <location></location> 30 </logic:notPresent> 31 32 <logic:present name="event" property="sponsor"> 33 <sponsor><bean:write name="formattedEvent" property="event.sponsor.name" /></sponsor> 34 </logic:present> 35 <logic:notPresent name="event" property="sponsor"> 36 <sponsor></sponsor> 37 </logic:notPresent> 38 24 39 <creator><bean:write name="formattedEvent" property="event.creator.account" /></creator> 25 40 </event> trunk/calendar3/webcommon/src/org/bedework/webcommon/BwAbstractAction.java
r111 r128 237 237 /** Set the objects to null so we get new ones. 238 238 */ 239 form.initFields();239 initFields(form); 240 240 241 241 form.getMsg().emit("org.bedework.client.message.cancelled"); … … 260 260 261 261 return forward; 262 } 263 264 protected void initFields(BwActionFormBase form) { 262 265 } 263 266 … … 1037 1040 } 1038 1041 svci.open(); 1042 svci.beginTransaction(); 1039 1043 } 1040 1044 } trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java
r111 r128 78 78 import org.bedework.calfacade.svc.BwSubscription; 79 79 import org.bedework.calfacade.svc.BwView; 80 import org.bedework.calfacade.svc.EventInfo; 80 81 import org.bedework.calfacade.svc.UserAuth; 81 82 import org.bedework.calsvci.CalSvcI; … … 271 272 private BwEvent editEvent; 272 273 273 /** For apssing between actions 274 private EventInfo eventInfo; 275 276 /** For passing between actions 274 277 */ 275 278 private BwEvent currentEvent; … … 1777 1780 editEvent = val; 1778 1781 1779 if (val != null) { 1782 if (val == null) { 1783 getEventDates().setNewEvent(val, fetchSvci().getTimezones()); 1784 } else { 1780 1785 getEventDates().setFromEvent(val, fetchSvci().getTimezones()); 1781 1786 } … … 1791 1796 if (editEvent == null) { 1792 1797 editEvent = new BwEventObj(); 1798 eventInfo = new EventInfo(editEvent); 1793 1799 } 1794 1800 1795 1801 return editEvent; 1802 } 1803 1804 /** 1805 * @param val 1806 */ 1807 public void setEventInfo(EventInfo val) { 1808 eventInfo = val; 1809 if (val == null) { 1810 setEditEvent(null); 1811 } else { 1812 setEditEvent(val.getEvent()); 1813 } 1814 } 1815 1816 /** 1817 * @return EventInfo 1818 */ 1819 public EventInfo getEventInfo() { 1820 return eventInfo; 1796 1821 } 1797 1822 … … 1961 1986 viewTypeI = -1; 1962 1987 //key.reset(); 1963 }1964 1965 /**1966 *1967 */1968 public void initFields() {1969 1988 } 1970 1989
