Upload
darcy-heath
View
212
Download
0
Embed Size (px)
Citation preview
XML Import & Exportfor uP 2 Using Cernunnos
Andrew Petro & Drew WillsApril 2007 uPortal Dev Meeting
Johns Hopkins University
© Copyright Unicon, Inc., 2006. This work is the intellectual property of Unicon, Inc. Permission is granted for this material to be shared for non-commercial, educational purposes, provided that this copyright statement appears on the reproduced materials and notice is given that the copying is by permission of Unicon, Inc. To disseminate otherwise or to republish requires written permission from Unicon, Inc.
Introduction
• These slides provide some basic information
about a prototype Import/Export tool
developed for uPortal 2.5 and later by Drew
Wills
• Much more information is available on the
wiki page describing today’s discussion:
uP2 XML import export 2007 JHU Dev Meeting Slot
Motivation
• uPortal doesn’t work without some basic data
– Users
– Groups
– Channels
– Layouts
– etc.
• Although every uPortal release comes with a viable
data set, every institution needs to customize this
data extensively to meet their individual needs
Motivation (Cont.)
• Editing this data where it lives (i.e. data.xml)
is confusing, tedious, and risky!
• Using uPortal’s UI to edit the data isn’t
reproducible by automated means
Solution
• Storing the data in XML is great because
tools like Subversion can manage it smoothly
• But the XML format used by data.xml is
inaccessible to human beings
• It would be better to store this data in a
collection of smaller XML documents with
domain-specific schemas
Solution (Cont.)
• These documents can be more succinct and
manageable by conveying information
structurally that data.xml must convey
explicitly (e.g parent-child relationships, entity
types)
• Also these documents can avoid referencing
database IDs, allowing entities to be imported
and exported ad hoc – even from one portal
database to another!
Example XML Document
<layout username="student" script="classpath://org/jasig/portal/layout/simple/import-layout.crn">
<root name="Root folder" immutable="N" unremovable="Y">
<header name="Header folder" immutable="Y" unremovable="Y">
<channel fname="header"/>
<channel fname="portal/login/general"/>
</header>
<tab name="Main Student Tab" immutable="N" unremovable="N">
<column name="Column 2" immutable="N" unremovable="N">
<channel fname="salon.com"/>
</column>
<column name="Column 1" immutable="N" unremovable="N">
<channel fname="minesweeper"/>
<channel fname="word-of-the-day"/>
<channel fname="number-guessing-game"/>
</column>
</tab>
<footer name="Footer folder" immutable="N" unremovable="N">
<channel fname="footer"/>
</footer>
</root>
</layout>
Data in uPortal
• Information in the portal database represents the following classes of entities:
– Minor Items (version info., sequences, etc.)
– Users
– Groups
– Channels
– Group Memberships
– Permissions
– Layouts
• Items that appear lower on this list often depend on items that appear higher (viz. foreign keys)
Status of the Prototype
• Work on the prototype started with Layouts (DLM) and proceeded “backwards”
• The prototype currently includes both import and export through Groups
• Which leaves:
– Minor Items
– Users
• It works in uPortal 2.5.3 (AFAIK)
• It hasn’t been tried in any other version
Design of the Prototype
• Import & export operations were mostly implemented in Cernunnos scripts
• Cernunnos is a recent open source project hosted by Google Code with exactly one committer (me)
• In a nutshell, Cernunnos provides flexible Java implementations for common behaviors and allows them to be “instrumented” through a lightweight XML syntax
• Source code and documentation for Cernunnos is available at Google Code:
– http://code.google.com/p/cernunnos/
Example Cernunnos Script
<file-iterator includes="**/*.jar">
<with-attribute key="JAR_NAME" value="${req(Attributes.LOCATION)}">
<echo-ln>${req(JAR_NAME)}:</echo-ln>
<archive-iterator>
<if test="${jexl(Attributes.LOCATION.contains('${req($1)}'))}">
<echo-ln prefix="	">${req(Attributes.LOCATION)}</echo-ln>
</if>
</archive-iterator>
<echo-ln/>
</with-attribute>
</file-iterator>
Using the Prototype
• The prototype Import/Export tool is attached
as a ZIP to the wiki page about this
discussion
• To use it, extract the contents into the root of
a uPortal 2.5 (or later) distribution
Using the Prototype (Cont.)
• Invoke it from the command line using Ant– ant –f import-export.xml export –Ddir={dir} –Dtype={type} [–
Dsysid={sysid}]
– ant –f import-export.xml import [-Ddir={dir}] [-Dpattern={pattern}]
dir = a file system directory
type = all | layout | all-layouts | channel | all-channels | all-permissions | all-memberships | group | all-groups
sysid = user_name | fname |group_name
pattern = a regex expression