- make the correct version + revision available also to the java side (thru web.xml)
- add @Override metadata to the commands that were missing it - make the version information appear even when using trunk (Fixes Issue 136) git-svn-id: http://google-refine.googlecode.com/svn/trunk@1406 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
cb19cb4f43
commit
b62e63306a
@ -229,6 +229,11 @@
|
||||
<replacefilter token="$REVISION" value="${revision}"/>
|
||||
</replace>
|
||||
|
||||
<replace file="${built.webapp.dir}/WEB-INF/web.xml">
|
||||
<replacefilter token="$VERSION" value="${version}"/>
|
||||
<replacefilter token="$REVISION" value="${revision}"/>
|
||||
</replace>
|
||||
|
||||
<replace file="${built.webapp.dir}/WEB-INF/butterfly.properties">
|
||||
<replacefilter token="../../extensions/" value="extensions"/>
|
||||
</replace>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<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/butterfly-trunk.jar" sourcepath="webapp/WEB-INF/lib-src/butterfly-trunk.jar"/>
|
||||
<classpathentry kind="lib" path="webapp/WEB-INF/lib/butterfly-trunk.jar" sourcepath="webapp/WEB-INF/lib-src/butterfly-trunk-sources.jar"/>
|
||||
<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"/>
|
||||
|
@ -25,28 +25,28 @@ import edu.mit.simile.butterfly.ButterflyModule;
|
||||
|
||||
public class RefineServlet extends Butterfly {
|
||||
|
||||
static private final String VERSION = "2.0";
|
||||
static public String VERSION = "";
|
||||
static public String REVISION = "";
|
||||
static public String FULLNAME = "Google Refine ";
|
||||
|
||||
private static final long serialVersionUID = 2386057901503517403L;
|
||||
static public final String AGENT_ID = "/en/google_refine";
|
||||
|
||||
static final long serialVersionUID = 2386057901503517403L;
|
||||
|
||||
private static final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir";
|
||||
static private final String JAVAX_SERVLET_CONTEXT_TEMPDIR = "javax.servlet.context.tempdir";
|
||||
|
||||
static private RefineServlet s_singleton;
|
||||
static private File s_dataDir;
|
||||
static private File s_dataDir;
|
||||
|
||||
static final private Map<String, Command> commands = new HashMap<String, Command>();
|
||||
|
||||
// timer for periodically saving projects
|
||||
static private Timer _timer;
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("refine");
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
final static protected long s_autoSavePeriod = 1000 * 60 * 5; // 5 minutes
|
||||
static final Logger logger = LoggerFactory.getLogger("refine");
|
||||
|
||||
static final protected long s_autoSavePeriod = 1000 * 60 * 5; // 5 minutes
|
||||
|
||||
static protected class AutoSaveTimerTask extends TimerTask {
|
||||
public void run() {
|
||||
try {
|
||||
@ -64,6 +64,12 @@ public class RefineServlet extends Butterfly {
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
|
||||
VERSION = getInitParameter("refine.version");
|
||||
REVISION = getInitParameter("refine.revision");
|
||||
FULLNAME += VERSION + " [" + REVISION + "]";
|
||||
|
||||
logger.info("Starting " + FULLNAME + "...");
|
||||
|
||||
s_singleton = this;
|
||||
|
||||
@ -114,10 +120,12 @@ public class RefineServlet extends Butterfly {
|
||||
Command command = commands.get(commandKey);
|
||||
if (command != null) {
|
||||
if (request.getMethod().equals("GET")) {
|
||||
if (!logger.isTraceEnabled()) logger.info("GET {}", request.getPathInfo());
|
||||
logger.trace("> GET {}", commandKey);
|
||||
command.doGet(request, response);
|
||||
logger.trace("< GET {}", commandKey);
|
||||
} else if (request.getMethod().equals("POST")) {
|
||||
if (!logger.isTraceEnabled()) logger.info("POST {}", request.getPathInfo());
|
||||
logger.trace("> POST {}", commandKey);
|
||||
command.doPost(request, response);
|
||||
logger.trace("< POST {}", commandKey);
|
||||
|
24
main/src/com/google/refine/commands/GetVersionCommand.java
Normal file
24
main/src/com/google/refine/commands/GetVersionCommand.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.google.refine.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.refine.RefineServlet;
|
||||
|
||||
public class GetVersionCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "text/plain");
|
||||
response.getWriter().write(RefineServlet.VERSION);
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,10 +27,10 @@ public class OpenWorkspaceDirCommand extends Command {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
desktop.open(dir);
|
||||
} else /* if Mac */ {
|
||||
Process p = Runtime.getRuntime().exec(
|
||||
"open .",
|
||||
new String[] {},
|
||||
dir
|
||||
Runtime.getRuntime().exec(
|
||||
"open .",
|
||||
new String[] {},
|
||||
dir
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ public class AuthorizeCommand extends Command {
|
||||
|
||||
private static final String OAUTH_VERIFIER_PARAM = "oauth_verifier";
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
// get the provider from the request
|
||||
|
@ -13,6 +13,7 @@ import com.google.refine.oauth.Provider;
|
||||
|
||||
public class DeAuthorizeCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
try {
|
||||
|
@ -16,8 +16,9 @@ import com.google.refine.util.FreebaseUtils;
|
||||
|
||||
public class GetUserBadgesCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("check-authorization_command");
|
||||
final static Logger logger = LoggerFactory.getLogger("get-version_command");
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
try {
|
||||
|
@ -32,6 +32,7 @@ public class GetScatterplotCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("get-scatterplot_command");
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
|
@ -21,6 +21,7 @@ import com.google.refine.model.Project;
|
||||
|
||||
public class GetColumnsInfoCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
|
@ -31,6 +31,7 @@ public class ExportRowsCommand extends Command {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
|
@ -29,6 +29,7 @@ import com.google.refine.util.Pool;
|
||||
|
||||
public class GetRowsCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
internalRespond(request, response);
|
||||
|
@ -68,7 +68,7 @@ public class History implements Jsonizable {
|
||||
}
|
||||
|
||||
static public void writeOneChange(Writer writer, Change change, Properties options) throws IOException {
|
||||
writer.write(RefineServlet.getVersion()); writer.write('\n');
|
||||
writer.write(RefineServlet.VERSION); writer.write('\n');
|
||||
writer.write(change.getClass().getName()); writer.write('\n');
|
||||
|
||||
change.save(writer, options);
|
||||
|
@ -122,7 +122,7 @@ public class Project {
|
||||
}
|
||||
|
||||
protected void saveToWriter(Writer writer, Properties options) throws IOException {
|
||||
writer.write(RefineServlet.getVersion()); writer.write('\n');
|
||||
writer.write(RefineServlet.VERSION); writer.write('\n');
|
||||
|
||||
writer.write("columnModel=\n"); columnModel.save(writer, options);
|
||||
writer.write("history=\n"); history.save(writer, options);
|
||||
|
17
main/src/com/google/refine/oauth/GoogleProvider.java
Normal file
17
main/src/com/google/refine/oauth/GoogleProvider.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.google.refine.oauth;
|
||||
|
||||
public class GoogleProvider extends Provider {
|
||||
|
||||
public String getRequestTokenServiceURL() {
|
||||
return "https://www.google.com/accounts/OAuthGetRequestToken";
|
||||
}
|
||||
|
||||
public String getAccessTokenServiceURL() {
|
||||
return "https://www.google.com/accounts/OAuthGetAccessToken";
|
||||
}
|
||||
|
||||
public String getUserAuthorizationURL() {
|
||||
return "https://www.google.com/accounts/OAuthAuthorizeToken";
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@ public class OAuthUtilities {
|
||||
static final private Map<String,Provider> providers = new HashMap<String,Provider>();
|
||||
static final private Map<String,String[]> infos = new HashMap<String,String[]>();
|
||||
|
||||
static private final String[] FREEBASE_OAUTH_INFO = { "#9202a8c04000641f80000000150979b7" , "8ded7babfad2f94f4c77e39bbd6c90f31939999b"};
|
||||
static private final String[] FREEBASE_OAUTH_INFO = { "#9202a8c04000641f80000000185352db" , "4561ee02279e6f04ebd88a1557e4292489380adf"};
|
||||
|
||||
static {
|
||||
Provider freebase = new FreebaseProvider(FreebaseUtils.FREEBASE_HOST);
|
||||
|
@ -5,6 +5,9 @@ public abstract class Provider {
|
||||
|
||||
protected String host;
|
||||
|
||||
public Provider() {
|
||||
}
|
||||
|
||||
public Provider(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import com.google.refine.oauth.Provider;
|
||||
public class FreebaseUtils {
|
||||
|
||||
static final public String FREEBASE_HOST = "www.freebase.com";
|
||||
static final public String FREEBASE_SANDBOX_HOST = "www.sandbox-freebase.com";
|
||||
|
||||
static final private String FREEQ_URL = "http://data.labs.freebase.com/freeq/gridworks";
|
||||
//static final private String FREEQ_URL = "http://data.labs.freebase.com/freeq/refine";
|
||||
@ -55,7 +54,7 @@ public class FreebaseUtils {
|
||||
}
|
||||
|
||||
private static String getUserAgent() {
|
||||
return "Google Refine " + RefineServlet.getVersion();
|
||||
return RefineServlet.FULLNAME;
|
||||
}
|
||||
|
||||
public static String getUserInfo(Credentials credentials, Provider provider)
|
||||
@ -190,7 +189,7 @@ public class FreebaseUtils {
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
|
||||
|
||||
HttpPost httpRequest = new HttpPost(getFreeQUrl());
|
||||
httpRequest.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Google Refine " + RefineServlet.getVersion());
|
||||
httpRequest.getParams().setParameter(CoreProtocolPNames.USER_AGENT, getUserAgent());
|
||||
httpRequest.setEntity(entity);
|
||||
|
||||
HttpPost surrogateRequest = new HttpPost(getUserInfoURL(FREEBASE_HOST));
|
||||
|
@ -62,7 +62,7 @@ public class Pool implements Jsonizable {
|
||||
}
|
||||
|
||||
public void save(Writer writer) throws IOException {
|
||||
writer.write(RefineServlet.getVersion()); writer.write('\n');
|
||||
writer.write(RefineServlet.VERSION); writer.write('\n');
|
||||
|
||||
Properties options = new Properties();
|
||||
options.setProperty("mode", "save");
|
||||
|
@ -21,6 +21,14 @@
|
||||
<servlet>
|
||||
<servlet-name>refine</servlet-name>
|
||||
<servlet-class>com.google.refine.RefineServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>refine.version</param-name>
|
||||
<param-value>$VERSION</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>refine.revision</param-name>
|
||||
<param-value>$REVISION</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
|
@ -13,7 +13,9 @@ var templatedFiles = {
|
||||
|
||||
function registerCommands() {
|
||||
var RS = Packages.com.google.refine.RefineServlet;
|
||||
|
||||
|
||||
RS.registerCommand(module, "get-version", new Packages.com.google.refine.commands.GetVersionCommand());
|
||||
|
||||
RS.registerCommand(module, "create-project-from-upload", new Packages.com.google.refine.commands.project.CreateProjectCommand());
|
||||
RS.registerCommand(module, "import-project", new Packages.com.google.refine.commands.project.ImportProjectCommand());
|
||||
RS.registerCommand(module, "export-project", new Packages.com.google.refine.commands.project.ExportProjectCommand());
|
||||
|
@ -1,4 +1,3 @@
|
||||
description = Google Refine Core Module
|
||||
implements = core
|
||||
templating.macros = macros.vm
|
||||
|
||||
|
@ -95,16 +95,15 @@
|
||||
<div class="field-hint">use 0 if there is no header line</div>
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<div><input id="ignore-quotes-input" name="ignore-quotes" type="checkbox" />Ignore Quotation Marks </div>
|
||||
<div class="field-hint">Ignore quotation marks,<br/>using all newlines and separators</div>
|
||||
</div>
|
||||
<div class="field-group">
|
||||
<div><input id="ignore-quotes-input" name="ignore-quotes" type="checkbox" />Ignore Quotation Marks </div>
|
||||
<div class="field-hint">Ignore quotation marks,<br/>using all newlines and separators</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr></table>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<form id="project-upload-form" method="post" enctype="multipart/form-data" action="/command/core/import-project" accept-charset="UTF-8" style="display:none;">
|
||||
<div id="form-tabs-import-project" class="round-corners">
|
||||
<a class="form-tab-link" href="javascript:showHide('project-upload-form', 'file-upload-form')">or Create a New Project</a>
|
||||
|
@ -203,19 +203,19 @@ function onLoad() {
|
||||
$("#more-options").show();
|
||||
});
|
||||
|
||||
var version = (GoogleRefineVersion.version != "$VERSION") ? "Version " + GoogleRefineVersion.version + "-" + GoogleRefineVersion.revision : "";
|
||||
var version = (GoogleRefineVersion.version != "$VERSION") ? "Version " + GoogleRefineVersion.version + " [" + GoogleRefineVersion.revision + "]" : "Version <trunk>";
|
||||
$("#google-refine-version").text(version);
|
||||
|
||||
var script = $('<script></script>')
|
||||
.attr("src", "http://google-refine.googlecode.com/svn/support/releases2.js")
|
||||
.attr("src", "http://google-refine.googlecode.com/svn/support/releases.js")
|
||||
.attr("type", "text/javascript")
|
||||
.appendTo(document.body);
|
||||
|
||||
var poll = function() {
|
||||
if ("GoogleRefineReleases" in window) {
|
||||
if ("releases" in window) {
|
||||
if (isThereNewRelease()) {
|
||||
$('<div id="version-message">' +
|
||||
'New version "' + GoogleRefineReleases.releases[0].description + '" <a href="' + GoogleRefineReleases.homepage + '">available for download here</a>.' +
|
||||
'New version "' + releases.releases[0].description + '" <a href="' + releases.homepage + '">available for download here</a>.' +
|
||||
'</div>').appendTo(document.body);
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user