Search in sources :

Example 1 with MDownloader

use of de.herrlock.manga.downloader.MDownloader in project Manga by herrlock.

the class JDExport method execute.

public static void execute(final Properties p) {
    logger.traceEntry();
    String jdhome = p.getProperty(Configuration.JDFW);
    if (jdhome == null || jdhome.trim().isEmpty()) {
        throw new InitializeException("\"" + Configuration.JDFW + "\" must be set");
    }
    JDConfiguration conf = JDConfiguration.create(p);
    MDownloader dlImpl = new JDExport(conf);
    DownloadProcessor.getInstance().addDownload(dlImpl);
}
Also used : InitializeException(de.herrlock.manga.exceptions.InitializeException) JDConfiguration(de.herrlock.manga.util.configuration.JDConfiguration) MDownloader(de.herrlock.manga.downloader.MDownloader)

Example 2 with MDownloader

use of de.herrlock.manga.downloader.MDownloader in project Manga by herrlock.

the class MDObject method handle.

@Override
public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
    logger.traceEntry();
    JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
    for (Entry<UUID, MDObject> entry : this.dlContext.entrySet()) {
        UUID key = entry.getKey();
        MDObject value = entry.getValue();
        MDownloader mdownloader = value.getMdownloader();
        arrayBuilder.add(// 
        Json.createObjectBuilder().add("uuid", // 
        key.toString()).add("url", // 
        value.getUrl()).add("started", // 
        mdownloader.getStarted()).add("progress", // 
        mdownloader.getProgress()).add("maxProgress", mdownloader.getMaxProgress()));
    }
    Json.createWriter(response.getOutputStream()).write(arrayBuilder.build());
    response.setContentType(MediaType.JSON_UTF_8.toString());
    response.setStatus(HttpServletResponse.SC_OK);
    baseRequest.setHandled(true);
}
Also used : MDownloader(de.herrlock.manga.downloader.MDownloader) JsonArrayBuilder(javax.json.JsonArrayBuilder) UUID(java.util.UUID)

Aggregations

MDownloader (de.herrlock.manga.downloader.MDownloader)2 InitializeException (de.herrlock.manga.exceptions.InitializeException)1 JDConfiguration (de.herrlock.manga.util.configuration.JDConfiguration)1 UUID (java.util.UUID)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1