Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.adaptris.security.TestCompositeKeystore.java

public void testImportCertificate() throws Exception {
    CompositeKeystore ksp = new CompositeKeystore(keystoreLocationList);
    try {//  www  . java2 s  . co  m
        ksp.setCertificate("", "");
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (Certificate) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (InputStream) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (File) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
}

From source file:com.clustercontrol.notify.util.ExecCommand.java

private String getCommandString(OutputBasicInfo outputInfo, NotifyCommandInfo commandInfo, int priority) {
    // ??/*from   w  w w.  j  ava2s .c  o  m*/
    try {
        Map<String, String> param = NotifyUtil.createParameter(outputInfo, commandInfo.getNotifyInfoEntity());
        StringBinder binder = new StringBinder(param);
        return binder.bindParam(getCommand(commandInfo, priority));
    } catch (Exception e) {
        m_log.warn("notify() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);

        // ??????????
        return getCommand(commandInfo, priority);
    }
}

From source file:edu.gmu.csiss.automation.pacs.servlet.FileUploadServlet.java

/**
 * Processes requests for both HTTP/* w w  w.  j  av  a2  s. com*/
 * <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 req, HttpServletResponse res)
        throws ServletException, IOException {
    res.setContentType("text/plain;charset=gbk");

    res.setContentType("text/html; charset=utf-8");
    PrintWriter pw = res.getWriter();
    try {
        //initialize the prefix url
        if (prefix_url == null) {
            //                String hostname = req.getServerName ();
            //                int port = req.getServerPort ();
            //                prefix_url = "http://"+hostname+":"+port+"/igfds/"+relativePath+"/";
            //updated by Ziheng - on 8/27/2015
            //This method should be used everywhere.
            int num = req.getRequestURI().indexOf("/PACS");
            String prefix = req.getRequestURI().substring(0, num + "/PACS".length()); //in case there is something before PACS
            prefix_url = req.getScheme() + "://" + req.getServerName()
                    + ("http".equals(req.getScheme()) && req.getServerPort() == 80
                            || "https".equals(req.getScheme()) && req.getServerPort() == 443 ? ""
                                    : ":" + req.getServerPort())
                    + prefix + "/" + relativePath + "/";
        }
        pw.println("<!DOCTYPE html>");
        pw.println("<html>");
        String head = "<head>" + "<title>File Uploading Response</title>"
                + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"
                + "<script type=\"text/javascript\" src=\"js/TaskGridTool.js\"></script>" + "</head>";
        pw.println(head);
        pw.println("<body>");

        DiskFileItemFactory diskFactory = new DiskFileItemFactory();
        // threshold  2M 
        //extend to 2M - updated by ziheng - 9/25/2014
        diskFactory.setSizeThreshold(2 * 1024);
        // repository 
        diskFactory.setRepository(new File(tempPath));

        ServletFileUpload upload = new ServletFileUpload(diskFactory);
        // 2M
        upload.setSizeMax(2 * 1024 * 1024);
        // HTTP
        List fileItems = upload.parseRequest(req);
        Iterator iter = fileItems.iterator();
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            if (item.isFormField()) {
                processFormField(item, pw);
            } else {
                processUploadFile(item, pw);
            }
        } // end while()
          //add some buttons for further process
        pw.println("<input type=\"button\" id=\"bt\" value=\"load\" onclick=\"load();\">");
        pw.println("<input type=\"button\" id=\"close\" value=\"close window\" onclick=\"window.close();\">");
        pw.println("</body>");
        pw.println("</html>");
    } catch (Exception e) {
        e.printStackTrace();
        pw.println("ERR:" + e.getClass().getName() + ":" + e.getLocalizedMessage());
    } finally {
        pw.flush();
        pw.close();
    }
}

From source file:edu.fullerton.viewerplugin.XYPlotter.java

public int plotAndSave(double[][] data) throws WebUtilException {
    ChartPanel cpnl = getPanel(data);//from  ww w .j  a v  a2  s .  co m
    int imageId = 0;
    try {
        PluginSupport psup = new PluginSupport();
        psup.setup(db, vpage, vuser);
        psup.setSize(width, height);
        imageId = psup.saveImageAsPNG(cpnl);
    } catch (Exception ex) {
        throw new WebUtilException(
                "Creating XY plot: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
    }
    return imageId;
}

From source file:org.sonatype.nexus.repository.httpclient.internal.BlockingHttpClient.java

private String getReason(final Exception e) {
    if (e instanceof SSLPeerUnverifiedException) {
        return "Untrusted Remote";
    }/*from   ww w .j a  v a  2  s.co m*/
    return e.getClass().getName() + ": " + e.getMessage();
}

From source file:crossspectrumapp.CrossSpectrumApp.java

private void go(String[] args) {
    long startMs = System.currentTimeMillis();
    try {/*from   w  w  w. jav a 2 s .  c  o m*/
        cscl = new CrossSpectrumCommandLine();
        if (cscl.parseCommand(args, "CrossSpectrumApp", "0.0.0")) {
            doPlot();
        }

    } catch (Exception ex) {
        System.err.format("Error generating Cross Spectrum Plot: %1$s - %2$s \n", ex.getClass().getSimpleName(),
                ex.getLocalizedMessage());
    }
    float elapsedTimeSeconds = (System.currentTimeMillis() - startMs) / 1000.f;
    System.out.format("Elapsed time: %1$.1fs\n", elapsedTimeSeconds);
}

From source file:nl.b3p.imagetool.ImageCollector.java

public ImageCollector call() throws Exception {
    status = ACTIVE;//from w  w  w  . j a v  a  2 s. c o  m
    try {
        log.info(preLog + "starting download from URL " + combinedImageUrl);
        downloadImage(combinedImageUrl.getUrl());

        status = COMPLETED;
    } catch (Exception ex) {
        log.error(String.format(preLog + "exception downloading image from URL %s: %s: %s",
                combinedImageUrl.toString(), ex.getClass().getName(), ex.getMessage()));
        log.debug("Full stacktrace for exception downloading image", ex);
        status = ERROR;
    }
    return this;
}

From source file:de.devbliss.apitester.dummyserver.DummyRequestHandler.java

private void handleException(Exception e, HttpServletResponse response) throws IOException {
    response.setContentType(CONTENT_TYPE_ERROR);
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    response.getWriter().write("exception type: " + e.getClass());
    response.getWriter().write(e.getMessage());
}

From source file:com.transcend.rds.worker.DescribeDBInstancesActionWorker.java

@Override
protected DescribeDBInstancesActionResultMessage doWork0(DescribeDBInstancesActionRequestMessage req,
        ServiceRequestContext context) throws Exception {
    DescribeDBInstancesActionResultMessage.Builder result = null;
    String msg = "";
    final Session sess = HibernateUtil.newSession();
    try {//from w  w  w  .j a  v  a2  s.  com
        sess.beginTransaction();
        final AccountBean ac = context.getAccountBean();
        final long userID = ac.getId();
        final String instanceID = req.getDbInstanceIdentifier();
        final String marker = req.getMarker();
        final int maxRecords = ValidationManager.validateMaxRecords(req.getMaxRecords(), false);

        logger.info("DescribeInstance: " + " UserID = " + userID + " InstanceID  = " + instanceID + " Marker = "
                + marker + " MaxRecords = " + maxRecords);
        final List<RdsDbinstance> il = InstanceEntity.selectInstances(sess, instanceID, ac, marker, maxRecords);

        if (instanceID != null && il.size() == 0) {
            throw RDSQueryFaults.DBInstanceNotFound();
        }

        // build response document resp = new DescribeDBInstancesResponse();
        final List<DBInstance> dbs = new ArrayList<DBInstance>();
        if (il != null) {
            for (final RdsDbinstance inst : il) {
                final DBInstance dbInstance = toDBInstance(inst, ac);
                dbs.add(dbInstance);
            }
        }
        result = DescribeDBInstancesActionResultMessage.newBuilder();
        result.addAllDbInstances(dbs);
        if (il.size() > 0 && maxRecords <= il.size()) {
            result.setMarker(il.get(il.size() - 1).getDbinstanceId());
        }
        sess.getTransaction().commit();
    } catch (final ErrorResponse rde) {
        sess.getTransaction().rollback();
        throw rde;
    } catch (final Exception e) {
        e.printStackTrace();
        sess.getTransaction().rollback();
        msg = "DescribeInstance: Class: " + e.getClass() + "Msg:" + e.getMessage();
        logger.error(msg);
        throw RDSQueryFaults.InternalFailure();
    } finally {
        sess.close();
    }

    return result.buildPartial();
}

From source file:com.haulmont.cuba.web.app.ui.jmxcontrol.inspect.attribute.AttributeEditWindow.java

private boolean assignValue() {
    ManagedBeanAttribute mba = getItem();

    Object oldValue = mba.getValue();
    try {/*from w  w w  .  ja v a  2 s . co m*/
        Object newValue = valueHolder != null ? valueHolder.getAttributeValue(false) : null;
        if (newValue != null) {
            if (!ObjectUtils.equals(mba.getValue(), newValue)) {
                mba.setValue(newValue);
                jmxControlAPI.saveAttributeValue(mba);
            }
            return true;
        }
    } catch (Exception e) {
        getDialogOptions().setWidth(themeConstants.getInt("cuba.web.AttributeEditWindow.messageDialog.width"));

        showMessageDialog(String.format(getMessage("editAttribute.exception"), mba.getName()),
                e.getClass().getCanonicalName() + " " + e.getMessage() + "\n", MessageType.WARNING);
        mba.setValue(oldValue);
        return false;
    }
    showNotification(getMessage("editAttribute.conversionError"), NotificationType.HUMANIZED);
    return false;
}