2010-06-08 18:21:53 -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.dav ;
2013-07-08 17:48:31 -04:00
import davmail.Settings ;
2010-07-24 06:54:27 -04:00
import davmail.util.StringUtil ;
2010-06-08 18:21:53 -04:00
import org.apache.jackrabbit.webdav.property.DavPropertyName ;
2010-06-09 05:13:13 -04:00
import org.apache.jackrabbit.webdav.property.DefaultDavProperty ;
2012-10-08 17:49:34 -04:00
import org.apache.jackrabbit.webdav.property.PropEntry ;
2010-07-13 05:56:48 -04:00
import org.apache.jackrabbit.webdav.xml.DomUtil ;
2010-06-08 18:21:53 -04:00
import org.apache.jackrabbit.webdav.xml.Namespace ;
2010-07-13 05:56:48 -04:00
import org.apache.jackrabbit.webdav.xml.XmlSerializable ;
import org.w3c.dom.Document ;
import org.w3c.dom.Element ;
2010-06-08 18:21:53 -04:00
2010-07-13 05:56:48 -04:00
import java.util.ArrayList ;
2010-06-08 18:21:53 -04:00
import java.util.HashMap ;
2010-07-13 05:56:48 -04:00
import java.util.List ;
2010-06-08 18:21:53 -04:00
import java.util.Map ;
/ * *
* WebDav Field
* /
public class Field {
2010-06-10 16:47:55 -04:00
protected static final Map < DistinguishedPropertySetType , String > distinguishedPropertySetMap = new HashMap < DistinguishedPropertySetType , String > ( ) ;
static {
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . Meeting , " 6ed8da90-450b-101b-98da-00aa003f1305 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . Appointment , " 00062002-0000-0000-c000-000000000046 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . Common , " 00062008-0000-0000-c000-000000000046 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . PublicStrings , " 00020329-0000-0000-c000-000000000046 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . Address , " 00062004-0000-0000-c000-000000000046 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . InternetHeaders , " 00020386-0000-0000-c000-000000000046 " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . UnifiedMessaging , " 4442858e-a9e3-4e80-b900-317a210cc15b " ) ;
distinguishedPropertySetMap . put ( DistinguishedPropertySetType . Task , " 00062003-0000-0000-c000-000000000046 " ) ;
}
2010-06-17 19:04:38 -04:00
protected static final Namespace EMPTY = Namespace . getNamespace ( " " ) ;
2010-07-13 05:56:48 -04:00
protected static final Namespace XML = Namespace . getNamespace ( " xml: " ) ;
2010-06-08 18:21:53 -04:00
protected static final Namespace DAV = Namespace . getNamespace ( " DAV: " ) ;
protected static final Namespace URN_SCHEMAS_HTTPMAIL = Namespace . getNamespace ( " urn:schemas:httpmail: " ) ;
protected static final Namespace URN_SCHEMAS_MAILHEADER = Namespace . getNamespace ( " urn:schemas:mailheader: " ) ;
protected static final Namespace SCHEMAS_EXCHANGE = Namespace . getNamespace ( " http://schemas.microsoft.com/exchange/ " ) ;
2010-07-13 05:56:48 -04:00
protected static final Namespace SCHEMAS_MAPI = Namespace . getNamespace ( " http://schemas.microsoft.com/mapi/ " ) ;
2010-06-08 18:21:53 -04:00
protected static final Namespace SCHEMAS_MAPI_PROPTAG = Namespace . getNamespace ( " http://schemas.microsoft.com/mapi/proptag/ " ) ;
protected static final Namespace SCHEMAS_MAPI_ID = Namespace . getNamespace ( " http://schemas.microsoft.com/mapi/id/ " ) ;
protected static final Namespace SCHEMAS_MAPI_STRING = Namespace . getNamespace ( " http://schemas.microsoft.com/mapi/string/ " ) ;
2010-06-10 16:47:55 -04:00
protected static final Namespace SCHEMAS_REPL = Namespace . getNamespace ( " http://schemas.microsoft.com/repl/ " ) ;
2010-06-08 18:21:53 -04:00
protected static final Namespace URN_SCHEMAS_CONTACTS = Namespace . getNamespace ( " urn:schemas:contacts: " ) ;
2010-06-15 10:51:49 -04:00
protected static final Namespace URN_SCHEMAS_CALENDAR = Namespace . getNamespace ( " urn:schemas:calendar: " ) ;
2010-06-08 18:21:53 -04:00
2010-06-10 16:47:55 -04:00
protected static final Namespace SCHEMAS_MAPI_STRING_INTERNET_HEADERS =
Namespace . getNamespace ( SCHEMAS_MAPI_STRING . getURI ( ) +
'{' + distinguishedPropertySetMap . get ( DistinguishedPropertySetType . InternetHeaders ) + " }/ " ) ;
2010-06-08 18:21:53 -04:00
protected static final Map < PropertyType , String > propertyTypeMap = new HashMap < PropertyType , String > ( ) ;
static {
2010-07-23 04:58:39 -04:00
propertyTypeMap . put ( PropertyType . Integer , " 0003 " ) ; // PT_INT
propertyTypeMap . put ( PropertyType . Boolean , " 000b " ) ; // PT_BOOLEAN
propertyTypeMap . put ( PropertyType . SystemTime , " 0040 " ) ; // PT_SYSTIME
2010-06-30 17:38:01 -04:00
propertyTypeMap . put ( PropertyType . String , " 001f " ) ; // 001f is PT_UNICODE_STRING, 001E is PT_STRING
2010-07-23 04:58:39 -04:00
propertyTypeMap . put ( PropertyType . Binary , " 0102 " ) ; // PT_BINARY
2011-08-07 05:57:03 -04:00
propertyTypeMap . put ( PropertyType . Double , " 0005 " ) ; // PT_DOUBLE
2010-06-08 18:21:53 -04:00
}
2010-07-21 05:14:23 -04:00
@SuppressWarnings ( { " UnusedDeclaration " } )
2010-06-08 18:21:53 -04:00
protected static enum DistinguishedPropertySetType {
Meeting , Appointment , Common , PublicStrings , Address , InternetHeaders , CalendarAssistant , UnifiedMessaging , Task
}
protected static final Map < String , Field > fieldMap = new HashMap < String , Field > ( ) ;
static {
// well known folders
createField ( URN_SCHEMAS_HTTPMAIL , " inbox " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " deleteditems " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " sentitems " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " sendmsg " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " drafts " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " calendar " ) ;
2011-07-18 18:32:24 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " tasks " ) ;
2010-06-08 18:21:53 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " contacts " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " outbox " ) ;
2010-06-10 16:47:55 -04:00
2010-06-08 18:21:53 -04:00
// folder
createField ( " folderclass " , SCHEMAS_EXCHANGE , " outlookfolderclass " ) ;
2010-06-10 16:47:55 -04:00
createField ( DAV , " hassubs " ) ;
createField ( DAV , " nosubs " ) ;
2012-09-18 18:30:54 -04:00
createField ( " count " , DAV , " objectcount " ) ;
2010-06-10 16:47:55 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " unreadcount " ) ;
createField ( SCHEMAS_REPL , " contenttag " ) ;
2010-06-08 18:21:53 -04:00
2010-07-23 04:58:39 -04:00
createField ( " uidNext " , 0x6751 , PropertyType . Integer ) ; // PR_ARTICLE_NUM_NEXT
createField ( " highestUid " , 0x6752 , PropertyType . Integer ) ; // PR_IMAP_LAST_ARTICLE_ID
2010-06-23 18:27:42 -04:00
createField ( DAV , " isfolder " ) ;
2010-07-06 05:45:25 -04:00
// item uid, do not use as search parameter, see http://support.microsoft.com/kb/320749
createField ( DAV , " uid " ) ; // based on PR_RECORD_KEY
2010-07-01 08:47:57 -04:00
2010-06-08 18:21:53 -04:00
// POP and IMAP message
2010-07-23 04:58:39 -04:00
createField ( " messageSize " , 0x0e08 , PropertyType . Integer ) ; //PR_MESSAGE_SIZE
createField ( " imapUid " , 0x0e23 , PropertyType . Integer ) ; //PR_INTERNET_ARTICLE_NUMBER
2013-07-08 17:48:31 -04:00
createField ( " junk " , 0x1083 , PropertyType . Integer ) ; //PR_SPAMTYPE
2010-07-23 04:58:39 -04:00
createField ( " flagStatus " , 0x1090 , PropertyType . Integer ) ; //PR_FLAG_STATUS
createField ( " messageFlags " , 0x0e07 , PropertyType . Integer ) ; //PR_MESSAGE_FLAGS
createField ( " lastVerbExecuted " , 0x1081 , PropertyType . Integer ) ; //PR_LAST_VERB_EXECUTED
createField ( " iconIndex " , 0x1080 , PropertyType . Integer ) ; //PR_ICON_INDEX
2010-06-08 18:21:53 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " read " ) ;
//createField("read", 0x0e69, PropertyType.Boolean);//PR_READ
2013-07-08 17:48:31 -04:00
if ( Settings . getBooleanProperty ( " davmail.popCommonDeleted " , true ) ) {
// deleted flag, see http://microsoft.public.win32.programmer.messaging.narkive.com/w7Mrsrsx/how-to-detect-deleted-imap-messages-using-mapi-outlook-object-model-api
createField ( " deleted " , DistinguishedPropertySetType . Common , 0x8570 , " deleted " , PropertyType . String ) ;
} else {
createField ( " deleted " , DistinguishedPropertySetType . PublicStrings ) ;
}
2010-06-29 04:43:42 -04:00
2010-07-21 06:18:46 -04:00
//createField(URN_SCHEMAS_HTTPMAIL, "date");//PR_CLIENT_SUBMIT_TIME, 0x0039
createField ( " date " , 0x0e06 , PropertyType . SystemTime ) ; //PR_MESSAGE_DELIVERY_TIME
2010-06-09 05:13:13 -04:00
createField ( URN_SCHEMAS_MAILHEADER , " bcc " ) ; //PS_INTERNET_HEADERS/bcc
2010-06-16 17:43:11 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " datereceived " ) ; //PR_MESSAGE_DELIVERY_TIME, 0x0E06
2010-07-21 09:43:41 -04:00
// unused: force message encoding
2010-07-23 04:58:39 -04:00
createField ( " messageFormat " , 0x5909 , PropertyType . Integer ) ; //PR_MSG_EDITOR_FORMAT EDITOR_FORMAT_PLAINTEXT = 1 EDITOR_FORMAT_HTML = 2
2010-09-07 17:09:53 -04:00
createField ( " mailOverrideFormat " , 0x5902 , PropertyType . Integer ) ; //PR_INETMAIL_OVERRIDE_FORMAT ENCODING_PREFERENCE = 2 BODY_ENCODING_TEXT_AND_HTML = 1 ENCODING_MIME = 4
2010-06-08 18:21:53 -04:00
// IMAP search
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " subject " ) ; // DistinguishedPropertySetType.InternetHeaders/Subject/String
2010-06-08 18:21:53 -04:00
//createField("subject", 0x0037, PropertyType.String);//PR_SUBJECT
createField ( " body " , 0x1000 , PropertyType . String ) ; //PR_BODY
2012-05-16 12:07:35 -04:00
createField ( " messageheaders " , 0x007D , PropertyType . String ) ; // PR_TRANSPORT_MESSAGE_HEADERS
2010-06-08 18:21:53 -04:00
createField ( URN_SCHEMAS_HTTPMAIL , " from " ) ;
//createField("from", DistinguishedPropertySetType.PublicStrings, 0x001f);//urn:schemas:httpmail:from
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_MAILHEADER , " to " ) ; // DistinguishedPropertySetType.InternetHeaders/To/String
createField ( URN_SCHEMAS_MAILHEADER , " cc " ) ; // DistinguishedPropertySetType.InternetHeaders/To/String
2010-09-29 19:28:22 -04:00
createField ( URN_SCHEMAS_MAILHEADER , " message-id " ) ; // DistinguishedPropertySetType.InternetHeaders/message-id/String
createField ( URN_SCHEMAS_MAILHEADER , " htmldescription " ) ; // DistinguishedPropertySetType.InternetHeaders/htmldescription/String
2010-06-08 18:21:53 -04:00
2010-06-30 17:38:01 -04:00
createField ( " lastmodified " , DAV , " getlastmodified " ) ; // PR_LAST_MODIFICATION_TIME 0x3008 SystemTime
2010-06-08 18:21:53 -04:00
// failover search
createField ( DAV , " displayname " ) ;
2010-06-30 17:38:01 -04:00
createField ( " urlcompname " , 0x10f3 , PropertyType . String ) ; //PR_URL_COMP_NAME
2010-06-15 10:51:49 -04:00
// items
createField ( " etag " , DAV , " getetag " ) ;
// calendar
createField ( SCHEMAS_EXCHANGE , " permanenturl " ) ;
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CALENDAR , " instancetype " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:instancetype/Integer
createField ( URN_SCHEMAS_CALENDAR , " dtstart " ) ; // 0x10C3 SystemTime
2010-07-22 19:10:24 -04:00
createField ( URN_SCHEMAS_CALENDAR , " dtend " ) ; // 0x10C4 SystemTime
2010-09-13 12:07:49 -04:00
//createField(URN_SCHEMAS_CALENDAR, "prodid"); // // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:prodid/String
createField ( " calendarversion " , URN_SCHEMAS_CALENDAR , " version " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:version/String
createField ( URN_SCHEMAS_CALENDAR , " method " ) ; // // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:method/String
createField ( " calendarlastmodified " , URN_SCHEMAS_CALENDAR , " lastmodified " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:isorganizer/Boolean
createField ( URN_SCHEMAS_CALENDAR , " dtstamp " ) ; // PidLidOwnerCriticalChange
createField ( " calendaruid " , URN_SCHEMAS_CALENDAR , " uid " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:uid/String
createField ( URN_SCHEMAS_CALENDAR , " transparent " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:transparent/String
createField ( URN_SCHEMAS_CALENDAR , " organizer " ) ;
createField ( URN_SCHEMAS_CALENDAR , " created " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:created/SystemTime
createField ( URN_SCHEMAS_CALENDAR , " alldayevent " ) ; // DistinguishedPropertySetType.Appointment/0x8215 Boolean
2010-09-13 15:27:16 -04:00
createField ( URN_SCHEMAS_CALENDAR , " rrule " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:rrule/PtypMultipleString
createField ( URN_SCHEMAS_CALENDAR , " exdate " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:exdate/PtypMultipleTime
2010-09-13 16:08:05 -04:00
createField ( SCHEMAS_MAPI , " reminderset " ) ; // PidLidReminderSet
createField ( SCHEMAS_MAPI , " reminderdelta " ) ; // PidLidReminderDelta
2010-09-13 12:07:49 -04:00
// TODO
createField ( SCHEMAS_MAPI , " allattendeesstring " ) ; // PidLidAllAttendeesString
createField ( SCHEMAS_MAPI , " required_attendees " ) ; // PidLidRequiredAttendees
createField ( SCHEMAS_MAPI , " apptendtime " ) ; // PidLidAppointmentEndTime
createField ( SCHEMAS_MAPI , " apptstateflags " ) ; // PidLidAppointmentStateFlags 1: Meeting, 2: Received, 4: Cancelled
createField ( URN_SCHEMAS_CALENDAR , " isorganizer " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:isorganizer/Boolean
createField ( URN_SCHEMAS_CALENDAR , " location " ) ; // DistinguishedPropertySetType.Appointment/0x8208 String
createField ( URN_SCHEMAS_CALENDAR , " attendeerole " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:attendeerole/Integer
createField ( URN_SCHEMAS_CALENDAR , " busystatus " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:busystatus/String
createField ( URN_SCHEMAS_CALENDAR , " exrule " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:exrule/PtypMultipleString
createField ( URN_SCHEMAS_CALENDAR , " recurrenceidrange " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:recurrenceidrange/String
createField ( URN_SCHEMAS_CALENDAR , " rdate " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:rdate/PtypMultipleTime
createField ( URN_SCHEMAS_CALENDAR , " reminderoffset " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:reminderoffset/Integer
createField ( URN_SCHEMAS_CALENDAR , " timezone " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezone/String
2010-06-17 16:08:57 -04:00
createField ( SCHEMAS_EXCHANGE , " sensitivity " ) ; // PR_SENSITIVITY 0x0036 Integer
createField ( URN_SCHEMAS_CALENDAR , " timezoneid " ) ; // DistinguishedPropertySetType.PublicStrings/urn:schemas:calendar:timezoneid/Integer
2010-09-13 12:07:49 -04:00
// should use PidLidServerProcessed ?
2010-06-17 16:08:57 -04:00
createField ( " processed " , 0x65e8 , PropertyType . Boolean ) ; // PR_MESSAGE_PROCESSED
2010-06-15 10:51:49 -04:00
createField ( DAV , " contentclass " ) ;
createField ( " internetContent " , 0x6659 , PropertyType . Binary ) ;
2010-06-16 17:43:11 -04:00
// contact
createField ( SCHEMAS_EXCHANGE , " outlookmessageclass " ) ;
createField ( URN_SCHEMAS_HTTPMAIL , " subject " ) ;
createField ( URN_SCHEMAS_CONTACTS , " middlename " ) ; // PR_MIDDLE_NAME 0x3A44
createField ( URN_SCHEMAS_CONTACTS , " fileas " ) ; // urn:schemas:contacts:fileas PS_PUBLIC_STRINGS
2010-07-07 05:56:35 -04:00
//createField("id", 0x0ff6, PropertyType.Binary); // PR_INSTANCE_KEY http://support.microsoft.com/kb/320749
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " homepostaladdress " ) ; // homeAddress DistinguishedPropertySetType.Address/0x0000801A/String
createField ( URN_SCHEMAS_CONTACTS , " otherpostaladdress " ) ; // otherAddress DistinguishedPropertySetType.Address/0x0000801C/String
createField ( URN_SCHEMAS_CONTACTS , " mailingaddressid " ) ; // postalAddressId DistinguishedPropertySetType.Address/0x00008022/String
createField ( URN_SCHEMAS_CONTACTS , " workaddress " ) ; // workAddress DistinguishedPropertySetType.Address/0x0000801B/String
createField ( URN_SCHEMAS_CONTACTS , " alternaterecipient " ) ; // alternaterecipient DistinguishedPropertySetType.PublicStrings/urn:schemas:contacts:alternaterecipient/String
createField ( SCHEMAS_EXCHANGE , " extensionattribute1 " ) ; // DistinguishedPropertySetType.Address/0x0000804F/String
createField ( SCHEMAS_EXCHANGE , " extensionattribute2 " ) ; // DistinguishedPropertySetType.Address/0x00008050/String
createField ( SCHEMAS_EXCHANGE , " extensionattribute3 " ) ; // DistinguishedPropertySetType.Address/0x00008051/String
createField ( SCHEMAS_EXCHANGE , " extensionattribute4 " ) ; // DistinguishedPropertySetType.Address/0x00008052/String
createField ( URN_SCHEMAS_CONTACTS , " bday " ) ; // PR_BIRTHDAY 0x3A42 SystemTime
2010-07-20 12:43:38 -04:00
createField ( " anniversary " , URN_SCHEMAS_CONTACTS , " weddinganniversary " ) ; // WeddingAnniversary
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " businesshomepage " ) ; // PR_BUSINESS_HOME_PAGE 0x3A51 String
2010-07-19 10:07:46 -04:00
createField ( URN_SCHEMAS_CONTACTS , " personalHomePage " ) ; // PR_PERSONAL_HOME_PAGE 0x3A50 String
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " cn " ) ; // PR_DISPLAY_NAME 0x3001 String
2010-07-07 09:18:33 -04:00
createField ( URN_SCHEMAS_CONTACTS , " co " ) ; // workAddressCountry DistinguishedPropertySetType.Address/0x00008049/String
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " department " ) ; // PR_DEPARTMENT_NAME 0x3A18 String
2010-07-23 06:13:08 -04:00
// smtp email
createField ( " smtpemail1 " , DistinguishedPropertySetType . Address , 0x8084 , " smtpemail1 " ) ; // Email1OriginalDisplayName
createField ( " smtpemail2 " , DistinguishedPropertySetType . Address , 0x8094 , " smtpemail2 " ) ; // Email2OriginalDisplayName
createField ( " smtpemail3 " , DistinguishedPropertySetType . Address , 0x80A4 , " smtpemail3 " ) ; // Email3OriginalDisplayName
// native email
2012-02-02 17:32:48 -05:00
createField ( " email1 " , DistinguishedPropertySetType . Address , 0x8083 , " email1 " ) ; // Email1EmailAddress
createField ( " email2 " , DistinguishedPropertySetType . Address , 0x8093 , " email2 " ) ; // Email2EmailAddress
createField ( " email3 " , DistinguishedPropertySetType . Address , 0x80A3 , " email3 " ) ; // Email3EmailAddress
// email type
createField ( " email1type " , DistinguishedPropertySetType . Address , 0x8082 , " email1type " ) ; // Email1AddressType
createField ( " email2type " , DistinguishedPropertySetType . Address , 0x8092 , " email2type " ) ; // Email2AddressType
createField ( " email3type " , DistinguishedPropertySetType . Address , 0x80A2 , " email3type " ) ; // Email3AddressType
2010-07-06 12:26:55 -04:00
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " facsimiletelephonenumber " ) ; // PR_BUSINESS_FAX_NUMBER 0x3A24 String
createField ( URN_SCHEMAS_CONTACTS , " givenName " ) ; // PR_GIVEN_NAME 0x3A06 String
2010-07-06 12:26:55 -04:00
createField ( URN_SCHEMAS_CONTACTS , " homepostofficebox " ) ; // PR_HOME_ADDRESS_POST_OFFICE_BOX 0x3A5E String
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " homeCity " ) ; // PR_HOME_ADDRESS_CITY 0x3A59 String
createField ( URN_SCHEMAS_CONTACTS , " homeCountry " ) ; // PR_HOME_ADDRESS_COUNTRY 0x3A5A String
createField ( URN_SCHEMAS_CONTACTS , " homePhone " ) ; // PR_HOME_TELEPHONE_NUMBER 0x3A09 String
createField ( URN_SCHEMAS_CONTACTS , " homePostalCode " ) ; // PR_HOME_ADDRESS_POSTAL_CODE 0x3A5B String
createField ( URN_SCHEMAS_CONTACTS , " homeState " ) ; // PR_HOME_ADDRESS_STATE_OR_PROVINCE 0x3A5C String
createField ( URN_SCHEMAS_CONTACTS , " homeStreet " ) ; // PR_HOME_ADDRESS_STREET 0x3A5D String
createField ( URN_SCHEMAS_CONTACTS , " l " ) ; // workAddressCity DistinguishedPropertySetType.Address/0x00008046/String
createField ( URN_SCHEMAS_CONTACTS , " manager " ) ; // PR_MANAGER_NAME 0x3A4E String
createField ( URN_SCHEMAS_CONTACTS , " mobile " ) ; // PR_MOBILE_TELEPHONE_NUMBER 0x3A1C String
createField ( URN_SCHEMAS_CONTACTS , " namesuffix " ) ; // PR_GENERATION 0x3A05 String
createField ( URN_SCHEMAS_CONTACTS , " nickname " ) ; // PR_NICKNAME 0x3A4F String
2010-07-06 05:45:25 -04:00
createField ( URN_SCHEMAS_CONTACTS , " o " ) ; // PR_COMPANY_NAME 0x3A16 String
2010-06-17 16:08:57 -04:00
createField ( URN_SCHEMAS_CONTACTS , " pager " ) ; // PR_PAGER_TELEPHONE_NUMBER 0x3A21 String
createField ( URN_SCHEMAS_CONTACTS , " personaltitle " ) ; // PR_DISPLAY_NAME_PREFIX 0x3A45 String
createField ( URN_SCHEMAS_CONTACTS , " postalcode " ) ; // workAddressPostalCode DistinguishedPropertySetType.Address/0x00008048/String
createField ( URN_SCHEMAS_CONTACTS , " postofficebox " ) ; // workAddressPostOfficeBox DistinguishedPropertySetType.Address/0x0000804A/String
createField ( URN_SCHEMAS_CONTACTS , " profession " ) ; // PR_PROFESSION 0x3A46 String
createField ( URN_SCHEMAS_CONTACTS , " roomnumber " ) ; // PR_OFFICE_LOCATION 0x3A19 String
createField ( URN_SCHEMAS_CONTACTS , " secretarycn " ) ; // PR_ASSISTANT 0x3A30 String
createField ( URN_SCHEMAS_CONTACTS , " sn " ) ; // PR_SURNAME 0x3A11 String
createField ( URN_SCHEMAS_CONTACTS , " spousecn " ) ; // PR_SPOUSE_NAME 0x3A48 String
createField ( URN_SCHEMAS_CONTACTS , " st " ) ; // workAddressState DistinguishedPropertySetType.Address/0x00008047/String
createField ( URN_SCHEMAS_CONTACTS , " street " ) ; // workAddressStreet DistinguishedPropertySetType.Address/0x00008045/String
createField ( URN_SCHEMAS_CONTACTS , " telephoneNumber " ) ; // PR_BUSINESS_TELEPHONE_NUMBER 0x3A08 String
createField ( URN_SCHEMAS_CONTACTS , " title " ) ; // PR_TITLE 0x3A17 String
2010-07-06 05:45:25 -04:00
createField ( " description " , URN_SCHEMAS_HTTPMAIL , " textdescription " ) ; // PR_BODY 0x1000 String
2010-07-06 11:52:38 -04:00
createField ( " im " , SCHEMAS_MAPI , " InstMsg " ) ; // InstantMessagingAddress DistinguishedPropertySetType.Address/0x00008062/String
2010-07-19 10:07:46 -04:00
createField ( URN_SCHEMAS_CONTACTS , " othermobile " ) ; // PR_CAR_TELEPHONE_NUMBER 0x3A1E String
2010-07-26 11:08:06 -04:00
createField ( URN_SCHEMAS_CONTACTS , " internationalisdnnumber " ) ; // PR_ISDN_NUMBER 0x3A2D String
2010-07-19 10:07:46 -04:00
2010-07-26 11:08:06 -04:00
createField ( URN_SCHEMAS_CONTACTS , " otherTelephone " ) ; // PR_OTHER_TELEPHONE_NUMBER 0x3A21 String
createField ( URN_SCHEMAS_CONTACTS , " homefax " ) ; // PR_HOME_FAX_NUMBER 0x3A25 String
2010-06-16 17:43:11 -04:00
2010-07-06 12:26:55 -04:00
createField ( URN_SCHEMAS_CONTACTS , " otherstreet " ) ; // PR_OTHER_ADDRESS_STREET 0x3A63 String
createField ( URN_SCHEMAS_CONTACTS , " otherstate " ) ; // PR_OTHER_ADDRESS_STATE_OR_PROVINCE 0x3A62 String
createField ( URN_SCHEMAS_CONTACTS , " otherpostofficebox " ) ; // PR_OTHER_ADDRESS_POST_OFFICE_BOX 0x3A64 String
createField ( URN_SCHEMAS_CONTACTS , " otherpostalcode " ) ; // PR_OTHER_ADDRESS_POSTAL_CODE 0x3A61 String
createField ( URN_SCHEMAS_CONTACTS , " othercountry " ) ; // PR_OTHER_ADDRESS_COUNTRY 0x3A60 String
createField ( URN_SCHEMAS_CONTACTS , " othercity " ) ; // PR_OTHER_ADDRESS_CITY 0x3A5F String
2010-07-20 16:18:01 -04:00
createField ( URN_SCHEMAS_CONTACTS , " gender " ) ; // PR_GENDER 0x3A4D Integer16
2010-07-13 05:56:48 -04:00
createField ( " keywords " , SCHEMAS_EXCHANGE , " keywords-utf8 " , PropertyType . StringArray ) ; // PS_PUBLIC_STRINGS Keywords String
//createField("keywords", DistinguishedPropertySetType.PublicStrings, "Keywords", ); // PS_PUBLIC_STRINGS Keywords String
2010-06-29 04:43:42 -04:00
// contact private flags
2010-07-18 17:33:22 -04:00
createField ( " private " , DistinguishedPropertySetType . Common , 0x8506 , " private " , PropertyType . Boolean ) ; // True/False
2010-07-23 04:58:39 -04:00
createField ( " sensitivity " , 0x0036 , PropertyType . Integer ) ; // PR_SENSITIVITY SENSITIVITY_PRIVATE = 2, SENSITIVITY_PERSONAL = 1, SENSITIVITY_NONE = 0
2010-06-29 04:43:42 -04:00
2010-07-18 18:54:54 -04:00
createField ( " haspicture " , DistinguishedPropertySetType . Address , 0x8015 , " haspicture " , PropertyType . Boolean ) ; // True/False
2010-07-06 19:40:48 -04:00
2010-07-26 09:22:28 -04:00
createField ( URN_SCHEMAS_CALENDAR , " fburl " ) ; // freeBusyLocation
2010-06-28 12:26:08 -04:00
// OWA settings
createField ( " messageclass " , 0x001a , PropertyType . String ) ;
createField ( " roamingxmlstream " , 0x7c08 , PropertyType . Binary ) ;
createField ( " roamingdictionary " , 0x7c07 , PropertyType . Binary ) ;
createField ( DAV , " ishidden " ) ;
2010-07-17 17:29:13 -04:00
2010-07-24 05:45:32 -04:00
// attachment content
createField ( " attachDataBinary " , 0x3701 , PropertyType . Binary ) ;
2010-07-17 17:29:13 -04:00
createField ( " attachmentContactPhoto " , 0x7FFF , PropertyType . Boolean ) ; // PR_ATTACHMENT_CONTACTPHOTO
2010-07-23 04:58:39 -04:00
createField ( " renderingPosition " , 0x370B , PropertyType . Integer ) ; // PR_RENDERING_POSITION
2010-07-24 05:45:32 -04:00
//createField("attachFilename", 0x3704, PropertyType.String); // PR_ATTACH_FILENAME
2011-03-23 05:43:53 -04:00
createField ( " attachExtension " , 0x3703 , PropertyType . String ) ; // PR_ATTACH_EXTENSION
2010-07-24 05:45:32 -04:00
2011-03-23 05:43:53 -04:00
createField ( " xmozlastack " , DistinguishedPropertySetType . PublicStrings ) ;
createField ( " xmozsnoozetime " , DistinguishedPropertySetType . PublicStrings ) ;
createField ( " xmozsendinvitations " , DistinguishedPropertySetType . PublicStrings ) ;
2011-08-06 15:11:39 -04:00
// task
createField ( URN_SCHEMAS_MAILHEADER , " importance " ) ; //PS_INTERNET_HEADERS/importance
2011-08-07 05:57:03 -04:00
createField ( " percentcomplete " , DistinguishedPropertySetType . Task , 0x8102 , " percentcomplete " , PropertyType . Double ) ;
createField ( " taskstatus " , DistinguishedPropertySetType . Task , 0x8101 , " taskstatus " , PropertyType . Integer ) ;
2011-08-08 05:06:39 -04:00
createField ( " startdate " , DistinguishedPropertySetType . Task , 0x8104 , " startdate " , PropertyType . SystemTime ) ;
createField ( " duedate " , DistinguishedPropertySetType . Task , 0x8105 , " duedate " , PropertyType . SystemTime ) ;
2011-08-08 07:54:23 -04:00
createField ( " datecompleted " , DistinguishedPropertySetType . Task , 0x810F , " datecompleted " , PropertyType . SystemTime ) ;
createField ( " iscomplete " , DistinguishedPropertySetType . Task , 0x811C , " iscomplete " , PropertyType . Boolean ) ;
createField ( " commonstart " , DistinguishedPropertySetType . Common , 0x8516 , " commonstart " , PropertyType . SystemTime ) ;
createField ( " commonend " , DistinguishedPropertySetType . Common , 0x8517 , " commonend " , PropertyType . SystemTime ) ;
2010-06-08 18:21:53 -04:00
}
2010-07-01 08:47:57 -04:00
protected static String toHexString ( int propertyTag ) {
2010-07-19 05:02:14 -04:00
StringBuilder hexValue = new StringBuilder ( Integer . toHexString ( propertyTag ) ) ;
2010-07-01 08:47:57 -04:00
while ( hexValue . length ( ) < 4 ) {
2010-07-19 05:02:14 -04:00
hexValue . insert ( 0 , '0' ) ;
2010-07-01 08:47:57 -04:00
}
2010-07-19 05:02:14 -04:00
return hexValue . toString ( ) ;
2010-07-01 08:47:57 -04:00
}
2010-06-08 18:21:53 -04:00
protected static void createField ( String alias , int propertyTag , PropertyType propertyType ) {
2010-07-01 08:47:57 -04:00
String name = 'x' + toHexString ( propertyTag ) + propertyTypeMap . get ( propertyType ) ;
Field field ;
if ( propertyType = = PropertyType . Binary ) {
2010-07-21 05:14:23 -04:00
field = new Field ( alias , SCHEMAS_MAPI_PROPTAG , name , propertyType , null , " bin.base64 " , name ) ;
2010-07-01 08:47:57 -04:00
} else {
2010-07-18 17:33:22 -04:00
field = new Field ( alias , SCHEMAS_MAPI_PROPTAG , name , propertyType ) ;
2010-07-06 05:45:25 -04:00
}
2010-06-08 18:21:53 -04:00
fieldMap . put ( field . alias , field ) ;
}
2011-03-23 05:43:53 -04:00
protected static void createField ( String alias , DistinguishedPropertySetType propertySetType ) {
Field field = new Field ( Namespace . getNamespace ( SCHEMAS_MAPI_STRING . getURI ( ) +
'{' + distinguishedPropertySetMap . get ( propertySetType ) + " }/ " ) , alias ) ;
fieldMap . put ( field . alias , field ) ;
}
2010-06-16 08:06:59 -04:00
protected static void createField ( String alias , DistinguishedPropertySetType propertySetType , int propertyTag , String responseAlias ) {
2010-07-21 05:14:23 -04:00
createField ( alias , propertySetType , propertyTag , responseAlias , null ) ;
2010-07-18 17:33:22 -04:00
}
protected static void createField ( String alias , DistinguishedPropertySetType propertySetType , int propertyTag , String responseAlias , PropertyType propertyType ) {
2010-07-06 11:52:38 -04:00
String name ;
2010-07-18 18:54:54 -04:00
String updateAlias ;
2010-06-22 04:37:34 -04:00
if ( propertySetType = = DistinguishedPropertySetType . Address ) {
// Address namespace expects integer names
2010-07-06 11:52:38 -04:00
name = String . valueOf ( propertyTag ) ;
2011-08-07 05:57:03 -04:00
updateAlias = " _x0030_x " + toHexString ( propertyTag ) ;
} else if ( propertySetType = = DistinguishedPropertySetType . Task ) {
name = " 0x " + toHexString ( propertyTag ) ;
updateAlias = " 0x0000 " + toHexString ( propertyTag ) ;
2010-06-22 04:37:34 -04:00
} else {
// Common namespace expects hex names
2010-07-06 11:52:38 -04:00
name = " 0x " + toHexString ( propertyTag ) ;
2011-08-07 05:57:03 -04:00
updateAlias = " _x0030_x " + toHexString ( propertyTag ) ;
2010-06-22 04:37:34 -04:00
}
Field field = new Field ( alias , Namespace . getNamespace ( SCHEMAS_MAPI_ID . getURI ( ) +
2010-07-21 05:14:23 -04:00
'{' + distinguishedPropertySetMap . get ( propertySetType ) + " }/ " ) , name , propertyType , responseAlias , null , updateAlias ) ;
2010-06-09 05:13:13 -04:00
fieldMap . put ( field . alias , field ) ;
}
2010-06-08 18:21:53 -04:00
protected static void createField ( Namespace namespace , String name ) {
Field field = new Field ( namespace , name ) ;
fieldMap . put ( field . alias , field ) ;
}
protected static void createField ( String alias , Namespace namespace , String name ) {
2010-07-18 17:33:22 -04:00
Field field = new Field ( alias , namespace , name , null ) ;
2010-06-08 18:21:53 -04:00
fieldMap . put ( field . alias , field ) ;
}
2010-07-13 05:56:48 -04:00
protected static void createField ( String alias , Namespace namespace , String name , PropertyType propertyType ) {
2010-07-18 17:33:22 -04:00
Field field = new Field ( alias , namespace , name , propertyType ) ;
2010-07-13 05:56:48 -04:00
fieldMap . put ( field . alias , field ) ;
}
2010-07-21 05:14:23 -04:00
private final DavPropertyName davPropertyName ;
2010-06-08 18:21:53 -04:00
protected final String alias ;
protected final String uri ;
2010-06-16 08:06:59 -04:00
protected final String requestPropertyString ;
2010-06-17 19:04:38 -04:00
protected final DavPropertyName responsePropertyName ;
2010-07-18 18:54:54 -04:00
protected final DavPropertyName updatePropertyName ;
2010-07-01 08:47:57 -04:00
protected final String cast ;
2010-07-18 17:33:22 -04:00
protected final boolean isIntValue ;
protected final boolean isMultivalued ;
protected final boolean isBooleanValue ;
2011-08-07 05:57:03 -04:00
protected final boolean isFloatValue ;
2011-08-08 05:06:39 -04:00
protected final boolean isDateValue ;
2010-06-17 19:04:38 -04:00
2010-07-21 05:14:23 -04:00
/ * *
* Create field for namespace and name , use name as alias .
*
* @param namespace Exchange namespace
* @param name Exchange name
* /
protected Field ( Namespace namespace , String name ) {
2010-07-18 17:33:22 -04:00
this ( name , namespace , name , null ) ;
2010-06-08 18:21:53 -04:00
}
2010-07-21 05:14:23 -04:00
/ * *
* Create field for namespace and name of type propertyType .
*
* @param alias logical name in DavMail
* @param namespace Exchange namespace
* @param name Exchange name
* @param propertyType property type
* /
protected Field ( String alias , Namespace namespace , String name , PropertyType propertyType ) {
this ( alias , namespace , name , propertyType , null , null , name ) ;
2010-06-16 08:06:59 -04:00
}
2010-07-21 05:14:23 -04:00
/ * *
* Create field for namespace and name of type propertyType .
*
* @param alias logical name in DavMail
* @param namespace Exchange namespace
* @param name Exchange name
* @param propertyType property type
* @param responseAlias property name in SEARCH response ( as responsealias in request )
* @param cast response cast type ( e . g . bin . base64 )
* @param updateAlias some properties use a different alias in PROPPATCH requests
* /
protected Field ( String alias , Namespace namespace , String name , PropertyType propertyType , String responseAlias , String cast , String updateAlias ) {
this . alias = alias ;
// property name in PROPFIND requests
2010-06-08 18:21:53 -04:00
davPropertyName = DavPropertyName . create ( name , namespace ) ;
2010-07-21 05:14:23 -04:00
// property name in PROPPATCH requests
updatePropertyName = DavPropertyName . create ( updateAlias , namespace ) ;
// a few type based flags
isMultivalued = propertyType ! = null & & propertyType . toString ( ) . endsWith ( " Array " ) ;
2010-07-23 04:58:39 -04:00
isIntValue = propertyType = = PropertyType . Long | | propertyType = = PropertyType . Integer | | propertyType = = PropertyType . Short ;
2010-07-18 17:33:22 -04:00
isBooleanValue = propertyType = = PropertyType . Boolean ;
2011-08-07 05:57:03 -04:00
isFloatValue = propertyType = = PropertyType . Float | | propertyType = = PropertyType . Double ;
2011-08-08 05:06:39 -04:00
isDateValue = propertyType = = PropertyType . SystemTime ;
2010-07-21 05:14:23 -04:00
2010-07-06 11:52:38 -04:00
this . uri = namespace . getURI ( ) + name ;
2010-06-16 08:06:59 -04:00
if ( responseAlias = = null ) {
this . requestPropertyString = '"' + uri + '"' ;
2010-06-17 19:04:38 -04:00
this . responsePropertyName = davPropertyName ;
2010-06-16 08:06:59 -04:00
} else {
this . requestPropertyString = '"' + uri + " \" as " + responseAlias ;
2010-06-17 19:04:38 -04:00
this . responsePropertyName = DavPropertyName . create ( responseAlias , EMPTY ) ;
2010-06-16 08:06:59 -04:00
}
2010-07-01 08:47:57 -04:00
this . cast = cast ;
2010-06-08 18:21:53 -04:00
}
2010-07-21 05:14:23 -04:00
/ * *
* Property uri .
*
* @return uri
* /
2010-06-08 18:21:53 -04:00
public String getUri ( ) {
return uri ;
}
2010-07-21 05:14:23 -04:00
/ * *
* Integer value property type .
*
* @return true if the field value is integer
* /
2010-07-06 05:45:25 -04:00
public boolean isIntValue ( ) {
return isIntValue ;
}
2010-06-08 18:21:53 -04:00
/ * *
* Get Field by alias .
*
* @param alias field alias
* @return field
* /
public static Field get ( String alias ) {
Field field = fieldMap . get ( alias ) ;
if ( field = = null ) {
throw new IllegalArgumentException ( " Unknown field: " + alias ) ;
}
return field ;
}
/ * *
2010-06-28 12:26:08 -04:00
* Get Mime header field .
2010-06-08 18:21:53 -04:00
*
2010-06-28 12:26:08 -04:00
* @param headerName header name
* @return field object
2010-06-08 18:21:53 -04:00
* /
public static Field getHeader ( String headerName ) {
2010-06-10 16:47:55 -04:00
return new Field ( SCHEMAS_MAPI_STRING_INTERNET_HEADERS , headerName ) ;
2010-06-08 18:21:53 -04:00
}
2010-06-09 05:13:13 -04:00
2010-07-21 05:14:23 -04:00
/ * *
* Create DavProperty object for field alias and value .
*
* @param alias DavMail field alias
* @param value field value
* @return DavProperty with value or DavPropertyName for null values
* /
2012-10-08 17:49:34 -04:00
public static PropEntry createDavProperty ( String alias , String value ) {
2010-07-13 05:56:48 -04:00
Field field = Field . get ( alias ) ;
2010-06-11 18:12:37 -04:00
if ( value = = null ) {
// return DavPropertyName to remove property
2010-07-18 18:54:54 -04:00
return field . updatePropertyName ;
2010-07-13 05:56:48 -04:00
} else if ( field . isMultivalued ) {
2010-07-21 05:14:23 -04:00
// multivalued field, split values separated by \n
2010-07-13 05:56:48 -04:00
List < XmlSerializable > valueList = new ArrayList < XmlSerializable > ( ) ;
2012-09-17 17:28:18 -04:00
String [ ] values = value . split ( " , " ) ;
2010-07-13 05:56:48 -04:00
for ( final String singleValue : values ) {
valueList . add ( new XmlSerializable ( ) {
public Element toXml ( Document document ) {
return DomUtil . createElement ( document , " v " , XML , singleValue ) ;
}
} ) ;
}
2010-07-18 18:54:54 -04:00
return new DefaultDavProperty ( field . updatePropertyName , valueList ) ;
2010-07-24 05:45:32 -04:00
} else if ( field . isBooleanValue & & ! " haspicture " . equals ( alias ) ) {
2010-07-18 17:33:22 -04:00
if ( " true " . equals ( value ) ) {
2010-07-18 18:54:54 -04:00
return new DefaultDavProperty ( field . updatePropertyName , " 1 " ) ;
2010-07-21 05:14:23 -04:00
} else if ( " false " . equals ( value ) ) {
2010-07-18 18:54:54 -04:00
return new DefaultDavProperty ( field . updatePropertyName , " 0 " ) ;
2010-07-18 17:33:22 -04:00
} else {
2010-07-21 05:14:23 -04:00
throw new RuntimeException ( " Invalid value for " + field . alias + " : " + value ) ;
2010-07-18 17:33:22 -04:00
}
2010-06-11 18:12:37 -04:00
} else {
2010-07-18 18:54:54 -04:00
return new DefaultDavProperty ( field . updatePropertyName , value ) ;
2010-06-11 18:12:37 -04:00
}
2010-06-09 05:13:13 -04:00
}
2010-06-16 08:06:59 -04:00
2010-07-25 07:34:37 -04:00
/ * *
* Create property value object for field and value .
*
* @param alias field alias
* @param value field value
* @return property value object
* @see ExchangePropPatchMethod
* /
2010-07-24 06:54:27 -04:00
public static PropertyValue createPropertyValue ( String alias , String value ) {
Field field = Field . get ( alias ) ;
DavPropertyName davPropertyName = field . davPropertyName ;
if ( value = = null ) {
// return DavPropertyName to remove property
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) ) ;
} else if ( field . isMultivalued ) {
StringBuilder buffer = new StringBuilder ( ) ;
// multivalued field, split values separated by \n
String [ ] values = value . split ( " \ n " ) ;
for ( final String singleValue : values ) {
2010-07-24 08:38:10 -04:00
buffer . append ( " <v> " ) ;
2010-07-24 06:54:27 -04:00
buffer . append ( StringUtil . xmlEncode ( singleValue ) ) ;
buffer . append ( " </v> " ) ;
}
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) , buffer . toString ( ) ) ;
} else if ( field . isBooleanValue ) {
if ( " true " . equals ( value ) ) {
2011-08-08 05:06:39 -04:00
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) , " 1 " , " boolean " ) ;
2010-07-24 06:54:27 -04:00
} else if ( " false " . equals ( value ) ) {
2011-08-08 05:06:39 -04:00
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) , " 0 " , " boolean " ) ;
2010-07-24 06:54:27 -04:00
} else {
throw new RuntimeException ( " Invalid value for " + field . alias + " : " + value ) ;
}
2011-08-07 05:57:03 -04:00
} else if ( field . isFloatValue ) {
2011-08-08 05:06:39 -04:00
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) , StringUtil . xmlEncode ( value ) , " float " ) ;
2011-08-07 05:57:03 -04:00
} else if ( field . isIntValue ) {
2011-08-08 05:06:39 -04:00
return new PropertyValue ( field . updatePropertyName . getNamespace ( ) . getURI ( ) , field . updatePropertyName . getName ( ) , StringUtil . xmlEncode ( value ) , " int " ) ;
} else if ( field . isDateValue ) {
return new PropertyValue ( field . updatePropertyName . getNamespace ( ) . getURI ( ) , field . updatePropertyName . getName ( ) , StringUtil . xmlEncode ( value ) , " dateTime.tz " ) ;
2010-07-24 06:54:27 -04:00
} else {
return new PropertyValue ( davPropertyName . getNamespace ( ) . getURI ( ) , davPropertyName . getName ( ) , StringUtil . xmlEncode ( value ) ) ;
}
}
2010-07-21 05:14:23 -04:00
/ * *
* SEARCH request property name for alias
*
* @param alias field alias
* @return request property string
* /
public static String getRequestPropertyString ( String alias ) {
return Field . get ( alias ) . requestPropertyString ;
}
2010-06-16 08:06:59 -04:00
2010-07-21 05:14:23 -04:00
/ * *
* PROPFIND request property name
*
* @param alias field alias
* @return request property name
* /
2010-06-16 09:30:36 -04:00
public static DavPropertyName getPropertyName ( String alias ) {
2010-06-16 08:06:59 -04:00
return Field . get ( alias ) . davPropertyName ;
}
2010-07-21 05:14:23 -04:00
/ * *
* SEARCH response property name
*
* @param alias field alias
* @return response property name
* /
2010-06-17 19:04:38 -04:00
public static DavPropertyName getResponsePropertyName ( String alias ) {
return Field . get ( alias ) . responsePropertyName ;
}
2010-06-08 18:21:53 -04:00
}