You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2014/10/15 20:42:19 UTC
[42/51] [partial] added missing querybuilder code.
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src-dev/dev/RunFuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src-dev/dev/RunFuseki.java b/jena-fuseki/src-dev/dev/RunFuseki.java
deleted file mode 100644
index 74f678c..0000000
--- a/jena-fuseki/src-dev/dev/RunFuseki.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package dev;
-
-import org.apache.jena.fuseki.FusekiCmd ;
-
-public class RunFuseki
-{
- public static void main(String[] args)
- {
- //demo() ;
- //FusekiCmd.main("--config=config.ttl") ; System.exit(0) ;
- main1() ;
- }
-
- public static void demo()
- {
- String DIR="DemoServer" ;
- FusekiCmd.main("--config="+name(DIR,"config.ttl"), "--pages="+name(DIR, "demo-pages")) ;
- System.exit(0) ;
- }
-
- public static String name(String DIR, String filename)
- {
- StringBuilder sb = new StringBuilder() ;
- if ( ! filename.startsWith("/") )
- {
- sb.append(DIR) ;
- if ( ! DIR.endsWith("/") )
- sb.append("/") ;
- }
- sb.append(filename) ;
- return sb.toString() ;
- }
-
- private static void main1()
- {
- String tmpdir = System.getenv("TMPDIR") ;
- if ( tmpdir == null )
- tmpdir = System.getenv("TMP") ;
- if ( tmpdir == null )
- tmpdir = System.getenv("HOME")+"/tmp" ;
- if ( ! tmpdir.endsWith("/") )
- tmpdir = tmpdir+"/" ;
-
- FusekiCmd.main(
- // "-v",
- "--mem", "--update", "/ds"
- //"--update", "--loc="+tmpdir+"DB", "--set=tdb:unionDefaultGraph=true", "/ds"
- //"--update", "--mem", "/ds"
-
- //"--update", "--memtdb", "--set=tdb:unionDefaultGraph=true", "/ds"
-
- //"--debug",
- //"--update",
- //"--timeout=1000,5000",
- //"--set=arq:queryTimeout=1000",
- //"--port=3030",
- //"--mgtPort=3031",
- //"--mem",
- //"--home=/home/afs/Projects/Fuseki",
- //"--loc=DB",
- //"--file=D.nt",
- //"--gzip=no",
- //"--desc=desc.ttl",
- //--pages=
- //"--jetty-config=jetty-fuseki.xml",
- //"--config=config-tdb.ttl"
- // "/ds"
- ) ;
- System.exit(0) ;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/DEF.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/DEF.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/DEF.java
deleted file mode 100644
index c24f7e3..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/DEF.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import static org.apache.jena.riot.WebContent.* ;
-import org.apache.jena.atlas.web.AcceptList ;
-import org.apache.jena.atlas.web.MediaType ;
-
-public class DEF
-{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML) ;
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads) ;
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML) ;
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeTurtleAlt2,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- ) ;
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeTriGAlt2,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeNQuadsAlt2
- ) ;
-
- public static final AcceptList rsOfferTable = AcceptList.create(contentTypeResultsJSON,
- contentTypeTextCSV,
- contentTypeTextTSV,
- contentTypeResultsXML,
- contentTypeResultsThrift,
- contentTypeTextPlain
- ) ;
-
- public static final AcceptList rsOfferBoolean = AcceptList.create(contentTypeResultsJSON,
- contentTypeTextCSV,
- contentTypeTextTSV,
- contentTypeResultsXML,
- contentTypeTextPlain
- ) ;
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/EmbeddedFusekiServer.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/EmbeddedFusekiServer.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/EmbeddedFusekiServer.java
deleted file mode 100644
index 0261b67..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/EmbeddedFusekiServer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.fuseki.server.FusekiConfig ;
-import org.apache.jena.fuseki.server.SPARQLServer ;
-import org.apache.jena.fuseki.server.ServerConfig ;
-
-import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.sparql.core.DatasetGraphFactory ;
-import com.hp.hpl.jena.tdb.TDBFactory ;
-
-/** Embedded (same JVM) server.
- * <p>Example for one server per test suite:
- * <pre>
- private static EmbeddedFusekiServer server = null ;
- \@BeforeClass public static void beforeClass() {
- server = EmbeddedFusekiServer.createMemByPath(3030, "/test") ;
- server.start() ;
- \@AfterClass public static void afterClass() {
- server.stop() ;
- }
- </pre>
- */
-public class EmbeddedFusekiServer
-{
-
- public static EmbeddedFusekiServer mem(int port, String datasetPath) {
- DatasetGraph dsg = DatasetGraphFactory.createMem() ;
- return EmbeddedFusekiServer.create(port, dsg, datasetPath) ;
- }
-
- public static EmbeddedFusekiServer memTDB(int port, String datasetPath) {
- DatasetGraph dsg = TDBFactory.createDatasetGraph() ;
- return EmbeddedFusekiServer.create(port, dsg, datasetPath) ;
- }
-
- public static EmbeddedFusekiServer create(int port, DatasetGraph dsg, String datasetPath) {
- ServerConfig conf = FusekiConfig.defaultConfiguration(datasetPath, dsg, true, true) ;
- conf.port = port ;
- conf.pagesPort = port ;
- if ( ! FileOps.exists(conf.pages) )
- conf.pages = null ;
- return new EmbeddedFusekiServer(conf) ;
- }
-
- public static EmbeddedFusekiServer configure(int port, String fileConfig) {
- ServerConfig conf = FusekiConfig.configure(fileConfig) ;
- conf.port = port ;
- conf.pagesPort = port ;
- if ( ! FileOps.exists(conf.pages) )
- conf.pages = null ;
- return new EmbeddedFusekiServer(conf) ;
- }
-
- private SPARQLServer server = null ;
-
- public EmbeddedFusekiServer(ServerConfig conf) {
- server = new SPARQLServer(conf) ;
- }
-
- public void start() {
- server.start() ;
- }
-
- public void stop() {
- server.stop() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java
deleted file mode 100644
index c62ba1f..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.fuseki.server.SPARQLServer ;
-import org.apache.jena.riot.RIOT ;
-import org.apache.jena.riot.system.stream.LocatorFTP ;
-import org.apache.jena.riot.system.stream.LocatorHTTP ;
-import org.apache.jena.riot.system.stream.StreamManager ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-import com.hp.hpl.jena.query.ARQ ;
-import com.hp.hpl.jena.sparql.SystemARQ ;
-import com.hp.hpl.jena.sparql.lib.Metadata ;
-import com.hp.hpl.jena.sparql.mgt.SystemInfo ;
-import com.hp.hpl.jena.sparql.util.Context ;
-import com.hp.hpl.jena.sparql.util.MappingRegistry ;
-import com.hp.hpl.jena.tdb.TDB ;
-import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
-
-/**
- * <p>The main class enabling us to:</p>
- * <ol>
- * <li>create instances of a Fuseki server e.g.
- * the ARQ, RIOT and TDB server stack</li>
- * <li>get server global {@link com.hp.hpl.jena.sparql.util.Context} e.g.
- * named values used to pass implementation-specific parameters across
- * general interfaces.</li>
- * <li>get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.</li>
- * <li>set the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.</li>
- *
- */
-public class Fuseki
-{
- /** Path to ???*/
- static public String PATH = "org.apache.jena.fuseki" ;
-
- /** a unique IRI for the Fuseki namespace*/
- static public String FusekiIRI = "http://jena.apache.org/Fuseki" ;
-
- /** Fuseki home environment, usually set to $FUSEKI_HOME */
- static public String FusekiHomeEnv = "FUSEKI_HOME" ;
-
- /** a unique IRI including the symbol notation for which properties should be appended */
- static public String FusekiSymbolIRI = "http://jena.apache.org/fuseki#" ;
-
- /** ??? */
- static public String PagesStatic = "pages" ;
-
- /**
- * TEMPORARY - this enables POST of triples to the dataset URI causing a graph to be created.
- * POSTing to /dataset?graph=uri is preferred
- */
- static public boolean graphStoreProtocolPostCreate = false ;
-
- /** an relative path to the location of <code>fuseki-properties.xml</code> file */
- static private String metadataLocation = "org/apache/jena/fuseki/fuseki-properties.xml" ;
-
- /** Object which holds metadata specified within {@link Fuseki#metadataLocation} */
- static private Metadata metadata = initMetadata() ;
-
- private static Metadata initMetadata()
- {
- Metadata m = new Metadata() ;
- //m.addMetadata(metadataDevLocation) ;
- m.addMetadata(metadataLocation) ;
- return m ;
- }
-
- /** The name of the Fuseki server. Set to the string <code>Fuseki</code> by default.*/
- static public final String NAME = "Fuseki" ;
-
- /** Version of this Fuseki instance */
- static public final String VERSION = metadata.get(PATH+".version", "development");
-
- /** Date when Fuseki was built */
- static public final String BUILD_DATE = metadata.get(PATH+".build.datetime", "unknown") ; // call Date if unavailable.
-
- /** An identifier for the HTTP Fuseki server instance*/
- static public final String serverHttpName = NAME+" ("+VERSION+")" ;
-
- /** Actual log file for operations */
- public static final String requestLogName = PATH+".Fuseki" ;
-
- /** Instance of log for operations */
- public static final Logger requestLog = LoggerFactory.getLogger(requestLogName) ;
-
- /** Actual log file for general server messages.*/
- public static final String serverLogName = PATH+".Server" ;
-
- /** Instance of log for general server messages */
- public static final Logger serverLog = LoggerFactory.getLogger(serverLogName) ;
-
- /** Actual log file for config server messages. */
- public static final String configLogName = PATH+".Config" ;
-
- /** Instance of log for config server message s*/
- public static final Logger configLog = LoggerFactory.getLogger(configLogName) ;
-
- /** Instance of log for config server message s*/
- public static boolean verboseLogging = false ;
-
- /** An instance of management for stream opening, including redirecting through a
- * location mapper whereby a name (e.g. URL) is redirected to another name (e.g. local file).
- * */
- public static final StreamManager webStreamManager ;
- static {
- webStreamManager = new StreamManager() ;
- // Only know how to handle http and ftp URLs - nothing local.
- webStreamManager.addLocator(new LocatorHTTP()) ;
- webStreamManager.addLocator(new LocatorFTP()) ;
- }
-
- private static boolean initialized = false ;
-
- /**
- * Initialize an instance of the Fuseki server stack.
- */
- public synchronized static void init()
- {
- if ( initialized )
- return ;
- initialized = true ;
- ARQ.init() ;
- SystemInfo sysInfo = new SystemInfo(FusekiIRI, PATH, VERSION, BUILD_DATE) ;
- SystemARQ.registerSubSystem(sysInfo) ;
- RIOT.init() ;
- TDB.init() ;
- MappingRegistry.addPrefixMapping("fuseki", FusekiSymbolIRI) ;
-
- TDB.setOptimizerWarningFlag(false) ;
- // Don't set TDB batch commits.
- // This can be slower, but it less memory hungry and more predictable.
- TransactionManager.QueueBatchSize = 0 ;
- }
-
- /**
- * Get server global {@link com.hp.hpl.jena.sparql.util.Context}.
- * @return {@link com.hp.hpl.jena.query.ARQ#getContext()}
- */
- public static Context getContext()
- {
- return ARQ.getContext() ;
- }
-
- // Temporary ...
- private static SPARQLServer server ;
-
- /** set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.*/
- public static void setServer(SPARQLServer _server) { server = _server ; }
-
- /** get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance. */
- public static SPARQLServer getServer() { return server ; }
-
- // Force a call to init.
- static { init() ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
deleted file mode 100644
index b076871..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import static org.apache.jena.fuseki.Fuseki.serverLog ;
-
-import java.io.File ;
-import java.io.InputStream ;
-import java.util.List ;
-
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.lib.Lib ;
-import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.atlas.logging.LogCtl ;
-import org.apache.jena.fuseki.mgt.ManagementServer ;
-import org.apache.jena.fuseki.server.FusekiConfig ;
-import org.apache.jena.fuseki.server.SPARQLServer ;
-import org.apache.jena.fuseki.server.ServerConfig ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.riot.SysRIOT ;
-import org.eclipse.jetty.server.Server ;
-import org.slf4j.Logger ;
-import arq.cmd.CmdException ;
-import arq.cmdline.ArgDecl ;
-import arq.cmdline.CmdARQ ;
-import arq.cmdline.ModDatasetAssembler ;
-
-import com.hp.hpl.jena.query.ARQ ;
-import com.hp.hpl.jena.query.Dataset ;
-import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.sparql.core.DatasetGraphFactory ;
-import com.hp.hpl.jena.tdb.TDB ;
-import com.hp.hpl.jena.tdb.TDBFactory ;
-import com.hp.hpl.jena.tdb.sys.Names ;
-import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
-
-public class FusekiCmd extends CmdARQ
-{
- private static String log4Jsetup = StrUtils.strjoinNL(
- "## Plain output to stdout"
- , "log4j.appender.jena.plain=org.apache.log4j.ConsoleAppender"
- , "log4j.appender.jena.plain.target=System.out"
- , "log4j.appender.jena.plain.layout=org.apache.log4j.PatternLayout"
- , "log4j.appender.jena.plain.layout.ConversionPattern=%d{HH:mm:ss} %-5p %m%n"
-
- , "## Plain output with level, to stderr"
- , "log4j.appender.jena.plainlevel=org.apache.log4j.ConsoleAppender"
- , "log4j.appender.jena.plainlevel.target=System.err"
- , "log4j.appender.jena.plainlevel.layout=org.apache.log4j.PatternLayout"
- , "log4j.appender.jena.plainlevel.layout.ConversionPattern=%d{HH:mm:ss} %-5p %m%n"
-
- , "## Everything"
- , "log4j.rootLogger=INFO, jena.plain"
- , "log4j.logger.com.hp.hpl.jena=WARN"
- , "log4j.logger.org.openjena=WARN"
- , "log4j.logger.org.apache.jena=WARN"
-
- , "# Server log."
- , "log4j.logger.org.apache.jena.fuseki.Server=INFO"
- , "# Request log."
- , "log4j.logger.org.apache.jena.fuseki.Fuseki=INFO"
- , "log4j.logger.org.apache.jena.tdb.loader=INFO"
- , "log4j.logger.org.eclipse.jetty=ERROR"
-
- , "## Parser output"
- , "log4j.additivity."+SysRIOT.riotLoggerName+"=false"
- , "log4j.logger."+SysRIOT.riotLoggerName+"=INFO, jena.plainlevel "
- ) ;
-
-
- // Set logging.
- // 1/ Use log4j.configuration is defined.
- // 2/ Use file:log4j.properties
- // 3/ Use Built in.
-
- static void setLogging() {
- // No loggers have been created but configuration may have been set up.
- String x = System.getProperty("log4j.configuration", null) ;
-
- if ( x != null && ! x.equals("set") ) {
- // "set" indicates that CmdMain set logging.
- // Use standard log4j initialization.
- return ;
- }
-
- String fn = "log4j.properties" ;
- File f = new File(fn) ;
- if ( f.exists() ) {
- System.out.println("File") ;
- // Use file log4j.properties
- System.setProperty("log4j.configuration", "file:"+fn) ;
- return ;
- }
- // Use built-in for Fuseki.
- LogCtl.resetLogging(log4Jsetup) ;
- }
-
- static { setLogging() ; }
-
- // Arguments:
- // --update
-
- // Specific switches:
-
- // --admin=on/off
-
- // --http-update
- // --http-get
-
- // --sparql-query
- // --sparql-update
-
- // pages/validators/
- // pages/control/
- // pages/query/ or /pages/sparql/
-
- private static ArgDecl argMgtPort = new ArgDecl(ArgDecl.HasValue, "mgtPort", "mgtport") ;
- private static ArgDecl argMem = new ArgDecl(ArgDecl.NoValue, "mem") ;
- private static ArgDecl argAllowUpdate = new ArgDecl(ArgDecl.NoValue, "update", "allowUpdate") ;
- private static ArgDecl argFile = new ArgDecl(ArgDecl.HasValue, "file") ;
- private static ArgDecl argMemTDB = new ArgDecl(ArgDecl.NoValue, "memtdb", "memTDB") ;
- private static ArgDecl argTDB = new ArgDecl(ArgDecl.HasValue, "loc", "location") ;
- private static ArgDecl argPort = new ArgDecl(ArgDecl.HasValue, "port") ;
- private static ArgDecl argLocalhost = new ArgDecl(ArgDecl.NoValue, "localhost", "local") ;
- private static ArgDecl argTimeout = new ArgDecl(ArgDecl.HasValue, "timeout") ;
- private static ArgDecl argFusekiConfig = new ArgDecl(ArgDecl.HasValue, "config", "conf") ;
- private static ArgDecl argJettyConfig = new ArgDecl(ArgDecl.HasValue, "jetty-config") ;
- private static ArgDecl argGZip = new ArgDecl(ArgDecl.HasValue, "gzip") ;
- private static ArgDecl argUber = new ArgDecl(ArgDecl.NoValue, "uber", "über") ; // Use the überservlet (experimental)
- private static ArgDecl argBasicAuth = new ArgDecl(ArgDecl.HasValue, "basic-auth") ;
-
- private static ArgDecl argGSP = new ArgDecl(ArgDecl.NoValue, "gsp") ; // GSP compliance mode
-
- private static ArgDecl argHome = new ArgDecl(ArgDecl.HasValue, "home") ;
- private static ArgDecl argPages = new ArgDecl(ArgDecl.HasValue, "pages") ;
-
- //private static ModLocation modLocation = new ModLocation() ;
- private static ModDatasetAssembler modDataset = new ModDatasetAssembler() ;
-
- // fuseki [--mem|--desc assembler.ttl] [--port PORT] **** /datasetURI
-
- static public void main(String...argv)
- {
- // Just to make sure ...
- ARQ.init() ;
- TDB.init() ;
- Fuseki.init() ;
- new FusekiCmd(argv).mainRun() ;
- }
-
- private int port = 3030 ;
- private int mgtPort = -1 ;
- private boolean listenLocal = false ;
-
- private DatasetGraph dsg = null ;
- private String datasetPath = null ;
- private boolean allowUpdate = false ;
-
- private String fusekiConfigFile = null ;
- private boolean enableCompression = true ;
- private String jettyConfigFile = null ;
- private String authConfigFile = null ;
- private String homeDir = null ;
- private String pagesDir = null ;
-
- public FusekiCmd(String...argv)
- {
- super(argv) ;
-
- if ( false )
- // Consider ...
- TransactionManager.QueueBatchSize = TransactionManager.QueueBatchSize / 2 ;
-
- getUsage().startCategory("Fuseki") ;
- addModule(modDataset) ;
- add(argMem, "--mem", "Create an in-memory, non-persistent dataset for the server") ;
- add(argFile, "--file=FILE", "Create an in-memory, non-persistent dataset for the server, initialised with the contents of the file") ;
- add(argTDB, "--loc=DIR", "Use an existing TDB database (or create if does not exist)") ;
- add(argMemTDB, "--memTDB", "Create an in-memory, non-persistent dataset using TDB (testing only)") ;
- add(argPort, "--port", "Listen on this port number") ;
- add(argPages, "--pages=DIR", "Set of pages to serve as static content") ;
- // Set via jetty config file.
- add(argLocalhost, "--localhost", "Listen only on the localhost interface") ;
- add(argTimeout, "--timeout=", "Global timeout applied to queries (value in ms) -- format is X[,Y] ") ;
- add(argAllowUpdate, "--update", "Allow updates (via SPARQL Update and SPARQL HTTP Update)") ;
- add(argFusekiConfig, "--config=", "Use a configuration file to determine the services") ;
- add(argJettyConfig, "--jetty-config=FILE", "Set up the server (not services) with a Jetty XML file") ;
- add(argBasicAuth, "--basic-auth=FILE", "Configure basic auth using provided Jetty realm file, ignored if --jetty-config is used") ;
- add(argMgtPort, "--mgtPort=port", "Enable the management commands on the given port") ;
- add(argHome, "--home=DIR", "Root of Fuseki installation (overrides environment variable FUSEKI_HOME)") ;
- add(argGZip, "--gzip=on|off", "Enable GZip compression (HTTP Accept-Encoding) if request header set") ;
-
- add(argUber) ;
- //add(argGSP) ;
-
- super.modVersion.addClass(TDB.class) ;
- super.modVersion.addClass(Fuseki.class) ;
- }
-
- static String argUsage = "[--config=FILE] [--mem|--desc=AssemblerFile|--file=FILE] [--port PORT] /DatasetPathName" ;
-
- @Override
- protected String getSummary()
- {
- return getCommandName()+" "+argUsage ;
- }
-
- @Override
- protected void processModulesAndArgs()
- {
- int x = 0 ;
-
- Logger log = Fuseki.serverLog ;
-
- if ( contains(argFusekiConfig) )
- fusekiConfigFile = getValue(argFusekiConfig) ;
-
- ArgDecl assemblerDescDecl = new ArgDecl(ArgDecl.HasValue, "desc", "dataset") ;
- if ( contains(argMem) ) x++ ;
- if ( contains(argFile) ) x++ ;
- if ( contains(assemblerDescDecl) ) x++ ;
- if ( contains(argTDB) ) x++ ;
- if ( contains(argMemTDB) ) x++ ;
-
- if ( fusekiConfigFile != null )
- {
- if ( x > 1 )
- throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
- }
- else
- {
- if ( x == 0 )
- throw new CmdException("Required: either --config=FILE or one of --mem, --file, --loc or --desc") ;
- }
-
- if ( contains(argMem) )
- {
- log.info("Dataset: in-memory") ;
- dsg = DatasetGraphFactory.createMem() ;
- }
- if ( contains(argFile) )
- {
- dsg = DatasetGraphFactory.createMem() ;
- // replace by RiotLoader after ARQ refresh.
- String filename = getValue(argFile) ;
- log.info("Dataset: in-memory: load file: "+filename) ;
- if ( ! FileOps.exists(filename) )
- throw new CmdException("File not found: "+filename) ;
-
- Lang language = RDFLanguages.filenameToLang(filename) ;
- if ( language == null )
- throw new CmdException("Can't guess language for file: "+filename) ;
- InputStream input = IO.openFile(filename) ;
-
- if ( RDFLanguages.isQuads(language) )
- RDFDataMgr.read(dsg, filename) ;
- else
- RDFDataMgr.read(dsg.getDefaultGraph(), filename) ;
- }
-
- if ( contains(argMemTDB) )
- {
- log.info("TDB dataset: in-memory") ;
- dsg = TDBFactory.createDatasetGraph() ;
- }
-
- if ( contains(argTDB) )
- {
- String dir = getValue(argTDB) ;
-
- if ( Lib.equal(dir, Names.memName) ) {
- log.info("TDB dataset: in-memory") ;
- } else {
- if ( ! FileOps.exists(dir) )
- throw new CmdException("Directory not found: "+dir) ;
- log.info("TDB dataset: directory="+dir) ;
- }
- dsg = TDBFactory.createDatasetGraph(dir) ;
- }
-
- // Otherwise
- if ( contains(assemblerDescDecl) )
- {
- log.info("Dataset from assembler") ;
- Dataset ds = modDataset.createDataset() ;
- if ( ds != null )
- dsg = ds.asDatasetGraph() ;
- }
-
- if ( contains(argFusekiConfig) )
- {
- if ( dsg != null )
- throw new CmdException("Dataset specificed on the command line and also a configuration file specificed.") ;
- fusekiConfigFile = getValue(argFusekiConfig) ;
- }
-
- if ( contains(argPort) )
- {
- String portStr = getValue(argPort) ;
- try {
- port = Integer.parseInt(portStr) ;
- } catch (NumberFormatException ex)
- {
- throw new CmdException(argPort.getKeyName()+" : bad port number: "+portStr) ;
- }
- }
-
- if ( contains(argMgtPort) )
- {
- String mgtPortStr = getValue(argMgtPort) ;
- try {
- mgtPort = Integer.parseInt(mgtPortStr) ;
- } catch (NumberFormatException ex)
- {
- throw new CmdException(argMgtPort.getKeyName()+" : bad port number: "+mgtPortStr) ;
- }
- }
-
- if ( contains(argLocalhost) )
- listenLocal = true ;
-
- if ( fusekiConfigFile == null && dsg == null )
- throw new CmdException("No dataset defined and no configuration file: "+argUsage) ;
-
- if ( dsg != null )
- {
- if ( getPositional().size() == 0 )
- throw new CmdException("No dataset path name given") ;
- if ( getPositional().size() > 1 )
- throw new CmdException("Multiple dataset path names given") ;
- datasetPath = getPositionalArg(0) ;
- if ( datasetPath.length() > 0 && ! datasetPath.startsWith("/") )
- throw new CmdException("Dataset path name must begin with a /: "+datasetPath) ;
-
- allowUpdate = contains(argAllowUpdate) ;
- }
-
- if ( contains(argTimeout) )
- {
- String str = getValue(argTimeout) ;
- ARQ.getContext().set(ARQ.queryTimeout, str) ;
- }
-
- if ( contains(argJettyConfig) )
- {
- jettyConfigFile = getValue(argJettyConfig) ;
- if ( !FileOps.exists(jettyConfigFile) )
- throw new CmdException("No such file: "+jettyConfigFile) ;
- }
-
- if ( contains(argBasicAuth) )
- {
- authConfigFile = getValue(argBasicAuth) ;
- if ( !FileOps.exists(authConfigFile) )
- throw new CmdException("No such file: " + authConfigFile) ;
- }
-
- if ( contains(argHome) )
- {
- List<String> args = super.getValues(argHome) ;
- homeDir = args.get(args.size()-1) ;
- }
-
- if ( contains(argPages) )
- {
- List<String> args = super.getValues(argPages) ;
- pagesDir = args.get(args.size()-1) ;
- }
-
- if ( contains(argGZip) )
- {
- if ( ! hasValueOfTrue(argGZip) && ! hasValueOfFalse(argGZip) )
- throw new CmdException(argGZip.getNames().get(0)+": Not understood: "+getValue(argGZip)) ;
- enableCompression = super.hasValueOfTrue(argGZip) ;
- }
-
- if ( contains(argUber) )
- SPARQLServer.überServlet = true ;
-
- if ( contains(argGSP) )
- {
- SPARQLServer.überServlet = true ;
- Fuseki.graphStoreProtocolPostCreate = true ;
- }
-
- }
-
- private static String sort_out_dir(String path)
- {
- path.replace('\\', '/') ;
- if ( ! path.endsWith("/"))
- path = path +"/" ;
- return path ;
- }
-
- @Override
- protected void exec()
- {
- if ( homeDir == null )
- {
- if ( System.getenv(Fuseki.FusekiHomeEnv) != null )
- homeDir = System.getenv(Fuseki.FusekiHomeEnv) ;
- else
- homeDir = "." ;
- }
-
- homeDir = sort_out_dir(homeDir) ;
- Fuseki.configLog.info("Home Directory: " + FileOps.fullDirectoryPath(homeDir));
- if ( ! FileOps.exists(homeDir) )
- Fuseki.configLog.warn("No such directory for Fuseki home: "+homeDir) ;
-
- String staticContentDir = pagesDir ;
- if ( staticContentDir == null )
- staticContentDir = homeDir+Fuseki.PagesStatic ;
-
- Fuseki.configLog.debug("Static Content Directory: "+ FileOps.fullDirectoryPath(staticContentDir)) ;
-
- if ( ! FileOps.exists(staticContentDir) ) {
- Fuseki.configLog.warn("No such directory for static content: " + FileOps.fullDirectoryPath(staticContentDir)) ;
- Fuseki.configLog.warn("You may need to set the --pages or --home option to configure static content correctly");
- }
-
- if ( jettyConfigFile != null )
- Fuseki.configLog.info("Jetty configuration: "+jettyConfigFile) ;
-
- ServerConfig serverConfig ;
-
- if ( fusekiConfigFile != null )
- {
- Fuseki.configLog.info("Configuration file: "+fusekiConfigFile) ;
- serverConfig = FusekiConfig.configure(fusekiConfigFile) ;
- }
- else
- {
- serverConfig = FusekiConfig.defaultConfiguration(datasetPath, dsg, allowUpdate, listenLocal) ;
- if ( ! allowUpdate )
- Fuseki.serverLog.info("Running in read-only mode.");
- }
-
- // TODO Get from parsing config file.
- serverConfig.port = port ;
- serverConfig.pages = staticContentDir ;
- serverConfig.mgtPort = mgtPort ;
- serverConfig.pagesPort = port ;
- serverConfig.loopback = listenLocal ;
- serverConfig.enableCompression = enableCompression ;
- serverConfig.jettyConfigFile = jettyConfigFile ;
- serverConfig.authConfigFile = authConfigFile ;
- serverConfig.verboseLogging = ( super.isVerbose() || super.isDebug() ) ;
-
- SPARQLServer server = new SPARQLServer(serverConfig) ;
-
- // Temporary
- Fuseki.setServer(server) ;
-
- Server mgtServer = null ;
-
- if ( mgtPort > 0 )
- {
- Fuseki.configLog.info("Management services on port "+mgtPort) ;
- mgtServer = ManagementServer.createManagementServer(mgtPort) ;
- try { mgtServer.start() ; }
- catch (java.net.BindException ex)
- { serverLog.error("SPARQLServer: Failed to start management server: " + ex.getMessage()) ; System.exit(1) ; }
- catch (Exception ex)
- { serverLog.error("SPARQLServer: Failed to start management server: " + ex.getMessage(), ex) ; System.exit(1) ; }
- }
-
- server.start() ;
- try { server.getServer().join() ; } catch (Exception ex) {}
-
- if ( mgtServer != null )
- {
- try { mgtServer.stop() ; }
- catch (Exception e) { serverLog.warn("Failed to cleanly stop the management server", e) ; }
- }
- System.exit(0) ;
- }
-
-
- @Override
- protected String getCommandName()
- {
- return "fuseki" ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiConfigException.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiConfigException.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiConfigException.java
deleted file mode 100644
index 5e1b018..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiConfigException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-
-public class FusekiConfigException extends FusekiException
-{
- public FusekiConfigException(String msg, Throwable cause) { super(msg, cause) ; }
- public FusekiConfigException(String msg) { super(msg) ; }
- public FusekiConfigException(Throwable cause) { super(cause) ; }
- public FusekiConfigException() { super() ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiException.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiException.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiException.java
deleted file mode 100644
index 04953ce..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import com.hp.hpl.jena.sparql.ARQException ;
-
-public class FusekiException extends ARQException
-{
- public FusekiException(String msg, Throwable cause) { super(msg, cause) ; }
- public FusekiException(String msg) { super(msg) ; }
- public FusekiException(Throwable cause) { super(cause) ; }
- public FusekiException() { super() ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiLib.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiLib.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiLib.java
deleted file mode 100644
index 5324793..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiLib.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import java.util.Iterator ;
-
-import javax.servlet.http.HttpServletRequest ;
-
-import org.apache.commons.lang.StringUtils ;
-import org.apache.jena.atlas.lib.MultiMap ;
-import org.apache.jena.atlas.lib.MultiMapToList ;
-import org.apache.jena.atlas.web.ContentType ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFLanguages ;
-
-import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.shared.PrefixMapping ;
-import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.sparql.core.Quad ;
-import com.hp.hpl.jena.sparql.util.Convert ;
-
-public class FusekiLib {
- /** Get the content type of an action or return the default.
- * @param action
- * @return ContentType
- */
- public static ContentType getContentType(HttpAction action) {
- return getContentType(action.request) ;
- }
-
- /** Get the content type of an action or return the default.
- * @param request
- * @return ContentType
- */
- public static ContentType getContentType(HttpServletRequest request) {
- String contentTypeHeader = request.getContentType() ;
- if ( contentTypeHeader == null )
- return null ;
- return ContentType.create(contentTypeHeader) ;
- }
-
- /** Get the incoming Lang based on Content-Type of an action.
- * @param action
- * @param dft Default if no "Content-Type:" found.
- * @return ContentType
- */
- public static Lang getLangFromAction(HttpAction action, Lang dft) {
- String contentTypeHeader = action.request.getContentType() ;
- if ( contentTypeHeader == null )
- return dft ;
- return RDFLanguages.contentTypeToLang(contentTypeHeader) ;
- }
-
- static String fmtRequest(HttpServletRequest request) {
- StringBuilder sbuff = new StringBuilder() ;
- sbuff.append(request.getMethod()) ;
- sbuff.append(" ") ;
- sbuff.append(Convert.decWWWForm(request.getRequestURL())) ;
-
- String qs = request.getQueryString() ;
- if ( qs != null ) {
- String tmp = request.getQueryString() ;
- tmp = Convert.decWWWForm(tmp) ;
- tmp = tmp.replace('\n', ' ') ;
- tmp = tmp.replace('\r', ' ') ;
- sbuff.append("?").append(tmp) ;
- }
- return sbuff.toString() ;
- }
-
- /** Parse the query string - do not process the body even for a form */
- public static MultiMap<String, String> parseQueryString(HttpServletRequest req) {
- MultiMap<String, String> map = MultiMapToList.create() ;
-
- // Don't use ServletRequest.getParameter or getParamterNames
- // as that reads form data. This code parses just the query string.
- if ( req.getQueryString() != null ) {
- String[] params = req.getQueryString().split("&") ;
- for ( String p : params )
- {
- String[] x = p.split( "=", 2 );
- String name = null;
- String value = null;
-
- if ( x.length == 0 )
- { // No "="
- name = p;
- value = "";
- }
- else if ( x.length == 1 )
- { // param=
- name = x[0];
- value = "";
- }
- else
- { // param=value
- name = x[0];
- value = x[1];
- }
- map.put( name, value );
- }
- }
- return map ;
- }
-
- public static String safeParameter(HttpServletRequest request, String pName) {
- String value = request.getParameter(pName) ;
- value = StringUtils.replaceChars(value, "\r", "") ;
- value = StringUtils.replaceChars(value, "\n", "") ;
- return value ;
- }
-
- // Do the addition directly on the dataset
- public static void addDataInto(Graph data, DatasetGraph dsg, Node graphName) {
- // Prefixes?
- if ( graphName == null )
- graphName = Quad.defaultGraphNodeGenerated ;
-
- Iterator<Triple> iter = data.find(Node.ANY, Node.ANY, Node.ANY) ;
- for (; iter.hasNext();) {
- Triple t = iter.next() ;
- dsg.add(graphName, t.getSubject(), t.getPredicate(), t.getObject()) ;
- }
-
- PrefixMapping pmapSrc = data.getPrefixMapping() ;
- PrefixMapping pmapDest = dsg.getDefaultGraph().getPrefixMapping() ;
- pmapDest.setNsPrefixes(pmapSrc) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiNotFoundException.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiNotFoundException.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiNotFoundException.java
deleted file mode 100644
index be9be90..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiNotFoundException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.web.HttpSC ;
-
-public class FusekiNotFoundException extends FusekiRequestException
-{
- public FusekiNotFoundException(String msg) { super(HttpSC.NOT_FOUND_404, msg) ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiRequestException.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiRequestException.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiRequestException.java
deleted file mode 100644
index e197be2..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiRequestException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-import org.apache.jena.web.HttpSC ;
-
-
-public class FusekiRequestException extends FusekiException
-{
- public static FusekiRequestException create(int code, String msg)
- {
- if ( code == HttpSC.NOT_FOUND_404 )
- return new FusekiNotFoundException(msg) ;
- return new FusekiRequestException(code, msg) ;
- }
-
- private final int statusCode ;
- private final String responseMessage ;
- protected FusekiRequestException(int code, String msg)
- {
- super(msg) ;
- this.statusCode = code ;
- responseMessage = msg ;
- }
-
- public int getStatusCode()
- {
- return statusCode ;
- }
-
- public String getResponseMessage()
- {
- return responseMessage ;
- }
-
- @Override
- public String toString()
- {
- return "HTTP: "+statusCode+" "+getMessage() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/HttpNames.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/HttpNames.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/HttpNames.java
deleted file mode 100644
index f6cee56..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/HttpNames.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-public class HttpNames
-{
- // Request
- public static final String hAccept = "Accept" ;
- public static final String hAcceptEncoding = "Accept-Encoding" ;
- public static final String hAcceptCharset = "Accept-Charset" ;
- //public static final String hAcceptLanguage = "Accept-Language" ;
-
- // Response
- public static final String xhAcceptRanges = "Accept-Ranges" ;
- public static final String hAllow = "Allow" ;
- public static final String hContentEncoding = "Content-Encoding" ;
- public static final String hContentLengh = "Content-Length" ;
- public static final String hContentLocation = "Content-Location" ;
- public static final String hContentRange = "Content-Range" ;
- public static final String hContentType = "Content-Type" ;
- public static final String hRetryAfter = "Retry-After" ;
- public static final String hServer = "Server" ;
- public static final String hLocation = "Location" ;
- public static final String hVary = "Vary" ;
- public static final String charset = "charset" ;
-
- // CORS:
- // http://www.w3.org/TR/cors/ http://esw.w3.org/CORS_Enabled
- public static final String hAccessControlAllowOrigin = "Access-Control-Allow-Origin" ;
-
- // Fuseki parameter names
- public static final String paramGraph = "graph" ;
- public static final String paramGraphDefault = "default" ;
-
- public static final String paramQuery = "query" ;
- public static final String paramQueryRef = "query-ref" ;
- public static final String paramDefaultGraphURI = "default-graph-uri" ;
- public static final String paramNamedGraphURI = "named-graph-uri" ;
-
- public static final String paramStyleSheet = "stylesheet" ;
- public static final String paramAccept = "accept" ;
- public static final String paramOutput1 = "output" ; // See Yahoo! developer: http://developer.yahoo.net/common/json.html
- public static final String paramOutput2 = "format" ; // Alternative name
- public static final String paramCallback = "callback" ;
- public static final String paramForceAccept = "force-accept" ; // Force the accept header at the last moment
- public static final String paramTimeout = "timeout" ;
-
- public static final String paramUpdate = "update" ;
- public static final String paramRequest = "request" ;
- public static final String paramUsingGraphURI = "using-graph-uri" ;
- public static final String paramUsingNamedGraphURI = "using-named-graph-uri" ;
-
- public static final String METHOD_DELETE = "DELETE";
- public static final String METHOD_HEAD = "HEAD";
- public static final String METHOD_GET = "GET";
- public static final String METHOD_OPTIONS = "OPTIONS";
- public static final String METHOD_PATCH = "PATCH" ;
- public static final String METHOD_POST = "POST";
- public static final String METHOD_PUT = "PUT";
- public static final String METHOD_TRACE = "TRACE";
-
- public static final String HEADER_IFMODSINCE = "If-Modified-Since";
- public static final String HEADER_LASTMOD = "Last-Modified";
-
- // Names for services in the default configuration
- public static final String ServiceQuery = "query" ;
- public static final String ServiceQueryAlt = "sparql" ;
- public static final String ServiceUpdate = "update" ;
- public static final String ServiceData = "data" ;
- public static final String ServiceUpload = "upload" ;
- public static final String ServiceGeneralQuery = "/sparql" ;
-
- // Posisble values of fields.
- // TODO Pull in from results writer.
- public static final String valueDefault = "default" ;
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/Test.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/Test.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/Test.java
deleted file mode 100644
index b4f5fed..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/Test.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki;
-
-public class Test
-{
- public static void init() { System.out.println("INIT called") ; }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/ConNeg.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/ConNeg.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/ConNeg.java
deleted file mode 100644
index 25e6a4f..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/ConNeg.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.conneg;
-
-import static org.apache.jena.fuseki.HttpNames.hAcceptCharset ;
-
-import javax.servlet.http.HttpServletRequest ;
-
-import org.apache.jena.atlas.web.AcceptList ;
-import org.apache.jena.atlas.web.MediaRange ;
-import org.apache.jena.atlas.web.MediaType ;
-import org.slf4j.Logger ;
-import org.slf4j.LoggerFactory ;
-
-public class ConNeg
-{
- private static Logger log = LoggerFactory.getLogger(ConNeg.class) ;
- // See riot.ContentNeg (client side).
- // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
-
- static public MediaType parse(String contentType)
- {
- try {
- return MediaType.create(contentType) ;
- } catch (RuntimeException ex) { return null ; }
- }
-
- static public MediaType match(String headerString, AcceptList offerList)
- {
- AcceptList l = new AcceptList(headerString) ;
- return AcceptList.match(l, offerList) ;
- }
-
- /** Match a single media type against a header string */
- public static String match(String headerString, String mediaRangeStr)
- {
- AcceptList l = new AcceptList(headerString) ;
- MediaRange aItem = new MediaRange(mediaRangeStr) ; // MediaType
- MediaType m = l.match(aItem) ;
- if ( m == null )
- return null ;
- return m.toHeaderString() ;
- }
-
- /*package*/ static String[] split(String s, String splitStr)
- {
- String[] x = s.split(splitStr,2) ;
- for ( int i = 0 ; i < x.length ; i++ )
- {
- x[i] = x[i].trim() ;
- }
- return x ;
- }
-
- public static MediaType chooseCharset(HttpServletRequest httpRequest,
- AcceptList myPrefs,
- MediaType defaultMediaType)
- {
- String a = httpRequest.getHeader(hAcceptCharset) ;
- if ( log.isDebugEnabled() )
- log.debug("Accept-Charset request: "+a) ;
-
- MediaType item = choose(a, myPrefs, defaultMediaType) ;
-
- if ( log.isDebugEnabled() )
- log.debug("Charset chosen: "+item) ;
-
- return item ;
- }
-
- public static MediaType chooseContentType(HttpServletRequest httpRequest,
- AcceptList myPrefs,
- MediaType defaultMediaType)
- {
- String a = WebLib.getAccept(httpRequest) ;
- if ( log.isDebugEnabled() )
- log.debug("Accept request: "+a) ;
-
- MediaType item = choose(a, myPrefs, defaultMediaType) ;
-
- if ( log.isDebugEnabled() )
- log.debug("Content type chosen: "+item) ;
-
- return item ;
- }
-
- private static MediaType choose(String headerString, AcceptList myPrefs,
- MediaType defaultMediaType)
- {
- if ( headerString == null )
- return defaultMediaType ;
-
- AcceptList headerList = new AcceptList(headerString) ;
-
- if ( myPrefs == null )
- {
- MediaType i = headerList.first() ;
- if ( i == null ) return defaultMediaType ;
- return i ;
- }
-
- MediaType i = AcceptList.match(headerList, myPrefs) ;
- if ( i == null )
- return defaultMediaType ;
- return i ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/WebLib.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/WebLib.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/WebLib.java
deleted file mode 100644
index fdeb139..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/conneg/WebLib.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.conneg;
-
-import java.util.Enumeration ;
-
-import javax.servlet.http.HttpServletRequest ;
-
-import org.apache.jena.fuseki.HttpNames ;
-
-public class WebLib
-{
- /** Split a string, removing whitespace around the split string.
- * e.g. Use in splitting HTTP accept/content-type headers.
- */
- public static String[] split(String s, String splitStr)
- {
- String[] x = s.split(splitStr,2) ;
- for ( int i = 0 ; i < x.length ; i++ )
- {
- x[i] = x[i].trim() ;
- }
- return x ;
- }
-
- /** Migrate to WebLib */
- public static String getAccept(HttpServletRequest httpRequest)
- {
- // There can be multiple accept headers -- note many tools don't allow these to be this way (e.g. wget, curl)
- Enumeration<String> en = httpRequest.getHeaders(HttpNames.hAccept) ;
- if ( ! en.hasMoreElements() )
- return null ;
- StringBuilder sb = new StringBuilder() ;
- String sep = "" ;
- for ( ; en.hasMoreElements() ; )
- {
- String x = en.nextElement() ;
- sb.append(sep) ;
- sep = ", " ;
- sb.append(x) ;
- }
- return sb.toString() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
deleted file mode 100644
index c36e8be..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.mgt ;
-
-import static java.lang.String.format ;
-
-import java.io.* ;
-import java.util.concurrent.Callable ;
-import java.util.concurrent.ExecutorService ;
-import java.util.concurrent.Executors ;
-import java.util.zip.GZIPOutputStream ;
-
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.io.IO ;
-import org.apache.jena.atlas.lib.FileOps ;
-import org.apache.jena.atlas.logging.Log ;
-import org.apache.jena.fuseki.FusekiException ;
-import org.apache.jena.fuseki.FusekiLib ;
-import org.apache.jena.fuseki.server.DatasetRef ;
-import org.apache.jena.fuseki.server.DatasetRegistry ;
-import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletBase ;
-import org.apache.jena.riot.Lang ;
-import org.apache.jena.riot.RDFDataMgr ;
-import org.apache.jena.web.HttpSC ;
-
-import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-public class ActionBackup extends ServletBase
-{
- public ActionBackup() { super() ; }
-
- // Limit to one backup at a time.
- public static final ExecutorService backupService = Executors.newFixedThreadPool(1) ;
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
- {
- String dataset = FusekiLib.safeParameter(request, "dataset") ;
- if ( dataset == null )
- {
- response.sendError(HttpSC.BAD_REQUEST_400, "Required parameter missing: ?dataset=") ;
- return ;
- }
-
- if ( ! dataset.startsWith("/") )
- dataset="/"+dataset ;
-
- // HttpSession session = request.getSession(true) ;
- // session.setAttribute("dataset", dataset) ;
- // session.setMaxInactiveInterval(15*60) ; // 10 mins
-
- boolean known = DatasetRegistry.get().isRegistered(dataset) ;
- if (!known)
- {
- response.sendError(HttpSC.BAD_REQUEST_400, "No such dataset: " + dataset) ;
- return ;
- }
-
- long id = allocRequestId(request, response);
- HttpAction action = new HttpAction(id, request, response, false) ;
- DatasetRef ref = DatasetRegistry.get().get(dataset) ;
- action.setDataset(ref);
- scheduleBackup(action) ;
- }
-
- static final String BackupArea = "backups" ;
-
- private void scheduleBackup(final HttpAction action)
- {
- String dsName = action.dsRef.name ;
- final String ds = dsName.startsWith("/")? dsName : "/"+dsName ;
-
- String timestamp = Utils.nowAsString("yyyy-MM-dd_HH-mm-ss") ;
- final String filename = BackupArea + ds + "_" + timestamp ;
- FileOps.ensureDir(BackupArea) ;
-
- try {
- final Callable<Boolean> task = new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception
- {
- log.info(format("[%d] Start backup %s to '%s'", action.id, ds, filename)) ;
- action.beginRead() ;
- try {
- backup(action.getActiveDSG(), filename) ;
- log.info(format("[%d] Finish backup %s to '%s'", action.id, ds, filename)) ;
- }
- catch ( RuntimeException ex )
- {
- log.info(format("[%d] Exception during backup: ", action.id, ex.getMessage()), ex) ;
- return Boolean.FALSE ;
- }
- finally {
- action.endRead() ;
- }
- return Boolean.TRUE ;
- }} ;
-
- log.info(format("[%d] Schedule backup %s to '%s'", action.id, ds, filename)) ;
- backupService.submit(task) ;
- }
- //catch (FusekiException ex)
- catch (RuntimeException ex)
- {
- log.warn("Unanticipated exception", ex) ;
- try { action.response.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()) ; }
- catch (IOException e) { IO.exception(e) ; }
- return ;
- }
-
- successPage(action, "Backup scheduled - see server log for details") ;
- }
-
- // Share with new ServletBase.
- protected static void successPage(HttpAction action, String message)
- {
- try {
- action.response.setContentType("text/html");
- action.response.setStatus(HttpSC.OK_200);
- PrintWriter out = action.response.getWriter() ;
- out.println("<html>") ;
- out.println("<head>") ;
- out.println("</head>") ;
- out.println("<body>") ;
- out.println("<h1>Success</h1>");
- if ( message != null )
- {
- out.println("<p>") ;
- out.println(message) ;
- out.println("</p>") ;
- }
- out.println("</body>") ;
- out.println("</html>") ;
- out.flush() ;
- } catch (IOException ex) { IO.exception(ex) ; }
- }
-
- public static void backup(DatasetGraph dsg, String backupfile)
- {
- if ( ! backupfile.endsWith(".nq") )
- backupfile = backupfile+".nq" ;
-
- OutputStream out = null ;
- try
- {
- if ( true )
- {
- // This seems to achive about the same as "gzip -6"
- // It's not too expensive in elapsed time but it's not zero cost.
- // GZip, large buffer.
- out = new FileOutputStream(backupfile+".gz") ;
- out = new GZIPOutputStream(out, 8*1024) ;
- out = new BufferedOutputStream(out) ;
- }
- else
- {
- out = new FileOutputStream(backupfile) ;
- out = new BufferedOutputStream(out) ;
- }
-
- RDFDataMgr.write(out, dsg,Lang.NQUADS) ;
- out.close() ;
- out = null ;
- }
- catch (FileNotFoundException e)
- {
- Log.warn(ActionBackup.class, "File not found: "+backupfile) ;
- throw new FusekiException("File not found: "+backupfile) ;
- }
- catch (IOException e) { IO.exception(e) ; }
- finally {
- try { if (out != null) out.close() ; }
- catch (IOException e) { /* ignore */ }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionDataset.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionDataset.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionDataset.java
deleted file mode 100644
index fc3d395..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ActionDataset.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.mgt;
-
-import java.io.IOException ;
-import java.io.UnsupportedEncodingException ;
-
-import javax.servlet.ServletOutputStream ;
-import javax.servlet.http.HttpServlet ;
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-import javax.servlet.http.HttpSession ;
-
-import org.apache.commons.codec.binary.Base64 ;
-import org.apache.jena.fuseki.FusekiLib ;
-import org.apache.jena.fuseki.HttpNames ;
-import org.apache.jena.fuseki.server.DatasetRegistry ;
-import org.apache.jena.web.HttpSC ;
-
-/** Log-in and choose dataset */
-public class ActionDataset extends HttpServlet
-{
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
- {
-// request.getRemoteUser() ;
-// request.getUserPrincipal() ;
-
- String dataset = FusekiLib.safeParameter(request, "dataset") ;
- HttpSession session = request.getSession(true) ;
- session.setAttribute("dataset", dataset) ;
- session.setMaxInactiveInterval(15*60) ; // 10 mins
-
- boolean known = DatasetRegistry.get().isRegistered(dataset) ;
- if ( !known )
- {
- response.sendError(HttpSC.BAD_REQUEST_400, "No such dataset: "+dataset) ;
- return ;
- }
-
- if ( true )
- {
- // Redirect to GET page.
- response.setHeader(HttpNames.hLocation, PageNames.pageAfterLogin) ;
- response.setStatus(HttpSC.SEE_OTHER_303) ;
- }
- else
- {
- // Welcome style - but HTML inline :-(
- response.setContentType("text/html");
- response.setStatus(HttpSC.OK_200) ;
- ServletOutputStream out = response.getOutputStream() ;
- out.print("<p>"+dataset+"("+known+")</p>") ;
-
- for ( String name : DatasetRegistry.get().keys() ) {
- out.print("<li>") ;
- out.print(name) ;
- out.println("</li>") ;
- }
- out.println("</ul>") ;
- out.println("<p><a href=\"info\">Next</a></p>") ;
- }
-
-// Cookie cookie = new Cookie("org.apache.jena.fuseki.session", dataset) ;
-// // 24 hours.
-// cookie.setMaxAge(24*60*60) ;
-
- }
-
- /**
- * This method returns true if the HttpServletRequest contains a valid
- * authorisation header
- * @param req The HttpServletRequest to test
- * @return true if the Authorisation header is valid
- */
-
- private boolean authenticate(HttpServletRequest req)
- {
- String authhead=req.getHeader("Authorization");
-
- if(authhead!=null)
- {
- byte[] up = Base64.decodeBase64(authhead.substring(6)) ;
- // Decode the authorisation String
- String usernpass ;
- try
- {
- usernpass = new String(up, "ascii") ;
- } catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- usernpass = null ;
- }
- // Split the username from the password
- String user=usernpass.substring(0,usernpass.indexOf(":"));
- String password=usernpass.substring(usernpass.indexOf(":")+1);
-
- if (user.equals("user") && password.equals("pass"))
- return true;
- }
-
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/2fb788d3/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ManagementServer.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ManagementServer.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ManagementServer.java
deleted file mode 100644
index c884bde..0000000
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/mgt/ManagementServer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.mgt;
-
-import static org.apache.jena.fuseki.Fuseki.serverLog ;
-
-import java.util.List ;
-
-import javax.servlet.http.HttpServlet ;
-
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.server.FusekiErrorHandler ;
-import org.apache.jena.fuseki.servlets.DumpServlet ;
-import org.eclipse.jetty.server.Connector ;
-import org.eclipse.jetty.server.Server ;
-import org.eclipse.jetty.server.nio.SelectChannelConnector ;
-import org.eclipse.jetty.servlet.ServletContextHandler ;
-import org.eclipse.jetty.servlet.ServletHolder ;
-
-public class ManagementServer
-{
- public static Server createManagementServer(int mgtPort)
- {
- Fuseki.serverLog.info("Adding management functions") ;
-
- // Separate Jetty server
- Server server = new Server() ;
-
-// BlockingChannelConnector bcConnector = new BlockingChannelConnector() ;
-// bcConnector.setUseDirectBuffers(false) ;
-// Connector connector = bcConnector ;
-
- Connector connector = new SelectChannelConnector() ;
- // Ignore idle time.
- // If set, then if this goes off, it keeps going off and you get a lot of log messages.
- connector.setMaxIdleTime(0) ; // Jetty outputs a lot of messages if this goes off.
- connector.setPort(mgtPort);
- server.addConnector(connector) ;
-
- ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
- context.setErrorHandler(new FusekiErrorHandler()) ;
- server.setHandler(context);
-
- // Add the server control servlet
- addServlet(context, new MgtCmdServlet(), "/mgt") ;
- addServlet(context, new DumpServlet(), "/dump") ;
- addServlet(context, new StatsServlet(), "/stats") ;
-
- return server ;
- // Old plan
-// // Development : server control panel.
-// addServlet(context, new ServerServlet(), "/server") ;
-// addServlet(context, new ActionBackup(), "/backup") ;
- }
-
- // SHARE
- private static void addServlet(ServletContextHandler context, String datasetPath, HttpServlet servlet, List<String> pathSpecs)
- {
- for ( String pathSpec : pathSpecs )
- {
- if ( pathSpec.endsWith("/") )
- pathSpec = pathSpec.substring(0, pathSpec.length()-1) ;
- if ( pathSpec.startsWith("/") )
- pathSpec = pathSpec.substring(1, pathSpec.length()) ;
- addServlet(context, servlet, datasetPath+"/"+pathSpec) ;
- }
- }
-
- private static void addServlet(ServletContextHandler context, HttpServlet servlet, String pathSpec)
- {
- ServletHolder holder = new ServletHolder(servlet) ;
- addServlet(context, holder, pathSpec) ;
- }
-
- private static void addServlet(ServletContextHandler context, ServletHolder holder, String pathSpec)
- {
- serverLog.debug("Add servlet @ "+pathSpec) ;
- context.addServlet(holder, pathSpec) ;
- }
-
-}
-