Search in sources :

Example 1 with InitializeException

use of de.herrlock.manga.exceptions.InitializeException 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 InitializeException

use of de.herrlock.manga.exceptions.InitializeException in project Manga by herrlock.

the class Configuration method _createUrl.

/**
 * creates a {@link URL} from the property {@value #URL} in the given Properties
 *
 * @param p
 *            the {@link Properties} where to search for an url
 * @return the created URL
 * @throws InitializeException
 *             in case the URL is not availabile or malformed
 */
protected static URL _createUrl(final Properties p) throws InitializeException {
    logger.traceEntry();
    URL url = _createUrlNotRequired(p);
    if (url == null) {
        throw new InitializeException("url is not filled but required");
    }
    logger.debug("URL: {}", url);
    return url;
}
Also used : InitializeException(de.herrlock.manga.exceptions.InitializeException) URL(java.net.URL)

Example 3 with InitializeException

use of de.herrlock.manga.exceptions.InitializeException in project Manga by herrlock.

the class Configuration method _createProxy.

/**
 * Creates a {@link ProxyStorage} that serves as proxy
 *
 * @param p
 *            the {@link Properties} where to search for proxy-settings
 * @return a {@link ProxyStorage} containing the proxy-settings. Does not return null, instead the {@link ProxyStorage}
 *         contains {@code null}-values
 * @throws InitializeException
 *             in case the given url is malformed or cannot be resolved
 */
protected static ProxyStorage _createProxy(final Properties p) throws InitializeException {
    logger.traceEntry();
    // get proxy
    try {
        String proxyString = p.getProperty(PROXY);
        if (proxyString != null && !"".equals(proxyString)) {
            return createProxyStorage(proxyString);
        }
    } catch (final MalformedURLException | UnknownHostException ex) {
        logger.error("", ex);
        throw new InitializeException("proxy-url is malformed or not recognized.", ex);
    }
    logger.debug("No Proxy");
    return new ProxyStorage();
}
Also used : MalformedURLException(java.net.MalformedURLException) InitializeException(de.herrlock.manga.exceptions.InitializeException) UnknownHostException(java.net.UnknownHostException)

Example 4 with InitializeException

use of de.herrlock.manga.exceptions.InitializeException in project Manga by herrlock.

the class ChapterList method getInstance.

/**
 * creates an instance of {@linkplain ChapterList}, gets the right {@linkplain Details} from the {@linkplain URL} in the given
 * {@link DownloadConfiguration}
 *
 * @param conf
 *            the {@link DownloadConfiguration} to use
 * @return an instance of {@link ChapterList}; when no suitable Hoster can be detected {@code null}
 */
public static ChapterList getInstance(final DownloadConfiguration conf) {
    logger.traceEntry("Configuration: {}", conf);
    URL url = conf.getUrl();
    Hoster h;
    try {
        h = Hosters.getHostByURL(url);
    } catch (NoHosterFoundException ex) {
        throw new InitializeException(ex);
    }
    logger.debug("Selected Hoster: {}", h.getName());
    return h.getChapterList(conf);
}
Also used : InitializeException(de.herrlock.manga.exceptions.InitializeException) NoHosterFoundException(de.herrlock.manga.host.exceptions.NoHosterFoundException) URL(java.net.URL)

Aggregations

InitializeException (de.herrlock.manga.exceptions.InitializeException)4 URL (java.net.URL)2 MDownloader (de.herrlock.manga.downloader.MDownloader)1 NoHosterFoundException (de.herrlock.manga.host.exceptions.NoHosterFoundException)1 JDConfiguration (de.herrlock.manga.util.configuration.JDConfiguration)1 MalformedURLException (java.net.MalformedURLException)1 UnknownHostException (java.net.UnknownHostException)1