Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<module>wayback-cdx-server-core</module>
<module>wayback-cdx-server-webapp</module>
<module>wayback-core</module>
<module>wayback-webapp</module>
<module>wayback-webapp</module>
<module>dist</module>
</modules>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public WaybackRequest parse(HttpServletRequest httpRequest,
AccessPoint accessPoint) throws BetterRequestException {
WaybackRequest wbRequest = super.parse(httpRequest, accessPoint);
if (wbRequest != null) {
String replayTimestamp = wbRequest.getReplayTimestamp();
if ((replayTimestamp == null) || replayTimestamp.length() == 0) {
// If it's not a capture or URL query, let's call it a star
// query:
if (!(wbRequest.isCaptureQueryRequest() || wbRequest
.isUrlQueryRequest())) {
// TODO: should we clone?
wbRequest.setStartTimestamp(null);
wbRequest.setEndTimestamp(null);
}
}
String requestPath =
accessPoint.translateRequestPathQuery(httpRequest);
ArchivalUrl aUrl = new ArchivalUrl(wbRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.logging.Logger;

import org.archive.util.iterator.CloseableIterator;
import org.archive.wayback.UrlCanonicalizer;
Expand Down Expand Up @@ -52,13 +53,18 @@
public class BDBIndex extends BDBRecordSet implements
UpdatableSearchResultSource {

private static final Logger LOGGER = Logger.getLogger(BDBIndex.class
.getName());

private String bdbPath = null;
private String bdbName = null;
/**
* @throws DatabaseException
* @throws ConfigurationException
*/
public void init() throws IOException, ConfigurationException {
LOGGER.info("Starting BDBIndex with path: " + bdbPath + " and name: "
+ bdbName);
initializeDB(bdbPath,bdbName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public ResourceFileList getResourceFileList() throws IOException {
}
ResourceFileList list = new ResourceFileList();
populateFileList(list,root,recurse);
LOGGER.info("Returning list...");
java.util.Iterator<ResourceFileLocation> i = list.iterator();
while (i.hasNext()) {
LOGGER.info("- " + i.next().getUrl());
}
return list;
}

Expand All @@ -71,10 +76,12 @@ private void populateFileList(ResourceFileList list, File root, boolean recurse)
File[] files = root.listFiles();
if(files != null) {
for(File file : files) {
LOGGER.fine("Inspecting: " + file.getAbsolutePath());
if(file.isFile() && filter.accept(root, file.getName())) {
ResourceFileLocation location = new ResourceFileLocation(
file.getName(),file.getAbsolutePath());
list.add(location);
LOGGER.info("Added: " + file.getAbsolutePath());
} else if(recurse && file.isDirectory()){
populateFileList(list, file, recurse);
}
Expand Down Expand Up @@ -108,6 +115,7 @@ public String getName() {
}

public void setName(String name) {
LOGGER.info("Setting name to: " + name);
this.name = name;
}

Expand All @@ -118,6 +126,7 @@ public String getPrefix() {
return path;
}
public void setPrefix(String path) {
LOGGER.info("Setting prefix to: " + path);
this.path = path;
root = new File(path);
}
Expand All @@ -127,6 +136,7 @@ public boolean isRecurse() {
}

public void setRecurse(boolean recurse) {
LOGGER.info("Setting recurse to: " + recurse);
this.recurse = recurse;
}

Expand Down
103 changes: 95 additions & 8 deletions wayback-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<name>OpenWayback Web Application</name>
<packaging>war</packaging>

<properties>
<jetty.version>9.2.10.v20150310</jetty.version>
</properties>

<build>
<finalName>openwayback-${project.version}</finalName>
<plugins>
Expand All @@ -25,14 +29,85 @@
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<jettyXml>${project.basedir}/src/test/resources/jetty.xml</jettyXml>
<stopPort>1999</stopPort>
<stopKey>HALT</stopKey>
<webApp>
<descriptor>${project.basedir}/src/test/webapp/WEB-INF/web.xml</descriptor>
</webApp>
<useTestScope>true</useTestScope>
<systemProperties>
<systemProperty>
<name>wayback.warc.dir</name>
<value>${basedir}/src/test/resources/warcs</value>
</systemProperty>
<systemProperty>
<name>wayback.work.dir</name>
<value>${basedir}/target/wayback-work</value>
</systemProperty>
<systemProperty>
<name>wayback.host</name>
<value>localhost</value>
</systemProperty>
</systemProperties>
<includePluginDependencies>true</includePluginDependencies>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<!-- Run in the background so tests can execute: -->
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<excludes>
<exclude>**/integration/*Test.java
</exclude>
</excludes>
<includePluginDependencies>true</includePluginDependencies>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude>none</exclude>
</excludes>
<includes>
<include>**/integration/*Test.java
</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand All @@ -47,6 +122,18 @@
<artifactId>foresite</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
2 changes: 1 addition & 1 deletion wayback-webapp/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.netpreserve.openwayback.webapp.integration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
*
* @author Andrew Jackson <[email protected]>
*
*/
public class WaybackRequestTest {

@Before
public void await() throws InterruptedException {
// Give the newly booted OpenWayback instance a few seconds to index the
// test warc(s):
System.out.println("Pausing before testing...");
Thread.sleep(10 * 1000);
}

/**
*
* @throws IOException
*/
@Test
public void testInterject() throws IOException {
this.checkUrlContentType(
"http://localhost:18080/wayback/20120118143132/http://en.wikipedia.org/wiki/Main_Page",
"text/html; charset=UTF-8");
this.checkUrlContentType(
"http://localhost:18080/wayback/20120118143132/http://en.wikipedia.org/robots.txt",
"text/plain; charset=UTF-8");
}

/**
*
* @param url
* @param expectedType
* @throws IOException
*/
private void checkUrlContentType( String url, String expectedType ) throws IOException {
CloseableHttpClient httpclient = HttpClients.createSystem();
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse res = httpclient.execute(httpGet);
// Check response exists:
Assert.assertNotNull("Response for "+url+" should not be NULL.", res);
// Check the Content-Type:
assertNotNull("Content-Type should not be NULL for "+url, res.getFirstHeader("Content-Type"));
assertEquals( expectedType, res.getFirstHeader("Content-Type").getValue() );
// Download the content:
byte[] out = IOUtils.toByteArray(res.getEntity().getContent());
assertNotNull(out);
// Clean up:
res.close();
httpclient.close();
}

}
Loading