Skip to content

Commit 8e6bae5

Browse files
author
pborissow
committed
- Added line to validate SSL certificates when connecting to Exchange
- Added ability to delete emails - Added ability to move and rename folders git-svn-id: svn://192.168.0.80/JavaXT/javaxt-exchange@400 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 3595627 commit 8e6bae5

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

src/javaxt/exchange/Connection.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010

1111
public class Connection {
1212

13-
1413
private String username;
1514
private String password;
1615
private String ews;
1716

18-
1917
//**************************************************************************
2018
//** Constructor
2119
//**************************************************************************
@@ -50,6 +48,7 @@ public String getUserName(){
5048
public org.w3c.dom.Document execute(String soap) throws ExchangeException {
5149

5250
javaxt.http.Request request = new javaxt.http.Request(ews);
51+
request.validateSSLCertificates(true);
5352
request.setCredentials(username, password);
5453
request.setHeader("Accept", "*/*");
5554
request.setHeader("Content-Type", "text/xml");

src/javaxt/exchange/Email.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,19 @@ public void setIsRead(boolean isRead){
316316
public boolean hasAttachments(){
317317
return hasAttachments;
318318
}
319+
320+
321+
//**************************************************************************
322+
//** delete
323+
//**************************************************************************
324+
/** Used to delete a message.
325+
* @param MoveToDeletedItems If true, moves the item to the deleted items
326+
* folder. If false, permanently deletes the message.
327+
*/
328+
public void delete(boolean MoveToDeletedItems, Connection conn) throws ExchangeException {
329+
java.util.HashMap<String, String> options = new java.util.HashMap<String, String>();
330+
if (MoveToDeletedItems) options.put("DeleteType", "MoveToDeletedItems");
331+
else options.put("DeleteType", "HardDelete");
332+
super.delete(options, conn);
333+
}
319334
}

src/javaxt/exchange/Folder.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,58 @@ public Folder createFolder(String name) throws ExchangeException {
142142
}
143143

144144

145+
//**************************************************************************
146+
//** rename
147+
//**************************************************************************
148+
/** Used to rename this folder.
149+
*/
150+
public void rename(String name) throws ExchangeException {
151+
changeKey = getChangeKey(conn);
152+
name = name.trim();
153+
String msg =
154+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
155+
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
156+
+ "<soap:Body>"
157+
+ "<UpdateFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
158+
+ "<FolderChanges>"
159+
+ "<t:FolderChange>"
160+
+ "<t:FolderId Id=\"" + id + "\" ChangeKey=\"" + changeKey + "\"/>"
161+
+ "<t:Updates>"
162+
+ "<t:SetFolderField>"
163+
+ "<t:FieldURI FieldURI=\"folder:DisplayName\" />"
164+
+ "<t:Folder><t:DisplayName>" + name + "</t:DisplayName></t:Folder>"
165+
+ "</t:SetFolderField>"
166+
+ "</t:Updates>"
167+
+ "</t:FolderChange>"
168+
+ "</FolderChanges>"
169+
+ "</UpdateFolder>"
170+
+ "</soap:Body>"
171+
+ "</soap:Envelope>";
172+
conn.execute(msg);
173+
this.name = name;
174+
}
175+
176+
177+
//**************************************************************************
178+
//** move
179+
//**************************************************************************
180+
/** Used to move this folder to another folder.
181+
*/
182+
public void move(Folder destination) throws ExchangeException {
183+
String msg =
184+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
185+
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
186+
+ "<soap:Body>"
187+
+ "<MoveFolder xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">"
188+
+ "<ToFolderId><t:FolderId Id=\"" + destination.id + "\"/></ToFolderId>"
189+
+ "<FolderIds><t:FolderId Id=\"" + id + "\"/></FolderIds>"
190+
+ "</MoveFolder>"
191+
+ "</soap:Body>"
192+
+ "</soap:Envelope>";
193+
conn.execute(msg);
194+
}
195+
196+
145197
//**************************************************************************
146198
//** delete
147199
//**************************************************************************
@@ -161,6 +213,16 @@ public void delete() throws ExchangeException {
161213
}
162214

163215

216+
//**************************************************************************
217+
//** getChangeKey
218+
//**************************************************************************
219+
/** Used to retrieve the latest ChangeKey for this folder. This method is
220+
* required to update an item.
221+
*/
222+
protected String getChangeKey(Connection conn) throws ExchangeException {
223+
changeKey = new Folder(id, conn).changeKey;
224+
return changeKey;
225+
}
164226

165227
private void parseXML(org.w3c.dom.Document xml) throws ExchangeException {
166228
org.w3c.dom.Node[] nodes = javaxt.xml.DOM.getElementsByTagName("FolderId", xml);

src/javaxt/exchange/FolderItem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public void setLastModifiedTime(javaxt.utils.Date lastModified){
296296
//**************************************************************************
297297
//** getChangeKey
298298
//**************************************************************************
299-
/** Used to retrieve the ChangeKey for this contact. Note that the ChangeKey
299+
/** Used to retrieve the ChangeKey for this item. Note that the ChangeKey
300300
* is set in the constructor and may not reflect the most recent value.
301301
*/
302302
public String getChangeKey(){
@@ -307,7 +307,7 @@ public String getChangeKey(){
307307
//**************************************************************************
308308
//** getChangeKey
309309
//**************************************************************************
310-
/** Used to retrieve the latest ChangeKey for this contact. This method is
310+
/** Used to retrieve the latest ChangeKey for this item. This method is
311311
* required to update an item.
312312
*/
313313
protected String getChangeKey(Connection conn) throws ExchangeException {

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