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:edu.cornell.mannlib.vitro.webapp.controller.edit.Classes2ClassesRetryController.java

public void doPost(HttpServletRequest req, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) {
        return;//from   w ww  . ja  va  2s  . 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();
    }

    VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
    epo.setDataAccessObject(vcDao);
    Classes2Classes objectForEditing = new Classes2Classes();

    String superclassURIstr = request.getParameter("SuperclassURI");
    String subclassURIstr = request.getParameter("SubclassURI");
    if (superclassURIstr != null && superclassURIstr.length() > 0)
        objectForEditing.setSuperclassURI(superclassURIstr);
    if (subclassURIstr != null && subclassURIstr.length() > 0)
        objectForEditing.setSubclassURI(subclassURIstr);

    epo.setOriginalBean(objectForEditing);

    populateBeanFromParams(objectForEditing, request);

    HashMap hash = new HashMap();
    hash.put("SuperclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(), "URI", "PickListName",
            objectForEditing.getSuperclassURI(), null));
    hash.put("SubclassURI", FormUtils.makeOptionListFromBeans(vcDao.getAllVclasses(), "URI", "PickListName",
            objectForEditing.getSubclassURI(), null));

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

    epo.setFormObject(foo);

    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("disjointWith")) {
        request.setAttribute("editAction", "classes2ClassesOp");
        request.setAttribute("formJsp", "/templates/edit/specific/disjointClasses_retry.jsp");
        request.setAttribute("title", "Disjointness Axiom Editing Form");
    } else if (modeStr != null && modeStr.equals("equivalentClass")) {
        request.setAttribute("editAction", "classes2ClassesOp");
        request.setAttribute("formJsp", "/templates/edit/specific/equivalentClasses_retry.jsp");
        request.setAttribute("title", "Equivalent Class Editing Form");
    } else {
        request.setAttribute("formJsp", "/templates/edit/specific/class2classes_retry.jsp");
        request.setAttribute("title", "Super/Subclass Editing Form");
    }
    request.setAttribute("_action", action);
    request.setAttribute("unqualifiedClassName", "Classes2Classes");
    setRequestAttributes(request, epo);

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

}

From source file:org.catrobat.catroid.HomeController.java

@RequestMapping(value = "/*", method = RequestMethod.POST)
public String Upload(@RequestParam(value = "file", required = true) MultipartFile file, Model model,
        HttpServletRequest request) throws IOException {

    if (file == null)
        return home(model, request);
    if (!isCatrobatFile(file.getOriginalFilename())) {
        return error(model, "Illegal file!",
                "File you tried to upload is not .catrobat file. Please, upload catrobat project (e. g.\"project.catrobat\")");

    }/*from www .j ava 2s.c  om*/

    String appFolder = request.getSession().getServletContext().getRealPath("/");
    String uploadFolder = getUploadFolder(request);

    try {
        createProjectDir(appFolder, uploadFolder);
    } catch (UploadException e1) {
        return error(model, "Cannot create directory for project",
                "Oops, it seems we have some internal error. Please, try one more time and do mot hurry.");
    }

    String filePath = appFolder + uploadFolder + "\\" + file.getOriginalFilename();

    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new File(filePath));
        outputStream.write(file.getBytes());
        outputStream.close();
    } catch (Exception e) {
        return error(model, "Cannot save file", e.getStackTrace().toString());
    }

    setPathsToSesisionAttributes(request, appFolder, uploadFolder);

    ZipFile zip;
    try {
        zip = new ZipFile(filePath);
        zip.extractAll(appFolder + uploadFolder);
    } catch (ZipException e) {
        return error(model, "Cannot unzip project file", e.getStackTrace().toString());
    }

    return home(model, request);
}

From source file:org.cybercat.automation.core.ConfigurationManager.java

private Browser getRemoteBrowser(Browsers browserType) throws PageObjectException {
    try {/* w ww .  ja v a  2 s .  c o  m*/
        RemoteServerProvider rsp = context.getBean(RemoteServerProvider.class);
        browser = rsp.createRemoteWebDriver(browserType);
        browser = setupBrowser(browser);
        return browser;
    } catch (Exception e) {
        log.error(e.getMessage());
        log.error(e.getStackTrace());
        log.error(browserType.toString() + " remote browser is unsupported by your system.");
        throw new PageObjectException(e.getLocalizedMessage());
    }

}

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

public void doPost(HttpServletRequest request, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.DO_BACK_END_EDITING.ACTION)) {
        return;/*w w w . j  ava2  s.c  o  m*/
    }

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

    String action = "insert";

    VitroRequest vreq = new VitroRequest(request);

    DataPropertyStatementDao dataPropertyStatementDao = vreq.getUnfilteredWebappDaoFactory()
            .getDataPropertyStatementDao();
    epo.setDataAccessObject(dataPropertyStatementDao);
    DataPropertyDao dpDao = vreq.getUnfilteredWebappDaoFactory().getDataPropertyDao();
    IndividualDao eDao = vreq.getUnfilteredWebappDaoFactory().getIndividualDao();
    epo.setBeanClass(DataPropertyStatement.class);

    DataPropertyStatement objectForEditing = null;
    if (!epo.getUseRecycledBean()) {
        objectForEditing = new DataPropertyStatementImpl();
        populateBeanFromParams(objectForEditing, vreq);
        if (vreq.getParameter(MULTIPLEXED_PARAMETER_NAME) != null) {
            action = "update";
        }
        epo.setOriginalBean(objectForEditing);
    } else {
        objectForEditing = (DataPropertyStatement) epo.getNewBean();
    }

    FormObject foo = new FormObject();
    foo.setValues(new HashMap());
    HashMap OptionMap = new HashMap();
    List entityList = new LinkedList();
    if (objectForEditing.getIndividualURI() != null) {
        Individual individual = eDao.getIndividualByURI(objectForEditing.getIndividualURI());
        entityList.add(new Option(individual.getURI(), individual.getName(), true));
    } else {
        entityList.add(new Option("-1", "Error: the individual must be specified", true));
    }
    OptionMap.put("IndividualURI", entityList);
    DataProperty dp = dpDao.getDataPropertyByURI(objectForEditing.getDatapropURI());
    if (dp == null) {
        foo.getValues().put("Dataprop", "Error: the data property must be specified");
    } else {
        foo.getValues().put("Dataprop", dp.getPublicName());
    }
    foo.setOptionLists(OptionMap);
    epo.setFormObject(foo);

    FormUtils.populateFormFromBean(objectForEditing, action, foo);

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp");
    request.setAttribute("formJsp", "/templates/edit/specific/ents2data_retry.jsp");
    request.setAttribute("scripts", "/templates/edit/formBasic.js");
    request.setAttribute("title", "Individual Data Editing Form");
    request.setAttribute("_action", action);
    request.setAttribute("unqualifiedClassName", "DataPropertyStatement");
    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:de.uzk.hki.da.webservice.HttpFileTransmissionClient.java

/**
 * Cleanup./*ww  w  .j  av  a 2 s. c o m*/
 *
 * @throws ClientProtocolException the client protocol exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void cleanup() {
    HttpClient httpclient = null;
    try {
        httpclient = new DefaultHttpClient();

        HttpGet httpget = new HttpGet(url);
        HttpParams httpRequestParameters = httpget.getParams();
        httpRequestParameters.setParameter(ClientPNames.HANDLE_REDIRECTS, true);
        httpget.setParams(httpRequestParameters);
        java.net.URI uri = new URIBuilder(httpget.getURI()).addParameter("cleanup", "1").build();
        logger.debug("calling webservice for cleanup now. recieving response");
        httpget.setURI(uri);

        HttpResponse response = httpclient.execute(httpget);
        HttpEntity resEntity = response.getEntity();
        printResponse(resEntity);
    } catch (Exception e) {
        logger.error("Exception occured in cleanup " + e.getStackTrace());
        throw new RuntimeException("Webservice error " + url, e);
    } finally {
        if (httpclient != null)
            httpclient.getConnectionManager().shutdown();
    }
}

From source file:org.alfresco.repo.search.impl.noindex.NoIndexIndexer.java

private void trace() {
    if (s_logger.isTraceEnabled()) {
        Exception e = new Exception();
        e.fillInStackTrace();//w  w  w.j  a va 2s .  co  m

        StringBuilder sb = new StringBuilder(1024);
        StackTraceUtil.buildStackTrace("Index trace ...", e.getStackTrace(), sb, -1);
        s_logger.trace(sb);
    }
}

From source file:org.apache.pig.impl.logicalLayer.LOStore.java

public void setOutputFile(FileSpec outputFileSpec) throws IOException {
    try {/*  ww  w  .  jav  a2  s.  c o m*/
        mStoreFunc = (StoreFuncInterface) PigContext.instantiateFuncFromSpec(outputFileSpec.getFuncSpec());
    } catch (Exception e) {
        IOException ioe = new IOException(e.getMessage());
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
    }
    mOutputFile = outputFileSpec;
}

From source file:com.clinic.controller.BaseController.java

public void exceptionHander(HttpServletRequest request, Exception exception, HttpServletResponse response) {
    // /*from   w  w w  . j  a  v a2s .c  om*/
    StringBuffer sb = new StringBuffer();
    StackTraceElement[] stackArray = exception.getStackTrace();
    for (int i = 0; i < stackArray.length; i++) {
        StackTraceElement element = stackArray[i];
        sb.append(element.toString() + "\n");
    }
    log.error("" + sb.toString() + "" + exception.getMessage(), exception);
    // ???????
    if (exception instanceof ServiceException) {
        ServiceException e = (ServiceException) exception;
        switch (e.getErrorType()) {
        case ExceptionCode.GOODSCATEGORY_NULL_EXCEPTION:
            ResponseHandler.responseError(ResponseMessage.goodsCategory_dont_exist, response);
            break;
        case ExceptionCode.PRICE_ERROR:
            ResponseHandler.responseError(ResponseMessage.price_error, response);
            break;
        case ExceptionCode.USER_NO_LOGIN:
            ResponseHandler.responseApiLoginError(response);
            break;
        case ExceptionCode.DEL_GOODSCATEGORY_EXIST_PRODUCT:
            ResponseHandler.responseError(ResponseMessage.goodsCategory_product_error, response);
            break;
        case ExceptionCode.USER_NO_AUTHEN:
            ResponseHandler.responseError(ResponseMessage.account_no_auth, response);
            break;
        case ExceptionCode.SELLER_NO_OPEN_STORE:
            ResponseHandler.responseError(ResponseMessage.seller_no_store, response);
            break;
        case ExceptionCode.EXIST_BUSINESSLICENSENAME:
            ResponseHandler.responseError(ResponseMessage.exist_businesslicensename, response);
            break;
        case ExceptionCode.BUSINESSLICENSENAME_LENGTH_GT_30:
            ResponseHandler.responseError(ResponseMessage.businessLicenseName_length_gt_30, response);
            break;
        case ExceptionCode.BUSINESSLICENSENAME_LENGTH_LT_5:
            ResponseHandler.responseError(ResponseMessage.businessLicenseName_length_lt_5, response);
            break;
        default:
            ResponseHandler.responseServerError(response);
            break;
        }
        return;
    }
    if (exception instanceof com.alibaba.dubbo.rpc.RpcException) {
        ResponseHandler.responseServerTimeout(response);
    } else {
        ResponseHandler.responseServerError(response);
    }
}

From source file:news.pangbo.com.pangbbonews.ui.common.ShowPicViewPagerActivity.java

public void saveImg(Bitmap photo) {
    String path_file_img = Environment.getExternalStorageDirectory().getPath() + "/Qbang/down/"
            + System.currentTimeMillis() + ".jpg";
    File file_img = new File(path_file_img);

    File dir = new File(Environment.getExternalStorageDirectory().getPath() + "/Qbang/down/");
    if (!dir.exists()) {
        dir.mkdirs();/* www.  j av a  2s  . com*/
    }
    if (file_img.exists()) {
        file_img.delete();
    }
    FileOutputStream fos = null;
    try {
        file_img.createNewFile();
        fos = new FileOutputStream(file_img);
        photo.compress(Bitmap.CompressFormat.JPEG, 100, fos);

    } catch (Exception e) {
        e.getStackTrace();
    } finally {
        if (fos != null) {
            try {
                fos.flush();
                fos.close();
                ToastUtil.showToast(getApplicationContext(), "??" + path_file_img);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}

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

public void doPost(HttpServletRequest request, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.DO_BACK_END_EDITING.ACTIONS)) {
        return;/*  w ww  . j a  v a 2s  .  c om*/
    }

    VitroRequest vreq = new VitroRequest(request);

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

    String action = "insert";

    DataPropertyDao dpDao = vreq.getFullWebappDaoFactory().getDataPropertyDao();
    DataPropertyStatementDao edDao = vreq.getFullWebappDaoFactory().getDataPropertyStatementDao();
    epo.setDataAccessObject(edDao);
    epo.setBeanClass(DataPropertyStatement.class);

    IndividualDao eDao = vreq.getFullWebappDaoFactory().getIndividualDao();

    DataPropertyStatement eidForEditing = null;
    if (!epo.getUseRecycledBean()) {
        eidForEditing = new DataPropertyStatementImpl();
        populateBeanFromParams(eidForEditing, vreq);
        if (vreq.getParameter(MULTIPLEXED_PARAMETER_NAME) != null) {
            action = "update";
        }
        epo.setOriginalBean(eidForEditing);
    } else {
        eidForEditing = (DataPropertyStatement) epo.getNewBean();
    }

    //make a simple mask for the class's id
    Object[] simpleMaskPair = new Object[2];
    simpleMaskPair[0] = "Id";
    //simpleMaskPair[1]=Integer.valueOf(eidForEditing.getId());
    epo.getSimpleMask().add(simpleMaskPair);

    //set up any listeners

    FormObject foo = new FormObject();
    HashMap OptionMap = new HashMap();
    List entityList = new LinkedList();
    if (eidForEditing.getIndividualURI() != null) {
        Individual individual = eDao.getIndividualByURI(eidForEditing.getIndividualURI());
        entityList.add(new Option(individual.getURI(), individual.getName(), true));
    } else {
        entityList.add(new Option("-1", "Error: the entity must be specified", true));
    }
    OptionMap.put("IndividualURI", entityList);
    // TOOD change following DAO call to getAllExternalIdDataProperties once implemented
    List allExternalIdDataProperties = dpDao.getAllExternalIdDataProperties();
    Collections.sort(allExternalIdDataProperties);
    OptionMap.put("DatapropURI", FormUtils.makeOptionListFromBeans(allExternalIdDataProperties, "URI",
            "PublicName", eidForEditing.getDatapropURI(), ""));
    foo.setOptionLists(OptionMap);
    foo.setErrorMap(epo.getErrMsgMap());

    epo.setFormObject(foo);

    FormUtils.populateFormFromBean(eidForEditing, action, foo, epo.getBadValueMap());

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp");
    request.setAttribute("formJsp", "/templates/edit/specific/externalIds_retry.jsp");
    request.setAttribute("scripts", "/templates/edit/formBasic.js");
    request.setAttribute("title", "External Id Editing Form");
    request.setAttribute("_action", action);
    request.setAttribute("unqualifiedClassName", "External Id");
    setRequestAttributes(request, epo);

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

}