mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-11-09 23:43:29 +00:00
* JobResource.java
rename 'discard' to 'teardown'
enable browse/edit of paths outside jobdir via new /anypath/ service
* EngineResource.java, Engine.java
enable addition of job dirs from outside main jobs directory
* EngineApplication.java
register new /engine/anypath service for outside-job-dir paths
This commit is contained in:
1 parent
4d7c4834d8
commit
52a0895c6b
4 files changed
+62
-19
No files matched your search
@@ -83,20 +83,26 @@ public class Engine {
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.isDirectory();
|
||||
}})) {
|
||||
for (File cxml : dir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".cxml");
|
||||
}})) {
|
||||
try {
|
||||
CrawlJob cj = new CrawlJob(cxml);
|
||||
if(!jobConfigs.containsKey(cj.getShortName())) {
|
||||
jobConfigs.put(cj.getShortName(),cj);
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
LOGGER.log(Level.WARNING,"bad cxml: "+cxml,iae);
|
||||
considerAsJobDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean considerAsJobDirectory(File dir) {
|
||||
for (File cxml : dir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".cxml");
|
||||
}})) {
|
||||
try {
|
||||
CrawlJob cj = new CrawlJob(cxml);
|
||||
if(!jobConfigs.containsKey(cj.getShortName())) {
|
||||
jobConfigs.put(cj.getShortName(),cj);
|
||||
return true;
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
LOGGER.log(Level.WARNING,"bad cxml: "+cxml,iae);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String,CrawlJob> getJobConfigs() {
|
||||
|
||||
@@ -72,6 +72,21 @@ public class EngineApplication extends Application {
|
||||
router.attach("/engine/jobsdir",alljobsdir);
|
||||
|
||||
|
||||
EnhDirectory anypath = new EnhDirectory(
|
||||
getContext(),
|
||||
engine.getJobsDir().toURI().toString() /*TODO: changeme*/) {
|
||||
@Override
|
||||
Reference determineRootRef(Request request) {
|
||||
String ref = "file:/";
|
||||
System.out.println(ref);
|
||||
return new Reference(ref);
|
||||
}};
|
||||
anypath.setListingAllowed(true);
|
||||
anypath.setModifiable(true);
|
||||
anypath.setEditFilter(JobResource.EDIT_FILTER);
|
||||
|
||||
router.attach("/engine/anypath/",anypath);
|
||||
|
||||
EnhDirectory jobdir = new EnhDirectory(
|
||||
getContext(),
|
||||
engine.getJobsDir().toURI().toString() /*TODO: changeme*/) {
|
||||
|
||||
@@ -72,7 +72,9 @@ public class EngineResource extends Resource {
|
||||
String action = form.getFirstValue("action");
|
||||
if("rescan".equals(action)) {
|
||||
getEngine().findJobConfigs();
|
||||
}
|
||||
} else if ("add".equals(action)) {
|
||||
getEngine().considerAsJobDirectory(new File(form.getFirstValue("addpath")));
|
||||
}
|
||||
// default: redirect to GET self
|
||||
getResponse().redirectSeeOther(getRequest().getOriginalRef());
|
||||
}
|
||||
@@ -105,7 +107,7 @@ public class EngineResource extends Resource {
|
||||
jobs.addAll(engine.getJobConfigs().values());
|
||||
|
||||
pw.println("<form method=\'POST\'><h2>Job Directories ("+jobs.size()+")");
|
||||
pw.println("<input style='width:6em' type='submit' name='action' value='rescan'>");
|
||||
pw.println("<input type='submit' name='action' value='rescan'>");
|
||||
pw.println("</h2></form>");
|
||||
Collections.sort(jobs);
|
||||
pw.println("<ul>");
|
||||
@@ -117,9 +119,16 @@ public class EngineResource extends Resource {
|
||||
pw.println("</ul>");
|
||||
pw.println(
|
||||
"To create a new job, use the 'copy' functionality on " +
|
||||
"an existing job's detail page, or create a new job " +
|
||||
"directory outside this interface and use the 'rescan' " +
|
||||
"button.");
|
||||
"an existing job's detail page. Or, create a new job " +
|
||||
"directory manually the main jobs directory and use the " +
|
||||
"'rescan' button above. Or, supply a full path to another " +
|
||||
"valid job directory at the engine machine below.<br/><br/>");
|
||||
|
||||
pw.println("<form method=\'POST\'>");
|
||||
pw.println("Add job directory: <input size='50' name='addpath'/>");
|
||||
pw.println("<input type='submit' name='action' value='add'>");
|
||||
pw.println("</form>");
|
||||
|
||||
pw.println("</body>");
|
||||
pw.flush();
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class JobResource extends Resource {
|
||||
pw.println(" disabled ");
|
||||
}
|
||||
pw.println(" type='submit' name='action' value='terminate'/>");
|
||||
pw.println("<input type='submit' name='action' value='discard' ");
|
||||
pw.println("<input type='submit' name='action' value='teardown' ");
|
||||
pw.print(cj.isContainerOk()?"":"disabled='disabled' title='no instance'");
|
||||
pw.println("/><br/>");
|
||||
|
||||
@@ -332,7 +332,20 @@ public class JobResource extends Resource {
|
||||
protected void printLinkedIfInJobDirectory(PrintWriter pw, File f) {
|
||||
String jobDirRelative = cj.jobDirRelativePath(f);
|
||||
if(jobDirRelative==null) {
|
||||
pw.println(f);
|
||||
/// print via anypath
|
||||
String fullPath = f.getAbsolutePath();
|
||||
fullPath = fullPath.replace(File.separatorChar, '/');
|
||||
pw.println("<a href='../../anypath/"
|
||||
+ fullPath + "'>"
|
||||
+ f +"</a>");
|
||||
if(EDIT_FILTER.accept(f)) {
|
||||
pw.println("[<a href='../../anypath/"
|
||||
+ fullPath
|
||||
+ "?format=textedit'>edit</a>]<br/>");
|
||||
}
|
||||
|
||||
|
||||
//pw.println(f);
|
||||
return;
|
||||
}
|
||||
pw.println("<a href='jobdir/"
|
||||
@@ -367,7 +380,7 @@ public class JobResource extends Resource {
|
||||
cj.instantiateContainer();
|
||||
} else if("build".equals(action)||"validate".equals(action)) {
|
||||
cj.validateConfiguration();
|
||||
} else if("discard".equals(action)) {
|
||||
} else if("teardown".equals(action)) {
|
||||
cj.reset();
|
||||
} else if("pause".equals(action)) {
|
||||
cj.getCrawlController().requestCrawlPause();
|
||||
|
||||
Reference in new issue
Block a user