List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:com.silverpeas.ical.ImportIcalManager.java
/** * IMPORT SilverpeasCalendar in Ical format * @param file/*www.ja va 2 s .c o m*/ * @return * @throws Exception */ public String importIcalAgenda(File file) throws Exception { SilverTrace.debug("agenda", "ImportIcalManager.importIcalAgenda()", "root.MSG_GEN_ENTER_METHOD"); String returnCode = AgendaSessionController.IMPORT_FAILED; InputStreamReader inputStream = null; XmlReader xr = null; try { String charsetUsed = agendaSessionController.getSettings().getString("defaultCharset"); if (StringUtil.isDefined(charset)) { charsetUsed = charset; } // File Encoding detection xr = new XmlReader(file); SilverTrace.debug("agenda", "ImportIcalManager.importIcalAgenda()", "Encoding = " + xr.getEncoding()); if (StringUtil.isDefined(xr.getEncoding())) { charsetUsed = xr.getEncoding(); } inputStream = new InputStreamReader(new FileInputStream(file), charsetUsed); CalendarBuilder builder = new CalendarBuilder(); Calendar calendar = builder.build(inputStream); // Get all EVENTS for (Object o : calendar.getComponents(Component.VEVENT)) { VEvent eventIcal = (VEvent) o; String name = getFieldEvent(eventIcal.getProperty(Property.SUMMARY)); String description = null; if (StringUtil.isDefined(getFieldEvent(eventIcal.getProperty(Property.DESCRIPTION)))) { description = getFieldEvent(eventIcal.getProperty(Property.DESCRIPTION)); } // Name is mandatory in the Silverpeas Agenda if (!StringUtil.isDefined(name)) { if (StringUtil.isDefined(description)) { name = description; } else { name = " "; } } String priority = getFieldEvent(eventIcal.getProperty(Property.PRIORITY)); if (!StringUtil.isDefined(priority)) { priority = Priority.UNDEFINED.getValue(); } String classification = getFieldEvent(eventIcal.getProperty(Property.CLASS)); String startDate = getFieldEvent(eventIcal.getProperty(Property.DTSTART)); String endDate = getFieldEvent(eventIcal.getProperty(Property.DTEND)); Date startDay = getDay(startDate); String startHour = getHour(startDate); Date endDay = getDay(endDate); String endHour = getHour(endDate); // Duration of the event long duration = endDay.getTime() - startDay.getTime(); boolean allDay = false; // All day case // I don't know why ?? if (("00:00".equals(startHour) && "00:00".equals(endHour)) || (!StringUtil.isDefined(startHour) && !StringUtil.isDefined(endHour))) { // For complete Day startHour = ""; endHour = ""; allDay = true; } // Get reccurrent dates Collection reccurenceDates = getRecurrenceDates(eventIcal); // No reccurent dates if (reccurenceDates == null) { String idEvent = isExist(eventIcal); // update if event already exists, create if does not exist if (StringUtil.isDefined(idEvent)) { agendaSessionController.updateJournal(idEvent, name, description, priority, classification, startDay, startHour, endDay, endHour); } else { idEvent = agendaSessionController.addJournal(name, description, priority, classification, startDay, startHour, endDay, endHour); } // Get Categories processCategories(eventIcal, idEvent); } else { for (Object reccurenceDate : reccurenceDates) { // Reccurent event startDate startDay = (DateTime) reccurenceDate; // Reccurent event endDate long newEndDay = startDay.getTime() + duration; endDay = new DateTime(newEndDay); if (allDay) { // So we have to convert this date to agenda format date GregorianCalendar gregCalendar = new GregorianCalendar(); gregCalendar.setTime(endDay); gregCalendar.add(GregorianCalendar.DATE, -1); endDay = new Date(gregCalendar.getTime()); } String idEvent = isExist(eventIcal, startDay, endDay, startHour); // update if event already exists, create if does not exist if (StringUtil.isDefined(idEvent)) { SilverTrace.debug("agenda", "ImportIcalManager.importIcalAgenda()", "root.MSG_GEN_PARAM_VALUE" + "Update event: " + DateUtil.date2SQLDate(startDay) + " " + startHour + " to " + DateUtil.date2SQLDate(endDay) + " " + endHour); agendaSessionController.updateJournal(idEvent, name, description, priority, classification, startDay, startHour, endDay, endHour); } else { SilverTrace.debug("agenda", "ImportIcalManager.importIcalAgenda()", "root.MSG_GEN_PARAM_VALUE" + "Create event: " + DateUtil.date2SQLDate(startDay) + " " + startHour + " to " + DateUtil.date2SQLDate(endDay) + " " + endHour); idEvent = agendaSessionController.addJournal(name, description, priority, classification, startDay, startHour, endDay, endHour); } // Get Categories processCategories(eventIcal, idEvent); } } } returnCode = AgendaSessionController.IMPORT_SUCCEEDED; } catch (Exception e) { SilverTrace.error("agenda", "ImportIcalManager.importIcalAgenda()", e.getCause().toString()); returnCode = AgendaSessionController.IMPORT_FAILED; } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(xr); } SilverTrace.debug("agenda", "ImportIcalManager.importIcalAgenda()", "root.MSG_GEN_EXIT_METHOD"); return returnCode; }
From source file:org.energyos.espi.common.service.impl.NotificationServiceImpl.java
@Override public void notifyAllNeed() { List<Long> authList = resourceService.findAllIds(Authorization.class); Map<Long, BatchList> notifyList = new HashMap<Long, BatchList>(); for (Long id : authList) { Authorization authorization = resourceService.findById(id, Authorization.class); String tempResourceUri = authorization.getResourceURI(); System.out.println("NotificationServiceImpl: notifyAllNeed - resourceURI: " + tempResourceUri); // Ignore client_access_tokens which contain "/Batch/Bulk/ // for their ResourceUri values if (!tempResourceUri.contains("/Batch/Bulk/")) { try { resourceService.findByResourceUri(tempResourceUri, Authorization.class); } catch (Exception ex) { System.out.printf( "NotificationServiceImpl: notifyAllNeed - Processing Authorization: %s, Resource: %s, Exception Cause: %s, Exception Message: %s\n", id, tempResourceUri, ex.getCause(), ex.getMessage()); }//from w w w . j ava 2 s.c o m } String thirdParty = authorization.getThirdParty(); // do not do any of the local authorizations // if (!((thirdParty.equals("data_custodian_admin")) || (thirdParty.equals("upload_admin")))) { // if this is the first time we have seen this third party, add // it to the notification list. if (!(notifyList.containsKey(thirdParty))) { notifyList.put(id, new BatchList()); } // and now add the appropriate resource URIs to the batchList of // this third party // String resourceUri = authorization.getResourceURI(); // resourceUri's that contain /Batch/Bulk are // client-access-token and will be ignored here with the // actual Batch/Bulk ids will be picked up by looking at the // scope strings of the individual // authorization/subscription pairs if (!(resourceUri.contains("/Batch/Bulk"))) { String scope = authorization.getScope(); for (String term : scope.split(";")) { if (term.contains("BR=")) { // we have a bulkId to deal with term = term.substring(scope.indexOf("=") + 1); // TODO the following getResourceURI() should be // changed to getBulkRequestURI when the seed tables // have non-null values for that attribute. String bulkResourceUri = authorization.getResourceURI() + "/Batch/Bulk/" + term; if (!(notifyList.get(id).getResources().contains(bulkResourceUri))) { notifyList.get(id).getResources().add(bulkResourceUri); } } else { // just add the resourceUri if (!(notifyList.get(id).getResources().contains(resourceUri))) { notifyList.get(id).getResources().add(resourceUri); } } } } } } // now notify each ThirdParty for (Entry<Long, BatchList> entry : notifyList.entrySet()) { String notifyUri = resourceService.findById(entry.getKey(), Authorization.class) .getApplicationInformation().getThirdPartyNotifyUri(); BatchList batchList = entry.getValue(); if (!(batchList.getResources().isEmpty())) { notifyInternal(notifyUri, batchList); } } }
From source file:de.fhg.fokus.diameter.DiameterPeer.transport.Communicator.java
public void run() { MessageInfo messageInfo = null;/*from w w w .j ava2 s . c om*/ ByteBuffer receiveByteBuffer = ByteBuffer.allocateDirect(MAX_MESSAGE_LENGTH); DiameterMessage msg = null; byte[] buffer = null; int len = 0; //handler to keep track of association setup and termination AssociationHandler assocHandler = new AssociationHandler(); try { while (this.running) { messageInfo = sctpChannel.receive(receiveByteBuffer, System.out, assocHandler); log.debug("Received msg from communicator:" + this + " and sctpChannel:" + sctpChannel); log.debug("Received msg's length:" + messageInfo.bytes()); log.error("Received msg's length:" + messageInfo.bytes()); receiveByteBuffer.flip(); if (receiveByteBuffer.remaining() > 0) { buffer = new byte[messageInfo.bytes()]; receiveByteBuffer.get(buffer); receiveByteBuffer.clear(); // log.debug("The origin message stream is:\n" + CommonMethod.byteToHex(buffer)); //first we check the version if (buffer[0] != 1) { log.error("Expecting diameter version 1, received version " + buffer[0]); continue; } //then we check the length of the message len = ((int) buffer[1] & 0xFF) << 16 | ((int) buffer[2] & 0xFF) << 8 | ((int) buffer[3] & 0xFF); if (len > MAX_MESSAGE_LENGTH) { log.error("Message too long (msg length:" + len + " > max buffer length:" + MAX_MESSAGE_LENGTH + ")."); continue; } //now we can decode the message try { msg = Codec.decodeDiameterMessage(buffer, 0); } catch (DiameterMessageDecodeException e) { log.error("Error decoding diameter message !"); log.error(e, e); msg = null; continue; } msg.networkTime = System.currentTimeMillis(); log.debug("Received message is:\n" + msg); if (this.peer != null) { this.peer.refreshTimer(); } processMessage(msg); } msg = null; } } catch (Exception e1) { log.error("Exception:" + e1.getCause() + " catched in communicator:" + this + " and running flag=" + running); if (this.running) { if (this.peer != null) { if (this.peer.I_comm == this) { StateMachine.process(this.peer, StateMachine.I_Peer_Disc); } if (this.peer.R_comm == this) { log.error("Now closing the peer:" + this.peer); StateMachine.process(this.peer, StateMachine.R_Peer_Disc); } } log.error("Error reading from sctpChannel:" + sctpChannel + ", the channel might be colsed."); } /* else it was a shutdown request, it's normal */ } log.debug("Now closing communicator:" + this + ", and it's sctpChannel:" + sctpChannel); this.running = false; try { sctpChannel.close(); } catch (IOException e) { log.error("Error closing sctpChannel !"); log.error(e, e); } }
From source file:com.wineaccess.wine.WineAdapterHelper.java
/** * This method is used to add the wine in the database. * /*w ww. jav a 2s.co m*/ * @param winePO this is used to take the input. * @return output map containing response */ public static Map<String, Object> addWine(final WinePO winePO) { logger.info("start addWine method"); String errorMsg = StringUtils.EMPTY; final Map<String, Object> output = new ConcurrentHashMap<String, Object>(); Response response = null; try { MasterData wineStyle = null; MasterData vintage = null; MasterData varietal = null; MasterData bottleInMl = null; MasterData bottlesPerBox = null; WineryModel winery = null; MasterData wineSourcingId = null; ImporterModel importer = null; wineStyle = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getWineStyleId())); if (wineStyle == null) { // wine style not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_WINE_STYLE, SystemErrorCode.INVALID_WINE_STYLE_TEXT, SUCCESS_CODE); logger.error("wine style not exist"); } if (response == null) { vintage = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getVintageId())); if (vintage == null) { // vintage not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_VINTAGE, SystemErrorCode.INVALID_VINTAGE_TEXT, SUCCESS_CODE); logger.error("vintage not exist"); } } if (response == null) { varietal = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getVarietalId())); if (varietal == null) { // varietal not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_VARIETAL, SystemErrorCode.INVALID_VARIETAL_TEXT, SUCCESS_CODE); logger.error("varietal not exist"); } } if (response == null) { bottleInMl = MasterDataRepository.getMasterDataById(Long.parseLong(winePO.getBottleInMlId())); if (bottleInMl == null) { // bottleInMlId not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_BOTTLE_IN_ML, SystemErrorCode.INVALID_BOTTLE_IN_ML_TEXT, SUCCESS_CODE); logger.error("bottleInMlId not exist"); } } if (response == null) { if (winePO.getBottlesPerBoxId() != null) { if (!winePO.getBottlesPerBoxId().isEmpty()) { bottlesPerBox = MasterDataRepository .getMasterDataById(Long.parseLong(winePO.getBottlesPerBoxId())); if (bottlesPerBox == null) { // bottlesPerBox not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_BOTTLES_PER_BOX, SystemErrorCode.INVALID_BOTTLES_PER_BOX_TEXT, SUCCESS_CODE); logger.error("bottlesPerBox not exist"); } } } } if (response == null) { winery = WineryRepository.getWineryById(Long.parseLong(winePO.getWineryId())); if (winery == null) { // winery not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_WINERY, SystemErrorCode.INVALID_WINERY_TEXT, SUCCESS_CODE); logger.error("winery not exist"); } } if (response == null) { if (winePO.getWineSourcingId() != null) { if (!winePO.getWineSourcingId().isEmpty()) { wineSourcingId = MasterDataRepository .getMasterDataById(Long.parseLong(winePO.getWineSourcingId())); if (wineSourcingId == null) { // wineSourcingId not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.INVALID_SOURCING, SystemErrorCode.INVALID_SOURCING_TEXT, SUCCESS_CODE); logger.error("wineSourcingId not exist"); } } } } boolean isImported = false; if (response == null) { importer = winery.getActiveImporterId(); if (importer != null) { isImported = true; } } if (response == null) { final WineModel wineModel = new WineModel(); String wineFullName = PropertyholderUtils.getStringProperty("wine.full.name"); wineFullName = wineFullName.replace("<vintage>", vintage.getName() + " "); wineFullName = wineFullName.replace("<winery>", winery.getWineryName() + " "); wineFullName = wineFullName.replace("<winename>", winePO.getWineName()); wineModel.setWineFullName(wineFullName); wineModel.setWineName(winePO.getWineName()); wineModel.setVerietal(varietal); wineModel.setVintage(vintage); if (winePO.getWineShortName() != null) { if (!winePO.getWineShortName().isEmpty()) { wineModel.setWineryShortName(winePO.getWineShortName()); } else { wineModel.setWineryShortName(null); } } wineModel.setBottleInMl(bottleInMl); wineModel.setBottlesPerBox(bottlesPerBox); wineModel.setIsDeleted(false); if (winePO.getAlcoholPercentage() != null) { if (!winePO.getAlcoholPercentage().isEmpty()) { wineModel.setAlcoholPercentage(Double.parseDouble(winePO.getAlcoholPercentage())); } else { wineModel.setAlcoholPercentage(null); } } if (winePO.getNotes() != null) { if (!winePO.getNotes().isEmpty()) { wineModel.setNotes(winePO.getNotes()); } else { wineModel.setNotes(null); } } if (winePO.getWineLabel() != null) { if (!winePO.getWineLabel().isEmpty()) { wineModel.setWineLabel(winePO.getWineLabel()); } else { wineModel.setWineLabel(null); } } if (winePO.getPrivateLabel() != null) { if (!winePO.getPrivateLabel().isEmpty()) { wineModel.setPrivateLabel(winePO.getPrivateLabel()); } else { wineModel.setPrivateLabel(null); } } wineModel.setWineType(wineStyle); wineModel.setWineryId(winery); wineModel.setWineSourcingId(wineSourcingId); if (winePO.getSendToFullfillerOn() != null) { if (!winePO.getSendToFullfillerOn().isEmpty()) { wineModel.setSendToFullfillerOn(Boolean.parseBoolean(winePO.getSendToFullfillerOn())); } else { wineModel.setSendToFullfillerOn(null); } } if (winePO.getUsaArrivalDate() != null) { wineModel.setUsaArrivalDate(winePO.getUsaArrivalDate()); } if (winePO.getLicenseFFPartnerId() != null) { if (!winePO.getLicenseFFPartnerId().isEmpty()) { wineModel.setLicenseFullfillmentPartnerId(Long.parseLong(winePO.getLicenseFFPartnerId())); } else { wineModel.setLicenseFullfillmentPartnerId(null); } } if (winePO.getSellInMainStatesOnly() != null) { wineModel.setSellInMainStates(Boolean.parseBoolean(winePO.getSellInMainStatesOnly())); } if (winePO.getNameIfNotSellInAltStates() != null) { wineModel.setSellInAltStates(Boolean.parseBoolean(winePO.getNameIfNotSellInAltStates())); } wineModel.setIsImported(isImported); if (isImported) { wineModel.setImporterId(importer); } wineModel.setIsEnabled(Boolean.parseBoolean(winePO.getStatus())); MasterData masterData = MasterDataRepository.getMasterDataByTypeAndName("ProductType", "Wine"); if (masterData != null) { if (isImported) { if (importer.getWarehouseId() != null) { wineModel.setWarehouseId(importer.getWarehouseId()); } else if (winery.getWarehouseId() != null) { wineModel.setWarehouseId(winery.getWarehouseId()); } else { wineModel.setWarehouseId(null); } } else { if (winery.getWarehouseId() != null) { wineModel.setWarehouseId(winery.getWarehouseId()); } else { wineModel.setWarehouseId(null); } } WineryImporterContacts contactModel = null; if (importer != null) { contactModel = WineryImporterContactRepository.getImporterContactById(importer.getId()); } else { contactModel = WineryImporterContactRepository.getWineryContactById(winery.getId()); } wineModel.setContactId(contactModel); WineRepository.save(wineModel); WineRepository.updateWCAndActiveWCInWinery(winery.getId()); if (isImported) { WineRepository.updateWCAndActiveWCInImporter(importer.getId()); } ProductItemModel productItemModel = new ProductItemModel(); productItemModel.setProductId(masterData.getId()); productItemModel.setItemId(wineModel.getId()); ProductItemRepository.save(productItemModel); wineModel.setProduct(productItemModel); WineRepository.update(wineModel); WineVO wineVO = new WineVO(SystemErrorCode.WINE_ADD_SUCCESS_TEXT); BeanUtils.copyProperties(wineVO, wineModel); wineVO.setId(wineModel.getProduct().getId()); wineVO.setWineId(wineModel.getId()); wineVO.setWineryId(wineModel.getWineryId().getId()); if (wineModel.getWarehouseId() != null) { wineVO.setWarehouseId(wineModel.getWarehouseId().getId()); } response = new com.wineaccess.response.SuccessResponse(wineVO, SUCCESS_CODE); } else { response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.WINE_ADD_WINE_INVALID_MASTER_DATA, SystemErrorCode.WINE_ADD_WINE_INVALID_MASTER_DATA_TEXT, SUCCESS_CODE); logger.error("Invalid Master Data "); } } } catch (Exception e) { errorMsg = e.getCause().getMessage(); } if (response == null) { if (errorMsg.contains("uk_wine")) { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.WINE_ADD_WINE_DUPLICATE, SystemErrorCode.WINE_ADD_WINE_DUPLICATE_TEXT, SUCCESS_CODE); logger.error("Duplicate entry for wine name "); } else { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.WINE_ADD_UNKNOWN_ERROR, SystemErrorCode.WINE_ADD_UNKNOWN_ERROR_TEXT, SUCCESS_CODE); logger.error("Unkonwn error "); } } output.put(OUPUT_PARAM_KEY, response); logger.info("exit addWine method"); return output; }
From source file:com.mpower.mintel.android.tasks.DownloadFormsTask.java
@Override protected HashMap<String, String> doInBackground(ArrayList<FormDetails>... values) { ArrayList<FormDetails> toDownload = values[0]; int total = toDownload.size(); int count = 1; HashMap<String, String> result = new HashMap<String, String>(); for (int i = 0; i < total; i++) { FormDetails fd = toDownload.get(i); publishProgress(fd.formName, Integer.valueOf(count).toString(), Integer.valueOf(total).toString()); String message = ""; try {//from w w w .j a va 2s . c o m // get the xml file // if we've downloaded a duplicate, this gives us the file File dl = downloadXform(fd.formName, fd.downloadUrl); String[] projection = { FormsColumns._ID, FormsColumns.FORM_FILE_PATH }; String[] selectionArgs = { dl.getAbsolutePath() }; String selection = FormsColumns.FORM_FILE_PATH + "=?"; Cursor alreadyExists = MIntel.getInstance().getContentResolver().query(FormsColumns.CONTENT_URI, projection, selection, selectionArgs, null); Uri uri = null; if (alreadyExists.getCount() <= 0) { // doesn't exist, so insert it ContentValues v = new ContentValues(); v.put(FormsColumns.FORM_FILE_PATH, dl.getAbsolutePath()); HashMap<String, String> formInfo = FileUtils.parseXML(dl); v.put(FormsColumns.DISPLAY_NAME, formInfo.get(FileUtils.TITLE)); v.put(FormsColumns.MODEL_VERSION, formInfo.get(FileUtils.MODEL)); v.put(FormsColumns.UI_VERSION, formInfo.get(FileUtils.UI)); v.put(FormsColumns.JR_FORM_ID, formInfo.get(FileUtils.FORMID)); v.put(FormsColumns.SUBMISSION_URI, formInfo.get(FileUtils.SUBMISSIONURI)); uri = MIntel.getInstance().getContentResolver().insert(FormsColumns.CONTENT_URI, v); } else { alreadyExists.moveToFirst(); uri = Uri.withAppendedPath(FormsColumns.CONTENT_URI, alreadyExists.getString(alreadyExists.getColumnIndex(FormsColumns._ID))); } if (fd.manifestUrl != null) { Cursor c = MIntel.getInstance().getContentResolver().query(uri, null, null, null, null); if (c.getCount() > 0) { // should be exactly 1 c.moveToFirst(); String error = downloadManifestAndMediaFiles( c.getString(c.getColumnIndex(FormsColumns.FORM_MEDIA_PATH)), fd, count, total); if (error != null) { message += error; } } } else { // TODO: manifest was null? Log.e(t, "Manifest was null. PANIC"); } } catch (SocketTimeoutException se) { se.printStackTrace(); message += se.getMessage(); } catch (Exception e) { e.printStackTrace(); if (e.getCause() != null) { message += e.getCause().getMessage(); } else { message += e.getMessage(); } } count++; if (message.equalsIgnoreCase("")) { message = MIntel.getInstance().getString(R.string.success); } result.put(fd.formName, message); } return result; }
From source file:com.aliyun.fs.oss.nat.JetOssNativeFileSystemStore.java
private void handleException(Exception e) throws IOException, OssException { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else {/* ww w . j av a 2 s . c o m*/ throw new OssException(e); } }
From source file:it.geosolutions.geobatch.actions.freemarker.FreeMarkerAction.java
private final File buildOutput(final File outputDir, final Map<String, Object> root) throws ActionException { // try to open the file to write into FileWriter fw = null;//from ww w. jav a 2 s . c o m final File outputFile; try { final String outputFilePrefix = FilenameUtils.getBaseName(conf.getInput()) + "_"; final String outputFileSuffix = "." + FilenameUtils.getExtension(conf.getInput()); outputFile = File.createTempFile(outputFilePrefix, outputFileSuffix, outputDir); if (LOGGER.isInfoEnabled()) LOGGER.info("Output file name: " + outputFile); fw = new FileWriter(outputFile); } catch (IOException ioe) { IOUtils.closeQuietly(fw); final String message = "Unable to build the output file writer: " + ioe.getLocalizedMessage(); if (LOGGER.isErrorEnabled()) LOGGER.error(message); throw new ActionException(this, message); } /* * If available, process the output file using the TemplateModel data * structure */ try { // process the input template file processor.process(processor.wrapRoot(root), fw); // flush the buffer if (fw != null) fw.flush(); } catch (IOException ioe) { throw new ActionException(this, "Unable to flush buffer to the output file: " + ioe.getLocalizedMessage(), ioe.getCause()); } catch (TemplateModelException tme) { throw new ActionException(this, "Unable to wrap the passed object: " + tme.getLocalizedMessage(), tme.getCause()); } catch (Exception e) { throw new ActionException(this, "Unable to process the input file: " + e.getLocalizedMessage(), e.getCause()); } finally { IOUtils.closeQuietly(fw); } return outputFile; }
From source file:hoot.services.db.DbUtils.java
/** * Clears all data in all resource related tables in the database * * @param conn JDBC Connection//w ww. j a v a 2s . c o m * @throws Exception * if any records still exist in the table after the attempted * deletion */ public static void clearServicesDb(Connection conn) throws Exception { try { deleteMapRelatedTables(); conn.setAutoCommit(false); Configuration configuration = getConfiguration(); SQLDeleteClause delete = new SQLDeleteClause(conn, configuration, QCurrentWayNodes.currentWayNodes); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QCurrentRelationMembers.currentRelationMembers); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QCurrentNodes.currentNodes); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QCurrentWays.currentWays); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QCurrentRelations.currentRelations); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QChangesets.changesets); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QMaps.maps); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QUsers.users); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QReviewItems.reviewItems); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QElementIdMappings.elementIdMappings); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QReviewMap.reviewMap); delete.execute(); delete = new SQLDeleteClause(conn, configuration, QJobStatus.jobStatus); delete.execute(); conn.commit(); } catch (Exception e) { conn.rollback(); String msg = "Error clearing services database. "; msg += " " + e.getCause().getMessage(); throw new Exception(msg); } finally { conn.setAutoCommit(true); } }
From source file:com.alibaba.napoli.metamorphosis.client.transaction.TransactionContext.java
/** * XA/* ww w .ja v a 2 s . com*/ * * @param e * @return */ XAException toXAException(final Exception e) { if (e.getCause() != null && e.getCause() instanceof XAException) { final XAException original = (XAException) e.getCause(); final XAException xae = new XAException(original.getMessage()); xae.errorCode = original.errorCode; xae.initCause(original); return xae; } if (e instanceof XAException) { // ((XAException) e).errorCode = XAException.XAER_RMFAIL; return (XAException) e; } final XAException xae = new XAException(e.getMessage()); xae.errorCode = XAException.XAER_RMFAIL; xae.initCause(e); return xae; }
From source file:com.microsoft.tfs.client.common.ui.controls.generic.FullFeaturedBrowser.java
private RuntimeException handleReflectionException(final Exception e) { log.warn("Error using reflection", e); //$NON-NLS-1$ if (e instanceof RuntimeException) { return (RuntimeException) e; } else if (e instanceof InvocationTargetException) { if (e.getCause() instanceof RuntimeException) { return (RuntimeException) e.getCause(); } else {/*from w w w . ja v a 2 s.c o m*/ return new RuntimeException(e.getCause()); } } return new RuntimeException(e); }