[Bedework-commit] exchgsynch r3 - in trunk: . server
server/src/org/bedework/exchgsynch
svnadmin at bedework.org
svnadmin at bedework.org
Mon Sep 27 15:30:23 EDT 2010
Author: douglm
Date: 2010-09-27 15:30:21 -0400 (Mon, 27 Sep 2010)
New Revision: 3
Added:
trunk/server/
trunk/server/src/
trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java
trunk/server/src/org/bedework/exchgsynch/ExsynchConfig.java
trunk/server/src/org/bedework/exchgsynch/SynchException.java
trunk/server/src/org/bedework/exchgsynch/bwimpl/
Removed:
trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java
trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java
Log:
Intermediate save as I build the project
Copied: trunk/server/src (from rev 1, trunk/src)
Deleted: trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java
===================================================================
--- trunk/src/org/bedework/exchgsynch/ExchangeCallback.java 2010-09-27 17:58:54 UTC (rev 1)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -1,42 +0,0 @@
-/* **********************************************************************
- Copyright 2010 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.caldav.server.exchange;
-
-import edu.rpi.cct.webdav.servlet.shared.WebdavException;
-
-/** Calls from the calendar system to the exchange synch processor.
- *
- * @author Mike Douglass
- */
-public abstract class ExchangeCallback {
- /** Update or add a subscription.
- *
- * @param sub
- * @throws WebdavException
- */
- public abstract void subscribeRequest(ExchangeSubscription sub) throws WebdavException;
-}
Copied: trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java (from rev 2, trunk/src/org/bedework/exchgsynch/ExchangeCallback.java)
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeCallback.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,40 @@
+/* **********************************************************************
+ Copyright 2010 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.exchgsynch;
+
+/** Calls from the calendar system to the exchange synch processor.
+ *
+ * @author Mike Douglass
+ */
+public abstract class ExchangeCallback {
+ /** Update or add a subscription.
+ *
+ * @param sub
+ * @throws WebdavException
+ */
+ public abstract void subscribeRequest(ExchangeSubscription sub) throws SynchException;
+}
Deleted: trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java
===================================================================
--- trunk/src/org/bedework/exchgsynch/ExchangeSubscription.java 2010-09-27 17:58:54 UTC (rev 1)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -1,261 +0,0 @@
-/* **********************************************************************
- Copyright 2010 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.caldav.server.exchange;
-
-import edu.rpi.cmt.access.AccessPrincipal;
-
-/** Represents a current subscription or a subscription request.
- *
- * @author Mike Douglass
- */
-public class ExchangeSubscription implements Comparable<ExchangeSubscription> {
- private String calpath;
-
- private AccessPrincipal principal;
-
- private String exchangeCalendar;
-
- private String exchangeURI;
-
- private boolean subscribe;
-
- private ExchangeSubscription outstandingSubscription;
-
- /** Constructor
- *
- * @param principal
- * @param calpath
- * @param exchangeCalendar
- * @param exchangeURI
- * @param subscribe
- */
- public ExchangeSubscription(final String calpath,
- final AccessPrincipal principal,
- final String exchangeCalendar,
- final String exchangeURI,
- final boolean subscribe) {
- this.principal = principal;
- this.calpath = calpath;
- this.exchangeCalendar = exchangeCalendar;
- this.exchangeURI = exchangeURI;
- this.subscribe = subscribe;
- }
-
- /** Path to this systems calendar collection
- *
- * @param val String
- */
- public void setCalpath(final String val) {
- calpath = val;
- }
-
- /** Path to this systems calendar collection
- *
- * @return String
- */
- public String getCalpath() {
- return calpath;
- }
-
-
- /** Principal requesting synch service
- *
- * @param val AccessPrincipal
- */
- public void setprincipal(final AccessPrincipal val) {
- principal = val;
- }
-
- /** Principal requesting synch service
- *
- * @return AccessPrincipal
- */
- public AccessPrincipal getprincipal() {
- return principal;
- }
- /** Exchange Calendar
- *
- * @param val String
- */
- public void setExchangeCalendar(final String val) {
- exchangeCalendar = val;
- }
-
- /** Exchange Calendar
- *
- * @return String
- */
- public String getExchangeCalendar() {
- return exchangeCalendar;
- }
-
- /** Exchange web service uri
- *
- * @param val String
- */
- public void setExchangeURI(final String val) {
- exchangeURI = val;
- }
-
- /** Exchange web service uri
- *
- * @return String
- */
- public String getExchangeURI() {
- return exchangeURI;
- }
-
- /** (un)subscribe?
- *
- * @param val boolean
- */
- public void setSubscribe(final boolean val) {
- subscribe = val;
- }
-
- /** (un)subscribe?
- *
- * @return boolean
- */
- public boolean getSubscribe() {
- return subscribe;
- }
-
- /** An outstanding request that requires an unsubscribe to complete first
- *
- * @param val ExchangeSubscription
- */
- public void setOutstandingSubscription(final ExchangeSubscription val) {
- outstandingSubscription = val;
- }
-
- /** An outstanding request that requires an unsubscribe to complete first
- *
- * @return ExchangeSubscription
- */
- public ExchangeSubscription getOutstandingSubscription() {
- return outstandingSubscription;
- }
-
- /** equality just checks the path. Look at the rest.
- *
- * @param that
- * @return true if anything changed
- */
- public boolean changed(final ExchangeSubscription that) {
- if (!equals(that)) {
- return true;
- }
-
- if (!getprincipal().equals(that.getprincipal())) {
- return true;
- }
-
- if (!getExchangeCalendar().equals(that.getExchangeCalendar())) {
- return true;
- }
-
- if (!getExchangeURI().equals(that.getExchangeURI())) {
- return true;
- }
-
- if (getSubscribe() != that.getSubscribe()) {
- return true;
- }
-
- return false;
- }
-
- /* ====================================================================
- * Object methods
- * ==================================================================== */
-
- @Override
- public int hashCode() {
- return getCalpath().hashCode();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("ExchangeSubscription{");
-
- toStringSegment(sb, " ");
-
- if (getOutstandingSubscription() != null) {
- sb.append(", \n OustandingSubscription{");
-
- toStringSegment(sb, " ");
- sb.append(" }");
- }
-
- sb.append("}");
- return sb.toString();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(final ExchangeSubscription that) {
- if (this == that) {
- return 0;
- }
-
- return getCalpath().compareTo(that.getCalpath());
- }
-
- @Override
- public boolean equals(final Object o) {
- return compareTo((ExchangeSubscription)o) == 0;
- }
-
- /* ====================================================================
- * Private methods
- * ==================================================================== */
-
- private void toStringSegment(final StringBuilder sb,
- final String indent) {
- sb.append("calpath = ");
- sb.append(getCalpath());
-
- sb.append(",\n");
- sb.append(indent);
- sb.append("principal = ");
- sb.append(getprincipal());
-
- sb.append(",\n");
- sb.append(indent);
- sb.append("exchangeCalendar = ");
- sb.append(getExchangeCalendar());
- sb.append(", exchangeURI = ");
- sb.append(getExchangeURI());
-
- sb.append(",\n");
- sb.append(indent);
- sb.append("subscribe = ");
- sb.append(getSubscribe());
- }
-}
Copied: trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java (from rev 2, trunk/src/org/bedework/exchgsynch/ExchangeSubscription.java)
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSubscription.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,261 @@
+/* **********************************************************************
+ Copyright 2010 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.exchgsynch;
+
+import edu.rpi.cmt.access.AccessPrincipal;
+
+/** Represents a current subscription or a subscription request.
+ *
+ * @author Mike Douglass
+ */
+public class ExchangeSubscription implements Comparable<ExchangeSubscription> {
+ private String calpath;
+
+ private AccessPrincipal principal;
+
+ private String exchangeCalendar;
+
+ private String exchangeURI;
+
+ private boolean subscribe;
+
+ private ExchangeSubscription outstandingSubscription;
+
+ /** Constructor
+ *
+ * @param principal
+ * @param calpath
+ * @param exchangeCalendar
+ * @param exchangeURI
+ * @param subscribe
+ */
+ public ExchangeSubscription(final String calpath,
+ final AccessPrincipal principal,
+ final String exchangeCalendar,
+ final String exchangeURI,
+ final boolean subscribe) {
+ this.principal = principal;
+ this.calpath = calpath;
+ this.exchangeCalendar = exchangeCalendar;
+ this.exchangeURI = exchangeURI;
+ this.subscribe = subscribe;
+ }
+
+ /** Path to this systems calendar collection
+ *
+ * @param val String
+ */
+ public void setCalpath(final String val) {
+ calpath = val;
+ }
+
+ /** Path to this systems calendar collection
+ *
+ * @return String
+ */
+ public String getCalpath() {
+ return calpath;
+ }
+
+
+ /** Principal requesting synch service
+ *
+ * @param val AccessPrincipal
+ */
+ public void setprincipal(final AccessPrincipal val) {
+ principal = val;
+ }
+
+ /** Principal requesting synch service
+ *
+ * @return AccessPrincipal
+ */
+ public AccessPrincipal getprincipal() {
+ return principal;
+ }
+ /** Exchange Calendar
+ *
+ * @param val String
+ */
+ public void setExchangeCalendar(final String val) {
+ exchangeCalendar = val;
+ }
+
+ /** Exchange Calendar
+ *
+ * @return String
+ */
+ public String getExchangeCalendar() {
+ return exchangeCalendar;
+ }
+
+ /** Exchange web service uri
+ *
+ * @param val String
+ */
+ public void setExchangeURI(final String val) {
+ exchangeURI = val;
+ }
+
+ /** Exchange web service uri
+ *
+ * @return String
+ */
+ public String getExchangeURI() {
+ return exchangeURI;
+ }
+
+ /** (un)subscribe?
+ *
+ * @param val boolean
+ */
+ public void setSubscribe(final boolean val) {
+ subscribe = val;
+ }
+
+ /** (un)subscribe?
+ *
+ * @return boolean
+ */
+ public boolean getSubscribe() {
+ return subscribe;
+ }
+
+ /** An outstanding request that requires an unsubscribe to complete first
+ *
+ * @param val ExchangeSubscription
+ */
+ public void setOutstandingSubscription(final ExchangeSubscription val) {
+ outstandingSubscription = val;
+ }
+
+ /** An outstanding request that requires an unsubscribe to complete first
+ *
+ * @return ExchangeSubscription
+ */
+ public ExchangeSubscription getOutstandingSubscription() {
+ return outstandingSubscription;
+ }
+
+ /** equality just checks the path. Look at the rest.
+ *
+ * @param that
+ * @return true if anything changed
+ */
+ public boolean changed(final ExchangeSubscription that) {
+ if (!equals(that)) {
+ return true;
+ }
+
+ if (!getprincipal().equals(that.getprincipal())) {
+ return true;
+ }
+
+ if (!getExchangeCalendar().equals(that.getExchangeCalendar())) {
+ return true;
+ }
+
+ if (!getExchangeURI().equals(that.getExchangeURI())) {
+ return true;
+ }
+
+ if (getSubscribe() != that.getSubscribe()) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /* ====================================================================
+ * Object methods
+ * ==================================================================== */
+
+ @Override
+ public int hashCode() {
+ return getCalpath().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder("ExchangeSubscription{");
+
+ toStringSegment(sb, " ");
+
+ if (getOutstandingSubscription() != null) {
+ sb.append(", \n OustandingSubscription{");
+
+ toStringSegment(sb, " ");
+ sb.append(" }");
+ }
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(final ExchangeSubscription that) {
+ if (this == that) {
+ return 0;
+ }
+
+ return getCalpath().compareTo(that.getCalpath());
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ return compareTo((ExchangeSubscription)o) == 0;
+ }
+
+ /* ====================================================================
+ * Private methods
+ * ==================================================================== */
+
+ private void toStringSegment(final StringBuilder sb,
+ final String indent) {
+ sb.append("calpath = ");
+ sb.append(getCalpath());
+
+ sb.append(",\n");
+ sb.append(indent);
+ sb.append("principal = ");
+ sb.append(getprincipal());
+
+ sb.append(",\n");
+ sb.append(indent);
+ sb.append("exchangeCalendar = ");
+ sb.append(getExchangeCalendar());
+ sb.append(", exchangeURI = ");
+ sb.append(getExchangeURI());
+
+ sb.append(",\n");
+ sb.append(indent);
+ sb.append("subscribe = ");
+ sb.append(getSubscribe());
+ }
+}
Deleted: trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java
===================================================================
--- trunk/src/org/bedework/exchgsynch/ExchangeSynch.java 2010-09-27 17:58:54 UTC (rev 1)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -1,284 +0,0 @@
-/* **********************************************************************
- Copyright 2010 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.caldav.server.exchange;
-
-import org.bedework.caldav.server.CaldavBWIntf;
-
-import edu.rpi.cct.webdav.servlet.shared.WebdavException;
-
-import org.apache.log4j.Logger;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/** Exchange synch processor.
- *
- * <p>This process manages the setting up of push-subscriptions with the exchange
- * service and provides support for the resulting call-back from Exchange.
- *
- * @author Mike Douglass
- */
-public class ExchangeSynch {
- private boolean debug;
-
- protected transient Logger log;
-
- /* Map of subscription requests with our calendar path as key */
- private Map<String, ExchangeSubscription> subs =
- new HashMap<String, ExchangeSubscription>();
-
- /* Map of subscription requests with Exchange subscription id as key */
- private Map<String, ExchangeSubscription> subsById =
- new HashMap<String, ExchangeSubscription>();
-
- ///* Line up subscriptions for processing */
- //private Queue<ExchangeSubscription> subscribeQueue =
- // new ConcurrentLinkedQueue<ExchangeSubscription>();
-
- private CaldavBWIntf bwintf;
-
- private ExchangeSynchIntf exintf;
-
- private boolean starting;
-
- private boolean running;
-
- private boolean stopping;
-
- /* Where we keep subscriptions that come in while we are starting */
- private List<ExchangeSubscription> subsList;
-
- private class Callback extends ExchangeCallback {
- @Override
- public void subscribeRequest(final ExchangeSubscription sub) throws WebdavException {
- ExchangeSynch.this.subscribeRequest(sub);
- }
- }
-
- /* We use this as a monitor */
- private Callback cb = new Callback();
-
- /** Constructor
- *
- * @param bwintf
- */
- public ExchangeSynch(final CaldavBWIntf bwintf) {
- this.bwintf = bwintf;
- debug = getLogger().isDebugEnabled();
- }
-
- /** Start synch process.
- *
- * @throws WebdavException
- */
- public void start() throws WebdavException {
- if (starting || running) {
- warn("Start called when already starting or running");
- return;
- }
-
- synchronized (cb) {
- subsList = null;
-
- starting = true;
- }
-
- exintf = bwintf.getSysi().initExchangeSynch(cb);
- if (exintf == null) {
- warn("System interface returned null interface");
- return;
- }
-
- info("Starting exchange synch");
-
- /* Get the list of subscriptions from the back end service and process them.
- * while starting, new subscribe requests get added to the list.
- */
- List<ExchangeSubscription> startList = exintf.getSubscriptions();
-
- while (starting) {
- if (debug) {
- trace("startList has " + startList.size() + " subscriptions");
- }
-
- for (ExchangeSubscription es: startList) {
- subscribe(es);
- }
-
- synchronized (cb) {
- if (subsList == null) {
- // Nothing came in as we started
- starting = false;
- running = true;
- break;
- }
-
- startList = subsList;
- subsList = null;
- }
- }
-
- info("Exchange synch started");
- }
-
- /** Stop synch process.
- *
- * @throws WebdavException
- */
- public void stop() throws WebdavException {
-
- }
-
- /** Update or add a subscription.
- *
- * @param sub
- * @throws WebdavException
- */
- public void subscribeRequest(final ExchangeSubscription sub) throws WebdavException {
- if (debug) {
- trace("new subscription " + sub);
- }
-
- synchronized (cb) {
- if (starting) {
- if (subsList == null) {
- subsList = new ArrayList<ExchangeSubscription>();
- }
-
- subsList.add(sub);
- return;
- }
- }
-
- if (!running) {
- return;
- }
-
- subscribe(sub);
- }
-
- /* ====================================================================
- * private methods
- * ==================================================================== */
-
- private void subscribe(final ExchangeSubscription sub) throws WebdavException {
- if (debug) {
- trace("Handle subscription " + sub);
- }
-
- if (!checkAccess(sub)) {
- info("No access for subscription " + sub);
- return;
- }
-
- synchronized (subs) {
- ExchangeSubscription tsub = subs.get(sub.getCalpath());
-
- if (tsub == null) {
- if (!sub.getSubscribe()) {
- if (debug) {
- trace("Unsubscribe and already unsubscribed");
- }
- }
-
- doSubscription(sub);
- subs.put(sub.getCalpath(), sub);
-
- return;
- }
-
- // We already have a subscription - does this change the state?
- if (!tsub.changed(sub)) {
- if (debug) {
- trace("No change");
- }
-
- return;
- }
-
- if (tsub.getSubscribe() && !sub.getSubscribe()) {
- // Unsubscribe request - set subscribed off and next callback will unsubscribe
- tsub.setOutstandingSubscription(null);
- tsub.setSubscribe(false);
- return;
- }
-
- if (!tsub.getSubscribe() && sub.getSubscribe()) {
- // Reverse previous unsubscribe?
- tsub.setSubscribe(true);
- return;
- }
-
- if (!tsub.getExchangeCalendar().equals(sub.getExchangeCalendar()) ||
- !tsub.getExchangeURI().equals(sub.getExchangeURI())) {
- // Pointing at another exchange target
- tsub.setOutstandingSubscription(sub);
- tsub.setSubscribe(false);
- return;
- }
-
- return;
- }
-
-
- }
-
- private void doSubscription(final ExchangeSubscription sub) throws WebdavException {
- /* Send a request for a new subscription to exchange */
- }
-
- private boolean checkAccess(final ExchangeSubscription sub) throws WebdavException {
- /* Does this principal have the rights to subscribe? */
- return true;
- }
-
- private Logger getLogger() {
- if (log == null) {
- log = Logger.getLogger(this.getClass());
- }
-
- return log;
- }
-
- private void trace(final String msg) {
- getLogger().debug(msg);
- }
-
- private void warn(final String msg) {
- getLogger().warn(msg);
- }
-
- private void error(final Throwable t) {
- getLogger().error(this, t);
- }
-
- private void info(final String msg) {
- getLogger().info(msg);
- }
-}
Copied: trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java (from rev 2, trunk/src/org/bedework/exchgsynch/ExchangeSynch.java)
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSynch.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,284 @@
+/* **********************************************************************
+ Copyright 2010 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.exchgsynch;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+/** Exchange synch processor.
+ *
+ * <p>This process manages the setting up of push-subscriptions with the exchange
+ * service and provides support for the resulting call-back from Exchange.
+ *
+ * @author Mike Douglass
+ */
+public class ExchangeSynch {
+ private boolean debug;
+
+ protected transient Logger log;
+
+ /* Map of subscription requests with our calendar path as key */
+ private Map<String, ExchangeSubscription> subs =
+ new HashMap<String, ExchangeSubscription>();
+
+ /* Map of subscription requests with Exchange subscription id as key */
+ private Map<String, ExchangeSubscription> subsById =
+ new HashMap<String, ExchangeSubscription>();
+
+ ///* Line up subscriptions for processing */
+ //private Queue<ExchangeSubscription> subscribeQueue =
+ // new ConcurrentLinkedQueue<ExchangeSubscription>();
+
+ private ExchangeSynchIntf intf;
+
+ private ExchangeSynchIntf exintf;
+
+ private boolean starting;
+
+ private boolean running;
+
+ private boolean stopping;
+
+ /* Where we keep subscriptions that come in while we are starting */
+ private List<ExchangeSubscription> subsList;
+
+ private class Callback extends ExchangeCallback {
+ @Override
+ public void subscribeRequest(final ExchangeSubscription sub) throws SynchException {
+ ExchangeSynch.this.subscribeRequest(sub);
+ }
+ }
+
+ /* We use this as a monitor */
+ private Callback cb = new Callback();
+
+ /** Constructor
+ *
+ * @param intf
+ */
+ public ExchangeSynch(final ExchangeSynchIntf intf) {
+ this.intf = intf;
+ debug = getLogger().isDebugEnabled();
+ }
+
+ /** Start synch process.
+ *
+ * @throws SynchException
+ */
+ public void start() throws SynchException {
+ if (starting || running) {
+ warn("Start called when already starting or running");
+ return;
+ }
+
+ synchronized (cb) {
+ subsList = null;
+
+ starting = true;
+ }
+
+ if (!intf.initExchangeSynch(cb)) {
+ warn("System interface returned false from init. Stopping");
+ starting = false;
+ return;
+ }
+
+ info("**************************************************");
+ info("Starting exchange synch");
+ info("**************************************************");
+
+ /* Get the list of subscriptions from the back end service and process them.
+ * while starting, new subscribe requests get added to the list.
+ */
+ List<ExchangeSubscription> startList = exintf.getSubscriptions();
+
+ while (starting) {
+ if (debug) {
+ trace("startList has " + startList.size() + " subscriptions");
+ }
+
+ for (ExchangeSubscription es: startList) {
+ subscribe(es);
+ }
+
+ synchronized (cb) {
+ if (subsList == null) {
+ // Nothing came in as we started
+ starting = false;
+ running = true;
+ break;
+ }
+
+ startList = subsList;
+ subsList = null;
+ }
+ }
+
+ info("**************************************************");
+ info("Exchange synch started");
+ info("**************************************************");
+ }
+
+ /** Stop synch process.
+ *
+ * @throws SynchException
+ */
+ public void stop() throws SynchException {
+
+ }
+
+ /** Update or add a subscription.
+ *
+ * @param sub
+ * @throws SynchException
+ */
+ public void subscribeRequest(final ExchangeSubscription sub) throws SynchException {
+ if (debug) {
+ trace("new subscription " + sub);
+ }
+
+ synchronized (cb) {
+ if (starting) {
+ if (subsList == null) {
+ subsList = new ArrayList<ExchangeSubscription>();
+ }
+
+ subsList.add(sub);
+ return;
+ }
+ }
+
+ if (!running) {
+ return;
+ }
+
+ subscribe(sub);
+ }
+
+ /* ====================================================================
+ * private methods
+ * ==================================================================== */
+
+ private void subscribe(final ExchangeSubscription sub) throws SynchException {
+ if (debug) {
+ trace("Handle subscription " + sub);
+ }
+
+ if (!checkAccess(sub)) {
+ info("No access for subscription " + sub);
+ return;
+ }
+
+ synchronized (subs) {
+ ExchangeSubscription tsub = subs.get(sub.getCalpath());
+
+ if (tsub == null) {
+ if (!sub.getSubscribe()) {
+ if (debug) {
+ trace("Unsubscribe and already unsubscribed");
+ }
+ }
+
+ doSubscription(sub);
+ subs.put(sub.getCalpath(), sub);
+
+ return;
+ }
+
+ // We already have a subscription - does this change the state?
+ if (!tsub.changed(sub)) {
+ if (debug) {
+ trace("No change");
+ }
+
+ return;
+ }
+
+ if (tsub.getSubscribe() && !sub.getSubscribe()) {
+ // Unsubscribe request - set subscribed off and next callback will unsubscribe
+ tsub.setOutstandingSubscription(null);
+ tsub.setSubscribe(false);
+ return;
+ }
+
+ if (!tsub.getSubscribe() && sub.getSubscribe()) {
+ // Reverse previous unsubscribe?
+ tsub.setSubscribe(true);
+ return;
+ }
+
+ if (!tsub.getExchangeCalendar().equals(sub.getExchangeCalendar()) ||
+ !tsub.getExchangeURI().equals(sub.getExchangeURI())) {
+ // Pointing at another exchange target
+ tsub.setOutstandingSubscription(sub);
+ tsub.setSubscribe(false);
+ return;
+ }
+
+ return;
+ }
+
+
+ }
+
+ private void doSubscription(final ExchangeSubscription sub) throws SynchException {
+ /* Send a request for a new subscription to exchange */
+ }
+
+ private boolean checkAccess(final ExchangeSubscription sub) throws SynchException {
+ /* Does this principal have the rights to subscribe? */
+ return true;
+ }
+
+ private Logger getLogger() {
+ if (log == null) {
+ log = Logger.getLogger(this.getClass());
+ }
+
+ return log;
+ }
+
+ private void trace(final String msg) {
+ getLogger().debug(msg);
+ }
+
+ private void warn(final String msg) {
+ getLogger().warn(msg);
+ }
+
+ private void error(final Throwable t) {
+ getLogger().error(this, t);
+ }
+
+ private void info(final String msg) {
+ getLogger().info(msg);
+ }
+}
Deleted: trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java
===================================================================
--- trunk/src/org/bedework/exchgsynch/ExchangeSynchIntf.java 2010-09-27 17:58:54 UTC (rev 1)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -1,70 +0,0 @@
-/* **********************************************************************
- Copyright 2010 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.caldav.server.exchange;
-
-import edu.rpi.cct.webdav.servlet.shared.WebdavException;
-
-import java.util.List;
-
-/** Calls from exchange synch processor to the service.
- *
- * @author Mike Douglass
- */
-public abstract class ExchangeSynchIntf {
- /** */
- public static class Credentials {
- String id;
- byte[] password;
-
- /** Constructor
- *
- * @param id
- * @param password
- */
- public Credentials(final String id,
- final byte[] password) {
- this.id = id;
- this.password = password;
- }
- }
-
- /** Get Credentials allowing log in to exchange for th egiven subscription
- *
- * @param sub
- * @return Credentials object
- * @throws WebdavException
- */
- public abstract Credentials getCredentials(ExchangeSubscription sub) throws WebdavException;
-
- /** Called by the Exchange synch process at startup to get the current list
- * of subscriptions. Will normally not be called again.
- *
- * @return List of current subscriptions - never null
- * @throws WebdavException
- */
- public abstract List<ExchangeSubscription> getSubscriptions() throws WebdavException;
-}
Copied: trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java (from rev 2, trunk/src/org/bedework/exchgsynch/ExchangeSynchIntf.java)
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/ExchangeSynchIntf.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,79 @@
+/* **********************************************************************
+ Copyright 2010 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.exchgsynch;
+
+import java.util.List;
+
+/** Calls from exchange synch processor to the service.
+ *
+ * @author Mike Douglass
+ */
+public interface ExchangeSynchIntf {
+ /** Called to initialise the exchange synch process. A response of false means
+ * no exchange synch. Note that users can synchronize with exchange systems in
+ * other domains, so even if your site doesn't run exchange you may want to to
+ * run the synch process,
+ *
+ * @param cb
+ * @return false for no synch.
+ * @throws WebdavException
+ */
+ boolean initExchangeSynch(ExchangeCallback cb) throws SynchException;
+
+ /** */
+ public static class Credentials {
+ String id;
+ byte[] password;
+
+ /** Constructor
+ *
+ * @param id
+ * @param password
+ */
+ public Credentials(final String id,
+ final byte[] password) {
+ this.id = id;
+ this.password = password;
+ }
+ }
+
+ /** Get Credentials allowing log in to exchange for the given subscription
+ *
+ * @param sub
+ * @return Credentials object
+ * @throws SynchException
+ */
+ Credentials getCredentials(ExchangeSubscription sub) throws SynchException;
+
+ /** Called by the Exchange synch process at startup to get the current list
+ * of subscriptions. Will normally not be called again.
+ *
+ * @return List of current subscriptions - never null
+ * @throws SynchException
+ */
+ List<ExchangeSubscription> getSubscriptions() throws SynchException;
+}
Added: trunk/server/src/org/bedework/exchgsynch/ExsynchConfig.java
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/ExsynchConfig.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/ExsynchConfig.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,89 @@
+/* **********************************************************************
+ Copyright 2007 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.exchgsynch;
+
+import java.io.Serializable;
+
+/** This class defines the various properties we need for an Exchange synch
+ *
+ * @author Mike Douglass
+ */
+public class ExsynchConfig implements Serializable {
+ /* Fro bedework build */
+ private String appType;
+
+ /* Default exchange web service uri - null for no default */
+ private String exchangeWsURI;
+
+ /* Exchange web service push callback uri - null for no exchange sync */
+ private String exchangeWsPushURI;
+
+ /**
+ * @param val
+ */
+ public void setAppType(final String val) {
+ appType = val;
+ }
+
+ /**
+ * @return String
+ */
+ public String getAppType() {
+ return appType;
+ }
+
+ /** Default exchange web service uri - null for no default
+ *
+ * @param val String
+ */
+ public void setExchangeWsURI(final String val) {
+ exchangeWsURI = val;
+ }
+
+ /** Default exchange web service uri - null for no default
+ *
+ * @return String
+ */
+ public String getExchangeWsURI() {
+ return exchangeWsURI;
+ }
+
+ /** Exchange web service push callback uri - null for no exchange sync
+ *
+ * @param val String
+ */
+ public void setExchangeWsPushURI(final String val) {
+ exchangeWsPushURI = val;
+ }
+
+ /** Exchange web service push callback uri - null for no exchange sync
+ *
+ * @return String
+ */
+ public String getExchangeWsPushURI() {
+ return exchangeWsPushURI;
+ }
+}
Copied: trunk/server/src/org/bedework/exchgsynch/SynchException.java (from rev 2, trunk/src/org/bedework/exchgsynch/SynchException.java)
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/SynchException.java (rev 0)
+++ trunk/server/src/org/bedework/exchgsynch/SynchException.java 2010-09-27 19:30:21 UTC (rev 3)
@@ -0,0 +1,126 @@
+/* **********************************************************************
+ 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.exchgsynch;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+
+/** Base exception thrown by exchange synch classes
+ *
+ * @author Mike Douglass douglm at rpi.edu
+ */
+public class SynchException extends Throwable {
+ /** > 0 if set
+ */
+ int statusCode = -1;
+ QName errorTag;
+
+ /** Constructor
+ *
+ * @param s
+ */
+ public SynchException(String s) {
+ super(s);
+ if (statusCode < 0) {
+ statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ }
+ }
+
+ /** Constructor
+ *
+ * @param t
+ */
+ public SynchException(Throwable t) {
+ super(t);
+ if (statusCode < 0) {
+ statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ }
+ }
+
+ /** Constructor
+ *
+ * @param st
+ */
+ public SynchException(int st) {
+ statusCode = st;
+ }
+
+ /** Constructor
+ *
+ * @param st
+ * @param msg
+ */
+ public SynchException(int st, String msg) {
+ super(msg);
+ statusCode = st;
+ }
+
+ /** Constructor
+ *
+ * @param st
+ * @param errorTag
+ */
+ public SynchException(int st, QName errorTag) {
+ statusCode = st;
+ this.errorTag = errorTag;
+ }
+
+ /** Constructor
+ *
+ * @param st
+ * @param errorTag
+ * @param msg
+ */
+ public SynchException(int st, QName errorTag, String msg) {
+ super(msg);
+ statusCode = st;
+ this.errorTag = errorTag;
+ }
+
+ /** Set the status
+ * @param val int status
+ */
+ public void setStatusCode(int val) {
+ statusCode = val;
+ }
+
+ /** Get the status
+ *
+ * @return int status
+ */
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ /** Get the errorTag
+ *
+ * @return QName
+ */
+ public QName getErrorTag() {
+ return errorTag;
+ }
+}
Copied: trunk/server/src/org/bedework/exchgsynch/bwimpl (from rev 2, trunk/src/org/bedework/exchgsynch/bwimpl)
More information about the Bedework-commit
mailing list