2010-05-20 05:22:03 -04:00
|
|
|
/*
|
|
|
|
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
|
|
|
* Copyright (C) 2010 Mickael Guessant
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
package davmail.exchange.ews;
|
|
|
|
|
2010-07-20 11:00:48 -04:00
|
|
|
import davmail.util.StringUtil;
|
|
|
|
|
2010-05-20 05:22:03 -04:00
|
|
|
/**
|
|
|
|
* Unindexed Field URI
|
|
|
|
*/
|
|
|
|
public class UnindexedFieldURI implements FieldURI {
|
2010-06-29 10:15:50 -04:00
|
|
|
protected final String fieldURI;
|
|
|
|
protected final String fieldName;
|
2010-05-20 05:22:03 -04:00
|
|
|
|
2010-07-10 20:13:28 -04:00
|
|
|
/**
|
|
|
|
* Create unindexed field URI.
|
|
|
|
*
|
|
|
|
* @param fieldURI field name
|
|
|
|
*/
|
2010-05-20 05:22:03 -04:00
|
|
|
public UnindexedFieldURI(String fieldURI) {
|
|
|
|
this.fieldURI = fieldURI;
|
2010-06-29 10:15:50 -04:00
|
|
|
int colonIndex = fieldURI.indexOf(':');
|
|
|
|
if (colonIndex < 0) {
|
|
|
|
fieldName = fieldURI;
|
|
|
|
} else {
|
2010-07-10 20:13:28 -04:00
|
|
|
fieldName = fieldURI.substring(colonIndex + 1);
|
2010-06-29 10:15:50 -04:00
|
|
|
}
|
2010-05-20 05:22:03 -04:00
|
|
|
}
|
|
|
|
|
2010-06-07 17:17:07 -04:00
|
|
|
public void appendTo(StringBuilder buffer) {
|
|
|
|
buffer.append("<t:FieldURI FieldURI=\"").append(fieldURI).append("\"/>");
|
2010-05-20 05:22:03 -04:00
|
|
|
}
|
|
|
|
|
2010-06-29 10:15:50 -04:00
|
|
|
public void appendValue(StringBuilder buffer, String itemType, String value) {
|
2010-07-12 08:25:21 -04:00
|
|
|
if (fieldURI.startsWith("message") && itemType != null) {
|
2010-07-09 08:51:33 -04:00
|
|
|
itemType = "Message";
|
2010-09-17 06:13:00 -04:00
|
|
|
} else if (fieldURI.startsWith("calendar") && itemType != null) {
|
|
|
|
itemType = "CalendarItem";
|
2011-07-16 17:57:00 -04:00
|
|
|
} else if (fieldURI.startsWith("task") && itemType != null) {
|
|
|
|
itemType = "Task";
|
2012-04-16 18:25:07 -04:00
|
|
|
} else if (fieldURI.startsWith("contacts") && itemType != null) {
|
|
|
|
itemType = "Contact";
|
2010-07-09 08:51:33 -04:00
|
|
|
}
|
2010-07-12 08:25:21 -04:00
|
|
|
if (itemType != null) {
|
|
|
|
appendTo(buffer);
|
|
|
|
buffer.append("<t:");
|
|
|
|
buffer.append(itemType);
|
|
|
|
buffer.append('>');
|
|
|
|
}
|
2010-09-17 06:13:00 -04:00
|
|
|
if ("MeetingTimeZone".equals(fieldName)) {
|
|
|
|
buffer.append("<t:MeetingTimeZone TimeZoneName=\"");
|
2011-02-23 17:23:06 -05:00
|
|
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
2010-09-17 06:13:00 -04:00
|
|
|
buffer.append("\"></t:MeetingTimeZone>");
|
|
|
|
} else if ("StartTimeZone".equals(fieldName)) {
|
|
|
|
buffer.append("<t:StartTimeZone Id=\"");
|
2011-02-23 17:23:06 -05:00
|
|
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
2010-09-17 06:13:00 -04:00
|
|
|
buffer.append("\"></t:StartTimeZone>");
|
|
|
|
} else {
|
|
|
|
buffer.append("<t:");
|
|
|
|
buffer.append(fieldName);
|
|
|
|
buffer.append('>');
|
2011-02-23 17:23:06 -05:00
|
|
|
buffer.append(StringUtil.xmlEncodeAttribute(value));
|
2010-09-17 06:13:00 -04:00
|
|
|
buffer.append("</t:");
|
|
|
|
buffer.append(fieldName);
|
|
|
|
buffer.append('>');
|
|
|
|
}
|
2010-07-12 08:25:21 -04:00
|
|
|
if (itemType != null) {
|
|
|
|
buffer.append("</t:");
|
|
|
|
buffer.append(itemType);
|
|
|
|
buffer.append('>');
|
|
|
|
}
|
2010-06-29 10:15:50 -04:00
|
|
|
}
|
|
|
|
|
2010-07-01 12:12:57 -04:00
|
|
|
public String getResponseName() {
|
|
|
|
return fieldName;
|
|
|
|
}
|
|
|
|
|
2010-05-20 05:22:03 -04:00
|
|
|
}
|