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:com.sirti.microservice.hbase.service.HKpiService.java

public HKpiResultSet findAll() {
    HKpiResultSet hkpiresultset = new HKpiResultSet();

    try {//w  ww  .j  a  v  a2  s.  com
        long starttime = System.nanoTime();
        List<HKpi> hkpilist = hKpiDao.findAll();
        long endtime = System.nanoTime();
        hkpiresultset.setHKpiList(hkpilist);
        hkpiresultset.setDuration((endtime - starttime) / 1000000);
        hkpiresultset.setError(Boolean.FALSE);
    } catch (Exception e) {
        hkpiresultset.setError(Boolean.TRUE);
        hkpiresultset.setErrorMsg(e.getLocalizedMessage());
    }
    return hkpiresultset;
}

From source file:com.sirti.microservice.hbase.service.HKpiService.java

public HKpiResultSet findFilterAlarms(String filter) {
    HKpiResultSet hkpiresultset = new HKpiResultSet();

    try {/* w  ww  .  j  a  va 2 s  . com*/
        long starttime = System.nanoTime();
        List<HKpi> hkpilist = hKpiDao.findFilterHKpi(filter);
        long endtime = System.nanoTime();
        hkpiresultset.setHKpiList(hkpilist);
        hkpiresultset.setDuration((endtime - starttime) / 1000000);
        hkpiresultset.setError(Boolean.FALSE);
    } catch (Exception e) {
        hkpiresultset.setError(Boolean.TRUE);
        hkpiresultset.setErrorMsg(e.getLocalizedMessage());
    }
    return hkpiresultset;
}

From source file:com.amazonaws.mturk.cmd.UpdateHITs.java

protected void runCommand(CommandLine cmdLine) throws Exception {

    if (!cmdLine.hasOption(ARG_SUCCESS)) {

        log.error("Missing: -" + ARG_SUCCESS + " [path to success file -- eg. c:\\mturk\\helloworld.success]");
        System.exit(-1);/*  ww w.ja  va2 s .  c  o m*/

    } else if (!cmdLine.hasOption(ARG_PROPERTIES)) {

        log.error("Missing: -" + ARG_PROPERTIES
                + " [path to config file -- eg. c:\\mturk\\helloworld.properties]");
        System.exit(-1);

    }

    try {
        updateHITs(cmdLine.getOptionValue(ARG_SUCCESS), cmdLine.getOptionValue(ARG_PROPERTIES));
    } catch (Exception e) {
        log.error("Error loading HITs: " + e.getLocalizedMessage(), e);
        System.exit(-1);
    }
}

From source file:com.sirti.microservice.hbase.service.UnicoStoricoService.java

public UnicoStoricoResultSet findAll() {
    UnicoStoricoResultSet hkpiresultset = new UnicoStoricoResultSet();

    try {// w w w. jav a 2s .  c o m
        long starttime = System.nanoTime();
        List<UnicoStorico> hkpilist = unicoStoricoDao.findAll();
        long endtime = System.nanoTime();
        hkpiresultset.setList(hkpilist);
        hkpiresultset.setDuration((endtime - starttime) / 1000000);
        hkpiresultset.setError(Boolean.FALSE);
    } catch (Exception e) {
        hkpiresultset.setError(Boolean.TRUE);
        hkpiresultset.setErrorMsg(e.getLocalizedMessage());
    }
    return hkpiresultset;
}

From source file:com.sirti.microservice.hbase.service.UnicoStoricoService.java

public UnicoStoricoResultSet findFilterAlarms(String filter) {
    UnicoStoricoResultSet hkpiresultset = new UnicoStoricoResultSet();

    try {//w w  w  .  ja v  a  2 s .c  o m
        long starttime = System.nanoTime();
        List<UnicoStorico> hkpilist = unicoStoricoDao.findFilterUnicoStorico(filter);
        long endtime = System.nanoTime();
        hkpiresultset.setList(hkpilist);
        hkpiresultset.setDuration((endtime - starttime) / 1000000);
        hkpiresultset.setError(Boolean.FALSE);
    } catch (Exception e) {
        hkpiresultset.setError(Boolean.TRUE);
        hkpiresultset.setErrorMsg(e.getLocalizedMessage());
    }
    return hkpiresultset;
}

From source file:it.geosolutions.httpproxy.service.ProxyServiceDefaultTest.java

/**
 * Test IProxyService execute as HTTP GET
 *//*from  w  ww  .  j  a va2 s.  c o  m*/
@Test
public void testExecuteGet() {
    try {
        // Generate mocked request and response
        MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", "/proxy/");
        mockRequest.addParameter("url", TEST_URL);
        MockHttpServletResponse mockResponse = new MockHttpServletResponse();

        // Call proxy execute
        proxy.execute(mockRequest, mockResponse);

        // Assert the response
        assertNotNull(mockResponse);
        assertEquals(mockResponse.getStatus(), HttpStatus.SC_OK);
        assertNotNull(mockResponse.getOutputStream());
        assertNotNull(mockResponse.getContentType());
        assertTrue(mockResponse.getContentType().contains("application/vnd.ogc.wms_xml"));

        LOGGER.info("Success proxy GET in '" + TEST_URL + "'");
        LOGGER.info("************************ Response ************************");
        LOGGER.info(mockResponse.getContentAsString());
        LOGGER.info("********************** EoF Response **********************");

    } catch (Exception e) {
        fail("Exception executing proxy-->\t" + e.getLocalizedMessage());
    }
}

From source file:hotel.web.util.RegistrationVerifier.java

/**
 * Processes requests for both HTTP/* w  ww  .j  a  v a  2 s . co  m*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    String errMsg = "";
    String destination = "/registrationVerified.jsp";

    try {
        String id = request.getParameter("id");
        byte[] decoded = Base64.decode(id.getBytes());
        String username = new String(decoded);
        Users user = userService.find(username);
        if (user == null) {
            throw new RuntimeException("Sorry, that user is not in our system");
        }
        user.setEnabled(true);
        userService.edit(user);

    } catch (Exception dae) {
        errMsg = "VERIFICATION ERROR: " + dae.getLocalizedMessage();
        request.setAttribute("errMsg", errMsg);
        destination = "/registrationError.jsp";
    }

    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(destination);
    dispatcher.forward(request, response);

}

From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java

public String generateHeatmap(String[] rows, String[] columns, String[][] data) {

    JPanel heatmapPanelLayout = new JPanel();
    heatmapPanelLayout.setLayout(null);//from  ww  w  . ja v  a 2  s  .com
    heatmapPanelLayout.setVisible(true);
    heatmapPanelLayout.setBorder(new LineBorder(Color.BLACK));
    int width = (columns.length + 1) * 50;
    int height = (rows.length + 1) * 50;
    heatmapPanelLayout.setSize(width, height);
    JPanel cornerCell = initCell("#ffffff", 0, 0);
    int x = 50;
    int y = 0;
    heatmapPanelLayout.add(cornerCell);

    for (String headerCell : columns) {
        JPanel cell = initCell(headerCell, x, y);
        x += 50;
        heatmapPanelLayout.add(cell);

    }
    y = 50;
    for (String headerCell : rows) {
        JPanel cell = initCell(headerCell, 0, y);
        y += 50;
        heatmapPanelLayout.add(cell);

    }
    x = 50;
    y = 50;
    for (String[] row : data) {
        for (String color : row) {
            JPanel cell = initCell(color, x, y);
            heatmapPanelLayout.add(cell);
            x += 50;
        }
        x = 50;
        y += 50;
    }

    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D graphics = image.createGraphics();
    graphics.setPaint(Color.WHITE);
    heatmapPanelLayout.paint(graphics);
    //        super.paint(graphics);
    byte[] imageData = null;

    try {

        ImageEncoder in = ImageEncoderFactory.newInstance(ImageFormat.PNG, new Float(0.084666f));
        imageData = in.encode(image);
    } catch (Exception e) {
        System.out.println(e.getLocalizedMessage());
    }

    String base64 = Base64.encodeBytes(imageData);
    base64 = "data:image/png;base64," + base64;
    return base64;
    //
    //        JFrame frame = new JFrame();
    //        frame.setSize(1000, 1000);
    //        frame.add(heatmapPanelLayout);
    //        frame.setVisible(true);

    //        return "";
}

From source file:eu.musesproject.client.connectionmanager.TLSManager.java

/**
 * Convert local certificate to BKS/*from www.j  a  v a2  s .  c o m*/
 * @param cerStream
 * @param alias
 *    
 * @param password
 * @return keyStore
 */
private KeyStore convertCerToBKS(InputStream cerStream, String alias, char[] password) {
    KeyStore keyStore = null;
    try {
        keyStore = KeyStore.getInstance("BKS", "BC");
        CertificateFactory factory = CertificateFactory.getInstance("X.509", "BC");
        Certificate certificate = factory.generateCertificate(cerStream);
        keyStore.load(null, password);
        keyStore.setCertificateEntry(alias, certificate);
    } catch (Exception e) {
        Log.d(TAG, e.getLocalizedMessage());
    }
    return keyStore;
}

From source file:com.sun.socialsite.web.ui.core.struts2.SelfRegistration.java

public String save() {
    try {/*from   w  w  w . java  2  s . co m*/
        createUser(newUser);
    } catch (Exception ex) {
        this.setError("SelfRegistration.error", ex.getLocalizedMessage());
        log.error("Unexpected Exception", ex);
        return INPUT;
    }
    addMessage("SelfRegistration.saved");
    return SUCCESS;
}