Major refactor to separate the webapp part from the embedded servlet engine part

git-svn-id: http://google-refine.googlecode.com/svn/trunk@883 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-05-28 23:19:08 +00:00
parent ce570016d7
commit 2c8595098c
1067 changed files with 1412 additions and 561 deletions

8
.gitignore vendored
View File

@ -1,4 +1,8 @@
.DS_Store
build/
src/main/webapp/WEB-INF/classes/
tests/java/classes/
server/classes/
main/webapp/WEB-INF/classes/
main/tests/server/classes/
main/test-output/
appengine/classes/
tools/

10
appengine/.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/gridworks"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/httpcore-4.0.1.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/httpcore-4.0.1-sources.jar"/>
<classpathentry kind="lib" path="/gridworks/webapp/WEB-INF/lib/httpclient-4.0.1.jar" sourcepath="/gridworks/webapp/WEB-INF/lib-src/httpclient-4.0.1-sources.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="com.google.appengine.eclipse.core.projectValidator"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="com.google.gdt.eclipse.core.webAppProjectValidator"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

43
appengine/.project Normal file
View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gridworks appengine</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/com.google.gdt.eclipse.core.webAppProjectValidator.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>com.google.appengine.eclipse.core.enhancerbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/com.google.appengine.eclipse.core.projectValidator.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.google.appengine.eclipse.core.gaeNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,3 @@
#Wed May 26 15:13:15 PDT 2010
eclipse.preferences.version=1
validationExclusions=src/com/metaweb/gridworks/appengine/*ClientConnection*.java

View File

@ -0,0 +1,5 @@
#Wed May 26 15:11:38 PDT 2010
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
warSrcDir=
warSrcDirIsOutput=true

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,243 @@
package com.metaweb.gridworks.appengine;
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.allowTruncate;
import java.io.ByteArrayOutputStream;
import java.net.InetAddress;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSession;
import org.apache.http.Header;
import org.apache.http.HttpConnectionMetrics;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPMethod;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
class AppEngineClientConnection implements ManagedClientConnection {
// Managed is the composition of ConnectionReleaseTrigger,
// HttpClientConnection, HttpConnection, HttpInetConnection
private HttpRoute _route;
private Object _state;
private boolean _reuseable;
public AppEngineClientConnection(HttpRoute route, Object state) {
_route = route;
_state = state;
}
// ManagedClientConnection methods
public HttpRoute getRoute() {
return _route;
}
public Object getState() {
return _state;
}
public SSLSession getSSLSession() {
return null;
}
public boolean isSecure() {
// XXX maybe parse the url to see if it's https?
return false;
}
public boolean isMarkedReusable() {
return _reuseable;
}
public void markReusable() {
_reuseable = true;
}
public void layerProtocol(HttpContext context, HttpParams params) {
return;
}
public void open(HttpRoute route, HttpContext context, HttpParams params) {
return;
}
public void setIdleDuration(long duration, TimeUnit unit) {
return;
}
public void setState(Object state) {
_state = state;
}
public void tunnelProxy(HttpHost next, boolean secure, HttpParams params) {
return;
}
public void tunnelTarget(boolean secure, HttpParams params) {
return;
}
public void unmarkReusable() {
_reuseable = false;
}
// ConnectionReleaseTrigger methods
public void releaseConnection() {
return;
}
public void abortConnection() {
return;
}
// HttpClientConnection methods
private HTTPRequest _appengine_hrequest;
private HTTPResponse _appengine_hresponse;
public void flush() {
return;
}
public boolean isResponseAvailable(int timeout) {
// XXX possibly use Async fetcher
return true;
}
public void receiveResponseEntity(org.apache.http.HttpResponse apache_response) {
byte[] data = _appengine_hresponse.getContent();
if (data != null) {
apache_response.setEntity(new ByteArrayEntity(data));
}
}
public HttpResponse receiveResponseHeader() {
URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
try {
_appengine_hresponse = ufs.fetch(_appengine_hrequest);
} catch (java.io.IOException e) {
throw new RuntimeException(e);
}
org.apache.http.HttpResponse apache_response =
new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 0),
_appengine_hresponse.getResponseCode(),
null);
for (HTTPHeader h : _appengine_hresponse.getHeaders()) {
apache_response.addHeader(h.getName(), h.getValue());
}
return apache_response;
}
public void sendRequestEntity(org.apache.http.HttpEntityEnclosingRequest request) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
org.apache.http.HttpEntity ent = request.getEntity();
if (ent != null) {
try {
ent.writeTo(os);
} catch (java.io.IOException e) {
throw new RuntimeException(e);
}
}
_appengine_hrequest.setPayload(os.toByteArray());
}
public void sendRequestHeader(org.apache.http.HttpRequest apache_request) {
URL request_url;
HttpHost host = _route.getTargetHost();
String protocol = host.getSchemeName();
String addr = host.getHostName();
int port = host.getPort();
String path = apache_request.getRequestLine().getUri();
try {
request_url = new URL(protocol, addr, port, path);
} catch (java.net.MalformedURLException e) {
throw new RuntimeException(e);
}
HTTPMethod method = HTTPMethod.valueOf(apache_request.getRequestLine().getMethod());
_appengine_hrequest = new HTTPRequest(request_url, method, allowTruncate()
.doNotFollowRedirects());
Header[] apache_headers = apache_request.getAllHeaders();
for (int i = 0; i < apache_headers.length; i++) {
Header h = apache_headers[i];
_appengine_hrequest
.setHeader(new HTTPHeader(h.getName(), h.getValue()));
}
}
// HttpConnection methods
public void close() {
return;
}
public HttpConnectionMetrics getMetrics() {
return null;
}
public int getSocketTimeout() {
return -1;
}
public boolean isOpen() {
return true;
}
public boolean isStale() {
return false;
}
public void setSocketTimeout(int timeout) {
return;
}
public void shutdown() {
return;
}
// HttpInetConnection methods
public InetAddress getLocalAddress() {
return null;
}
public int getLocalPort() {
return -1;
}
public InetAddress getRemoteAddress() {
return null;
}
public int getRemotePort() {
return -1;
}
}

View File

@ -0,0 +1,83 @@
package com.metaweb.gridworks.appengine;
import java.net.InetAddress;
import java.net.Socket;
import java.util.concurrent.TimeUnit;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionRequest;
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.scheme.SocketFactory;
import org.apache.http.params.HttpParams;
public class AppEngineClientConnectionManager implements ClientConnectionManager {
private SchemeRegistry schemes;
class NoopSocketFactory implements SocketFactory {
public Socket connectSocket(Socket sock, String host, int port,
InetAddress addr, int lport,
HttpParams params) {
return null;
}
public Socket createSocket() {
return null;
}
public boolean isSecure(Socket sock) {
return false;
}
}
public AppEngineClientConnectionManager() {
SocketFactory noop_sf = new NoopSocketFactory();
schemes = new SchemeRegistry();
schemes.register(new Scheme("http", noop_sf, 80));
schemes.register(new Scheme("https", noop_sf, 443));
}
public void closeExpiredConnections() {
return;
}
public void closeIdleConnections(long idletime, TimeUnit tunit) {
return;
}
public ManagedClientConnection getConnection(HttpRoute route, Object state) {
return new AppEngineClientConnection(route, state);
}
public SchemeRegistry getSchemeRegistry() {
return schemes;
}
public void releaseConnection(ManagedClientConnection conn,
long valid, TimeUnit tuint) {
return;
}
public ClientConnectionRequest requestConnection(final HttpRoute route,
final Object state) {
return new ClientConnectionRequest() {
public void abortRequest() {
return;
}
public ManagedClientConnection getConnection(long idletime,
TimeUnit tunit) {
return AppEngineClientConnectionManager.this.getConnection(route, state);
}
};
}
public void shutdown() {
return;
}
}

182
build.xml
View File

@ -29,6 +29,10 @@
<not><isset property="revision"/></not>
</condition>
<condition property="full_version" value="0.0.0.0">
<not><isset property="full_version"/></not>
</condition>
<condition property="build.dir" value="build">
<not><isset property="build.dir"/></not>
</condition>
@ -37,82 +41,119 @@
<not><isset property="dist.dir"/></not>
</condition>
<property name="src.dir" value="${basedir}/src/main/java" />
<property name="server.src.dir" value="${basedir}/src/server/java" />
<property name="graphics.dir" value="${basedir}/src/graphics" />
<property name="conf.dir" value="${basedir}/src/conf" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="tests.dir" value="${basedir}/tests/java" />
<property name="fullname" value="gridworks-${version}-${revision}" />
<property name="main.dir" value="${basedir}/main" />
<property name="webapp.dir" value="${main.dir}/webapp" />
<property name="webapp.src.dir" value="${main.dir}/src" />
<property name="webapp.lib.dir" value="${webapp.dir}/WEB-INF/lib" />
<property name="webapp.classes.dir" value="${webapp.dir}/WEB-INF/classes" />
<property name="server.dir" value="${basedir}/server" />
<property name="server.src.dir" value="${server.dir}/src" />
<property name="server.lib.dir" value="${server.dir}/lib" />
<property name="server.classes.dir" value="${server.dir}/classes" />
<property name="appengine.dir" value="${basedir}/appengine" />
<property name="appengine.src.dir" value="${appengine.dir}/src" />
<property name="appengine.lib.dir" value="${appengine.dir}/lib" />
<property name="appengine.classes.dir" value="${appengine.dir}/classes" />
<property name="tests.dir" value="${main.dir}/tests" />
<property name="server.tests.dir" value="${tests.dir}/server" />
<property name="server.tests.lib.dir" value="${server.tests.dir}/lib" />
<property name="server.tests.src.dir" value="${server.tests.dir}/src" />
<property name="server.tests.classes.dir" value="${server.tests.dir}/classes" />
<property name="graphics.dir" value="${basedir}/graphics" />
<property name="conf.dir" value="${basedir}/conf" />
<property name="tools.dir" value="${basedir}/tools" />
<property name="reports.dir" value="${build.dir}/reports" />
<property name="server_classes.dir" value="${build.dir}/classes" />
<property name="webapp_classes.dir" value="${basedir}/src/main/webapp/WEB-INF/classes" />
<property name="tests_classes.dir" value="${tests.dir}/classes" />
<property name="webapp.name" value="webapp" />
<property name="webapp.dir" value="${build.dir}/${webapp.name}" />
<property name="built.webapp.name" value="webapp" />
<property name="built.webapp.dir" value="${build.dir}/${built.webapp.name}" />
<property name="mac.dir" value="${build.dir}/mac" />
<property name="windows.dir" value="${build.dir}/windows" />
<property name="linux.name" value="gridworks-${version}" />
<property name="linux.dir" value="${build.dir}/linux/${linux.name}" />
<path id="class.path">
<fileset dir="${lib.dir}">
<path id="server.class.path">
<fileset dir="${server.lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${server_classes.dir}"/>
<pathelement location="${webapp_classes.dir}"/>
<pathelement location="${server.classes.dir}"/>
</path>
<path id="webapp.class.path">
<fileset dir="${server.lib.dir}">
<include name="**/servlet-api*.jar" />
</fileset>
<fileset dir="${webapp.lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${webapp.classes.dir}"/>
</path>
<path id="tests.class.path">
<path refid="class.path"/>
<fileset dir="${tests.dir}/lib">
<path refid="webapp.class.path"/>
<fileset dir="${server.tests.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- NOTE(SM): this is needed to support autoreloading, don't remove! -->
<target name="build_server">
<mkdir dir="${server_classes.dir}" />
<javac srcdir="${server.src.dir}" destdir="${server_classes.dir}" debug="true" includeAntRuntime="no">
<classpath refid="class.path" />
<mkdir dir="${server.classes.dir}" />
<javac srcdir="${server.src.dir}" destdir="${server.classes.dir}" debug="true" includeAntRuntime="no">
<classpath refid="server.class.path" />
</javac>
<copy file="${server.src.dir}/log4j.properties" tofile="${server_classes.dir}/log4j.properties"/>
<copy file="${server.src.dir}/log4j.properties" tofile="${server.classes.dir}/log4j.properties"/>
</target>
<target name="build" depends="build_server">
<mkdir dir="${webapp_classes.dir}" />
<javac destdir="${webapp_classes.dir}" debug="true" includeAntRuntime="no">
<src path="${server.src.dir}"/>
<src path="${src.dir}"/>
<classpath refid="class.path" />
<target name="build_webapp">
<mkdir dir="${webapp.classes.dir}" />
<javac destdir="${webapp.classes.dir}" debug="true" includeAntRuntime="no">
<src path="${webapp.src.dir}"/>
<classpath refid="webapp.class.path" />
</javac>
<copy file="${server.src.dir}/log4j.properties" tofile="${webapp_classes.dir}/log4j.properties"/>
</target>
<target name="build_tests" depends="build">
<mkdir dir="${tests_classes.dir}" />
<javac srcdir="${tests.dir}/src" destdir="${tests_classes.dir}" debug="true" includeAntRuntime="no">
<target name="build_tests" depends="build_webapp">
<mkdir dir="${server.tests.classes.dir}" />
<javac srcdir="${server.tests.src.dir}" destdir="${server.tests.classes.dir}" debug="true" includeAntRuntime="no">
<classpath refid="tests.class.path" />
</javac>
<copy file="${tests.dir}/src/log4j.properties" tofile="${tests_classes.dir}/log4j.properties"/>
<copy file="${server.tests.src.dir}/log4j.properties" tofile="${server.tests.classes.dir}/log4j.properties"/>
</target>
<target name="jar" depends="build">
<jar destfile="${build.dir}/gridworks.jar" basedir="${webapp_classes.dir}"/>
<target name="build" depends="build_server, build_webapp"/>
<target name="jar_server" depends="build_server">
<jar destfile="${build.dir}/${fullname}-server.jar" basedir="${webapp.classes.dir}"/>
</target>
<target name="jar_webapp" depends="build_webapp">
<jar destfile="${build.dir}/${fullname}.jar" basedir="${webapp.classes.dir}"/>
</target>
<target name="prepare_webapp">
<mkdir dir="${webapp.dir}" />
<target name="jar" depends="jar_server, jar_webapp"/>
<target name="prepare_webapp" depends="jar_webapp">
<mkdir dir="${built.webapp.dir}" />
<copy todir="${webapp.dir}">
<fileset dir="${basedir}/src/main/webapp">
<copy todir="${built.webapp.dir}">
<fileset dir="${webapp.dir}">
<include name="**/*"/>
<exclude name="WEB-INF/classes/**"/>
<exclude name="WEB-INF/lib-src/**"/>
</fileset>
</copy>
<replace file="${webapp.dir}/scripts/version.js">
<copy file="${build.dir}/${fullname}.jar" tofile="${built.webapp.dir}/WEB-INF/lib/${fullname}.jar"/>
<replace file="${built.webapp.dir}/scripts/version.js">
<replacefilter token="$VERSION" value="${version}"/>
<replacefilter token="$REVISION" value="${revision}"/>
</replace>
@ -144,16 +185,13 @@
liveresize="true"
growboxintrudes="true"
screenmenu="true">
<jarfileset dir="${lib.dir}">
<jarfilelist dir="${build.dir}" files="${fullname}-server.jar" />
<jarfileset dir="${server.lib.dir}">
<exclude name="**/.svn" />
<include name="**/*.jar" />
</jarfileset>
<jarfilelist dir="${build.dir}" files="gridworks.jar" />
<resourcefileset dir="${webapp.dir}/..">
<include name="${webapp.name}/**" />
</resourcefileset>
<resourcefileset dir="${lib.dir}/..">
<include name="lib/jython/**" />
<resourcefileset dir="${built.webapp.dir}/..">
<include name="${built.webapp.name}/**" />
</resourcefileset>
</jarbundler>
</target>
@ -169,7 +207,7 @@
<config
headerType="console"
outfile="${windows.dir}/Gridworks.exe"
jarPath="lib/gridworks-${version}-${revision}.jar"
jarPath="lib/${fullname}.jar"
dontWrapJar="true"
icon="${graphics.dir}/icon/gridworks.ico">
<classPath mainClass="com.metaweb.gridworks.Gridworks">
@ -192,29 +230,25 @@
/>
</config>
</launch4j>
<copy file="${build.dir}/${fullname}-server.jar" tofile="${windows.dir}/${fullname}-server.jar"/>
<copy todir="${windows.dir}/lib">
<fileset dir="${lib.dir}">
<fileset dir="${server.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<copy todir="${windows.dir}/lib/native/windows">
<fileset dir="${lib.dir}/native/windows">
<fileset dir="${server.lib.dir}/native/windows">
<include name="*.dll"/>
</fileset>
</copy>
<copy file="${build.dir}/gridworks.jar" tofile="${windows.dir}/lib/gridworks-${version}-${revision}.jar"/>
<copy todir="${windows.dir}/lib/jython">
<fileset dir="${lib.dir}/jython">
<include name="**"/>
</fileset>
</copy>
<copy file="${build.dir}/${fullname}.jar" tofile="${windows.dir}/${fullname}.jar"/>
<copy todir="${windows.dir}/webapp">
<fileset dir="${webapp.dir}">
<include name="**"/>
</fileset>
</copy>
<copy todir="${linux.dir}/licenses">
<copy todir="${windows.dir}/licenses">
<fileset dir="${basedir}/licenses">
<include name="**"/>
</fileset>
@ -232,19 +266,14 @@
<mkdir dir="${linux.dir}"/>
<copy todir="${linux.dir}/lib">
<fileset dir="${lib.dir}">
<fileset dir="${server.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<copy file="${build.dir}/gridworks.jar" tofile="${linux.dir}/lib/gridworks-${version}-${revision}.jar"/>
<copy file="${build.dir}/${fullname}-server.jar" tofile="${linux.dir}/lib/${fullname}-server.jar"/>
<copy todir="${linux.dir}/lib/jython">
<fileset dir="${lib.dir}/jython">
<include name="**"/>
</fileset>
</copy>
<copy todir="${linux.dir}/src/main/webapp">
<copy todir="${linux.dir}/webapp">
<fileset dir="${webapp.dir}">
<include name="**"/>
</fileset>
@ -281,9 +310,9 @@
classpath="${findbugs.dir}/lib/findbugs-ant.jar"
/>
<findbugs jvmargs="-Xmx1024m" home="${findbugs.dir}" output="html" outputFile="${reports.dir}/findbugs.html" >
<auxClasspath refid="class.path" />
<sourcePath path="${src.dir}" />
<class location="${webapp_classes.dir}" />
<auxClasspath refid="webapp.class.path" />
<sourcePath path="${webapp.src.dir}" />
<class location="${webapp.classes.dir}" />
</findbugs>
</target>
@ -301,10 +330,10 @@
<fileset dir="${server.src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src.dir}">
<fileset dir="${webapp.src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${tests.dir}">
<fileset dir="${server.tests.src.dir}">
<include name="**/*.java"/>
</fileset>
</pmd>
@ -323,7 +352,7 @@
<fileset dir="${server.src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src.dir}">
<fileset dir="${webapp.src.dir}">
<include name="**/*.java"/>
</fileset>
</cpd>
@ -340,17 +369,18 @@
/>
<jslint>
<formatter type="plain" destfile="${reports.dir}/jslint.txt" />
<fileset dir="${basedir}/src/main/webapp/scripts">
<fileset dir="${webapp.dir}/scripts">
<include name="**/*.js" />
</fileset>
</jslint>
</target>
<target name="clean">
<delete file="${build.dir}/gridworks.jar" />
<delete dir="${server_classes.dir}" />
<delete dir="${webapp_classes.dir}" />
<delete dir="${tests_classes.dir}" />
<delete file="${build.dir}/${fullname}.jar" />
<delete file="${build.dir}/${fullname}-server.jar" />
<delete dir="${server.classes.dir}" />
<delete dir="${webapp.classes.dir}" />
<delete dir="${server.tests.classes.dir}" />
</target>
<target name="distclean" depends="clean">

View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -369,7 +369,7 @@ ant() {
#export ANT_OPTS="-Xmx1024M"
"$ANT" -f build.xml $ANT_PARAMS -Dbuild.dir="$GRIDWORKS_BUILD_DIR" -Ddist.dir="$GRIDWORKS_DIST_DIR" -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Dfull_version="$FULL_VERSION" -Drevision="$REVISION" $1 || error "Error while running ant task '$1'"
"$ANT" -f build.xml $ANT_PARAMS -Dversion="$VERSION" -Dnum_version="$NUM_VERSION" -Dfull_version="$FULL_VERSION" -Drevision="$REVISION" $1 || error "Error while running ant task '$1'"
}
# ----------------------------------------------------------------------------------------------
@ -383,7 +383,7 @@ dist() {
echo
echo "Upload them to the distibution site, then prepend the GridworksReleases array at"
echo
echo " http://acre.freebase.com/#app=/user/dfhuynh/labs-site&file=gridworks.js"
echo " http://code.google.com/p/freebase-gridworks/source/browse/support/releases.js"
echo
echo "with"
echo
@ -427,7 +427,7 @@ mac_dist() {
ant mac
mkdir -p "$GRIDWORKS_BUILD_DIR/mac/.background"
cp src/graphics/dmg_background/dmg_background.png "$GRIDWORKS_BUILD_DIR/mac/.background/dmg_background.png"
cp graphics/dmg_background/dmg_background.png "$GRIDWORKS_BUILD_DIR/mac/.background/dmg_background.png"
SIZE=60
@ -526,10 +526,10 @@ server_test() {
ant build_tests
echo ""
CLASSPATH="$GRIDWORKS_TEST_DIR/java/classes${SEP}$GRIDWORKS_WEBAPP/WEB-INF/classes${SEP}$GRIDWORKS_BUILD_DIR/classes${SEP}$GRIDWORKS_TEST_DIR/java/lib/*${SEP}$GRIDWORKS_LIB_DIR/*${SEP}$GRIDWORKS_WEBAPP/WEB-INF/lib/*"
CLASSPATH="$GRIDWORKS_TEST_DIR/server/classes${SEP}$GRIDWORKS_WEBAPP/WEB-INF/classes${SEP}$GRIDWORKS_CLASSES_DIR${SEP}$GRIDWORKS_TEST_DIR/server/lib/*${SEP}$GRIDWORKS_LIB_DIR/*${SEP}$GRIDWORKS_WEBAPP/WEB-INF/lib/*"
if [ -z "$1" ]; then
TESTS="-excludegroups broken $GRIDWORKS_TEST_DIR/java/conf/tests.xml"
TESTS="-excludegroups broken $GRIDWORKS_TEST_DIR/server/conf/tests.xml"
else
TESTS="-testclass $1"
fi
@ -545,7 +545,7 @@ server_test() {
run() {
FORK=$1
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ]; then
if [ ! -d $GRIDWORKS_CLASSES_DIR ]; then
IS_JAR=`ls $GRIDWORKS_LIB_DIR | grep gridworks`
if [ -z "$IS_JAR" ]; then
ant build
@ -559,19 +559,19 @@ run() {
warn "Gridworks is already running."
fi
if [ -d $GRIDWORKS_BUILD_DIR/classes ]; then
if [ -d $GRIDWORKS_CLASSES_DIR ]; then
add_option "-Dgridworks.autoreloading=true"
fi
if $DARWIN ; then
add_option "-Xdock:name=Gridworks -Xdock:icon=src/graphics/icon/gridworks.icns"
add_option "-Xdock:name=Gridworks -Xdock:icon=graphics/icon/gridworks.icns"
fi
if [ "$GRIDWORKS_DATA_DIR" ]; then
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
fi
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes${SEP}$GRIDWORKS_LIB_DIR/*"
CLASSPATH="$GRIDWORKS_CLASSES_DIR${SEP}$GRIDWORKS_LIB_DIR/*"
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
@ -588,22 +588,6 @@ run() {
GRIDWORKS_PID="$!"
fi
}
execute() {
if [ ! -d $GRIDWORKS_BUILD_DIR/classes ]; then
ant build
echo ""
fi
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes${SEP}$GRIDWORKS_LIB_DIR/*"
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS $*"
#echo "$RUN_CMD"
#echo ""
exec $RUN_CMD $*
}
findbugs() {
findbugs_prepare
@ -761,22 +745,26 @@ fi
add_option "-Dgridworks.host=$GRIDWORKS_HOST"
if [ -z "$GRIDWORKS_WEBAPP" ]; then
GRIDWORKS_WEBAPP="src/main/webapp"
GRIDWORKS_WEBAPP="main/webapp"
fi
add_option "-Dgridworks.webapp=$GRIDWORKS_WEBAPP"
if [ -z "$GRIDWORKS_TEST_DIR" ]; then
GRIDWORKS_TEST_DIR="tests"
GRIDWORKS_TEST_DIR="main/tests"
fi
if [ -z "$GRIDWORKS_CLASSES_DIR" ]; then
GRIDWORKS_CLASSES_DIR="server/classes"
fi
if [ -z "$GRIDWORKS_LIB_DIR" ]; then
GRIDWORKS_LIB_DIR="server/lib"
fi
if [ -z "$GRIDWORKS_BUILD_DIR" ]; then
GRIDWORKS_BUILD_DIR="build"
fi
if [ -z "$GRIDWORKS_LIB_DIR" ]; then
GRIDWORKS_LIB_DIR="lib"
fi
if [ -z "$GRIDWORKS_TOOLS_DIR" ]; then
GRIDWORKS_TOOLS_DIR="tools"
fi
@ -791,9 +779,9 @@ fi
add_option "-Dgridworks.verbosity=$GRIDWORKS_VERBOSITY"
if [ -z "$JYTHONPATH" ]; then
JYTHONPATH="$GRIDWORKS_LIB_DIR/jython"
JYTHONPATH="$GRIDWORKS_WEBAPP/WEB-INF/lib/jython"
else
JYTHONPATH="$GRIDWORKS_LIB_DIR/jython/${SEP}$JYTHONPATH"
JYTHONPATH="$GRIDWORKS_WEBAPP/WEB-INF/lib/jython${SEP}$JYTHONPATH"
fi
add_option "-Dpython.path=$JYTHONPATH"
@ -815,7 +803,6 @@ case "$ACTION" in
cpd) cpd;;
jslint) jslint;;
run) run;;
execute) execute $*;;
mac_dist) mac_dist $1;;
windows_dist) windows_dist $1;;
linux_dist) linux_dist $1;;

View File

@ -141,16 +141,16 @@ set GRIDWORKS_HOST=127.0.0.1
set OPTS=%OPTS% -Dgridworks.host=%GRIDWORKS_HOST%
if not "%GRIDWORKS_WEBAPP%" == "" goto gotHost
set GRIDWORKS_WEBAPP=src\main\webapp
set GRIDWORKS_WEBAPP=main\webapp
:gotHOST
set OPTS=%OPTS% -Dgridworks.webapp=%GRIDWORKS_WEBAPP%
if not "%GRIDWORKS_BUILD_DIR%" == "" goto gotBuildDir
set GRIDWORKS_BUILD_DIR=build
set GRIDWORKS_BUILD_DIR=server\build
:gotBuildDir
if not "%GRIDWORKS_LIB_DIR%" == "" goto gotLibDir
set GRIDWORKS_LIB_DIR=lib
set GRIDWORKS_LIB_DIR=server\lib
:gotLibDir
rem ----- Respond to the action ----------------------------------------------------------
@ -164,7 +164,7 @@ if ""%ACTION%"" == ""run"" goto doRun
:doRun
set CLASSPATH="%GRIDWORKS_BUILD_DIR%\classes;%GRIDWORKS_LIB_DIR%\*"
"%JAVA_HOME%\bin\java.exe" -cp %CLASSPATH% %OPTS% -Djava.library.path=lib/native/windows com.metaweb.gridworks.Gridworks
"%JAVA_HOME%\bin\java.exe" -cp %CLASSPATH% %OPTS% -Djava.library.path=%GRIDWORKS_LIB_DIR%/native/windows com.metaweb.gridworks.Gridworks
goto end
:doAnt

202
licenses/gaevfs.LICENSE.txt Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

38
main/.classpath Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests/server/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-codec-1.4.jar" sourcepath="webapp/WEB-INF/lib-src/commons-codec-1.4-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-lang-2.5.jar" sourcepath="webapp/WEB-INF/lib-src/commons-lang-2.5-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/commons-fileupload-1.2.1.jar" sourcepath="webapp/WEB-INF/lib-src/commons-fileupload-1.2.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/json-20100208.jar" sourcepath="webapp/WEB-INF/lib-src/json-20100208-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/icu4j-4.2.1.jar" sourcepath="webapp/WEB-INF/lib-src/icu4j-4.2.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/arithcode-1.1.jar" sourcepath="webapp/WEB-INF/lib-src/arithcode-1.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/secondstring-20100303.jar" sourcepath="webapp/WEB-INF/lib-src/secondstring-20100303-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/ant-tools-1.8.0.jar" sourcepath="webapp/WEB-INF/lib-src/ant-tools-1.8.0-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/vicino-1.1.jar" sourcepath="webapp/WEB-INF/lib-src/vicino-1.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpcore-4.0.1.jar" sourcepath="webapp/WEB-INF/lib-src/httpcore-4.0.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/httpclient-4.0.1.jar" sourcepath="webapp/WEB-INF/lib-src/httpclient-4.0.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/signpost-core-1.2.1.1.jar" sourcepath="webapp/WEB-INF/lib-src/signpost-core-1.2.1.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/signpost-commonshttp4-1.2.1.1.jar" sourcepath="webapp/WEB-INF/lib-src/signpost-commonshttp4-1.2.1.1-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/opencsv-2.2.jar" sourcepath="tests/java/lib-src/opencsv-2.2-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-3.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-ooxml-3.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/poi-ooxml-schemas-3.6-20091214.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/xmlbeans-2.3.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jython-2.5.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/clojure-1.1.0.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jackson-core-asl-1.5.1.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/marc4j-2.4.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jrdf-0.5.6.jar"/>
<classpathentry kind="lib" path="tests/server/lib/mockito-all-1.8.4.jar" sourcepath="tests/server/lib-src/mockito-all-1.8.4-sources.jar"/>
<classpathentry kind="lib" path="tests/server/lib/testng-5.12.1.jar" sourcepath="tests/server/lib-src/testng-5.12.1-sources.jar"/>
<classpathentry kind="lib" path="/gridworks server/lib/servlet-api-2.5.jar" sourcepath="/gridworks server/lib-src/servlet-api-2.5-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/jcl-over-slf4j-1.5.6.jar" sourcepath="webapp/WEB-INF/lib-src/jcl-over-slf4j-1.5.6-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar" sourcepath="webapp/WEB-INF/lib/slf4j-api-1.5.6.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar" sourcepath="webapp/WEB-INF/lib-src/slf4j-log4j12-1.5.6-sources.jar"/>
<classpathentry kind="lib" path="webapp/WEB-INF/lib/log4j-1.2.15.jar" sourcepath="webapp/WEB-INF/lib-src/log4j-1.2.15-sources.jar"/>
<classpathentry kind="output" path="webapp/WEB-INF/classes"/>
</classpath>

View File

@ -6,7 +6,7 @@
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.testng.remote.RemoteTestNG"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gridworks"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:gridworks/build}"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:gridworks/tests/server}"/>
<mapAttribute key="org.testng.eclipse.ALL_CLASS_METHODS"/>
<listAttribute key="org.testng.eclipse.CLASS_TEST_LIST"/>
<stringAttribute key="org.testng.eclipse.COMPLIANCE_LEVEL" value="JDK"/>
@ -15,7 +15,7 @@
<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="2"/>
<listAttribute key="org.testng.eclipse.PACKAGE_TEST_LIST"/>
<listAttribute key="org.testng.eclipse.SUITE_TEST_LIST">
<listEntry value="tests/java/conf/tests.xml"/>
<listEntry value="tests/server/conf/tests.xml"/>
</listAttribute>
<intAttribute key="org.testng.eclipse.TYPE" value="3"/>
</launchConfiguration>

View File

@ -0,0 +1,38 @@
Gridworks Helpers for Eclipse
-----------------------------
This file contains Eclipse-specific help files that can get simplify your life
developing Gridworks with Eclipse (http://www.eclipse.org/).
Launch Files (*.launch)
-----------------------
These are files that help you running Gridworks directly from eclipse without having to execute
the shell scripts.
To run, right click on the files directly from Eclipse, then do "Run As -> <name>".
Code Style Format Configurations (Gridworks.style.xml)
------------------------------------------------------
This is the code formatting configurations that all Gridworks developers should follow.
To import, open the Eclipse preferences, then follow to "Java > Code Style > Formatter"
and click the "Import" button and load the file.
- o -
Thank you for your interest.
The Freebase Gridworks Development Team
http://code.google.com/p/freebase-gridworks/

View File

@ -1,11 +1,13 @@
package com.metaweb.gridworks;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -18,8 +20,12 @@ import com.metaweb.gridworks.commands.Command;
public class GridworksServlet extends HttpServlet {
static private final String VERSION = "1.0";
private static final long serialVersionUID = 2386057901503517403L;
private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir";
static final private Map<String, Command> commands = new HashMap<String, Command>();
// timer for periodically saving projects
@ -104,11 +110,12 @@ public class GridworksServlet extends HttpServlet {
{"mqlwrite", "com.metaweb.gridworks.commands.freebase.MQLWriteCommand"},
};
static {
registerCommands(commandNames);
public static String getVersion() {
return VERSION;
}
final static protected long s_autoSavePeriod = 1000 * 60 * 5; // 5 minutes
static protected class AutoSaveTimerTask extends TimerTask {
public void run() {
try {
@ -121,12 +128,21 @@ public class GridworksServlet extends HttpServlet {
}
}
protected ServletConfig config;
@Override
public void init() throws ServletException {
super.init();
logger.trace("> initialize");
ProjectManager.initialize();
String data = getInitParameter("gridworks.data");
if (data == null) {
throw new ServletException("can't find servlet init config 'gridworks.data', I have to give up initializing");
}
registerCommands(commandNames);
ProjectManager.initialize(new File(data));
if (_timer == null) {
_timer = new Timer("autosave");
@ -149,6 +165,8 @@ public class GridworksServlet extends HttpServlet {
ProjectManager.singleton.save(true); // complete save
ProjectManager.singleton = null;
}
this.config = null;
super.destroy();
@ -188,6 +206,26 @@ public class GridworksServlet extends HttpServlet {
return slash > 0 ? commandName.substring(0, slash) : commandName;
}
private File tempDir = null;
public File getTempDir() {
if (tempDir == null) {
File tempDir = (File) this.config.getServletContext().getAttribute(JAVAX_SERVLET_CONTEXT_TEMPDIR);
if (tempDir == null) {
throw new RuntimeException("This app server doesn't support temp directories");
}
}
return tempDir;
}
public File getTempFile(String name) {
return new File(getTempDir(), name);
}
public String getConfiguration(String name, String def) {
return null;
}
/**
* Register an array of commands
*
@ -198,7 +236,7 @@ public class GridworksServlet extends HttpServlet {
* the second.
* @return false if any commands failed to load
*/
static public boolean registerCommands(String[][] commands) {
private boolean registerCommands(String[][] commands) {
boolean status = true;
for (String[] command : commandNames) {
String commandName = command[0];
@ -206,8 +244,7 @@ public class GridworksServlet extends HttpServlet {
logger.debug("Loading command " + commandName + " class: " + className);
Command cmd;
try {
// TODO: May need to use the servlet container's class loader here
cmd = (Command) Class.forName(className).newInstance();
cmd = (Command) this.getClass().getClassLoader().loadClass(className).newInstance();
} catch (InstantiationException e) {
logger.error("Failed to load command class " + className, e);
status = false;
@ -235,8 +272,7 @@ public class GridworksServlet extends HttpServlet {
* object implementing the command
* @return true if command was loaded and registered successfully
*/
static public boolean registerCommand(String name,
Command commandObject) {
protected boolean registerCommand(String name, Command commandObject) {
if (commands.containsKey(name)) {
return false;
}
@ -245,7 +281,7 @@ public class GridworksServlet extends HttpServlet {
}
// Currently only for test purposes
static protected boolean unregisterCommand(String verb) {
protected boolean unregisterCommand(String verb) {
return commands.remove(verb) != null;
}
}

View File

@ -22,8 +22,6 @@ import org.json.JSONWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.codeberry.jdatapath.DataPath;
import com.codeberry.jdatapath.JDataPathSystem;
import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.util.JSONUtilities;
@ -58,112 +56,13 @@ public class ProjectManager {
static public ProjectManager singleton;
static public synchronized void initialize() {
static public synchronized void initialize(File dir) {
if (singleton == null) {
File dir = getProjectLocation();
logger.info("Using workspace directory: {}", dir.getAbsolutePath());
singleton = new ProjectManager(dir);
}
}
static protected File getProjectLocation() {
String data_dir = Configurations.get("gridworks.data_dir");
if (data_dir != null) {
return new File(data_dir);
}
String os = Configurations.get("os.name").toLowerCase();
if (os.contains("windows")) {
try {
// NOTE(SM): finding the "local data app" in windows from java is actually a PITA
// see http://stackoverflow.com/questions/1198911/how-to-get-local-application-data-folder-in-java
// so we're using a library that uses JNI to ask directly the win32 APIs,
// it's not elegant but it's the safest bet.
DataPath localDataPath = JDataPathSystem.getLocalSystem().getLocalDataPath("Gridworks");
File data = new File(fixWindowsUnicodePath(localDataPath.getPath()));
data.mkdirs();
return data;
} catch (Error e) {
/*
* The above trick can fail, particularly on a 64-bit OS as the jdatapath.dll
* we include is compiled for 32-bit. In this case, we just have to dig up
* environment variables and try our best to find a user-specific path.
*/
logger.warn("Failed to use jdatapath to detect user data path: resorting to environment variables");
File parentDir = null;
{
String appData = System.getenv("APPDATA");
if (appData != null && appData.length() > 0) {
// e.g., C:\Users\[userid]\AppData\Roaming
parentDir = new File(appData);
} else {
String userProfile = System.getenv("USERPROFILE");
if (userProfile != null && userProfile.length() > 0) {
// e.g., C:\Users\[userid]
parentDir = new File(userProfile);
}
}
}
if (parentDir == null) {
parentDir = new File(".");
}
File data = new File(parentDir, "Gridworks");
data.mkdirs();
return data;
}
} else if (os.contains("mac os x")) {
// on macosx, use "~/Library/Application Support"
String home = System.getProperty("user.home");
String data_home = (home != null) ? home + "/Library/Application Support/Gridworks" : ".gridworks";
File data = new File(data_home);
data.mkdirs();
return data;
} else { // most likely a UNIX flavor
// start with the XDG environment
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
String data_home = System.getenv("XDG_DATA_HOME");
if (data_home == null) { // if not found, default back to ~/.local/share
String home = System.getProperty("user.home");
if (home == null) home = ".";
data_home = home + "/.local/share";
}
File data = new File(data_home + "/gridworks");
data.mkdirs();
return data;
}
}
/**
* For Windows file paths that contain user IDs with non ASCII characters,
* those characters might get replaced with ?. We need to use the environment
* APPDATA value to substitute back the original user ID.
*/
static protected String fixWindowsUnicodePath(String path) {
int q = path.indexOf('?');
if (q < 0) {
return path;
}
int pathSep = path.indexOf(File.separatorChar, q);
String goodPath = System.getenv("APPDATA");
if (goodPath == null || goodPath.length() == 0) {
goodPath = System.getenv("USERPROFILE");
if (!goodPath.endsWith(File.separator)) {
goodPath = goodPath + File.separator;
}
}
int goodPathSep = goodPath.indexOf(File.separatorChar, q);
return path.substring(0, q) + goodPath.substring(q, goodPathSep) + path.substring(pathSep);
}
private ProjectManager(File dir) {
_workspaceDir = dir;
_workspaceDir.mkdirs();

View File

@ -59,7 +59,6 @@ public class Engine implements Jsonizable {
public FilteredRows getAllRows() {
return new FilteredRows() {
@Override
public void accept(Project project, RowVisitor visitor) {
try {
visitor.start(project);
@ -100,7 +99,6 @@ public class Engine implements Jsonizable {
public FilteredRecords getAllRecords() {
return new FilteredRecords() {
@Override
public void accept(Project project, RecordVisitor visitor) {
try {
visitor.start(project);

View File

@ -58,9 +58,7 @@ public class ListFacet implements Facet {
public ListFacet() {
}
@Override
public void write(JSONWriter writer, Properties options)
throws JSONException {
public void write(JSONWriter writer, Properties options) throws JSONException {
writer.object();
writer.key("name"); writer.value(_name);
@ -98,7 +96,6 @@ public class ListFacet implements Facet {
writer.endObject();
}
@Override
public void initializeFromJSON(Project project, JSONObject o) throws Exception {
_name = o.getString("name");
_expression = o.getString("expression");
@ -147,7 +144,6 @@ public class ListFacet implements Facet {
_selectError = JSONUtilities.getBoolean(o, "selectError", false);
}
@Override
public RowFilter getRowFilter(Project project) {
return
_eval == null ||
@ -164,13 +160,11 @@ public class ListFacet implements Facet {
_invert);
}
@Override
public RecordFilter getRecordFilter(Project project) {
RowFilter rowFilter = getRowFilter(project);
return rowFilter == null ? null : new AnyRowRecordFilter(rowFilter);
}
@Override
public void computeChoices(Project project, FilteredRows filteredRows) {
if (_eval != null && _errorMessage == null) {
ExpressionNominalValueGrouper grouper =
@ -182,7 +176,6 @@ public class ListFacet implements Facet {
}
}
@Override
public void computeChoices(Project project, FilteredRecords filteredRecords) {
if (_eval != null && _errorMessage == null) {
ExpressionNominalValueGrouper grouper =

View File

@ -174,7 +174,6 @@ public class RangeFacet implements Facet {
}
}
@Override
public RecordFilter getRecordFilter(Project project) {
RowFilter rowFilter = getRowFilter(project);
return rowFilter == null ? null : new AnyRowRecordFilter(rowFilter);

View File

@ -87,17 +87,14 @@ public class ScatterplotDrawingRowVisitor implements RowVisitor, RecordVisitor {
g2.setPaint(color);
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}
@Override
public boolean visit(Project project, int rowIndex, Row row) {
Cell cellx = row.getCell(col_x);
Cell celly = row.getCell(col_y);
@ -118,7 +115,6 @@ public class ScatterplotDrawingRowVisitor implements RowVisitor, RecordVisitor {
return false;
}
@Override
public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
visit(project, r, project.rows.get(r));

View File

@ -276,7 +276,6 @@ public class ScatterplotFacet implements Facet {
}
}
@Override
public RecordFilter getRecordFilter(Project project) {
RowFilter rowFilter = getRowFilter(project);
return rowFilter == null ? null : new AnyRowRecordFilter(rowFilter);

View File

@ -36,10 +36,7 @@ public class TextSearchFacet implements Facet {
public TextSearchFacet() {
}
@Override
public void write(JSONWriter writer, Properties options)
throws JSONException {
public void write(JSONWriter writer, Properties options) throws JSONException {
writer.object();
writer.key("name"); writer.value(_name);
writer.key("columnName"); writer.value(_columnName);
@ -49,7 +46,6 @@ public class TextSearchFacet implements Facet {
writer.endObject();
}
@Override
public void initializeFromJSON(Project project, JSONObject o) throws Exception {
_name = o.getString("name");
_columnName = o.getString("columnName");
@ -77,7 +73,6 @@ public class TextSearchFacet implements Facet {
}
}
@Override
public RowFilter getRowFilter(Project project) {
if (_query == null || _query.length() == 0) {
return null;
@ -102,18 +97,15 @@ public class TextSearchFacet implements Facet {
}
}
@Override
public RecordFilter getRecordFilter(Project project) {
RowFilter rowFilter = getRowFilter(project);
return rowFilter == null ? null : new AnyRowRecordFilter(rowFilter);
}
@Override
public void computeChoices(Project project, FilteredRows filteredRows) {
// nothing to do
}
@Override
public void computeChoices(Project project, FilteredRecords filteredRecords) {
// nothing to do
}

View File

@ -6,13 +6,13 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Record;
public class AnyRowRecordFilter implements RecordFilter {
final protected RowFilter _rowFilter;
final protected RowFilter _rowFilter;
public AnyRowRecordFilter(RowFilter rowFilter) {
_rowFilter = rowFilter;
}
@Override
public boolean filterRecord(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
if (_rowFilter.filterRow(project, r, project.rows.get(r))) {

View File

@ -13,13 +13,13 @@ import com.metaweb.gridworks.model.Record;
* Encapsulate logic for visiting records that match all given record filters.
*/
public class ConjunctiveFilteredRecords implements FilteredRecords {
final protected List<RecordFilter> _recordFilters = new LinkedList<RecordFilter>();
public void add(RecordFilter recordFilter) {
_recordFilters.add(recordFilter);
}
@Override
public void accept(Project project, RecordVisitor visitor) {
try {
visitor.start(project);

View File

@ -9,22 +9,20 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Row;
public class ExpressionBasedRowEvaluable implements RowEvaluable {
final protected String _columnName;
final protected int _cellIndex;
final protected Evaluable _eval;
public ExpressionBasedRowEvaluable(
String columnName, int cellIndex, Evaluable eval) {
_columnName = columnName;
_cellIndex = cellIndex;
_eval = eval;
}
@Override
public Object eval(
Project project, int rowIndex, Row row, Properties bindings) {
final protected String _columnName;
final protected int _cellIndex;
final protected Evaluable _eval;
public ExpressionBasedRowEvaluable(String columnName, int cellIndex, Evaluable eval) {
_columnName = columnName;
_cellIndex = cellIndex;
_eval = eval;
}
public Object eval(Project project, int rowIndex, Row row, Properties bindings) {
Cell cell = row.getCell(_cellIndex);
ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell);

View File

@ -58,12 +58,10 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
_cellIndex = cellIndex;
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}
@ -86,7 +84,6 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
return false;
}
@Override
public boolean visit(Project project, Record record) {
hasError = false;
hasBlank = false;
@ -164,12 +161,10 @@ public class ExpressionNominalValueGrouper implements RowVisitor, RecordVisitor
public RowEvaluable getChoiceCountRowEvaluable() {
return new RowEvaluable() {
@Override
public Object eval(Project project, int rowIndex, Row row, Properties bindings) {
Object value = evalRow(project, rowIndex, row, bindings);
return getChoiceValueCountMultiple(value);
}
};
}

View File

@ -15,6 +15,7 @@ import com.metaweb.gridworks.model.Row;
* from a given expression.
*/
public class ExpressionNumericValueBinner implements RowVisitor, RecordVisitor {
/*
* Configuration
*/
@ -44,17 +45,14 @@ public class ExpressionNumericValueBinner implements RowVisitor, RecordVisitor {
bins = new int[_index.getBins().length];
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}
@Override
public boolean visit(Project project, int rowIndex, Row row) {
resetFlags();
@ -66,7 +64,6 @@ public class ExpressionNumericValueBinner implements RowVisitor, RecordVisitor {
return false;
}
@Override
public boolean visit(Project project, Record record) {
resetFlags();

View File

@ -6,15 +6,14 @@ import com.metaweb.gridworks.browsing.RowVisitor;
import com.metaweb.gridworks.model.Project;
public class FilteredRecordsAsFilteredRows implements FilteredRows {
final protected FilteredRecords _filteredRecords;
public FilteredRecordsAsFilteredRows(FilteredRecords filteredRecords) {
_filteredRecords = filteredRecords;
}
@Override
public void accept(Project project, RowVisitor visitor) {
_filteredRecords.accept(project, new RowVisitorAsRecordVisitor(visitor));
}
public FilteredRecordsAsFilteredRows(FilteredRecords filteredRecords) {
_filteredRecords = filteredRecords;
}
public void accept(Project project, RowVisitor visitor) {
_filteredRecords.accept(project, new RowVisitorAsRecordVisitor(visitor));
}
}

View File

@ -6,29 +6,27 @@ import com.metaweb.gridworks.model.Project;
import com.metaweb.gridworks.model.Record;
public class RowVisitorAsRecordVisitor implements RecordVisitor {
final protected RowVisitor _rowVisitor;
public RowVisitorAsRecordVisitor(RowVisitor rowVisitor) {
_rowVisitor = rowVisitor;
}
@Override
final protected RowVisitor _rowVisitor;
public RowVisitorAsRecordVisitor(RowVisitor rowVisitor) {
_rowVisitor = rowVisitor;
}
public void start(Project project) {
_rowVisitor.start(project);
}
@Override
public void end(Project project) {
_rowVisitor.end(project);
}
@Override
public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
if (_rowVisitor.visit(project, r, project.rows.get(r))) {
return true;
}
}
return false;
}
public boolean visit(Project project, Record record) {
for (int r = record.fromRowIndex; r < record.toRowIndex; r++) {
if (_rowVisitor.visit(project, r, project.rows.get(r))) {
return true;
}
}
return false;
}
}

View File

@ -66,12 +66,10 @@ public class BinningClusterer extends Clusterer {
}
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}

View File

@ -80,12 +80,10 @@ public class kNNClusterer extends Clusterer {
}
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}
@ -131,12 +129,10 @@ public class kNNClusterer extends Clusterer {
_clusterer = new NGramClusterer(_distance, _blockingNgramSize);
}
@Override
public void start(Project project) {
// nothing to do
}
@Override
public void end(Project project) {
// nothing to do
}

View File

@ -16,6 +16,7 @@ import org.json.JSONWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.metaweb.gridworks.GridworksServlet;
import com.metaweb.gridworks.Jsonizable;
import com.metaweb.gridworks.ProjectManager;
import com.metaweb.gridworks.ProjectMetadata;
@ -33,6 +34,12 @@ public abstract class Command {
final static protected Logger logger = LoggerFactory.getLogger("command");
protected GridworksServlet servlet;
public void init(GridworksServlet servlet) {
this.servlet = servlet;
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

View File

@ -2,6 +2,8 @@ package com.metaweb.gridworks.commands.auth;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -10,13 +12,12 @@ import javax.servlet.http.HttpServletResponse;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.OAuthProvider;
import com.metaweb.gridworks.Gridworks;
import com.metaweb.gridworks.commands.Command;
import com.metaweb.gridworks.oauth.Credentials;
import com.metaweb.gridworks.oauth.OAuthUtilities;
import com.metaweb.gridworks.oauth.Provider;
public class AuthorizeCommand extends Command {
public class AuthorizeCommand extends Command {
private static final String OAUTH_VERIFIER_PARAM = "oauth_verifier";
@ -124,7 +125,21 @@ public class AuthorizeCommand extends Command {
private String getBaseURL(HttpServletRequest request, Provider provider) {
String host = request.getHeader("host");
if (host == null) host = Gridworks.getFullHost();
if (host == null) {
String referrer = request.getHeader("referer");
if (referrer != null) {
URI url;
try {
url = new URI(referrer);
int port = url.getPort();
host = url.getHost() + ((port > -1) ? ":" + url.getPort() : "");
} catch (URISyntaxException e) {
throw new RuntimeException("referrer '" + referrer + "' can't be parsed as a URL");
}
} else {
throw new RuntimeException("neither the 'host' nor 'referer' headers were present in the HTTP response, I can't determine what URL gridworks is listening to.");
}
}
return "http://" + host + "/command/authorize/" + provider.getHost();
}
}

Some files were not shown because too many files have changed in this diff Show More