/** * Load the SMIL document identified by <code>mpe</code>. Throws an exception if it does not exist or cannot be loaded * by any reason. * * @return the document */ public static Document loadSmilDocument(InputStream in, MediaPackageElement mpe) { try { Either<Exception, org.w3c.dom.Document> eitherDocument = XmlUtil.parseNs(new InputSource(in)); if (eitherDocument.isRight()) return eitherDocument.right().value(); throw eitherDocument.left().value(); } catch (Exception e) { logger.warn("Unable to load smil document from catalog '{}'", mpe, e); return Misc.chuck(e); } }
/** Get the value or throw the exception. */ public static <A> A getOrError(Either<Exception, A> response) { if (response.isRight()) { return response.right().value(); } else { return chuck(response.left().value()); } }
@Override public List<AccessControlEntry> apply(List<AccessControlEntry> sum, Either<AccessControlEntry, List<AccessControlEntry>> current) { if (current.isLeft()) sum.add(current.left().value()); else sum.addAll(current.right().value()); return sum; } });
public static String getContentOn(final RequestRunner<String> runner, final int... status) { final Either<Exception, String> res = runner.run(getContentOn(status)); if (res.isRight()) { return res.right().value(); } else { return chuck(res.left().value()); } }