List of usage examples for java.lang IllegalStateException IllegalStateException
public IllegalStateException(Throwable cause)
From source file:Strings.java
public static String getMD5(String source) { byte[] bytes; try {/*from w w w .jav a2s. c om*/ bytes = source.getBytes("UTF-8"); } catch (java.io.UnsupportedEncodingException ue) { throw new IllegalStateException(ue); } byte[] result; synchronized (MESSAGE_DIGEST) { MESSAGE_DIGEST.update(bytes); result = MESSAGE_DIGEST.digest(); } char[] resChars = new char[32]; int len = result.length; for (int i = 0; i < len; i++) { byte b = result[i]; int lo4 = b & 0x0F; int hi4 = (b & 0xF0) >> 4; resChars[i * 2] = HEX_CHARS.charAt(hi4); resChars[i * 2 + 1] = HEX_CHARS.charAt(lo4); } return new String(resChars); }
From source file:org.kordamp.javatrove.example01.TestHelper.java
public static String repositoriesAsJSON(Collection<Repository> repositories, ObjectMapper objectMapper) { StringWriter writer = new StringWriter(); try {// w ww . j ava2 s . c o m objectMapper.writeValue(writer, repositories); } catch (IOException e) { throw new IllegalStateException(e); } return writer.toString(); }
From source file:com.ebay.logstorm.server.utils.LogStormServerDebug.java
private static File findAssemblyJarFile() { String projectRootDir = System.getProperty("user.dir"); String assemblyModuleTargeDirPath = projectRootDir + "/assembly/target/"; File assemblyTargeDirFile = new File(assemblyModuleTargeDirPath); if (!assemblyTargeDirFile.exists()) { throw new IllegalStateException( assemblyModuleTargeDirPath + " not found, please execute 'mvn install -DskipTests' under " + projectRootDir + " to build the project firstly and retry"); }//from ww w .jav a 2 s. c o m String jarFileNameWildCard = "logstorm-assembly-*.jar"; Collection<File> jarFiles = FileUtils.listFiles(assemblyTargeDirFile, new WildcardFileFilter(jarFileNameWildCard), TrueFileFilter.INSTANCE); if (jarFiles.size() == 0) { throw new IllegalStateException( "jar is not found, please execute 'mvn install -DskipTests' from project root firstly and retry"); } File jarFile = jarFiles.iterator().next(); LOG.debug("Found pipeline.jar: {}", jarFile.getAbsolutePath()); return jarFile; }
From source file:com.genericworkflownodes.knime.workflowexporter.export.KnimeWorkflowExporterProvider.java
/** * Initializes the instance. This method is to be called only once!. * /*from w w w. ja v a2 s .c o m*/ * @param availableExporters * The available exporters. */ public static void initInstance(final Collection<KnimeWorkflowExporter> availableExporters) { LOCK.lock(); try { if (INSTANCE != null) { throw new IllegalStateException("INSTANCE has already been initialized."); } INSTANCE = new KnimeWorkflowExporterProvider(availableExporters); } finally { LOCK.unlock(); } }
From source file:org.hawkular.alerts.api.json.JsonUtil.java
public static String toJson(Object resource) { try {/*from w w w . j a va 2 s . co m*/ return instance.mapper.writeValueAsString(resource); } catch (JsonProcessingException e) { throw new IllegalStateException(e); } }
From source file:eu.freme.broker.security.tools.PasswordHasher.java
public static boolean check(String password, String stored) throws Exception { String[] saltAndPass = stored.split("\\$"); if (saltAndPass.length != 2) { throw new IllegalStateException("The stored password have the form 'salt$hash'"); }/* ww w . j a va2 s. c o m*/ String hashOfInput = hash(password, Base64.decodeBase64(saltAndPass[0])); return hashOfInput.equals(saltAndPass[1]); }
From source file:Main.java
public static Element getChildByName(Element paramElement, String paramString) { Element[] arrayOfElement = getChildrenByName(paramElement, paramString); if (arrayOfElement.length == 0) return null; if (arrayOfElement.length > 1) throw new IllegalStateException( "Too many (" + arrayOfElement.length + ") '" + paramString + "' elements found!"); return arrayOfElement[0]; }
From source file:com.ejisto.util.ContainerUtils.java
public static String extractAgentJar(String classPath) { String systemProperty = System.getProperty("ejisto.agent.jar.path"); if (StringUtils.isNotBlank(systemProperty)) { return systemProperty; }//from ww w . ja v a 2 s. c o m final Optional<String> agentPath = Arrays.stream(classPath.split(Pattern.quote(File.pathSeparator))) .filter(e -> AGENT_JAR.matcher(e).matches()).findFirst(); if (agentPath.isPresent()) { return Paths.get(System.getProperty("user.dir"), agentPath.get()).toString(); } throw new IllegalStateException("unable to find agent jar"); }
From source file:cz.cas.lib.proarc.authentication.Authenticators.java
public static Authenticators getInstance() { if (INSTANCE == null) { throw new IllegalStateException("set instance first!"); }//from w w w.j a va2s . co m return INSTANCE; }
From source file:com.ebay.logstorm.core.utils.PipelineEnvironmentLoaderForTest.java
private static File findAssemblyJarFile(String relativeToHomePath) { String projectRootDir = System.getProperty("user.dir"); String assemblyModuleTargeDirPath = relativeToHomePath == null ? projectRootDir + "/assembly/target/" : projectRootDir + relativeToHomePath + "/assembly/target/"; File assemblyTargeDirFile = new File(assemblyModuleTargeDirPath); if (!assemblyTargeDirFile.exists()) { throw new IllegalStateException( assemblyModuleTargeDirPath + " not found, please execute 'mvn install -DskipTests' under " + projectRootDir + " to build the project firstly and retry"); }//w w w . jav a 2s . com String jarFileNameWildCard = "logstorm-assembly-*.jar"; Collection<File> jarFiles = FileUtils.listFiles(assemblyTargeDirFile, new WildcardFileFilter(jarFileNameWildCard), TrueFileFilter.INSTANCE); if (jarFiles.size() == 0) { throw new IllegalStateException( "jar is not found, please execute 'mvn install -DskipTests' from project root firstly and retry"); } File jarFile = jarFiles.iterator().next(); LOG.debug("Found pipeline.jar: {}", jarFile.getAbsolutePath()); return jarFile; }