Archived / Obsolete Documentation

Documentation in this space is no longer accurate.
Looking for official DSpace documentation? See all documentation

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

<?xml version="1.0" encoding="utf-8"?>
<html>

config/xmlui.xconf

<xmlui>
<aspects>
...
<aspect name="JScholarship SVN Version" path="JScholarshipVersion/"/>
...
</aspects>
<themes>
...
<theme name="Build Information" regex="^svn$" path="BuildInformation/" />
...
</themes>
</xmlui>

aspects/JScholarshipVersion/sitemap.xmap

<!--
Aspect which emits JHU Subversion information found in 'svnbuild.properties' into
the <pageMeta> of the DRI
-->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:transformers>
<map:transformer name="JscholarshipVersion" src="edu.jhu.library.dspace.app.xmlui.aspect.general.JscholarshipVersionTransformer"/>
</map:transformers>
</map:components>
<map:pipelines>
<map:pipeline>
<map:generate/>
<map:transform type="JscholarshipVersion"/>
<map:serialize type="xml"/>
</map:pipeline>
</map:pipelines>
</map:sitemap>

src/edu/jhu/library/dspace/app/xmlui/aspect/general/JscholarshipVersionTransformer.java

package edu.jhu.library.dspace.app.xmlui.aspect.general;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
import org.dspace.app.xmlui.utils.UIException;
import org.dspace.app.xmlui.wing.WingException;
import org.dspace.app.xmlui.wing.element.Body;
import org.dspace.app.xmlui.wing.element.PageMeta;
import org.dspace.authorize.AuthorizeException;
import org.xml.sax.SAXException;

import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Properties;

/**

  • Emits Subversion revision information of JScholarship found in the resource 'svnbuild.properties' to the DRI.
    */
    public class JscholarshipVersionTransformer extends AbstractDSpaceTransformer
    {
    private static final Log log = LogFactory.getLog( JscholarshipVersionTransformer.class );
    private final static String buildResource = "/svnbuild.properties";
    private final static String metadataElementProperty = "meta.element";
    private final static String defaultMetadataElementPropertyValue = "svn";
    private final static Properties buildInfo = new Properties();
    private static boolean available = false;
    static
    {
    InputStream is = JscholarshipVersionTransformer.class.getResourceAsStream( buildResource );
    if ( is != null )
    {
    try
    {
    buildInfo.load( is );
    if ( buildInfo.size() > 0 )
    {
    available = true;
    }
    }
    catch ( IOException e )
    {
    log.warn( "Unable to load Subversion build information: " + e.getMessage() );
    System.err.println( "Unable to load Subversion build information: " + e.getMessage() );
    }
    }
    else
    {
    log.info( "Build information will not be availible. Resource " + buildResource + " not found." );
    }
    }

public void addBody(Body body) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
{
// To avoid an empty body.
body.addDivision( "buildinfo" ).addPara( " " );
}

public void addPageMeta( PageMeta pageMeta )
throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
{
String element = buildInfo.getProperty( metadataElementProperty, defaultMetadataElementPropertyValue );

if ( available )
{
pageMeta.addMetadata( element, "enabled" ).addContent( "true" );

Enumeration props = buildInfo.propertyNames();
while ( props.hasMoreElements() )
{
String qualifier = (String)props.nextElement();
String metadataValue = buildInfo.getProperty( qualifier, "" );
pageMeta.addMetadata( element, qualifier ).addContent( metadataValue );
}
}
else
{
pageMeta.addMetadata( element, "enabled" ).addContent( "false" );
}
}
}

</html>

  • No labels