List of usage examples for java.lang Throwable getLocalizedMessage
public String getLocalizedMessage()
From source file:com.ibm.mobilefirstplatform.clientsdk.android.security.mca.internal.AuthorizationRequestManager.java
/** * Called from onSuccess and onFailure. Handles all possible exceptions and notifies the listener * if an exception occurs./* w w w .j av a2 s . c o m*/ * * @param response server response * @param isFailure specifies whether this method is called from onSuccess (false) or onFailure (true). */ private void processResponseWrapper(Response response, boolean isFailure) { try { ResponseImpl responseImpl = (ResponseImpl) response; if (isFailure || !responseImpl.isRedirect()) { processResponse(response); } else { processRedirectResponse(response); } } catch (Throwable t) { logger.error("processResponseWrapper caught exception: " + t.getLocalizedMessage()); listener.onFailure(response, t, null); } }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.security.mca.internal.AuthorizationRequestManager.java
/** * Removes an expected challenge answer from collection. * * @param realm Realm of the answer to remove. *//* w ww . ja v a 2 s . c om*/ public void removeExpectedAnswer(String realm) { if (answers != null) { answers.remove(realm); } try { if (isAnswersFilled()) { resendRequest(); } } catch (Throwable t) { logger.error("removeExpectedAnswer failed with exception: " + t.getLocalizedMessage(), t); } }
From source file:org.geoserver.taskmanager.web.AbstractConfigurationsPage.java
@Override public void onInitialize() { super.onInitialize(); add(dialog = new GeoServerDialog("dialog")); dialog.setInitialHeight(150);/* w w w . ja v a 2 s . c om*/ ((ModalWindow) dialog.get("dialog")).showUnloadConfirmation(false); add(new AjaxLink<Object>("addNew") { private static final long serialVersionUID = 3581476968062788921L; @Override public void onClick(AjaxRequestTarget target) { if (templates || TaskManagerBeans.get().getDao().getConfigurations(true).isEmpty()) { Configuration configuration = TaskManagerBeans.get().getFac().createConfiguration(); configuration.setTemplate(templates); setResponsePage(new ConfigurationPage(configuration)); } else { dialog.setTitle(new ParamResourceModel("addNewDialog.title", getPage())); dialog.showOkCancel(target, new GeoServerDialog.DialogDelegate() { private static final long serialVersionUID = -5552087037163833563L; private DropDownPanel panel; @Override protected Component getContents(String id) { ArrayList<String> list = new ArrayList<String>(); for (Configuration template : TaskManagerBeans.get().getDao().getConfigurations(true)) { list.add(template.getName()); } panel = new DropDownPanel(id, new Model<String>(), new Model<ArrayList<String>>(list), new ParamResourceModel("addNewDialog.chooseTemplate", getPage())); return panel; } @Override protected boolean onSubmit(AjaxRequestTarget target, Component contents) { String choice = (String) panel.getDefaultModelObject(); Configuration configuration; if (choice == null) { configuration = TaskManagerBeans.get().getFac().createConfiguration(); } else { configuration = TaskManagerBeans.get().getDao().copyConfiguration(choice); configuration.setTemplate(false); configuration.setName(null); } setResponsePage(new ConfigurationPage(configuration)); return true; } }); } } }); // the removal button add(remove = new AjaxLink<Object>("removeSelected") { private static final long serialVersionUID = 3581476968062788921L; @Override public void onClick(AjaxRequestTarget target) { boolean someCant = false; for (Configuration config : configurationsPanel.getSelection()) { BatchElement be = taskInUseByExternalBatch(config); if (be != null) { error(new ParamResourceModel("taskInUse", AbstractConfigurationsPage.this, config.getName(), be.getTask().getName(), be.getBatch().getName()).getString()); someCant = true; } else if (!TaskManagerBeans.get().getDataUtil().isDeletable(config)) { error(new ParamResourceModel("stillRunning", AbstractConfigurationsPage.this, config.getName()).getString()); someCant = true; } else if (!TaskManagerBeans.get().getSecUtil().isAdminable( AbstractConfigurationsPage.this.getSession().getAuthentication(), config)) { error(new ParamResourceModel("noDeleteRights", AbstractConfigurationsPage.this, config.getName()).getString()); someCant = true; } } if (someCant) { addFeedbackPanels(target); } else { dialog.setTitle(new ParamResourceModel("confirmDeleteDialog.title", getPage())); dialog.showOkCancel(target, new GeoServerDialog.DialogDelegate() { private static final long serialVersionUID = -5552087037163833563L; private String error = null; private IModel<Boolean> shouldCleanupModel = new Model<Boolean>(); @Override protected Component getContents(String id) { StringBuilder sb = new StringBuilder(); sb.append(new ParamResourceModel("confirmDeleteDialog.content", getPage()).getString()); for (Configuration config : configurationsPanel.getSelection()) { sb.append("\n "); sb.append(escapeHtml(config.getName())); } return new MultiLabelCheckBoxPanel(id, sb.toString(), new ParamResourceModel("cleanUp", getPage()).getString(), shouldCleanupModel); } @Override protected boolean onSubmit(AjaxRequestTarget target, Component contents) { try { for (Configuration config : configurationsPanel.getSelection()) { if (shouldCleanupModel.getObject()) { if (TaskManagerBeans.get().getTaskUtil().canCleanup(config)) { if (TaskManagerBeans.get().getTaskUtil().cleanup(config)) { info(new ParamResourceModel("cleanUp.success", getPage(), config.getName()).getString()); } else { error(new ParamResourceModel("cleanUp.error", getPage(), config.getName()).getString()); } } else { info(new ParamResourceModel("cleanUp.ignore", getPage(), config.getName()).getString()); } } TaskManagerBeans.get().getDao().remove(config); } configurationsPanel.clearSelection(); remove.setEnabled(false); } catch (Exception e) { LOGGER.log(Level.WARNING, e.getMessage(), e); Throwable rootCause = ExceptionUtils.getRootCause(e); error = rootCause == null ? e.getLocalizedMessage() : rootCause.getLocalizedMessage(); } return true; } @Override public void onClose(AjaxRequestTarget target) { if (error != null) { error(error); addFeedbackPanels(target); } addFeedbackPanels(target); target.add(configurationsPanel); target.add(remove); } }); } } }); remove.setOutputMarkupId(true); remove.setEnabled(false); // the copy button add(copy = new AjaxLink<Object>("copySelected") { private static final long serialVersionUID = 3581476968062788921L; @Override public void onClick(AjaxRequestTarget target) { Configuration copy = TaskManagerBeans.get().getDao() .copyConfiguration(configurationsPanel.getSelection().get(0).getName()); //make sure we can't copy with workspace we don't have access to WorkspaceInfo wi = GeoServerApplication.get().getCatalog().getWorkspaceByName(copy.getWorkspace()); if (wi == null || !TaskManagerBeans.get().getSecUtil() .isAdminable(AbstractConfigurationsPage.this.getSession().getAuthentication(), wi)) { copy.setWorkspace(null); } setResponsePage(new ConfigurationPage(copy)); } }); copy.setOutputMarkupId(true); copy.setEnabled(false); //the panel add(configurationsPanel = new GeoServerTablePanel<Configuration>("configurationsPanel", new ConfigurationsModel(templates), true) { private static final long serialVersionUID = -8943273843044917552L; @Override protected void onSelectionUpdate(AjaxRequestTarget target) { remove.setEnabled(configurationsPanel.getSelection().size() > 0); copy.setEnabled(configurationsPanel.getSelection().size() == 1); target.add(remove); target.add(copy); } @SuppressWarnings("unchecked") @Override protected Component getComponentForProperty(String id, IModel<Configuration> itemModel, Property<Configuration> property) { if (property.equals(ConfigurationsModel.NAME)) { return new SimpleAjaxLink<String>(id, (IModel<String>) property.getModel(itemModel)) { private static final long serialVersionUID = -9184383036056499856L; @Override protected void onClick(AjaxRequestTarget target) { setResponsePage(new ConfigurationPage(itemModel)); } }; } return null; } }); configurationsPanel.setOutputMarkupId(true); }
From source file:de.elanev.studip.android.app.frontend.forums.ForumEntryComposeFragment.java
private void createNewEntry() { setViewsVisible(false);/* www . ja v a 2 s . c om*/ String subject = mSubjectEditText.getText().toString(); String content = mContentEditText.getText().toString(); Server server = Prefs.getInstance(getActivity()).getServer(); StudIpLegacyApiService legacyApiService = new StudIpLegacyApiService(server, getActivity()); mCompositeSubscription.add(bind(legacyApiService.createForumEntry(sEntryId, subject, content)) .subscribe(new Subscriber<ForumArea>() { @Override public void onCompleted() { Toast.makeText(getActivity(), R.string.successfully_added, Toast.LENGTH_LONG).show(); getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); } @Override public void onError(Throwable e) { if (e instanceof TimeoutException) { Toast.makeText(getActivity(), "Request timed out", Toast.LENGTH_SHORT).show(); } else if (e instanceof RetrofitError || e instanceof HttpException) { Toast.makeText(getActivity(), "Retrofit error or http exception", Toast.LENGTH_LONG) .show(); Log.e(TAG, e.getLocalizedMessage()); } else { e.printStackTrace(); throw new RuntimeException("See inner exception"); } setViewsVisible(true); } @Override public void onNext(ForumArea forumArea) { } })); }
From source file:org.opencms.workflow.CmsExtendedWorkflowManager.java
/** * Sends the notification for released resources.<p> * * @param userCms the user's CMS context * @param recipient the OpenCms user to whom the notification should be sent * @param workflowProject the workflow project which * @param resources the resources which have been affected by a workflow action *//* w w w. j a v a 2 s. c o m*/ protected void sendNotification(CmsObject userCms, CmsUser recipient, CmsProject workflowProject, List<CmsResource> resources) { try { String linkHref = OpenCms.getLinkManager().getServerLink(userCms, "/system/workplace/commons/publish.jsp?" + CmsPublishService.PARAM_PUBLISH_PROJECT_ID + "=" + workflowProject.getUuid() + "&" + CmsPublishService.PARAM_CONFIRM + "=true"); CmsWorkflowNotification notification = new CmsWorkflowNotification(m_adminCms, userCms, recipient, getNotificationResource(), workflowProject, resources, linkHref); notification.send(); } catch (Throwable e) { LOG.error(e.getLocalizedMessage(), e); } }
From source file:org.malaguna.cmdit.bbeans.AbstractBean.java
/** * It runs a command safely and catching all error info. If commands fail, * it will show error info standard way. * //from www .j a va 2 s. c om * @param cmd * @return */ @Override protected Command runCommand(Command cmd) { cmd.setLocale(getLocale()); cmd.setUser(getAuthUserFromSession()); try { cmd = super.runCommand(cmd); if ((cmd != null) && (cmd.getUserComment() != null)) { setInfoMessage("Command Info:", cmd.getUserComment()); } } catch (Exception e) { Throwable ce = (e.getCause() != null) ? e.getCause() : e; String aux = getMessage(ce.getClass().getName(), getLocale()); String errMsg = null; if (aux != null) errMsg = String.format("%s: %s", aux, ce.getLocalizedMessage()); else errMsg = ce.getLocalizedMessage(); setErrorMessage("Command Error:", errMsg); cmd = null; } return cmd; }
From source file:com.quarterfull.newsAndroid.ssl.MemorizingTrustManager.java
private String certChainMessage(final X509Certificate[] chain, CertificateException cause) { Throwable e = cause; Log.d(TAG, "certChainMessage for " + e); StringBuilder si = new StringBuilder(); if (e.getCause() != null) { e = e.getCause();/* w w w.j av a2 s . c om*/ si.append(e.getLocalizedMessage()); //si.append("\n"); } for (X509Certificate c : chain) { si.append("\n\n"); si.append(c.getSubjectDN().toString()); si.append("\nMD5: "); si.append(certHash(c, "MD5")); si.append("\nSHA1: "); si.append(certHash(c, "SHA-1")); si.append("\nSigned by: "); si.append(c.getIssuerDN().toString()); } return si.toString(); }
From source file:com.jaspersoft.android.jaspermobile.dialog.PasswordDialogFragment.java
private void tryToLogin(String password) { mCheckPasswordUseCase.execute(password, new Subscriber<Void>() { @Override/* www . jav a2s .co m*/ public void onStart() { showLoader(); } @Override public void onCompleted() { hideLoader(); } @Override public void onError(Throwable e) { if (e instanceof ServiceException) { ServiceException serviceException = (ServiceException) e; int code = serviceException.code(); if (code == StatusCodes.AUTHORIZATION_ERROR) { showError(getString(R.string.r_error_incorrect_credentials)); } } else { showError(e.getLocalizedMessage()); } hideLoader(); } @Override public void onNext(Void item) { dismiss(); Intent restartIntent = NavigationActivity_.intent(getActivity()).get(); restartIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); getActivity().finish(); getActivity().startActivity(restartIntent); } }); }
From source file:stellr.util.stores.admin.FileUploadServlet.java
/** * handles file upload/*from www . ja va 2 s. co m*/ * * @param request * @param response * @throws javax.servlet.ServletException * @throws java.io.IOException */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Clear current rowdata this.rowData = null; this.colData = null; System.gc(); // Check that we have a file upload request isMultipart = ServletFileUpload.isMultipartContent(request); if (!isMultipart) { System.out.println("Not file Exception Upload"); return; } DiskFileItemFactory factory = new DiskFileItemFactory(); FileItem fileIn; // maximum size that will be stored in memory factory.setSizeThreshold(maxMemSize); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // maximum file size to be uploaded. upload.setSizeMax(maxFileSize); try { // Parse the request to get file items. List fileItems = upload.parseRequest(request); // Process the uploaded file items Iterator i = fileItems.iterator(); while (i.hasNext()) { fileIn = (FileItem) i.next(); if (!fileIn.isFormField()) { // Get the uploaded file parameters String fileName = fileIn.getName(); try { String str = fileIn.getString(); //Rows String[] arr = str.split("\n\\s*(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); //Rows Initialize String[][] csv = new String[arr.length][]; //Split csv data for rows and columns for (int r = 0; r < arr.length; r++) { String[] tmpRowData = arr[r].split(",\\s*(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); //Add column infront String[] addColData = new String[tmpRowData.length + 1]; addColData[0] = Boolean.FALSE.toString(); try { //Copy Row Column Celldata to new Array Row for datatable //Data should now have a new column in the front saying FALSE, used for is header tick box int cdidx = 1; for (String colCellData : tmpRowData) { addColData[cdidx++] = colCellData; } csv[r] = addColData; } catch (Exception e12) { csv[r] = arr[r].split(",\\s*(?=([^\"]*\"[^\"]*\")*[^\"]*$)"); } } //Setup new rowdata for datatable setRowData(new ArrayList<>()); //Add Header Row for (int x = 0; x < 1; x++) { //Create String array with one extra cell for is header checkbox //Initialise column header data setColData(new ArrayList(Arrays.asList(new String[csv[x].length]))); //Add first empty row to Row Data getRowData().add(getColData()); } //Add DataRows from CSV for (String[] csvRow : csv) { //Add Each row from CSV as Row Data getRowData().add((ArrayList<String>) (new ArrayList(Arrays.asList(csvRow)))); } } catch (Exception e) { System.out.println(" File Write Exception e " + e.getMessage()); Throwable cause = e.getCause(); String msg = ""; if (cause != null) { msg = cause.getLocalizedMessage(); } Logger.getLogger(FileUploadServlet.class.getName()).log(Level.SEVERE, null, e); } } } } catch (Exception ex) { System.out.println("DoPost Ex " + ex); } }
From source file:de.treichels.hott.ui.android.MdlViewerActivity.java
private void showDialog(final String message, final Throwable throwable) { setWait(0);//w ww. j a v a 2 s.co m if (message != null) { showDialog(message); } else if (throwable != null) { showDialog(throwable.getLocalizedMessage()); } else { showDialog("Background task failed!"); } }