Novell iChain workaround

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1485 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-09-30 23:18:24 +00:00
parent a90a39becd
commit 90c983d626
8 changed files with 491 additions and 51 deletions

View File

@ -33,6 +33,7 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.util.IdleConnectionTimeoutThread;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
@ -234,6 +235,8 @@ public final class DavGatewayHttpClientFacade {
testMethod.setDoAuthentication(false);
try {
status = httpClient.executeMethod(testMethod);
} catch (IOException e) {
LOGGER.warn(e.getMessage(), e);
} finally {
testMethod.releaseConnection();
}
@ -294,8 +297,13 @@ public final class DavGatewayHttpClientFacade {
while (redirectCount++ < 10
&& location != null
&& isRedirect(status)) {
// Novell iChain workaround
String locationValue = location.getValue();
if (locationValue.indexOf('"') >= 0) {
locationValue = URIUtil.encodePath(locationValue);
}
currentMethod.releaseConnection();
currentMethod = new GetMethod(location.getValue());
currentMethod = new GetMethod(locationValue);
currentMethod.setFollowRedirects(false);
DavGatewayTray.debug(new BundleMessage("LOG_EXECUTE_FOLLOW_REDIRECTS_COUNT", currentMethod.getURI(), redirectCount));
httpClient.executeMethod(currentMethod);

View File

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway - iPhone Mail setup</title>
<author email="mguessan@free.fr">Mickael Guessant</author>
</properties>
<body>
<section name="iPhone Mail setup">
<p>Note: you can't install DavMail directly on an iPhone, you need a separate DavMail server,
see <a href="iphonesetup.html">iPhone setup</a>.
</p>
<subsection name="Create a new account">
<p>Open iPhone Settings application and choose Mail, Contacts, Calendar:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneAccount1.png" alt=""/>
</div>
<p>Then select Add Account...:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneAccount2.png" alt=""/>
</div>
<p>DavMail is not an Exchange ActiveSync server, press Other:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneAccount3.png" alt=""/>
</div>
<p>Choose Add Mail Account:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail01.png" alt=""/>
</div>
<p>Enter your name, email address and password, then press Next:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail02.png" alt=""/>
</div>
<p>Select IMAP account type:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail03.png" alt=""/>
</div>
<p>In Incoming Mail Server section, enter your DavMail server hostname,
append ':' and port if DavMail IMAP port is not 143:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail04.png" alt=""/>
</div>
<p>In Outgoing Mail Server section, enter your DavMail server hostname,
append ':' and port if DavMail SMTP port is not 25, then press Next:
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail05.png" alt=""/>
</div>
<p>TODO
</p>
<div style="width: 100%;text-align: center">
<img src="images/iphone/iphoneMail07.png" alt=""/>
</div>
</subsection>
</section>
</body>
</document>

View File

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<document xmlns="http://maven.apache.org/XDOC/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
<properties>
<title>DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange Gateway - iPhone setup</title>
<author email="mguessan@free.fr">Mickael Guessant</author>
</properties>
<body>
<section name="iPhone setup">
<p>In order to use DavMail with an iPhone, you need to install DavMail in server mode.
This server should be available directly on the internet or through a Wifi connection.
See <a href="serversetup.html">Server setup</a> for more information.
</p>
<p>Once you have a working DavMail server, proceed to:
<a href="iphonemailsetup.html">iPhone Mail setup</a>
</p>
</section>
</body>
</document>

View File

@ -33,6 +33,7 @@ import org.apache.jackrabbit.webdav.DavException;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
@ -265,4 +266,41 @@ public class TestCaldav extends AbstractDavMailTestCase {
assertEquals(1, responses.length);
}
public void testRenameCalendar() throws IOException {
String folderName = "testcalendarfolder";
String encodedFolderpath = URIUtil.encodePath("/users/" + session.getEmail() + "/calendar/" + folderName + '/');
// first delete calendar
session.deleteFolder("calendar/" + folderName);
String body =
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
" <C:mkcalendar xmlns:D=\"DAV:\"\n" +
" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\n" +
" <D:set>\n" +
" <D:prop>\n" +
" <D:displayname>" + StringUtil.xmlEncode(folderName) + "</D:displayname>\n" +
" <C:calendar-description xml:lang=\"en\">Calendar description</C:calendar-description>\n" +
" <C:supported-calendar-component-set>\n" +
" <C:comp name=\"VEVENT\"/>\n" +
" </C:supported-calendar-component-set>\n" +
" </D:prop>\n" +
" </D:set>\n" +
" </C:mkcalendar>";
SearchReportMethod method = new SearchReportMethod(encodedFolderpath, body) {
@Override
public String getName() {
return "MKCALENDAR";
}
};
httpClient.executeMethod(method);
assertEquals(HttpStatus.SC_CREATED, method.getStatusCode());
MoveMethod moveMethod = new MoveMethod(encodedFolderpath, "http://localhost:" + Settings.getProperty("davmail.caldavPort")+"/users/" + session.getEmail() + "/movedcalendarfolder", true);
httpClient.executeMethod(moveMethod);
}
public void testRenameMainCalendar() throws IOException {
MoveMethod moveMethod = new MoveMethod("/users/" + session.getEmail() + "/Calendrierzzz", "http://localhost:" + Settings.getProperty("davmail.caldavPort")+"/users/" + session.getEmail() + "/Calendrier", true);
httpClient.executeMethod(moveMethod);
}
}

View File

@ -39,59 +39,59 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
}
public void testDumpVtimezones() throws IOException {
Properties properties = new Properties() {
@Override
public synchronized Enumeration<Object> keys() {
Enumeration keysEnumeration = super.keys();
TreeSet<String> sortedKeySet = new TreeSet<String>();
while (keysEnumeration.hasMoreElements()) {
sortedKeySet.add((String) keysEnumeration.nextElement());
}
final Iterator<String> sortedKeysIterator = sortedKeySet.iterator();
return new Enumeration<Object>() {
Properties properties = new Properties() {
@Override
public synchronized Enumeration<Object> keys() {
Enumeration keysEnumeration = super.keys();
TreeSet<String> sortedKeySet = new TreeSet<String>();
while (keysEnumeration.hasMoreElements()) {
sortedKeySet.add((String) keysEnumeration.nextElement());
}
final Iterator<String> sortedKeysIterator = sortedKeySet.iterator();
return new Enumeration<Object>() {
public boolean hasMoreElements() {
return sortedKeysIterator.hasNext();
}
public boolean hasMoreElements() {
return sortedKeysIterator.hasNext();
}
public Object nextElement() {
return sortedKeysIterator.next();
}
};
}
public Object nextElement() {
return sortedKeysIterator.next();
}
};
}
};
for (int i = 1; i < 100; i++) {
Settings.setProperty("davmail.timezoneId", String.valueOf(i));
VObject timezone = session.getVTimezone();
if (timezone.getProperty("TZID") != null) {
properties.put(timezone.getPropertyValue("TZID").replaceAll("\\\\", ""), String.valueOf(i));
System.out.println(timezone.getPropertyValue("TZID") + '=' + i);
}
session.vTimezone = null;
}
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream("timezoneids.properties");
properties.store(fileOutputStream, "Timezone ids");
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// ignore
}
}
}
}
};
for (int i = 1; i < 100; i++) {
Settings.setProperty("davmail.timezoneId", String.valueOf(i));
VObject timezone = session.getVTimezone();
if (timezone.getProperty("TZID") != null) {
properties.put(timezone.getPropertyValue("TZID").replaceAll("\\\\", ""), String.valueOf(i));
System.out.println(timezone.getPropertyValue("TZID") + '=' + i);
}
session.vTimezone = null;
}
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream("timezoneids.properties");
properties.store(fileOutputStream, "Timezone ids");
} finally {
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// ignore
}
}
}
}
public void testSearchCalendar() throws IOException {
List<ExchangeSession.Event> events = null;
try {
events = session.getAllEvents("/users/" + session.getEmail() + "/calendar");
for (ExchangeSession.Event event:events) {
System.out.println(event.getBody());
}
for (ExchangeSession.Event event : events) {
System.out.println(event.getBody());
}
} catch (IOException e) {
System.out.println(e.getMessage());
throw e;
@ -119,12 +119,61 @@ public class TestExchangeSessionCalendar extends AbstractExchangeSessionTestCase
fbdata = session.getFreeBusyData(Settings.getProperty("davmail.to"), formatter.format(startDate),
formatter.format(endDate), 60);
assertNotNull(fbdata);
// unknown user data
// unknown user data
fbdata = session.getFreeBusyData("unknown@company.org", formatter.format(startDate),
formatter.format(endDate), 60);
assertNull(fbdata);
}
public void testCreateEvent() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:Pacific Time (US & Canada)\\; Tijuana\n" +
"BEGIN:STANDARD\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0700\n" +
"TZOFFSETTO:-0800\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0800\n" +
"TZOFFSETTO:-0700\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\n" +
"END:DAYLIGHT\n" +
"END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" +
"CREATED:20100829T204658Z\n" +
"LAST-MODIFIED:20100829T204829Z\n" +
"DTSTAMP:20100829T204829Z\n" +
"UID:701b9d8f-ab64-4a7c-a75d-251cc8687cd9\n" +
"SUMMARY:testzz\n" +
"DTSTART;TZID=\"Pacific Time (US & Canada); Tijuana\":20100830T230000\n" +
"DTEND;TZID=\"Pacific Time (US & Canada); Tijuana\":20100831T000000\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n" +
"TRANSP:OPAQUE\n" +
"X-MOZ-GENERATION:1\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String itemName = UUID.randomUUID().toString() + ".EML";
session.createOrUpdateItem("calendar", itemName, itemBody, null, null);
}
public void testGetEvent() throws IOException {
ExchangeSession.Item item = session.getItem("calendar", "19083675-f8ce-4d81-8ac8-096fa0bd0e13.EML");
item.getBody();
}
public void testGetInbox() throws IOException {
List<ExchangeSession.Event> items = session.getEventMessages("INBOX");
for (ExchangeSession.Item item : items) {
System.out.println(item.getBody());
}
}
}

View File

@ -71,8 +71,8 @@ public class TestExchangeSessionContact extends AbstractExchangeSessionTestCase
vCardWriter.appendProperty("ADR;TYPE=other", "otherpostofficebox", null, "otherstreet", "othercity", "otherstate", "otherpostalcode", "othercountry");
vCardWriter.appendProperty("EMAIL;TYPE=work", "email1@local.net");
vCardWriter.appendProperty("EMAIL;TYPE=home", "email2@local.net");
vCardWriter.appendProperty("EMAIL;TYPE=other", "email3@local.net");
//vCardWriter.appendProperty("EMAIL;TYPE=home", "email2@local.net");
//vCardWriter.appendProperty("EMAIL;TYPE=other", "email3@local.net");
vCardWriter.appendProperty("ORG", "o", "department");

View File

@ -273,7 +273,7 @@ public class TestExchangeSessionEvent extends TestCase {
vCalendar.fixVCalendar(false);
String status = vCalendar.getAttendeeStatus();
assertEquals("ACCEPTED", status);
System.out.println("'"+BundleMessage.format(status)+"'");
System.out.println("'" + BundleMessage.format(status) + "'");
}
public void testMissingTzid() throws IOException {
@ -288,4 +288,209 @@ public class TestExchangeSessionEvent extends TestCase {
assertTrue(toServer.contains("DTSTART;TZID="));
assertTrue(toServer.contains("DTEND;TZID="));
}
public void testBroken() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" +
"METHOD:REQUEST\n" +
"PRODID:Microsoft CDO for Microsoft Exchange\n" +
"VERSION:2.0\n" +
"BEGIN:VTIMEZONE\n" +
"TZID:GMT -0500 (Standard) / GMT -0400 (Daylight)\n" +
"BEGIN:STANDARD\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0400\n" +
"TZOFFSETTO:-0500\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=11;BYDAY=1SU\n" +
"END:STANDARD\n" +
"BEGIN:DAYLIGHT\n" +
"DTSTART:16010101T020000\n" +
"TZOFFSETFROM:-0500\n" +
"TZOFFSETTO:-0400\n" +
"RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=2SU\n" +
"END:DAYLIGHT\n" +
"END:VTIMEZONE\n" +
"BEGIN:VEVENT\n" +
"DTSTAMP:20091109T160328Z\n" +
"DTSTART;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20090831T140000\n" +
"SUMMARY:Canceled: LIMS on Demand Check In\n" +
"UID:040000008200E00074C5B7101A82E0080000000040FBD1416E21CA01000000000000000\n" +
" 010000000E6ECF22DE22C3141B0F14F2A61B150AD\n" +
"ORGANIZER;CN=\"Najjar, Susan M.\":MAILTO:susan.najjar@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Shah, Kim\n" +
" \":MAILTO:kim.shah@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Mac Conao\n" +
" naigh, Seamus\":MAILTO:seamus.macconaonaigh@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Holbrook,\n" +
" Doug\":MAILTO:doug.holbrook@thermo.com\n" +
"LOCATION:USBIL-Water\n" +
"DTEND;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20090831T150000\n" +
"RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=MO;WKST=SU\n" +
"EXDATE;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20091026T140000\n" +
"DESCRIPTION:When: Occurs every 2 weeks on Monday effective 8/31/2009 from 2\n" +
" :00 PM to 3:00 PM (GMT-05:00) Eastern Time (US & Canada).\\NWhere: USBIL-Wa\n" +
" ter\\N\\NNote: The GMT offset above does not reflect daylight saving time ad\n" +
" justments.\\N\\N*~*~*~*~*~*~*~*~*~*\\N\\NAll\\,\\N\\NLets do a check in every \n" +
" two weeks to talk about LIMS on Demand. Please feel free to add to the ag\n" +
" enda. I scheduled an hour but dont anticipate it to go that long unles\n" +
" s we have something to review in detail.\\N\\NProposed Agenda\\N-\tBeta update\n" +
" \\N-\tAutodemo review\\N-\tIT whitepaper update\\N-\tCloud picture update\\N\t\t\\N\t\n" +
" \t 1 205 263 0808\\N\t\t 1 877 897 0005\\N\t\t \\N\t\t \\N2.\tIf prompted\\, en\n" +
" ter the Meeting Number: * 3843152 * \\N\t\t(Be sure to enter the * star key \n" +
" before and after the Meeting Number)\\N\\N3.\tIf you are the Moderator\\, ente\n" +
" r your *PIN* \\N\t\t(Be sure to enter the * star key before and after your P\n" +
" IN)\\N\\N24x7 Technical Support <http://www.genesys.com/support/index.html> \n" +
" \\N\\N\\N\\N\\N\\N\\N\\N\n" +
"SEQUENCE:2\n" +
"PRIORITY:1\n" +
"CLASS:\n" +
"CREATED:20090820T121655Z\n" +
"LAST-MODIFIED:20100701T143032Z\n" +
"STATUS:CANCELLED\n" +
"TRANSP:OPAQUE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:FREE\n" +
"X-MICROSOFT-CDO-INSTTYPE:1\n" +
"X-MICROSOFT-CDO-REPLYTIME:16010101T000000Z\n" +
"X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-IMPORTANCE:2\n" +
"X-MICROSOFT-CDO-OWNERAPPTID:-1508603943\n" +
"X-MICROSOFT-CDO-APPT-SEQUENCE:2\n" +
"X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20091109T160328Z\n" +
"X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20091109T160328Z\n" +
"BEGIN:VALARM\n" +
"ACTION:DISPLAY\n" +
"DESCRIPTION:REMINDER\n" +
"TRIGGER;RELATED=START:-PT00H15M00S\n" +
"END:VALARM\n" +
"END:VEVENT\n" +
"BEGIN:VEVENT\n" +
"X-MICROSOFT-CDO-MODPROPS:attendee,BEGIN,class,description,dtend,dtstamp,dts\n" +
" tart,END,organizer,priority,recurrence-id,status,x-microsoft-cdo-attendee-\n" +
" critical-change,x-microsoft-cdo-busystatus,x-microsoft-cdo-importance,x-mi\n" +
" crosoft-cdo-insttype,x-microsoft-cdo-owner-critical-change,x-microsoft-cdo\n" +
" -ownerapptid\n" +
"DTSTAMP:20091109T160337Z\n" +
"DTSTART;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20091109T140000\n" +
"SUMMARY:Canceled: LIMS on Demand Check In\n" +
"UID:040000008200E00074C5B7101A82E0080000000040FBD1416E21CA01000000000000000\n" +
" 010000000E6ECF22DE22C3141B0F14F2A61B150AD\n" +
"ORGANIZER;CN=\"Najjar, Susan M.\":MAILTO:susan.najjar@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Shah, Kim\n" +
" \":MAILTO:kim.shah@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Mac Conao\n" +
" naigh, Seamus\":MAILTO:seamus.macconaonaigh@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Holbrook,\n" +
" Doug\":MAILTO:doug.holbrook@thermo.com\n" +
"LOCATION:USBIL-Water\n" +
"DTEND;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20091109T150000\n" +
"DESCRIPTION:When: Monday\\, November 09\\, 2009 2:00 PM-3:00 PM (GMT-05:00) E\n" +
" astern Time (US & Canada).\\NWhere: USBIL-Water\\N\\NNote: The GMT offset abo\n" +
" ve does not reflect daylight saving time adjustments.\\N\\N*~*~*~*~*~*~*~*~*\n" +
" ~*\\N\\NAll\\,\\N\\NLets do a check in every two weeks to talk about LIMS on\n" +
" Demand. Please feel free to add to the agenda. I scheduled an hour but \n" +
" dont anticipate it to go that long unless we have something to review i\n" +
" n detail.\\N\\NProposed Agenda\\N-\tBeta update\\N-\tAutodemo review\\N-\tIT white\n" +
" paper update\\N-\tCloud picture update\\N\t\t\\N\t\t 1 205 263 0808\\N\t\t 1 877 \n" +
" 897 0005\\N\t\t \\N\t\t \\N2.\tIf prompted\\, enter the Meeting Number: * 38431\n" +
" 52 * \\N\t\t(Be sure to enter the * star key before and after the Meeting Nu\n" +
" mber)\\N\\N3.\tIf you are the Moderator\\, enter your *PIN* \\N\t\t(Be sure to e\n" +
" nter the * star key before and after your PIN)\\N\\N24x7 Technical Support <\n" +
" http://www.genesys.com/support/index.html> \\N\\N\\N\\N\\N\\N\\N\\N\n" +
"RECURRENCE-ID;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20091109T1\n" +
" 40000\n" +
"SEQUENCE:2\n" +
"PRIORITY:1\n" +
"CLASS:\n" +
"CREATED:20090820T121655Z\n" +
"LAST-MODIFIED:20100701T143032Z\n" +
"STATUS:CANCELLED\n" +
"TRANSP:OPAQUE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:FREE\n" +
"X-MICROSOFT-CDO-INSTTYPE:3\n" +
"X-MICROSOFT-CDO-REPLYTIME:16010101T000000Z\n" +
"X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-IMPORTANCE:2\n" +
"X-MICROSOFT-CDO-OWNERAPPTID:-1508603943\n" +
"X-MICROSOFT-CDO-APPT-SEQUENCE:2\n" +
"X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20091109T160336Z\n" +
"X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20091109T160337Z\n" +
"END:VEVENT\n" +
"BEGIN:VEVENT\n" +
"X-MICROSOFT-CDO-MODPROPS:BEGIN,dtend,dtstamp,dtstart,END,recurrence-id,x-mi\n" +
" crosoft-cdo-insttype\n" +
"DTSTAMP:20091109T160328Z\n" +
"DTSTART;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20090831T140000\n" +
"SUMMARY:Canceled: LIMS on Demand Check In\n" +
"UID:040000008200E00074C5B7101A82E0080000000040FBD1416E21CA01000000000000000\n" +
" 010000000E6ECF22DE22C3141B0F14F2A61B150AD\n" +
"ORGANIZER;CN=\"Najjar, Susan M.\":MAILTO:susan.najjar@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Shah, Kim\n" +
" \":MAILTO:kim.shah@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Mac Conao\n" +
" naigh, Seamus\":MAILTO:seamus.macconaonaigh@thermo.com\n" +
"ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Holbrook,\n" +
" Doug\":MAILTO:doug.holbrook@thermo.com\n" +
"LOCATION:USBIL-Water\n" +
"DTEND;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20090831T150000\n" +
"DESCRIPTION:When: Occurs every 2 weeks on Monday effective 8/31/2009 from 2\n" +
" :00 PM to 3:00 PM (GMT-05:00) Eastern Time (US & Canada).\\NWhere: USBIL-Wa\n" +
" ter\\N\\NNote: The GMT offset above does not reflect daylight saving time ad\n" +
" justments.\\N\\N*~*~*~*~*~*~*~*~*~*\\N\\NAll\\,\\N\\NLets do a check in every \n" +
" two weeks to talk about LIMS on Demand. Please feel free to add to the ag\n" +
" enda. I scheduled an hour but dont anticipate it to go that long unles\n" +
" s we have something to review in detail.\\N\\NProposed Agenda\\N-\tBeta update\n" +
" \\N-\tAutodemo review\\N-\tIT whitepaper update\\N-\tCloud picture update\\N\t\t\\N\t\n" +
" \t 1 205 263 0808\\N\t\t 1 877 897 0005\\N\t\t \\N\t\t \\N2.\tIf prompted\\, en\n" +
" ter the Meeting Number: * 3843152 * \\N\t\t(Be sure to enter the * star key \n" +
" before and after the Meeting Number)\\N\\N3.\tIf you are the Moderator\\, ente\n" +
" r your *PIN* \\N\t\t(Be sure to enter the * star key before and after your P\n" +
" IN)\\N\\N24x7 Technical Support <http://www.genesys.com/support/index.html> \n" +
" \\N\\N\\N\\N\\N\\N\\N\\N\n" +
"RECURRENCE-ID;TZID=\"GMT -0500 (Standard) / GMT -0400 (Daylight)\":20090831T1\n" +
" 40000\n" +
"SEQUENCE:2\n" +
"PRIORITY:1\n" +
"CLASS:\n" +
"CREATED:20090820T121655Z\n" +
"LAST-MODIFIED:20100701T143032Z\n" +
"STATUS:CANCELLED\n" +
"TRANSP:OPAQUE\n" +
"X-MICROSOFT-CDO-BUSYSTATUS:FREE\n" +
"X-MICROSOFT-CDO-INSTTYPE:3\n" +
"X-MICROSOFT-CDO-REPLYTIME:16010101T000000Z\n" +
"X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\n" +
"X-MICROSOFT-CDO-ALLDAYEVENT:FALSE\n" +
"X-MICROSOFT-CDO-IMPORTANCE:2\n" +
"X-MICROSOFT-CDO-OWNERAPPTID:-1508603943\n" +
"X-MICROSOFT-CDO-APPT-SEQUENCE:2\n" +
"X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20091109T160328Z\n" +
"X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20091109T160328Z\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String toClient = fixICS(itemBody, true);
System.out.println(toClient);
assertTrue(toClient.contains("DTSTART;TZID="));
assertTrue(toClient.contains("DTEND;TZID="));
}
public void testAnotherBroken() throws IOException {
String itemBody = "BEGIN:VCALENDAR\n" +
"PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"CREATED:20100916T115132Z\n" +
"LAST-MODIFIED:20100916T115138Z\n" +
"DTSTAMP:20100916T115138Z\n" +
"UID:d72ff8cc-f3ee-4fbc-b44d-1aaf78d92847\n" +
"SUMMARY:New Event\n" +
"DTSTART;VALUE=DATE:20100929\n" +
"DTEND;VALUE=DATE:20100930\n" +
"TRANSP:TRANSPARENT\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
String toServer = fixICS(itemBody, true);
System.out.println(toServer);
}
}

View File

@ -62,4 +62,39 @@ public class StringUtilTest extends TestCase {
assertEquals("%26", StringUtil.urlEncodeAmpersand("&"));
assertEquals("&", StringUtil.urlDecodeAmpersand("%26"));
}
public void testPerf() {
String value = "dqsdqs+dsqds+dsqdqs";
for (int j = 0; j < 5; j++) {
long startTime = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
//String result = StringUtil.encodePlusSign(value);
//String result = StringUtil.replaceAll(value, '+', "%2B");
/*int length = value.length();
StringBuilder buffer = new StringBuilder(length);
int startIndex = 0;
int endIndex = value.indexOf('+');
while (endIndex >= 0) {
buffer.append(value.substring(startIndex, endIndex));
buffer.append("%2B");
startIndex = endIndex + 1;
endIndex = value.indexOf('+', startIndex);
}
buffer.append(value.substring(startIndex)); */
/*
for (int k = 0; k < length; k++) {
char c = value.charAt(k);
if (c == '+') {
buffer.append("%2B");
} else {
buffer.append(c);
}
}*/
//String result = buffer.toString();
//String result = value.replaceAll("\\+", "%2B");
}
System.out.println("Elapsed: " + (System.currentTimeMillis() - startTime) + " ms");
}
}
}