Changeset 2657


Ignore:
Timestamp:
03/06/13 15:22:58 (11 years ago)
Author:
keeloo
Message:

Repaired faulty packaging. Also changed the access to the parameter file from file to stream io. At the moment the packaged parameter file is accessed in a hard coded way.

Location:
vlo/branches/vlo-2.13-param/vlo_importer
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-2.13-param/vlo_importer/pom.xml

    r2651 r2657  
    1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    2          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     1<project xmlns="http://maven.apache.org/POM/4.0.0"
     2         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
     4
     5>
    36    <modelVersion>4.0.0</modelVersion>
     7
    48    <groupId>eu.clarin.cmdi</groupId>
     9
    510    <artifactId>vlo</artifactId>
     11
    612    <packaging>jar</packaging>
    713
    8     <!-- When updating the version number here, also update
    9     vlo_solr_importer.sh in src/main/bin and the version number
    10     in the parent's pom.xml -->
    1114    <version>2.13</version>
    1215    <name>vlo_importer</name>
     
    1518    <properties>
    1619        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    17         <packaging>war</packaging>
     20        <packaging>jar</packaging>
    1821        <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server>
    1922    </properties>
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/assembly/buildjar.xml

    r2651 r2657  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<assembly>
    3     <id>jar</id>
     3    <id>importer</id> <!-- name of the jar that needs to be assembled -->
    44    <formats>
    55        <format>jar</format>
     
    77    <includeBaseDirectory>false</includeBaseDirectory>
    88    <fileSets>
    9         <!-- CLASSES -->
     9        <!-- classes: end up in packages -->
    1010        <fileSet>
    1111            <directory>target/classes</directory>
     
    1616        </fileSet>
    1717
    18         <!-- Resources -->
     18        <!-- resources: end up in the default package -->
    1919        <fileSet>
    2020            <directory>src/main/resources</directory>
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/ConfigFilePersister.java

    r2570 r2657  
    33
    44import java.io.File;
     5import java.io.InputStream;
    56import org.simpleframework.xml.core.Persister;
    67
     
    130131     */
    131132    public Object ConfigFromFile() {
     133       
     134        // may be change the name of to something reflecting the stream idea
    132135
    133136        Object object;
    134137
    135         File configSource;
    136         configSource = new File(fileName);
     138        // File configSource;
     139        // configSource = new File(fileName);
     140       
     141        // configSource = new InputStream(filename);
     142       
     143        // seems to be clean, that is: without reference to context
     144       
     145        // configSource = getClass().getClassLoader().getResourceAsStream(fileName);
     146       
     147        Class c = null;
     148        try {
     149            c = Class.forName("eu.clarin.cmdi.vlo.config.ConfigFilePersister");
     150        } catch (Exception ex) {
     151            // This should not happen.
     152        }
     153       
     154        /**
     155         * The point is that here some merging will take place. Find a suitable
     156         * name for c. Another point is that now the filename should take the
     157         * place of the absName
     158         */
     159           
     160        String absName = "/VloConfig.xml";
     161       
     162        InputStream configSource = c.getResourceAsStream(absName);
    137163
    138164        try {
    139             object = persister.read(configClass, configSource);
     165            // object = persister.read(configClass, configSource);
     166            object = persister.read(configClass, configSource, true);
    140167        } catch (Exception e) {
    141168            object = null;
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java

    r2651 r2657  
    44import java.net.URLEncoder;
    55import java.util.List;
    6 import javax.servlet.ServletContext;
    76import org.simpleframework.xml.Element;
    87import org.simpleframework.xml.ElementArray;
     
    1211
    1312/**
    14  * Web application configuration<br><br>
    15  *
    16  * Map the elements in the packaged {@literal WebAppConfig.xml} file to the
    17  * members in this class, the configuration of the VLO web application and
    18  * importer according to the Simple framework specification. So<br><br>
    19  *
    20  * {@literal <parameterMember>}"the value of the
     13 * VLO configuration<br><br>
     14 *
     15 * The annotated members in this class are the parameters by means of which
     16 * you can configure a VLO application like for example the VLO importer or
     17 * the VLO web application.
     18 *
     19 * A member is annotated by prepending @element. When the VloConfig class is
     20 * reflected into the Simple framework, the framework will assign the values
     21 * it finds in the VloConfig.xml file to the members in the VloConfig class.
     22 *
     23 * By invoking the get method defined in the VloConfig class, a VLO application
     24 * can query the value of a parameter. If you just instantiate an instance of
     25 * the VloConfig class, the members will be assigned values from the packaged
     26 * the VloConfig.xml file.
     27 *
     28 * Alternatively, the readConfig methods will let you specify an xml file of
     29 * your choice.
     30 *
     31 * Whenever you like to add a parameter the VLO configuration, add a member
     32 * with the appropriate name and type, and prepend an at aign to the
     33 * declaration, like this:
     34 *
     35 * {@literal @element}<br> {@literal parameterMember}<br><br>
     36 *
     37 * The xml file used should in this case contain a definition like
     38 *
     39 * {@literal<parameterMember>} "the value of the
    2140 * parameter"{@literal </parameterMember>}<br><br>
    2241 *
    23  * in the XML file is accompanied by<br><br>
    24  *
    25  * {@literal
    26  *
    27  * @element}<br> {@literal parameterMember}<br><br>
    28  *
    29  * in the VloConfig class. If you want to add a type of member that is not
    30  * included in the class yet, refer to the Simple framework's
    31  * specification.<br><br>
    32  *
    33  * The parameters are stored statically. This means that a parameter can be
    34  * referenced from the application without first creating a configuration
    35  * object. So get() in
     42 * If you want to add a type of member that is not included in VloConfig class
     43 * yet, or if you are looking for more information on the framework, please refer
     44 * to <url> <br><br>
     45 *
     46 * The parameters are stored statically. This means that after you have create
     47 * a VloConfig object, you can reference a parameter outside the scope in which
     48 * the object was originally created. So after a VloConfig object has been
     49 * created, get() in
    3650 *
    3751 * WebAppConfig.get().getSomeParameter();<br><br>
    3852 *
    39  * will return the static configuration, and getSomeParameter() will return a
    40  * specific parameter in this configuration.
     53 * will return the configuration, and getSomeParameter() will return a
     54 * specific parameter in it.
    4155 *
    4256 * Through the get and set methods, the application is indifferent to the origin
    4357 * of a parameter: you can get and set the value of a parameter without having
    44  * to worry about how the parameter was defined originally. By invoking the read
    45  * method, and by querying the context, the web application, on initialization,
    46  * determines which definition to use.
     58 * to worry about how the parameter was defined originally.
     59 *
     60 * By invoking the read method, and by querying the context, the web
     61 * application, on initialization, determines which definition to use.
    4762 *
    4863 * Also, the get and set methods allow for a modification of the original value
    4964 * of the parameter. For example, if the format of a parameter changes, this
    50  * change can be handled in the get and set method once, instead of having to
     65 * change can be handled in the get and set methods, instead of having to
    5166 * modify every reference to the parameter in the application.
    5267 *
    53  * Please note on the explanation of the meaning of the parameters. Because the
     68 * Note on the explanation of the meaning of the parameters. Because the
    5469 * meaning of a parameter is not local to this class, or even not local to the
    5570 * configuration package, they are described in the general VLO
     
    5873 * @author keeloo
    5974 */
    60 @Root(strict=false)
     75@Root
    6176public class VloConfig extends ConfigFromFile {
    6277
    63     // create a reference to the application logging
     78    /**
     79     * Create a reference through which a VloConfig class object can send
     80     * messages to the logging framework that has been associated with the
     81     * application.
     82     */
    6483    private final static org.slf4j.Logger LOG =
    6584            LoggerFactory.getLogger(VloConfig.class);
    6685
    67     // connect to the logging framework
    68     private class WebAppConfigLogger implements ConfigFilePersister.Logger {
     86    /**
     87     * Because the VloConfig class uses the Simple framework via the
     88     * ConfigFilePersister class, implement the logging interface in
     89     * that class.
     90     */
     91    private class VloConfigLogger implements ConfigFilePersister.Logger {
    6992
    7093        @Override
    7194        public void log(Object data) {
    72 
     95           
     96            /**
     97             * Send a message to the logging framework by using the
     98             * LOG reference.
     99             */
    73100            LOG.error(data.toString());
    74101        }
    75102    }
    76     private static WebAppConfigLogger logger;
     103 
     104    // create a reference to the ConfigFilePersister's logging interface
     105    private static VloConfigLogger logger;
    77106
    78107    /**
     
    80109     */
    81110    public VloConfig() {
    82         // let the superclass know about the logger defined here
    83 
    84         logger = new WebAppConfigLogger();
    85 
     111        // create the ConfigFilePersister's logging interface
     112        logger = new VloConfigLogger();
     113
     114        /**
     115         * Initialize the ConfigFilePersister's reference to the interface
     116         */
    86117        ConfigFilePersister.setLogger(VloConfig.logger);
    87118    }
    88119   
    89120    /**
    90      * Make the configuration statically accessible
     121     * Create a static reference to the class itself to collect the members
     122     * denoting parameters. Because these members themselves are static, the
     123     * reference will point the a fixed set of parameters. Please note that the
     124     * reference needs to be a protected reference because of access from one
     125     * of the extending VloWebApp class.
    91126     */
    92127    protected static VloConfig config = null;
     
    95130     * Read the configuration from an XML file.
    96131     *
    97      * Please invoke this method from the web application or from the importer;
    98      * the readTestConfig method is intended for testing purposes.
    99      *
    100      * @param fileName
    101      *
    102      * @return the web application configuration
     132     * Please invoke this method if you want a configuration different from
     133     * the one that is represented in the packages XML file.
     134     * 
     135     * @param fileName the name of the file to read the configuration from
     136     *
     137     * @return the configuration
    103138     */
    104139    public static VloConfig readConfig(String fileName) {
     
    108143        }
    109144
    110         // get the XML file configuration from the file by invoking the
    111 
     145        // get the XML file configuration from the file by invoking ...
    112146        config = (VloConfig) read(fileName, config);
    113147
     
    118152     * Read the configuration from an XML file.
    119153     *
    120      * Please invoke this method from the package tests. If the tests invoke a
    121      * method different from the one used by the web application and the
    122      * important, you can make some test specific changes to the parameters
    123      * here.
     154     * Invole this method instead of readConfig() if you want to change
     155     * the parameters because the application is run in a context different
     156     * from the usual one. Here, modifications of the parameters inspired on
     157     * the difference in context can be made.
    124158     *
    125      * @param fileName
    126      *
    127      * @return the web application configuration in a new static context
     159     * A web application can serve as a tipical example of a difference in
     160     * context: the application itself runs in a web server container, while the
     161     * tests associated with the web application will be run outside this
     162     * container.
     163     *     
     164     * @param fileName the name of the file to read the configuration from
     165     *
     166     * @return the configuration
    128167     */
    129168    public static VloConfig readTestConfig(String fileName) {
     
    133172        }
    134173
    135         // get the XML file configuration from the file by invoking the
    136 
     174        // get the XML file configuration from the file by invoking ...
    137175        config = (VloConfig) read(fileName, config);
     176       
     177        // modify the parameters here
    138178
    139179        return config;
     
    141181   
    142182    /**
    143      * Return the configuration
     183     * Return the reference to the configuration
    144184     *
    145      * @return
     185     * @return the configuration
    146186     */
    147187    public static VloConfig get (){
     
    152192     * VLO application parameter members<br><br>
    153193     *
    154      * Initialize a member corresponding to application parameters with an empty
    155      * string at least, for this will allow them to be linearized to
    156      * corresponding elements in the XML file.
     194     * Initialize the annotated members in a proper way. This will allow them to
     195     * be linearized to corresponding elements in an XML file.
    157196     *
    158197     * Please refer to the general VLO documentation for a description of the
     
    202241     *
    203242     * In case of an array of elements, the number of elements in the array
    204      * needs to be communicated to Simple. The following would be a correct
    205      * description of an array of three facet fields<br><br>
     243     * needs to be communicated to the Simple framework. The following would be
     244     * a correct description of an array of three facet fields<br><br>
    206245     *
    207246     * {@literal <facetFields length="3">}<br>
     
    253292     * documentation.
    254293     *
    255      * @param the value
     294     * @param dataRoots the value
    256295     */
    257296    public void setDataRoots(List<DataRoot> dataRoots) {
     
    260299
    261300    /**
    262      * Set the value deleteAllFirst parameter<br><br>
     301     * Set the value of the deleteAllFirst parameter<br><br>
    263302     *
    264303     * For a description of the parameter, refer to the general VLO
     
    289328     * documentation.
    290329     *
    291      * @param the value
     330     * @param printMapping the value
    292331     */
    293332    public void setPrintMapping(boolean printMapping) {
     
    349388     * documentation.
    350389     *
    351      * @param the parameter
     390     * @param url the parameter
    352391     */
    353392    public void setSolrUrl(String url) {
     
    444483     * For a description of the schema, refer to the general VLO documentation.
    445484     *
    446      * @param handle the value
     485     * @return the value
    447486     */
    448487    public String getIMDIBrowserUrl(String handle) {
     
    623662        this.silToISO639CodesUrl = url;
    624663    }
    625            
    626    
    627664}
  • vlo/branches/vlo-2.13-param/vlo_importer/src/main/resources/VloConfig.xml

    r2639 r2657  
    77    <dataRoots>
    88        <DataRoot>
    9             <originName>MPI IMDI Archive
    10             </originName>
     9            <originName>MPI IMDI Archive</originName>
    1110            <rootFile>/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/</rootFile>           
    1211            <prefix>http://catalog.clarin.eu/</prefix>
Note: See TracChangeset for help on using the changeset viewer.