implemented the full gridworks -> freebase conduit via delegated oauth and freeq/tripleloader
(still doesn't work as argus returns a 500 but the entire conduit is in place) git-svn-id: http://google-refine.googlecode.com/svn/trunk@519 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
531431a869
commit
6990604981
@ -7,6 +7,7 @@
|
||||
<classpathentry kind="lib" path="lib/servlet-api-2.5.jar" sourcepath="lib-src/servlet-api-2.5-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jetty-6.1.22.jar" sourcepath="lib-src/jetty-6.1.22-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jetty-util-6.1.22.jar" sourcepath="lib-src/jetty-util-6.1.22-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/slf4j-api-1.5.6.jar" sourcepath="lib-src/slf4j-api-1.5.6-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar" sourcepath="lib-src/log4j-1.2.15-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-codec-1.4.jar" sourcepath="lib-src/commons-codec-1.4-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang-2.5.jar" sourcepath="lib-src/commons-lang-2.5-sources.jar"/>
|
||||
|
@ -95,9 +95,6 @@ licenses/datejs.LICENSE.txt
|
||||
|
||||
licenses/imgareaselect.LICENSE.txt
|
||||
imgareaselect
|
||||
|
||||
licenses/blockui.LICENSE.txt
|
||||
blockui
|
||||
|
||||
licenses/slf4j.LICENSE.txt
|
||||
slf4j-api
|
||||
|
@ -59,6 +59,7 @@
|
||||
<javac srcdir="${server.src.dir}" destdir="${server_classes.dir}" debug="true" includeAntRuntime="no">
|
||||
<classpath refid="class.path" />
|
||||
</javac>
|
||||
<copy file="${conf.dir}/log4j.properties" tofile="${server_classes.dir}/log4j.properties"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="build_server">
|
||||
@ -68,6 +69,7 @@
|
||||
<src path="${src.dir}"/>
|
||||
<classpath refid="class.path" />
|
||||
</javac>
|
||||
<copy file="${conf.dir}/log4j.properties" tofile="${webapp_classes.dir}/log4j.properties"/>
|
||||
</target>
|
||||
|
||||
<target name="build_tests" depends="build">
|
||||
|
13
gridworks
13
gridworks
@ -46,6 +46,9 @@ where [options] include:
|
||||
-m <memory> max memory heap size to use
|
||||
default: 1024M
|
||||
|
||||
-v <level> verbosity level [from low to high: error,warn,info,debug,trace]
|
||||
default: info
|
||||
|
||||
--debug enable JVM debugging (on port 8000)
|
||||
|
||||
--jmx enable JMX monitoring (for jconsole and jvisualvm)
|
||||
@ -560,13 +563,13 @@ run() {
|
||||
if [ "$GRIDWORKS_DATA_DIR" ]; then
|
||||
add_option "-Dgridworks.data_dir=$GRIDWORKS_DATA_DIR"
|
||||
fi
|
||||
|
||||
|
||||
CLASSPATH="$GRIDWORKS_BUILD_DIR/classes${SEP}$GRIDWORKS_LIB_DIR/*"
|
||||
|
||||
RUN_CMD="$JAVA -cp $CLASSPATH $OPTS com.metaweb.gridworks.Gridworks"
|
||||
|
||||
#echo "$RUN_CMD"
|
||||
#cd tooecho ""
|
||||
#echo ""
|
||||
|
||||
echo "Starting Gridworks at 'http://${GRIDWORKS_HOST}:${GRIDWORKS_PORT}/'"
|
||||
echo ""
|
||||
@ -697,6 +700,7 @@ while [ $# -ne 0 ] ; do
|
||||
-w) shift; GRIDWORKS_WEBAPP="$1"; shift; continue;;
|
||||
-d) shift; GRIDWORKS_DATA_DIR="$1"; shift; continue;;
|
||||
-m) shift; GRIDWORKS_MEMORY="$1"; shift; continue;;
|
||||
-v) shift; GRIDWORKS_VERBOSITY="$1"; shift; continue;;
|
||||
--debug) shift; add_option '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'; continue;;
|
||||
--jmx) shift; add_option '-Dcom.sun.management.jmxremote'; continue;;
|
||||
-*) fail "Invalid option: $1";;
|
||||
@ -759,6 +763,11 @@ if [ -z "$GRIDWORKS_DIST_DIR" ]; then
|
||||
GRIDWORKS_DIST_DIR="dist"
|
||||
fi
|
||||
|
||||
if [ -z "$GRIDWORKS_VERBOSITY" ]; then
|
||||
GRIDWORKS_VERBOSITY="info"
|
||||
fi
|
||||
add_option "-Dgridworks.verbosity=$GRIDWORKS_VERBOSITY"
|
||||
|
||||
if [ -z "$JYTHONPATH" ]; then
|
||||
JYTHONPATH="$GRIDWORKS_LIB_DIR/jython"
|
||||
else
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
Copyright (c) 2007-2008 M. Alsup
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
src/conf/log4j.properties
Normal file
9
src/conf/log4j.properties
Normal file
@ -0,0 +1,9 @@
|
||||
log4j.rootLogger=INFO, console
|
||||
log4j.logger.org.mortbay.log=WARN
|
||||
log4j.logger.org.mortbay.jetty=ERROR
|
||||
log4j.logger.org.apache.http.headers=WARN
|
||||
log4j.logger.org.apache.http.impl=WARN
|
||||
log4j.logger.org.apache.http.client=WARN
|
||||
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=com.metaweb.util.logging.IndentingLayout
|
@ -11,10 +11,13 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.commands.Command;
|
||||
import com.metaweb.gridworks.commands.auth.AuthorizeCommand;
|
||||
import com.metaweb.gridworks.commands.auth.CheckAuthorizationCommand;
|
||||
import com.metaweb.gridworks.commands.auth.DeAuthorizeCommand;
|
||||
import com.metaweb.gridworks.commands.auth.AuthorizeCommand;
|
||||
import com.metaweb.gridworks.commands.edit.AddColumnCommand;
|
||||
import com.metaweb.gridworks.commands.edit.AnnotateOneRowCommand;
|
||||
import com.metaweb.gridworks.commands.edit.AnnotateRowsCommand;
|
||||
@ -35,6 +38,7 @@ import com.metaweb.gridworks.commands.edit.SplitColumnCommand;
|
||||
import com.metaweb.gridworks.commands.edit.SplitMultiValueCellsCommand;
|
||||
import com.metaweb.gridworks.commands.edit.TextTransformCommand;
|
||||
import com.metaweb.gridworks.commands.edit.UndoRedoCommand;
|
||||
import com.metaweb.gridworks.commands.edit.UploadDataCommand;
|
||||
import com.metaweb.gridworks.commands.info.ComputeClustersCommand;
|
||||
import com.metaweb.gridworks.commands.info.ComputeFacetsCommand;
|
||||
import com.metaweb.gridworks.commands.info.ExportRowsCommand;
|
||||
@ -71,6 +75,8 @@ public class GridworksServlet extends HttpServlet {
|
||||
|
||||
// timer for periodically saving projects
|
||||
static protected Timer _timer;
|
||||
|
||||
final Logger logger = LoggerFactory.getLogger("servlet");
|
||||
|
||||
static {
|
||||
_commands.put("create-project-from-upload", new CreateProjectCommand());
|
||||
@ -137,11 +143,14 @@ public class GridworksServlet extends HttpServlet {
|
||||
_commands.put("check-authorization", new CheckAuthorizationCommand());
|
||||
_commands.put("authorize", new AuthorizeCommand());
|
||||
_commands.put("deauthorize", new DeAuthorizeCommand());
|
||||
|
||||
_commands.put("upload-data", new UploadDataCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
logger.trace("> initialize");
|
||||
|
||||
ProjectManager.initialize();
|
||||
|
||||
@ -156,10 +165,14 @@ public class GridworksServlet extends HttpServlet {
|
||||
ProjectManager.singleton.save(false); // quick, potentially incomplete save
|
||||
}
|
||||
}, period, period);
|
||||
|
||||
logger.trace("< initialize");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.trace("> destroy");
|
||||
|
||||
// cancel automatic periodic saving and force a complete save.
|
||||
if (_timer != null) {
|
||||
_timer.cancel();
|
||||
@ -171,34 +184,41 @@ public class GridworksServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
Command command = _commands.get(getCommandName(request));
|
||||
if (command != null) {
|
||||
command.doPost(request, response);
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
|
||||
logger.trace("< destroy");
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
Command command = _commands.get(getCommandName(request));
|
||||
String commandName = getCommandName(request);
|
||||
Command command = _commands.get(commandName);
|
||||
if (command != null) {
|
||||
logger.trace("> GET {}", commandName);
|
||||
command.doGet(request, response);
|
||||
logger.trace("< GET {}", commandName);
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String commandName = getCommandName(request);
|
||||
Command command = _commands.get(commandName);
|
||||
if (command != null) {
|
||||
logger.trace("> POST {}", commandName);
|
||||
command.doPost(request, response);
|
||||
logger.trace("< POST {}", commandName);
|
||||
} else {
|
||||
response.sendError(404);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCommandName(HttpServletRequest request) {
|
||||
/*
|
||||
* Remove extraneous path segments that might be there for other purposes,
|
||||
* e.g., for /export-rows/filename.ext, export-rows is the command while
|
||||
* filename.ext is only for the browser to prompt a convenient filename.
|
||||
*/
|
||||
// Remove extraneous path segments that might be there for other purposes,
|
||||
// e.g., for /export-rows/filename.ext, export-rows is the command while
|
||||
// filename.ext is only for the browser to prompt a convenient filename.
|
||||
String commandName = request.getPathInfo().substring(1);
|
||||
int slash = commandName.indexOf('/');
|
||||
return slash > 0 ? commandName.substring(0, slash) : commandName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.codeberry.jdatapath.DataPath;
|
||||
import com.codeberry.jdatapath.JDataPathSystem;
|
||||
@ -34,6 +36,8 @@ public class ProjectManager {
|
||||
protected Map<Long, ProjectMetadata> _projectsMetadata;
|
||||
protected List<String> _expressions;
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("project_manager");
|
||||
|
||||
/**
|
||||
* While each project's metadata is loaded completely at start-up, each project's raw data
|
||||
* is loaded only when the project is accessed by the user. This is because project
|
||||
@ -52,7 +56,7 @@ public class ProjectManager {
|
||||
static public synchronized void initialize() {
|
||||
if (singleton == null) {
|
||||
File dir = getProjectLocation();
|
||||
Gridworks.log("Using workspace directory: " + dir.getAbsolutePath());
|
||||
logger.info("Using workspace directory: {}", dir.getAbsolutePath());
|
||||
|
||||
singleton = new ProjectManager(dir);
|
||||
}
|
||||
@ -83,9 +87,7 @@ public class ProjectManager {
|
||||
* environment variables and try our best to find a user-specific path.
|
||||
*/
|
||||
|
||||
Gridworks.log(
|
||||
"Failed to use jdatapath to detect user data path. " +
|
||||
"Resorting to environment variables.");
|
||||
logger.warn("Failed to use jdatapath to detect user data path: resorting to environment variables");
|
||||
|
||||
File parentDir = null;
|
||||
{
|
||||
@ -289,7 +291,7 @@ public class ProjectManager {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Gridworks.log("Failed to save workspace.");
|
||||
logger.warn("Failed to save workspace");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -305,7 +307,7 @@ public class ProjectManager {
|
||||
oldFile.delete();
|
||||
}
|
||||
|
||||
//Gridworks.log("Saved workspace.");
|
||||
logger.info("Saved workspace");
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +399,7 @@ public class ProjectManager {
|
||||
}
|
||||
});
|
||||
|
||||
Gridworks.log(allModified ?
|
||||
logger.info(allModified ?
|
||||
"Saving all modified projects ..." :
|
||||
"Saving some modified projects ..."
|
||||
);
|
||||
@ -456,7 +458,7 @@ public class ProjectManager {
|
||||
}
|
||||
|
||||
protected boolean loadFromFile(File file) {
|
||||
Gridworks.log("Loading workspace from " + file.getAbsolutePath());
|
||||
logger.info("Loading workspace: {}", file.getAbsolutePath());
|
||||
|
||||
_projectsMetadata.clear();
|
||||
_expressions.clear();
|
||||
@ -482,14 +484,14 @@ public class ProjectManager {
|
||||
JSONUtilities.getStringList(obj, "expressions", _expressions);
|
||||
return true;
|
||||
} catch (JSONException e) {
|
||||
Gridworks.warn("Error reading " + file, e);
|
||||
logger.warn("Error reading file", e);
|
||||
} catch (IOException e) {
|
||||
Gridworks.warn("Error reading " + file, e);
|
||||
logger.warn("Error reading file", e);
|
||||
} finally {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
Gridworks.warn("Exception closing file",e);
|
||||
logger.warn("Exception closing file",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.util.JSONUtilities;
|
||||
import com.metaweb.gridworks.util.ParsingUtilities;
|
||||
@ -30,6 +32,8 @@ public class ProjectMetadata implements Jsonizable {
|
||||
private int _encodingConfidence;
|
||||
private List<String> _expressions = new LinkedList<String>();
|
||||
|
||||
final Logger logger = LoggerFactory.getLogger("project_metadata");
|
||||
|
||||
protected ProjectMetadata(Date date) {
|
||||
_created = date;
|
||||
}
|
||||
@ -64,7 +68,7 @@ public class ProjectMetadata implements Jsonizable {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Gridworks.log("Failed to save project metadata");
|
||||
logger.warn("Failed to save project metadata");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,9 @@ import org.apache.commons.codec.binary.Base64;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
import com.metaweb.gridworks.browsing.filters.DualExpressionsNumberComparisonRowFilter;
|
||||
import com.metaweb.gridworks.browsing.filters.RowFilter;
|
||||
@ -109,6 +110,8 @@ public class ScatterplotFacet implements Facet {
|
||||
|
||||
public static String EMPTY_IMAGE;
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("scatterplot_facet");
|
||||
|
||||
static {
|
||||
try {
|
||||
EMPTY_IMAGE = serializeImage(new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR));
|
||||
@ -302,7 +305,7 @@ public class ScatterplotFacet implements Facet {
|
||||
try {
|
||||
image = serializeImage(drawer.getImage());
|
||||
} catch (IOException e) {
|
||||
Gridworks.warn("Exception caught while generating the image", e);
|
||||
logger.warn("Exception caught while generating the image", e);
|
||||
}
|
||||
} else {
|
||||
image = EMPTY_IMAGE;
|
||||
@ -341,7 +344,7 @@ public class ScatterplotFacet implements Facet {
|
||||
try {
|
||||
eval = MetaParser.parse(expression);
|
||||
} catch (ParsingException e) {
|
||||
Gridworks.warn("Error parsing expression",e);
|
||||
logger.warn("Error parsing expression",e);
|
||||
}
|
||||
}
|
||||
NumericBinIndex index = (NumericBinIndex) column.getPrecompute(key);
|
||||
|
@ -14,8 +14,9 @@ import java.util.Map.Entry;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
import com.metaweb.gridworks.browsing.RowVisitor;
|
||||
@ -30,6 +31,8 @@ public class BinningClusterer extends Clusterer {
|
||||
|
||||
static final protected Map<String, Keyer> _keyers = new HashMap<String, Keyer>();
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("binning_clusterer");
|
||||
|
||||
List<Map<String,Integer>> _clusters;
|
||||
|
||||
static {
|
||||
@ -54,7 +57,7 @@ public class BinningClusterer extends Clusterer {
|
||||
if (k instanceof NGramFingerprintKeyer) {
|
||||
try {
|
||||
int size = _config.getJSONObject("params").getInt("ngram-size");
|
||||
Gridworks.log("Using ngram size: " + size);
|
||||
logger.debug("Using ngram size: {}", size);
|
||||
_params = new Object[1];
|
||||
_params[0] = size;
|
||||
} catch (JSONException e) {
|
||||
|
@ -15,8 +15,9 @@ import java.util.Map.Entry;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
import com.metaweb.gridworks.browsing.RowVisitor;
|
||||
@ -47,6 +48,8 @@ public class kNNClusterer extends Clusterer {
|
||||
|
||||
Map<Serializable, Integer> _counts = new HashMap<Serializable, Integer>();
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("kNN_clusterer");
|
||||
|
||||
static {
|
||||
_distances.put("levenshtein", new LevenshteinDistance());
|
||||
_distances.put("jaccard", new JaccardDistance());
|
||||
@ -109,11 +112,11 @@ public class kNNClusterer extends Clusterer {
|
||||
try {
|
||||
JSONObject params = o.getJSONObject("params");
|
||||
_radius = params.getDouble("radius");
|
||||
Gridworks.warn("Use radius: " + _radius);
|
||||
logger.debug("Use radius: {}", _radius);
|
||||
_blockingNgramSize = params.getInt("blocking-ngram-size");
|
||||
Gridworks.warn("Use blocking ngram size: " + _blockingNgramSize);
|
||||
logger.debug("Use blocking ngram size: {}",_blockingNgramSize);
|
||||
} catch (JSONException e) {
|
||||
Gridworks.warn("No parameters found, using defaults");
|
||||
logger.debug("No parameters found, using defaults");
|
||||
}
|
||||
_clusterer = new NGramClusterer(_distance, _blockingNgramSize);
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import org.apache.commons.lang.NotImplementedException;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Jsonizable;
|
||||
import com.metaweb.gridworks.ProjectManager;
|
||||
@ -28,6 +30,9 @@ import com.metaweb.gridworks.util.ParsingUtilities;
|
||||
* are AJAX calls.
|
||||
*/
|
||||
public abstract class Command {
|
||||
|
||||
final static protected Logger logger = LoggerFactory.getLogger("command");
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
@ -50,10 +55,7 @@ public abstract class Command {
|
||||
*/
|
||||
static protected JSONObject getEngineConfig(HttpServletRequest request) throws Exception {
|
||||
String json = request.getParameter("engine");
|
||||
if (json != null) {
|
||||
return ParsingUtilities.evaluateJsonStringToObject(json);
|
||||
}
|
||||
return null;
|
||||
return (json == null) ? null : ParsingUtilities.evaluateJsonStringToObject(json);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,10 +110,9 @@ public abstract class Command {
|
||||
String value = request.getParameter(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
JSONObject o = ParsingUtilities.evaluateJsonStringToObject(value);
|
||||
|
||||
return o;
|
||||
return ParsingUtilities.evaluateJsonStringToObject(value);
|
||||
} catch (JSONException e) {
|
||||
logger.warn("error getting json parameter",e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -123,15 +124,22 @@ public abstract class Command {
|
||||
Project project,
|
||||
Process process
|
||||
) throws Exception {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
HistoryEntry historyEntry = project.processManager.queueProcess(process);
|
||||
if (historyEntry != null) {
|
||||
JSONWriter writer = new JSONWriter(response.getWriter());
|
||||
Writer w = response.getWriter();
|
||||
JSONWriter writer = new JSONWriter(w);
|
||||
Properties options = new Properties();
|
||||
|
||||
writer.object();
|
||||
writer.key("code"); writer.value("ok");
|
||||
writer.key("historyEntry"); historyEntry.write(writer, options);
|
||||
writer.endObject();
|
||||
|
||||
w.flush();
|
||||
w.close();
|
||||
} else {
|
||||
respond(response, "{ \"code\" : \"pending\" }");
|
||||
}
|
||||
@ -140,8 +148,25 @@ public abstract class Command {
|
||||
static protected void respond(HttpServletResponse response, String content)
|
||||
throws IOException {
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
response.getWriter().write(content);
|
||||
Writer w = response.getWriter();
|
||||
w.write(content);
|
||||
w.flush();
|
||||
w.close();
|
||||
}
|
||||
|
||||
static protected void respond(HttpServletResponse response, String status, String message)
|
||||
throws IOException, JSONException {
|
||||
|
||||
Writer w = response.getWriter();
|
||||
JSONWriter writer = new JSONWriter(w);
|
||||
writer.object();
|
||||
writer.key("status"); writer.value(status);
|
||||
writer.key("message"); writer.value(message);
|
||||
writer.endObject();
|
||||
w.flush();
|
||||
w.close();
|
||||
}
|
||||
|
||||
static protected void respondJSON(HttpServletResponse response, Jsonizable o)
|
||||
@ -157,15 +182,19 @@ public abstract class Command {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
JSONWriter writer = new JSONWriter(response.getWriter());
|
||||
Writer w = response.getWriter();
|
||||
JSONWriter writer = new JSONWriter(w);
|
||||
|
||||
o.write(writer, options);
|
||||
w.flush();
|
||||
w.close();
|
||||
}
|
||||
|
||||
static protected void respondException(HttpServletResponse response, Exception e)
|
||||
throws IOException {
|
||||
|
||||
e.printStackTrace();
|
||||
logger.warn("Exception caught", e);
|
||||
|
||||
try {
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("code", "error");
|
||||
@ -179,6 +208,7 @@ public abstract class Command {
|
||||
|
||||
o.put("stack", sw.toString());
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
respond(response, o.toString());
|
||||
} catch (JSONException e1) {
|
||||
@ -187,12 +217,7 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
static protected void redirect(HttpServletResponse response, String url) throws IOException {
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
|
||||
Writer writer = response.getWriter();
|
||||
writer.write("<html><head>");
|
||||
writer.write("<meta http-equiv=\"refresh\" content=\"1;url=" + url + "\">");
|
||||
writer.write("</head><body></body></html>");
|
||||
response.sendRedirect(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package com.metaweb.gridworks.commands.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import com.metaweb.gridworks.commands.Command;
|
||||
import com.metaweb.gridworks.oauth.OAuthUtilities;
|
||||
import com.metaweb.gridworks.oauth.Provider;
|
||||
|
||||
public class AuthorizationCommand extends Command {
|
||||
|
||||
private static final String PROVIDER_PARAM = "provider";
|
||||
|
||||
protected void respond(HttpServletResponse response, String status, String message) throws IOException, JSONException {
|
||||
JSONWriter writer = new JSONWriter(response.getWriter());
|
||||
writer.object();
|
||||
writer.key("status"); writer.value(status);
|
||||
writer.key("message"); writer.value(message);
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
protected Provider getProvider(HttpServletRequest request) {
|
||||
String provider_str = request.getParameter(PROVIDER_PARAM);
|
||||
Provider provider = OAuthUtilities.getProvider(request.getParameter(PROVIDER_PARAM));
|
||||
if (provider == null) throw new RuntimeException("Can't find OAuth provider '" + provider_str + "'");
|
||||
return provider;
|
||||
}
|
||||
}
|
@ -11,26 +11,28 @@ 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 AuthorizationCommand {
|
||||
public class AuthorizeCommand extends Command {
|
||||
|
||||
private static final String OAUTH_VERIFIER_PARAM = "oauth_verifier";
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
// get the provider from the request
|
||||
Provider provider = OAuthUtilities.getProvider(request);
|
||||
|
||||
try {
|
||||
|
||||
// get the provider from the request
|
||||
Provider provider = getProvider(request);
|
||||
|
||||
// see if the request comes with access credentials
|
||||
Credentials access_credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
|
||||
|
||||
// prepare the continuation URL that the OAuth provider will redirect the user to
|
||||
// (we need to make sure this URL points back to this code or the dance will never complete)
|
||||
String callbackURL = Gridworks.getURL() + "/command/authorize";
|
||||
String callbackURL = Gridworks.getURL() + "/command/authorize/" + provider.getHost();
|
||||
|
||||
if (access_credentials == null) {
|
||||
// access credentials are not available so we need to check
|
||||
@ -39,7 +41,7 @@ public class AuthorizeCommand extends AuthorizationCommand {
|
||||
// get the request token credentials
|
||||
Credentials request_credentials = Credentials.getCredentials(request, provider, Credentials.Type.REQUEST);
|
||||
|
||||
OAuthConsumer consumer = OAuthUtilities.getConsumer(provider);
|
||||
OAuthConsumer consumer = OAuthUtilities.getConsumer(request_credentials, provider);
|
||||
OAuthProvider pp = OAuthUtilities.getOAuthProvider(provider);
|
||||
|
||||
if (request_credentials == null) {
|
||||
@ -70,7 +72,7 @@ public class AuthorizeCommand extends AuthorizationCommand {
|
||||
String verificationCode = request.getParameter(OAUTH_VERIFIER_PARAM);
|
||||
|
||||
pp.retrieveAccessToken(consumer, verificationCode);
|
||||
|
||||
|
||||
access_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);
|
||||
|
||||
// no matter the result, we need to remove the request token
|
||||
@ -95,6 +97,8 @@ public class AuthorizeCommand extends AuthorizationCommand {
|
||||
finish(response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST);
|
||||
Credentials.deleteCredentials(request, response, provider, Credentials.Type.ACCESS);
|
||||
respondException(response, e);
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +1,28 @@
|
||||
package com.metaweb.gridworks.commands.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import oauth.signpost.OAuthConsumer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.CoreProtocolPNames;
|
||||
|
||||
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;
|
||||
import com.metaweb.gridworks.util.IOUtils;
|
||||
import com.metaweb.gridworks.util.FreebaseUtils;
|
||||
|
||||
public class CheckAuthorizationCommand extends AuthorizationCommand {
|
||||
public class CheckAuthorizationCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("check-authorization_command");
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
try {
|
||||
|
||||
Provider provider = getProvider(request);
|
||||
Provider provider = OAuthUtilities.getProvider(request);
|
||||
|
||||
// this cookie should not be there, but this is good hygiene practice
|
||||
Credentials.deleteCredentials(request, response, provider, Credentials.Type.REQUEST);
|
||||
@ -39,30 +33,15 @@ public class CheckAuthorizationCommand extends AuthorizationCommand {
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
if (access_credentials != null) {
|
||||
Gridworks.log(access_credentials.toString());
|
||||
|
||||
OAuthConsumer consumer = OAuthUtilities.getConsumer(access_credentials, provider);
|
||||
|
||||
HttpGet httpRequest = new HttpGet("http://" + provider.getHost() + "/api/service/user_info");
|
||||
httpRequest.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Gridworks " + Gridworks.getVersion());
|
||||
|
||||
// this is required by the Metaweb API to avoid XSS
|
||||
httpRequest.setHeader("X-Requested-With", "1");
|
||||
|
||||
consumer.sign(request);
|
||||
|
||||
HttpClient httpClient = new DefaultHttpClient();
|
||||
HttpResponse httpResponse = httpClient.execute(httpRequest);
|
||||
OutputStream output = response.getOutputStream();
|
||||
InputStream input = httpResponse.getEntity().getContent();
|
||||
IOUtils.copy(input, output);
|
||||
input.close();
|
||||
output.close();
|
||||
String user_info = FreebaseUtils.getUserInfo(access_credentials, provider);
|
||||
response.getWriter().write(user_info);
|
||||
} else {
|
||||
respond(response, "401 Unauthorized", "You don't have the right credentials");
|
||||
}
|
||||
|
||||
respond(response, "401 Unauthorized", "You don't have the right credentials");
|
||||
} catch (Exception e) {
|
||||
logger.info("error",e);
|
||||
respondException(response, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,12 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
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 DeAuthorizeCommand extends AuthorizationCommand {
|
||||
public class DeAuthorizeCommand extends Command {
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
@ -17,7 +19,7 @@ public class DeAuthorizeCommand extends AuthorizationCommand {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
Provider provider = getProvider(request);
|
||||
Provider provider = OAuthUtilities.getProvider(request);
|
||||
|
||||
Credentials.deleteCredentials(request, response, provider, Credentials.Type.ACCESS);
|
||||
|
||||
|
@ -36,6 +36,8 @@ import org.apache.commons.fileupload.util.Streams;
|
||||
import org.apache.tools.bzip2.CBZip2InputStream;
|
||||
import org.apache.tools.tar.TarEntry;
|
||||
import org.apache.tools.tar.TarInputStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ibm.icu.text.CharsetDetector;
|
||||
import com.ibm.icu.text.CharsetMatch;
|
||||
@ -54,6 +56,8 @@ import com.metaweb.gridworks.util.ParsingUtilities;
|
||||
|
||||
public class CreateProjectCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("create-project_command");
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
@ -164,7 +168,7 @@ public class CreateProjectCommand extends Command {
|
||||
InputStream inputStream
|
||||
) throws Exception {
|
||||
|
||||
Gridworks.info("Importing " + fileName + "");
|
||||
logger.info("Importing '{}'", fileName);
|
||||
|
||||
if (fileName.endsWith(".zip") || fileName.endsWith(".tar.gz") || fileName.endsWith(".tgz") || fileName.endsWith(".tar.bz2")) {
|
||||
|
||||
@ -236,7 +240,8 @@ public class CreateProjectCommand extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
Gridworks.log("Most frequent extensions: " + exts.toString());
|
||||
|
||||
logger.info("Most frequent extensions: {}", exts.toString());
|
||||
|
||||
// second pass, load the data for real
|
||||
is = getStream(fileName, new FileInputStream(file));
|
||||
@ -399,10 +404,7 @@ public class CreateProjectCommand extends Command {
|
||||
options.setProperty("encoding", charsetMatch.getName());
|
||||
options.setProperty("encoding_confidence", Integer.toString(charsetMatch.getConfidence()));
|
||||
|
||||
Gridworks.log(
|
||||
"Best encoding guess: " +
|
||||
charsetMatch.getName() +
|
||||
" [confidence: " + charsetMatch.getConfidence() + "]");
|
||||
logger.info("Best encoding guess: {} [confidence: {}]", charsetMatch.getName(), charsetMatch.getConfidence());
|
||||
|
||||
break;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.metaweb.gridworks.commands.edit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
@ -19,8 +19,9 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.fileupload.util.Streams;
|
||||
import org.apache.tools.tar.TarEntry;
|
||||
import org.apache.tools.tar.TarInputStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.ProjectManager;
|
||||
import com.metaweb.gridworks.ProjectMetadata;
|
||||
import com.metaweb.gridworks.commands.Command;
|
||||
@ -29,6 +30,8 @@ import com.metaweb.gridworks.util.ParsingUtilities;
|
||||
|
||||
public class ImportProjectCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("import-project_command");
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
@ -37,7 +40,7 @@ public class ImportProjectCommand extends Command {
|
||||
Properties options = ParsingUtilities.parseUrlParameters(request);
|
||||
|
||||
long projectID = Project.generateID();
|
||||
Gridworks.log("Importing existing project using new ID " + projectID);
|
||||
logger.info("Importing existing project using new ID {}", projectID);
|
||||
|
||||
internalImport(request, options, projectID);
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.metaweb.gridworks.commands.edit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.commands.Command;
|
||||
import com.metaweb.gridworks.exporters.TripleloaderExporter;
|
||||
import com.metaweb.gridworks.model.Project;
|
||||
import com.metaweb.gridworks.util.FreebaseUtils;
|
||||
|
||||
public class UploadDataCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
Engine engine = getEngine(request, project);
|
||||
TripleloaderExporter exporter = new TripleloaderExporter();
|
||||
StringWriter triples = new StringWriter(1024 * 10);
|
||||
exporter.export(project, new Properties(), engine, triples);
|
||||
|
||||
String info = request.getParameter("info");
|
||||
|
||||
String result = FreebaseUtils.uploadTriples(request, info, triples.toString());
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
try {
|
||||
new JSONObject(result);
|
||||
response.getWriter().write(result);
|
||||
} catch (JSONException e) {
|
||||
respond(response,"500 Error", result);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.clustering.Clusterer;
|
||||
import com.metaweb.gridworks.clustering.binning.BinningClusterer;
|
||||
@ -18,6 +19,8 @@ import com.metaweb.gridworks.model.Project;
|
||||
|
||||
public class ComputeClustersCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("compute-clusters_command");
|
||||
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
@ -42,7 +45,7 @@ public class ComputeClustersCommand extends Command {
|
||||
clusterer.computeClusters(engine);
|
||||
|
||||
respondJSON(response, clusterer);
|
||||
Gridworks.log("computed clusters [" + type + "," + clusterer_conf.getString("function") + "] in " + (System.currentTimeMillis() - start) + "ms");
|
||||
logger.info("computed clusters [{},{}] in {}ms", new Object[] { type, clusterer_conf.getString("function"), Long.toString(System.currentTimeMillis() - start) });
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
|
@ -13,8 +13,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.browsing.Engine;
|
||||
import com.metaweb.gridworks.browsing.FilteredRows;
|
||||
import com.metaweb.gridworks.browsing.facets.NumericBinIndex;
|
||||
@ -29,6 +30,8 @@ import com.metaweb.gridworks.model.Project;
|
||||
|
||||
public class GetScatterplotCommand extends Command {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("get-scatterplot_command");
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
@ -50,7 +53,7 @@ public class GetScatterplotCommand extends Command {
|
||||
sos.close();
|
||||
}
|
||||
|
||||
Gridworks.log("Drawn scatterplot in " + (System.currentTimeMillis() - start) + "ms");
|
||||
logger.info("Drawn scatterplot in {} ms", Long.toString(System.currentTimeMillis() - start));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
respondException(response, e);
|
||||
@ -97,7 +100,7 @@ public class GetScatterplotCommand extends Command {
|
||||
try {
|
||||
eval_x = MetaParser.parse(expression_x);
|
||||
} catch (ParsingException e) {
|
||||
Gridworks.warn("error parsing expression", e);
|
||||
logger.warn("error parsing expression", e);
|
||||
}
|
||||
|
||||
String columnName_y = o.getString(ScatterplotFacet.Y_COLUMN_NAME);
|
||||
@ -115,7 +118,7 @@ public class GetScatterplotCommand extends Command {
|
||||
try {
|
||||
eval_y = MetaParser.parse(expression_y);
|
||||
} catch (ParsingException e) {
|
||||
Gridworks.warn("error parsing expression", e);
|
||||
logger.warn("error parsing expression", e);
|
||||
}
|
||||
|
||||
NumericBinIndex index_x = null;
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.metaweb.gridworks.expr.functions;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
|
||||
import com.metaweb.gridworks.expr.util.CalendarParser;
|
||||
import com.metaweb.gridworks.expr.util.CalendarParserException;
|
||||
|
@ -34,7 +34,6 @@ import com.metaweb.gridworks.expr.functions.math.Pow;
|
||||
import com.metaweb.gridworks.expr.functions.math.Round;
|
||||
import com.metaweb.gridworks.expr.functions.math.Sum;
|
||||
import com.metaweb.gridworks.expr.functions.strings.Contains;
|
||||
import com.metaweb.gridworks.expr.functions.strings.SplitByLengths;
|
||||
import com.metaweb.gridworks.expr.functions.strings.Diff;
|
||||
import com.metaweb.gridworks.expr.functions.strings.EndsWith;
|
||||
import com.metaweb.gridworks.expr.functions.strings.Fingerprint;
|
||||
@ -51,6 +50,7 @@ import com.metaweb.gridworks.expr.functions.strings.ReplaceChars;
|
||||
import com.metaweb.gridworks.expr.functions.strings.SHA1;
|
||||
import com.metaweb.gridworks.expr.functions.strings.Split;
|
||||
import com.metaweb.gridworks.expr.functions.strings.SplitByCharType;
|
||||
import com.metaweb.gridworks.expr.functions.strings.SplitByLengths;
|
||||
import com.metaweb.gridworks.expr.functions.strings.StartsWith;
|
||||
import com.metaweb.gridworks.expr.functions.strings.ToLowercase;
|
||||
import com.metaweb.gridworks.expr.functions.strings.ToTitlecase;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.metaweb.gridworks.history;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
@ -20,6 +20,9 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.ProjectManager;
|
||||
import com.metaweb.gridworks.ProjectMetadata;
|
||||
@ -40,6 +43,8 @@ public class Project {
|
||||
transient public ProcessManager processManager = new ProcessManager();
|
||||
transient public Date lastSave = new Date();
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("project");
|
||||
|
||||
static public long generateID() {
|
||||
return System.currentTimeMillis() + Math.round(Math.random() * 1000000000000L);
|
||||
}
|
||||
@ -68,7 +73,7 @@ public class Project {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Gridworks.log("Failed to save project " + id);
|
||||
logger.warn("Failed to save project {}", id);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -86,7 +91,7 @@ public class Project {
|
||||
|
||||
lastSave = new Date();
|
||||
|
||||
Gridworks.log("Saved project " + id + ".");
|
||||
logger.info("Saved project '{}'",id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,10 +218,8 @@ public class Project {
|
||||
|
||||
project.columnModel.setMaxCellIndex(maxCellCount - 1);
|
||||
|
||||
Gridworks.log(
|
||||
"Loaded project " + id + " from disk in " +
|
||||
(System.currentTimeMillis() - start) / 1000 +
|
||||
" sec(s)"
|
||||
logger.info(
|
||||
"Loaded project {} from disk in {} sec(s)",id,Long.toString((System.currentTimeMillis() - start) / 1000)
|
||||
);
|
||||
|
||||
project.recomputeRowContextDependencies();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.metaweb.gridworks.model.changes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
|
@ -25,6 +25,7 @@ public class Credentials {
|
||||
}
|
||||
|
||||
public String getCookieName(Provider provider) {
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
return provider.getHost() + "_" + postfix;
|
||||
}
|
||||
};
|
||||
@ -36,10 +37,8 @@ public class Credentials {
|
||||
|
||||
public static void setCredentials(HttpServletResponse response, Credentials credentials, Type type, int max_age) {
|
||||
String name = type.getCookieName(credentials.getProvider());
|
||||
Cookie c = new Cookie(name, credentials.toString());
|
||||
c.setPath("/");
|
||||
c.setMaxAge(max_age);
|
||||
response.addCookie(c);
|
||||
String value = credentials.toString();
|
||||
CookiesUtilities.setCookie(response, name, value, max_age);
|
||||
}
|
||||
|
||||
public static void deleteCredentials(HttpServletRequest request, HttpServletResponse response, Provider provider, Type type) {
|
||||
@ -60,6 +59,8 @@ public class Credentials {
|
||||
if (token == null) throw new RuntimeException("Could not find " + TOKEN + " in auth credentials");
|
||||
this.secret = secret;
|
||||
if (secret == null) throw new RuntimeException("Could not find " + SECRET + " in auth credentials");
|
||||
this.provider = provider;
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
|
@ -3,10 +3,15 @@ package com.metaweb.gridworks.oauth;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import oauth.signpost.OAuthConsumer;
|
||||
import oauth.signpost.OAuthProvider;
|
||||
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
|
||||
import oauth.signpost.commonshttp.CommonsHttpOAuthProvider;
|
||||
import oauth.signpost.http.HttpParameters;
|
||||
|
||||
import com.metaweb.gridworks.util.FreebaseUtils;
|
||||
|
||||
public class OAuthUtilities {
|
||||
|
||||
@ -14,30 +19,43 @@ public class OAuthUtilities {
|
||||
static final private Map<String,String[]> infos = new HashMap<String,String[]>();
|
||||
|
||||
static private final String[] FREEBASE_OAUTH_INFO = { "#9202a8c04000641f80000000150979b7" , "8ded7babfad2f94f4c77e39bbd6c90f31939999b"};
|
||||
static private final String[] SANDBOX_OAUTH_INFO = { "#9202a8c04000641f800000001505964a" , "a816b13991bf1d191ad1c371f3c230feca6a11e2"};
|
||||
|
||||
static {
|
||||
providers.put("freebase", new FreebaseProvider("www.freebase.com"));
|
||||
providers.put("sandbox", new FreebaseProvider("www.sandbox-freebase.com"));
|
||||
Provider freebase = new FreebaseProvider(FreebaseUtils.FREEBASE_HOST);
|
||||
providers.put(freebase.getHost(), freebase);
|
||||
|
||||
infos.put("www.freebase.com", FREEBASE_OAUTH_INFO);
|
||||
infos.put("www.sandbox-freebase.com", SANDBOX_OAUTH_INFO);
|
||||
infos.put(freebase.getHost(), FREEBASE_OAUTH_INFO);
|
||||
}
|
||||
|
||||
public static Provider getProvider(String name) {
|
||||
return (name == null) ? null : providers.get(name);
|
||||
}
|
||||
|
||||
public static Provider getProvider(HttpServletRequest request) {
|
||||
String path = request.getPathInfo().substring(1);
|
||||
int slash = path.lastIndexOf('/');
|
||||
String provider_str = path.substring(slash + 1);
|
||||
Provider provider = getProvider(provider_str);
|
||||
if (provider == null) throw new RuntimeException("Can't find OAuth provider '" + provider_str + "'");
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static OAuthConsumer getConsumer(Provider provider) {
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
String[] consumer_info = infos.get(provider.getHost());
|
||||
if (consumer_info == null) throw new RuntimeException("Can't find secrets for provider '" + provider.getHost() + "'");
|
||||
return new CommonsHttpOAuthConsumer(consumer_info[0],consumer_info[1]);
|
||||
OAuthConsumer oauthConsumer = new CommonsHttpOAuthConsumer(consumer_info[0],consumer_info[1]);
|
||||
HttpParameters params = new HttpParameters();
|
||||
params.put("realm", provider.getHost());
|
||||
oauthConsumer.setAdditionalParameters(params);
|
||||
return oauthConsumer;
|
||||
}
|
||||
|
||||
public static OAuthConsumer getConsumer(Credentials credentials, Provider provider) {
|
||||
OAuthConsumer consumer = getConsumer(provider);
|
||||
consumer.setTokenWithSecret(credentials.getToken(), credentials.getSecret());
|
||||
if (credentials != null) {
|
||||
consumer.setTokenWithSecret(credentials.getToken(), credentials.getSecret());
|
||||
}
|
||||
return consumer;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class CookiesUtilities {
|
||||
|
||||
public static final String DOMAIN = "127.0.0.1";
|
||||
public static final String PATH = "/";
|
||||
|
||||
public static Cookie getCookie(HttpServletRequest request, String name) {
|
||||
if (name == null) throw new RuntimeException("cookie name cannot be null");
|
||||
Cookie cookie = null;
|
||||
@ -20,15 +23,20 @@ public class CookiesUtilities {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
public static void setCookie(HttpServletResponse response, String name, String value, int max_age) {
|
||||
Cookie c = new Cookie(name, value);
|
||||
c.setDomain(DOMAIN);
|
||||
c.setPath(PATH);
|
||||
c.setMaxAge(max_age);
|
||||
response.addCookie(c);
|
||||
}
|
||||
|
||||
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name) {
|
||||
Cookie cookie = getCookie(request, name);
|
||||
if (cookie != null) {
|
||||
Cookie delCookie = new Cookie(cookie.getName(), cookie.getValue());
|
||||
delCookie.setDomain(cookie.getDomain());
|
||||
delCookie.setPath(cookie.getPath());
|
||||
delCookie.setMaxAge(0);
|
||||
response.addCookie(delCookie);
|
||||
}
|
||||
Cookie c = new Cookie(name, "");
|
||||
c.setDomain(DOMAIN);
|
||||
c.setPath(PATH);
|
||||
c.setMaxAge(0);
|
||||
response.addCookie(c);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
package com.metaweb.gridworks.util;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
|
115
src/main/java/com/metaweb/gridworks/util/FreebaseUtils.java
Normal file
115
src/main/java/com/metaweb/gridworks/util/FreebaseUtils.java
Normal file
@ -0,0 +1,115 @@
|
||||
package com.metaweb.gridworks.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import oauth.signpost.OAuthConsumer;
|
||||
import oauth.signpost.exception.OAuthCommunicationException;
|
||||
import oauth.signpost.exception.OAuthExpectationFailedException;
|
||||
import oauth.signpost.exception.OAuthMessageSignerException;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.params.CoreProtocolPNames;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.metaweb.gridworks.Gridworks;
|
||||
import com.metaweb.gridworks.oauth.Credentials;
|
||||
import com.metaweb.gridworks.oauth.OAuthUtilities;
|
||||
import com.metaweb.gridworks.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/prod/";
|
||||
|
||||
private static String getUserInfoURL(String host) {
|
||||
return "http://" + host + "/api/service/user_info";
|
||||
}
|
||||
|
||||
public static String getUserInfo(Credentials credentials, Provider provider)
|
||||
throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, IOException {
|
||||
|
||||
OAuthConsumer consumer = OAuthUtilities.getConsumer(credentials, provider);
|
||||
|
||||
HttpGet httpRequest = new HttpGet(getUserInfoURL(provider.getHost()));
|
||||
httpRequest.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Gridworks " + Gridworks.getVersion());
|
||||
|
||||
// this is required by the Metaweb API to avoid XSS
|
||||
httpRequest.setHeader("X-Requested-With", "1");
|
||||
|
||||
// sign the request with the oauth library
|
||||
consumer.sign(httpRequest);
|
||||
|
||||
// execute the request
|
||||
HttpClient httpClient = new DefaultHttpClient();
|
||||
HttpResponse httpResponse = httpClient.execute(httpRequest);
|
||||
|
||||
// return the results
|
||||
return EntityUtils.toString(httpResponse.getEntity());
|
||||
}
|
||||
|
||||
public static String uploadTriples(HttpServletRequest request, String info, String triples)
|
||||
throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, JSONException, IOException {
|
||||
|
||||
Provider provider = OAuthUtilities.getProvider(FREEBASE_HOST);
|
||||
|
||||
Credentials credentials = Credentials.getCredentials(request, provider, Credentials.Type.ACCESS);
|
||||
|
||||
JSONObject user_info = new JSONObject(getUserInfo(credentials, provider));
|
||||
if (user_info.has("username")) {
|
||||
|
||||
List<NameValuePair> formparams = new ArrayList<NameValuePair>();
|
||||
formparams.add(new BasicNameValuePair("user", user_info.getString("username")));
|
||||
formparams.add(new BasicNameValuePair("action_type", "LOAD_TRIPLE"));
|
||||
formparams.add(new BasicNameValuePair("operator", "gridworks"));
|
||||
formparams.add(new BasicNameValuePair("mdo_info", info));
|
||||
formparams.add(new BasicNameValuePair("graphport", provider.getHost().equals(FREEBASE_HOST) ? "otg" : "sandbox"));
|
||||
formparams.add(new BasicNameValuePair("payload", triples));
|
||||
formparams.add(new BasicNameValuePair("check_params", "false"));
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");
|
||||
|
||||
HttpPost httpRequest = new HttpPost(FREEQ_URL);
|
||||
httpRequest.setEntity(entity);
|
||||
|
||||
HttpPost surrogateRequest = new HttpPost(getUserInfoURL(FREEBASE_HOST));
|
||||
surrogateRequest.setEntity(entity);
|
||||
|
||||
OAuthConsumer consumer = OAuthUtilities.getConsumer(credentials, provider);
|
||||
|
||||
consumer.sign(surrogateRequest);
|
||||
|
||||
Header[] h = surrogateRequest.getHeaders("Authorization");
|
||||
if (h.length > 0) {
|
||||
httpRequest.setHeader("X-Freebase-Credentials", h[0].getValue());
|
||||
} else {
|
||||
throw new RuntimeException("Couldn't find the oauth signature header in the surrogate request");
|
||||
}
|
||||
|
||||
// execute the request
|
||||
HttpClient httpClient = new DefaultHttpClient();
|
||||
HttpResponse httpResponse = httpClient.execute(httpRequest);
|
||||
|
||||
// return the results
|
||||
return EntityUtils.toString(httpResponse.getEntity());
|
||||
} else {
|
||||
throw new RuntimeException("Invalid credentials");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
BIN
src/main/webapp/WEB-INF/lib/slf4j-api-1.5.6.jar
Normal file
BIN
src/main/webapp/WEB-INF/lib/slf4j-api-1.5.6.jar
Normal file
Binary file not shown.
BIN
src/main/webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar
Normal file
BIN
src/main/webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar
Normal file
Binary file not shown.
@ -1,8 +0,0 @@
|
||||
log4j.rootLogger=INFO, console
|
||||
log4j.logger.org.mortbay.jetty=ERROR
|
||||
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.console.layout.ConversionPattern=[%p] %m%n
|
||||
#log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %c(%L) - %m%n
|
||||
log4j.appender.console.layout.ConversionPattern=[%p] %c(%L) - %m%n
|
478
src/main/webapp/externals/blockui/jquery.blockui.js
vendored
478
src/main/webapp/externals/blockui/jquery.blockui.js
vendored
@ -1,478 +0,0 @@
|
||||
/*!
|
||||
* jQuery blockUI plugin
|
||||
* Version 2.31 (06-JAN-2010)
|
||||
* @requires jQuery v1.2.3 or later
|
||||
*
|
||||
* Examples at: http://malsup.com/jquery/block/
|
||||
* Copyright (c) 2007-2008 M. Alsup
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
|
||||
if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
|
||||
alert('blockUI requires jQuery v1.2.3 or later! You are using v' + $.fn.jquery);
|
||||
return;
|
||||
}
|
||||
|
||||
$.fn._fadeIn = $.fn.fadeIn;
|
||||
|
||||
var noOp = function() {};
|
||||
|
||||
// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
|
||||
// retarded userAgent strings on Vista)
|
||||
var mode = document.documentMode || 0;
|
||||
var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
|
||||
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
|
||||
|
||||
// global $ methods for blocking/unblocking the entire page
|
||||
$.blockUI = function(opts) { install(window, opts); };
|
||||
$.unblockUI = function(opts) { remove(window, opts); };
|
||||
|
||||
// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
|
||||
$.growlUI = function(title, message, timeout, onClose) {
|
||||
var $m = $('<div class="growlUI"></div>');
|
||||
if (title) $m.append('<h1>'+title+'</h1>');
|
||||
if (message) $m.append('<h2>'+message+'</h2>');
|
||||
if (timeout == undefined) timeout = 3000;
|
||||
$.blockUI({
|
||||
message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
|
||||
timeout: timeout, showOverlay: false,
|
||||
onUnblock: onClose,
|
||||
css: $.blockUI.defaults.growlCSS
|
||||
});
|
||||
};
|
||||
|
||||
// plugin method for blocking element content
|
||||
$.fn.block = function(opts) {
|
||||
return this.unblock({ fadeOut: 0 }).each(function() {
|
||||
if ($.css(this,'position') == 'static')
|
||||
this.style.position = 'relative';
|
||||
if ($.browser.msie)
|
||||
this.style.zoom = 1; // force 'hasLayout'
|
||||
install(this, opts);
|
||||
});
|
||||
};
|
||||
|
||||
// plugin method for unblocking element content
|
||||
$.fn.unblock = function(opts) {
|
||||
return this.each(function() {
|
||||
remove(this, opts);
|
||||
});
|
||||
};
|
||||
|
||||
$.blockUI.version = 2.31; // 2nd generation blocking at no extra cost!
|
||||
|
||||
// override these in your code to change the default behavior and style
|
||||
$.blockUI.defaults = {
|
||||
// message displayed when blocking (use null for no message)
|
||||
message: '<h1>Please wait...</h1>',
|
||||
|
||||
title: null, // title string; only used when theme == true
|
||||
draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
|
||||
|
||||
theme: false, // set to true to use with jQuery UI themes
|
||||
|
||||
// styles for the message when blocking; if you wish to disable
|
||||
// these and use an external stylesheet then do this in your code:
|
||||
// $.blockUI.defaults.css = {};
|
||||
css: {
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
width: '30%',
|
||||
top: '40%',
|
||||
left: '35%',
|
||||
textAlign: 'center',
|
||||
color: '#000',
|
||||
border: '3px solid #aaa',
|
||||
backgroundColor:'#fff',
|
||||
cursor: 'wait'
|
||||
},
|
||||
|
||||
// minimal style set used when themes are used
|
||||
themedCSS: {
|
||||
width: '30%',
|
||||
top: '40%',
|
||||
left: '35%'
|
||||
},
|
||||
|
||||
// styles for the overlay
|
||||
overlayCSS: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.6,
|
||||
cursor: 'wait'
|
||||
},
|
||||
|
||||
// styles applied when using $.growlUI
|
||||
growlCSS: {
|
||||
width: '350px',
|
||||
top: '10px',
|
||||
left: '',
|
||||
right: '10px',
|
||||
border: 'none',
|
||||
padding: '5px',
|
||||
opacity: 0.6,
|
||||
cursor: 'default',
|
||||
color: '#fff',
|
||||
backgroundColor: '#000',
|
||||
'-webkit-border-radius': '10px',
|
||||
'-moz-border-radius': '10px'
|
||||
},
|
||||
|
||||
// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
|
||||
// (hat tip to Jorge H. N. de Vasconcelos)
|
||||
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
|
||||
|
||||
// force usage of iframe in non-IE browsers (handy for blocking applets)
|
||||
forceIframe: false,
|
||||
|
||||
// z-index for the blocking overlay
|
||||
baseZ: 1000,
|
||||
|
||||
// set these to true to have the message automatically centered
|
||||
centerX: true, // <-- only effects element blocking (page block controlled via css above)
|
||||
centerY: true,
|
||||
|
||||
// allow body element to be stetched in ie6; this makes blocking look better
|
||||
// on "short" pages. disable if you wish to prevent changes to the body height
|
||||
allowBodyStretch: true,
|
||||
|
||||
// enable if you want key and mouse events to be disabled for content that is blocked
|
||||
bindEvents: true,
|
||||
|
||||
// be default blockUI will supress tab navigation from leaving blocking content
|
||||
// (if bindEvents is true)
|
||||
constrainTabKey: true,
|
||||
|
||||
// fadeIn time in millis; set to 0 to disable fadeIn on block
|
||||
fadeIn: 200,
|
||||
|
||||
// fadeOut time in millis; set to 0 to disable fadeOut on unblock
|
||||
fadeOut: 400,
|
||||
|
||||
// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
|
||||
timeout: 0,
|
||||
|
||||
// disable if you don't want to show the overlay
|
||||
showOverlay: true,
|
||||
|
||||
// if true, focus will be placed in the first available input field when
|
||||
// page blocking
|
||||
focusInput: true,
|
||||
|
||||
// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
|
||||
applyPlatformOpacityRules: true,
|
||||
|
||||
// callback method invoked when fadeIn has completed and blocking message is visible
|
||||
onBlock: null,
|
||||
|
||||
// callback method invoked when unblocking has completed; the callback is
|
||||
// passed the element that has been unblocked (which is the window object for page
|
||||
// blocks) and the options that were passed to the unblock call:
|
||||
// onUnblock(element, options)
|
||||
onUnblock: null,
|
||||
|
||||
// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
|
||||
quirksmodeOffsetHack: 4
|
||||
};
|
||||
|
||||
// private data and functions follow...
|
||||
|
||||
var pageBlock = null;
|
||||
var pageBlockEls = [];
|
||||
|
||||
function install(el, opts) {
|
||||
var full = (el == window);
|
||||
var msg = opts && opts.message !== undefined ? opts.message : undefined;
|
||||
opts = $.extend({}, $.blockUI.defaults, opts || {});
|
||||
opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
|
||||
var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
|
||||
var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
|
||||
msg = msg === undefined ? opts.message : msg;
|
||||
|
||||
// remove the current block (if there is one)
|
||||
if (full && pageBlock)
|
||||
remove(window, {fadeOut:0});
|
||||
|
||||
// if an existing element is being used as the blocking content then we capture
|
||||
// its current place in the DOM (and current display style) so we can restore
|
||||
// it when we unblock
|
||||
if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
|
||||
var node = msg.jquery ? msg[0] : msg;
|
||||
var data = {};
|
||||
$(el).data('blockUI.history', data);
|
||||
data.el = node;
|
||||
data.parent = node.parentNode;
|
||||
data.display = node.style.display;
|
||||
data.position = node.style.position;
|
||||
if (data.parent)
|
||||
data.parent.removeChild(node);
|
||||
}
|
||||
|
||||
var z = opts.baseZ;
|
||||
|
||||
// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
|
||||
// layer1 is the iframe layer which is used to supress bleed through of underlying content
|
||||
// layer2 is the overlay layer which has opacity and a wait cursor (by default)
|
||||
// layer3 is the message content that is displayed while blocking
|
||||
|
||||
var lyr1 = ($.browser.msie || opts.forceIframe)
|
||||
? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
|
||||
: $('<div class="blockUI" style="display:none"></div>');
|
||||
var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
|
||||
|
||||
var lyr3;
|
||||
if (opts.theme && full) {
|
||||
var s = '<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:fixed">' +
|
||||
'<div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(opts.title || ' ')+'</div>' +
|
||||
'<div class="ui-widget-content ui-dialog-content"></div>' +
|
||||
'</div>';
|
||||
lyr3 = $(s);
|
||||
}
|
||||
else {
|
||||
lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>')
|
||||
: $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');
|
||||
}
|
||||
|
||||
// if we have a message, style it
|
||||
if (msg) {
|
||||
if (opts.theme) {
|
||||
lyr3.css(themedCSS);
|
||||
lyr3.addClass('ui-widget-content');
|
||||
}
|
||||
else
|
||||
lyr3.css(css);
|
||||
}
|
||||
|
||||
// style the overlay
|
||||
if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
|
||||
lyr2.css(opts.overlayCSS);
|
||||
lyr2.css('position', full ? 'fixed' : 'absolute');
|
||||
|
||||
// make iframe layer transparent in IE
|
||||
if ($.browser.msie || opts.forceIframe)
|
||||
lyr1.css('opacity',0.0);
|
||||
|
||||
//$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
|
||||
var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
|
||||
$.each(layers, function() {
|
||||
this.appendTo($par);
|
||||
});
|
||||
|
||||
if (opts.theme && opts.draggable && $.fn.draggable) {
|
||||
lyr3.draggable({
|
||||
handle: '.ui-dialog-titlebar',
|
||||
cancel: 'li'
|
||||
});
|
||||
}
|
||||
|
||||
// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
|
||||
var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
|
||||
if (ie6 || expr) {
|
||||
// give body 100% height
|
||||
if (full && opts.allowBodyStretch && $.boxModel)
|
||||
$('html,body').css('height','100%');
|
||||
|
||||
// fix ie6 issue when blocked element has a border width
|
||||
if ((ie6 || !$.boxModel) && !full) {
|
||||
var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
|
||||
var fixT = t ? '(0 - '+t+')' : 0;
|
||||
var fixL = l ? '(0 - '+l+')' : 0;
|
||||
}
|
||||
|
||||
// simulate fixed position
|
||||
$.each([lyr1,lyr2,lyr3], function(i,o) {
|
||||
var s = o[0].style;
|
||||
s.position = 'absolute';
|
||||
if (i < 2) {
|
||||
full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
|
||||
: s.setExpression('height','this.parentNode.offsetHeight + "px"');
|
||||
full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
|
||||
: s.setExpression('width','this.parentNode.offsetWidth + "px"');
|
||||
if (fixL) s.setExpression('left', fixL);
|
||||
if (fixT) s.setExpression('top', fixT);
|
||||
}
|
||||
else if (opts.centerY) {
|
||||
if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
|
||||
s.marginTop = 0;
|
||||
}
|
||||
else if (!opts.centerY && full) {
|
||||
var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
|
||||
var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
|
||||
s.setExpression('top',expression);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// show the message
|
||||
if (msg) {
|
||||
if (opts.theme)
|
||||
lyr3.find('.ui-widget-content').append(msg);
|
||||
else
|
||||
lyr3.append(msg);
|
||||
if (msg.jquery || msg.nodeType)
|
||||
$(msg).show();
|
||||
}
|
||||
|
||||
if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
|
||||
lyr1.show(); // opacity is zero
|
||||
if (opts.fadeIn) {
|
||||
var cb = opts.onBlock ? opts.onBlock : noOp;
|
||||
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
|
||||
var cb2 = msg ? cb : noOp;
|
||||
if (opts.showOverlay)
|
||||
lyr2._fadeIn(opts.fadeIn, cb1);
|
||||
if (msg)
|
||||
lyr3._fadeIn(opts.fadeIn, cb2);
|
||||
}
|
||||
else {
|
||||
if (opts.showOverlay)
|
||||
lyr2.show();
|
||||
if (msg)
|
||||
lyr3.show();
|
||||
if (opts.onBlock)
|
||||
opts.onBlock();
|
||||
}
|
||||
|
||||
// bind key and mouse events
|
||||
bind(1, el, opts);
|
||||
|
||||
if (full) {
|
||||
pageBlock = lyr3[0];
|
||||
pageBlockEls = $(':input:enabled:visible',pageBlock);
|
||||
if (opts.focusInput)
|
||||
setTimeout(focus, 20);
|
||||
}
|
||||
else
|
||||
center(lyr3[0], opts.centerX, opts.centerY);
|
||||
|
||||
if (opts.timeout) {
|
||||
// auto-unblock
|
||||
var to = setTimeout(function() {
|
||||
full ? $.unblockUI(opts) : $(el).unblock(opts);
|
||||
}, opts.timeout);
|
||||
$(el).data('blockUI.timeout', to);
|
||||
}
|
||||
};
|
||||
|
||||
// remove the block
|
||||
function remove(el, opts) {
|
||||
var full = (el == window);
|
||||
var $el = $(el);
|
||||
var data = $el.data('blockUI.history');
|
||||
var to = $el.data('blockUI.timeout');
|
||||
if (to) {
|
||||
clearTimeout(to);
|
||||
$el.removeData('blockUI.timeout');
|
||||
}
|
||||
opts = $.extend({}, $.blockUI.defaults, opts || {});
|
||||
bind(0, el, opts); // unbind events
|
||||
|
||||
var els;
|
||||
if (full) // crazy selector to handle odd field errors in ie6/7
|
||||
els = $('body').children().filter('.blockUI').add('body > .blockUI');
|
||||
else
|
||||
els = $('.blockUI', el);
|
||||
|
||||
if (full)
|
||||
pageBlock = pageBlockEls = null;
|
||||
|
||||
if (opts.fadeOut) {
|
||||
els.fadeOut(opts.fadeOut);
|
||||
setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
|
||||
}
|
||||
else
|
||||
reset(els, data, opts, el);
|
||||
};
|
||||
|
||||
// move blocking element back into the DOM where it started
|
||||
function reset(els,data,opts,el) {
|
||||
els.each(function(i,o) {
|
||||
// remove via DOM calls so we don't lose event handlers
|
||||
if (this.parentNode)
|
||||
this.parentNode.removeChild(this);
|
||||
});
|
||||
|
||||
if (data && data.el) {
|
||||
data.el.style.display = data.display;
|
||||
data.el.style.position = data.position;
|
||||
if (data.parent)
|
||||
data.parent.appendChild(data.el);
|
||||
$(el).removeData('blockUI.history');
|
||||
}
|
||||
|
||||
if (typeof opts.onUnblock == 'function')
|
||||
opts.onUnblock(el,opts);
|
||||
};
|
||||
|
||||
// bind/unbind the handler
|
||||
function bind(b, el, opts) {
|
||||
var full = el == window, $el = $(el);
|
||||
|
||||
// don't bother unbinding if there is nothing to unbind
|
||||
if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
|
||||
return;
|
||||
if (!full)
|
||||
$el.data('blockUI.isBlocked', b);
|
||||
|
||||
// don't bind events when overlay is not in use or if bindEvents is false
|
||||
if (!opts.bindEvents || (b && !opts.showOverlay))
|
||||
return;
|
||||
|
||||
// bind anchors and inputs for mouse and key events
|
||||
var events = 'mousedown mouseup keydown keypress';
|
||||
b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);
|
||||
|
||||
// former impl...
|
||||
// var $e = $('a,:input');
|
||||
// b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
|
||||
};
|
||||
|
||||
// event handler to suppress keyboard/mouse events when blocking
|
||||
function handler(e) {
|
||||
// allow tab navigation (conditionally)
|
||||
if (e.keyCode && e.keyCode == 9) {
|
||||
if (pageBlock && e.data.constrainTabKey) {
|
||||
var els = pageBlockEls;
|
||||
var fwd = !e.shiftKey && e.target == els[els.length-1];
|
||||
var back = e.shiftKey && e.target == els[0];
|
||||
if (fwd || back) {
|
||||
setTimeout(function(){focus(back)},10);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// allow events within the message content
|
||||
if ($(e.target).parents('div.blockMsg').length > 0)
|
||||
return true;
|
||||
|
||||
// allow events for content that is not being blocked
|
||||
return $(e.target).parents().children().filter('div.blockUI').length == 0;
|
||||
};
|
||||
|
||||
function focus(back) {
|
||||
if (!pageBlockEls)
|
||||
return;
|
||||
var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
|
||||
if (e)
|
||||
e.focus();
|
||||
};
|
||||
|
||||
function center(el, x, y) {
|
||||
var p = el.parentNode, s = el.style;
|
||||
var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
|
||||
var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
|
||||
if (x) s.left = l > 0 ? (l+'px') : '0';
|
||||
if (y) s.top = t > 0 ? (t+'px') : '0';
|
||||
};
|
||||
|
||||
function sz(el, p) {
|
||||
return parseInt($.css(el,p))||0;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
File diff suppressed because one or more lines are too long
@ -5,76 +5,118 @@ function FreebaseLoadingDialog() {
|
||||
FreebaseLoadingDialog.prototype._createDialog = function() {
|
||||
var self = this;
|
||||
var frame = DialogSystem.createDialog();
|
||||
frame.width("900px");
|
||||
frame.width("800px");
|
||||
|
||||
var header = $('<div></div>').addClass("dialog-header").text('Load Data into Freebase').appendTo(frame);
|
||||
var body = $('<div></div>').addClass("dialog-body").appendTo(frame);
|
||||
var footer = $(
|
||||
'<div class="dialog-footer">' +
|
||||
'<table width="100%"><tr>' +
|
||||
'<td class="left" style="text-align: left"></td>' +
|
||||
'<td class="right" style="text-align: right"></td>' +
|
||||
'<td class="left" style="text-align: left" width="40%" nowrap="true"></td>' +
|
||||
'<td class="center" style="text-align: center" width="20%" nowrap="true"></td>' +
|
||||
'<td class="right" style="text-align: right" width="40%" nowrap="true"></td>' +
|
||||
'</tr></table>' +
|
||||
'</div>'
|
||||
).appendTo(frame);
|
||||
|
||||
$.post(
|
||||
"/command/export-rows?" + $.param({
|
||||
"/command/export-rows",
|
||||
{
|
||||
project: theProject.id,
|
||||
format : "tripleloader"
|
||||
}),
|
||||
{},
|
||||
},
|
||||
function(data) {
|
||||
frame.find(".dialog-body").html('<div class="freebase-loading-tripleloader-data">' + data + '</pre>');
|
||||
console.log(data);
|
||||
body.html(
|
||||
'<div class="freebase-loading-tripleloader-data">' + data + '</div>' +
|
||||
'<div class="freebase-loading-tripleloader-info">' +
|
||||
'<div>Describe the data you\'re about to load ¬</div>' +
|
||||
'<textarea></textarea>' +
|
||||
'</div>'
|
||||
);
|
||||
self._level = DialogSystem.showDialog(frame);
|
||||
}
|
||||
);
|
||||
|
||||
var left_footer = footer.find(".left");
|
||||
$('<button></button>').text("Cancel").click(function() {
|
||||
var left_footer = footer.find(".left");
|
||||
|
||||
var cancel_button = $('<button id="freebase-loading-cancel"></button>').text("Cancel").click(function() {
|
||||
self._dismiss();
|
||||
}).appendTo(left_footer);
|
||||
|
||||
var center_footer = footer.find(".center");
|
||||
|
||||
var authorization = $('<div>').addClass("freebase-loading-authorization").hide().appendTo(center_footer);
|
||||
|
||||
var right_footer = footer.find(".right");
|
||||
|
||||
//$('<div class="freebase-loading-authorization signedin" style="display: none">Signed in as: <span class="user"></span></div>').appendTo(right_footer);
|
||||
|
||||
var selector = $('<span>').addClass("freebase-loading-graph-selector").html("Load into " +
|
||||
var selector = $('<span>').addClass("freebase-loading-graph-selector").html("Load this data into " +
|
||||
'<input type="radio" bind="sandbox" id="freebase-loading-graph-selector-sandbox" name="graph-selector" checked="checked" value="sandbox"/><label class="sandbox" for="freebase-loading-graph-selector-sandbox" title="Load into the sandbox">sandbox</label>' +
|
||||
'<input type="radio" bind="otg" id="freebase-loading-graph-selector-otg" name="graph-selector" value="otg"/><label class="otg" for="freebase-loading-graph-selector-otg" title="Load into Freebase">freebase</label>'
|
||||
'<input type="radio" bind="freebase" id="freebase-loading-graph-selector-freebase" name="graph-selector" value="freebase"/><label class="freebase" for="freebase-loading-graph-selector-freebase" title="Load into Freebase">freebase</label>'
|
||||
).buttonset().appendTo(right_footer);
|
||||
|
||||
$('<button></button>').text("Load").click(function() {
|
||||
self._check_authorization(self._load);
|
||||
}).appendTo(right_footer);
|
||||
|
||||
var load_button = $('<button id="freebase-loading-load"></button>').text("Sign In").appendTo(right_footer);
|
||||
|
||||
this._elmts = DOM.bind(frame);
|
||||
|
||||
var provider = "www.freebase.com";
|
||||
|
||||
this._elmts.otg.click(function() {
|
||||
if (!confirm("are you sure?")) {
|
||||
self._elmts.sandbox.attr("checked","checked");
|
||||
self._elmts.otg.removeAttr("checked");
|
||||
selector.find("input").button('refresh');
|
||||
}
|
||||
var check_authorization = function() {
|
||||
$.get("/command/check-authorization/" + provider, function(data) {
|
||||
if ("status" in data && data.status == "200 OK") {
|
||||
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
|
||||
DOM.bind(authorization).signout.click(function() {
|
||||
Sign.signout(check_authorization,provider);
|
||||
});
|
||||
load_button.text("Load").unbind().click(function() {
|
||||
self._load(self);
|
||||
});
|
||||
} else {
|
||||
authorization.html("").hide();
|
||||
load_button.text("Sign In").removeAttr("disabled").unbind().click(function() {
|
||||
Sign.signin(check_authorization,provider);
|
||||
});
|
||||
}
|
||||
},"json");
|
||||
};
|
||||
|
||||
check_authorization();
|
||||
|
||||
this._elmts.sandbox.click(function() {
|
||||
//check_authorization();
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
FreebaseLoadingDialog.prototype._check_authorization = function(cont) {
|
||||
var freebase = this._elmts.otg.attr("checked");
|
||||
var provider = (freebase) ? "freebase" : "sandbox";
|
||||
$.get("/command/check-authorization",{ "provider" : provider }, function(data) {
|
||||
if ("status" in data && data.status == "200 OK") {
|
||||
if (typeof cont == "function") cont();
|
||||
} else {
|
||||
alert("Sorry, we're working very hard to make this happen.");
|
||||
//Sign.signin(cont,provider);
|
||||
this._elmts.freebase.click(function() {
|
||||
if (!confirm("Are you sure your data is clean enough to enter Freebase?")) {
|
||||
self._elmts.sandbox.attr("checked","checked");
|
||||
self._elmts.freebase.removeAttr("checked");
|
||||
selector.find("input").button('refresh');
|
||||
}
|
||||
},"json");
|
||||
//check_authorization();
|
||||
});
|
||||
};
|
||||
|
||||
FreebaseLoadingDialog.prototype._load = function() {
|
||||
// do the real loading here
|
||||
FreebaseLoadingDialog.prototype._load = function(self) {
|
||||
$.post("/command/upload-data",
|
||||
{
|
||||
project: theProject.id,
|
||||
"graph" : ($("#freebase-loading-graph-selector-freebase").attr("checked")) ? "otg" : "sandbox",
|
||||
"info" : $("#freebase-loading-tripleloader-info textarea").val()
|
||||
},
|
||||
function(data) {
|
||||
var body = $(".dialog-body");
|
||||
if ("status" in data && data.status == "200 OK") {
|
||||
body.html('<div class="freebase-loading-tripleloader-message"><h2>Data successfully loaded!</h2>' + data.message + '</div>');
|
||||
} else {
|
||||
body.html('<div class="freebase-loading-tripleloader-message"><h2>Error loading data!</h2><pre>' + JSON.stringify(data,null,2) + '</pre></div>');
|
||||
}
|
||||
$("button#freebase-loading-load").text("Close").unbind().click(function() {
|
||||
self._dismiss();
|
||||
});
|
||||
$("button#freebase-loading-cancel").hide();
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
FreebaseLoadingDialog.prototype._dismiss = function() {
|
||||
|
@ -56,27 +56,7 @@
|
||||
|
||||
return window.open(url, windowname || "", params_list.join(","));
|
||||
},
|
||||
|
||||
block : function() {
|
||||
if ($.blockUI) {
|
||||
$.blockUI({ css: {
|
||||
border: 'none',
|
||||
padding: '15px',
|
||||
backgroundColor: '#000',
|
||||
'-webkit-border-radius': '10px',
|
||||
'-moz-border-radius': '10px',
|
||||
opacity: .5,
|
||||
color: '#fff'
|
||||
} });
|
||||
}
|
||||
},
|
||||
|
||||
unblock : function() {
|
||||
if ($.unblockUI) {
|
||||
$.unblockUI();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
signintize : function(cont) {
|
||||
$('.signedin').show();
|
||||
$('.signedout').hide();
|
||||
@ -87,33 +67,31 @@
|
||||
},
|
||||
|
||||
signin : function(success, provider, width, height) {
|
||||
var newwin = window.Sign.popup("/command/authorize?" + $.param({ "provider" : provider}), width, height);
|
||||
var newwin = window.Sign.popup("/command/authorize/" + provider, width, height);
|
||||
|
||||
console.log(newwin);
|
||||
|
||||
newwin.opener = window;
|
||||
if (newwin !== null) {
|
||||
newwin.opener = window;
|
||||
}
|
||||
|
||||
window.onauthorization = function() {
|
||||
window.Sign.block();
|
||||
if (typeof success == 'undefined') {
|
||||
window.location.reload();
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "/command/check-authorization",
|
||||
url: "/command/check-authorization/" + provider,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
window.user = data;
|
||||
window.Sign.signintize(success);
|
||||
window.Sign.unblock();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (window.focus) {
|
||||
if (window.focus && newwin !== null) {
|
||||
newwin.focus();
|
||||
console.log("focus");
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
@ -124,17 +102,13 @@
|
||||
},
|
||||
|
||||
signout : function(success,provider) {
|
||||
window.Sign.block();
|
||||
|
||||
$.ajax({
|
||||
url: "/command/deauthorize",
|
||||
data: { "provider" : provider },
|
||||
url: "/command/deauthorize/" + provider,
|
||||
success: function() {
|
||||
if (typeof success == 'undefined') {
|
||||
window.location.reload();
|
||||
} else {
|
||||
window.Sign.signoutize(success);
|
||||
window.Sign.unblock();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,8 +1,34 @@
|
||||
.freebase-loading-tripleloader-data {
|
||||
height: 500px;
|
||||
height: 400px;
|
||||
width: 99%;
|
||||
overflow: auto;
|
||||
border: 1px solid #aaa;
|
||||
white-space: pre;
|
||||
padding: 0.3em 0.5em 0.5em 0.5em;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.freebase-loading-tripleloader-message {
|
||||
height: 500px;
|
||||
overflow: auto;
|
||||
border: 1px solid #aaa;
|
||||
padding: 0.3em 0.5em 0.5em 0.5em;
|
||||
}
|
||||
|
||||
.freebase-loading-authorization {
|
||||
margin: 0em 2em;
|
||||
padding: 0.6em 0.8em;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
-moz-border-radius: 0.8em;
|
||||
-webkit-border-radius: 0.8em;
|
||||
}
|
||||
|
||||
.freebase-loading-tripleloader-info {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.freebase-loading-tripleloader-info textarea {
|
||||
width: 99%;
|
||||
height: 5em;
|
||||
}
|
@ -20,18 +20,15 @@ import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import org.apache.log4j.Appender;
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.bio.SocketConnector;
|
||||
import org.mortbay.jetty.webapp.WebAppContext;
|
||||
import org.mortbay.log.Log;
|
||||
import org.mortbay.util.Scanner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.metaweb.util.logging.IndentingLayout;
|
||||
import com.metaweb.util.signal.AbstractSignalHandler;
|
||||
import com.metaweb.util.threads.ThreadPoolExecutorAdapter;
|
||||
|
||||
@ -45,29 +42,8 @@ public class Gridworks {
|
||||
static private File tempDir;
|
||||
static private int port;
|
||||
static private String host;
|
||||
|
||||
private static Logger root = Logger.getRootLogger();
|
||||
private static Logger logger = Logger.getLogger("com.metaweb.gridworks");
|
||||
|
||||
public static void log(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public static void info(String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public static void error(String message, Throwable t) {
|
||||
logger.error(message, t);
|
||||
}
|
||||
|
||||
public static void warn(String message) {
|
||||
logger.warn(message);
|
||||
}
|
||||
|
||||
public static void warn(String message, Throwable t) {
|
||||
logger.warn(message, t);
|
||||
}
|
||||
final static Logger logger = LoggerFactory.getLogger("gridworks");
|
||||
|
||||
public static String getVersion() {
|
||||
return VERSION;
|
||||
@ -100,20 +76,15 @@ public class Gridworks {
|
||||
System.setProperty("com.apple.eawt.CocoaComponent.CompatibilityMode", "false");
|
||||
|
||||
// tell the signpost library to log
|
||||
System.setProperty("debug","true");
|
||||
//System.setProperty("debug","true");
|
||||
|
||||
// if not already set, make sure jython can find its python stuff
|
||||
if (System.getProperty("python.path") == null) {
|
||||
System.setProperty("python.path","lib/python");
|
||||
}
|
||||
|
||||
// initialize the log4j system
|
||||
Appender console = new ConsoleAppender(new IndentingLayout());
|
||||
root.setLevel(Level.ALL);
|
||||
root.addAppender(console);
|
||||
|
||||
Logger jetty_logger = Logger.getLogger("org.mortbay.log");
|
||||
jetty_logger.setLevel(Level.WARN);
|
||||
// set the log verbosity level
|
||||
org.apache.log4j.Logger.getRootLogger().setLevel(Level.toLevel(Configurations.get("gridworks.verbosity","info")));
|
||||
|
||||
tempDir = new File(Configurations.get("gridworks.temp","temp"));
|
||||
if (!tempDir.exists()) tempDir.mkdirs();
|
||||
@ -137,7 +108,7 @@ public class Gridworks {
|
||||
GridworksClient client = new GridworksClient();
|
||||
client.init(host,port);
|
||||
} catch (Exception e) {
|
||||
Log.warn("Sorry, some error prevented us from launching the browser for you.\n\n Point your browser to http://" + host + ":" + port + "/ to start using Gridworks.");
|
||||
logger.warn("Sorry, some error prevented us from launching the browser for you.\n\n Point your browser to http://" + host + ":" + port + "/ to start using Gridworks.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +123,8 @@ public class Gridworks {
|
||||
|
||||
class GridworksServer extends Server {
|
||||
|
||||
final static Logger logger = LoggerFactory.getLogger("gridworks_server");
|
||||
|
||||
private ThreadPoolExecutor threadPool;
|
||||
|
||||
public void init(String host, int port) throws Exception {
|
||||
@ -177,11 +150,11 @@ class GridworksServer extends Server {
|
||||
|
||||
File webXml = new File(contextRoot, "WEB-INF/web.xml");
|
||||
if (!webXml.isFile()) {
|
||||
Gridworks.warn("Warning: Failed to find web application. Could not find 'web.xml' at '" + webXml.getAbsolutePath() + "'");
|
||||
logger.warn("Warning: Failed to find web application. Could not find 'web.xml' at '" + webXml.getAbsolutePath() + "'");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Gridworks.info("Initializing context: '" + contextPath + "' from '" + contextRoot.getAbsolutePath() + "'");
|
||||
logger.info("Initializing context: '" + contextPath + "' from '" + contextRoot.getAbsolutePath() + "'");
|
||||
WebAppContext context = new WebAppContext(contextRoot.getAbsolutePath(), contextPath);
|
||||
//context.setCopyWebDir(false);
|
||||
//context.setDefaultsDescriptor(null);
|
||||
@ -217,7 +190,7 @@ class GridworksServer extends Server {
|
||||
scanList.add(new File(contextRoot, "WEB-INF/web.xml"));
|
||||
findFiles(".class", new File(contextRoot, "WEB-INF/classes"), scanList);
|
||||
|
||||
Gridworks.info("Starting autoreloading scanner... ");
|
||||
logger.info("Starting autoreloading scanner... ");
|
||||
|
||||
Scanner scanner = new Scanner();
|
||||
scanner.setScanInterval(Configurations.getInteger("gridworks.scanner.period",1));
|
||||
@ -228,10 +201,10 @@ class GridworksServer extends Server {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void filesChanged(List changedFiles) {
|
||||
try {
|
||||
Gridworks.info("Stopping context: " + contextRoot.getAbsolutePath());
|
||||
logger.info("Stopping context: " + contextRoot.getAbsolutePath());
|
||||
context.stop();
|
||||
|
||||
Gridworks.info("Starting context: " + contextRoot.getAbsolutePath());
|
||||
logger.info("Starting context: " + contextRoot.getAbsolutePath());
|
||||
context.start();
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
Loading…
Reference in New Issue
Block a user