Changeset 5891 for SRUAggregator
- Timestamp:
- 12/05/14 08:14:03 (9 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 3 added
- 2 deleted
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/build.sh
r5890 r5891 1 1 #!/bin/bash 2 2 3 WEBDIR=src/main/webapp 4 LIBDIR=$ WEBDIR/lib3 ASSETDIR=src/main/resources/assets 4 LIBDIR=$ASSETDIR/lib 5 5 6 6 if [ ! -e bower_components ] … … 18 18 19 19 mkdir -p src/main/webapp/fonts 20 cp bower_components/bootstrap/fonts/* $ WEBDIR/fonts/21 cp bower_components/font-awesome/fonts/* $ WEBDIR/fonts/20 cp bower_components/bootstrap/fonts/* $ASSETDIR/fonts/ 21 cp bower_components/font-awesome/fonts/* $ASSETDIR/fonts/ 22 22 fi 23 23 24 JSDIR= src/main/webapp/js24 JSDIR=$ASSETDIR/js 25 25 for f in $JSDIR/*.jsx; do 26 26 cp -v $f $JSDIR/`basename $f .jsx`.js; … … 28 28 node_modules/react-tools/bin/jsx --no-cache-dir $JSDIR $JSDIR 29 29 30 #mvn clean package 30 #mvn -q clean package 31 32 # Run in production: 33 #java -jar target/Aggregator2-2.0.0-alpha-6.jar server aggregator.yml 34 35 # Run for development: 36 #java -DEnvironment=Development -cp src/main/resources:target/Aggregator2-2.0.0-alpha-6.jar eu.clarin.sru.fcs.aggregator.app.Aggregator server aggregator.yml -
SRUAggregator/trunk/pom.xml
r5890 r5891 1 < project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"2 1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 3 <modelVersion>4.0.0</modelVersion> 4 <prerequisites> 5 <maven>3.0.0</maven> 6 </prerequisites> 4 7 5 8 <groupId>eu.clarin.sru.fcs</groupId> 6 9 <artifactId>Aggregator2</artifactId> 7 <version>2.0.0-ALPHA5</version> 8 <packaging>war</packaging> 9 10 <name>Aggregator2</name> 10 <version>2.0.0-alpha-6</version> 11 <name>Federated Content Search Aggregator</name> 11 12 12 13 <properties> 13 <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>14 14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 15 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 15 16 </properties> 16 17 … … 19 20 <id>clarin</id> 20 21 <url>http://catalog.clarin.eu/ds/nexus/content/repositories/Clarin/</url> 22 </repository> 23 <repository> 24 <id>sonatype-nexus-snapshots</id> 25 <name>Sonatype Nexus Snapshots</name> 26 <url>http://oss.sonatype.org/content/repositories/snapshots</url> 21 27 </repository> 22 28 <repository> … … 28 34 <url>http://sardine.googlecode.com/svn/maven/</url> 29 35 </repository> 30 </repositories> 31 36 </repositories> 32 37 33 38 <dependencies> 39 <dependency> 40 <groupId>io.dropwizard</groupId> 41 <artifactId>dropwizard-core</artifactId> 42 <version>0.7.1</version> 43 </dependency> 44 <dependency> 45 <groupId>io.dropwizard</groupId> 46 <artifactId>dropwizard-assets</artifactId> 47 <version>0.7.1</version> 48 </dependency> 49 <dependency> 50 <groupId>io.dropwizard</groupId> 51 <artifactId>dropwizard-spdy</artifactId> 52 <version>0.7.1</version> 53 </dependency> 54 <dependency> 55 <groupId>io.dropwizard</groupId> 56 <artifactId>dropwizard-testing</artifactId> 57 <version>0.7.1</version> 58 <scope>test</scope> 59 </dependency> 60 34 61 <dependency> 35 62 <groupId>eu.clarin.sru</groupId> … … 37 64 <version>0.9.5-DEBUG</version> 38 65 </dependency> 39 40 66 41 67 <dependency> … … 81 107 <version>3.11-beta2</version> 82 108 </dependency> 83 84 <dependency>85 <groupId>org.slf4j</groupId>86 <artifactId>slf4j-api</artifactId>87 <version>1.7.7</version>88 </dependency>89 <dependency>90 <groupId>org.slf4j</groupId>91 <artifactId>slf4j-simple</artifactId>92 <version>1.7.7</version>93 </dependency>94 95 <dependency>96 <groupId>joda-time</groupId>97 <artifactId>joda-time</artifactId>98 <version>2.5</version>99 </dependency>100 <dependency>101 <groupId>junit</groupId>102 <artifactId>junit</artifactId>103 <version>4.11</version>104 <scope>test</scope>105 <type>jar</type>106 </dependency>107 <dependency>108 <groupId>com.google.code.gson</groupId>109 <artifactId>gson</artifactId>110 <version>2.3</version>111 <type>jar</type>112 </dependency>113 <dependency>114 <groupId>javax</groupId>115 <artifactId>javaee-web-api</artifactId>116 <version>6.0</version>117 <scope>provided</scope>118 </dependency>119 120 <dependency>121 <groupId>com.sun.jersey</groupId>122 <artifactId>jersey-server</artifactId>123 <version>1.18.1</version>124 </dependency>125 <dependency>126 <groupId>com.sun.jersey</groupId>127 <artifactId>jersey-servlet</artifactId>128 <version>1.18.1</version>129 </dependency>130 <dependency>131 <groupId>com.sun.jersey</groupId>132 <artifactId>jersey-client</artifactId>133 <version>1.18.1</version>134 </dependency>135 <dependency>136 <groupId>com.sun.jersey</groupId>137 <artifactId>jersey-core</artifactId>138 <version>1.18.1</version>139 </dependency>140 <dependency>141 <groupId>com.sun.jersey</groupId>142 <artifactId>jersey-json</artifactId>143 <version>1.18.1</version>144 </dependency>145 <dependency>146 <groupId>com.sun.jersey.contribs</groupId>147 <artifactId>jersey-multipart</artifactId>148 <version>1.18.1</version>149 </dependency>150 151 109 </dependencies> 152 110 153 111 <build> 154 <finalName>${project.artifactId}</finalName>155 112 <plugins> 113 <plugin> 114 <groupId>org.apache.maven.plugins</groupId> 115 <artifactId>maven-enforcer-plugin</artifactId> 116 <version>1.3.1</version> 117 <executions> 118 <execution> 119 <id>enforce</id> 120 <configuration> 121 <rules> 122 <DependencyConvergence /> 123 </rules> 124 </configuration> 125 <goals> 126 <!--<goal>enforce</goal>--> 127 </goals> 128 </execution> 129 </executions> 130 </plugin> 156 131 <plugin> 157 132 <groupId>org.apache.maven.plugins</groupId> … … 161 136 <source>1.7</source> 162 137 <target>1.7</target> 163 <compilerArguments> 164 <endorseddirs>${endorsed.dir}</endorseddirs> 165 </compilerArguments> 138 <encoding>UTF-8</encoding> 166 139 </configuration> 167 140 </plugin> 168 <plugin> 169 <groupId>org.apache.maven.plugins</groupId> 170 <artifactId>maven-war-plugin</artifactId> 141 <!--<plugin> 142 <groupId>org.apache.maven.plugins</groupId> 143 <artifactId>maven-source-plugin</artifactId> 144 <version>2.2.1</version> 145 <executions> 146 <execution> 147 <id>attach-sources</id> 148 <goals> 149 <goal>jar</goal> 150 </goals> 151 </execution> 152 </executions> 153 </plugin>--> 154 <plugin> 155 <groupId>org.apache.maven.plugins</groupId> 156 <artifactId>maven-jar-plugin</artifactId> 171 157 <version>2.5</version> 172 158 <configuration> 173 <failOnMissingWebXml>false</failOnMissingWebXml> 159 <archive> 160 <manifest> 161 <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 162 </manifest> 163 </archive> 174 164 </configuration> 175 165 </plugin> 176 166 <plugin> 177 167 <groupId>org.apache.maven.plugins</groupId> 178 <artifactId>maven-dependency-plugin</artifactId> 179 <version>2.9</version> 168 <artifactId>maven-shade-plugin</artifactId> 169 <version>2.2</version> 170 <configuration> 171 <createDependencyReducedPom>true</createDependencyReducedPom> 172 <filters> 173 <filter> 174 <artifact>*:*</artifact> 175 <excludes> 176 <exclude>META-INF/*.SF</exclude> 177 <exclude>META-INF/*.DSA</exclude> 178 <exclude>META-INF/*.RSA</exclude> 179 </excludes> 180 </filter> 181 </filters> 182 </configuration> 180 183 <executions> 181 184 <execution> 182 <phase> validate</phase>185 <phase>package</phase> 183 186 <goals> 184 <goal> copy</goal>187 <goal>shade</goal> 185 188 </goals> 186 189 <configuration> 187 <outputDirectory>${endorsed.dir}</outputDirectory> 188 <silent>true</silent> 189 <artifactItems> 190 <artifactItem> 191 <groupId>javax</groupId> 192 <artifactId>javaee-endorsed-api</artifactId> 193 <version>6.0</version> 194 <type>jar</type> 195 </artifactItem> 196 </artifactItems> 190 <transformers> 191 <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> 192 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 193 <mainClass>eu.clarin.sru.fcs.aggregator.app.Aggregator</mainClass> 194 </transformer> 195 </transformers> 197 196 </configuration> 198 197 </execution> -
SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java
r5890 r5891 1 1 package eu.clarin.sru.fcs.aggregator.app; 2 2 3 import com.fasterxml.jackson.databind.ObjectMapper; 3 4 import eu.clarin.sru.fcs.aggregator.search.Search; 4 5 import eu.clarin.sru.fcs.aggregator.cache.ScanCrawlTask; … … 9 10 import eu.clarin.sru.fcs.aggregator.cache.EndpointUrlFilter; 10 11 import eu.clarin.sru.fcs.aggregator.registry.Corpus; 12 import eu.clarin.sru.fcs.aggregator.rest.RestService; 13 import io.dropwizard.Application; 14 import io.dropwizard.assets.AssetsBundle; 15 import io.dropwizard.setup.Bootstrap; 16 import io.dropwizard.setup.Environment; 11 17 import java.io.File; 12 18 import java.io.IOException; … … 20 26 import java.util.concurrent.ScheduledExecutorService; 21 27 import java.util.concurrent.atomic.AtomicReference; 22 import javax.servlet.ServletContextEvent;23 import javax.servlet.ServletContextListener;24 28 import opennlp.tools.tokenize.TokenizerModel; 25 import org.codehaus.jackson.map.ObjectMapper;26 29 import org.slf4j.LoggerFactory; 27 30 … … 87 90 * 88 91 * TODO: zoom into the results from a corpus, allow functionality only for the 89 * view 90 * 91 * TODO: search for next set of results 92 * view (search for next set of results) 92 93 * 93 94 * TODO: Clear results (also before new search) … … 99 100 * TODO: Download to personal workspace as csv, excel, tcf, plain text 100 101 * 101 * TODO: implement102 *103 102 * TODO: use SRUClient's extraResponseData POJOs 104 103 * 105 * TODO: websockets , selfhosting104 * TODO: websockets 106 105 * 107 106 * TODO: atomic replace of cached corpora (file) … … 110 109 * 111 110 */ 112 public class Aggregator implements ServletContextListener{111 public class Aggregator extends Application<AggregatorConfiguration> { 113 112 114 113 private static final org.slf4j.Logger log = LoggerFactory.getLogger(Aggregator.class); 115 114 116 public static final String DE_TOK_MODEL = " /tokenizer/de-tuebadz-8.0-token.bin";115 public static final String DE_TOK_MODEL = "tokenizer/de-tuebadz-8.0-token.bin"; 117 116 118 117 private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); … … 130 129 private SRUThreadedClient sruScanClient = null; 131 130 private Map<Long, Search> activeSearches = Collections.synchronizedMap(new HashMap<Long, Search>()); 132 private Params params; 131 132 public static void main(String[] args) throws Exception { 133 new Aggregator().run(args); 134 } 135 136 @Override 137 public String getName() { 138 return "Federated Content Search Aggregator"; 139 } 140 141 @Override 142 public void initialize(Bootstrap<AggregatorConfiguration> bootstrap) { 143 bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html")); 144 } 145 146 @Override 147 public void run(AggregatorConfiguration config, Environment environment) { 148 environment.jersey().setUrlPattern("/rest/*"); 149 environment.jersey().register(new RestService()); 150 151 init(config); 152 } 153 133 154 134 155 public static Aggregator getInstance() { … … 140 161 } 141 162 142 public Params getParams() { 143 return params; 144 } 145 146 @Override 147 public void contextInitialized(ServletContextEvent servletContextEvent) { 163 public void init(AggregatorConfiguration config) { 148 164 log.info("Aggregator initialization started."); 149 165 instance = this; 150 166 try { 151 params = new Params(); 152 detectAndConfigureEnvironment(); 167 detectAndConfigureEnvironment(config); 153 168 154 169 sruScanClient = new ClarinFCSClientBuilder() … … 166 181 .buildThreadedClient(); 167 182 168 File corporaCacheFile = new File( params.aggregatorFilePath);183 File corporaCacheFile = new File(config.getAggregatorFilePath()); 169 184 try { 170 185 Corpora corpora = new ObjectMapper().readValue(corporaCacheFile, Corpora.class); … … 177 192 model = setUpTokenizers(); 178 193 179 ScanCrawlTask task = new ScanCrawlTask(sruScanClient, params.centerRegistryUrl,180 params.cacheMaxDepth, filter, scanCacheAtom, corporaCacheFile);194 ScanCrawlTask task = new ScanCrawlTask(sruScanClient, config.getCenterRegistryUrl(), 195 config.getScanMaxDepth(), filter, scanCacheAtom, corporaCacheFile); 181 196 scheduler.scheduleAtFixedRate(task, SCAN_TASK_INITIAL_DELAY, 182 params.cacheUpdateInterval, params.cacheUpdateIntervalUnit);197 config.getUpdateInterval(), config.getUpdateIntervalTimeUnit()); 183 198 184 199 log.info("Aggregator initialization finished."); … … 189 204 } 190 205 191 @Override 192 public void contextDestroyed(ServletContextEvent sce) { 206 public void shutdown() { 193 207 log.info("Aggregator is shutting down."); 194 208 for (Search search : activeSearches.values()) { … … 255 269 } 256 270 257 private void detectAndConfigureEnvironment( ) {271 private void detectAndConfigureEnvironment(AggregatorConfiguration config) { 258 272 if (!"Development".equals(System.getProperty("Environment"))) { 259 273 log.info(" *** Production Environment detected, using default settings *** "); 260 params.cacheMaxDepth = 1;274 config.setScanMaxDepth(1); 261 275 return; 262 276 } … … 273 287 // filter.allow("leipzig", "mpi.nl"); 274 288 // filter.allow("lindat"); 275 params.aggregatorFilePath = System.getProperty("user.home") + File.separator + "fcsAggregatorCorpora.json"; 276 params.cacheMaxDepth = 1; 289 config.setAggregatorFilePath(System.getProperty("user.home") 290 + File.separator + "fcsAggregatorCorpora.json"); 291 config.setScanMaxDepth(1); 277 292 } 278 293 } -
SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/cache/ScanCrawlTask.java
r5841 r5891 1 1 package eu.clarin.sru.fcs.aggregator.cache; 2 2 3 import com.fasterxml.jackson.databind.ObjectMapper; 3 4 import eu.clarin.sru.client.SRUThreadedClient; 4 5 import eu.clarin.sru.fcs.aggregator.registry.CenterRegistry; … … 7 8 import java.io.IOException; 8 9 import java.util.concurrent.atomic.AtomicReference; 9 import org.codehaus.jackson.map.ObjectMapper;10 10 import org.slf4j.LoggerFactory; 11 11 -
SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/RestService.java
r5841 r5891 1 1 package eu.clarin.sru.fcs.aggregator.rest; 2 2 3 import com. google.gson.Gson;4 import com. google.gson.GsonBuilder;5 import com. google.gson.JsonParser;3 import com.fasterxml.jackson.core.JsonProcessingException; 4 import com.fasterxml.jackson.databind.ObjectMapper; 5 import com.fasterxml.jackson.databind.ObjectWriter; 6 6 import eu.clarin.sru.client.SRUVersion; 7 7 import eu.clarin.sru.fcs.aggregator.app.Aggregator; … … 39 39 @Path("/") 40 40 public class RestService { 41 ObjectWriter ow = new ObjectMapper().writerWithDefaultPrettyPrinter(); 41 42 42 43 @Context … … 45 46 ServletContext servletContext; 46 47 47 private String toJson(Object o) { 48 JsonParser parser = new JsonParser(); 49 Gson gson = new GsonBuilder().setPrettyPrinting().create(); 50 return gson.toJson(o); 48 private String toJson(Object o) throws JsonProcessingException { 49 return ow.writeValueAsString(o); 51 50 } 52 51
Note: See TracChangeset
for help on using the changeset viewer.