List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:com.cws.esolutions.security.dao.certmgmt.impl.CertificateManagerImpl.java
/** * @see com.cws.esolutions.security.dao.certmgmt.interfaces.ICertificateManager#applyCertificateRequest(String, File, File, String) *//*w ww . j av a 2 s .co m*/ public synchronized boolean applyCertificateRequest(final String commonName, final File certificateFile, final File keystoreFile, final String storePassword) throws CertificateManagementException { final String methodName = ICertificateManager.CNAME + "#applyCertificateRequest(final String commonName, final File certificateFile, final File keystoreFile, final String storePassword) throws CertificateManagementException"; if (DEBUG) { DEBUGGER.debug(methodName); DEBUGGER.debug("Value: {}", commonName); DEBUGGER.debug("Value: {}", certificateFile); DEBUGGER.debug("Value: {}", keystoreFile); } final File rootDirectory = certConfig.getRootDirectory(); final File certificateDirectory = FileUtils .getFile(certConfig.getCertificateDirectory() + "/" + commonName); final File storeDirectory = FileUtils.getFile(certConfig.getStoreDirectory() + "/" + commonName); if (DEBUG) { DEBUGGER.debug("rootDirectory: {}", rootDirectory); DEBUGGER.debug("certificateDirectory: {}", certificateDirectory); DEBUGGER.debug("storeDirectory: {}", storeDirectory); DEBUGGER.debug("certificateFile: {}", certificateFile); DEBUGGER.debug("keystoreFile: {}", keystoreFile); } boolean isComplete = false; FileInputStream certStream = null; FileOutputStream storeStream = null; FileInputStream keystoreInput = null; FileInputStream rootCertStream = null; FileInputStream intermediateCertStream = null; try { if (!(rootDirectory.exists())) { throw new CertificateManagementException( "Root certificate directory either does not exist or cannot be written to. Cannot continue."); } if (!(rootDirectory.canWrite())) { throw new CertificateManagementException( "Root certificate directory either does not exist or cannot be written to. Cannot continue."); } if (!(certConfig.getRootCertificateFile().exists())) { throw new CertificateManagementException("Root certificate file does not exist. Cannot continue."); } if (!(certConfig.getIntermediateCertificateFile().exists())) { throw new CertificateManagementException( "Intermediate certificate file does not exist. Cannot continue."); } if (!(storeDirectory.canWrite())) { throw new CertificateManagementException( "Keystore directory either does not exist or cannot be written to. Cannot continue."); } if (!(keystoreFile.canWrite())) { throw new CertificateManagementException( "Unable to write to applicable keystore. Cannot continue."); } keystoreInput = FileUtils.openInputStream(keystoreFile); certStream = FileUtils.openInputStream(certificateFile); if (DEBUG) { DEBUGGER.debug("keystoreInput: {}", keystoreInput); DEBUGGER.debug("certStream: {}", certStream); } KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(keystoreInput, storePassword.toCharArray()); if (DEBUG) { DEBUGGER.debug("KeyStore: {}", keyStore); } Key privateKey = keyStore.getKey(commonName, storePassword.toCharArray()); CertificateFactory certFactory = CertificateFactory.getInstance(certConfig.getCertificateType()); if (DEBUG) { DEBUGGER.debug("CertificateFactory: {}", certFactory); } rootCertStream = FileUtils.openInputStream(FileUtils.getFile(certConfig.getRootCertificateFile())); intermediateCertStream = FileUtils .openInputStream(FileUtils.getFile(certConfig.getIntermediateCertificateFile())); if (DEBUG) { DEBUGGER.debug("rootCertStream: {}", rootCertStream); DEBUGGER.debug("intermediateCertStream: {}", intermediateCertStream); } X509Certificate[] responseCert = new X509Certificate[] { (X509Certificate) certFactory.generateCertificate(rootCertStream), (X509Certificate) certFactory.generateCertificate(intermediateCertStream), (X509Certificate) certFactory.generateCertificate(certStream) }; if (DEBUG) { DEBUGGER.debug("X509Certificate[]", (Object) responseCert); } storeStream = FileUtils.openOutputStream(keystoreFile); keyStore.setKeyEntry(commonName, privateKey, storePassword.toCharArray(), responseCert); keyStore.store(storeStream, storePassword.toCharArray()); isComplete = true; } catch (FileNotFoundException fnfx) { throw new CertificateManagementException(fnfx.getMessage(), fnfx); } catch (IOException iox) { throw new CertificateManagementException(iox.getMessage(), iox); } catch (NoSuchAlgorithmException nsax) { throw new CertificateManagementException(nsax.getMessage(), nsax); } catch (IllegalStateException isx) { throw new CertificateManagementException(isx.getMessage(), isx); } catch (KeyStoreException ksx) { throw new CertificateManagementException(ksx.getMessage(), ksx); } catch (CertificateException cx) { throw new CertificateManagementException(cx.getMessage(), cx); } catch (UnrecoverableKeyException ukx) { throw new CertificateManagementException(ukx.getMessage(), ukx); } finally { if (storeStream != null) { IOUtils.closeQuietly(storeStream); } if (intermediateCertStream != null) { IOUtils.closeQuietly(intermediateCertStream); } if (rootCertStream != null) { IOUtils.closeQuietly(rootCertStream); } if (certStream != null) { IOUtils.closeQuietly(certStream); } if (keystoreInput != null) { IOUtils.closeQuietly(keystoreInput); } } return isComplete; }
From source file:org.finra.herd.service.helper.notification.BusinessObjectFormatVersionChangeMessageBuilderTest.java
@Test public void testBuildBusinessObjectFormatVersionChangeMessagesJsonPayloadNoMessageType() throws Exception { // Create a business object format key. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION); // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity.setKey(//from w w w .ja va 2s . c o m ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions( Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { businessObjectFormatVersionChangeMessageBuilder.buildNotificationMessages( new BusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, FORMAT_VERSION_2.toString())); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.eclipse.gyrex.http.application.Application.java
/** * Called by the platform to initialize the application. * <p>/*ww w.j av a 2s.co m*/ * This implementations remembers the {@link IApplicationContext} and then * calls {@link #doInit()}. Subclasses may override {@link #doInit()}. * </p> * * @param applicationContext * the application context. * @throws Exception * in case of unrecoverable initialization failures * @noreference This method is not intended to be referenced by clients. */ public final void initialize(final IApplicationContext applicationContext) throws Exception { if (null == applicationContext) { throw new IllegalArgumentException("application context must not be null"); } this.applicationContext.set(applicationContext); try { LOG.info("Starting HTTP application {}...", getId()); final long started = System.currentTimeMillis(); doInit(); final long finished = System.currentTimeMillis(); initTimestamp.set(finished); LOG.info("Finished starting HTTP application {} (in {}).", getId(), toFormattedDuration(finished - started)); } catch (final IllegalStateException e) { // log a warning LOG.warn("Unable to initialize application {} at this time ({}). Will retry at next opportunity.", new Object[] { getId(), e.getMessage(), e }); // and deferred initialization initTimestamp.set(0); } catch (final Exception e) { // log error LOG.error("Unable to initialize application {} due to unrecoverable error. {}", new Object[] { getId(), ExceptionUtils.getRootCauseMessage(e), e }); // and re-throw (wrapped into a core exception) if (e instanceof CoreException) { throw e; } throw new CoreException(new Status(IStatus.ERROR, HttpActivator.SYMBOLIC_NAME, String.format( "Error while initializing applicaion %s. %s", id, ExceptionUtils.getRootCauseMessage(e)), e)); } }
From source file:org.finra.herd.service.helper.notification.BusinessObjectFormatVersionChangeMessageBuilderTest.java
@Test public void testBuildBusinessObjectFormatVersionChangeMessagesJsonPayloadNoMessageDestination() throws Exception { // Create a business object format key. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION); // Override configuration. ConfigurationEntity configurationEntity = new ConfigurationEntity(); configurationEntity.setKey(/* w w w. j a va 2s .c o m*/ ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()); configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections .singletonList(new NotificationMessageDefinition(MESSAGE_TYPE_SNS, NO_MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); // Try to build a notification message. try { businessObjectFormatVersionChangeMessageBuilder.buildNotificationMessages( new BusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, FORMAT_VERSION_2.toString())); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS .getKey()), e.getMessage()); } }
From source file:org.metaborg.intellij.idea.parsing.SpoofaxSyntaxHighlighterFactory.java
/** * Gets the syntax highlighter for the specified project and file. * * @param project The project./*ww w.java 2 s. co m*/ * @param virtualFile The file. * @return The syntax highlighter. */ @Override public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) { @Nullable ILanguageImpl implementation = null; @Nullable final FileObject file = this.resourceService.resolve(virtualFile); if (file != null) { try { implementation = this.identifierService.identify(file); } catch (IllegalStateException ex) { // Multiple possible languages identified // (e.g. when different languages have the same extension, // such as TypeScript and TS both having .ts extension) // TODO: Better error message, // but to do that the exception needs to have its own class (derived from IllegalStateException) // that contains a list of languages. Notification notification = NotificationUtils.METABORG_NOTIFICATIONS .createNotification(ex.getMessage(), NotificationType.ERROR); NotificationUtils.INSTANCE.notify(project, notification); implementation = null; } } else if (virtualFile instanceof LightVirtualFile) { final com.intellij.lang.Language ideaLanguage = ((LightVirtualFile) virtualFile).getLanguage(); if (ideaLanguage instanceof MetaborgIdeaLanguage) { final ILanguage language = this.languageManager.getLanguage((MetaborgIdeaLanguage) ideaLanguage); implementation = language.activeImpl(); } } if (implementation == null) { // We don't know the language, so // let's return the plain syntax highlighter instead. return new PlainSyntaxHighlighter(); } @Nullable final IProject metaborgProject = null; // FIXME: Get IProject from Project final SpoofaxTokenTypeManager tokenTypesManager = this.bindingManager .getTokenTypeManager(implementation.belongsTo()); final Lexer lexer = this.highlightingLexerFactory.create(file, metaborgProject, implementation, tokenTypesManager); return new SpoofaxSyntaxHighlighter(lexer); }
From source file:org.finra.herd.service.helper.StorageFileHelperTest.java
@Test public void testValidateRegisteredS3FilesUnexpectedNonEmptyS3FileFound() throws IOException { // Create two lists of expected and actual storage files, with an actual file not being added to the list of expected files. List<StorageFile> testExpectedFiles = new ArrayList<>(); List<S3ObjectSummary> testActualFiles = Collections .singletonList(createS3ObjectSummary(TARGET_S3_KEY, FILE_SIZE_1_KB)); // Create a business object data key. BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);/* ww w .jav a 2 s.c o m*/ // Try to validate S3 files when unexpected non-empty S3 file exists. // The validation is expected to fail when detecting an unregistered non-empty S3 file. try { storageFileHelper.validateRegisteredS3Files(testExpectedFiles, testActualFiles, STORAGE_NAME, businessObjectDataKey); fail(); } catch (IllegalStateException e) { assertEquals(String.format( "Found unregistered non-empty S3 file \"%s\" in \"%s\" storage. Business object data {%s}", TARGET_S3_KEY, STORAGE_NAME, businessObjectDataServiceTestHelper .getExpectedBusinessObjectDataKeyAsString(businessObjectDataKey)), e.getMessage()); } }
From source file:com.SecUpwN.AIMSICD.activities.MapViewerOsmDroid.java
/** * Description: Loads Signal Strength Database details to plot on the map, * only entries which have a location (lon, lat) are used. * * *///from www . j a v a2 s .co m private void loadEntries() { new AsyncTask<Void, Void, GeoPoint>() { @Override protected GeoPoint doInBackground(Void... voids) { final int SIGNAL_SIZE_RATIO = 15; // A scale factor to draw BTS Signal circles int signal; mCellTowerGridMarkerClusterer.getItems().clear(); loadOpenCellIDMarkers(); LinkedList<CellTowerMarker> items = new LinkedList<>(); mDbHelper.open(); Cursor c = null; try { // Grab cell data from CELL_TABLE (cellinfo) --> DBi_bts c = mDbHelper.getCellData(); } catch (IllegalStateException ix) { Log.e(TAG, ix.getMessage(), ix); } if (c != null && c.moveToFirst()) { do { // The indexing here is that of the Cursor and not the DB table itself final int cellID = c.getInt(0); // CID final int lac = c.getInt(1); // LAC final int net = c.getInt(2); // RAT final int mcc = c.getInt(6); // MCC final int mnc = c.getInt(7); // MNC final double dlat = Double.parseDouble(c.getString(3)); // Lat final double dlng = Double.parseDouble(c.getString(4)); // Lon if (dlat == 0.0 && dlng == 0.0) { continue; } signal = c.getInt(5); // signal // In case of missing or negative signal, set a default fake signal, // so that we can still draw signal circles. ? if (signal <= 0) { signal = 20; } if ((dlat != 0.0) || (dlng != 0.0)) { loc = new GeoPoint(dlat, dlng); CellTowerMarker ovm = new CellTowerMarker(mContext, mMap, "Cell ID: " + cellID, "", loc, new MarkerData("" + cellID, "" + loc.getLatitude(), "" + loc.getLongitude(), "" + lac, "" + mcc, "" + mnc, "", false)); // The pin of our current position ovm.setIcon(getResources().getDrawable(R.drawable.ic_map_pin_blue)); items.add(ovm); } } while (c.moveToNext()); } else { runOnUiThread(new Runnable() { @Override public void run() { Helpers.msgLong(MapViewerOsmDroid.this, getString(R.string.no_tracked_locations_found)); } }); } GeoPoint ret = new GeoPoint(0, 0); if (mBound) { try { int mcc = mAimsicdService.getCell().getMCC(); double[] d = mDbHelper.getDefaultLocation(mcc); ret = new GeoPoint(d[0], d[1]); } catch (Exception e) { Log.e("map", "Error getting default location!", e); } } if (c != null && !c.isClosed()) { c.close(); } mDbHelper.close(); // plot neighbouring cells while (mAimsicdService == null) try { Thread.sleep(100); } catch (Exception e) { } List<Cell> nc = mAimsicdService.getCellTracker().updateNeighbouringCells(); for (Cell cell : nc) { try { loc = new GeoPoint(cell.getLat(), cell.getLon()); CellTowerMarker ovm = new CellTowerMarker(mContext, mMap, getString(R.string.cell_id_label) + cell.getCID(), "", loc, new MarkerData("" + cell.getCID(), "" + loc.getLatitude(), "" + loc.getLongitude(), "" + cell.getLAC(), "" + cell.getMCC(), "" + cell.getMNC(), "", false)); // The pin of other BTS ovm.setIcon(getResources().getDrawable(R.drawable.ic_map_pin_orange)); items.add(ovm); } catch (Exception e) { Log.e("map", "Error plotting neighbouring cells", e); } } mCellTowerGridMarkerClusterer.addAll(items); return ret; } /** * TODO: We need a manual way to add our own location in case: * a) GPS is jammed or not working * b) WiFi location is not used * c) Default MCC is too far off * * @param defaultLoc */ @Override protected void onPostExecute(GeoPoint defaultLoc) { if (loc != null && (loc.getLatitude() != 0.0 && loc.getLongitude() != 0.0)) { mMap.getController().setZoom(16); mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); } else { if (mBound) { // Try and find last known location and zoom there GeoLocation lastLoc = mAimsicdService.lastKnownLocation(); if (lastLoc != null) { loc = new GeoPoint(lastLoc.getLatitudeInDegrees(), lastLoc.getLongitudeInDegrees()); mMap.getController().setZoom(16); mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); } else { //Use MCC to move camera to an approximate location near Countries Capital loc = defaultLoc; mMap.getController().setZoom(12); mMap.getController().animateTo(new GeoPoint(loc.getLatitude(), loc.getLongitude())); } } } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:org.alfresco.bm.test.TestRun.java
/** * Called to forcibly stop all executing test runs *//*from w w w.j a v a 2 s . co m*/ public synchronized void stop() { // Check the application context if (testRunCtx == null) { // There is nothing to do, the context is not available return; } // INFO logging as this is a critical part of the whole application if (logger.isInfoEnabled()) { logger.info("Stopping test run application context: " + id); } try { DBObject runObj = getRunObj(false); if (runObj != null) { ObjectId runObjId = (ObjectId) runObj.get(FIELD_ID); // Unregister the driver from the test run testDAO.removeTestRunDriver(runObjId, driverId); } boolean active = testRunCtx.isActive(); // Stop the context try { testRunCtx.stop(); } catch (IllegalStateException e) { // Ignore if we didn't have a functioning context to start with if (active) { logger.error("Unable to stop test run context: " + e.getMessage()); } } // Close down completely try { testRunCtx.close(); } catch (IllegalStateException e) { // Ignore if we didn't have a functioning context to start with if (active) { logger.error("Unable to close test run context: " + e.getMessage()); } } } catch (Exception e) { // There is little more that we can except report that the child ctx did not shut down logger.error("Test run application context did not shut down cleanly: \n" + id, e); } finally { testRunCtx = null; } // Log the successful shutdown logService.log(driverId, test, run, LogLevel.INFO, "Successful shutdown of test run '" + test + "." + run + "'."); }
From source file:com.feilong.servlet.http.RequestLogBuilder.java
/** * ?./*from ww w .ja v a2 s . co m*/ * * <p> * ?log, Cannot create a session after the response has been committed <br> * * </p> * * <p> * I have learnt that maybe my 8K buffer gets full in some cases (as you said, my contect is dynamic and sometimes could be large). <br> * * In that case, I have understanded that a full buffer triggers a commit, and when that happens the JSP error page can not do its job * and then "java.lang.IllegalStateException: Cannot create a session after the response has been committed" happens. <br> * * OK, but is there any other possible reason for the early commit? <br> * My session is created early enough, and in fact the JSP page creates it if necessary, by default. * </p> * * @return the session id,, {@link java.lang.Throwable#getMessage()} * @since 1.4.1 */ private String getSessionId() { try { HttpSession session = request.getSession(false); return null == session ? EMPTY : session.getId(); } catch (IllegalStateException e) {//Cannot create a session after the response has been committed String msg = Slf4jUtil.format("uri:[{}],paramMap:{}", request.getRequestURI(), request.getParameterMap()); LOGGER.error(msg, e); return e.getMessage(); } }
From source file:co.taqat.call.StatusFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.status, container, false); statusText = (TextView) view.findViewById(R.id.status_text); statusLed = (ImageView) view.findViewById(R.id.status_led); callQuality = (ImageView) view.findViewById(R.id.call_quality); encryption = (ImageView) view.findViewById(R.id.encryption); menu = (ImageView) view.findViewById(R.id.side_menu_button); voicemail = (ImageView) view.findViewById(R.id.voicemail); voicemailCount = (TextView) view.findViewById(R.id.voicemail_count); // We create it once to not delay the first display populateSliderContent();//from w w w.ja v a 2 s . c o m mListener = new LinphoneCoreListenerBase() { @Override public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig proxy, final LinphoneCore.RegistrationState state, String smessage) { if (!isAttached || !LinphoneService.isReady()) { return; } if (lc.getProxyConfigList() == null) { statusLed.setImageResource(R.drawable.led_disconnected); statusText.setText(getString(R.string.no_account)); } else { statusLed.setVisibility(View.VISIBLE); } if (lc.getDefaultProxyConfig() != null && lc.getDefaultProxyConfig().equals(proxy)) { statusLed.setImageResource(getStatusIconResource(state, true)); statusText.setText(getStatusIconText(state)); } else if (lc.getDefaultProxyConfig() == null) { statusLed.setImageResource(getStatusIconResource(state, true)); statusText.setText(getStatusIconText(state)); } try { statusText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!isInCall) { lc.refreshRegisters(); /*try { Thread.sleep(2000); } catch (InterruptedException e) { Log.e("Cannot sleep for 2s", e); }*/ } } }); } catch (IllegalStateException ise) { Log.e("ReRegisteration ERROR : ", ise.getMessage()); } } @Override public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content) { if (!content.getType().equals("application")) return; if (!content.getSubtype().equals("simple-message-summary")) return; if (content.getData() == null) return; int unreadCount = -1; String data = content.getDataAsString(); String[] voiceMail = data.split("voice-message: "); final String[] intToParse = voiceMail[1].split("/", 0); unreadCount = Integer.parseInt(intToParse[0]); if (unreadCount > 0) { voicemailCount.setText(unreadCount); voicemail.setVisibility(View.VISIBLE); voicemailCount.setVisibility(View.VISIBLE); } else { voicemail.setVisibility(View.GONE); voicemailCount.setVisibility(View.GONE); } } }; isAttached = true; Activity activity = getActivity(); if (activity instanceof LinphoneActivity) { ((LinphoneActivity) activity).updateStatusFragment(this); isInCall = false; } else if (activity instanceof CallActivity) { ((CallActivity) activity).updateStatusFragment(this); isInCall = true; } else if (activity instanceof AssistantActivity) { ((AssistantActivity) activity).updateStatusFragment(this); isInCall = false; } return view; }