Changeset 2657
- Timestamp:
- 03/06/13 15:22:58 (11 years ago)
- 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 > 3 6 <modelVersion>4.0.0</modelVersion> 7 4 8 <groupId>eu.clarin.cmdi</groupId> 9 5 10 <artifactId>vlo</artifactId> 11 6 12 <packaging>jar</packaging> 7 13 8 <!-- When updating the version number here, also update9 vlo_solr_importer.sh in src/main/bin and the version number10 in the parent's pom.xml -->11 14 <version>2.13</version> 12 15 <name>vlo_importer</name> … … 15 18 <properties> 16 19 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 17 <packaging> war</packaging>20 <packaging>jar</packaging> 18 21 <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server> 19 22 </properties> -
vlo/branches/vlo-2.13-param/vlo_importer/src/main/assembly/buildjar.xml
r2651 r2657 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <assembly> 3 <id> jar</id>3 <id>importer</id> <!-- name of the jar that needs to be assembled --> 4 4 <formats> 5 5 <format>jar</format> … … 7 7 <includeBaseDirectory>false</includeBaseDirectory> 8 8 <fileSets> 9 <!-- CLASSES-->9 <!-- classes: end up in packages --> 10 10 <fileSet> 11 11 <directory>target/classes</directory> … … 16 16 </fileSet> 17 17 18 <!-- Resources-->18 <!-- resources: end up in the default package --> 19 19 <fileSet> 20 20 <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 3 3 4 4 import java.io.File; 5 import java.io.InputStream; 5 6 import org.simpleframework.xml.core.Persister; 6 7 … … 130 131 */ 131 132 public Object ConfigFromFile() { 133 134 // may be change the name of to something reflecting the stream idea 132 135 133 136 Object object; 134 137 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); 137 163 138 164 try { 139 object = persister.read(configClass, configSource); 165 // object = persister.read(configClass, configSource); 166 object = persister.read(configClass, configSource, true); 140 167 } catch (Exception e) { 141 168 object = null; -
vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
r2651 r2657 4 4 import java.net.URLEncoder; 5 5 import java.util.List; 6 import javax.servlet.ServletContext;7 6 import org.simpleframework.xml.Element; 8 7 import org.simpleframework.xml.ElementArray; … … 12 11 13 12 /** 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 21 40 * parameter"{@literal </parameterMember>}<br><br> 22 41 * 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 36 50 * 37 51 * WebAppConfig.get().getSomeParameter();<br><br> 38 52 * 39 * will return the staticconfiguration, and getSomeParameter() will return a40 * specific parameter in this configuration.53 * will return the configuration, and getSomeParameter() will return a 54 * specific parameter in it. 41 55 * 42 56 * Through the get and set methods, the application is indifferent to the origin 43 57 * 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. 47 62 * 48 63 * Also, the get and set methods allow for a modification of the original value 49 64 * 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 to65 * change can be handled in the get and set methods, instead of having to 51 66 * modify every reference to the parameter in the application. 52 67 * 53 * Please note on the explanation of the meaning of the parameters. Because the68 * Note on the explanation of the meaning of the parameters. Because the 54 69 * meaning of a parameter is not local to this class, or even not local to the 55 70 * configuration package, they are described in the general VLO … … 58 73 * @author keeloo 59 74 */ 60 @Root (strict=false)75 @Root 61 76 public class VloConfig extends ConfigFromFile { 62 77 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 */ 64 83 private final static org.slf4j.Logger LOG = 65 84 LoggerFactory.getLogger(VloConfig.class); 66 85 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 { 69 92 70 93 @Override 71 94 public void log(Object data) { 72 95 96 /** 97 * Send a message to the logging framework by using the 98 * LOG reference. 99 */ 73 100 LOG.error(data.toString()); 74 101 } 75 102 } 76 private static WebAppConfigLogger logger; 103 104 // create a reference to the ConfigFilePersister's logging interface 105 private static VloConfigLogger logger; 77 106 78 107 /** … … 80 109 */ 81 110 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 */ 86 117 ConfigFilePersister.setLogger(VloConfig.logger); 87 118 } 88 119 89 120 /** 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. 91 126 */ 92 127 protected static VloConfig config = null; … … 95 130 * Read the configuration from an XML file. 96 131 * 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 applicationconfiguration132 * 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 103 138 */ 104 139 public static VloConfig readConfig(String fileName) { … … 108 143 } 109 144 110 // get the XML file configuration from the file by invoking the 111 145 // get the XML file configuration from the file by invoking ... 112 146 config = (VloConfig) read(fileName, config); 113 147 … … 118 152 * Read the configuration from an XML file. 119 153 * 120 * Please invoke this method from the package tests. If the tests invoke a121 * method different from the one used by the web application and the122 * important, you can make some test specific changes to the parameters123 * 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. 124 158 * 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 128 167 */ 129 168 public static VloConfig readTestConfig(String fileName) { … … 133 172 } 134 173 135 // get the XML file configuration from the file by invoking the 136 174 // get the XML file configuration from the file by invoking ... 137 175 config = (VloConfig) read(fileName, config); 176 177 // modify the parameters here 138 178 139 179 return config; … … 141 181 142 182 /** 143 * Return the configuration183 * Return the reference to the configuration 144 184 * 145 * @return 185 * @return the configuration 146 186 */ 147 187 public static VloConfig get (){ … … 152 192 * VLO application parameter members<br><br> 153 193 * 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. 157 196 * 158 197 * Please refer to the general VLO documentation for a description of the … … 202 241 * 203 242 * 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 correct205 * 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> 206 245 * 207 246 * {@literal <facetFields length="3">}<br> … … 253 292 * documentation. 254 293 * 255 * @param the value294 * @param dataRoots the value 256 295 */ 257 296 public void setDataRoots(List<DataRoot> dataRoots) { … … 260 299 261 300 /** 262 * Set the value deleteAllFirst parameter<br><br>301 * Set the value of the deleteAllFirst parameter<br><br> 263 302 * 264 303 * For a description of the parameter, refer to the general VLO … … 289 328 * documentation. 290 329 * 291 * @param the value330 * @param printMapping the value 292 331 */ 293 332 public void setPrintMapping(boolean printMapping) { … … 349 388 * documentation. 350 389 * 351 * @param the parameter390 * @param url the parameter 352 391 */ 353 392 public void setSolrUrl(String url) { … … 444 483 * For a description of the schema, refer to the general VLO documentation. 445 484 * 446 * @ param handlethe value485 * @return the value 447 486 */ 448 487 public String getIMDIBrowserUrl(String handle) { … … 623 662 this.silToISO639CodesUrl = url; 624 663 } 625 626 627 664 } -
vlo/branches/vlo-2.13-param/vlo_importer/src/main/resources/VloConfig.xml
r2639 r2657 7 7 <dataRoots> 8 8 <DataRoot> 9 <originName>MPI IMDI Archive 10 </originName> 9 <originName>MPI IMDI Archive</originName> 11 10 <rootFile>/lat/apache/htdocs/oai-harvester/mpi-self-harvest/harvested/results/cmdi/</rootFile> 12 11 <prefix>http://catalog.clarin.eu/</prefix>
Note: See TracChangeset
for help on using the changeset viewer.