Example usage for java.lang Exception getStackTrace

List of usage examples for java.lang Exception getStackTrace

Introduction

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

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:org.jenkinsci.plugins.appio.service.AppioService.java

/**
 * @param appId//  ww  w .j  a  v  a 2s  . c  o m
 * @param urlUpload
 * @return
 * @throws Exception
 */
public AppioVersionObject addVersion(String appId, String urlUpload) throws Exception {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    ResponseHandler<String> handler = new BasicResponseHandler();
    AppioVersion newVersion = new AppioVersion();
    AppioVersionObject versionObj = new AppioVersionObject();

    try {
        // Construct {"version": ... } message body
        versionObj.setApp_id(appId);
        versionObj.setBundle_url(urlUpload);
        newVersion.setVersion(versionObj);
        LOGGER.fine("AppioService.addVersion() Request: " + new Gson().toJson(newVersion));

        // Send new version REST call to Appio
        httpPostVersions.addHeader("Authorization", "Basic " + apiKey);
        httpPostVersions.addHeader("Content-Type", "application/json");
        httpPostVersions.addHeader("Accept", appio_v1);
        StringEntity reqBody = new StringEntity(new Gson().toJson(newVersion),
                ContentType.create("application/json", "UTF-8"));
        httpPostVersions.setEntity(reqBody);
        HttpResponse response = httpClient.execute(httpHost, httpPostVersions);

        String jsonAppioVersion = handler.handleResponse(response);
        LOGGER.fine("AppioService.addVersion() Response: " + jsonAppioVersion);
        newVersion = new Gson().fromJson(jsonAppioVersion, AppioVersion.class);

    } catch (Exception e) {
        e.getStackTrace();
        throw e;
    } finally {
        try {
            httpClient.getConnectionManager().shutdown();
        } catch (Exception ignore) {
        }
    }
    return newVersion.getVersion();
}

From source file:com.cnm.cnmrc.fragment.RcChannelVolume.java

/**
 * Loading TapPressAnimation <br>//www.j  ava 2 s  . c  om
 */
private void startLoadingAni(ImageButton view, final ImageView animView) {
    if (view != null) {
        view.post(new Runnable() {
            @Override
            public void run() {
                try {
                    mTapPressAnimation = new AnimationDrawable();
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress01), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress02), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress03), 60);
                    mTapPressAnimation.addFrame(getResources().getDrawable(R.drawable.tappress04), 60);
                    mTapPressAnimation.setOneShot(true);
                    animView.setImageDrawable(mTapPressAnimation);

                    // API 2.3.4?  ?... ???
                    // animView.setBackgroundResource(R.drawable.anim_tappress);
                    // mTapPressAnimation = (AnimationDrawable)
                    // animView.getBackground();

                    mTapPressDuration = 0;
                    for (int i = 0; i < mTapPressAnimation.getNumberOfFrames(); i++) {
                        mTapPressDuration += mTapPressAnimation.getDuration(i);
                    }

                    animView.setVisibility(View.VISIBLE);

                    // Start the animation (looped playback by default).
                    mTapPressAnimation.start();

                    mHandler.postDelayed(new Runnable() {
                        public void run() {
                            mTapPressAnimation.stop();
                            mTapPressAnimation = null;
                            animView.setBackgroundResource(0);
                            animView.setVisibility(View.INVISIBLE);
                            oneClickTapPress = true;
                        }
                    }, mTapPressDuration);
                } catch (Exception e) {
                    e.getStackTrace();
                }

            }
        });
    }

    //view.post(new Starter());
}

From source file:com.tridion.storage.si4t.JPASearchDAOFactory.java

private void logException(Exception e) {
    log.error(e.getMessage());
    log.error(Utils.stacktraceToString(e.getStackTrace()));
}

From source file:jenkins.plugins.ivyreport.GetResolutionCacheRootCallable.java

private IvySettings getIvySettings(PrintStream logger) throws AbortException {
    Message.setDefaultLogger(new IvyMessageImpl());
    File settingsLoc = (ivySettingsFile == null) ? null : new File(workspaceProper, ivySettingsFile);

    if ((settingsLoc != null) && (!settingsLoc.exists())) {
        throw new AbortException(
                Messages.IvyModuleSetBuild_NoSuchIvySettingsFile(settingsLoc.getAbsolutePath()));
    }//  w ww. j a  v  a 2s .  c om

    ArrayList<File> propertyFiles = new ArrayList<File>();
    if (StringUtils.isNotBlank(ivySettingsPropertyFiles)) {
        for (String file : ivySettingsPropertyFiles.split(",")) {
            File propertyFile = new File(workspaceProper, file.trim());
            if (!propertyFile.exists()) {
                throw new AbortException(
                        Messages.IvyModuleSetBuild_NoSuchPropertyFile(propertyFile.getAbsolutePath()));
            }
            propertyFiles.add(propertyFile);
        }
    }
    try {
        IvySettings ivySettings = new IvySettings(new EnvVarsVariableContainer(envVars));
        for (File file : propertyFiles) {
            ivySettings.loadProperties(file);
        }
        if (settingsLoc != null) {
            ivySettings.load(settingsLoc);
        } else {
            ivySettings.loadDefault();
        }
        if (ivyBranch != null) {
            ivySettings.setDefaultBranch(ivyBranch);
        }
        return ivySettings;
    } catch (Exception e) {
        logger.println("Error while reading the default Ivy 2.1 settings: " + e.getMessage());
        logger.println(e.getStackTrace());
    }
    return null;
}

From source file:org.opendaylight.fpc.notification.HTTPNotifier.java

@Override
public void run() {
    this.run = true;
    LOG.info("HTTPNotifier RUN started");
    try {// w ww.j  av a 2s  .  c  o m
        while (run) {
            SimpleEntry<Uri, Notification> obj = (AbstractMap.SimpleEntry<Uri, Notification>) blockingNotificationQueue
                    .take();
            String postBody = null;
            try {
                if (obj.getValue() instanceof ConfigResultNotification) {
                    postBody = fpcCodecUtils.notificationToJsonString(ConfigResultNotification.class,
                            (DataObject) obj.getValue(), true);
                } else if (obj.getValue() instanceof Notify) {
                    postBody = fpcCodecUtils.notificationToJsonString(Notify.class, (DataObject) obj.getValue(),
                            true);
                }
            } catch (Exception e) {
                ErrorLog.logError(e.getStackTrace());
            }
            if (obj.getKey() != null && postBody != null) {
                String url = obj.getKey().getValue();
                try {
                    client.start();
                    HttpRequest post = HttpAsyncMethods.createPost(url, postBody, ContentType.APPLICATION_JSON)
                            .generateRequest();
                    post.setHeader("User-Agent", "ODL Notification Agent");
                    post.setHeader("charset", "utf-8");
                    client.execute((HttpUriRequest) post, new FutureCallback<HttpResponse>() {
                        @Override
                        public void cancelled() {
                            LOG.error(post.getRequestLine() + "-> Cancelled");
                        }

                        @Override
                        public void completed(HttpResponse resp) {
                            try {
                                if (obj.getValue() instanceof Notify) {
                                    if (((Notify) obj.getValue())
                                            .getValue() instanceof DownlinkDataNotification) {
                                        String body = handler.handleResponse(resp);
                                        JSONObject json_body = new JSONObject(body);
                                        api.ddnAck(json_body);
                                        LOG.info("Response Body: " + body);
                                    }
                                }
                            } catch (IOException e) {
                                ErrorLog.logError(e.getStackTrace());
                            }
                        }

                        @Override
                        public void failed(Exception e) {
                            ErrorLog.logError(post.getRequestLine() + "->" + e.getMessage(), e.getStackTrace());
                        }
                    });
                } catch (UnsupportedEncodingException e) {
                    ErrorLog.logError(e.getStackTrace());
                } catch (IOException e) {
                    ErrorLog.logError(e.getStackTrace());
                } catch (HttpException e) {
                    ErrorLog.logError(e.getStackTrace());
                } catch (Exception e) {
                    ErrorLog.logError(e.getStackTrace());
                }
            }
        }
    } catch (InterruptedException e) {
        ErrorLog.logError(e.getStackTrace());
    } catch (Exception e) {
        ErrorLog.logError(e.getStackTrace());
    }
}

From source file:GUI.WebBrowserPanel.java

@Override
public void onLoadingEnded() {
    if (m_frame != null) {
        try {//from  www  .j a v  a2  s.  com
            String urltext = getDocument().getDocumentURI();
            URL url = new URL(urltext);
            InputStreamReader isr = new InputStreamReader(url.openStream());
            BufferedReader in = new BufferedReader(isr);
            String inputLine;

            urltext = null;
            url = null;

            m_content.clear();
            while ((inputLine = in.readLine()) != null) {
                m_content.add(inputLine);
            }
            in.close();

            isr = null;
            in = null;
            inputLine = null;

            Action action = parseHtml();
            if (action.value() == Action.ACTION_BROWSER_LOADING_DONE
                    && action.toString().equals(Action.COMMAND_CARD_PREVIEW)) {
                FileUtils.copyURLToFile(new URL(getCardImageURL(m_card.MID)), new File(m_card.getImagePath()));
                fireActionEvent(MainWindow.class, action.value(), action.toString());
            }

            action = null;

        } catch (Exception ex) {
            Dialog.ErrorBox(m_frame, ex.getStackTrace());
        }
    }
    m_loading = false;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.RefactorRetryController.java

public void doGet(HttpServletRequest request, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) {
        return;//from  w  ww  .ja va  2  s . co  m
    }

    //create an EditProcessObject for this and put it in the session
    EditProcessObject epo = super.createEpo(request);

    VitroRequest vreq = new VitroRequest(request);

    String modeStr = request.getParameter("mode");

    if (modeStr != null) {
        if (modeStr.equals("renameResource")) {
            doRenameResource(vreq, response, epo);
        } else if (modeStr.equals("movePropertyStatements")) {
            doMovePropertyStatements(vreq, response, epo);
        } else if (modeStr.equals("moveInstances")) {
            doMoveInstances(vreq, response, epo);
        }
    }

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    setRequestAttributes(request, epo);

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error(this.getClass().getName() + " could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.OntologyEditController.java

@Override
public void doPost(HttpServletRequest req, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) {
        return;/*  w  w w  .  jav a  2  s.co  m*/
    }

    VitroRequest request = new VitroRequest(req);

    EditProcessObject epo = super.createEpo(request);
    request.setAttribute("epoKey", epo.getKey());

    OntologyDao oDao = request.getUnfilteredWebappDaoFactory().getOntologyDao();
    Ontology o = null;
    if (request.getParameter("uri") == null) {
        log.error("doPost() expects non-null uri parameter");
    } else {
        o = oDao.getOntologyByURI(request.getParameter("uri"));
        if (o == null) {
            if (!VitroVocabulary.vitroURI.equals(request.getParameter("uri"))) {
                log.debug(
                        "doPost(): no ontology object found for the namespace " + request.getParameter("uri"));
            }
        } else {
            request.setAttribute("Ontology", o);
        }
    }
    ArrayList<String> results = new ArrayList<String>();
    results.add("Ontology");
    results.add("Namespace");
    results.add("Prefix");
    String name = o == null ? "" : (o.getName() == null) ? "" : o.getName();
    results.add(name);
    String namespace = o == null ? "" : (o.getURI() == null) ? "" : o.getURI();
    results.add(namespace);
    String prefix = o == null ? "" : (o.getPrefix() == null) ? "" : o.getPrefix();
    results.add(prefix);
    request.setAttribute("results", results);
    request.setAttribute("columncount", 3);
    request.setAttribute("suppressquery", "true");

    epo.setDataAccessObject(oDao);
    FormObject foo = new FormObject();
    HashMap<String, List<Option>> OptionMap = new HashMap<String, List<Option>>();

    HashMap formSelect = new HashMap(); // tells the JSP what select lists are populated, and thus should be displayed
    request.setAttribute("formSelect", formSelect);

    // add the options
    foo.setOptionLists(OptionMap);
    epo.setFormObject(foo);

    // funky hack because Ontology.getURI() will append a hash for a hash namespace
    // See OntologyDaoJena.ontologyFromOntologyResource() comments
    String realURI = OntologyDaoJena.adjustOntologyURI(o.getURI());
    request.setAttribute("realURI", realURI);
    request.setAttribute("exportURL", request.getContextPath() + Controllers.EXPORT_RDF);

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("epoKey", epo.getKey());
    request.setAttribute("bodyJsp", "/templates/edit/specific/ontologies_edit.jsp");
    request.setAttribute("title", "Ontology Control Panel");
    request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""
            + request.getAppBean().getThemeDir() + "css/edit.css\"/>");

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error("OntologyEditController could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.Properties2PropertiesRetryController.java

public void doGet(HttpServletRequest req, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) {
        return;//from www .ja  va 2  s.  c  o m
    }

    VitroRequest request = new VitroRequest(req);

    //create an EditProcessObject for this and put it in the session
    EditProcessObject epo = super.createEpo(request);

    String action = null;
    if (epo.getAction() == null) {
        action = "insert";
        epo.setAction("insert");
    } else {
        action = epo.getAction();
    }

    ObjectPropertyDao opDao = request.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
    DataPropertyDao dpDao = request.getUnfilteredWebappDaoFactory().getDataPropertyDao();
    epo.setDataAccessObject(opDao);

    List propList = ("data".equals(request.getParameter("propertyType"))) ? dpDao.getAllDataProperties()
            : opDao.getAllObjectProperties();

    sortForPickList(propList, request);

    String superpropertyURIstr = request.getParameter("SuperpropertyURI");
    String subpropertyURIstr = request.getParameter("SubpropertyURI");

    HashMap<String, Option> hashMap = new HashMap<String, Option>();
    List<Option> optionList = FormUtils.makeOptionListFromBeans(propList, "URI", "PickListName",
            superpropertyURIstr, null);
    List<Option> superPropertyOptions = getSortedList(hashMap, optionList, request);
    optionList = FormUtils.makeOptionListFromBeans(propList, "URI", "PickListName", subpropertyURIstr, null);
    List<Option> subPropertyOptions = getSortedList(hashMap, optionList, request);

    HashMap hash = new HashMap();
    hash.put("SuperpropertyURI", superPropertyOptions);
    hash.put("SubpropertyURI", subPropertyOptions);

    FormObject foo = new FormObject();
    foo.setOptionLists(hash);

    epo.setFormObject(foo);

    request.setAttribute("operation", "add");

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp");
    request.setAttribute("scripts", "/templates/edit/formBasic.js");
    String modeStr = request.getParameter("opMode");
    if (modeStr != null && (modeStr.equals("superproperty") || modeStr.equals("subproperty")
            || modeStr.equals("equivalentProperty"))) {
        request.setAttribute("editAction", "props2PropsOp");
        request.setAttribute("formJsp", "/templates/edit/specific/properties2properties_retry.jsp");
        request.setAttribute("title", (modeStr.equals("superproperty") ? "Add Superproperty"
                : modeStr.equals("equivalentProperty") ? "Add Equivalent Property" : "Add Subproperty"));
    }
    request.setAttribute("opMode", modeStr);

    request.setAttribute("_action", action);
    setRequestAttributes(request, epo);

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error(this.getClass().getName() + " could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}

From source file:ua.kiev.doctorvera.utils.SMSGateway.java

@SuppressWarnings("deprecation")
public ArrayList<String> send(String phone, String sms) {
    ArrayList<String> result = new ArrayList<String>();
    final String MESSAGE = "<message><service id='single' source='" + FROM + "'/><to>" + phone
            + "</to><body content-type='text/plain'>" + sms + "</body></message>";

    @SuppressWarnings("resource")
    HttpClient httpclient = new DefaultHttpClient();
    String xml = null;//from  w  w  w. j  av a  2s  . co m
    try {
        HttpPost httpPost = new HttpPost(SMS_SEND_URL);

        StringEntity entity = new StringEntity(MESSAGE, "UTF-8");
        entity.setContentType("text/xml");
        entity.setChunked(true);
        httpPost.setEntity(entity);
        httpPost.addHeader(
                BasicScheme.authenticate(new UsernamePasswordCredentials(LOGIN, PASS), "UTF-8", false));
        HttpResponse response = httpclient.execute(httpPost);
        HttpEntity resEntity = response.getEntity();
        LOG.info("Sending SMS: " + (response.getStatusLine().getStatusCode() == 200));
        xml = EntityUtils.toString(resEntity);
    } catch (Exception e) {
        LOG.severe("" + e.getStackTrace());
    } finally {
        httpclient.getConnectionManager().shutdown();
    }

    //parsing xml result
    Document doc = loadXMLFromString(xml);
    NodeList nl = doc.getElementsByTagName("status");
    Element status = (Element) nl.item(0);

    result.add(0, status.getAttribute("id").toString()); //tracking id at position 0
    result.add(1, status.getAttribute("date").toString()); //date at position 1
    result.add(2, getElementValue(status.getFirstChild())); //state at position 2
    return result;
}