List of usage examples for java.lang ClassCastException getMessage
public String getMessage()
From source file:com.ottogroup.bi.asap.pipeline.MicroPipelineFactory.java
/** * Returns the {@link MessageWaitStrategy} according to the provided configuration * @param configuration//w w w . jav a2 s.co m * @return * @throws RequiredInputMissingException * @throws UnknownComponentException * @throws ComponentInstantiationFailedException */ protected MessageWaitStrategy getMessageWaitStrategy(final MessageWaitStrategyConfiguration configuration, final Mailbox mailbox) throws RequiredInputMissingException, ComponentInstantiationFailedException, UnknownComponentException { ///////////////////////////////////////////////////////////// // validate mailbox if (mailbox == null) throw new RequiredInputMissingException("Missing required mailbox reference"); // ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// // if no configuration is provided, use default setting - which is by far the worst solution ;-) if (configuration == null) { YieldMessageWaitStrategy strategy = new YieldMessageWaitStrategy(); strategy.setId("waitStrategy-#" + System.currentTimeMillis()); strategy.setMailbox(mailbox); return strategy; } // ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// // validate input if (StringUtils.isBlank(configuration.getId())) throw new RequiredInputMissingException("Missing required strategy id"); if (StringUtils.isBlank(configuration.getName())) throw new RequiredInputMissingException("Missing required strategy name"); if (StringUtils.isBlank(configuration.getVersion())) throw new RequiredInputMissingException("Missing required strategy version"); // ///////////////////////////////////////////////////////////// try { return (MessageWaitStrategy) componentRepository.newInstance(configuration.getId(), configuration.getName(), configuration.getVersion(), configuration.getSettings()); } catch (ClassCastException e) { throw new ComponentInstantiationFailedException( "Failed to convert retrieved instance to mailbox representation. Error: " + e.getMessage()); } }
From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.TemplateListPage.java
private SelectionAdapter onBrowseClicked() { return new SelectionAdapter() { @Override/*from w ww. j av a 2s.c o m*/ public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); if (StringUtils.isNotBlank(model.getLocalTemplateFileName())) { File file = new File(model.getLocalTemplateFileName()); dialog.setFilterPath(file.getParentFile().getAbsolutePath()); } String file = null; do { file = dialog.open(); if (file != null) { try { model.setLocalTemplateFileName(file); return; } catch (ClassCastException ex) { IStatus status = ValidationStatus.error(ex.getMessage(), ex); OpenShiftUIActivator.getDefault().getLogger().logStatus(status); ErrorDialog.openError(getShell(), "Template Error", NLS.bind("The file \"{0}\" is not an OpenShift template.", file), status); } catch (UnsupportedVersionException ex) { IStatus status = ValidationStatus.error(ex.getMessage(), ex); OpenShiftUIActivator.getDefault().getLogger().logStatus(status); ErrorDialog.openError(getShell(), "Template Error", NLS.bind("The file \"{0}\" is a template in a version that we do not support.", file), status); } catch (OpenShiftException ex) { IStatus status = ValidationStatus.error(ex.getMessage(), ex); OpenShiftUIActivator.getDefault().getLogger().logStatus(status); ErrorDialog.openError(getShell(), "Template Error", NLS.bind("Unable to read and/or parse the file \"{0}\" as a template.", file), status); } } } while (file != null); } }; }
From source file:illab.nabal.proxy.WeiboContext.java
/** * Restore session data from persistent storage. * //from w w w . j ava 2s .com * @return true if successfully restored from persistent storage * @throws Exception */ protected boolean restoreSession() throws Exception { // no need to restore session if this session is covert op if (mIsCovertOp == true) { return false; } // restore session synchronized (mAccessToken) { if (StringHelper.isEmpty(mAlias) == false) { Log.i(TAG, "trying to restore session data from storage" + " for agent " + mAlias + " ..."); } else { Log.i(TAG, "trying to restore session data from storage..."); } try { // get a map from shared preferences file stored in persistent storage Map<String, String> map = getPrefMap(); for (String key : map.keySet()) { // assign values to variables read from storage String value = (String) map.get(key); if (ACCESS_TOKEN.equals(key) == true) { mAccessToken = value; } else if (EXPIRES_IN.equals(key) == true) { mExpiresIn = value; } else if (REMIND_IN.equals(key) == true) { mRemindIn = value; } else if (UID.equals(key) == true) { mUid = value; } } // check integrity if (StringHelper.isAllFull(mAccessToken, mExpiresIn, mRemindIn, mUid) == true) { Log.i(TAG, "successfully restored session data."); Log.i(TAG, "###############################"); Log.i(TAG, "mAccessToken : " + mAccessToken); Log.i(TAG, "mExpiresIn : " + mExpiresIn); Log.i(TAG, "mRemindIn : " + mRemindIn); Log.i(TAG, "mUid : " + mUid); Log.i(TAG, "###############################"); return true; } } catch (ClassCastException e) { Log.e(TAG, e.getMessage()); } // make sure empty session data if failed to restore Log.i(TAG, "failed to restore session data."); purgeSession(); return false; } }
From source file:arun.com.chromer.webheads.ui.views.BaseWebHead.java
@Nullable private Drawable getFaviconDrawable() { try {// w w w . j a v a2 s . c om TransitionDrawable drawable = (TransitionDrawable) favicon.getDrawable(); if (drawable != null) { return drawable.getDrawable(1); } else return null; } catch (ClassCastException e) { Timber.e("Error while getting favicon drawable: %s", e.getMessage()); } return null; }
From source file:org.elasticdroid.SshConnectorView.java
/** * Process results returned by SecurityGroupsModel. * // ww w . jav a2s. c o m * @param Result: Result produced by the AsyncTask model. */ @SuppressWarnings("unchecked") @Override public void processModelResults(Object result) { // dismiss the progress dialog if displayed. Check redundant if (progressDialogDisplayed) { progressDialogDisplayed = false; removeDialog(DialogConstants.PROGRESS_DIALOG.ordinal()); } //handle return of securityGroupsModel //if this fails, just return the user back to the parent activity (EC2SingleInstanceView) if (securityGroupsModel != null) { securityGroupsModel = null; //set the model to null. it's usefulness is done. //handle result if (result instanceof List<?>) { try { populateOpenPortsList((List<SerializableSecurityGroup>) result); //populate the spinner } catch (ClassCastException exception) { Log.e(TAG, exception.getMessage()); finish(); } populateSpinner(); //populate the spinner } else if (result instanceof AmazonServiceException) { // if a server error if (((AmazonServiceException) result).getErrorCode().startsWith("5")) { alertDialogMessage = this.getString(R.string.loginview_server_err_dlg); } else { alertDialogMessage = this.getString(R.string.loginview_invalid_keys_dlg); } alertDialogDisplayed = true; killActivityOnError = true;//do not kill activity on server error //allow user to retry. } else if (result instanceof AmazonClientException) { alertDialogMessage = this.getString(R.string.loginview_no_connxn_dlg); alertDialogDisplayed = true; killActivityOnError = true;//do not kill activity on connectivity error. allow //client to retry. } } //handle return of sshConnectorModel else if (sshConnectorModel != null) { sshConnectorModel = null; if (result instanceof String) { Log.v(TAG, "SshConnectorModel returned: " + (String) result); Intent connectBotIntent = new Intent(Intent.ACTION_VIEW, Uri.parse((String) result)); try { connectBotIntent.putExtra("usePubKeyAuth", ((CheckBox) findViewById(R.id.sshConnectorUsePublicKeyAuth)).isChecked()); //pass nickname: the last name of the file's path seq startActivity(connectBotIntent); } catch (ActivityNotFoundException exception) { alertDialogMessage = this.getString(R.string.connectbot_not_installed); alertDialogDisplayed = true; //kill the activity when user closes the dialog killActivityOnError = true; } } else if (result instanceof AmazonServiceException) { // if a server error if (((AmazonServiceException) result).getErrorCode().startsWith("5")) { alertDialogMessage = this.getString(R.string.loginview_server_err_dlg); } else { alertDialogMessage = this.getString(R.string.loginview_invalid_keys_dlg); } alertDialogDisplayed = true; killActivityOnError = false;//do not kill activity on server error //allow user to retry. } else if (result instanceof AmazonClientException) { alertDialogMessage = this.getString(R.string.loginview_no_connxn_dlg); alertDialogDisplayed = true; killActivityOnError = false;//do not kill activity on connectivity error. allow //client to retry. } else if (result instanceof ConnectionClosedException) { alertDialogMessage = ((ConnectionClosedException) result).getMessage(); alertDialogDisplayed = true; killActivityOnError = false; } } //display the alert dialog if the user set the displayed var to true if (alertDialogDisplayed) { alertDialogBox.setMessage(alertDialogMessage); alertDialogBox.show();//show error } }
From source file:org.roosster.input.UrlFetcher.java
/** * */// ww w . jav a 2 s .co m private void initProcessors(Registry registry) throws InitializeException { Configuration conf = registry.getConfiguration(); String procNames = conf.getProperty(PROP_PROCESSORS); if (procNames == null) throw new InitializeException("UrlFetcher needs ContentTypeProcessors"); String defProcName = conf.getProperty(PROP_PROCESSORS + ".default"); if (defProcName == null || "".equals(defProcName)) throw new InitializeException("No default processor defined"); StringTokenizer tok = new StringTokenizer(procNames.trim(), " "); while (tok.hasMoreTokens()) { String name = tok.nextToken(); String clazz = conf.getProperty(PROP_PROCESSORS + "." + name + ".class"); String typeStr = conf.getProperty(PROP_PROCESSORS + "." + name + ".type"); if (clazz == null || typeStr == null) { LOG.warn("No Class or Type property defined for processor '" + name + "'"); continue; } // split types by spaces, to allow single proc to // process multiple types List types = new ArrayList(); StringTokenizer typeTok = new StringTokenizer(typeStr); while (typeTok.hasMoreTokens()) { types.add(typeTok.nextToken()); } try { LOG.debug("Trying to load ContentTypeProcessor " + clazz); ContentTypeProcessor proc = (ContentTypeProcessor) Class.forName(clazz).newInstance(); proc.init(registry); for (int i = 0; i < types.size(); i++) { processors.put(types.get(i), proc); } if (defProcName.equals(name)) defaultProc = proc; } catch (ClassCastException ex) { LOG.warn("Processor " + name + " does not implement the " + ContentTypeProcessor.class + " interface", ex); throw new InitializeException(ex); } catch (Exception ex) { LOG.warn("Error while loading processor " + name + " ; Message: " + ex.getMessage(), ex); throw new InitializeException(ex); } } if (defaultProc == null) throw new InitializeException("Invalid default processor defined (misspelled class?)"); }
From source file:jp.terasoluna.fw.web.struts.actions.AbstractBLogicAction.java
/** * BLogicIO?B/*from w w w . j a va2 s . c o m*/ * * @param mapping ANV}bsO * @param request HTTPNGXg * @return rWlX?WbN?o? */ protected BLogicIO getBLogicIO(ActionMapping mapping, HttpServletRequest request) { String moduleName = ModuleUtil.getPrefix(request); BLogicResources resource = null; try { resource = (BLogicResources) servlet.getServletContext() .getAttribute(BLogicResources.BLOGIC_RESOURCES_KEY + moduleName); } catch (ClassCastException e) { // BLogicResourcesCX^X???AON?B log.error("Cannot cast BLogicResources : " + e.getMessage()); throw new SystemException(e, BLOGIC_RESOURCES_ILLEGAL_ERROR); } if (resource != null) { return resource.getBLogicIO(mapping.getPath()); } return null; }
From source file:jp.terasoluna.fw.web.struts.actions.AbstractBLogicAction.java
/** * BLogicMapperCX^X?B/*www . ja va2 s .c o m*/ * * @param req HTTPNGXg * @return BLogicMapperCX^X */ protected AbstractBLogicMapper getBLogicMapper(HttpServletRequest req) { String moduleName = ModuleUtil.getPrefix(req); AbstractBLogicMapper mapper = null; try { mapper = (AbstractBLogicMapper) servlet.getServletContext() .getAttribute(BLogicIOPlugIn.BLOGIC_MAPPER_KEY + moduleName); } catch (ClassCastException e) { // AbstractBLogicMapperCX^X???AON?B log.error("Cannot cast BLogicMapper : " + e.getMessage()); throw new SystemException(e, BLOGIC_MAPPING_ILLEGAL_ERROR); } // BLogicMappernull???AO? if (mapper == null) { log.error("BLogicMapper is null."); throw new SystemException(new NullPointerException(), NULL_MAPPER_KEY); } return mapper; }
From source file:org.fireflow.pdl.fpdl.behavior.StartNodeBehavior.java
private String triggeredByCron(WorkflowSession session, ActivityInstance activityInstance, TimerStartFeature timerDecorator) throws EngineException { RuntimeContext runtimeContext = ((WorkflowSessionLocalImpl) session).getRuntimeContext(); WorkflowSessionLocalImpl sessionLocalImpl = (WorkflowSessionLocalImpl) session; ProcessInstance processInstance = sessionLocalImpl.getCurrentProcessInstance(); Expression theCronExpression = timerDecorator.getCronExpression(); if (theCronExpression == null) { log.error("The cron expression is null!"); throw new EngineException(activityInstance, "The cron expression is null"); }/*from ww w. ja v a 2 s .co m*/ Map<String, Object> varContext = ScriptEngineHelper.fulfillScriptContext(session, runtimeContext, processInstance, activityInstance); try { Object obj = ScriptEngineHelper.evaluateExpression(runtimeContext, theCronExpression, varContext); return (String) obj; } catch (ClassCastException e) { log.error("The result of the cron expression is not a java String object.", e); throw new EngineException(activityInstance, "The result of the cron expression is not a java String object." + e.getMessage()); } }
From source file:org.apache.struts.action.DynaActionForm.java
/** * <p>Set the value of an indexed property with the specified name.</p> * * @param name Name of the property whose value is to be set * @param index Index of the property to be set * @param value Value to which this property is to be set * @throws ConversionException if the specified value cannot be * converted to the type required for * this property * @throws NullPointerException if there is no property of the * specified name * @throws IllegalArgumentException if the specified property exists, but * is not indexed * @throws IndexOutOfBoundsException if the specified index is outside the * range of the underlying property *///from w w w. j a v a 2s. c o m public void set(String name, int index, Object value) { Object prop = dynaValues.get(name); if (prop == null) { throw new NullPointerException("No indexed value for '" + name + "[" + index + "]'"); } else if (prop.getClass().isArray()) { Array.set(prop, index, value); } else if (prop instanceof List) { try { ((List) prop).set(index, value); } catch (ClassCastException e) { throw new ConversionException(e.getMessage()); } } else { throw new IllegalArgumentException("Non-indexed property for '" + name + "[" + index + "]'"); } }