Skip to content

Commit 57b3d30

Browse files
author
pborissow
committed
- Refactored the ExtendedProperty class into the ExtendedFieldURI which extends the new FieldURI class.
- Updated the Folder.getItems() method to use the new FieldURI and ExtendedFieldURI classes to define additional properties. - Updated the EmailFolder class to retrieve MAPI properties representing the the last action associated with an message. git-svn-id: svn://192.168.0.80/JavaXT/javaxt-exchange@415 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 7ac7123 commit 57b3d30

13 files changed

+397
-157
lines changed

src/javaxt/exchange/CalendarEvent.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public CalendarEvent(String title, String description, String location, Mailbox
8484
//**************************************************************************
8585
/** Creates a new instance of this class with an id
8686
*/
87-
public CalendarEvent(String exchangeID, Connection conn, ExtendedProperty[] AdditionalProperties) throws ExchangeException{
87+
public CalendarEvent(String exchangeID, Connection conn, ExtendedFieldURI[] AdditionalProperties) throws ExchangeException{
8888
super(exchangeID, conn, AdditionalProperties);
8989
parseCalendarItem();
9090
}
@@ -745,10 +745,13 @@ private String create(Connection conn) throws ExchangeException {
745745

746746

747747
//Add extended properties
748-
ExtendedProperty[] properties = this.getExtendedProperties();
748+
java.util.HashMap<ExtendedFieldURI, javaxt.utils.Value> properties = this.getExtendedProperties();
749749
if (properties!=null){
750-
for (ExtendedProperty property : properties){
751-
msg.append(property.toXML("t", "create"));
750+
java.util.Iterator<ExtendedFieldURI> it = properties.keySet().iterator();
751+
while (it.hasNext()){
752+
ExtendedFieldURI property = it.next();
753+
javaxt.utils.Value value = properties.get(property);
754+
msg.append(property.toXML("t", "create", value));
752755
}
753756
}
754757

src/javaxt/exchange/CalendarFolder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class CalendarFolder extends Folder {
1212

13-
private java.util.ArrayList<String> props = new java.util.ArrayList<String>();
13+
private java.util.HashSet<FieldURI> props = new java.util.HashSet<FieldURI>();
1414

1515
//**************************************************************************
1616
//** Constructor
@@ -19,7 +19,7 @@ public class CalendarFolder extends Folder {
1919

2020
public CalendarFolder(Connection conn) throws ExchangeException {
2121
super("calendar", conn);
22-
props.add("calendar:TimeZone");
22+
props.add(new FieldURI("calendar:TimeZone"));
2323
}
2424

2525
/*

src/javaxt/exchange/Connection.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public String getUserName(){
3838
}
3939

4040

41+
//**************************************************************************
42+
//** createRequest
43+
//**************************************************************************
4144
protected javaxt.http.Request createRequest(){
4245
javaxt.http.Request request = new javaxt.http.Request(ews);
4346
request.validateSSLCertificates(true);
@@ -49,6 +52,9 @@ protected javaxt.http.Request createRequest(){
4952
}
5053

5154

55+
//**************************************************************************
56+
//** getResponse
57+
//**************************************************************************
5258
protected Object getResponse(javaxt.http.Request request, boolean parseResponse) throws ExchangeException {
5359
javaxt.http.Response response = request.getResponse();
5460
int status = response.getStatus();

src/javaxt/exchange/Contact.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Contact(javaxt.exchange.Contact contact){
104104
//**************************************************************************
105105
/** Creates a new instance of this class
106106
*/
107-
public Contact(String exchangeID, Connection conn, ExtendedProperty[] AdditionalProperties) throws ExchangeException{
107+
public Contact(String exchangeID, Connection conn, ExtendedFieldURI[] AdditionalProperties) throws ExchangeException{
108108
super(exchangeID, conn, AdditionalProperties);
109109
parseContact();
110110
}
@@ -1096,10 +1096,13 @@ private void create(Connection conn) throws ExchangeException {
10961096

10971097

10981098
//Add extended properties
1099-
ExtendedProperty[] properties = this.getExtendedProperties();
1099+
java.util.HashMap<ExtendedFieldURI, javaxt.utils.Value> properties = this.getExtendedProperties();
11001100
if (properties!=null){
1101-
for (ExtendedProperty property : properties){
1102-
msg.append(property.toXML("t", "create"));
1101+
java.util.Iterator<ExtendedFieldURI> it = properties.keySet().iterator();
1102+
while (it.hasNext()){
1103+
ExtendedFieldURI property = it.next();
1104+
javaxt.utils.Value value = properties.get(property);
1105+
msg.append(property.toXML("t", "create", value));
11031106
}
11041107
}
11051108

src/javaxt/exchange/Email.java

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212
public class Email extends FolderItem {
1313

1414
private Mailbox from;
15+
private java.util.HashSet<Mailbox> ToRecipients = new java.util.HashSet<Mailbox>();
16+
private java.util.HashSet<Mailbox> CcRecipients = new java.util.HashSet<Mailbox>();
17+
private java.util.HashSet<Mailbox> BccRecipients = new java.util.HashSet<Mailbox>();
18+
1519
private String importance = "Normal";
1620
private String sensitivity = "Normal";
1721
private Integer size;
1822
private boolean isRead = false;
19-
private java.util.HashSet<Mailbox> ToRecipients = new java.util.HashSet<Mailbox>();
20-
private java.util.HashSet<Mailbox> CcRecipients = new java.util.HashSet<Mailbox>();
21-
private java.util.HashSet<Mailbox> BccRecipients = new java.util.HashSet<Mailbox>();
23+
private javaxt.utils.Date sent;
24+
private javaxt.utils.Date received;
25+
private String response;
26+
private javaxt.utils.Date responseDate;
27+
28+
//The following parameters are for internal use only!
2229
private String referenceId;
2330
private String messageType = "Message";
2431

@@ -59,13 +66,17 @@ private void init(javaxt.exchange.Email message){
5966

6067
//Email specific information
6168
this.from = message.from;
69+
this.ToRecipients = message.ToRecipients;
70+
this.CcRecipients = message.CcRecipients;
71+
this.BccRecipients = message.BccRecipients;
6272
this.importance = message.importance;
6373
this.sensitivity = message.sensitivity;
6474
this.size = message.size;
6575
this.isRead = message.isRead;
66-
this.ToRecipients = message.ToRecipients;
67-
this.CcRecipients = message.CcRecipients;
68-
this.BccRecipients = message.BccRecipients;
76+
this.sent = message.sent;
77+
this.received = message.received;
78+
this.response = message.response;
79+
this.responseDate = message.responseDate;
6980
this.referenceId = message.referenceId;
7081
this.messageType = message.messageType;
7182
}
@@ -88,7 +99,7 @@ protected Email(org.w3c.dom.Node messageNode) {
8899
//**************************************************************************
89100
/** Creates a new instance of this class
90101
*/
91-
public Email(String exchangeID, Connection conn, ExtendedProperty[] AdditionalProperties) throws ExchangeException{
102+
public Email(String exchangeID, Connection conn, ExtendedFieldURI[] AdditionalProperties) throws ExchangeException{
92103
super(exchangeID, conn, AdditionalProperties);
93104
parseMessage();
94105
}
@@ -110,6 +121,9 @@ public Email(String exchangeID, Connection conn) throws ExchangeException{
110121
/** Used to parse an xml node with email information.
111122
*/
112123
private void parseMessage(){
124+
125+
boolean isDraft = false;
126+
113127
org.w3c.dom.NodeList outerNodes = this.getChildNodes();
114128
for (int i=0; i<outerNodes.getLength(); i++){
115129
org.w3c.dom.Node outerNode = outerNodes.item(i);
@@ -169,6 +183,51 @@ else if(nodeName.equalsIgnoreCase("BccRecipients")){
169183
else if(nodeName.equalsIgnoreCase("IsRead")){
170184
isRead = javaxt.xml.DOM.getNodeValue(outerNode).equalsIgnoreCase("true");
171185
}
186+
else if(nodeName.equalsIgnoreCase("IsDraft")){
187+
isDraft = javaxt.xml.DOM.getNodeValue(outerNode).equalsIgnoreCase("true");
188+
}
189+
else if(nodeName.equalsIgnoreCase("DateTimeSent")){
190+
try{
191+
sent = new javaxt.utils.Date(javaxt.xml.DOM.getNodeValue(outerNode));
192+
}
193+
catch(java.text.ParseException e){}
194+
}
195+
else if(nodeName.equalsIgnoreCase("DateTimeReceived")){
196+
try{
197+
received = new javaxt.utils.Date(javaxt.xml.DOM.getNodeValue(outerNode));
198+
}
199+
catch(java.text.ParseException e){}
200+
}
201+
}
202+
}
203+
204+
//Update the sent and received timestamps as needed
205+
if (isDraft) sent = received = null;
206+
207+
208+
//Find the PR_LAST_VERB_EXECUTED (0x10810003) extended MAPI property
209+
java.util.Iterator<ExtendedFieldURI> it = extendedProperties.keySet().iterator();
210+
while(it.hasNext()){
211+
ExtendedFieldURI property = it.next();
212+
if (property.getName().equalsIgnoreCase("0x1081")){
213+
Integer value = extendedProperties.get(property).toInteger();
214+
if (value==102) this.response = "Reply";
215+
else if(value == 103) this.response = "ReplyAll";
216+
else if(value == 104) this.response = "Forward";
217+
extendedProperties.remove(property);
218+
break;
219+
}
220+
}
221+
222+
223+
//Find the PR_LAST_VERB_EXECUTION_TIME (0x10820040) extended MAPI property
224+
it = extendedProperties.keySet().iterator();
225+
while(it.hasNext()){
226+
ExtendedFieldURI property = it.next();
227+
if (property.getName().equalsIgnoreCase("0x1082")){
228+
responseDate = extendedProperties.get(property).toDate();
229+
extendedProperties.remove(property);
230+
break;
172231
}
173232
}
174233
}
@@ -304,19 +363,25 @@ public Mailbox getFrom(){
304363

305364

306365
//**************************************************************************
307-
//** setFrom
366+
//** getDateTimeReceived
308367
//**************************************************************************
309-
/** Used to set the sender.
310-
*
311-
public void setFrom(Mailbox from){
368+
/** Returns the date/time when the message was received. Returns a null if
369+
* the message is a draft.
370+
*/
371+
public javaxt.utils.Date getDateTimeReceived(){
372+
return received;
373+
}
312374

313-
if (id!=null) {
314-
if (from==null && this.from!=null) updates.put("From", null);
315-
if (from!=null && !from.equals(this.from)) updates.put("From", from.toXML("t"));
316-
}
317-
this.from = from;
375+
376+
//**************************************************************************
377+
//** getDateTimeSent
378+
//**************************************************************************
379+
/** Returns the date/time when the message was sent. Returns a null if
380+
* the message has not been sent (e.g. Draft message).
381+
*/
382+
public javaxt.utils.Date getDateTimeSent(){
383+
return sent;
318384
}
319-
*/
320385

321386

322387
//**************************************************************************
@@ -329,6 +394,30 @@ public Integer getSize(){
329394
}
330395

331396

397+
//**************************************************************************
398+
//** getResponse
399+
//**************************************************************************
400+
/** Returns the last action performed on this message. Possible values
401+
* include "Forward", "Reply", "ReplyAll", or null.
402+
*/
403+
public String getResponse(){
404+
return response;
405+
}
406+
407+
408+
//**************************************************************************
409+
//** getResponseDate
410+
//**************************************************************************
411+
/** Returns the date/time associated with the last action performed on this
412+
* message. This, in conjunction with the getResponse() method can be used
413+
* to generate messages like "You replied on 12/13/2012 5:38 PM." or
414+
* "You forwarded this message on 12/13/2012 6:01 PM."
415+
*/
416+
public javaxt.utils.Date getResponseDate(){
417+
return responseDate;
418+
}
419+
420+
332421
//**************************************************************************
333422
//** isRead
334423
//**************************************************************************

src/javaxt/exchange/EmailAddress.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
//** EmailAddress Class
66
//******************************************************************************
77
/**
8-
* Used to represent an email address. Includes email validation from mkyong:
9-
* http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
8+
* Used to represent an email address.
109
*
1110
******************************************************************************/
1211

1312
public class EmailAddress {
1413

15-
private String emailAddress;
14+
15+
/** Email validation from mkyong:
16+
* http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
17+
*/
1618
private static final Pattern pattern = Pattern.compile(
1719
//"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"
1820
"^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"
1921
);
2022

23+
private String emailAddress;
24+
2125
//**************************************************************************
2226
//** Constructor
2327
//**************************************************************************
@@ -50,7 +54,7 @@ public String toString(){
5054

5155

5256
public int hashCode(){
53-
return emailAddress.toLowerCase().hashCode();
57+
return emailAddress.hashCode();
5458
}
5559

5660
//**************************************************************************

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy