Example usage for java.lang Exception getLocalizedMessage

List of usage examples for java.lang Exception getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang Exception getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:jenkins.plugins.publish_over_ssh.BapSshClient.java

public void disconnectExecQuietly(final ChannelExec exec) {
    try {//from   w w  w.  j  a  va 2 s.  co m
        disconnectExec(exec);
    } catch (Exception e) {
        LOG.warn(Messages.exception_disconnect_exec(e.getLocalizedMessage()));
    }
}

From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.manageschoolleveltypemapping.SchoolLevelTypeMappingController.java

@RequestMapping(value = _CREATE_URI, method = RequestMethod.POST)
public String create(@RequestParam(value = "schoollevel", required = false) SchoolLevelType schoolLevel,
        @RequestParam(value = "degreetype", required = false) DegreeType degreeType, Model model,
        RedirectAttributes redirectAttributes) {

    try {/*from w ww .j a va  2 s. c  o m*/

        SchoolLevelTypeMapping schoolLevelTypeMapping = createSchoolLevelTypeMapping(schoolLevel, degreeType);

        return redirect("/integration/sas/manageschoolleveltypemapping/schoolleveltypemapping/", model,
                redirectAttributes);
    } catch (Exception de) {

        addErrorMessage(BundleUtil.getString(SasSpringConfiguration.BUNDLE, "label.error.create")
                + de.getLocalizedMessage(), model);
        return create(model);
    }
}

From source file:com.lp.alm.lyo.client.oslc.jazz.JazzFormAuthClient.java

/**
 * Executes the sequence of HTTP requests to perform a form login to a Jazz server
 * @throws JazzAuthFailedException//from  w  ww  . jav  a2  s.  c om
 * @throws JazzAuthErrorException
 *
 * @return The HTTP status code of the final request to verify login is successful
 *
 * @deprecated Use {@link #login()}.
 */
@Deprecated
public int formLogin() throws JazzAuthFailedException, JazzAuthErrorException {
    try {
        return login();
    } catch (JazzAuthFailedException jfe) {
        throw jfe;
    } catch (JazzAuthErrorException jee) {
        throw jee;
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage());
        return -1;
    }
}

From source file:com.jkoolcloud.tnt4j.streams.custom.dirStream.DefaultStreamingJob.java

/**
 * Initializes and starts configuration defined {@link TNTInputStream}s when job gets invoked by executor service.
 *//*from   ww  w  . j  a va  2  s.  c o m*/
@Override
public void run() {
    // StreamsAgent.runFromAPI(streamCfgFile);

    // TODO: configuration from ZooKeeper

    try {
        StreamsConfigLoader cfg = new StreamsConfigLoader(streamCfgFile);
        Collection<TNTInputStream<?, ?>> streams = cfg.getStreams();

        if (CollectionUtils.isEmpty(streams)) {
            throw new IllegalStateException(StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                    "StreamsAgent.no.activity.streams"));
        }

        ThreadGroup streamThreads = new ThreadGroup(DefaultStreamingJob.class.getName() + "Threads"); // NON-NLS
        StreamThread ft;

        DefaultStreamListener dsl = new DefaultStreamListener();

        for (TNTInputStream<?, ?> stream : streams) {
            stream.addStreamListener(dsl);

            stream.output().setProperty(OutputProperties.PROP_TNT4J_CONFIG_FILE, tnt4jCfgFilePath);

            ft = new StreamThread(streamThreads, stream,
                    String.format("%s:%s", stream.getClass().getSimpleName(), stream.getName())); // NON-NLS
            ft.start();
        }
    } catch (Exception e) {
        LOGGER.log(OpLevel.ERROR, String.valueOf(e.getLocalizedMessage()), e);
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectClinicalRawFileListener.java

public boolean createTabFileFromSoft(File rawFile, File newFile) {
    Vector<String> columns = new Vector<String>();
    Vector<HashMap<String, String>> lines = new Vector<HashMap<String, String>>();
    try {/*from  w  w w. j a  va2s  .c o  m*/
        BufferedReader br = new BufferedReader(new FileReader(rawFile));
        String line;
        Pattern p1 = Pattern.compile(".SAMPLE = .*");
        Pattern p2 = Pattern.compile("!Sample_characteristics_ch. = .*: .*");
        while ((line = br.readLine()) != null) {
            if (line.compareTo("") != 0) {
                Matcher m1 = p1.matcher(line);
                Matcher m2 = p2.matcher(line);
                if (m1.matches()) {
                    lines.add(new HashMap<String, String>());
                    if (!columns.contains("sample")) {
                        columns.add("sample");
                    }
                    lines.get(lines.size() - 1).put("sample", line.split(".SAMPLE = ", -1)[1]);
                } else if (m2.matches()) {
                    String s = line.split("!Sample_characteristics_ch. = ", -1)[1];
                    String tag = s.split(": ", -1)[0];
                    if (!columns.contains(tag)) {
                        columns.add(tag);
                    }
                    lines.get(lines.size() - 1).put(tag, s.split(": ", -1)[1]);
                }
            }
        }
        br.close();
    } catch (Exception e) {
        selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    if (columns.size() <= 1) {
        selectRawFilesUI.setMessage("Wrong soft format: no characteristics");
        selectRawFilesUI.setIsLoading(false);
        return false;
    }
    FileWriter fw;
    try {
        fw = new FileWriter(newFile);
        BufferedWriter out = new BufferedWriter(fw);

        for (int i = 0; i < columns.size() - 1; i++) {
            out.write(columns.get(i) + "\t");
        }
        out.write(columns.get(columns.size() - 1) + "\n");

        for (HashMap<String, String> sample : lines) {
            for (int i = 0; i < columns.size() - 1; i++) {
                String value = sample.get(columns.get(i));
                if (value == null)
                    value = "";
                out.write(value + "\t");
            }
            String value = sample.get(columns.get(columns.size() - 1));
            if (value == null)
                value = "";
            out.write(value + "\n");
        }
        out.close();
        return true;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage());
        selectRawFilesUI.setIsLoading(false);
        e.printStackTrace();
        return false;
    }
}

From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.manageschoolleveltypemapping.SchoolLevelTypeMappingController.java

@RequestMapping(value = _UPDATE_URI + "{oid}", method = RequestMethod.POST)
public String update(@PathVariable("oid") SchoolLevelTypeMapping schoolLevelTypeMapping,
        @RequestParam(value = "schoollevel", required = false) SchoolLevelType schoolLevel,
        @RequestParam(value = "degreetype", required = false) DegreeType degreeType, Model model,
        RedirectAttributes redirectAttributes) {

    setSchoolLevelTypeMapping(schoolLevelTypeMapping, model);

    try {/* w  w  w .  j a  va 2s. c  om*/

        updateSchoolLevelTypeMapping(schoolLevel, degreeType, model);

        return redirect("/integration/sas/manageschoolleveltypemapping/schoolleveltypemapping/", model,
                redirectAttributes);
    } catch (Exception de) {

        addErrorMessage(BundleUtil.getString(SasSpringConfiguration.BUNDLE, "label.error.update")
                + de.getLocalizedMessage(), model);
        return update(schoolLevelTypeMapping, model);

    }
}

From source file:com.aujur.ebookreader.catalog.LoadOPDSTask.java

@Override
protected Feed doInBackground(String... params) {

    String baseUrl = params[0];//  ww  w  .j a v a 2 s. c o  m

    if (baseUrl == null || baseUrl.trim().length() == 0) {
        return null;
    }

    boolean isBaseFeed = baseUrl.equals(config.getBaseOPDSFeed());

    baseUrl = baseUrl.trim();

    try {

        HttpGet currentRequest = new HttpGet(baseUrl);
        currentRequest.setHeader("User-Agent", config.getUserAgent());
        currentRequest.setHeader("Accept-Language", config.getLocale().getLanguage());
        HttpResponse response = httpClient.execute(currentRequest);

        LOG.debug("Starting download of " + baseUrl);

        if (response.getStatusLine().getStatusCode() != 200) {
            this.errorMessage = "HTTP " + response.getStatusLine().getStatusCode() + ": "
                    + response.getStatusLine().getReasonPhrase();
            return null;
        }

        InputStream stream = response.getEntity().getContent();
        Feed feed = Nucular.readAtomFeedFromStream(stream);
        feed.setURL(baseUrl);
        feed.setDetailFeed(asDetailsFeed);
        feed.setSearchFeed(asSearchFeed);

        for (Entry entry : feed.getEntries()) {
            entry.setBaseURL(baseUrl);
        }

        if (isBaseFeed) {
            addCustomSitesEntry(feed);
        }

        if (isCancelled()) {
            return null;
        }

        Link searchLink = feed.findByRel(AtomConstants.REL_SEARCH);

        if (searchLink != null) {
            URL mBaseUrl = new URL(baseUrl);
            URL mSearchUrl = new URL(mBaseUrl, searchLink.getHref());
            searchLink.setHref(mSearchUrl.toString());

            LOG.debug("Got searchLink of type " + searchLink.getType() + " with href=" + searchLink.getHref());

            /*
            Some sites report the search as OpenSearch, but still have the
            searchTerms in the URL. If the URL already contains searchTerms,
            we ignore the reported type and treat it as Atom
             */
            if (searchLink.getHref().contains(AtomConstants.SEARCH_TERMS)) {
                searchLink.setType(AtomConstants.TYPE_ATOM);
            }

            if (AtomConstants.TYPE_OPENSEARCH.equals(searchLink.getType())) {

                String searchURL = searchLink.getHref();

                LOG.debug("Attempting to download OpenSearch description from " + searchURL);

                try {
                    currentRequest = new HttpGet(searchURL);
                    InputStream searchStream = httpClient.execute(currentRequest).getEntity().getContent();

                    SearchDescription desc = Nucular.readOpenSearchFromStream(searchStream);

                    if (desc.getSearchLink() != null) {
                        searchLink.setHref(desc.getSearchLink().getHref());
                        searchLink.setType(AtomConstants.TYPE_ATOM);
                    }
                } catch (Exception searchIO) {
                    LOG.error("Could not get search info", searchIO);
                }
            }

            LOG.debug("Using searchURL " + searchLink.getHref());

        }

        return feed;
    } catch (Exception e) {
        this.errorMessage = e.getLocalizedMessage();
        LOG.error("Download failed for url: " + baseUrl, e);
        return null;
    }

}

From source file:client.InterfaceSalon.java

public void setLobbyList(String liste) {
    DefaultListModel lobbyListContent = new DefaultListModel();

    if (!liste.equals("[]")) {
        try {//  ww w . j  a  v a2 s .  co  m
            this.lobbyListJSON = (JSONArray) parser.parse(liste);
        } catch (Exception e) {
            System.out.println("error json : " + e.getLocalizedMessage());
        }

        Iterator it = lobbyListJSON.iterator();

        while (it.hasNext()) {
            JSONObject lobby = (JSONObject) it.next();
            lobbyListContent.addElement(
                    lobby.get("name") + "  " + lobby.get("nbJoueurs") + "/" + lobby.get("nbJoueursMax"));
        }
    }
    lobbyList.setModel(lobbyListContent);
}

From source file:com.amalto.workbench.actions.XSDDeleteXPathAction.java

public IStatus doAction() {
    try {// ww w  . j a  v a  2 s.c o m

        // xsdPath is to support the multiple delete action on key press,
        // which each delete action on xpath must be explicit passed a xsd path to
        // delete
        XSDXPathDefinition xpath = xsdPath;
        if (xpath == null) {
            ISelection selection = page.getTreeViewer().getSelection();
            xpath = (XSDXPathDefinition) ((IStructuredSelection) selection).getFirstElement();
        }
        XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) xpath.getContainer();
        if (icd == null)
            return Status.CANCEL_STATUS;

        if (xpath.getVariety().equals(XSDXPathVariety.SELECTOR_LITERAL)) {
            MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                    Messages.XSDDeleteXPathAction_SelectorCannotDel);
            return Status.CANCEL_STATUS;
        }

        if (icd.getFields().size() == 1) {
            MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                    Messages.XSDDeleteXPathAction_KeyMustContainOne);
            return Status.CANCEL_STATUS;
        }

        icd.getFields().remove(xpath);
        icd.updateElement();
        xsdPath = null;
        page.refresh();
        page.markDirty();

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDDeleteXPathAction_ErrorRemoveAField, e.getLocalizedMessage()));

        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}

From source file:jenkins.plugins.publish_over_ssh.BapSshClient.java

public void disconnectQuietly() {
    try {// ww w. jav a2s . c  o m
        disconnectSftp();
    } catch (Exception e) {
        LOG.warn(Messages.exception_disconnect_sftp(e.getLocalizedMessage()));
    }
    try {
        disconnectSession();
    } catch (Exception e) {
        LOG.warn(Messages.exception_disconnect_session(e.getLocalizedMessage()));
    }
}