Skip to content

Commit

Permalink
Rename FusekiSystem as FusekiWebapp.
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Nov 13, 2018
1 parent f25e410 commit 6e8e074
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.jena.fuseki.system.FusekiLogging;
import org.apache.jena.fuseki.webapp.FusekiEnv;
import org.apache.jena.fuseki.webapp.FusekiServerListener;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;
import org.apache.jena.query.ARQ ;
import org.apache.jena.query.Dataset ;
import org.apache.jena.riot.Lang ;
Expand Down Expand Up @@ -224,7 +224,7 @@ protected void processModulesAndArgs() {
if ( ! cmdlineConfigPresent && cmdLineConfig.fusekiCmdLineConfigFile == null ) {
// Turn command line argument into an absolute file name.
FusekiEnv.setEnvironment();
Path cfg = FusekiEnv.FUSEKI_BASE.resolve(FusekiSystem.DFT_CONFIG).toAbsolutePath() ;
Path cfg = FusekiEnv.FUSEKI_BASE.resolve(FusekiWebapp.DFT_CONFIG).toAbsolutePath() ;
if ( Files.exists(cfg) )
cmdLineConfig.fusekiServerConfigFile = cfg.toString() ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.jena.fuseki.ctl.ActionCtl;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;

/**
* A JSON API to list all the backups in the backup directory
Expand Down Expand Up @@ -67,11 +67,11 @@ protected void perform(HttpAction action) {
} ;

private JsonValue description(HttpAction action) {
if ( ! Files.isDirectory(FusekiSystem.dirBackups) )
ServletOps.errorOccurred(format("[%d] Backup area '%s' is not a directory", action.id, FusekiSystem.dirBackups)) ;
if ( ! Files.isDirectory(FusekiWebapp.dirBackups) )
ServletOps.errorOccurred(format("[%d] Backup area '%s' is not a directory", action.id, FusekiWebapp.dirBackups)) ;

List<Path> paths = new ArrayList<>() ;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiSystem.dirBackups, filterVisibleFiles)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiWebapp.dirBackups, filterVisibleFiles)) {
stream.forEach(paths::add) ;
} catch (IOException ex) {
action.log.error(format("[%d] Backup file list :: IOException :: %s", action.id, ex.getMessage())) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.apache.jena.fuseki.servlets.ServletOps;
import org.apache.jena.fuseki.system.FusekiNetLib;
import org.apache.jena.fuseki.system.Upload;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;
import org.apache.jena.fuseki.webapp.SystemState;
import org.apache.jena.graph.Node ;
import org.apache.jena.graph.NodeFactory ;
Expand Down Expand Up @@ -160,7 +160,7 @@ else if ( WebContent.isMultiPartForm(ct) )
// ----
// Keep a persistent copy immediately. This is not used for
// anything other than being "for the record".
systemFileCopy = FusekiSystem.dirFileArea.resolve(uuid.asString()).toString() ;
systemFileCopy = FusekiWebapp.dirFileArea.resolve(uuid.asString()).toString() ;
try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
}
Expand Down Expand Up @@ -210,8 +210,8 @@ else if ( WebContent.isMultiPartForm(ct) )

action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;

configFile = FusekiSystem.generateConfigurationFilename(datasetPath) ;
List<String> existing = FusekiSystem.existingConfigurationFile(datasetPath) ;
configFile = FusekiWebapp.generateConfigurationFilename(datasetPath) ;
List<String> existing = FusekiWebapp.existingConfigurationFile(datasetPath) ;
if ( ! existing.isEmpty() )
ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists") ;

Expand Down Expand Up @@ -325,7 +325,7 @@ protected void execDeleteItem(HttpAction action) {
ServletOps.errorNotFound("No such dataset registered: "+name);

String filename = name.startsWith("/") ? name.substring(1) : name;
List<String> configurationFiles = FusekiSystem.existingConfigurationFile(filename);
List<String> configurationFiles = FusekiWebapp.existingConfigurationFile(filename);
if ( configurationFiles.size() != 1 ) {
// This should not happen.
action.log.warn(format("[%d] There are %d configuration files, not one.", action.id, configurationFiles.size()));
Expand Down Expand Up @@ -363,7 +363,7 @@ protected void execDeleteItem(HttpAction action) {
// Delete databases created by the UI, or the admin operation, which are
// in predictable, unshared location on disk.
// There may not be any database files, the in-memory case.
Path pDatabase = FusekiSystem.dirDatabases.resolve(filename);
Path pDatabase = FusekiWebapp.dirDatabases.resolve(filename);
if ( Files.exists(pDatabase)) {
try {
if ( Files.isSymbolicLink(pDatabase)) {
Expand Down Expand Up @@ -423,7 +423,7 @@ private static void assemblerFromForm(HttpAction action, StreamRDF dest) {
params.put(Template.NAME, dbName.substring(1)) ;
else
params.put(Template.NAME, dbName) ;
FusekiSystem.addGlobals(params);
FusekiWebapp.addGlobals(params);

//action.log.info(format("[%d] Create database : name = %s, type = %s", action.id, dbName, dbType )) ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.jena.atlas.logging.Log ;
import org.apache.jena.fuseki.Fuseki ;
import org.apache.jena.fuseki.FusekiException ;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;
import org.apache.jena.query.ReadWrite ;
import org.apache.jena.riot.Lang ;
import org.apache.jena.riot.RDFDataMgr ;
Expand All @@ -53,7 +53,7 @@ public static String chooseFileName(String dsName) {

String timestamp = DateTimeUtils.nowAsString("yyyy-MM-dd_HH-mm-ss") ;
String filename = ds + "_" + timestamp ;
filename = FusekiSystem.dirBackups.resolve(filename).toString() ;
filename = FusekiWebapp.dirBackups.resolve(filename).toString() ;
return filename ;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* FusekiLogging can use these values.
* This code must not touch Jena.
*
* @see FusekiSystem
* @see FusekiWebapp
*/
public class FusekiEnv {
// Initialization logging happens via stdout/stderr directly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ private synchronized void serverInitialization(ServletContext servletContext) {
DataAccessPointRegistry.set(servletContext, dataAccessPointRegistry);

try {
FusekiSystem.formatBaseArea() ;
if ( ! FusekiSystem.serverInitialized ) {
FusekiWebapp.formatBaseArea() ;
if ( ! FusekiWebapp.serverInitialized ) {
Fuseki.serverLog.error("Failed to initialize : Server not running") ;
return ;
}
Expand All @@ -86,7 +86,7 @@ private synchronized void serverInitialization(ServletContext servletContext) {
// In a non-commandline startup, initialSetup is null.
if ( initialSetup == null ) {
initialSetup = new FusekiInitialConfig() ;
String cfg = FusekiEnv.FUSEKI_BASE.resolve(FusekiSystem.DFT_CONFIG).toAbsolutePath().toString() ;
String cfg = FusekiEnv.FUSEKI_BASE.resolve(FusekiWebapp.DFT_CONFIG).toAbsolutePath().toString() ;
initialSetup.fusekiServerConfigFile = cfg ;
}

Expand All @@ -95,8 +95,8 @@ private synchronized void serverInitialization(ServletContext servletContext) {
throw new FusekiException("No configuration") ;
}
Fuseki.setVerbose(servletContext, initialSetup.verbose);
FusekiSystem.initializeDataAccessPoints(dataAccessPointRegistry,
initialSetup, FusekiSystem.dirConfiguration.toString()) ;
FusekiWebapp.initializeDataAccessPoints(dataAccessPointRegistry,
initialSetup, FusekiWebapp.dirConfiguration.toString()) ;
} catch (Throwable th) {
Fuseki.serverLog.error("Exception in initialization: {}", th.getMessage()) ;
throw th ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import org.apache.jena.sparql.core.assembler.AssemblerUtils;
import org.apache.jena.tdb.sys.Names ;

public class FusekiSystem
public class FusekiWebapp
{
// Initialization of FUSEKI_HOME and FUSEKI_BASE is done in FusekiEnv.setEnvironment()
// so that the code is independent of any logging. FusekiLogging can use
Expand Down Expand Up @@ -209,7 +209,7 @@ private static void copyFileIfMissing(Path src, String fn, Path dst) {
public static void copyFileFromResource(String fn, Path dstFile) {
try {
// Get from the file from area "org/apache/jena/fuseki/server" (our package)
URL url = FusekiSystem.class.getResource(fn) ;
URL url = FusekiWebapp.class.getResource(fn) ;
if ( url == null )
throw new FusekiConfigException("Failed to find resource '"+fn+"'") ;
InputStream in = url.openStream() ;
Expand Down Expand Up @@ -281,8 +281,8 @@ private static List<DataAccessPoint> processServerConfigFile(String configFilena
Model model = AssemblerUtils.readAssemblerFile(configFilename) ;
if ( model.size() == 0 )
return Collections.emptyList() ;
FusekiConfig.processServerConfig(model);
return FusekiConfig.servicesAndDatasets(model) ;
List<DataAccessPoint> x = FusekiConfig.processServerConfiguration(model, Fuseki.getContext());
return x;
}

private static DataAccessPoint configFromTemplate(String templateFile, String datasetPath,
Expand Down Expand Up @@ -453,20 +453,20 @@ public static String generateConfigurationFilename(String dsName) {
// Without "/"
if ( filename.startsWith("/"))
filename = filename.substring(1) ;
Path p = FusekiSystem.dirConfiguration.resolve(filename+".ttl") ;
Path p = FusekiWebapp.dirConfiguration.resolve(filename+".ttl") ;
return p.toString();
}

/** Return the filenames of all matching files in the configuration directory (absolute paths returned ). */
public static List<String> existingConfigurationFile(String baseFilename) {
try {
List<String> paths = new ArrayList<>() ;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiSystem.dirConfiguration, baseFilename+".*") ) {
stream.forEach((p)-> paths.add(FusekiSystem.dirConfiguration.resolve(p).toString() ));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(FusekiWebapp.dirConfiguration, baseFilename+".*") ) {
stream.forEach((p)-> paths.add(FusekiWebapp.dirConfiguration.resolve(p).toString() ));
}
return paths ;
} catch (IOException ex) {
throw new InternalErrorException("Failed to read configuration directory "+FusekiSystem.dirConfiguration) ;
throw new InternalErrorException("Failed to read configuration directory "+FusekiWebapp.dirConfiguration) ;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ShiroEnvironmentLoader() {}

@Override
public void contextInitialized(ServletContextEvent sce) {
FusekiSystem.formatBaseArea() ;
FusekiWebapp.formatBaseArea() ;
this.servletContext = sce.getServletContext() ;
try {
// Shiro.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void init() {
initialized = true ;

if ( location == null )
location = Location.create(FusekiSystem.dirSystemDatabase.toString()) ;
location = Location.create(FusekiWebapp.dirSystemDatabase.toString()) ;

if ( ! location.isMem() )
FileOps.ensureDir(location.getDirectoryPath()) ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.jena.fuseki.system.FusekiNetLib;
import org.apache.jena.fuseki.webapp.FusekiEnv;
import org.apache.jena.fuseki.webapp.FusekiServerListener;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;
import org.apache.jena.fuseki.webapp.SystemState;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.sparql.core.DatasetGraph ;
Expand Down Expand Up @@ -233,11 +233,11 @@ protected static void setupServer(boolean updateable) {
// in the case of starting in the same location. FusekiSystem has statics.
// Fuseki-full is designed to be the only server, not restartable.
// Here, we want to reset for testing.
emptyDirectory(FusekiSystem.dirSystemDatabase);
emptyDirectory(FusekiSystem.dirBackups);
emptyDirectory(FusekiSystem.dirLogs);
emptyDirectory(FusekiSystem.dirConfiguration);
emptyDirectory(FusekiSystem.dirDatabases);
emptyDirectory(FusekiWebapp.dirSystemDatabase);
emptyDirectory(FusekiWebapp.dirBackups);
emptyDirectory(FusekiWebapp.dirLogs);
emptyDirectory(FusekiWebapp.dirConfiguration);
emptyDirectory(FusekiWebapp.dirDatabases);

setupServer(port(), null, datasetPath(), updateable) ;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ public static void setupServer(int port, String authConfigFile, String datasetPa
if ( server != null ) {
// Clear out the registry.
server.getDataAccessPointRegistry().clear() ;
FileOps.clearAll(FusekiSystem.dirConfiguration.toFile()) ;
FileOps.clearAll(FusekiWebapp.dirConfiguration.toFile()) ;
server.stop() ;
}
server = null ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.jena.atlas.web.HttpException;
import org.apache.jena.atlas.web.TypedInputStream;
import org.apache.jena.fuseki.webapp.FusekiSystem;
import org.apache.jena.fuseki.webapp.FusekiWebapp;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.rdfconnection.RDFConnection;
import org.apache.jena.rdfconnection.RDFConnectionFactory;
Expand Down Expand Up @@ -77,7 +77,7 @@ private static void testAddDelete(String dbName, String dbType, boolean hasFiles
int x1 = count(conn);
assertEquals(1, x1);

Path pathDB = FusekiSystem.dirDatabases.resolve(dbName);
Path pathDB = FusekiWebapp.dirDatabases.resolve(dbName);

if ( hasFiles )
assertTrue(Files.exists(pathDB));
Expand Down

0 comments on commit 6e8e074

Please sign in to comment.