AddEditEventStory

Functional specifications

This adds add/edit functionality to the calendar.
  • A button is use to add an event and one to remove it
  • The event titles are links to edit them
  • After each addition/edit the iCal file has to be synchronized in order to avoid conflicts.
    • The events are thrown out of the database
    • The iCal file is read in the database again
    • The new/edited event is validated (checked if its unique and if its adheres to the standard)
      • On conflicts the user is informed
      • Else the event is stored in the database and the remote file is updated

Technical interpretation

  • The WebDavCalendarSynchronisation must be extended to support synchronisyng and writing back the webdav file
  • The EventDaoWebDavHibernateBufferedImpl must be updated so that it synchs the iCal file on addition/update
  • Wicket
    • AddEditEventPanel
      • backlink
      • Form component with the event fields
      • Button to remove the event
      • Validation and feedback

Budget/Hours

task hours todo spend developer
extending WebDavCalendarSynchronisation 20 0 19 Jochem
!EventDaoWebDavHibernateBufferedImpl 10 0 8 Jochem
AddEditEventPanel 8 0 32 Jochem
Total 38 0 59

Discussion

  • 18-11-2006: In a minute i'll check my first try into cvs. Two test succeed (testStoreEventFull and testStoreEventMinimal). But they don't write into the ics file on icalx. There is no error message, everything seems to be working fine. Can anyone assist?
  • I've fixed the ics upload. There were a couple of problems:
    1. The connection you used was a generic URLConnection where a HttpUrlConnection was needed to use the PUT method
    2. There seems to be a bug in the HttpConnection / !!URLConnection where when you ignore the inputstream the output is never written

The following methods return the rigth connection:

   /**
    * Returns a HttpUrlConnection for a URL pointing to an HTTP resource. Make sure it does point to a HTTP resource or a IlliagalArgumentException is thrown
    * @param url the url of a HTTP resource
    * @return a HttpUrlConnection
    * @throws IOException
    */
   protected HttpURLConnection getHttpUrlConnection(URL url) throws IOException {
      URLConnection connection = url.openConnection();
      if(connection instanceof HttpURLConnection) {
         return (HttpURLConnection) connection;
      } else {
         throw new IllegalArgumentException("Url is not targeted at an HTTP resource" + url);
      }
   }

   /**
    * Returns a HttpsUrlConnection for a URL pointing to an HTTPS resource. Make sure it does point to a HTTPS resource or a IlliagalArgumentException is thrown
    * @param url the url of a HTTPS resource
    * @param ignoreBadCertificates a boolean specifying if the certificates have to be signed
    * @return a HttpsURLConnection
    * @throws KeyManagementException
    * @throws NoSuchAlgorithmException
    * @throws UnknownHostException
    * @throws IOException
    */
   protected HttpsURLConnection getHttpsUrlConnection(URL url, boolean ignoreBadCertificates) throws KeyManagementException, NoSuchAlgorithmException, UnknownHostException, IOException {
      URLConnection connection = getURLConnection(url, ignoreBadCertificates);
      if(connection instanceof HttpsURLConnection) {
         return (HttpsURLConnection) connection;
      } else {
         throw new IllegalArgumentException("Url is not targeted at an HTTPS resource" + url);
      }
   }

Here you can see how to set the rigth http method and the hack:

         //Write the calendar to the remote file
         connection.setDoOutput(true);
         connection.setRequestMethod(HTTP_PUT_METHOD);
         calendarOutputter.output(ical4jCalendar, connection.getOutputStream() );
         
         if(log.isDebugEnabled()) {
            log.debug("Flushing connection: " + connection.getURL());
         }

         connection.getOutputStream().flush();
         connection.getOutputStream().close();
         
         //XXX Somehow the output is not writen if the input is not read, so read 1 byte.
         if(connection.getInputStream().available() > 0) {
            connection.getInputStream().read();
         }

-- IvoVanDongen - 17 Sep 2006

Topic revision: r11 - 20 Jan 2007 - 13:13:20 - JochemKolthof
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback