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:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SetUnitsListener.java

@Override
public void handleEvent(Event event) {
    Vector<String> columns = this.setUnitsUI.getColumns();
    Vector<String> units = this.setUnitsUI.getUnits();
    if (columns.size() == 1) {
        if (columns.get(0).compareTo("") == 0 && columns.get(0).compareTo("") == 0) {
            columns = new Vector<String>();
            units = new Vector<String>();
        }// w  w  w .  j  a  v a  2  s . c o  m
    }
    for (int i = 0; i < columns.size(); i++) {
        if (columns.get(i).compareTo("") == 0 || units.get(i).compareTo("") == 0) {
            this.setUnitsUI.displayMessage("Some values are not set");
            return;
        }
        String columnFileName = columns.get(i).split(" - ", 2)[0];
        String unitFileName = units.get(i).split(" - ", 2)[0];
        if (columnFileName.compareTo(unitFileName) != 0) {
            this.setUnitsUI.displayMessage("Columns for value and unit have to been from the same file");
        }
    }
    if (((ClinicalData) this.dataType).getCMF() == null) {
        this.setUnitsUI.displayMessage("Error: no column mapping file");
        return;
    }
    if (!this.checkValues(columns, units))
        return;
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".columns.tmp");
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);
        out.write(
                "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");
        try {
            BufferedReader br = new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
            String line = br.readLine();
            while ((line = br.readLine()) != null) {
                if (line.split("\t", -1)[3].compareTo("UNITS") != 0) {
                    out.write(line + "\n");
                }
            }
            br.close();
        } catch (Exception e) {
            this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage());
            e.printStackTrace();
            out.close();
        }
        for (int i = 0; i < columns.size(); i++) {
            String fileName = columns.get(i).split(" - ", 2)[0];
            int columnColumnNumber = -1;
            for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) {
                if (rawFile.getName().compareTo(fileName) == 0) {
                    columnColumnNumber = FileHandler.getHeaderNumber(rawFile,
                            columns.get(i).split(" - ", 2)[1]);
                }
            }
            int unitColumnNumber = -1;
            for (File rawFile : ((ClinicalData) this.dataType).getRawFiles()) {
                if (rawFile.getName().compareTo(fileName) == 0) {
                    unitColumnNumber = FileHandler.getHeaderNumber(rawFile, units.get(i).split(" - ", 2)[1]);
                }
            }
            if (columnColumnNumber != -1 && unitColumnNumber != -1) {
                out.write(fileName + "\t\t" + String.valueOf(unitColumnNumber) + "\tUNITS\t"
                        + String.valueOf(columnColumnNumber) + "\t\t\n");

            }
        }

        out.close();
        String fileName = ((ClinicalData) this.dataType).getCMF().getName();
        FileUtils.deleteQuietly(((ClinicalData) this.dataType).getCMF());
        try {
            File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            FileUtils.moveFile(file, fileDest);
            ((ClinicalData) this.dataType).setCMF(fileDest);
        } catch (Exception ioe) {
            this.setUnitsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.setUnitsUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.setUnitsUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.marpies.ane.vk.functions.RequestFunction.java

private String parseRequestParameters(FREArray params, VKParameters vkParameters) {
    if (params != null) {
        try {/*  w ww .  j ava 2s. c o m*/
            long length = params.getLength();
            String key = null;
            for (long i = 0; i < length; i++) {
                FREObject param = params.getObjectAt(i);
                /* Get key */
                if (i % 2 == 0) {
                    key = FREObjectUtils.getString(param);
                }
                /* Get value */
                else {
                    Object value = null;
                    FREObjectType type = getFREObjectType(param);
                    switch (type) {
                    case INT:
                        value = FREObjectUtils.getInt(param);
                        AIR.log("FREObjectType: INT = " + FREObjectUtils.getInt(param));
                        break;
                    case DOUBLE:
                        value = FREObjectUtils.getDouble(param);
                        AIR.log("FREObjectType: DOUBLE = " + FREObjectUtils.getDouble(param));
                        break;
                    case STRING:
                        value = FREObjectUtils.getString(param);
                        AIR.log("FREObjectType: STRING = " + FREObjectUtils.getString(param));
                        break;
                    case ARRAY:
                        value = FREObjectUtils.getListOfString((FREArray) param);
                        AIR.log("FREObjectType: ARRAY = " + FREObjectUtils.getListOfString((FREArray) param));
                        break;
                    case UNKNOWN:
                        throw new Exception("Parameter value for key " + key + " cannot be evaluated.");
                    }
                    if (value != null) {
                        vkParameters.put(key, value);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            return e.getLocalizedMessage();
        }
    }
    /* No error message */
    return null;
}

From source file:gov.va.isaac.search.CompositeSearchResultComparator.java

/**
 * Note, the primary getBestScore() sort is in reverse, so it goes highest to lowest
 *
 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 *//*from   ww w .j  av  a 2 s  .co  m*/
@Override
public int compare(CompositeSearchResult o1, CompositeSearchResult o2) {
    if (o1.getBestScore() < o2.getBestScore()) {
        return 1;
    } else if (o1.getBestScore() > o2.getBestScore()) {
        return -1;
    }

    if (o1.getContainingConcept() == null || o2.getContainingConcept() == null) {
        if (o1.getContainingConcept() == null && o2.getContainingConcept() != null) {
            return 1;
        } else if (o1.getContainingConcept() != null && o2.getContainingConcept() == null) {
            return -1;
        } else {
            return 0;
        }
    }
    // else same score
    String o1FSN = null;
    try {
        o1FSN = o1.getContainingConcept().getFullySpecifiedDescription().getText().trim();
    } catch (Exception e) {
        LOG.warn("Failed calling getFullySpecifiedDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o1, e);
    }
    String o2FSN = null;
    try {
        o2FSN = o2.getContainingConcept().getFullySpecifiedDescription().getText().trim();
    } catch (Exception e) {
        LOG.warn("Failed calling getFullySpecifiedDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o2, e);
    }

    int fsnComparison = ObjectUtils.compare(o1FSN, o2FSN);
    if (fsnComparison != 0) {
        return fsnComparison;
    }

    // else same score and FSN
    String o1PreferredDescription = null;
    try {
        o1PreferredDescription = o1.getContainingConcept().getPreferredDescription().getText().trim();
    } catch (Exception e) {
        LOG.debug("Failed calling getPreferredDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o1, e);
    }

    String o2PreferredDescription = null;
    try {
        o2PreferredDescription = o2.getContainingConcept().getPreferredDescription().getText().trim();
    } catch (Exception e) {
        LOG.debug("Failed calling getPreferredDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o2, e);
    }

    int prefDescComparison = ObjectUtils.compare(o1PreferredDescription, o2PreferredDescription);
    if (prefDescComparison != 0) {
        return prefDescComparison;
    }

    // else same score and FSN and preferred description - sort on type
    String comp1String = o1.getMatchingComponents().iterator().next().toUserString();
    String comp2String = o2.getMatchingComponents().iterator().next().toUserString();

    return ObjectUtils.compare(comp1String, comp2String);
}

From source file:com.cclife.registration.dao.FamilyJPADaoImpl.java

/**
 *
 * @param obj//from w ww . ja  v a 2  s . c o  m
 * @throws PreexistingEntityException
 * @throws RollbackFailureException
 * @throws Exception
 */
@Transactional
@Override
public void create(Family obj) throws PreexistingEntityException, RollbackFailureException, Exception {
    try {
        //            em.persist(obj);

        if (obj.getFamilyID() == null) {

            em.persist(obj);
        } else {
            if (!em.contains(obj)) {
                em.merge(obj);
            }
        }
    } catch (Exception ex) {
        logger.error("Create Family ERROR:" + ex.getLocalizedMessage());
        if (find(obj.getFamilyID()) != null) {
            throw new PreexistingEntityException("Family " + obj + " already exists.", ex);
        }
        throw ex;
    }
}

From source file:at.bitfire.davdroid.webdav.WebDavCollection.java

public boolean multiGet(String[] names, MultigetType type)
        throws IOException, IncapableResourceException, HttpException {
    DavMultiget multiget = (type == MultigetType.ADDRESS_BOOK) ? new DavAddressbookMultiget()
            : new DavCalendarMultiget();

    multiget.prop = new DavProp();
    multiget.prop.getetag = new DavProp.DavPropGetETag();

    if (type == MultigetType.ADDRESS_BOOK)
        multiget.prop.addressData = new DavProp.DavPropAddressData();
    else if (type == MultigetType.CALENDAR)
        multiget.prop.calendarData = new DavProp.DavPropCalendarData();

    multiget.hrefs = new ArrayList<DavHref>(names.length);
    for (String name : names)
        multiget.hrefs.add(new DavHref(location.resolve(name).getPath()));

    Serializer serializer = new Persister();
    StringWriter writer = new StringWriter();
    try {/*from www. jav a2  s .c om*/
        serializer.write(multiget, writer);
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
        return false;
    }

    HttpReport report = new HttpReport(location, writer.toString());
    HttpResponse response = client.execute(report);
    checkResponse(response);

    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_MULTI_STATUS) {
        DavMultistatus multistatus;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            InputStream is = new TeeInputStream(response.getEntity().getContent(), baos);
            multistatus = serializer.read(DavMultistatus.class, is);

            Log.d(TAG, "Received multistatus response: " + baos.toString("UTF-8"));
        } catch (Exception e) {
            Log.e(TAG, e.getLocalizedMessage());
            return false;
        }
        processMultiStatus(multistatus);

    } else
        throw new IncapableResourceException();
    return true;
}

From source file:org.miloss.fgsms.presentation.StatusHelper.java

/**
 * determines if an fgsms service is currently accessible. not for use
 * with other services.//  w  w  w .  j  ava2 s .c om
 *
 * @param endpoint
 * @return
 */
public String sendGetRequest(String endpoint) {
    //   String result = null;
    if (endpoint.startsWith("http")) {
        // Send a GET request to the servlet
        try {

            URL url = new URL(endpoint);
            int port = url.getPort();
            if (port <= 0) {
                if (endpoint.startsWith("https:")) {
                    port = 443;
                } else {
                    port = 80;
                }
            }

            HttpClientBuilder create = HttpClients.custom();

            if (mode == org.miloss.fgsms.common.Constants.AuthMode.UsernamePassword) {
                CredentialsProvider credsProvider = new BasicCredentialsProvider();
                credsProvider.setCredentials(new AuthScope(url.getHost(), port),
                        new UsernamePasswordCredentials(username, Utility.DE(password)));
                create.setDefaultCredentialsProvider(credsProvider);
                ;

            }
            CloseableHttpClient c = create.build();

            CloseableHttpResponse response = c.execute(new HttpHost(url.getHost(), port),
                    new HttpGet(endpoint));

            c.close();
            int status = response.getStatusLine().getStatusCode();
            if (status == 200) {
                return "OK";
            }
            return String.valueOf(status);

        } catch (Exception ex) {
            Logger.getLogger(Helper.class).log(Level.WARN,
                    "error fetching http doc from " + endpoint + ex.getLocalizedMessage());
            return "offline";
        }
    } else {
        return "undeterminable";
    }
}

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

public boolean checkTabFormat(File rawFile) {
    try {/*from ww  w.  j  av a2s .co  m*/
        BufferedReader br = new BufferedReader(new FileReader(rawFile));
        String line = br.readLine();
        int columnsNbr = line.split("\t", -1).length;
        while ((line = br.readLine()) != null) {
            if (line.compareTo("") != 0) {
                if (line.split("\t", -1).length != columnsNbr) {
                    selectRawFilesUI.setMessage("Wrong file format:\nLines have no the same number of columns");
                    selectRawFilesUI.setIsLoading(false);
                    br.close();
                    return false;
                }
            }
        }
        br.close();
    } catch (Exception e) {
        selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage());
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.SelectSTSMFListener.java

public boolean checkFormat(File file) {
    try {//ww w .j ava  2 s  .  c  om
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line = br.readLine();
        Vector<String> samples = FileHandler.getSamplesId(((GeneExpressionData) this.dataType).getRawFile());
        Vector<String> samplesSTSMF = new Vector<String>();
        String category = "";
        while ((line = br.readLine()) != null) {
            if (line.compareTo("") != 0) {
                String[] fields = line.split("\t", -1);
                //check columns number
                if (fields.length != 9) {
                    this.selectSTSMFUI.displayMessage("Error:\nLines have not the right number of columns");
                    br.close();
                    return false;
                }
                //check that study id is set
                if (fields[0].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nStudy identifiers have to be set");
                    br.close();
                    return false;
                }
                //check that subject id is set
                if (fields[3].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nSubjects identifiers have to be set");
                    br.close();
                    return false;
                }
                //check that samples id is set
                if (fields[4].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nSamples identifiers have to be set");
                    br.close();
                    return false;
                }
                //check that platform is set
                if (fields[5].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nPlatform has to be set");
                    br.close();
                    return false;
                }
                //check that tissue type is set
                if (fields[5].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nTissue type has to be set");
                    br.close();
                    return false;
                }
                //check that category codes are set
                if (fields[8].compareTo("") == 0) {
                    this.selectSTSMFUI.displayMessage("Error:\nCategory codes have to be set");
                    br.close();
                    return false;
                }
                if (category.compareTo("") == 0) {
                    category = fields[8];
                } else {
                    if (fields[8].compareTo(category) != 0) {
                        this.selectSTSMFUI.displayMessage("Category code has to be always the same");
                        br.close();
                        return false;
                    }
                }
                if (!samplesSTSMF.contains(fields[3])) {
                    if (samples.contains(fields[3])) {
                        samplesSTSMF.add(fields[3]);
                    }
                }
            }
        }
        if (samplesSTSMF.size() != samples.size()) {
            this.selectSTSMFUI
                    .displayMessage("Error:\nSample identifiers are not the same than in raw data file");
            br.close();
            return false;
        }
        br.close();
    } catch (Exception e) {
        selectSTSMFUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:com.qperior.GSAOneBoxProvider.QPOneBoxProviderServletTest.java

/**
 * //from  w w w  .j  a  v  a 2  s .c  o  m
 */
@Test
public void testDoGetHttpServletRequestHttpServletResponse() {

    String uri = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_APIMIN + URI_AMP + URI_AUTHTYPE + URI_AMP + URI_LANG
            + URI_AMP + URI_ONEBOXNAME + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>lookupFailure</resultCode><Diagnostics>Empty result.</Diagnostics><provider>Dummy Provider (none)</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri2 = URI_SERVLET + URI_APIMIN + URI_AMP + URI_AUTHTYPE + URI_AMP + URI_LANG + URI_AMP
            + URI_ONEBOXNAME + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri2);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (Integer) 'apiMaj' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri3 = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_AUTHTYPE + URI_AMP + URI_LANG + URI_AMP
            + URI_ONEBOXNAME + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri3);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (Integer) 'apiMin' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri4 = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_APIMIN + URI_AMP + URI_LANG + URI_AMP
            + URI_ONEBOXNAME + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri4);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (QPAuthType) 'authType' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri5 = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_APIMIN + URI_AMP + URI_AUTHTYPE + URI_AMP
            + URI_ONEBOXNAME + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri5);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (String) 'lang' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri6 = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_APIMIN + URI_AMP + URI_AUTHTYPE + URI_AMP + URI_LANG
            + URI_AMP + URI_QUERY;

    try {
        String actual = this.callHttpGet(uri6);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (String) 'oneboxName' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }

    String uri7 = URI_SERVLET + URI_APIMAJ + URI_AMP + URI_APIMIN + URI_AMP + URI_AUTHTYPE + URI_AMP + URI_LANG
            + URI_AMP + URI_ONEBOXNAME + URI_AMP;

    try {
        String actual = this.callHttpGet(uri7);
        assertEquals(null,
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?><OneBoxResults xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"oneboxresults.xsd\"><resultCode>securityFailure</resultCode><Diagnostics>QPRequestValidateException: Request parameter (String) 'query' not send or in wrong format.</Diagnostics><provider>Provider not initialized.</provider></OneBoxResults>",
                actual);
    } catch (Exception exc) {
        fail("Exception in DoGet: " + exc.getLocalizedMessage());
    }
}

From source file:uk.ac.ebi.emma.controller.BiblioManagementListController.java

/**
 * Deletes the biblio identified by <b>id</b>. This method is configured as
 * a GET because it is intended to be called as an ajax call. Using GET
 * avoids re-posting problems with the back button. NOTE: It is the caller's
 * responsibility to insure there are no foreign key constraints.
 * /*from w  w w. j a v  a  2s. c om*/
 * @param biblio_key primary key of the biblio to be deleted
 * @return a JSON string containing 'status' [ok or fail], and a message [
 * empty string if status is ok; error message otherwise]
 */
@RequestMapping(value = "/deleteBiblio", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<String> deleteBiblio(@RequestParam int biblio_key) {
    String status, message;

    try {
        bibliosManager.delete(biblio_key);
        status = "ok";
        message = "";
    } catch (Exception e) {
        status = "fail";
        message = e.getLocalizedMessage();
    }

    JSONObject returnStatus = new JSONObject();
    returnStatus.put("status", status);
    returnStatus.put("message", message);
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Type", "application/json; charset=utf-8");

    return new ResponseEntity(returnStatus.toJSONString(), headers, HttpStatus.OK);
}