List of usage examples for java.lang Exception fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:net.kamhon.ieagle.struts2.interceptor.LoggerInterceptor.java
public String intercept(ActionInvocation actionInvocation) throws Exception { Map<String, Object> params = actionInvocation.getInvocationContext().getParameters(); if (actionInvocation.getAction() instanceof Action) { Action action = (Action) actionInvocation.getAction(); log.debug("action = " + action.getClass().getName()); }//from ww w .ja va 2 s. c om ActionProxy actionProxy = actionInvocation.getProxy(); String actionType = params.get("actionType") != null ? ((String[]) params.get("actionType"))[0] : null; log.debug("action detail(name, method, type) = [" + actionProxy.getActionName() + ", " + actionProxy.getMethod() + ", " + actionType + "]"); log.debug("params = " + CollectionUtil.toLog(params)); try { return actionInvocation.invoke(); } catch (Exception ex) { if (exceptionLoggingBundle == null) { exceptionLoggingBundle = (ExceptionLoggingBundle) Application .lookupBean(ExceptionLoggingBundle.BEAN_NAME); } if (exceptionLoggingBundle.isNeedToLog(ex)) { log.error(ex, ex.fillInStackTrace()); } if (ex instanceof NullPointerException) { throw new DataException(ex.toString()); } else { throw ex; } } }
From source file:org.alfresco.repo.content.AbstractContentAccessor.java
/** * Derived classes can call this method to ensure that necessary trace logging is performed * when the IO Channel is opened.// w w w. java 2s . co m */ protected final void channelOpened() { // trace debug if (loggerTrace.isDebugEnabled()) { Exception e = new Exception(); e.fillInStackTrace(); traceLoggerChannelAssignTrace = e.getStackTrace(); } }
From source file:guru.qas.martini.jmeter.sampler.MartiniSampler.java
protected Exception getUnimplementedStepException(Martini martini, Step step) { Resource source = martini.getRecipe().getSource(); String relative;//from w w w .ja va2 s . c o m try { URL url = source.getURL(); String externalForm = url.toExternalForm(); int i = externalForm.lastIndexOf('!'); relative = i > 0 && externalForm.length() > i + 1 ? externalForm.substring(i + 1) : externalForm; } catch (IOException e) { logger.warn("unable to obtain URL from Resource " + source, e); relative = source.toString(); } int line = step.getLocation().getLine(); String message = String.format("unimplemented step: %s line %s", relative, line); Exception exception = new Exception(message); exception.fillInStackTrace(); return exception; }
From source file:com.ubundude.timesheet.MainUIFragment.java
/** * Get current date and time and place them into Timestamp table as generic entry * //from www. j av a 2 s . c om * @param view * @throws SQLException */ private void quickAddHandler(int proId) throws SQLException { Log.d("QuickAdd", "Got project id: " + proId); /** Strings and int for the current dates and project */ String timeIn, timeOut, dateIn, dateOut, wim, month, year; timeIn = formTime.format(c.getTime()); timeOut = timeIn; dateIn = formDate.format(c.getTime()); dateOut = dateIn; wim = formWIM.format(c.getTime()); month = formMonthNum.format(c.getTime()); year = formYear.format(c.getTime()); /** Open Database for writing */ db = dbHelp.getWritableDatabase(); /** String to insert a timestamp into the database */ String insertSQL = "insert into timestamp (date_in, time_in, date_out, time_out, week_year, year, month, hours, project) " + "values('" + dateIn + "', '" + timeIn + "', '" + dateOut + "', '" + timeOut + "', '" + wim + "', '" + year + "', '" + month + "', 0.00, '" + proId + "')"; try { db.execSQL(insertSQL); } catch (Exception e) { Log.d("save Fail", e.getLocalizedMessage(), e.fillInStackTrace()); } /** Close the Database */ db.close(); Log.d("QuickAdd", "Database Closed"); Log.d("QuickAdd", "Exiting"); getDailyTimestamps(date); }
From source file:org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl.java
@SuppressWarnings("unchecked") public void executeAction(RuntimeActionService actionService, Action action, NodeRef actionedUponNodeRef, boolean checkConditions, Set<String> actionChain, NodeRef actionExecutionHistoryNodeRef) { if (logger.isDebugEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Received request to execute async action ").append(action.getActionDefinitionName()) .append(" on ").append(actionedUponNodeRef); logger.debug(msg.toString());//from w w w .j a v a2 s. c o m msg = new StringBuilder(); msg.append("ThreadPool's active count = ").append(this.threadPoolExecutor.getActiveCount()); logger.debug(msg.toString()); msg = new StringBuilder(); msg.append("ThreadPool's queue size = ").append(this.threadPoolExecutor.getQueue().size()); logger.debug(msg.toString()); } Set<RuleServiceImpl.ExecutedRuleData> executedRules = (Set<RuleServiceImpl.ExecutedRuleData>) AlfrescoTransactionSupport .getResource("RuleServiceImpl.ExecutedRules"); Runnable runnable = new ActionExecutionWrapper(actionService, action, actionedUponNodeRef, checkConditions, actionChain, executedRules); // Consider whether this action should be filtered out by one of the registered filters. boolean newActionShouldBeFilteredOut = false; OngoingAsyncAction nodeBeingNewlyActioned = new OngoingAsyncAction(actionedUponNodeRef, action); for (Entry<String, AbstractAsynchronousActionFilter> entry : actionFilters.entrySet()) { AbstractAsynchronousActionFilter comparator = entry.getValue(); String actionDefinitionName = comparator.getActionDefinitionName(); if (actionDefinitionName.equals(action.getActionDefinitionName()) == false) { // We're only interested in registered actions with the same name as this one. continue; } else { // Now we've found a registered action that matches the current one. // So we'll go through the actions that are ongoing and consider them for matches with this one. // Need to synchronize to prevent changes to ongoingActions whilst iterating. Assume that ongoingActions // is not going to be too big and the loop will execute quite quickly, so that the synchronization // will not impact concurrency too much. synchronized (this.ongoingActions) { for (OngoingAsyncAction ongoingAction : this.ongoingActions) { if (comparator.compare(ongoingAction, nodeBeingNewlyActioned) == 0) { newActionShouldBeFilteredOut = true; break; } } } } } if (newActionShouldBeFilteredOut) { if (logger.isDebugEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Dropping action ").append(action).append(" as equivalent is ongoing."); logger.debug(msg.toString()); } return; } else { if (logger.isDebugEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Executing action ").append(action); logger.debug(msg.toString()); } // Queue it and do it. ongoingActions.add(nodeBeingNewlyActioned); threadPoolExecutor.execute(runnable); } // Done if (logger.isDebugEnabled()) { // get the stack trace Exception e = new Exception(); e.fillInStackTrace(); StackTraceElement[] trace = e.getStackTrace(); StringBuilder sb = new StringBuilder(); sb.append("\n").append("Placed action on execution queue: \n").append(" Action: " + action); String msg = sb.toString(); sb = new StringBuilder(); StackTraceUtil.buildStackTrace(msg, trace, sb, -1); logger.debug(sb); } }
From source file:guru.qas.martini.jmeter.sampler.MartiniSampler.java
protected SampleResult sample(DefaultMartiniResult martiniResult) { Martini martini = martiniResult.getMartini(); Map<Step, StepImplementation> stepIndex = martini.getStepIndex(); String label = martini.getScenarioName(); SampleResult sampleResult = new SampleResult(); sampleResult.setSampleLabel(label);//from w ww.jav a 2 s . com sampleResult.setSuccessful(true); sampleResult.sampleStart(); for (Map.Entry<Step, StepImplementation> mapEntry : stepIndex.entrySet()) { Step step = mapEntry.getKey(); StepImplementation implementation = mapEntry.getValue(); DefaultStepResult stepResult = new DefaultStepResult(step, implementation); martiniResult.add(stepResult); publishBeforeStep(martiniResult); SampleResult subResult; if (sampleResult.isSuccessful()) { JMeterContext threadContext = super.getThreadContext(); SamplerContext samplerContext = new SamplerContext(threadContext); samplerContext.clear(); subResult = getSubResult(step, implementation); update(stepResult, subResult, samplerContext); } else { subResult = getSkipped(step); Exception exception = getUnimplementedStepException(martini, step); exception.fillInStackTrace(); stepResult.setException(exception); stepResult.setStatus(Status.SKIPPED); } try { String json = stepMarshaller.getJson(stepResult); subResult.setDataType(SampleResult.TEXT); subResult.setResponseHeaders("Content-Type: application/json"); subResult.setResponseData(json, "UTF-8"); } catch (Exception e) { logger.error("unable to marshall StepResult", e); } sampleResult.addSubResult(subResult); sampleResult.setSuccessful(sampleResult.isSuccessful() && subResult.isSuccessful()); publishAfterStep(martiniResult); } try { martiniResult.setStartTimestamp(sampleResult.getStartTime()); martiniResult.setEndTimestamp(sampleResult.getEndTime()); martiniResult.setExecutionTimeMs(sampleResult.getTime()); String json = martiniMarshaller.getJson(martiniResult); sampleResult.setDataType(SampleResult.TEXT); sampleResult.setResponseHeaders("Content-Type: application/json"); sampleResult.setResponseData(json, "UTF-8"); } catch (Exception e) { logger.error("unable to marshall MartiniResult; will not include ResponseData", e); } return sampleResult; }
From source file:com.wineaccess.wine.WineAdapterHelper.java
/** * Method to enable/disable the wine//from www. j a v a 2 s . c om * @param ChangeWineStatusPO * @return */ public static Map<String, Object> performBulkOperation(final ChangeWineStatusPO changeWineStatusPO) { Response response = new FailureResponse(); response.setStatus(200); final Map<String, Object> outputBulkOperation = new ConcurrentHashMap<String, Object>(); try { Map<String, Boolean> dependantFieldsMap = new HashMap<String, Boolean>(); final String bulkOperation = changeWineStatusPO.getBulkOperation(); final List<Long> wineList = changeWineStatusPO.getProductId(); String forceUpdate = "false"; if (null != wineList || wineList.isEmpty()) { //List<Long> wineIds = ProductItemRepository.getWineIds(wineList, null); if (null != changeWineStatusPO.getForceUpdate() && !("").equals(changeWineStatusPO.getForceUpdate())) { forceUpdate = changeWineStatusPO.getForceUpdate(); } dependantFieldsMap.put("isDeleted", true); BulkDeleteModel<WineModel> bulkDeleteModel = null; if (("E").equals(bulkOperation)) { dependantFieldsMap.put("isEnabled", true); bulkDeleteModel = WineRepository.enableDisable(wineList, Boolean.parseBoolean(forceUpdate), dependantFieldsMap, true); } else { dependantFieldsMap.put("isEnabled", false); bulkDeleteModel = WineRepository.enableDisable(wineList, Boolean.parseBoolean(forceUpdate), dependantFieldsMap, false); } DeleteVO<WineDetails> wineDetailsForDependency = new DeleteVO<WineDetails>(); DeleteVO<WineDetails> wineDetailsForDeleted = new DeleteVO<WineDetails>(); List<WineDetails> deleteList = new ArrayList<WineDetails>(); List<WineDetails> dependencyList = new ArrayList<WineDetails>(); List<WineModel> canBeDeletedList = bulkDeleteModel.getDeletedList(); for (WineModel wineModel : canBeDeletedList) { deleteList.add(populateWineDetails(wineModel)); } wineDetailsForDeleted.setElements(deleteList); List<WineModel> canNotBeDeletedList = bulkDeleteModel.getNotDeletedList(); for (WineModel wineModel : canNotBeDeletedList) { dependencyList.add(populateWineDetails(wineModel)); } wineDetailsForDependency.setElements(dependencyList); List<Long> nonExistingList = (List<Long>) bulkDeleteModel.getNotExistsList(); ChangeWineStatusResponse changeWineStatusResponse = new ChangeWineStatusResponse(); changeWineStatusResponse.setNonExistsList(nonExistingList); changeWineStatusResponse.setFailureList(wineDetailsForDependency); changeWineStatusResponse.setSuccessList(wineDetailsForDeleted); response = new com.wineaccess.response.SuccessResponse(changeWineStatusResponse, SUCCESS_CODE); } else { response.addError(new WineaccessError(SystemErrorCode.WINE_PRODUCT_ID_MISSING, SystemErrorCode.WINE_PRODUCT_ID_MISSING_TEXT)); } } catch (Exception e) { response.addError(new WineaccessError(SystemErrorCode.WINE_UPDATE_STATUS_ERROR, SystemErrorCode.WINE_UPDATE_STATUS_ERROR_TEXT)); logger.error("Error while updating the status of Wine. ", e.fillInStackTrace()); } outputBulkOperation.put("FINAL-RESPONSE", response); return outputBulkOperation; }
From source file:com.wineaccess.wine.WineAdapterHelper.java
/** * Method to add/update wine logistic//ww w .j av a 2 s . com * @param addLogisticPO PO to add wine logistic * @return */ public static Map<String, Object> addLogistic(final AddLogisticPO addLogisticPO) { Response response = new FailureResponse(); response.setStatus(200); final WineLogisticBasicVO addWineVO = new WineLogisticBasicVO(); final Long wineryId = Long.parseLong(addLogisticPO.getWineryId()); final Long productId = Long.parseLong(addLogisticPO.getProductId()); final Long contactId = Long.parseLong(addLogisticPO.getContactId()); final Map<String, Object> outputAddLogistic = new ConcurrentHashMap<String, Object>(); try { final WineryModel wineryModel = WineryRepository.getWineryById(wineryId); final ImporterModel importerModel = wineryModel.getActiveImporterId(); ProductItemModel productModel = ProductItemRepository.getProductItemById(productId); WineModel wineModel = null; WineryImporterContacts contactModel = null; MasterData bottlePerBox = null; WarehouseModel warehouseModel = null; if (productModel != null) { wineModel = WineRepository.getWineById(productModel.getItemId()); if (wineModel == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_WINE, SystemErrorCode.LOGISTIC_INVALID_WINE_TEXT)); logger.error("wine not exist"); } } if (wineryModel == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_WINERY, SystemErrorCode.LOGISTIC_INVALID_WINERY_TEXT)); logger.error("winery not exist"); } if (productModel == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_PRODUCT, SystemErrorCode.LOGISTIC_INVALID_PRODUCT_TEXT)); logger.error("product not exist"); } if (productModel != null && wineModel != null && wineryModel != null) { if (addLogisticPO.getWarehouseId() != null && !(StringUtils.EMPTY).equals(addLogisticPO.getWarehouseId())) { warehouseModel = WarehouseRepository .getNonDeletedWarehouseById(Long.parseLong(addLogisticPO.getWarehouseId())); if (warehouseModel == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_WAREHOUSE, SystemErrorCode.LOGISTIC_INVALID_WAREHOUSE_TEXT)); logger.error("warehouse does not exist"); } } else { wineModel.setWarehouseId(warehouseModel); } contactModel = WineryImporterContactRepository .getContactById(Long.parseLong(addLogisticPO.getContactId())); //contactModel = WineryImporterContactRepository.getContactByContactIdWineryId(wineryId,contactId); bottlePerBox = MasterDataRepository .getMasterDataById(Long.parseLong(addLogisticPO.getBottlePerBox())); final Long wineryIdFromModel = wineModel.getWineryId().getId(); final Long wineIdFromModel = wineryModel.getId(); if (!wineryIdFromModel.equals(wineIdFromModel)) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_WINE_WINERY, SystemErrorCode.LOGISTIC_INVALID_WINE_WINERY_TEXT)); logger.error("wine and winery combination not exist"); } if (contactModel == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_CONTACT, SystemErrorCode.LOGISTIC_INVALID_CONTACT_TEXT)); logger.error("wine and winery combination not exist"); } if (bottlePerBox == null) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_INVALID_BOTTLE_PER_BOX, SystemErrorCode.LOGISTIC_INVALID_BOTTLE_PER_BOX_TEXT)); logger.error("wine and winery combination not exist"); } } if (response.getErrors().isEmpty() && wineModel != null) { wineModel.setWarehouseId(warehouseModel); wineModel.setContactId(contactModel); wineModel.setIsFullCaseOnly(Boolean.valueOf(addLogisticPO.getIsFullCaseOnly())); wineModel.setBottleWeightInLBS(Long.parseLong(addLogisticPO.getBottleWeightInLBS())); wineModel.setBottlesPerBox(bottlePerBox); wineModel = WineRepository.update(wineModel); if (wineModel.getId() != null) { addWineVO.setWineId(wineModel.getId()); addWineVO.setWineryId(wineModel.getWineryId().getId()); addWineVO.setProductId(productModel.getId()); addWineVO.setMessage("Logistic for Wine Created"); response = new com.wineaccess.response.SuccessResponse(addWineVO, 200); } else { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_NOT_CREATED, SystemErrorCode.LOGISTIC_NOT_CREATED_TEXT)); } } } catch (Exception e) { response.addError(new WineaccessError(SystemErrorCode.LOGISTIC_NOT_CREATED, SystemErrorCode.LOGISTIC_NOT_CREATED_TEXT)); logger.error("Some error occured", e.fillInStackTrace()); } outputAddLogistic.put("FINAL-RESPONSE", response); return outputAddLogistic; }
From source file:org.alfresco.repo.action.ActionTrackingServiceImpl.java
public boolean isCancellationRequested(CancellableAction action) { // If the action isn't in the cache, but is of // status executing, then put it back into the // cache and warn // (Probably means the cache is too small) String key = generateCacheKey(action); ExecutionDetails details = getExecutionDetails(buildExecutionSummary(key)); if (details == null) { Exception e = new Exception("Cancellation status missing from cache"); e.fillInStackTrace(); logger.warn("Unable to check cancellation status for running action " + action + " with execution key " + key + " as it wasn't in the running actions cache! " + "Your running actions cache is probably too small", e); // Re-generate details = buildExecutionDetails(action); // Re-save into the cache, so it's there for // next time executingActionsCache.put(key, details); }/*from w w w .j a v a 2s . c om*/ // Check the cached details, and see if cancellation // has been requested return details.isCancelRequested(); }
From source file:org.openmrs.module.FacesRegister.web.controller.Faces361BRegisterManageController.java
@RequestMapping(value = "/module/FacesRegister/patientList", method = RequestMethod.POST) public void artStart(Model model, @RequestParam(value = "location", required = true) String location, @RequestParam(value = "Startdate", required = true) String artsDate, @RequestParam(value = "Enddate", required = true) String cendDate) { // Do Stuff with the location, and date log.info(location);/*ww w . j a va 2 s. c om*/ log.info(artsDate); log.info(location); log.info(cendDate); log.info(dateFormat(cendDate)); RegisterService service = Context.getService(RegisterService.class); Location l = Context.getLocationService().getLocation(location); //get the Id for the selected site/facility log.info("Selected Location " + l.getLocationId() + " - " + l.getName()); try { SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy"); HashMap<Patient, String> patients = service.getPatientsGivenArtDates(l.getLocationId(), sdf.parse(artsDate), sdf.parse(cendDate)); //Convert patients to persons List<Person> person = new ArrayList<Person>(); for (Patient px : patients.keySet()) person.add(px); List<ArtRegister> artRegister = new ArrayList<ArtRegister>(); //HashMap<Patient, Date> artdates=service.getArtStartDates(person,l.getLocationId()); HashMap<Patient, String> whoStage = service.getStatusatStartArtWHO(person, sdf.parse(artsDate), sdf.parse(cendDate)); //HashMap<Patient, String>cd4=service.getCD4CountAtStart(person, sdf.parse(artsDate), sdf.parse(cendDate)); HashMap<Patient, String> cd4Count = service.getCD4CountAtStart(person, sdf.parse(artsDate), sdf.parse(cendDate)); HashMap<Patient, String> weight = service.getWeightatStart(person, sdf.parse(artsDate), sdf.parse(cendDate)); HashMap<Patient, String> originalRegimen = service.getOriginalRegimen(person); HashMap<Patient, String> ctx = service.getCtxStart(person); HashMap<Patient, String> tb = service.getTBStart(person); HashMap<Patient, String> inh = service.getINHStart(person); HashMap<Patient, String> monthly[]; Integer n = service.getMonths(sdf.parse(cendDate)); monthly = new HashMap[n]; for (int i = 0; i < n; i++) { monthly[i] = service.getMonthlyReg(person, sdf.parse(cendDate), i + 1); } int serial = 1; for (Patient p : patients.keySet()) { ArtRegister artRcd = new ArtRegister(); artRcd.setPatient(p); artRcd.setId(serial); artRcd.setArtStartDate(patients.get(p)); artRcd.setWhoStage(whoStage.get(p)); artRcd.setCd4Count(cd4Count.get(p)); artRcd.setWeightStartArt(weight.get(p)); artRcd.setOriginalReg(originalRegimen.get(p)); artRcd.setCtxStart(ctx.get(p)); artRcd.setInhStart(inh.get(p)); artRcd.setTbStart(tb.get(p)); artRcd.setnMonths(n); /* * Creating a list of monthly regimen prescriptions for the current patient */ List<String> monthlyReg = new ArrayList<String>(); for (int x = 0; x < n; x++) { monthlyReg.add(monthly[x].get(p)); } artRcd.setMonthlyVisit(monthlyReg); serial++; artRegister.add(artRcd); } //model.addAttribute("artLocationResults", patients); model.addAttribute("artLocationResults", artRegister); // RedirectView rv = new RedirectView("/module/FacesRegister/manage"); //return rv; } catch (Exception e) { log.error("Error " + e.getMessage() + " \n " + e.fillInStackTrace()); } }