router.attach("/engine",EngineResource.class)
.setMatchingMode(Template.MODE_EQUALS);
router.attach("/engine/",EngineResource.class)
.setMatchingMode(Template.MODE_EQUALS);
Directory alljobsdir = new Directory(
getContext(),
engine.getJobsDir().toURI().toString());
alljobsdir.setListingAllowed(true);
router.attach("/engine/jobsdir",alljobsdir);
EnhDirectory anypath = new EnhDirectory(
getContext(),
engine.getJobsDir().toURI().toString() /*TODO: changeme*/) {
@Override
protected Reference determineRootRef(Request request) {
String ref = "file:/";
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*/) {
@Override
protected Reference determineRootRef(Request request) {
try {
return new Reference(
EngineApplication.this.getEngine()
.getJob(TextUtils.urlUnescape(
(String)request.getAttributes().get("job")))
.getJobDir().getCanonicalFile().toURI().toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}};
jobdir.setListingAllowed(true);
jobdir.setModifiable(true);
jobdir.setEditFilter(JobResource.EDIT_FILTER);
router.attach("/engine/job/{job}/jobdir",jobdir);
router.attach("/engine/job/{job}",JobResource.class);
router.attach("/engine/job/{job}/report/{reportClass}",ReportGenResource.class);
router.attach("/engine/job/{job}/beans",BeanBrowseResource.class);
router.attach("/engine/job/{job}/beans/{beanPath}",BeanBrowseResource.class);
router.attach("/engine/job/{job}/script",ScriptResource.class);
// static files (won't serve directory, but will serve files in it)
String resource = "clap://class/org/archive/crawler/restlet";
Directory staticDir = new Directory(getContext(),resource);
router.attach("/engine/static/",staticDir);
return router;
}