[Bedework-commit] exchgsynch r22 - in trunk: common/src/org/bedework/exchgsynch common/src/org/bedework/exchgsynch/responses server/src/org/bedework/exchgsynch/web

svnadmin at bedework.org svnadmin at bedework.org
Fri Oct 15 11:49:58 EDT 2010


Author: douglm
Date: 2010-10-15 11:49:57 -0400 (Fri, 15 Oct 2010)
New Revision: 22

Added:
   trunk/common/src/org/bedework/exchgsynch/responses/
   trunk/common/src/org/bedework/exchgsynch/responses/ExchangeResponse.java
   trunk/common/src/org/bedework/exchgsynch/responses/ExsynchSubscribeResponse.java
   trunk/common/src/org/bedework/exchgsynch/responses/Notification.java
Removed:
   trunk/common/src/org/bedework/exchgsynch/ExchangeResponse.java
   trunk/common/src/org/bedework/exchgsynch/ExsynchSubscribeResponse.java
   trunk/common/src/org/bedework/exchgsynch/Notification.java
Modified:
   trunk/common/src/org/bedework/exchgsynch/ExchangeSynch.java
   trunk/server/src/org/bedework/exchgsynch/web/PostMethod.java
Log:
Some refactoring


Deleted: trunk/common/src/org/bedework/exchgsynch/ExchangeResponse.java
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/ExchangeResponse.java	2010-10-15 15:36:22 UTC (rev 21)
+++ trunk/common/src/org/bedework/exchgsynch/ExchangeResponse.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -1,142 +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.exchgsynch;
-
-import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType;
-import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType.MessageXml;
-import com.microsoft.schemas.exchange.services._2006.types.ResponseClassType;
-
-/** Base Response from Exchange.
- *
- */
-public class ExchangeResponse {
-  private String messageText;
-
-  private String responseCode;
-
-  private Integer descriptiveLinkKey;
-
-  private MessageXml messageXml;
-
-  private boolean valid;
-  private boolean warning;
-  private boolean error;
-
-  ExchangeResponse(final ResponseMessageType resp) throws SynchException {
-    messageText = resp.getMessageText();
-
-    responseCode = resp.getResponseCode();
-
-    descriptiveLinkKey = resp.getDescriptiveLinkKey();
-
-    messageXml = resp.getMessageXml();
-
-    ResponseClassType rcl = resp.getResponseClass();
-    if (rcl.equals(ResponseClassType.ERROR)) {
-      error = true;
-      return;
-    }
-
-    if (rcl.equals(ResponseClassType.WARNING)) {
-      warning = true;
-      return;
-    }
-
-    valid = true;
-  }
-
-  /**
-   * @return - message text
-   */
-  public String getMessageText() {
-    return messageText;
-  }
-
-  /**
-   * @return - responseCode
-   */
-  public String getResponseCode() {
-    return responseCode;
-  }
-
-  /**
-   * @return Integer or null
-   */
-  public Integer getDescriptiveLinkKey() {
-      return descriptiveLinkKey;
-  }
-
-  /**
-   * @return - message xml
-   */
-  public MessageXml getMessageXml() {
-    return messageXml;
-  }
-
-  /**
-   * @return - was the response valid?
-   */
-  public boolean getValid() {
-    return valid;
-  }
-
-  /**
-   * @return - was the response an error?
-   */
-  public boolean getError() {
-    return error;
-  }
-
-  /**
-   * @return - was the response a warning?
-   */
-  public boolean getWarning() {
-    return warning;
-  }
-
-  public void toStringSegment(final StringBuilder sb) {
-    if (getError()) {
-      sb.append("error");
-    } else if (getWarning()) {
-      sb.append("warning");
-    } else {
-      sb.append("success");
-    }
-
-    sb.append(", responseCode=");
-    sb.append(getResponseCode());
-
-    if (getMessageText() != null) {
-      sb.append(",\n    message=");
-      sb.append(getMessageText());
-    }
-
-    if (getDescriptiveLinkKey() != null) {
-      sb.append(", descriptiveLinkKey=");
-      sb.append(getDescriptiveLinkKey());
-    }
-  }
-}

Modified: trunk/common/src/org/bedework/exchgsynch/ExchangeSynch.java
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/ExchangeSynch.java	2010-10-15 15:36:22 UTC (rev 21)
+++ trunk/common/src/org/bedework/exchgsynch/ExchangeSynch.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -28,6 +28,7 @@
 
 import org.bedework.exchgsynch.ExchangeSynchIntf.Credentials;
 import org.bedework.exchgsynch.bwimpl.BwSynchIntfImpl;
+import org.bedework.exchgsynch.responses.ExsynchSubscribeResponse;
 
 import edu.rpi.sss.util.OptionsException;
 import edu.rpi.sss.util.OptionsI;
@@ -42,11 +43,14 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Holder;
 
 import com.microsoft.schemas.exchange.services._2006.messages.ExchangeServicePortType;
 import com.microsoft.schemas.exchange.services._2006.messages.ExchangeWebService;
+import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType;
+import com.microsoft.schemas.exchange.services._2006.messages.SubscribeResponseMessageType;
 import com.microsoft.schemas.exchange.services._2006.messages.SubscribeResponseType;
 import com.microsoft.schemas.exchange.services._2006.messages.SubscribeType;
 import com.microsoft.schemas.exchange.services._2006.types.DistinguishedFolderIdNameType;
@@ -512,8 +516,18 @@
         trace(subscribeResult.toString());
       }
 
-      ExsynchSubscribeResponse esr = new ExsynchSubscribeResponse(subscribeResult.value);
 
+      List<JAXBElement<? extends ResponseMessageType>> rms =
+        subscribeResult.value.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage();
+
+      if (rms.size() != 1) {
+        //
+        return;
+      }
+
+      SubscribeResponseMessageType srm = (SubscribeResponseMessageType)rms.iterator().next().getValue();
+      ExsynchSubscribeResponse esr = new ExsynchSubscribeResponse(srm);
+
       if (debug) {
         trace(esr.toString());
       }

Deleted: trunk/common/src/org/bedework/exchgsynch/ExsynchSubscribeResponse.java
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/ExsynchSubscribeResponse.java	2010-10-15 15:36:22 UTC (rev 21)
+++ trunk/common/src/org/bedework/exchgsynch/ExsynchSubscribeResponse.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -1,234 +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.exchgsynch;
-
-import org.apache.log4j.Logger;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType;
-import com.microsoft.schemas.exchange.services._2006.messages.SubscribeResponseMessageType;
-import com.microsoft.schemas.exchange.services._2006.messages.SubscribeResponseType;
-import com.microsoft.schemas.exchange.services._2006.types.ResponseClassType;
-
-/** Response from a subscription.
- *
- */
-public class ExsynchSubscribeResponse {
-  private Logger logger = Logger.getLogger(ExsynchSubscribeResponse.class);
-
-  private boolean debug = logger.isDebugEnabled();
-
-  private boolean valid;
-  private boolean warning;
-  private boolean error;
-  private String rcode;
-  private String messageText;
-
-  private Integer descriptiveLinkKey;
-  private String subscriptionId;
-  private String watermark;
-
-  ExsynchSubscribeResponse(final SubscribeResponseType resp) throws SynchException {
-    /* Successful looks ssomething like
-     * <?xml version="1.0" encoding="utf-8"?>
-     * <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
-     *   <s:Header>
-     *     <h:ServerVersionInfo MajorVersion="14" MinorVersion="0"
-     *                          MajorBuildNumber="639" MinorBuildNumber="21"
-     *                          Version="Exchange2010"
-     *          xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
-     *          xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
-     *          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-     *          xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
-     *   </s:Header>
-     *   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-     *           xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-     *     <m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
-     *                          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
-     *       <m:ResponseMessages>
-     *         <m:SubscribeResponseMessage ResponseClass="Success">
-     *           <m:ResponseCode>NoError</m:ResponseCode>
-     *           <m:SubscriptionId>HQB0b290bGVzLWZlMS5uZXZlcmxhbmQucnBpLmVkdRAAAAB6doL7rLBaRJpD6SPqdeo6E2rIWt0xzQg=</m:SubscriptionId>
-     *           <m:Watermark>AQAAAA9RN9h99EZMiSH6g0jBK/hThQAAAAAAAAA=</m:Watermark>
-     *         </m:SubscribeResponseMessage>
-     *       </m:ResponseMessages>
-     *     </m:SubscribeResponse>
-     *   </s:Body>
-     * </s:Envelope>
-     * ----------------------------------------------------------------------
-     * Failure:
-     * <?xml version="1.0" encoding="utf-8"?>
-     * <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
-     *   <s:Header>
-     *     <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="639" MinorBuildNumber="21" Version="Exchange2010"
-     *                          xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
-     *                          xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-     *                          xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
-     *   </s:Header>
-     *   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-     *     <m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
-     *                          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
-     *       <m:ResponseMessages>
-     *         <m:SubscribeResponseMessage ResponseClass="Error">
-     *           <m:MessageText>Id is malformed.</m:MessageText>
-     *           <m:ResponseCode>ErrorInvalidIdMalformed</m:ResponseCode>
-     *           <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
-     *         </m:SubscribeResponseMessage>
-     *       </m:ResponseMessages>
-     *     </m:SubscribeResponse>
-     *   </s:Body>
-     * </s:Envelope>
-     */
-    List<JAXBElement<? extends ResponseMessageType>> rms =
-      resp.getResponseMessages().getCreateItemResponseMessageOrDeleteItemResponseMessageOrGetItemResponseMessage();
-
-    if (rms.size() != 1) {
-      //
-      return;
-    }
-    SubscribeResponseMessageType srm = (SubscribeResponseMessageType)rms.iterator().next().getValue();
-
-    ResponseClassType rcl = srm.getResponseClass();
-    rcode = srm.getResponseCode();
-
-    messageText = srm.getMessageText();
-
-    if (rcl.equals(ResponseClassType.ERROR)) {
-      error = true;
-      return;
-    }
-
-    if (rcl.equals(ResponseClassType.WARNING)) {
-      warning = true;
-      return;
-    }
-
-    descriptiveLinkKey = srm.getDescriptiveLinkKey();
-    subscriptionId = srm.getSubscriptionId();
-    watermark = srm.getWatermark();
-
-    valid = true;
-  }
-
-  /**
-   * @return - rcode
-   */
-  public String getRcode() {
-    return rcode;
-  }
-
-  /**
-   * @return - message text
-   */
-  public String getMessageText() {
-    return messageText;
-  }
-
-  /**
-   * @return - was the response valid?
-   */
-  public boolean getValid() {
-    return valid;
-  }
-
-  /**
-   * @return - was the response an error?
-   */
-  public boolean getError() {
-    return error;
-  }
-
-  /**
-   * @return - was the response a warning?
-   */
-  public boolean getWarning() {
-    return warning;
-  }
-
-  /**
-   * @return Integer or null
-   */
-  public Integer getDescriptiveLinkKey() {
-      return descriptiveLinkKey;
-  }
-
-  /**
-   * @return String
-   */
-  public String getSubscriptionId() {
-    return subscriptionId;
-  }
-
-  /**
-   * @return String
-   */
-  public String getWatermark() {
-    return watermark;
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("ExsynchSubscribeResponse{");
-
-    if (getError()) {
-      sb.append("error");
-    } else if (getWarning()) {
-      sb.append("warning");
-    } else {
-      sb.append("success");
-    }
-
-    sb.append(", rcode=");
-    sb.append(getRcode());
-
-    if (getMessageText() != null) {
-      sb.append(", message=");
-      sb.append(getMessageText());
-    }
-
-    if (getDescriptiveLinkKey() != null) {
-      sb.append(", descriptiveLinkKey=");
-      sb.append(getDescriptiveLinkKey());
-    }
-
-    if (getSubscriptionId() != null) {
-      sb.append(",\n    subscriptionId=");
-      sb.append(getSubscriptionId());
-    }
-
-    if (getWatermark() != null) {
-      sb.append(",\n    watermark=");
-      sb.append(getWatermark());
-    }
-
-    sb.append("}");
-
-    return sb.toString();
-  }
-}

Deleted: trunk/common/src/org/bedework/exchgsynch/Notification.java
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/Notification.java	2010-10-15 15:36:22 UTC (rev 21)
+++ trunk/common/src/org/bedework/exchgsynch/Notification.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -1,301 +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.exchgsynch;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import com.microsoft.schemas.exchange.services._2006.messages.SendNotificationResponseMessageType;
-import com.microsoft.schemas.exchange.services._2006.types.BaseNotificationEventType;
-import com.microsoft.schemas.exchange.services._2006.types.BaseObjectChangedEventType;
-import com.microsoft.schemas.exchange.services._2006.types.FolderIdType;
-import com.microsoft.schemas.exchange.services._2006.types.ItemIdType;
-import com.microsoft.schemas.exchange.services._2006.types.ModifiedEventType;
-import com.microsoft.schemas.exchange.services._2006.types.MovedCopiedEventType;
-import com.microsoft.schemas.exchange.services._2006.types.NotificationType;
-
-/** Notification from Exchange.
- *
- */
-public class Notification extends ExchangeResponse {
-  private String subscriptionId;
-  private String previousWatermark;
-
-  private List<NotificationItem> notifications = new ArrayList<NotificationItem>();
-
-  public Notification(final SendNotificationResponseMessageType snrm) throws SynchException {
-    super(snrm);
-
-    NotificationType nt = snrm.getNotification();
-    subscriptionId = nt.getSubscriptionId();
-    previousWatermark = nt.getPreviousWatermark();
-
-    List<JAXBElement<? extends BaseNotificationEventType>> bnes =
-      nt.getCopiedEventOrCreatedEventOrDeletedEvent();
-
-    for (JAXBElement<? extends BaseNotificationEventType> el1: bnes) {
-      notifications.add(new NotificationItem(el1.getName().getLocalPart(),
-                                             el1.getValue()));
-    }
-  }
-
-  /**
-   * @return String
-   */
-  public String getSubscriptionId() {
-    return subscriptionId;
-  }
-
-  /**
-   * @return String
-   */
-  public String getPreviousWatermark() {
-    return previousWatermark;
-  }
-
-  public List<NotificationItem> getNotifications() {
-    return notifications;
-  }
-
-
-  public static class NotificationItem extends BaseObjectChangedEventType {
-    public enum ActionType {
-      CopiedEvent,
-      CreatedEvent,
-      DeletedEvent,
-      ModifiedEvent,
-      MovedEvent,
-      NewMailEvent,
-      StatusEvent
-    }
-
-    private ActionType action;
-
-    // Moved or copied fields
-    private FolderIdType oldFolderId;
-    private ItemIdType oldItemId;
-    private FolderIdType oldParentFolderId;
-
-    // Modified
-    private Integer unreadCount;
-
-    private NotificationItem(final String actionStr,
-                             final BaseNotificationEventType bne) {
-      setWatermark(bne.getWatermark());
-
-      if (actionStr.equals("StatusEvent")) {
-        action = ActionType.StatusEvent;
-
-        return;
-      }
-
-      if (bne instanceof BaseObjectChangedEventType) {
-        BaseObjectChangedEventType boce = (BaseObjectChangedEventType)bne;
-
-        setTimeStamp(boce.getTimeStamp());
-        setFolderId(boce.getFolderId());
-        setItemId(boce.getItemId());
-        setParentFolderId(boce.getParentFolderId());
-      }
-
-      if (actionStr.equals("CopiedEvent")) {
-        action = ActionType.CopiedEvent;
-
-        MovedCopiedEventType mce = (MovedCopiedEventType)bne;
-
-        oldFolderId = mce.getOldFolderId();
-        oldItemId = mce.getOldItemId();
-        oldParentFolderId = mce.getOldParentFolderId();
-
-        return;
-      }
-
-      if (actionStr.equals("CreatedEvent")) {
-        action = ActionType.CreatedEvent;
-
-        return;
-      }
-
-      if (actionStr.equals("DeletedEvent")) {
-        action = ActionType.DeletedEvent;
-
-        return;
-      }
-
-      if (actionStr.equals("ModifiedEvent")) {
-        action = ActionType.ModifiedEvent;
-        ModifiedEventType met = (ModifiedEventType)bne;
-
-        unreadCount = met.getUnreadCount();
-
-        return;
-      }
-
-      if (actionStr.equals("MovedEvent")) {
-        action = ActionType.MovedEvent;
-        MovedCopiedEventType mce = (MovedCopiedEventType)bne;
-
-        oldFolderId = mce.getOldFolderId();
-        oldItemId = mce.getOldItemId();
-        oldParentFolderId = mce.getOldParentFolderId();
-
-        return;
-      }
-
-      if (actionStr.equals("NewMailEvent")) {
-        action = ActionType.NewMailEvent;
-
-        return;
-      }
-    }
-
-    /** Common to all
-     *
-     * @return String
-     */
-    @Override
-    public String getWatermark() {
-      return watermark;
-    }
-
-    /**
-     * @return the action
-     */
-    public ActionType getAction() {
-      return action;
-    }
-
-    /** Gets the value of the oldFolderId property.
-     *
-     * @return FolderIdType
-     */
-    public FolderIdType getOldFolderId() {
-      return oldFolderId;
-    }
-
-    /** Gets the value of the oldItemId property.
-     *
-     * @return FolderIdType
-     */
-    public ItemIdType getOldItemId() {
-      return oldItemId;
-    }
-
-    /** Gets the value of the oldParentFolderId property.
-     *
-     * @return FolderIdType
-     */
-    public FolderIdType getOldParentFolderId() {
-      return oldParentFolderId;
-    }
-
-    /** Gets the value of the unreadCount property.
-     *
-     * @return Integer
-     */
-    public Integer getUnreadCount() {
-      return unreadCount;
-    }
-
-    @Override
-    public String toString() {
-      StringBuilder sb = new StringBuilder("NotificationItem{");
-
-      sb.append("watermark=");
-      sb.append(getWatermark());
-
-      sb.append(",\n      action=");
-      sb.append(getAction());
-
-      sb.append(", timeStamp=");
-      sb.append(getTimeStamp());
-
-      sb.append(",\n      folderId=");
-      sb.append(getFolderId());
-
-      sb.append(",\n      itemId=");
-      sb.append(getItemId());
-
-      sb.append(",\n      parentFolderId=");
-      sb.append(getParentFolderId());
-
-      if (getOldFolderId() != null) {
-        sb.append(",\n      oldFolderId=");
-        sb.append(getOldFolderId());
-      }
-
-      if (getOldItemId() != null) {
-        sb.append(",\n       oldItemId=");
-        sb.append(getOldItemId());
-      }
-
-      if (getOldParentFolderId() != null) {
-        sb.append(",\n       oldParentFolderId=");
-        sb.append(getOldParentFolderId());
-      }
-
-      if (getUnreadCount() != null) {
-        sb.append(",\n       unreadCount=");
-        sb.append(getUnreadCount());
-      }
-
-      sb.append("}");
-
-      return sb.toString();
-    }
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("Notification{");
-
-    super.toStringSegment(sb);
-
-    sb.append(",\n   subscriptionId=");
-    sb.append(getSubscriptionId());
-
-    sb.append(",\n   previousWatermark=");
-    sb.append(getPreviousWatermark());
-
-    String delim = ",\n   notification items{\n      ";
-    for (NotificationItem ni: getNotifications()) {
-      sb.append(delim);
-      sb.append(ni.toString());
-
-      delim =",\n      ";
-    }
-
-    if (getNotifications().size() > 0) {
-      sb.append("}");
-    }
-
-    sb.append("}");
-
-    return sb.toString();
-  }
-}

Copied: trunk/common/src/org/bedework/exchgsynch/responses/ExchangeResponse.java (from rev 21, trunk/common/src/org/bedework/exchgsynch/ExchangeResponse.java)
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/responses/ExchangeResponse.java	                        (rev 0)
+++ trunk/common/src/org/bedework/exchgsynch/responses/ExchangeResponse.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -0,0 +1,160 @@
+/* **********************************************************************
+    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.responses;
+
+import org.bedework.exchgsynch.SynchException;
+
+import org.apache.log4j.Logger;
+
+import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType;
+import com.microsoft.schemas.exchange.services._2006.messages.ResponseMessageType.MessageXml;
+import com.microsoft.schemas.exchange.services._2006.types.ResponseClassType;
+
+/** Base Response from Exchange.
+ *
+ */
+public class ExchangeResponse {
+  private Logger logger;
+
+  protected boolean debug;
+
+  private String messageText;
+
+  private String responseCode;
+
+  private Integer descriptiveLinkKey;
+
+  private MessageXml messageXml;
+
+  private boolean valid;
+  private boolean warning;
+  private boolean error;
+
+  ExchangeResponse(final ResponseMessageType resp) throws SynchException {
+    debug = getLogger().isDebugEnabled();
+
+    messageText = resp.getMessageText();
+
+    responseCode = resp.getResponseCode();
+
+    descriptiveLinkKey = resp.getDescriptiveLinkKey();
+
+    messageXml = resp.getMessageXml();
+
+    ResponseClassType rcl = resp.getResponseClass();
+    if (rcl.equals(ResponseClassType.ERROR)) {
+      error = true;
+      return;
+    }
+
+    if (rcl.equals(ResponseClassType.WARNING)) {
+      warning = true;
+      return;
+    }
+
+    valid = true;
+  }
+
+  /**
+   * @return - message text
+   */
+  public String getMessageText() {
+    return messageText;
+  }
+
+  /**
+   * @return - responseCode
+   */
+  public String getResponseCode() {
+    return responseCode;
+  }
+
+  /**
+   * @return Integer or null
+   */
+  public Integer getDescriptiveLinkKey() {
+      return descriptiveLinkKey;
+  }
+
+  /**
+   * @return - message xml
+   */
+  public MessageXml getMessageXml() {
+    return messageXml;
+  }
+
+  /**
+   * @return - was the response valid?
+   */
+  public boolean getValid() {
+    return valid;
+  }
+
+  /**
+   * @return - was the response an error?
+   */
+  public boolean getError() {
+    return error;
+  }
+
+  /**
+   * @return - was the response a warning?
+   */
+  public boolean getWarning() {
+    return warning;
+  }
+
+  public void toStringSegment(final StringBuilder sb) {
+    if (getError()) {
+      sb.append("error");
+    } else if (getWarning()) {
+      sb.append("warning");
+    } else {
+      sb.append("success");
+    }
+
+    sb.append(", responseCode=");
+    sb.append(getResponseCode());
+
+    if (getMessageText() != null) {
+      sb.append(",\n    message=");
+      sb.append(getMessageText());
+    }
+
+    if (getDescriptiveLinkKey() != null) {
+      sb.append(", descriptiveLinkKey=");
+      sb.append(getDescriptiveLinkKey());
+    }
+  }
+
+  protected Logger getLogger() {
+    if (logger == null) {
+      logger = Logger.getLogger(this.getClass());
+    }
+
+    return logger;
+  }
+}

Copied: trunk/common/src/org/bedework/exchgsynch/responses/ExsynchSubscribeResponse.java (from rev 20, trunk/common/src/org/bedework/exchgsynch/ExsynchSubscribeResponse.java)
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/responses/ExsynchSubscribeResponse.java	                        (rev 0)
+++ trunk/common/src/org/bedework/exchgsynch/responses/ExsynchSubscribeResponse.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -0,0 +1,130 @@
+/* **********************************************************************
+    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.responses;
+
+import org.bedework.exchgsynch.SynchException;
+
+import com.microsoft.schemas.exchange.services._2006.messages.SubscribeResponseMessageType;
+
+/** Response from a subscription.
+ *
+ */
+public class ExsynchSubscribeResponse extends ExchangeResponse {
+  private String subscriptionId;
+  private String watermark;
+
+  public ExsynchSubscribeResponse(final SubscribeResponseMessageType srm) throws SynchException {
+    /* Successful looks ssomething like
+     * <?xml version="1.0" encoding="utf-8"?>
+     * <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
+     *   <s:Header>
+     *     <h:ServerVersionInfo MajorVersion="14" MinorVersion="0"
+     *                          MajorBuildNumber="639" MinorBuildNumber="21"
+     *                          Version="Exchange2010"
+     *          xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
+     *          xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
+     *          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     *          xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
+     *   </s:Header>
+     *   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     *           xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+     *     <m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
+     *                          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
+     *       <m:ResponseMessages>
+     *         <m:SubscribeResponseMessage ResponseClass="Success">
+     *           <m:ResponseCode>NoError</m:ResponseCode>
+     *           <m:SubscriptionId>HQB0b290bGVzLWZlMS5uZXZlcmxhbmQucnBpLmVkdRAAAAB6doL7rLBaRJpD6SPqdeo6E2rIWt0xzQg=</m:SubscriptionId>
+     *           <m:Watermark>AQAAAA9RN9h99EZMiSH6g0jBK/hThQAAAAAAAAA=</m:Watermark>
+     *         </m:SubscribeResponseMessage>
+     *       </m:ResponseMessages>
+     *     </m:SubscribeResponse>
+     *   </s:Body>
+     * </s:Envelope>
+     * ----------------------------------------------------------------------
+     * Failure:
+     * <?xml version="1.0" encoding="utf-8"?>
+     * <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
+     *   <s:Header>
+     *     <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="639" MinorBuildNumber="21" Version="Exchange2010"
+     *                          xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
+     *                          xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+     *                          xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
+     *   </s:Header>
+     *   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+     *     <m:SubscribeResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
+     *                          xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
+     *       <m:ResponseMessages>
+     *         <m:SubscribeResponseMessage ResponseClass="Error">
+     *           <m:MessageText>Id is malformed.</m:MessageText>
+     *           <m:ResponseCode>ErrorInvalidIdMalformed</m:ResponseCode>
+     *           <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
+     *         </m:SubscribeResponseMessage>
+     *       </m:ResponseMessages>
+     *     </m:SubscribeResponse>
+     *   </s:Body>
+     * </s:Envelope>
+     */
+    super(srm);
+
+    subscriptionId = srm.getSubscriptionId();
+    watermark = srm.getWatermark();
+  }
+
+  /**
+   * @return String
+   */
+  public String getSubscriptionId() {
+    return subscriptionId;
+  }
+
+  /**
+   * @return String
+   */
+  public String getWatermark() {
+    return watermark;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("ExsynchSubscribeResponse{");
+
+    super.toStringSegment(sb);
+
+    if (getSubscriptionId() != null) {
+      sb.append(",\n    subscriptionId=");
+      sb.append(getSubscriptionId());
+    }
+
+    if (getWatermark() != null) {
+      sb.append(",\n    watermark=");
+      sb.append(getWatermark());
+    }
+
+    sb.append("}");
+
+    return sb.toString();
+  }
+}

Copied: trunk/common/src/org/bedework/exchgsynch/responses/Notification.java (from rev 21, trunk/common/src/org/bedework/exchgsynch/Notification.java)
===================================================================
--- trunk/common/src/org/bedework/exchgsynch/responses/Notification.java	                        (rev 0)
+++ trunk/common/src/org/bedework/exchgsynch/responses/Notification.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -0,0 +1,303 @@
+/* **********************************************************************
+    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.responses;
+
+import org.bedework.exchgsynch.SynchException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import com.microsoft.schemas.exchange.services._2006.messages.SendNotificationResponseMessageType;
+import com.microsoft.schemas.exchange.services._2006.types.BaseNotificationEventType;
+import com.microsoft.schemas.exchange.services._2006.types.BaseObjectChangedEventType;
+import com.microsoft.schemas.exchange.services._2006.types.FolderIdType;
+import com.microsoft.schemas.exchange.services._2006.types.ItemIdType;
+import com.microsoft.schemas.exchange.services._2006.types.ModifiedEventType;
+import com.microsoft.schemas.exchange.services._2006.types.MovedCopiedEventType;
+import com.microsoft.schemas.exchange.services._2006.types.NotificationType;
+
+/** Notification from Exchange.
+ *
+ */
+public class Notification extends ExchangeResponse {
+  private String subscriptionId;
+  private String previousWatermark;
+
+  private List<NotificationItem> notifications = new ArrayList<NotificationItem>();
+
+  public Notification(final SendNotificationResponseMessageType snrm) throws SynchException {
+    super(snrm);
+
+    NotificationType nt = snrm.getNotification();
+    subscriptionId = nt.getSubscriptionId();
+    previousWatermark = nt.getPreviousWatermark();
+
+    List<JAXBElement<? extends BaseNotificationEventType>> bnes =
+      nt.getCopiedEventOrCreatedEventOrDeletedEvent();
+
+    for (JAXBElement<? extends BaseNotificationEventType> el1: bnes) {
+      notifications.add(new NotificationItem(el1.getName().getLocalPart(),
+                                             el1.getValue()));
+    }
+  }
+
+  /**
+   * @return String
+   */
+  public String getSubscriptionId() {
+    return subscriptionId;
+  }
+
+  /**
+   * @return String
+   */
+  public String getPreviousWatermark() {
+    return previousWatermark;
+  }
+
+  public List<NotificationItem> getNotifications() {
+    return notifications;
+  }
+
+
+  public static class NotificationItem extends BaseObjectChangedEventType {
+    public enum ActionType {
+      CopiedEvent,
+      CreatedEvent,
+      DeletedEvent,
+      ModifiedEvent,
+      MovedEvent,
+      NewMailEvent,
+      StatusEvent
+    }
+
+    private ActionType action;
+
+    // Moved or copied fields
+    private FolderIdType oldFolderId;
+    private ItemIdType oldItemId;
+    private FolderIdType oldParentFolderId;
+
+    // Modified
+    private Integer unreadCount;
+
+    private NotificationItem(final String actionStr,
+                             final BaseNotificationEventType bne) {
+      setWatermark(bne.getWatermark());
+
+      if (actionStr.equals("StatusEvent")) {
+        action = ActionType.StatusEvent;
+
+        return;
+      }
+
+      if (bne instanceof BaseObjectChangedEventType) {
+        BaseObjectChangedEventType boce = (BaseObjectChangedEventType)bne;
+
+        setTimeStamp(boce.getTimeStamp());
+        setFolderId(boce.getFolderId());
+        setItemId(boce.getItemId());
+        setParentFolderId(boce.getParentFolderId());
+      }
+
+      if (actionStr.equals("CopiedEvent")) {
+        action = ActionType.CopiedEvent;
+
+        MovedCopiedEventType mce = (MovedCopiedEventType)bne;
+
+        oldFolderId = mce.getOldFolderId();
+        oldItemId = mce.getOldItemId();
+        oldParentFolderId = mce.getOldParentFolderId();
+
+        return;
+      }
+
+      if (actionStr.equals("CreatedEvent")) {
+        action = ActionType.CreatedEvent;
+
+        return;
+      }
+
+      if (actionStr.equals("DeletedEvent")) {
+        action = ActionType.DeletedEvent;
+
+        return;
+      }
+
+      if (actionStr.equals("ModifiedEvent")) {
+        action = ActionType.ModifiedEvent;
+        ModifiedEventType met = (ModifiedEventType)bne;
+
+        unreadCount = met.getUnreadCount();
+
+        return;
+      }
+
+      if (actionStr.equals("MovedEvent")) {
+        action = ActionType.MovedEvent;
+        MovedCopiedEventType mce = (MovedCopiedEventType)bne;
+
+        oldFolderId = mce.getOldFolderId();
+        oldItemId = mce.getOldItemId();
+        oldParentFolderId = mce.getOldParentFolderId();
+
+        return;
+      }
+
+      if (actionStr.equals("NewMailEvent")) {
+        action = ActionType.NewMailEvent;
+
+        return;
+      }
+    }
+
+    /** Common to all
+     *
+     * @return String
+     */
+    @Override
+    public String getWatermark() {
+      return watermark;
+    }
+
+    /**
+     * @return the action
+     */
+    public ActionType getAction() {
+      return action;
+    }
+
+    /** Gets the value of the oldFolderId property.
+     *
+     * @return FolderIdType
+     */
+    public FolderIdType getOldFolderId() {
+      return oldFolderId;
+    }
+
+    /** Gets the value of the oldItemId property.
+     *
+     * @return FolderIdType
+     */
+    public ItemIdType getOldItemId() {
+      return oldItemId;
+    }
+
+    /** Gets the value of the oldParentFolderId property.
+     *
+     * @return FolderIdType
+     */
+    public FolderIdType getOldParentFolderId() {
+      return oldParentFolderId;
+    }
+
+    /** Gets the value of the unreadCount property.
+     *
+     * @return Integer
+     */
+    public Integer getUnreadCount() {
+      return unreadCount;
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("NotificationItem{");
+
+      sb.append("watermark=");
+      sb.append(getWatermark());
+
+      sb.append(",\n      action=");
+      sb.append(getAction());
+
+      sb.append(", timeStamp=");
+      sb.append(getTimeStamp());
+
+      sb.append(",\n      folderId=");
+      sb.append(getFolderId());
+
+      sb.append(",\n      itemId=");
+      sb.append(getItemId());
+
+      sb.append(",\n      parentFolderId=");
+      sb.append(getParentFolderId());
+
+      if (getOldFolderId() != null) {
+        sb.append(",\n      oldFolderId=");
+        sb.append(getOldFolderId());
+      }
+
+      if (getOldItemId() != null) {
+        sb.append(",\n       oldItemId=");
+        sb.append(getOldItemId());
+      }
+
+      if (getOldParentFolderId() != null) {
+        sb.append(",\n       oldParentFolderId=");
+        sb.append(getOldParentFolderId());
+      }
+
+      if (getUnreadCount() != null) {
+        sb.append(",\n       unreadCount=");
+        sb.append(getUnreadCount());
+      }
+
+      sb.append("}");
+
+      return sb.toString();
+    }
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder("Notification{");
+
+    super.toStringSegment(sb);
+
+    sb.append(",\n   subscriptionId=");
+    sb.append(getSubscriptionId());
+
+    sb.append(",\n   previousWatermark=");
+    sb.append(getPreviousWatermark());
+
+    String delim = ",\n   notification items{\n      ";
+    for (NotificationItem ni: getNotifications()) {
+      sb.append(delim);
+      sb.append(ni.toString());
+
+      delim =",\n      ";
+    }
+
+    if (getNotifications().size() > 0) {
+      sb.append("}");
+    }
+
+    sb.append("}");
+
+    return sb.toString();
+  }
+}

Modified: trunk/server/src/org/bedework/exchgsynch/web/PostMethod.java
===================================================================
--- trunk/server/src/org/bedework/exchgsynch/web/PostMethod.java	2010-10-15 15:36:22 UTC (rev 21)
+++ trunk/server/src/org/bedework/exchgsynch/web/PostMethod.java	2010-10-15 15:49:57 UTC (rev 22)
@@ -27,8 +27,8 @@
 package org.bedework.exchgsynch.web;
 
 import org.bedework.exchgsynch.ExchangeSubscription;
-import org.bedework.exchgsynch.Notification;
 import org.bedework.exchgsynch.SynchException;
+import org.bedework.exchgsynch.responses.Notification;
 
 import org.w3c.dom.Document;
 



More information about the Bedework-commit mailing list