<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14031] CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14031">14031</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-09-30 09:22:02 -0700 (Tue, 30 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update augments.xml during upgrade</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectoryaugmentpy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/augment.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectorytesttest_augmentpy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_augment.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectorytesttest_principalpy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_principal.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavstdconfigpy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavtesttest_upgradepy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/test/test_upgrade.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavupgradepy">CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/upgrade.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectoryaugmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/augment.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/augment.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/augment.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -25,8 +25,6 @@
</span><span class="cx"> from twext.python.log import Logger
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.config import fullServerPath, config
</span><del>-from twistedcaldav.database import AbstractADBAPIDatabase, ADBAPISqliteMixin, \
- ADBAPIPostgreSQLMixin
</del><span class="cx"> from twistedcaldav.directory import xmlaugmentsparser
</span><span class="cx"> from twistedcaldav.directory.xmlaugmentsparser import XMLAugmentsParser
</span><span class="cx"> from twistedcaldav.xmlutil import newElementTreeWithRoot, addSubElement, \
</span><span class="lines">@@ -469,13 +467,11 @@
</span><span class="cx"> def _updateRecordInXMLDB(self, record, recordNode):
</span><span class="cx"> del recordNode[:]
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_UID, record.uid)
</span><del>- addSubElement(recordNode, xmlaugmentsparser.ELEMENT_ENABLE, "true" if record.enabled else "false")
</del><span class="cx"> if record.serverID:
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_SERVERID, record.serverID)
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_ENABLECALENDAR, "true" if record.enabledForCalendaring else "false")
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_ENABLEADDRESSBOOK, "true" if record.enabledForAddressBooks else "false")
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_ENABLELOGIN, "true" if record.enabledForLogin else "false")
</span><del>- addSubElement(recordNode, xmlaugmentsparser.ELEMENT_AUTOSCHEDULE, "true" if record.autoSchedule else "false")
</del><span class="cx"> if record.autoScheduleMode:
</span><span class="cx"> addSubElement(recordNode, xmlaugmentsparser.ELEMENT_AUTOSCHEDULE_MODE, record.autoScheduleMode)
</span><span class="cx"> if record.autoAcceptGroup:
</span><span class="lines">@@ -556,235 +552,3 @@
</span><span class="cx"> self.xmlFileStats[xmlFile] = (newModTime, newSize)
</span><span class="cx">
</span><span class="cx"> return results
</span><del>-
-
-
-class AugmentADAPI(AugmentDB, AbstractADBAPIDatabase):
- """
- DBAPI based augment database implementation.
- """
-
- schema_version = "3"
- schema_type = "AugmentDB"
-
- def __init__(self, dbID, dbapiName, dbapiArgs, **kwargs):
-
- AugmentDB.__init__(self)
- AbstractADBAPIDatabase.__init__(self, dbID, dbapiName, dbapiArgs, True, **kwargs)
-
-
- @inlineCallbacks
- def getAllUIDs(self):
- """
- Get all AugmentRecord UIDs.
-
- @return: L{Deferred}
- """
-
- # Query for the record information
- results = (yield self.queryList("select UID from AUGMENTS", ()))
- returnValue(results)
-
-
- @inlineCallbacks
- def _lookupAugmentRecord(self, uid):
- """
- Get an AugmentRecord for the specified UID.
-
- @param uid: directory UID to lookup
- @type uid: C{str}
-
- @return: L{Deferred}
- """
-
- # Query for the record information
- results = (yield self.query("select UID, ENABLED, SERVERID, CALENDARING, ADDRESSBOOKS, AUTOSCHEDULE, AUTOSCHEDULEMODE, AUTOACCEPTGROUP, LOGINENABLED from AUGMENTS where UID = :1", (uid,)))
- if not results:
- returnValue(None)
- else:
- uid, enabled, serverid, enabledForCalendaring, enabledForAddressBooks, autoSchedule, autoScheduleMode, autoAcceptGroup, enabledForLogin = results[0]
-
- record = AugmentRecord(
- uid=uid,
- enabled=enabled == "T",
- serverID=serverid,
- enabledForCalendaring=enabledForCalendaring == "T",
- enabledForAddressBooks=enabledForAddressBooks == "T",
- enabledForLogin=enabledForLogin == "T",
- autoSchedule=autoSchedule == "T",
- autoScheduleMode=autoScheduleMode,
- autoAcceptGroup=autoAcceptGroup,
- )
-
- returnValue(record)
-
-
- @inlineCallbacks
- def addAugmentRecords(self, records):
-
- for record in records:
-
- results = (yield self.query("select UID from AUGMENTS where UID = :1", (record.uid,)))
- update = len(results) > 0
-
- if update:
- yield self._modifyRecord(record)
- else:
- yield self._addRecord(record)
-
-
- @inlineCallbacks
- def removeAugmentRecords(self, uids):
- """
- Remove AugmentRecords with the specified UIDs.
-
- @param uids: list of uids to remove
- @type uids: C{list} of C{str}
-
- @return: L{Deferred}
- """
-
- for uid in uids:
- yield self.execute("delete from AUGMENTS where UID = :1", (uid,))
-
-
- def clean(self):
- """
- Remove all records.
- """
-
- return self.execute("delete from AUGMENTS", ())
-
-
- def _db_version(self):
- """
- @return: the schema version assigned to this index.
- """
- return AugmentADAPI.schema_version
-
-
- def _db_type(self):
- """
- @return: the collection type assigned to this index.
- """
- return AugmentADAPI.schema_type
-
-
- @inlineCallbacks
- def _db_init_data_tables(self):
- """
- Initialize the underlying database tables.
- """
-
- #
- # AUGMENTS table
- #
- yield self._create_table(
- "AUGMENTS",
- (
- ("UID", "text unique"),
- ("ENABLED", "text(1)"),
- ("SERVERID", "text"),
- ("CALENDARING", "text(1)"),
- ("ADDRESSBOOKS", "text(1)"),
- ("AUTOSCHEDULE", "text(1)"),
- ("AUTOSCHEDULEMODE", "text"),
- ("AUTOACCEPTGROUP", "text"),
- ("LOGINENABLED", "text(1)"),
- ),
- ifnotexists=True,
- )
-
-
- @inlineCallbacks
- def _db_empty_data_tables(self):
- yield self._db_execute("delete from AUGMENTS")
-
-
-
-class AugmentSqliteDB(ADBAPISqliteMixin, AugmentADAPI):
- """
- Sqlite based augment database implementation.
- """
-
- def __init__(self, dbpath):
-
- ADBAPISqliteMixin.__init__(self)
- AugmentADAPI.__init__(self, "Augments", "sqlite3", (fullServerPath(config.DataRoot, dbpath),))
-
-
- @inlineCallbacks
- def _addRecord(self, record):
- yield self.execute(
- """insert or replace into AUGMENTS
- (UID, ENABLED, SERVERID, CALENDARING, ADDRESSBOOKS, AUTOSCHEDULE, AUTOSCHEDULEMODE, AUTOACCEPTGROUP, LOGINENABLED)
- values (:1, :2, :3, :4, :5, :6, :7, :8, :9)""",
- (
- record.uid,
- "T" if record.enabled else "F",
- record.serverID,
- "T" if record.enabledForCalendaring else "F",
- "T" if record.enabledForAddressBooks else "F",
- "T" if record.autoSchedule else "F",
- record.autoScheduleMode if record.autoScheduleMode else "",
- record.autoAcceptGroup,
- "T" if record.enabledForLogin else "F",
- )
- )
-
-
- def _modifyRecord(self, record):
- return self._addRecord(record)
-
-
-
-class AugmentPostgreSQLDB(ADBAPIPostgreSQLMixin, AugmentADAPI):
- """
- PostgreSQL based augment database implementation.
- """
-
- def __init__(self, host, database, user=None, password=None):
-
- ADBAPIPostgreSQLMixin.__init__(self)
- AugmentADAPI.__init__(self, "Augments", "pgdb", (), host=host, database=database, user=user, password=password,)
-
-
- @inlineCallbacks
- def _addRecord(self, record):
- yield self.execute(
- """insert into AUGMENTS
- (UID, ENABLED, SERVERID, CALENDARING, ADDRESSBOOKS, AUTOSCHEDULE, AUTOSCHEDULEMODE, AUTOACCEPTGROUP, LOGINENABLED)
- values (:1, :2, :3, :4, :5, :6, :7, :8, :9)""",
- (
- record.uid,
- "T" if record.enabled else "F",
- record.serverID,
- "T" if record.enabledForCalendaring else "F",
- "T" if record.enabledForAddressBooks else "F",
- "T" if record.autoSchedule else "F",
- record.autoScheduleMode if record.autoScheduleMode else "",
- record.autoAcceptGroup,
- "T" if record.enabledForLogin else "F",
- )
- )
-
-
- @inlineCallbacks
- def _modifyRecord(self, record):
- yield self.execute(
- """update AUGMENTS set
- (UID, ENABLED, SERVERID, CALENDARING, ADDRESSBOOKS, AUTOSCHEDULE, AUTOSCHEDULEMODE, AUTOACCEPTGROUP, LOGINENABLED) =
- (:1, :2, :3, :4, :5, :6, :7, :8, :9) where UID = :10""",
- (
- record.uid,
- "T" if record.enabled else "F",
- record.serverID,
- "T" if record.enabledForCalendaring else "F",
- "T" if record.enabledForAddressBooks else "F",
- "T" if record.autoSchedule else "F",
- record.autoScheduleMode if record.autoScheduleMode else "",
- record.autoAcceptGroup,
- "T" if record.enabledForLogin else "F",
- record.uid,
- )
- )
</del></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectorytesttest_augmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_augment.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_augment.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_augment.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -15,8 +15,7 @@
</span><span class="cx"> ##
</span><span class="cx">
</span><span class="cx"> from twistedcaldav.test.util import TestCase
</span><del>-from twistedcaldav.directory.augment import AugmentXMLDB, AugmentSqliteDB, \
- AugmentPostgreSQLDB, AugmentRecord
</del><ins>+from twistedcaldav.directory.augment import AugmentXMLDB, AugmentRecord
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks
</span><span class="cx"> from twistedcaldav.directory.xmlaugmentsparser import XMLAugmentsParser
</span><span class="cx"> import cStringIO
</span><span class="lines">@@ -342,26 +341,3 @@
</span><span class="cx"> uids = list(self.uidsFromFile(newxmlfile.path))
</span><span class="cx"> self.assertEquals(uids, ['AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA'])
</span><span class="cx">
</span><del>-
-
-class AugmentSqliteTests(AugmentTests, AugmentTestsMixin):
-
- def _db(self, dbpath=None):
- return AugmentSqliteDB(dbpath if dbpath else os.path.abspath(self.mktemp()))
-
-
-
-class AugmentPostgreSQLTests(AugmentTests, AugmentTestsMixin):
-
- def _db(self, dbpath=None):
- return AugmentPostgreSQLDB("localhost", "augments")
-
-try:
- import pgdb
-except ImportError:
- AugmentPostgreSQLTests.skip = True
-else:
- try:
- db = pgdb.connect(host="localhost", database="augments")
- except:
- AugmentPostgreSQLTests.skip = True
</del></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavdirectorytesttest_principalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_principal.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_principal.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/directory/test/test_principal.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -429,9 +429,6 @@
</span><span class="cx"> yield hasProperty(
</span><span class="cx"> (calendarserver_namespace, "calendar-proxy-write-for")
</span><span class="cx"> )
</span><del>- # yield hasProperty(
- # (calendarserver_namespace, "auto-schedule")
- # )
</del><span class="cx"> else:
</span><span class="cx"> yield doesNotHaveProperty(
</span><span class="cx"> (caldav_namespace, "calendar-home-set")
</span><span class="lines">@@ -454,9 +451,6 @@
</span><span class="cx"> yield doesNotHaveProperty(
</span><span class="cx"> (calendarserver_namespace, "calendar-proxy-write-for")
</span><span class="cx"> )
</span><del>- # yield doesNotHaveProperty(
- # (calendarserver_namespace, "auto-schedule")
- # )
</del><span class="cx">
</span><span class="cx"> if record.hasContacts:
</span><span class="cx"> yield hasProperty(carddavxml.AddressBookHomeSet.qname())
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/stdconfig.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/stdconfig.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/stdconfig.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -101,15 +101,6 @@
</span><span class="cx"> "xmlFiles": ["augments.xml", ],
</span><span class="cx"> "statSeconds": 15,
</span><span class="cx"> },
</span><del>- "twistedcaldav.directory.augment.AugmentSqliteDB": {
- "dbpath": "augments.sqlite",
- },
- "twistedcaldav.directory.augment.AugmentPostgreSQLDB": {
- "host": "localhost",
- "database": "augments",
- "user": "",
- "password": "",
- },
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavtesttest_upgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/test/test_upgrade.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/test/test_upgrade.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/test/test_upgrade.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> xattrname, upgradeData, updateFreeBusySet,
</span><span class="cx"> removeIllegalCharacters, normalizeCUAddrs,
</span><span class="cx"> loadDelegatesFromXMLintoProxyDB, migrateDelegatesToStore,
</span><del>- upgradeResourcesXML
</del><ins>+ upgradeResourcesXML, upgradeAugmentsXML
</ins><span class="cx"> )
</span><span class="cx"> from txdav.caldav.datastore.index_file import db_basename
</span><span class="cx"> from txdav.caldav.datastore.scheduling.imip.mailgateway import MailGatewayTokensDatabase
</span><span class="lines">@@ -1514,6 +1514,17 @@
</span><span class="cx"> self.assertEquals(fp.getContent(), newResourcesFormat)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ def test_augmentsXML(self):
+ """
+ Verify conversion of old augments.xml auto-schedule related elements to twext.who format
+ """
+ fileName = self.mktemp()
+ fp = FilePath(fileName)
+ fp.setContent(oldAugmentsFormat)
+ upgradeAugmentsXML(fp)
+ self.assertEquals(fp.getContent(), newAugmentsFormat)
+
+
</ins><span class="cx"> oldResourcesFormat = """<accounts realm="/Search">
</span><span class="cx"> <location>
</span><span class="cx"> <uid>location1</uid>
</span><span class="lines">@@ -1536,6 +1547,58 @@
</span><span class="cx"> newResourcesFormat = """<directory realm="/Search"><record type="location"><short-name>location1</short-name><guid>C4F46062-9094-4D34-8591-61A42D993FAA</guid><uid>C4F46062-9094-4D34-8591-61A42D993FAA</uid><full-name>location name</full-name></record><record type="location"><short-name>5456580A-08EE-4288-8A87-2B4204A62A12</short-name><guid>5456580A-08EE-4288-8A87-2B4204A62A12</guid><uid>5456580A-08EE-4288-8A87-2B4204A62A12</uid><full-name>Fake Room</full-name></record><record type="resource"><short-name>resource1</short-name><guid>60B771CC-D727-4453-ACE0-0FE13CD7445A</guid><uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid><full-name>resource name</full-name></record></directory>"""
</span><span class="cx">
</span><span class="cx">
</span><ins>+
+
+oldAugmentsFormat = """<augments>
+ <record>
+ <uid>9F3603DD-65D0-480D-A1D1-5D33CAC41A13</uid>
+ <enable>true</enable>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule>false</auto-schedule>
+ <auto-schedule-mode>default</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>6A49C436-4CDB-4184-AD87-6F945040E37A</uid>
+ <enable>true</enable>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule>true</auto-schedule>
+ </record>
+ <record>
+ <uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid>
+ <enable>true</enable>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule-mode>none</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>E173AADC-4642-43CB-9745-8CE436A6FE4A</uid>
+ <enable>false</enable>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule>false</auto-schedule>
+ <auto-schedule-mode>automatic</auto-schedule-mode>
+ </record>
+ <record>
+ <uid>FC9A7F56-CCCA-4401-9160-903902880A37</uid>
+ <enable>false</enable>
+ <enable-calendar>true</enable-calendar>
+ <enable-addressbook>true</enable-addressbook>
+ <enable-login>true</enable-login>
+ <auto-schedule>true</auto-schedule>
+ <auto-schedule-mode>accept-if-free</auto-schedule-mode>
+ </record>
+</augments>
+"""
+
+newAugmentsFormat = """<augments>\n <record>\n <uid>9F3603DD-65D0-480D-A1D1-5D33CAC41A13</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mode>\n </record>\n <record>\n <uid>6A49C436-4CDB-4184-AD87-6F945040E37A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n </record>\n <record>\n <uid>60B771CC-D727-4453-ACE0-0FE13CD7445A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mode>\n </record>\n <record>\n <uid>E173AADC-4642-43CB-9745-8CE436A6FE4A</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>none</auto-schedule-mode>\n </record>\n <record>\n <uid>FC9A7F56-CCCA-4401-9160-903902880A37</uid>\n <enable-calendar>true</enable-calendar>\n <enable-addressbook>true</enable-addressbook>\n <enable-login>true</enable-login>\n <auto-schedule-mode>accept-if-free</auto-schedule-mode>\n </record>\n</augments>"""
+
+
</ins><span class="cx"> normalizeEvent = """BEGIN:VCALENDAR
</span><span class="cx"> VERSION:2.0
</span><span class="cx"> BEGIN:VEVENT
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer60devtwistedcaldavupgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/upgrade.py (14030 => 14031)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/upgrade.py        2014-09-30 14:24:55 UTC (rev 14030)
+++ CalendarServer/branches/release/CalendarServer-6.0-dev/twistedcaldav/upgrade.py        2014-09-30 16:22:02 UTC (rev 14031)
</span><span class="lines">@@ -707,6 +707,47 @@
</span><span class="cx"> resourcesFilePath.setContent(etreeToString(directoryNode, "utf-8"))
</span><span class="cx">
</span><span class="cx">
</span><ins>+def upgradeAugmentsXML(augmentsFilePath):
+ """
+ Convert the old augments XML auto-schedule related elements to the twext.who.xml format
+
+ @param augmentsFilePath: the file to convert
+ @type augmentsFilePath: L{FilePath}
+ """
+ try:
+ with augmentsFilePath.open() as fh:
+ try:
+ etree = parseXML(fh)
+ except XMLParseError:
+ log.error("Cannot parse {path}", path=augmentsFilePath.path)
+ return
+ except (OSError, IOError):
+ # Can't read the file
+ log.error("Cannot read {path}", path=augmentsFilePath.path)
+ return
+
+ augmentsNode = etree.getroot()
+ if augmentsNode.tag != "augments":
+ return
+
+ log.info("Converting augments.xml")
+ for recordNode in augmentsNode:
+
+ autoScheduleElement = recordNode.find("auto-schedule")
+ if autoScheduleElement is not None:
+ if autoScheduleElement.text == "false":
+ autoScheduleModeElement = recordNode.find("auto-schedule-mode")
+ if autoScheduleModeElement is not None:
+ autoScheduleModeElement.text = "none"
+ recordNode.remove(autoScheduleElement)
+
+ enableElement = recordNode.find("enable")
+ if enableElement is not None:
+ recordNode.remove(enableElement)
+
+ augmentsFilePath.setContent(etreeToString(augmentsNode, "utf-8"))
+
+
</ins><span class="cx"> # The on-disk version number (which defaults to zero if .calendarserver_version
</span><span class="cx"> # doesn't exist), is compared with each of the numbers in the upgradeMethods
</span><span class="cx"> # array. If it is less than the number, the associated method is called.
</span><span class="lines">@@ -728,6 +769,14 @@
</span><span class="cx"> if resourcesFilePath.exists():
</span><span class="cx"> upgradeResourcesXML(resourcesFilePath)
</span><span class="cx">
</span><ins>+ if config.AugmentService.type == "twistedcaldav.directory.augment.AugmentXMLDB":
+ for fileName in config.AugmentService.params.xmlFiles:
+ if fileName[0] not in ("/", "."):
+ fileName = os.path.join(config.DataRoot, fileName)
+ filePath = FilePath(fileName)
+ if filePath.exists():
+ upgradeAugmentsXML(filePath)
+
</ins><span class="cx"> triggerPath = os.path.join(config.ServerRoot, TRIGGER_FILE)
</span><span class="cx"> if os.path.exists(triggerPath):
</span><span class="cx"> try:
</span></span></pre>
</div>
</div>
</body>
</html>