edu.internet2.middleware.grouper.ui.util
Class MembershipExporter

java.lang.Object
  extended by edu.internet2.middleware.grouper.ui.util.MembershipExporter
All Implemented Interfaces:
Serializable

public class MembershipExporter
extends Object
implements Serializable

Reads an XML configuration file and exports membership data as specified. The configuration file is determined by looking up the media.properties key 'membership-export.config'. The base Grouper UI distribution does not have a value set. If you want to allow membership export you must configure one or more formats appropriate to your site.

<membership-export>
    <format  name="CSV (Open with Excel)" separator="," 
            quote="true" 
        extension=".csv" 
        content-type="application/ms-excel"
    >
<headers>
<header name="Id"/>
<header name="Name"/>
<header name="Type"/>
</headers>
<source id="g:gsa">
<field name="id"/>
<field name="displayName"/>
<field value="group"/>
</source>
<source id="qsuob">
<field name="id"/>
<field name="name"/>
<field value="person"/>
</source>
</format> </membership-export>

Currently only simple delimited files are supported

format tag

name is the text seen by the user to identify this format - unless there is only one format, in which case it is used as the default
quote=true indicates that double-quotes will surround each exported field.
extension determines the file extension that will be presented to the web browser - which helps the browser choose the correct application to open, and in the case where an application recognizes different formats, lets the application know the format to expect
content-type if configured, is sent as an HTTP header. This will determine how a web browser tries to handle the data. If no content-type is specified, it will be displayed in the UI as a normal page.
separator String used to separate fields - typically a comma or tab (\t)

headers tag

Optionally specifies column headings

source tag

Specifies which fields should be exported for Subjects with the specified source id. If a Subject to be exported has a source which has no configuration it is ignored.

Each source should specify the same number of fields, which should, if they are present, match the number of header fields specified.

field tag

name the name of the subject attribute, the value of which will be exported
value if name is not specified then the text in the value attribute will be used, as is. This allows 'padding' where Subjects from different sources may nnot always have equivalent fields

Version:
$Id: MembershipExporter.java,v 1.7 2009-10-16 10:30:08 isgwb Exp $
Author:
Gary Brown.
See Also:
Serialized Form

Constructor Summary
MembershipExporter()
           
 
Method Summary
 void export(String name, Collection subjects, PrintWriter writer)
           
 List getAvailableFormats()
           
 String getContentType(String format)
           
 String getExtension(String format)
           
 int getNumberOfAvailableFormats()
           
 boolean isActive()
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MembershipExporter

public MembershipExporter()
                   throws Exception
Throws:
Exception
Method Detail

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

isActive

public boolean isActive()

getAvailableFormats

public List getAvailableFormats()
                         throws Exception
Throws:
Exception

getNumberOfAvailableFormats

public int getNumberOfAvailableFormats()
                                throws Exception
Throws:
Exception

export

public void export(String name,
                   Collection subjects,
                   PrintWriter writer)
            throws Exception,
                   IOException
Throws:
Exception
IOException

getContentType

public String getContentType(String format)
                      throws Exception
Throws:
Exception

getExtension

public String getExtension(String format)
                    throws Exception
Throws:
Exception