[Bedework-commit] r626 - in trunk/calendar3: calCore/resources/hbms
freebusyServer/src/org/bedework/freebusyServer
svnadmin at bedework.org
svnadmin at bedework.org
Wed Jun 21 23:12:42 EDT 2006
Author: douglm
Date: 2006-06-21 23:12:39 -0400 (Wed, 21 Jun 2006)
New Revision: 626
Added:
trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/CalDavClient.java
trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBInfoSet.java
trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBUserInfo.java
trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/IcalTrans.java
Modified:
trunk/calendar3/calCore/resources/hbms/AuthUserPrefs.hbm.xml
trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java
Log:
Fix for schema from Dave Brondsema
Restructure freebusy aggregator
Modified: trunk/calendar3/calCore/resources/hbms/AuthUserPrefs.hbm.xml
===================================================================
--- trunk/calendar3/calCore/resources/hbms/AuthUserPrefs.hbm.xml 2006-06-21 21:37:55 UTC (rev 625)
+++ trunk/calendar3/calCore/resources/hbms/AuthUserPrefs.hbm.xml 2006-06-22 03:12:39 UTC (rev 626)
@@ -83,25 +83,25 @@
<class name="org.bedework.calfacade.svc.BwAuthUserPrefsCategory"
table="authprefCategories">
<id name="id" column="userid" unsaved-value="-1"/>
- <property name="categoryid" column="categoryid" type="integer"/>
+ <property name="categoryid" column="categoryid" type="integer" not-null="true"/>
</class>
<class name="org.bedework.calfacade.svc.BwAuthUserPrefsLocation"
table="authprefLocations">
<id name="id" column="userid" unsaved-value="-1"/>
- <property name="locationid" column="locationid" type="integer"/>
+ <property name="locationid" column="locationid" type="integer" not-null="true"/>
</class>
<class name="org.bedework.calfacade.svc.BwAuthUserPrefsSponsor"
table="authprefSponsors">
<id name="id" column="userid" unsaved-value="-1"/>
- <property name="sponsorid" column="sponsorid" type="integer"/>
+ <property name="sponsorid" column="sponsorid" type="integer" not-null="true"/>
</class>
<class name="org.bedework.calfacade.svc.BwAuthUserPrefsCalendar"
table="authprefCalendars">
<id name="id" column="userid" unsaved-value="-1"/>
- <property name="calendarid" column="calendarid" type="integer"/>
+ <property name="calendarid" column="calendarid" type="integer" not-null="true"/>
</class>
<!-- =================================================================
Added: trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/CalDavClient.java
===================================================================
--- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/CalDavClient.java (rev 0)
+++ trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/CalDavClient.java 2006-06-22 03:12:39 UTC (rev 626)
@@ -0,0 +1,128 @@
+/* **********************************************************************
+ Copyright 2005 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.freebusyServer;
+
+import org.bedework.caldav.client.api.CaldavClientIo;
+import org.bedework.caldav.client.api.CaldavResp;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+
+import javax.servlet.http.HttpServletResponse;
+
+/** Handle interactions with caldav servers.
+ *
+ * @author Mike Douglass
+ */
+public class CalDavClient {
+ private boolean debug;
+
+ /* There is one entry per host + port. Because we are likely to make a number
+ * of calls to the same host + port combination it makes sense to preserve
+ * the objects between calls.
+ */
+ private HashMap cioTable = new HashMap();
+
+ /**
+ *
+ */
+ public static class Response {
+ /** */
+ public FBUserInfo ui;
+
+ /** */
+ public int responseCode;
+
+ /** */
+ public Collection fbs = new ArrayList();
+
+ /** */
+ public CaldavResp cdresp;
+ }
+
+ /** Constructor
+ *
+ * @param debug
+ * @throws Throwable
+ */
+ public CalDavClient(boolean debug) throws Throwable {
+ this.debug = debug;
+ }
+
+ /**
+ * @param r
+ * @param ui
+ * @return Response
+ * @throws Throwable
+ */
+ public Response send(Req r, FBUserInfo ui) throws Throwable {
+ CaldavClientIo cio = getCio(ui.getHost(), ui.getPort());
+ Response resp = new Response();
+ resp.ui = ui;
+
+ if (r.getAuth()) {
+ resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(),
+ r.getUser(), r.getPw(),
+ r.getHeaders(), 0,
+ r.getContentType(),
+ r.getContentLength(), r.getContentBytes());
+ } else {
+ resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(),
+ r.getHeaders(), 0,
+ r.getContentType(), r.getContentLength(),
+ r.getContentBytes());
+ }
+
+ if (resp.responseCode != HttpServletResponse.SC_OK) {
+ error("Got response " + resp.responseCode +
+ " for account " + ui.getAccount() +
+ ", host " + ui.getHost() +
+ " and url " + ui.getUrl());
+ return resp;
+ }
+
+ resp.cdresp = cio.getResponse();
+
+ return resp;
+ }
+
+ private CaldavClientIo getCio(String host, int port) throws Throwable {
+ CaldavClientIo cio = (CaldavClientIo)cioTable.get(host + port);
+
+ if (cio == null) {
+ cio = new CaldavClientIo(host, port, debug);
+
+ cioTable.put(host + port, cio);
+ }
+
+ return cio;
+ }
+
+ private void error(String msg) {
+ System.err.println(msg);
+ }
+}
Added: trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBInfoSet.java
===================================================================
--- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBInfoSet.java (rev 0)
+++ trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBInfoSet.java 2006-06-22 03:12:39 UTC (rev 626)
@@ -0,0 +1,114 @@
+/* **********************************************************************
+ Copyright 2005 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.freebusyServer;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+/** Maintain information about the users (or groups) whose free/busy we are querying.
+ *
+ * @author Mike Douglass
+ */
+public class FBInfoSet {
+ // Temp - maintain local set
+ private TreeSet infoSet = new TreeSet();
+
+ /** Constructor
+ *
+ * @throws Throwable
+ */
+ public FBInfoSet() throws Throwable {
+ /*
+ addInfo(new UserInfo("douglm", "testuser01", "bedework",
+ "localhost", 8080, false,
+ "/ucaldav/user/douglm"));
+ addInfo(new UserInfo("testuser01", "bedework", "johnsa",
+ "localhost", 8080, false,
+ "/ucaldav/user/johnsa"));
+ */
+ /*
+ addInfo(new UserInfo("testuser02", "testuser02", "bedework",
+ "www.bedework.org", 80, false,
+ "/ucaldav/user/testuser02"));
+ */
+ addInfo(new FBUserInfo("douglm", "douglm", "bedework",
+ "localhost", 8080, false,
+ "/ucaldav/user/douglm"));
+/*
+ addInfo(new UserInfo("testuser02", "testuser02", "bedework",
+ "www.bedework.org", 80, false,
+ "/ucaldav/user/testuser02"));
+ addInfo(new UserInfo("testuser08", "testuser08", "bedework",
+ "www.bedework.org", 80, false,
+ "/ucaldav/user/testuser08"));
+*/
+ }
+
+ /** Get a set of all users.
+ *
+ * @return Set
+ * @throws Throwable
+ */
+ public Set getAll() throws Throwable {
+ return infoSet;
+ }
+
+ /**
+ * @param account - String account to locate
+ * @return FBUserInfo or null
+ * @throws Throwable
+ */
+ public FBUserInfo getInfo(String account) throws Throwable {
+ Iterator it = infoSet.iterator();
+
+ while (it.hasNext()) {
+ FBUserInfo info = (FBUserInfo)it.next();
+ if (account.equals(info.getAccount())) {
+ return info;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param val FBUserInfo
+ * @return true if added - false if already there
+ * @throws Throwable
+ */
+ public boolean addInfo(FBUserInfo val) throws Throwable {
+ return infoSet.add(val);
+ }
+
+ /**
+ * @param account - String account to remove
+ * @throws Throwable
+ */
+ public void removeInfo(String account) throws Throwable {
+ infoSet.remove(new FBUserInfo(account));
+ }
+}
Added: trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBUserInfo.java
===================================================================
--- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBUserInfo.java (rev 0)
+++ trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FBUserInfo.java 2006-06-22 03:12:39 UTC (rev 626)
@@ -0,0 +1,220 @@
+/* **********************************************************************
+ Copyright 2005 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.freebusyServer;
+
+import java.io.Serializable;
+
+/** Information about the user (or group) whose free/busy we are querying.
+ *
+ * <p>For a given target user we need an identifying account, possibly an email
+ * address, the host, port and url for the calendar information, and an
+ * id and password for an account authorised to read that free/busy.
+ *
+ * <p>In general the authorised id/pw will not be that of the user whose
+ * free/busy we are querying.
+ *
+ * @author Mike Douglass
+ */
+public class FBUserInfo implements Comparable, Serializable {
+ /* user id for server authentication. May be null if anon ok */
+ private String authUser;
+ private String authPw;
+
+ /* Whose free busy? */
+ private String account;
+
+ private String host;
+ private int port;
+
+ private boolean secure;
+
+ private String url;
+
+ /** Constructor
+ *
+ * @param account -- the key
+ * @param authUser
+ * @param authPw
+ * @param host
+ * @param port
+ * @param secure
+ * @param url
+ */
+ public FBUserInfo(String account,
+ String authUser,
+ String authPw,
+ String host,
+ int port,
+ boolean secure,
+ String url) {
+ this.account = account;
+ this.authUser = authUser;
+ this.authPw = authPw;
+ this.host = host;
+ this.port = port;
+ this.secure = secure;
+ this.url = url;
+ }
+
+ /** Constructor
+ *
+ * @param account -- the key
+ */
+ public FBUserInfo(String account) {
+ this.account = account;
+ }
+
+ /**
+ * @param val
+ */
+ public void setAccount(String val) {
+ account = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getAccount() {
+ return account;
+ }
+
+ /**
+ * @param val
+ */
+ public void setAuthUser(String val) {
+ authUser = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getAuthUser() {
+ return authUser;
+ }
+
+ /**
+ * @param val
+ */
+ public void setAuthPw(String val) {
+ authPw = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getAuthPw() {
+ return authPw;
+ }
+
+ /**
+ * @param val
+ */
+ public void setHost(String val) {
+ host = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @param val
+ */
+ public void setPort(int val) {
+ port = val;
+ }
+
+ /**
+ * @return int
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @param val
+ */
+ public void setSecure(boolean val) {
+ secure = val;
+ }
+
+ /**
+ * @return String
+ */
+ public boolean getSecure() {
+ return secure;
+ }
+
+ /**
+ * @param val
+ */
+ public void setUrl(String val) {
+ url = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /* ====================================================================
+ * Object methods
+ * The following are required for a db object.
+ * ==================================================================== */
+
+ public int compareTo(Object o) {
+ if (o == null) {
+ return -1;
+ }
+
+ if (!(o instanceof FBUserInfo)) {
+ return -1;
+ }
+
+ FBUserInfo that = (FBUserInfo)o;
+
+ return getAccount().compareTo(that.getAccount());
+ }
+
+ public int hashCode() {
+ return getAccount().hashCode();
+ }
+
+ /* We always use the compareTo method
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ return compareTo(obj) == 0;
+ }
+}
Modified: trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java
===================================================================
--- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java 2006-06-21 21:37:55 UTC (rev 625)
+++ trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/FreeBusyAggregator.java 2006-06-22 03:12:39 UTC (rev 626)
@@ -25,15 +25,8 @@
*/
package org.bedework.freebusyServer;
-import org.bedework.caldav.client.api.CaldavClientIo;
-import org.bedework.caldav.client.api.CaldavResp;
import org.bedework.calfacade.BwFreeBusy;
import org.bedework.calfacade.BwUser;
-import org.bedework.calfacade.CalFacadeException;
-import org.bedework.calsvc.CalSvc;
-import org.bedework.calsvci.CalSvcI;
-import org.bedework.calsvci.CalSvcIPars;
-import org.bedework.icalendar.IcalTranslator;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -41,7 +34,6 @@
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
import javax.servlet.http.HttpServletResponse;
@@ -54,75 +46,20 @@
*/
public class FreeBusyAggregator {
private boolean debug = true;
- private CalSvcI svci;
- IcalTranslator trans;
+ private IcalTrans trans;
- private static class UserInfo {
- /* user id for server authentication. May be null if anon ok */
- String authUser;
- String authPw;
+ private FBInfoSet infoset;
- /* Whose free busy? */
- String account;
-
- String host;
- int port;
-
- boolean secure;
-
- String url;
-
- UserInfo(String authUser,
- String authPw,
- String account,
- String host,
- int port,
- boolean secure,
- String url) {
- this.authUser = authUser;
- this.authPw = authPw;
- this.account = account;
- this.host = host;
- this.port = port;
- this.secure = secure;
- this.url = url;
- }
- }
-
- private static class Response {
- UserInfo ui;
-
- int responseCode;
-
- Collection fbs = new ArrayList();
- }
-
- Collection uiList;
-
- private HashMap cioTable = new HashMap();
-
- private CaldavClientIo getCio(String host, int port) throws Throwable {
- CaldavClientIo cio = (CaldavClientIo)cioTable.get(host + port);
-
- if (cio == null) {
- cio = new CaldavClientIo(host, port, debug);
-
- cioTable.put(host + port, cio);
- }
-
- return cio;
- }
-
- private Req makeFreeBusyRequest(Date start, Date end, UserInfo ui) throws Throwable {
+ private Req makeFreeBusyRequest(Date start, Date end, FBUserInfo ui) throws Throwable {
Req req;
- if (ui.authUser == null) {
+ if (ui.getAuthUser() == null) {
req = new Req();
} else {
- req = new Req(ui.authUser, ui.authPw);
+ req = new Req(ui.getAuthUser(), ui.getAuthPw());
}
- req.setUrl(ui.url);
+ req.setUrl(ui.getUrl());
req.setContentType("text/xml");
req.setMethod("REPORT");
req.addHeader("Depth", "0");
@@ -140,84 +77,34 @@
return req;
}
- private void addUser(UserInfo ui) {
- if (uiList == null) {
- uiList = new ArrayList();
- }
-
- uiList.add(ui);
- }
-
private void init() throws Throwable {
- /*
- addUser(new UserInfo("testuser01", "bedework", "douglm",
- "localhost", 8080, false,
- "/ucaldav/user/douglm"));
- addUser(new UserInfo("testuser01", "bedework", "johnsa",
- "localhost", 8080, false,
- "/ucaldav/user/johnsa"));
- */
- /*
- addUser(new UserInfo("testuser02", "bedework", "testuser02",
- "www.bedework.org", 80, false,
- "/ucaldav/user/testuser02"));
- */
- addUser(new UserInfo("douglm", "bedework", "douglm",
- "localhost", 8080, false,
- "/ucaldav/user/douglm"));
-/*
- addUser(new UserInfo("testuser02", "bedework", "testuser02",
- "www.bedework.org", 80, false,
- "/ucaldav/user/testuser02"));
- addUser(new UserInfo("testuser08", "bedework", "testuser08",
- "www.bedework.org", 80, false,
- "/ucaldav/user/testuser08"));
-*/
- getSvci(); //
+ infoset = new FBInfoSet();
+ trans = new IcalTrans(debug);
}
private Collection getFreeBusy(Date start, Date end) throws Throwable {
ArrayList responses = new ArrayList();
- Iterator it = uiList.iterator();
+ Iterator it = infoset.getAll().iterator();
+ CalDavClient cd = new CalDavClient(debug);
+
while (it.hasNext()) {
- UserInfo ui = (UserInfo)it.next();
+ FBUserInfo ui = (FBUserInfo)it.next();
Req r = makeFreeBusyRequest(start, end, ui);
- CaldavClientIo cio = getCio(ui.host, ui.port);
- Response resp = new Response();
- resp.ui = ui;
+ CalDavClient.Response resp = cd.send(r, ui);
responses.add(resp);
- if (r.getAuth()) {
- resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(),
- r.getUser(), r.getPw(),
- r.getHeaders(), 0,
- r.getContentType(),
- r.getContentLength(), r.getContentBytes());
- } else {
- resp.responseCode = cio.sendRequest(r.getMethod(), r.getUrl(),
- r.getHeaders(), 0,
- r.getContentType(), r.getContentLength(),
- r.getContentBytes());
- }
-
if (resp.responseCode != HttpServletResponse.SC_OK) {
- error("Got response " + resp.responseCode +
- " for account " + ui.account +
- ", host " + ui.host +
- " and url " + ui.url);
continue;
}
- CaldavResp cdresp = cio.getResponse();
-
/* We expect a VCALENDAR object containg VFREEBUSY components
*/
- InputStream in = cdresp.getContentStream();
+ InputStream in = resp.cdresp.getContentStream();
- Collection fbs = trans.fromIcal(null, new InputStreamReader(in));
+ Collection fbs = trans.getFreeBusy(new InputStreamReader(in));
Iterator fbit = fbs.iterator();
while (fbit.hasNext()) {
@@ -226,7 +113,7 @@
if (o instanceof BwFreeBusy) {
BwFreeBusy fb = (BwFreeBusy)o;
- fb.setWho(new BwUser(ui.account));
+ fb.setWho(new BwUser(ui.getAccount()));
resp.fbs.add(fb);
}
}
@@ -240,7 +127,7 @@
*/
public void close() {
try {
- close(svci);
+ trans.close();
} catch (Throwable t) {
}
}
@@ -249,69 +136,6 @@
* Private methods
* ==================================================================== */
- /** Use this for timezones
- *
- * @return CalSvcI
- * @throws CalFacadeException
- */
- private CalSvcI getSvci() throws CalFacadeException {
- boolean publicMode = true;
-
- if (svci != null) {
- if (!svci.isOpen()) {
- svci.open();
- svci.beginTransaction();
- }
-
- return svci;
- }
-
- svci = new CalSvc();
- /* account is what we authenticated with.
- * user, if non-null, is the user calendar we want to access.
- */
- CalSvcIPars pars = new CalSvcIPars(null, // account,
- null, // account,
- null, // calSuite,
- "org.bedework.app.freebusy.",
- publicMode,
- true, // caldav
- null, // synchId
- debug);
- svci.init(pars);
-
- svci.open();
- svci.beginTransaction();
-
- trans = new IcalTranslator(svci.getIcalCallback(), debug);
-
- return svci;
- }
-
- private void close(CalSvcI svci) throws CalFacadeException {
- if ((svci == null) || !svci.isOpen()) {
- return;
- }
-
- try {
- svci.endTransaction();
- } catch (CalFacadeException cfe) {
- try {
- svci.close();
- } catch (Throwable t1) {
- }
- svci = null;
- throw cfe;
- }
-
- try {
- svci.close();
- } catch (CalFacadeException cfe) {
- svci = null;
- throw cfe;
- }
- }
-
boolean processArgs(String[] args) throws Throwable {
if (args == null) {
return true;
@@ -350,10 +174,6 @@
return true;
}
- private void error(String msg) {
- System.err.println(msg);
- }
-
/** Main
*
* @param args
@@ -373,10 +193,10 @@
Iterator it = responses.iterator();
while (it.hasNext()) {
- Response resp = (Response)it.next();
+ CalDavClient.Response resp = (CalDavClient.Response)it.next();
if (resp.responseCode != HttpServletResponse.SC_OK) {
- out("Response code for " + resp.ui.account + " = " + resp.responseCode);
+ out("Response code for " + resp.ui.getAccount() + " = " + resp.responseCode);
} else {
}
@@ -387,6 +207,10 @@
}
}
+ private void error(String msg) {
+ System.err.println(msg);
+ }
+
private static void out(String msg) {
System.out.println(msg);
}
Added: trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/IcalTrans.java
===================================================================
--- trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/IcalTrans.java (rev 0)
+++ trunk/calendar3/freebusyServer/src/org/bedework/freebusyServer/IcalTrans.java 2006-06-22 03:12:39 UTC (rev 626)
@@ -0,0 +1,130 @@
+/* **********************************************************************
+ Copyright 2005 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.freebusyServer;
+
+import org.bedework.calfacade.CalFacadeException;
+import org.bedework.calsvc.CalSvc;
+import org.bedework.calsvci.CalSvcI;
+import org.bedework.calsvci.CalSvcIPars;
+import org.bedework.icalendar.IcalTranslator;
+
+import java.io.InputStreamReader;
+import java.util.Collection;
+
+/** Translate to/from ical. This requires the ability to get timezone info so
+ * we use the bedework svci and ical translator.
+ *
+ * @author Mike Douglass
+ */
+public class IcalTrans {
+ private boolean debug;
+
+ private CalSvcI svci;
+ private IcalTranslator trans;
+
+ /** Constructor
+ *
+ * @param debug
+ * @throws Throwable
+ */
+ public IcalTrans(boolean debug) throws Throwable {
+ this.debug = debug;
+
+ getSvci(); //
+ }
+
+ /**
+ *
+ * @throws CalFacadeException
+ */
+ private void getSvci() throws CalFacadeException {
+ boolean publicMode = true;
+
+ if (svci != null) {
+ if (!svci.isOpen()) {
+ svci.open();
+ svci.beginTransaction();
+ }
+
+ return;
+ }
+
+ svci = new CalSvc();
+ /* account is what we authenticated with.
+ * user, if non-null, is the user calendar we want to access.
+ */
+ CalSvcIPars pars = new CalSvcIPars(null, // account,
+ null, // account,
+ null, // calSuite,
+ "org.bedework.app.freebusy.",
+ publicMode,
+ true, // caldav
+ null, // synchId
+ debug);
+ svci.init(pars);
+
+ svci.open();
+ svci.beginTransaction();
+
+ trans = new IcalTranslator(svci.getIcalCallback(), debug);
+ }
+
+ /**
+ * @param in
+ * @return Collection
+ * @throws Throwable
+ */
+ public Collection getFreeBusy(InputStreamReader in) throws Throwable {
+ return trans.fromIcal(null, in);
+ }
+
+ /**
+ * @throws CalFacadeException
+ */
+ public void close() throws CalFacadeException {
+ if ((svci == null) || !svci.isOpen()) {
+ return;
+ }
+
+ try {
+ svci.endTransaction();
+ } catch (CalFacadeException cfe) {
+ try {
+ svci.close();
+ } catch (Throwable t1) {
+ }
+ svci = null;
+ throw cfe;
+ }
+
+ try {
+ svci.close();
+ } catch (CalFacadeException cfe) {
+ svci = null;
+ throw cfe;
+ }
+ }
+}
More information about the Bedework-commit
mailing list