List of usage examples for java.lang IllegalStateException IllegalStateException
public IllegalStateException(String message, Throwable cause)
From source file:com.github.jcustenborder.kafka.connect.salesforce.TestData.java
License:asdf
public static JsonNode salesForceEvent() { try (InputStream inputStream = TestData.class.getResourceAsStream("salesforceevent.json")) { return objectMapper.readTree(inputStream); } catch (IOException ex) { throw new IllegalStateException("Could not read", ex); }/*www . j av a 2 s. c om*/ }
From source file:com.mani.cucumber.ReflectionUtils.java
public static <T> Class<T> loadClass(ClassLoader classloader, String name) { try {//w ww .ja va 2s . co m @SuppressWarnings("unchecked") Class<T> loaded = (Class<T>) classloader.loadClass(name); return loaded; } catch (ClassNotFoundException exception) { throw new IllegalStateException("Cannot find class " + name, exception); } }
From source file:eu.peppol.document.PayloadDigestCalculator.java
public static MessageDigestResult calcDigest(String algorithm, StandardBusinessDocumentHeader sbdh, InputStream inputStream) { MessageDigest messageDigest;/*from www .j a va2 s.co m*/ try { messageDigest = MessageDigest.getInstance(algorithm); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException( "Unknown digest algorithm " + OxalisConstant.DEFAULT_DIGEST_ALGORITHM + " " + e.getMessage(), e); } InputStream inputStreamToCalculateDigestFrom = null; ManifestItem manifestItem = SbdhFastParser.searchForAsicManifestItem(sbdh); if (manifestItem != null) { // creates an FilterInputStream, which will extract the ASiC in binary format. inputStreamToCalculateDigestFrom = new Base64InputStream(new AsicFilterInputStream(inputStream)); } else inputStreamToCalculateDigestFrom = inputStream; DigestInputStream digestInputStream = new DigestInputStream( new BufferedInputStream(inputStreamToCalculateDigestFrom), messageDigest); try { IOUtils.copy(digestInputStream, new NullOutputStream()); } catch (IOException e) { throw new IllegalStateException("Unable to calculate digest for payload"); } return new MessageDigestResult(messageDigest.digest(), messageDigest.getAlgorithm()); }
From source file:io.github.seiferma.jameica.hibiscus.dkb.creditcard.account.DKBScraperAccountProperties.java
public static Integer getMaxMonthInPast(Konto k) { String propertyValue = getMetaDataNumber(PROP_MAX_MONTH_IN_PAST, k); if (StringUtils.isEmpty(propertyValue)) { return PROP_MAX_MONTH_IN_PAST_DEFAULT; }// w w w . j av a 2 s . c o m try { return Integer.parseInt(propertyValue); } catch (NumberFormatException e) { throw new IllegalStateException(String.format( "The maximum value for the months to go back for account \"%s\" is invalid.", k.toString()), e); } }
From source file:com.basho.riak.client.api.convert.reflection.ClassUtil.java
public static <T> Object getFieldValue(Field f, T obj) { Object value = null;/*ww w . j a va 2 s .com*/ try { value = f.get(obj); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to get Riak annotated field value", e); } return value; }
From source file:Main.java
private static DocumentBuilder createDocumentBuilder() { try {//w w w. j av a2 s . c o m return DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new IllegalStateException("Cannot create document builder", e); } }
From source file:net.javacrumbs.smock.axis2.server.SmockServer.java
public static ConfigurationContext createConfigurationContextFromResource(Resource axis2Repository) { try {/*from w w w .j av a2 s. co m*/ Assert.notNull(axis2Repository, "axis2Repository can not be null"); return ConfigurationContextFactory .createConfigurationContextFromFileSystem(axis2Repository.getFile().getAbsolutePath()); } catch (Exception e) { throw new IllegalStateException("Can not load Axis2 repository.", e); } }
From source file:org.gvnix.web.menu.roo.addon.util.XmlUtils.java
/** * Parses and build Document from the given path to XML file * /* w w w. j av a2 s.c o m*/ * @param is InputStream to parse * @return XML Document. Null if file doesn't exist or there is any problem * parsing file */ public static Document parseFile(InputStream is) { Document doc = null; try { doc = org.springframework.roo.support.util.XmlUtils.getDocumentBuilder().parse(is); } catch (Exception e) { throw new IllegalStateException("Error parsing XML", e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { logger.severe(e.getMessage()); } } } return doc; }
From source file:Main.java
/** * Initializes the Cipher for use.//from w w w . j a va2 s.c o m */ public static void initCipher(Cipher cipher, int mode, SecretKey secretKey, AlgorithmParameterSpec parameterSpec) { try { if (parameterSpec != null) { cipher.init(mode, secretKey, parameterSpec); } else { cipher.init(mode, secretKey); } } catch (InvalidKeyException e) { throw new IllegalArgumentException("Unable to initialize due to invalid secret key", e); } catch (InvalidAlgorithmParameterException e) { throw new IllegalStateException("Unable to initialize due to invalid decryption parameter spec", e); } }
From source file:com.alibaba.openapi.client.util.SignatureUtil.java
public static byte[] hmacSha1(byte[] data, SecretKeySpec signingKey) { Mac mac = null;/*from w ww. ja v a2 s. co m*/ try { mac = Mac.getInstance(HMAC_SHA1); mac.init(signingKey); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e.getMessage(), e); } catch (InvalidKeyException e) { throw new IllegalStateException(e.getMessage(), e); } return mac.doFinal(data); }