Defining DLM Fragments ala ALM
DLM Fragment Pushing Tool
This has been updated only slightly for uPortal 3. The attached code likely does NOT work without modification
Note!! This tool has not been extensively tested and should probably not be used in a production environment!
This tool allows you to specify your tabs/columns/channels for DLM in the dlm.xml file, the way ALM does (with its fragments.xml file). Syntax is very similar to ALM's fragments.xml.
You should be able to take your original dlm.xml file and just add these modifications to it. The original DLM code ignores the modifications we've made, and this tool ignores some of the original stuff like "audience". They work in a complementary way.
It expects channels to be already defined in the properties/chanpub directory (it looks up channels by their fname in the database itself).
There's an extra property that specifies the default skin:
<dlm:property name="defaultLayoutOwnerSkin" value="imm" />
Define a fragment for the default user (e.g. fragmentTemplate) (see example in the file). Inside this fragment, you should include the header and footer folders. These will be propagated to all the rest of the fragment users in the file that have the includeDefault="Y" attribute set.
Syntax is pretty much the same as for fragments.xml (but with a dlm: namespace). One extra attribute was added to the "folder" tag, "width", which lets you specify the width of a column.
The tool will automatically deal with "updating" fragments that already exist. So you should be able to do an "ant pushdlm pubfragments" with a restart and people should get the updated fragments. It will actually remove and recreate the fragment users giving them a password which is the same as their username.
A note of warning, if you make any changes to fragments, etc, via the portal itself (by logging in as a fragment user), you won't be able to run this again as it will overwrite what you did. It doesn't keep any changes done via the portal logins. (Of course this only applies to fragment users).
The DlmFragmentPusher munges dlm.xml into a "data.xml" style file in build/WEB-INF/properties/db/dlm-data.xml. It does this in a somewhat "smart" fashion, by generating "delete" actions for any existing data first and then adding the insert rows. The ant tasks call it and then push the data into the database using the dbloader (with create/droptables turned off).
Either copy the source/org/jasig/portal/security/Md5Passwd.java file into your source dir or edit your version and make the "encode" function public. DlmFragmentPusher uses this to generate an Md5 password for the users it creates.
Edit build.xml and add the following:
In the initportal task, just after the antcall to pubchan, add
<antcall target="pushdlm"/>
At the end of the file before the end project tag, add
<target name="pushdlmgen" description="Generates dlm fragments data file from dlm.xml" depends="compile"> <uportal-impl-macro> <java fork="true" failonerror="true" dir="${basedir}" classname="org.jasig.portal.tools.DlmFragmentPusher"> <classpath refid="uportal-impl-full.classpath" /> </java> </uportal-impl-macro> </target> <target name="pushdlm" description="Pushes dlm fragments data to db" depends="pushdlmgen"> <antcall target="db"> <param name="usedata" value="-d"/> <param name="datafile" value="/properties/db/dlm-data.xml"/> <param name="droptables" value="-nD"/> <param name="createtables" value="-nC"/> </antcall> </target>
A sample dlm.xml file is provided in properties/dlm.xml.