Changeset 4509
- Timestamp:
- 02/13/14 14:42:31 (10 years ago)
- Location:
- vlo/branches/vlo-3.0
- Files:
-
- 3 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-commons/pom.xml
r4480 r4509 18 18 <dependencies> 19 19 <dependency> 20 <groupId>org.simpleframework</groupId>21 <artifactId>simple-xml</artifactId>22 <version>2.4.1</version>23 </dependency>24 <dependency>25 20 <groupId>javax.servlet</groupId> 26 21 <artifactId>servlet-api</artifactId> … … 28 23 <scope>provided</scope> 29 24 </dependency> 25 <dependency> 26 <groupId>org.slf4j</groupId> 27 <artifactId>slf4j-log4j12</artifactId> 28 <version>${slf4j.version}</version> 29 <scope>test</scope> 30 </dependency> 31 <dependency> 32 <groupId>xmlunit</groupId> 33 <artifactId>xmlunit</artifactId> 34 <version>1.5</version> 35 <scope>test</scope> 36 <type>xml</type> 37 <classifier>ivy</classifier> 38 </dependency> 30 39 </dependencies> 31 40 </project> -
vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DataRoot.java
r4480 r4509 1 2 1 package eu.clarin.cmdi.vlo.config; 3 2 4 3 import java.io.File; 5 import org.simpleframework.xml.Element;6 import org.simpleframework.xml.Root;4 import javax.xml.bind.annotation.XmlElement; 5 import javax.xml.bind.annotation.XmlRootElement; 7 6 8 7 /** 9 8 * A dataRoot describes the meta data sources. 10 * 9 * 11 10 * In an XML file, a dataRoot is reflected like this:<br><br> 12 * 13 * {@literal <DataRoot>} 11 * 12 * {@literal <DataRoot>} 14 13 * {@literal<originName>}name{@literal</originName>} 15 14 * {@literal<rootFile>}topLevelMetadataDirectory/{@literal</rootFile>} … … 18 17 * {@literal<deleteFirst>}falseOrTrue{@literal</deleteFirst>} 19 18 * {@literal</DataRoot>} 20 * 19 * 21 20 * @author keeloo 22 21 */ 23 @ Root // Simple directive22 @XmlRootElement(name = "DataRoot") 24 23 public class DataRoot extends Object { 25 24 26 25 /** 27 26 * Constructor method 28 27 */ 29 public DataRoot (){30 } 31 28 public DataRoot() { 29 } 30 32 31 /** 33 32 * Constructor method 34 * 33 * 35 34 * @param originName name describing the meta data 36 35 * @param rootFile top level directory in which the meta data is stored 37 36 * @param prefix left part of the rootFile 38 * @param toStrip if you want to create the URL to the meta data, this is 37 * @param toStrip if you want to create the URL to the meta data, this is 39 38 * the part to be removed from the rootFile 40 * @param deleteFirst 39 * @param deleteFirst 41 40 */ 42 41 public DataRoot(String originName, File rootFile, String prefix, String toStrip, Boolean deleteFirst) { … … 44 43 this.rootFile = rootFile; 45 44 this.prefix = prefix; 46 this.to strip = toStrip;45 this.toStrip = toStrip; 47 46 this.deleteFirst = deleteFirst; 48 47 } 49 48 50 49 /** 51 50 * Test for equality of the object itself and the object passed to it 52 * 51 * 53 52 * @param dataRoot 54 53 * @return true if the object equals this, false otherwise 55 54 */ 56 55 @Override 57 public boolean equals (Object object){56 public boolean equals(Object object) { 58 57 boolean equal = false; 59 58 60 59 if (object == null) { 61 60 // define this object to be different from nothing 62 61 } else { 63 if (! 62 if (!(object instanceof DataRoot)) { 64 63 // the object is not a DataRoot, define it not to be equal 65 64 } else { … … 67 66 equal = this.rootFile.equals(((DataRoot) object).rootFile) && equal; 68 67 equal = this.prefix.equals(((DataRoot) object).prefix) && equal; 69 equal = this.to strip.equals(((DataRoot) object).tostrip) && equal;68 equal = this.toStrip.equals(((DataRoot) object).toStrip) && equal; 70 69 71 70 equal = this.deleteFirst == ((DataRoot) object).deleteFirst && equal; 72 71 } 73 72 } 74 73 75 74 return equal; 76 75 } … … 78 77 /** 79 78 * Generate by the ide 80 * 79 * 81 80 * @return hash code 82 81 */ … … 87 86 hash = 29 * hash + (this.rootFile != null ? this.rootFile.hashCode() : 0); 88 87 hash = 29 * hash + (this.prefix != null ? this.prefix.hashCode() : 0); 89 hash = 29 * hash + (this.to strip != null ? this.tostrip.hashCode() : 0);88 hash = 29 * hash + (this.toStrip != null ? this.toStrip.hashCode() : 0); 90 89 hash = 29 * hash + (this.deleteFirst ? 1 : 0); 91 90 return hash; … … 95 94 * name describing the meta data 96 95 */ 97 @Element // Simple directive98 96 private String originName; 99 97 100 98 /** 101 99 * top level directory in which the meta data is stored 102 100 */ 103 @Element104 101 private File rootFile; 105 106 /** 107 * Web equivalent of the toStrip. For example: 108 * 102 103 /** 104 * Web equivalent of the toStrip. For example: 105 * 109 106 * /lat/apache/htdocs/ 110 107 */ 111 @Element112 108 private String prefix; 113 109 114 110 /** 115 * Left part of the rootFile 111 * Left part of the rootFile 116 112 * 117 113 * By first removing {@literal tostrip} from {@literal rootFile} and then … … 119 115 * the URL to the meta data. 120 116 */ 121 @ Element122 private String to strip;123 117 @XmlElement(name = "tostrip") 118 private String toStrip; 119 124 120 /** 125 121 * Flag to signal the removal of records from the Solr server 126 * 127 * The value of this flag overrides the value defined in the { @lieteral128 * VloConfig.xml} file. With the deleteFirst flag you can control the129 * removal of the records originating from originName.130 * /131 @Element122 * 123 * The value of this flag overrides the value defined in the { 124 * 125 * @lieteral VloConfig.xml} file. With the deleteFirst flag you can control 126 * the removal of the records originating from originName. 127 */ 132 128 private boolean deleteFirst = false; 133 129 … … 135 131 * Get the value of the prefix element<br><br> 136 132 * 137 * For a description of the element, refer to the general VLO 138 * documentation. 133 * For a description of the element, refer to the general VLO documentation. 139 134 * 140 135 * @return the value … … 147 142 * Set the value of the prefix element<br><br> 148 143 * 149 * For a description of the element, refer to the general VLO 150 * documentation. 144 * For a description of the element, refer to the general VLO documentation. 151 145 * 152 146 * @param prefix the value … … 159 153 * Get the value of the {@literal tostrip} element<br><br> 160 154 * 161 * For a description of the element, refer to the general VLO 162 * documentation. 155 * For a description of the element, refer to the general VLO documentation. 163 156 * 164 157 * @return the value 165 158 */ 166 159 public String getToStrip() { 167 return to strip;160 return toStrip; 168 161 } 169 162 … … 171 164 * Set the value of the {@literal tostrip} element<br><br> 172 165 * 173 * For a description of the element, refer to the general VLO 174 * documentation. 166 * For a description of the element, refer to the general VLO documentation. 175 167 * 176 168 * @param tostrip the value 177 169 */ 178 170 public void setTostrip(String tostrip) { 179 this.to strip = tostrip;171 this.toStrip = tostrip; 180 172 } 181 173 … … 183 175 * Get the value of the originName element<br><br> 184 176 * 185 * For a description of the element, refer to the general VLO 186 * documentation. 187 * 188 * @return the value 189 */ 177 * For a description of the element, refer to the general VLO documentation. 178 * 179 * @return the value 180 */ 190 181 public String getOriginName() { 191 182 return originName; … … 195 186 * Set the value of the originName element<br><br> 196 187 * 197 * For a description of the element, refer to the general VLO 198 * documentation. 188 * For a description of the element, refer to the general VLO documentation. 199 189 * 200 190 * @param originName the value 201 */ 191 */ 202 192 public void setOriginName(String originName) { 203 193 this.originName = originName; … … 207 197 * Get the value of the rootFile element<br><br> 208 198 * 209 * For a description of the element, refer to the general VLO 210 * documentation. 211 * 212 * @return the value 213 */ 199 * For a description of the element, refer to the general VLO documentation. 200 * 201 * @return the value 202 */ 214 203 public File getRootFile() { 215 204 return rootFile; … … 219 208 * Set the value of the rootFile element<br><br> 220 209 * 221 * For a description of the element, refer to the general VLO 222 * documentation. 210 * For a description of the element, refer to the general VLO documentation. 223 211 * 224 212 * @param rootFile the value 225 */ 213 */ 226 214 public void setRootFile(File rootFile) { 227 215 this.rootFile = rootFile; … … 231 219 * Set the value of the deleteFirst element<br><br> 232 220 * 233 * For a description of the element, refer to the general VLO 234 * documentation. 221 * For a description of the element, refer to the general VLO documentation. 235 222 * 236 223 * @param deleteFirst the value 237 */ 224 */ 238 225 public void setDeleteFirst(boolean deleteFirst) { 239 226 this.deleteFirst = deleteFirst; … … 243 230 * Get the value of the deleteFirst element<br><br> 244 231 * 245 * For a description of the element, refer to the general VLO 246 * documentation. 247 * 248 * @return the value 249 */ 232 * For a description of the element, refer to the general VLO documentation. 233 * 234 * @return the value 235 */ 250 236 public boolean deleteFirst() { 251 237 return deleteFirst; 252 238 } 239 240 @Override 241 public String toString() { 242 return String.format("originName: %s; rootFile: %s; prefix: %s; toStrip: %s; deleteFirst: %b", originName, rootFile, prefix, toStrip, deleteFirst); 243 } 244 253 245 } 254 -
vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactory.java
r4507 r4509 15 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 package eu.clarin.cmdi.vlo.config; 17 18 18 package eu.clarin.cmdi.vlo.config; 19 import java.io.InputStream; 20 import javax.xml.bind.JAXBException; 21 import javax.xml.transform.stream.StreamSource; 19 22 20 23 /** … … 24 27 public class DefaultVloConfigFactory implements VloConfigFactory { 25 28 29 public static final String DEFAULT_CONFIG_RESOURCE = "/VloConfig.xml"; 30 private final VloConfigMarshaller marshaller; 31 32 public DefaultVloConfigFactory() { 33 try { 34 this.marshaller = new VloConfigMarshaller(); 35 } catch (JAXBException ex) { 36 throw new RuntimeException("Could not instantiate configuration marshaller while constructing configuration factory", ex); 37 } 38 } 39 26 40 public VloConfig newConfig() { 27 return new VloConfig(); 41 InputStream configResourceStream = getClass().getResourceAsStream(DEFAULT_CONFIG_RESOURCE); 42 try { 43 return marshaller.unmarshal(new StreamSource(configResourceStream)); 44 } catch (JAXBException ex) { 45 throw new RuntimeException("Could not read default configuration due to deserialization error", ex); 46 } 28 47 } 29 30 48 } -
vlo/branches/vlo-3.0/vlo-commons/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
r4507 r4509 4 4 import java.net.URLEncoder; 5 5 import java.util.List; 6 import org.simpleframework.xml.Root; 6 import javax.xml.bind.annotation.XmlElement; 7 import javax.xml.bind.annotation.XmlElementWrapper; 8 import javax.xml.bind.annotation.XmlRootElement; 7 9 8 10 /** … … 11 13 * @author keeloo, twagoo 12 14 */ 13 @ Root15 @XmlRootElement(name = "VloConfig") 14 16 public class VloConfig { 15 17 … … 41 43 private int solrTimeOut = 0; 42 44 43 private List<DataRoot> dataRoots; 45 @XmlElementWrapper(name="dataRoots") 46 @XmlElement(name="DataRoot") 47 private List<DataRoot> dataRoot; 44 48 45 49 private int maxFileSize = 0; … … 67 71 68 72 // services 69 private String FederatedContentSearchUrl = "";73 private String federatedContentSearchUrl = ""; 70 74 71 75 private boolean useHandleResolver = false; 72 76 77 @XmlElement 73 78 private String profileSchemaUrl = ""; 74 79 … … 77 82 private String handleServerUrl = ""; 78 83 84 @XmlElement 79 85 private String imdiBrowserUrl = ""; 80 86 … … 93 99 * An array of facetFields<br><br> 94 100 * 95 * In case of an array of elements, the number of elements in the array 96 * needs to be communicated to the Simple framework. The following would be 97 * a correct description of an array of three facet fields<br><br> 98 * 99 * {@literal <facetFields length="3">}<br> {@literal <facetField>}<br> 100 * {@literal fieldOne}<br> {@literal </facetField>}<br> 101 * {@literal <facetField>}<br> {@literal fieldTwo}<br> 102 * {@literal </facetField>}<br> {@literal <facetField>}<br> 103 * {@literal fieldThree}<br> {@literal </facetField>}<br> 104 * {@literal </facetFields>}<br><br> 105 * 106 * To let Simple now it has to interpret the facetFields element as an 107 * array, use the ElementArray directive. Use the directive to let Simple 108 * know that the elements inside 'facetFields' are named 'facetField'. 109 */ 110 //Array(entry = "facetField") 111 private String[] facetFields = {"", "", ""}; 101 * To let JAXB know it has to interpret the facetFields element as an array, 102 * use the XmlElementWrapper directive. Use the directive to let JAXB know 103 * that the elements inside 'facetFields' are named 'facetField'. 104 */ 105 @XmlElementWrapper(name = "facetFields") 106 private String[] facetField = {"", "", ""}; 112 107 113 108 // test related parameters … … 182 177 * @return the value 183 178 */ 184 public boolean deleteAllFirst() {179 public boolean getDeleteAllFirst() { 185 180 return deleteAllFirst; 186 181 } … … 351 346 */ 352 347 public List<DataRoot> getDataRoots() { 353 return dataRoot s;348 return dataRoot; 354 349 } 355 350 … … 363 358 */ 364 359 public void setDataRoots(List<DataRoot> param) { 365 dataRoot s= param;360 dataRoot = param; 366 361 } 367 362 … … 506 501 * @param param the value 507 502 */ 508 public void set ProfileSchemaUrl(String param) {503 public void setComponentRegistryProfileSchema(String param) { 509 504 profileSchemaUrl = param; 510 505 } … … 567 562 * @return the value 568 563 */ 569 public String getI MDIBrowserUrl(String handle) {564 public String getImdiBrowserUrl(String handle) { 570 565 String result; 571 566 try { … … 585 580 * @param param the value 586 581 */ 587 public void setI MDIBrowserUrl(String param) {582 public void setImdiBrowserUrl(String param) { 588 583 imdiBrowserUrl = param; 589 584 } … … 645 640 * @return the value 646 641 */ 642 @XmlElement(name = "FederatedContentSearchUrl") 647 643 public String getFederatedContentSearchUrl() { 648 return FederatedContentSearchUrl;644 return federatedContentSearchUrl; 649 645 } 650 646 … … 658 654 */ 659 655 public void setFederatedContentSearchUrl(String param) { 660 FederatedContentSearchUrl = param;656 federatedContentSearchUrl = param; 661 657 } 662 658 … … 694 690 */ 695 691 public String[] getFacetFields() { 696 return facetField s;692 return facetField; 697 693 } 698 694 … … 706 702 */ 707 703 public void setFacetFields(String[] param) { 708 facetField s= param;704 facetField = param; 709 705 } 710 706 -
vlo/branches/vlo-3.0/vlo-commons/src/test/java/eu/clarin/cmdi/vlo/config/DefaultVloConfigFactoryTest.java
r4507 r4509 8 8 import java.util.List; 9 9 import static org.junit.Assert.*; 10 import org.junit.Before Class;10 import org.junit.Before; 11 11 import org.junit.Test; 12 12 … … 20 20 } 21 21 22 private staticVloConfig config;23 24 @Before Class25 public staticvoid setUp() {22 private VloConfig config; 23 24 @Before 25 public void setUp() { 26 26 config = new DefaultVloConfigFactory().newConfig(); 27 27 } … … 54 54 System.out.println("getDataRoots"); 55 55 56 List rootsReturned = config.getDataRoots(); 57 58 assertEquals(dataRoots, rootsReturned); 56 List<DataRoot> rootsReturned = config.getDataRoots(); 57 assertArrayEquals(dataRoots.toArray(), rootsReturned.toArray()); 59 58 } 60 59 … … 285 284 286 285 boolean expResult = true; 287 boolean result = config. deleteAllFirst();286 boolean result = config.getDeleteAllFirst(); 288 287 289 288 assertEquals(expResult, result); … … 302 301 config.setDeleteAllFirst(param); 303 302 304 boolean result = config. deleteAllFirst();303 boolean result = config.getDeleteAllFirst(); 305 304 306 305 assertEquals(param, result); … … 407 406 System.out.println("getSolrUrl"); 408 407 409 String expResult = "http://localhost:808 4/vlo_solr/";408 String expResult = "http://localhost:8080/vlo_solr/"; 410 409 String result = config.getSolrUrl(); 411 410 … … 520 519 expResult = "http://corpus1.mpi.nl/ds/imdi_browser?openpath=" + "handle"; 521 520 } 522 String result = config.getI MDIBrowserUrl("handle");521 String result = config.getImdiBrowserUrl("handle"); 523 522 524 523 assertEquals(expResult, result); … … 535 534 String param = "http://corpus1.mpi.nl/ds/imdi_browser?openpath="; 536 535 537 config.setI MDIBrowserUrl(param);536 config.setImdiBrowserUrl(param); 538 537 539 538 String expResult; … … 544 543 } 545 544 546 String result = config.getI MDIBrowserUrl("handle");545 String result = config.getImdiBrowserUrl("handle"); 547 546 548 547 assertEquals(expResult, result); -
vlo/branches/vlo-3.0/vlo-commons/src/test/resources/log4j.properties
r4480 r4509 3 3 log4j.appender.Stdout.layout.conversionPattern=%d %p [%c{1}#%M:%L] - %m%n 4 4 5 log4j.rootLogger= INFO,Stdout5 log4j.rootLogger=DEBUG,Stdout 6 6 7 log4j.logger.org.apache.wicket=INFO8 log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO9 log4j.logger.org.apache.wicket.version=INFO10 log4j.logger.org.apache.wicket.RequestCycle=INFO11 12 -
vlo/branches/vlo-3.0/vlo-importer/src/main/java/eu/clarin/cmdi/vlo/importer/MetadataImporter.java
r4507 r4509 122 122 try { 123 123 // Delete the whole Solr db 124 if (config. deleteAllFirst()) {124 if (config.getDeleteAllFirst()) { 125 125 LOG.info("Deleting original data..."); 126 126 solrServer.deleteByQuery("*:*"); … … 155 155 156 156 // delete outdated entries (based on maxDaysInSolr parameter) 157 if(config.getMaxDaysInSolr() > 0 && config. deleteAllFirst() == false) {157 if(config.getMaxDaysInSolr() > 0 && config.getDeleteAllFirst() == false) { 158 158 LOG.info("Deleting old files that were not seen for more than "+config.getMaxDaysInSolr()+" days..."); 159 159 solrServer.deleteByQuery(FacetConstants.FIELD_LAST_SEEN+":[* TO NOW-"+config.getMaxDaysInSolr()+"DAYS]"); -
vlo/branches/vlo-3.0/vlo-importer/src/test/java/eu/clarin/cmdi/vlo/importer/ImporterTestcase.java
r4507 r4509 14 14 private final VloConfigFactory configFactory = new DefaultVloConfigFactory(); 15 15 protected VloConfig config; 16 17 16 private File testDir; 18 17 … … 36 35 37 36 // read the configuration defined in the packaged configuration file 38 config = configFactory.newConfig();37 MetadataImporter.config = configFactory.newConfig(); 39 38 40 39 // optionally, modify the configuration here 41 config.setComponentRegistryRESTURL("http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/"); 40 MetadataImporter.config.setComponentRegistryRESTURL("http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/"); 41 config = MetadataImporter.config; 42 42 } 43 43
Note: See TracChangeset
for help on using the changeset viewer.