use of de.herrlock.manga.exceptions.MDRuntimeException in project Manga by herrlock.
the class ViewPage method getVersion.
private String getVersion() {
URL[] urls = { ViewPage.class.getProtectionDomain().getCodeSource().getLocation() };
Manifest m = new Manifest();
try (URLClassLoader urlClassLoader = new URLClassLoader(urls)) {
try (InputStream in = urlClassLoader.getResourceAsStream("META-INF/MANIFEST.MF")) {
m.read(in);
}
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
Attributes infoAttributes = m.getAttributes("Info");
return infoAttributes == null ? "DEV" : infoAttributes.getValue("Version");
}
use of de.herrlock.manga.exceptions.MDRuntimeException in project Manga by herrlock.
the class MangaPandaChapterList method getAvailabile.
@Override
public Collection<HosterListEntry> getAvailabile(final IndexerConfiguration conf) {
Document doc;
final URL baseUrl;
try {
baseUrl = new URL(getDetails().baseUrl());
URL listUrl = new URL(baseUrl, "/alphabetical");
doc = Utils.getDocument(listUrl, conf);
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
Elements elements = doc.select("div.series_col ul.series_alpha > li > a");
Collection<HosterListEntry> entries = new TreeSet<>(HosterListEntry.NAME_COMPARATOR);
for (Element element : elements) {
HosterListEntry entry = new HosterListEntry();
entry.setName(element.text());
try {
entry.setUrl(new URL(baseUrl, element.attr("href")).toExternalForm());
} catch (MalformedURLException ex) {
logger.catching(Level.DEBUG, ex);
}
entries.add(entry);
}
return entries;
}
use of de.herrlock.manga.exceptions.MDRuntimeException in project Manga by herrlock.
the class Hosters method loadResourcePaths.
private static Collection<URL> loadResourcePaths(final Iterable<String> lines) {
Queue<URL> resourcePaths = new ArrayDeque<>();
try {
for (String line : lines) {
String filename = line.substring(1, line.length() - 1);
File nextFile = new File(filename);
if (nextFile.exists()) {
URL nextFileURL = nextFile.toURI().toURL();
resourcePaths.add(nextFileURL);
} else {
logger.warn("The File \"{}\" does not exist", nextFile);
}
}
} catch (MalformedURLException ex) {
throw new MDRuntimeException(ex);
}
return resourcePaths;
}
use of de.herrlock.manga.exceptions.MDRuntimeException in project Manga by herrlock.
the class Hosters method loadAdditionalHosters.
private static void loadAdditionalHosters(final Collection<String> lines) {
logger.traceEntry("lines: {}", lines);
final Predicate<String> isBracketLine = new Predicate<String>() {
@Override
public boolean apply(final String input) {
return input != null && input.startsWith("[") && input.endsWith("]");
}
};
Iterable<String> resourcesPathLines = Iterables.filter(lines, isBracketLine);
Collection<URL> resourcePaths = loadResourcePaths(resourcesPathLines);
URL[] resourcePathArray = resourcePaths.toArray(new URL[resourcePaths.size()]);
try (URLClassLoader classLoader = new URLClassLoader(resourcePathArray, Hosters.class.getClassLoader())) {
Iterable<String> otherLines = Iterables.filter(lines, Predicates.not(isBracketLine));
for (String line : otherLines) {
if (!line.trim().isEmpty() && !line.startsWith("#")) {
loadExtraClass(classLoader, line);
}
}
} catch (IOException ex) {
throw new MDRuntimeException(ex);
}
}
use of de.herrlock.manga.exceptions.MDRuntimeException in project Manga by herrlock.
the class Main method startServer.
private static void startServer(final CommandLine commandline) {
logger.traceEntry("Commandline: {}", commandline);
logger.info("Starting Server:");
try {
if (commandline.hasOption("browser")) {
logger.info("(and browser)");
ServerMain.execute(true);
} else {
ServerMain.execute(false);
}
} catch (IOException | MDException | URISyntaxException ex) {
throw new MDRuntimeException(ex);
}
}
Aggregations