Calendar Import and Export
Intro
Import and export scripts are now included with the Calendar Portlet. These scripts will import and export calendar data to and from XML files. The exports include:
- Predefined Calendar Definitions (.pcd.xml)
<predefined-calendar script="classpath:/org/jasig/portlet/calendar/io/import-PredefinedCalendarDefinition_v1-0.crn.xml"> <fname>us_holidays</fname> <className>httpIcalAdapter</className> <name>US Holidays</name> <parameters> <parameter name="url">http://ical.mac.com/ical/US32Holidays.ics</parameter> </parameters> <!-- predefinedRoles are role-based default subscriptions to the calendar. --> Â <predefinedRoles> <role>everyone</role> </predefinedRoles> </predefined-calendar>
- Predefined Calendar Subscriptions (.pcs.xml)
<predefined-calendar-sub script="classpath:/org/jasig/portlet/calendar/io/import-PredefinedCalendarSubscription_v1-0.crn.xml"> <subscribeId>student</subscribeId> <predefined-calendar>US Holidays</predefined-calendar> <!-- set displayed=false to decline subscription to a calendar (which may by default be subscribed via predefinedRoles). --> Â <displayed>true</displayed> <preferences/> </predefined-calendar-sub>
- User Defined Calendars (.ucd.xml)
<user-calendar script="classpath:/org/jasig/portlet/calendar/io/import-UserDefinedCalendar_v1-0.crn.xml"> <subscribeId>student</subscribeId> <className>httpIcalAdapter</className> <name>Google</name> <displayed>true</displayed> <parameters> <parameter name="url">http://www.google.com/calendar/ical/foo/calendar.ics</parameter> </parameters> </user-calendar>
Importing/Exporting Data
To import or export calendar data, you need to build the calendar portlet following the steps at Calendar Portlet Configuration. Once that's complete, run the following commands:
Export
# Calendar 2.1.1 and later mvn -Ddir=export-directory data-export # Pre 2.1.1 mvn antrun:run -Dexport -Ddir=export-directory
Each of the above entities (predefined calendar definitions and subscriptions, and user-defined calendars) will be exported to its own XML file.
Import
# Calendar 2.1.1 and later mvn -Ddir=import-directory data-import # Pre 2.1.1 mvn antrun:run -Dimport -Ddir=import-directory
The import directory provided will be scanned for all files of the above file types (.pcd.xml, .pcs.xml, .ucd.xml), and those calendar entities will be imported into the database. If an entity already exists in the database, the calendar information is updated, not duplicated.
Dropping and recreating db tables
# Calendar 2.1.1 and later mvn db-init