List of usage examples for java.lang Error Error
public Error(String message, Throwable cause)
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxLoader.CFAsteriskSaxLoaderClusterHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {// ww w . j ava 2s . c o m final String S_ProcName = "startElement"; assert qName.equals("Cluster"); CFAsteriskSaxLoader saxLoader = (CFAsteriskSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAsteriskSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } CFLibXmlCoreContext curContext = getParser().getCurContext(); ICFSecurityClusterObj useCluster = saxLoader.getUseCluster(); if (useCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "saxLoader.useCluster"); } curContext.putNamedValue("Object", useCluster); } catch (RuntimeException e) { throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }
From source file:edu.unc.lib.dl.ingest.aip.AIPImpl.java
/** * Makes an AIP with a empty prep dir/*ww w . j ava 2 s . co m*/ */ public AIPImpl(DepositRecord depositRecord) { this.depositRecord = depositRecord; try { this.prepDir = FileUtils.createTempDirectory("ingest-prep"); } catch (IOException e) { throw new Error("Unexpected", e); } }
From source file:edu.unc.lib.dl.xml.ModsXmlHelper.java
public static Document transformDCTerms2MODS(Element dcterms) throws TransformerException { Source dctermsSrc = new JDOMSource(dcterms); JDOMResult modsResult = new JDOMResult(); Transformer t = null;/*from w w w . j a v a 2 s.com*/ try { t = dcterms2MODS.newTransformer(); } catch (TransformerConfigurationException e) { throw new Error("There was a problem configuring the transformer.", e); } t.transform(dctermsSrc, modsResult); return modsResult.getDocument(); }
From source file:com.manydesigns.mail.queue.FileSystemMailQueue.java
public FileSystemMailQueue(File directory) { this.queuedDirectory = new File(directory, "queue"); this.sentDirectory = new File(directory, "sent"); this.failedDirectory = new File(directory, "failed"); if (!ElementsFileUtils.ensureDirectoryExistsAndWritable(this.queuedDirectory)) { logger.warn("Directory does not exist or is not writable: {}", this.queuedDirectory); }// w w w.j av a 2 s. co m if (!ElementsFileUtils.ensureDirectoryExistsAndWritable(this.sentDirectory)) { logger.warn("Directory does not exist or is not writable: {}", this.sentDirectory); } if (!ElementsFileUtils.ensureDirectoryExistsAndWritable(this.failedDirectory)) { logger.warn("Directory does not exist or is not writable: {}", this.failedDirectory); } try { jaxbContext = JAXBContext.newInstance(Email.class, Recipient.class); } catch (JAXBException e) { throw new Error("Couldn't create jaxb context", e); } }
From source file:org.fcrepo.auth.roles.basic.BasicRolesPEP.java
@Override public boolean hasModeShapePermission(final Path absPath, final String[] actions, final Set<Principal> allPrincipals, final Principal userPrincipal) { final boolean newNode = false; Set<String> roles = null; try {//ww w. j a v a 2s. c om final Session session = sessionFactory.getInternalSession(); final Node realNode = findRealNode(absPath, session); log.debug("using real node: " + realNode); roles = this.getRoles(session, allPrincipals, realNode); log.debug("roles for this request: " + roles); } catch (final RepositoryException e) { throw new Error("Cannot look up node information on " + absPath + " for permissions check.", e); } if (clog.isDebugEnabled()) { final StringBuilder msg = new StringBuilder(); msg.append(roles.toString()).append("\t").append(Arrays.toString(actions)).append("\t") .append(newNode ? "NEW" : "OLD").append("\t") .append((absPath == null ? absPath : absPath.toString())); clog.debug(msg.toString()); if (actions.length > 1) { // have yet to see more than one clog.debug("FOUND MULTIPLE ACTIONS: " + Arrays.toString(actions)); } } if (roles.size() == 0) { log.debug("A caller without content roles can do nothing in the repository."); return false; } if (roles.contains("admin")) { log.debug("Granting an admin role permission to perform any action."); return true; } if (roles.contains("writer")) { if (absPath.toString().contains(AUTHZ_DETECTION)) { log.debug("Denying writer role permission to perform an action on an ACL node."); return false; } else { log.debug("Granting writer role permission to perform any action on a non-ACL nodes."); return true; } } if (roles.contains("reader")) { if (actions.length == 1 && "read".equals(actions[0])) { log.debug("Granting reader role permission to perform a read action."); return true; } else { log.debug("Denying reader role permission to perform a non-read action."); return false; } } log.error("There are roles in session that aren't recognized by this PEP: " + roles); return false; }
From source file:edu.unc.lib.dl.util.IngestProperties.java
/** * @throws IOException// w w w . j ava 2 s.co m * @throws FileNotFoundException * @throws ClassNotFoundException * */ private void load() throws Exception { if (log.isDebugEnabled()) { log.debug("loading ingest properties from " + this.propFile.getAbsolutePath()); } Properties props = new Properties(); try (FileInputStream in = new FileInputStream(propFile)) { props.load(in); } this.submitter = props.getProperty("submitter"); String submitterGroups = props.getProperty("submitterGroups"); if (submitterGroups != null) { this.submitterGroups = submitterGroups; } String er = props.getProperty("email.recipients"); if (er != null) { this.emailRecipients = er.split(","); } this.message = props.getProperty("message"); String bytes = props.getProperty("managedBytes"); if (bytes != null) { try { this.managedBytes = Long.parseLong(bytes); } catch (NumberFormatException e) { } } String subTime = props.getProperty("submissionTime"); if (subTime != null) { try { this.submissionTime = Long.parseLong(subTime); } catch (NumberFormatException e) { throw new Error("Unexpected submissionTime exception", e); } } String finTime = props.getProperty("finishedTime"); if (finTime != null) { try { this.finishedTime = Long.parseLong(finTime); } catch (NumberFormatException e) { throw new Error("Unexpected finishedTime exception", e); } } String stTime = props.getProperty("startTime"); if (stTime != null) { try { this.startTime = Long.parseLong(stTime); } catch (NumberFormatException e) { throw new Error("Unexpected startTime exception", e); } } this.originalDepositId = props.getProperty("originalDepositId"); this.containerPlacements = new HashMap<PID, ContainerPlacement>(); for (Entry<Object, Object> e : props.entrySet()) { String key = (String) e.getKey(); if (key.startsWith("placement")) { String s = (String) e.getValue(); String[] vals = s.split(","); ContainerPlacement p = new ContainerPlacement(); p.pid = new PID(vals[0]); p.parentPID = new PID(vals[1]); if (2 < vals.length && !"null".equals(vals[2])) { p.designatedOrder = Integer.parseInt(vals[2]); } if (3 < vals.length && !"null".equals(vals[3])) { p.sipOrder = Integer.parseInt(vals[3]); } if (4 < vals.length && !"null".equals(vals[4])) { p.label = vals[4]; } this.containerPlacements.put(p.pid, p); } } }
From source file:com.gargoylesoftware.htmlunit.gae.GAETestRunner.java
/** * Loads the white list./*from w ww . ja v a 2 s. com*/ * @return the list of classes in the white list */ private static Set<String> loadWhiteList() { final InputStream is = GAETestRunner.class.getResourceAsStream("whitelist.txt"); assertNotNull(is); final List<String> lines; try { lines = IOUtils.readLines(is); } catch (final IOException e) { throw new Error("Failed to load while list content", e); } finally { IOUtils.closeQuietly(is); } return new HashSet<>(lines); }
From source file:drm.taskworker.workers.OptimusWorker.java
private TaskResult start(File workdir, Task task) throws IOException, ParameterFoundException { String obj = (String) task.getParam(PRM_START_FILE); // FIXME only works with the adapted taskworker-client script (not committed) byte[] file = Base64.decodeBase64(obj); String method = (String) task.getParam(PRM_START_METHOD); File f = new File(workdir, "input.zip"); OutputStream out = new FileOutputStream(f); out.write(file);//from w w w .j a v a2 s .c o m out.close(); ProcessBuilder pb = new ProcessBuilder("python", task.getJobOption("optimus.exe"), "input.zip", method); pb.directory(workdir); Process handle = pb.start(); (new VoidStreamPump(handle.getInputStream())).start(); (new VoidStreamPump(handle.getErrorStream())).start(); handles.put(task.getJobId(), handle); // start looking for flag file File goFile = new File(workdir, task.getJobOption("optimus.flagfile.go")); while (!goFile.exists()) { try { Thread.sleep(1000); } catch (InterruptedException e) { throw new Error("should not occur", e); } } goFile.delete(); return split(workdir, task); }
From source file:edu.unc.lib.dl.util.JDOMXPathUtil.java
public static Map<String, String> getDCFields(Document doc) { HashMap<String, String> result = new HashMap<String, String>(); try {/*from w w w .j a va2 s .c o m*/ for (Object con : _dcFieldsXpath.selectNodes(doc)) { if (con instanceof Element) { Element el = (Element) con; String value = el.getTextTrim(); String name = el.getName(); result.put(name, value); } } } catch (JDOMException e) { throw new Error("Programming error, XPath should be valid", e); } return result; }
From source file:jenkins.security.RSAConfidentialKey.java
/** * Obtains the private key (lazily.)//from ww w.ja v a 2 s .c om * <p> * This method is not publicly exposed as per the design principle of {@link ConfidentialKey}. * Instead of exposing private key, define methods that use them in specific way, such as * {@link RSADigitalSignatureConfidentialKey}. * * @throws Error * If key cannot be loaded for some reasons, we fail. */ protected synchronized RSAPrivateKey getPrivateKey() { try { if (priv == null) { byte[] payload = load(); if (payload == null) { KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); gen.initialize(2048, new SecureRandom()); // going beyond 2048 requires crypto extension KeyPair keys = gen.generateKeyPair(); priv = (RSAPrivateKey) keys.getPrivate(); pub = (RSAPublicKey) keys.getPublic(); store(priv.getEncoded()); } else { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); priv = (RSAPrivateKey) keyFactory.generatePrivate(new PKCS8EncodedKeySpec(payload)); RSAPrivateCrtKey pks = (RSAPrivateCrtKey) priv; pub = (RSAPublicKey) keyFactory .generatePublic(new RSAPublicKeySpec(pks.getModulus(), pks.getPublicExponent())); } } return priv; } catch (IOException e) { throw new Error("Failed to load the key: " + getId(), e); } catch (GeneralSecurityException e) { throw new Error("Failed to load the key: " + getId(), e); } }