List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:nl.mpi.lamus.archive.implementation.LamusArchiveFileLocationProviderTest.java
@Test public void getRelativePath_ChildPathEqualsParentPath() { final File parentFile = new File(URI.create("file:/archive/path/parentdir/parent.cmdi")); final File childFile = new File(URI.create("file:/archive/path/parentdir/parent.cmdi")); final String expectedExceptionMessage = "Parent and child files should be different"; try {/*from w w w.ja v a2s.c om*/ archiveFileLocationProvider.getChildPathRelativeToParent(parentFile, childFile); fail("should have thrown exception"); } catch (IllegalStateException ex) { assertEquals("Exception message different from expected", expectedExceptionMessage, ex.getMessage()); } }
From source file:com.blackducksoftware.integration.hub.teamcity.agent.scan.HubBuildProcess.java
private ProjectRequest getProjectRequest(final IntLogger logger, final CIEnvironmentVariables commonVariables) { final ProjectRequestBuilder projectRequestBuilder = new ProjectRequestBuilder(); projectRequestBuilder.setProjectName(commonVariables.getValue(HubConstantValues.HUB_PROJECT_NAME)); projectRequestBuilder.setVersionName(commonVariables.getValue(HubConstantValues.HUB_PROJECT_VERSION)); projectRequestBuilder.setPhase(commonVariables.getValue(HubConstantValues.HUB_PHASE)); projectRequestBuilder.setDistribution(commonVariables.getValue(HubConstantValues.HUB_DISTRIBUTION)); projectRequestBuilder.setProjectLevelAdjustments( Boolean.valueOf(commonVariables.getValue(HubConstantValues.HUB_MATCH_ADJUSTMENTS))); try {/*from w w w. j av a 2 s .co m*/ return projectRequestBuilder.build(); } catch (final IllegalStateException e) { logger.error(e.getMessage(), e); } return null; }
From source file:com.evolveum.midpoint.repo.common.expression.Expression.java
private PrismValueDeltaSetTriple<V> evaluateExpressionEvaluators( ExpressionEvaluationContext contextWithProcessedVariables) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { for (ExpressionEvaluator<?, ?> evaluator : evaluators) { PrismValueDeltaSetTriple<V> outputTriple = (PrismValueDeltaSetTriple<V>) evaluator .evaluate(contextWithProcessedVariables); if (outputTriple != null) { boolean allowEmptyRealValues = false; if (expressionType != null) { allowEmptyRealValues = BooleanUtils.isTrue(expressionType.isAllowEmptyValues()); }/* w w w.j a v a 2 s. c o m*/ outputTriple.removeEmptyValues(allowEmptyRealValues); if (InternalsConfig.consistencyChecks) { try { outputTriple.checkConsistence(); } catch (IllegalStateException e) { throw new IllegalStateException( e.getMessage() + "; in expression " + this + ", evaluator " + evaluator, e); } } return outputTriple; } } return null; }
From source file:com.glodon.paas.document.api.AbstractDocumentAPITest.java
private String parseReponseToString(HttpResponse response) { InputStream content = null;/*from w w w .ja v a 2 s . c om*/ StringWriter writer = null; try { writer = new StringWriter(); content = response.getEntity().getContent(); IOUtils.copy(content, writer); return writer.toString(); } catch (IllegalStateException e) { logger.error(e.getMessage()); } catch (IOException e) { logger.error(e.getMessage()); } finally { IOUtils.closeQuietly(content); IOUtils.closeQuietly(writer); } return null; }
From source file:org.finra.herd.service.helper.TarHelperTest.java
@Test public void testValidateTarFileSize() throws IOException { // Create a test file. File testFile = createLocalFile(localTempPath.toString(), FILE_NAME, FILE_SIZE_1_KB); // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BOD_NAMESPACE, BOD_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);//from ww w. ja va 2s.c om // Validate the test file size. tarHelper.validateTarFileSize(testFile, FILE_SIZE_1_KB, STORAGE_NAME, businessObjectDataKey); // Try to validate the test file size when it is less than the total size of storage files. try { tarHelper.validateTarFileSize(testFile, FILE_SIZE_2_KB, STORAGE_NAME, businessObjectDataKey); fail("Should throw an IllegalStateException when the test file size is less than the total size of storage files."); } catch (IllegalStateException e) { assertEquals(String.format( "The \"%s\" TAR archive file size (%d bytes) is less than the total size of registered storage files (%d bytes). " + "Storage: {%s}, business object data: {%s}", testFile.getPath(), FILE_SIZE_1_KB, FILE_SIZE_2_KB, STORAGE_NAME, getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage()); } }
From source file:org.apache.geode.management.internal.cli.functions.RegionCreateFunction.java
@Override public void execute(FunctionContext context) { ResultSender<Object> resultSender = context.getResultSender(); Cache cache = context.getCache();/*from ww w.j ava2 s . c o m*/ String memberNameOrId = CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember()); RegionFunctionArgs regionCreateArgs = (RegionFunctionArgs) context.getArguments(); if (regionCreateArgs.isSkipIfExists()) { Region<Object, Object> region = cache.getRegion(regionCreateArgs.getRegionPath()); if (region != null) { resultSender.lastResult(new CliFunctionResult(memberNameOrId, true, CliStrings.format(CliStrings.CREATE_REGION__MSG__SKIPPING_0_REGION_PATH_1_ALREADY_EXISTS, memberNameOrId, regionCreateArgs.getRegionPath()))); return; } } try { Region<?, ?> createdRegion = createRegion(cache, regionCreateArgs); XmlEntity xmlEntity = new XmlEntity(CacheXml.REGION, "name", createdRegion.getName()); resultSender.lastResult(new CliFunctionResult(memberNameOrId, xmlEntity, CliStrings.format(CliStrings.CREATE_REGION__MSG__REGION_0_CREATED_ON_1, createdRegion.getFullPath(), memberNameOrId))); } catch (IllegalStateException e) { String exceptionMsg = e.getMessage(); String localizedString = LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString(); if (localizedString.equals(e.getMessage())) { exceptionMsg = exceptionMsg + " " + CliStrings.format(CliStrings.CREATE_REGION__MSG__USE_ONE_OF_THESE_SHORTCUTS_0, new Object[] { String.valueOf(RegionCommandsUtils.PERSISTENT_OVERFLOW_SHORTCUTS) }); } resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, null/* do not log */)); } catch (IllegalArgumentException | CreateSubregionException e) { resultSender.lastResult(handleException(memberNameOrId, e.getMessage(), e)); } catch (RegionExistsException e) { String exceptionMsg = CliStrings.format( CliStrings.CREATE_REGION__MSG__REGION_PATH_0_ALREADY_EXISTS_ON_1, regionCreateArgs.getRegionPath(), memberNameOrId); resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, e)); } catch (Exception e) { String exceptionMsg = e.getMessage(); if (exceptionMsg == null) { exceptionMsg = CliUtil.stackTraceAsString(e); } resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, e)); } }
From source file:com.almende.eve.state.file.ConcurrentJsonFileState.java
@Override public void clear() { try {//w ww . ja va2 s . com openFile(); properties.clear(); write(); } catch (final IllegalStateException e) { LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e); } catch (final Exception e) { LOG.log(Level.WARNING, "", e); } closeFile(); }
From source file:com.almende.eve.state.file.ConcurrentJsonFileState.java
@Override public Set<String> keySet() { Set<String> result = null; try {/*ww w.j av a 2 s.co m*/ openFile(); read(); result = new HashSet<String>(properties.keySet()); } catch (final IllegalStateException e) { LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e); } catch (final Exception e) { LOG.log(Level.WARNING, "", e); } closeFile(); return result; }
From source file:com.almende.eve.state.file.ConcurrentJsonFileState.java
@Override public boolean containsKey(final String key) { boolean result = false; try {/* w ww . j a v a 2s . c o m*/ openFile(); read(); result = properties.containsKey(key); } catch (final IllegalStateException e) { LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e); } catch (final Exception e) { LOG.log(Level.WARNING, "", e); } closeFile(); return result; }
From source file:com.almende.eve.state.file.ConcurrentJsonFileState.java
@Override @JsonIgnore//from w ww. j ava 2 s. c o m public JsonNode get(final String key) { JsonNode result = NullNode.getInstance(); try { openFile(); read(); result = properties.get(key); } catch (final IllegalStateException e) { LOG.log(Level.WARNING, "Couldn't handle Statefile: " + e.getMessage(), e); } catch (final Exception e) { LOG.log(Level.WARNING, "", e); } closeFile(); return result; }