use of org.edamontology.edammap.core.preprocessing.Stopwords in project edammap by edamontology.
the class Server method run.
private static void run() throws IOException, ParseException {
paramsMain.add(new Param("Ontology file", ServerArgs.EDAM, new File(args.getEdam()).getName(), "https://github.com/edamontology/edamontology/tree/master/releases"));
for (Stopwords stopwords : Stopwords.values()) {
stopwordsAll.put(stopwords, PreProcessor.getStopwords(stopwords));
}
processor = new Processor(args.getProcessorArgs());
if (args.getProcessorArgs().getIdf() != null && !args.getProcessorArgs().getIdf().isEmpty()) {
idf = new Idf(args.getProcessorArgs().getIdf());
}
if (args.getProcessorArgs().getIdfStemmed() != null && !args.getProcessorArgs().getIdfStemmed().isEmpty()) {
idfStemmed = new Idf(args.getProcessorArgs().getIdfStemmed());
}
logger.info("Loading concepts");
concepts = Edam.load(args.getEdam());
logger.info("Configuring server");
final ResourceConfig rc = new ResourceConfig().packages("org.edamontology.edammap.server");
// TODO .property(JsonGenerator.PRETTY_PRINTING, true);
HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(args.getBaseUri() + "/" + args.getPath() + "/api"), rc, false);
final StaticHttpHandler filesHttpHandler = new StaticHttpHandler(args.getFiles());
filesHttpHandler.setDirectorySlashOff(true);
httpServer.getServerConfiguration().addHttpHandler(filesHttpHandler, "/" + args.getPath() + "/*");
httpServer.getServerConfiguration().addHttpHandler(new HttpHandler() {
@Override
public void service(Request request, Response response) throws Exception {
// TODO replace null with request.getParameterMap()
String responseText = Resource.runGet(null, request);
response.setContentType(MediaType.TEXT_HTML);
response.setContentLength(responseText.length());
response.getWriter().write(responseText);
}
}, "/" + args.getPath() + "/");
if (args.getLog() != null) {
Path accessDir = Paths.get(args.getLog() + "/access");
if (!Files.exists(accessDir)) {
Files.createDirectory(accessDir);
}
final AccessLogBuilder builder = new AccessLogBuilder(accessDir + "/edammap-access.log");
builder.rotatedDaily();
// builder.format(ApacheLogFormat.COMBINED); // TODO
builder.instrument(httpServer.getServerConfiguration());
}
logger.info("Starting server");
httpServer.start();
logger.info("{} has started", version.getName());
}
Aggregations