[CalendarServer-changes] [13133] CalendarServer/branches/users/sagen

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 2 15:13:15 PDT 2014


Revision: 13133
          http://trac.calendarserver.org//changeset/13133
Author:   gaya at apple.com
Date:     2014-04-02 15:13:14 -0700 (Wed, 02 Apr 2014)
Log Message:
-----------
enable CDT <feature>directory-gateway</feature> and get gateway tests working with new GUIDs.  More fixes in server directory-gateway code.

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directorybackedaddressbook.py
    CalendarServer/branches/users/sagen/move2who-4/txdav/who/vcard.py
    CalendarServer/branches/users/sagen/move2who-cdt/Resource/CardDAV/vreports/searchquery/16.xml
    CalendarServer/branches/users/sagen/move2who-cdt/scripts/server/serverinfo.xml
    CalendarServer/branches/users/sagen/move2who-cdt/scripts/tests/CardDAV/reports.xml

Added Paths:
-----------
    CalendarServer/branches/users/sagen/move2who-4/calendarserver/platform/darwin/od/

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directorybackedaddressbook.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directorybackedaddressbook.py	2014-04-02 21:27:52 UTC (rev 13132)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directorybackedaddressbook.py	2014-04-02 22:13:14 UTC (rev 13133)
@@ -37,8 +37,8 @@
 from txdav.carddav.datastore.query.filter import IsNotDefined, TextMatch, \
     ParameterFilter
 from txdav.who.idirectory import FieldName as CalFieldName
-from txdav.who.vcard import vCardKindToRecordTypeMap, vCardPropToParamMap, \
-    vCardConstantProperties, vCardFromRecord
+from txdav.who.vcard import vCardKindToRecordTypeMap, recordTypeToVCardKindMap, \
+    vCardPropToParamMap, vCardConstantProperties, vCardFromRecord
 from txdav.xml import element as davxml
 from txdav.xml.base import twisted_dav_namespace, dav_namespace, parse_date, \
     twisted_private_namespace
@@ -200,10 +200,11 @@
                         Operand.AND
                     )
             elif expression is True: # True means all records
+                allowedRecordTypes = set(self.directory.recordTypes()) & set(recordTypeToVCardKindMap.keys())
                 expression = CompoundExpression(
                     [
                         MatchExpression(FieldName.recordType, recordType, MatchType.equals)
-                            for recordType in self.directory.recordTypes()
+                            for recordType in allowedRecordTypes
                     ], Operand.OR
                 )
 
@@ -344,32 +345,32 @@
                 # special case recordType field
                 if fieldName == FieldName.recordType:
                     # change kind to record type
-                    uMatchString = vCardKindToRecordTypeMap.get(matchString)
-                    if uMatchString is None:
-                        uMatchString = NamedConstant()
-                        uMatchString.description = u""
+                    matchValue = vCardKindToRecordTypeMap.get(matchString.lower())
+                    if matchValue is None:
+                        matchValue = NamedConstant()
+                        matchValue.description = u""
 
                     # change types and flags
                     matchFlags &= ~MatchFlags.caseInsensitive
                     matchType = MatchType.equals
-                elif fieldName == FieldName.uid:
-                    # special case uid until I figure out how to do a case-sens collation
-                    matchFlags &= ~MatchFlags.caseInsensitive
-                    uMatchString = matchString.decode("utf-8")
                 else:
-                    uMatchString = matchString.decode("utf-8")
+                    matchValue = matchString.decode("utf-8")
 
-                return MatchExpression(fieldName, uMatchString, matchType, matchFlags)
+                return MatchExpression(fieldName, matchValue, matchType, matchFlags)
 
 
             def definedExpression(defined, allOf):
                 if constant or propFilter.filter_name in ("N" , "FN", "UID", "SOURCE", "KIND",):
                     return defined  # all records have this property so no records do not have it
                 else:
+                    # FIXME: The startsWith expression below, which works with LDAP and OD. is not currently supported
+                    return True
+                    '''
                     # this may generate inefficient LDAP query string
                     matchFlags = MatchFlags_none if defined else MatchFlags.NOT
                     matchList = [matchExpression(fieldName, "", MatchType.startsWith, matchFlags) for fieldName in searchableFields]
                     return andOrExpression(allOf, matchList)
+                    '''
 
 
             def andOrExpression(propFilterAllOf, matchList):
@@ -472,7 +473,7 @@
                             else:
                                 matchFlags = MatchFlags_none
 
-                            matchList = [matchExpression(fieldName, matchString.decode("utf-8"), matchType, matchFlags) for fieldName in searchableFields]
+                            matchList = [matchExpression(fieldName, matchString, matchType, matchFlags) for fieldName in searchableFields]
                             matchList.extend(matchList)
                         return andOrExpression(propFilterAllOf, matchList)
 
@@ -595,8 +596,8 @@
     '''
 
     @inlineCallbacks
-    def generate(self, record, kind=None, addProps=None,):
-        self._vCard = yield vCardFromRecord(record, kind, addProps, None)
+    def generate(self, record, forceKind=None, addProps=None,):
+        self._vCard = yield vCardFromRecord(record, forceKind, addProps, None)
         returnValue(self)
 
 

Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/vcard.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/vcard.py	2014-04-02 21:27:52 UTC (rev 13132)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/vcard.py	2014-04-02 22:13:14 UTC (rev 13133)
@@ -82,7 +82,7 @@
 
 
 @inlineCallbacks
-def vCardFromRecord(record, kind=None, addProps=None, parentURI=None):
+def vCardFromRecord(record, forceKind=None, addProps=None, parentURI=None):
 
     def isUniqueProperty(newProperty, ignoredParameters={}):
         existingProperties = vcard.properties(newProperty.name())
@@ -110,11 +110,13 @@
     # start
     #=======================================================================
 
-    log.debug("vCardFromRecord: record={record}, kind={kind}, addProps={addProps}, parentURI={parentURI}",
-                   record=record, kind=kind, addProps=addProps, parentURI=parentURI)
+    log.debug("vCardFromRecord: record={record}, forceKind={forceKind}, addProps={addProps}, parentURI={parentURI}",
+                   record=record, forceKind=forceKind, addProps=addProps, parentURI=parentURI)
 
-    if kind is None:
+    if forceKind is None:
         kind = recordTypeToVCardKindMap.get(record.recordType, "individual")
+    else:
+        kind = forceKind
 
     constantProperties = vCardConstantProperties.copy()
     if addProps:
@@ -239,8 +241,12 @@
     #
     # UNIMPLEMENTED:
     #     3.4.1 TZ
-    #     3.4.2 GEO
     #
+    # 3.4.2 GEO
+    geographicLocation = record.fields.get(CalFieldName.geographicLocation)
+    if geographicLocation:
+        vcard.addProperty(Property("GEO", geographicLocation.encode("utf-8")))
+
     #===================================================================
     # 3.5 ORGANIZATIONAL TYPES http://tools.ietf.org/html/rfc2426#section-3.5
     #===================================================================
@@ -295,12 +301,6 @@
     #    X-PHONETIC-LAST-NAME
     #    X-ABRELATEDNAMES
 
-    # X-GEOLOCATION
-    # TODO: Just made this up.  Check for standard.  Perhaps GEO can be pulled out
-    geographicLocation = record.fields.get(CalFieldName.geographicLocation)
-    if geographicLocation:
-        vcard.addProperty(Property("X-GEOLOCATION", geographicLocation.encode("utf-8")))
-
     # X-ADDRESSBOOKSERVER-KIND
     if kind == "group":
         vcard.addProperty(Property("X-ADDRESSBOOKSERVER-KIND", kind))

Modified: CalendarServer/branches/users/sagen/move2who-cdt/Resource/CardDAV/vreports/searchquery/16.xml
===================================================================
--- CalendarServer/branches/users/sagen/move2who-cdt/Resource/CardDAV/vreports/searchquery/16.xml	2014-04-02 21:27:52 UTC (rev 13132)
+++ CalendarServer/branches/users/sagen/move2who-cdt/Resource/CardDAV/vreports/searchquery/16.xml	2014-04-02 22:13:14 UTC (rev 13133)
@@ -13,7 +13,7 @@
        <C:prop-filter name="X-ADDRESSBOOKSERVER-MEMBER">
          <C:text-match collation="i;unicode-casemap"
                        match-type="contains"
-         >group</C:text-match>
+         >$groupguid3:</C:text-match>
        </C:prop-filter>
      </C:filter>
    </C:addressbook-query>

Modified: CalendarServer/branches/users/sagen/move2who-cdt/scripts/server/serverinfo.xml
===================================================================
--- CalendarServer/branches/users/sagen/move2who-cdt/scripts/server/serverinfo.xml	2014-04-02 21:27:52 UTC (rev 13132)
+++ CalendarServer/branches/users/sagen/move2who-cdt/scripts/server/serverinfo.xml	2014-04-02 22:13:14 UTC (rev 13133)
@@ -109,7 +109,7 @@
 		<feature>carddav</feature> 						<!-- Basic CardDAV feature enabler -->
 		<feature>default-addressbook</feature> 			<!-- Default address book behavior -->
 		<feature>shared-addressbooks</feature>			<!-- Shared address books extension -->
-		<!-- <feature>directory-gateway</feature> -->	<!-- Directory gateway extension -->
+		<feature>directory-gateway</feature>			<!-- Directory gateway extension -->
 
 	</features>
 

Modified: CalendarServer/branches/users/sagen/move2who-cdt/scripts/tests/CardDAV/reports.xml
===================================================================
--- CalendarServer/branches/users/sagen/move2who-cdt/scripts/tests/CardDAV/reports.xml	2014-04-02 21:27:52 UTC (rev 13132)
+++ CalendarServer/branches/users/sagen/move2who-cdt/scripts/tests/CardDAV/reports.xml	2014-04-02 22:13:14 UTC (rev 13133)
@@ -1326,16 +1326,28 @@
 						<value>$groupguid4:.vcf</value>
 						<value>$groupguid5:.vcf</value>
 						<value>$groupguid6:.vcf</value>
+						<value>$groupguid7:.vcf</value>
+						<value>$groupguid8:.vcf</value>
+						<value>$groupguid9:.vcf</value>
+						<value>$groupguid10:.vcf</value>
+						<value>$groupguid20:.vcf</value>
+						<value>$groupguid30:.vcf</value>
+						<value>$groupguid40:.vcf</value>
+						<value>$groupguid50:.vcf</value>
+						<value>$groupguid60:.vcf</value>
+						<value>$groupguid70:.vcf</value>
+						<value>$groupguid80:.vcf</value>
+						<value>$groupguid90:.vcf</value>
 					</arg>
 					<arg>
 						<name>totalcount</name>
-						<value>7</value>
+						<value>19</value>
 					</arg>
 				</verify>
 			</request>
 		</test>
 		<test name="16" ignore="no">
-			<description>query for resources with (KIND equal "group") and (X-ADDRESSBOOKSERVER-MEMBER contains "group"), no eTag, no props " </description>
+			<description>query for resources with (KIND equal "group") and (X-ADDRESSBOOKSERVER-MEMBER contains $groupguid3:), no eTag, no props " </description>
 			<request print-response="no">
 				<method>REPORT</method>
 				<ruri>$directory:</ruri>
@@ -1348,11 +1360,10 @@
 					<arg>
 						<name>okhrefs</name>
 						<value>$groupguid4:.vcf</value>
-						<value>$groupguid5:.vcf</value>
 					</arg>
 					<arg>
 						<name>totalcount</name>
-						<value>2</value>
+						<value>1</value>
 					</arg>
 				</verify>
 			</request>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140402/6a647d79/attachment-0001.html>


More information about the calendarserver-changes mailing list