List of usage examples for java.text DateFormat getDateInstance
public static final DateFormat getDateInstance(int style, Locale aLocale)
From source file:net.sf.jasperreports.functions.standard.DateTimeFunctions.java
/** * This methods tries to convert a generic object into a java.util.Date instance. * Supported types are for now String, Long values (time millis) and Date subtypes * like for example java.sql.Date.//w w w . j a va 2 s . c o m */ private Date convertDateObject(Object dateObject) { if (dateObject == null) { if (log.isDebugEnabled()) { log.debug("The date object can not be null."); } return null; } else if (dateObject instanceof String) { // Try to convert using the different style for pattern. // We use MEDIUM as the first one because it is the DEFAULT int formatTypes[] = new int[] { DateFormat.MEDIUM, DateFormat.SHORT, DateFormat.LONG, DateFormat.FULL }; for (int formatType : formatTypes) { try { DateFormat df = DateFormat.getDateInstance(formatType, getReportLocale()); df.setTimeZone(getReportTimeZone()); return df.parse((String) dateObject); } catch (ParseException e) { if (log.isDebugEnabled()) { log.debug("Unable to parse the string as Date using the standard SimpleDateFormat."); } } } return null; } else if (dateObject instanceof Long) { Calendar cal = Calendar.getInstance(getReportTimeZone(), getReportLocale()); cal.setTimeInMillis((Long) dateObject); return cal.getTime(); } else if (dateObject instanceof Date) { return (Date) dateObject; } if (log.isDebugEnabled()) { log.debug("The specified object is not among the allowed types for Date conversion."); } return null; }
From source file:DateFormatUtils.java
/** * <p>Gets a date formatter instance using the specified style, time * zone and locale.</p>/*from www.jav a2s . c o m*/ * * @param style date style: FULL, LONG, MEDIUM, or SHORT * @param timeZone optional time zone, overrides time zone of * formatted date * @param locale optional locale, overrides system locale * @return a localized standard date formatter * @throws IllegalArgumentException if the Locale has no date * pattern defined */ public static synchronized FastDateFormat getDateInstance(int style, TimeZone timeZone, Locale locale) { Object key = new Integer(style); if (timeZone != null) { key = new Pair(key, timeZone); } if (locale == null) { locale = Locale.getDefault(); } key = new Pair(key, locale); FastDateFormat format = (FastDateFormat) cDateInstanceCache.get(key); if (format == null) { try { SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale); String pattern = formatter.toPattern(); format = getInstance(pattern, timeZone, locale); cDateInstanceCache.put(key, format); } catch (ClassCastException ex) { throw new IllegalArgumentException("No date pattern for locale: " + locale); } } return format; }
From source file:org.hoteia.qalingo.core.service.impl.EmailServiceImpl.java
/** * @throws Exception /*from w w w.j a va 2 s . c o m*/ * @see org.hoteia.qalingo.core.service.EmailService#buildAndSaveCustomerForgottenPasswordMail(Localization localization, Customer customer, String velocityPath, CustomerForgottenPasswordEmailBean customerForgottenPasswordEmailBean) */ public void buildAndSaveCustomerForgottenPasswordMail(final RequestData requestData, final Customer customer, final String velocityPath, final CustomerForgottenPasswordEmailBean customerForgottenPasswordEmailBean) throws Exception { try { final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerForgottenPasswordEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put(CUSTOMER, customer); model.put("customerForgottenPasswordEmailBean", customerForgottenPasswordEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_PASSWORD_RESET_EMAIL, URLEncoder.encode(customer.getEmail(), Constants.ANSI)); urlParams.put(RequestConstants.REQUEST_PARAMETER_PASSWORD_RESET_TOKEN, customerForgottenPasswordEmailBean.getToken()); String resetPasswordUrl = urlService.generateUrl(FoUrls.RESET_PASSWORD, requestData, urlParams); model.put("activeChangePasswordUrl", urlService.buildAbsoluteUrl(requestData, resetPasswordUrl)); String canceResetPasswordUrl = urlService.generateUrl(FoUrls.CANCEL_RESET_PASSWORD, requestData, urlParams); model.put("cancelChangePasswordUrl", urlService.buildAbsoluteUrl(requestData, canceResetPasswordUrl)); model.put("customerForgottenPasswordEmailBean", customerForgottenPasswordEmailBean); String fromAddress = handleFromAddress(customerForgottenPasswordEmailBean.getFromAddress(), locale); String fromName = handleFromName(customerForgottenPasswordEmailBean.getFromName(), locale); String toEmail = customer.getEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_FORGOTTEN_PASSWORD, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.forgotten_password.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "forgotten-password-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "forgotten-password-text-content.vm", model)); Email email = new Email(); email.setType(Email.EMAIl_TYPE_FORGOTTEN_PASSWORD); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } }
From source file:org.hoteia.qalingo.core.service.EmailService.java
/** * @throws Exception //from w ww . j a v a 2 s . co m */ public Email buildAndSaveCustomerNewAccountMail(final RequestData requestData, final String velocityPath, final CustomerNewAccountConfirmationEmailBean customerNewAccountConfirmationEmailBean) throws Exception { Email email = null; try { final String contextNameValue = requestData.getContextNameValue(); final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerNewAccountConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put(CURRENT_DATE, dateFormatter.format(currentDate)); model.put("customerNewAccountConfirmationEmailBean", customerNewAccountConfirmationEmailBean); model.put(WORDING, coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_NEW_CUSTOMER_VALIDATION_EMAIL, URLEncoder.encode(customerNewAccountConfirmationEmailBean.getEmail(), Constants.ANSI)); urlParams.put(RequestConstants.REQUEST_PARAMETER_NEW_ACCOUNT_VALIDATION_TOKEN, UUID.randomUUID().toString()); String resetPasswordUrl = urlService.generateUrl(FoUrls.CUSTOMER_NEW_ACCOUNT_VALIDATION, requestData, urlParams); model.put("newCustomerValidationUrl", urlService.buildAbsoluteUrl(requestData, resetPasswordUrl)); String fromAddress = handleFromAddress(customerNewAccountConfirmationEmailBean.getFromAddress(), contextNameValue); String fromName = handleFromName(customerNewAccountConfirmationEmailBean.getFromName(), locale); String toEmail = customerNewAccountConfirmationEmailBean.getToEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION, model); mimeMessagePreparator.setTo(toEmail); mimeMessagePreparator.setFrom(fromAddress); mimeMessagePreparator.setFromName(fromName); mimeMessagePreparator.setReplyTo(fromAddress); Object[] parameters = { customerNewAccountConfirmationEmailBean.getLastname(), customerNewAccountConfirmationEmailBean.getFirstname() }; mimeMessagePreparator.setSubject( coreMessageSource.getMessage("email.new_account.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(getVelocityEngine(), velocityPath + "new-account-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString( getVelocityEngine(), velocityPath + "new-account-confirmation-text-content.vm", model)); email = new Email(); email.setType(Email.EMAIl_TYPE_NEW_ACCOUNT_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { logger.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { logger.error("Error, can't build the message :", e); throw e; } catch (IOException e) { logger.error("Error, can't serializable the message :", e); throw e; } return email; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * Sets all the axis formatting options. This includes the colors and fonts to use on * the axis as well as the color to use when drawing the axis line. * * @param axis the axis to format/*from w ww.ja va 2 s. c om*/ * @param labelFont the font to use for the axis label * @param labelColor the color of the axis label * @param tickLabelFont the font to use for each tick mark value label * @param tickLabelColor the color of each tick mark value label * @param tickLabelMask formatting mask for the label. If the axis is a NumberAxis then * the mask should be <code>java.text.DecimalFormat</code> mask, and * if it is a DateAxis then the mask should be a * <code>java.text.SimpleDateFormat</code> mask. * @param verticalTickLabels flag to draw tick labels at 90 degrees * @param lineColor color to use when drawing the axis line and any tick marks */ protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont, Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Color lineColor, boolean isRangeAxis, Comparable<?> axisMinValue, Comparable<?> axisMaxValue) { axis.setLabelFont(fontUtil.getAwtFont(getFont(labelFont), getLocale())); axis.setTickLabelFont(fontUtil.getAwtFont(getFont(tickLabelFont), getLocale())); if (labelColor != null) { axis.setLabelPaint(labelColor); } if (tickLabelColor != null) { axis.setTickLabelPaint(tickLabelColor); } if (lineColor != null) { axis.setAxisLinePaint(lineColor); axis.setTickMarkPaint(lineColor); } TimeZone timeZone = chartContext.getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } // FIXME use locale for formats if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(getLocale()); if (fmt instanceof DecimalFormat) { ((DecimalFormat) fmt).applyPattern(tickLabelMask); } ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) { fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale()); } else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) { fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale()); } else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) { fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale()); } else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) { fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale()); } else { fmt = new SimpleDateFormat(tickLabelMask, getLocale()); } if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } // ignore mask for other axis types. } if (verticalTickLabels != null && axis instanceof ValueAxis) { ((ValueAxis) axis).setVerticalTickLabels(verticalTickLabels); } setAxisBounds(axis, isRangeAxis, axisMinValue, axisMaxValue); }
From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java
private String doConvertToString(Map<String, Object> context, Object value) { String result = null;/* w ww .j ava 2 s . c o m*/ if (value instanceof int[]) { int[] x = (int[]) value; List<Integer> intArray = new ArrayList<Integer>(x.length); for (int aX : x) { intArray.add(Integer.valueOf(aX)); } result = StringUtils.join(intArray, ", "); } else if (value instanceof long[]) { long[] x = (long[]) value; List<Long> longArray = new ArrayList<Long>(x.length); for (long aX : x) { longArray.add(Long.valueOf(aX)); } result = StringUtils.join(longArray, ", "); } else if (value instanceof double[]) { double[] x = (double[]) value; List<Double> doubleArray = new ArrayList<Double>(x.length); for (double aX : x) { doubleArray.add(new Double(aX)); } result = StringUtils.join(doubleArray, ", "); } else if (value instanceof boolean[]) { boolean[] x = (boolean[]) value; List<Boolean> booleanArray = new ArrayList<Boolean>(x.length); for (boolean aX : x) { booleanArray.add(new Boolean(aX)); } result = StringUtils.join(booleanArray, ", "); } else if (value instanceof Date) { DateFormat df = null; if (value instanceof java.sql.Time) { df = DateFormat.getTimeInstance(DateFormat.MEDIUM, getLocale(context)); } else if (value instanceof java.sql.Timestamp) { SimpleDateFormat dfmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, getLocale(context)); df = new SimpleDateFormat(dfmt.toPattern() + MILLISECOND_FORMAT); } else { df = DateFormat.getDateInstance(DateFormat.SHORT, getLocale(context)); } result = df.format(value); } else if (value instanceof String[]) { result = StringUtils.join((String[]) value, ", "); } return result; }
From source file:org.glom.web.server.ReportGenerator.java
/** * @param x//from ww w . jav a 2 s . c o m * @param libglomLayoutItemField * @return */ private JRDesignTextField createFieldValueElement(final Position pos, final LayoutItemField libglomLayoutItemField) { final JRDesignTextField textField = new JRDesignTextField(); // Make sure this field starts at the right of the previous field, // because JasperReports uses absolute positioning. textField.setY(pos.y); textField.setX(pos.x); textField.setWidth(width); // No data will be shown without this. // This only stretches vertically, but that is better than // nothing. textField.setStretchWithOverflow(true); textField.setHeight(height); // We must specify _some_ height. final JRDesignExpression expression = createFieldExpression(libglomLayoutItemField); textField.setExpression(expression); if (libglomLayoutItemField.getGlomType() == GlomFieldType.TYPE_NUMERIC) { // Numeric formatting: final Formatting formatting = libglomLayoutItemField.getFormattingUsed(); final NumericFormat numericFormat = formatting.getNumericFormat(); final DecimalFormat format = new DecimalFormat(); format.setMaximumFractionDigits(numericFormat.getDecimalPlaces()); format.setGroupingUsed(numericFormat.getUseThousandsSeparator()); // TODO: Use numericFormat.get_currency_symbol(), possibly via format.setCurrency(). textField.setPattern(format.toPattern()); } else if (libglomLayoutItemField.getGlomType() == GlomFieldType.TYPE_DATE) { // Date formatting // TODO: Use a 4-digit-year short form, somehow. try // We use a try block because getDateInstance() is not guaranteed to return a SimpleDateFormat. { final SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.ROOT); textField.setPattern(format.toPattern()); } catch (final Exception ex) { Log.info("ReportGenerator: The cast of SimpleDateFormat failed."); } } else if (libglomLayoutItemField.getGlomType() == GlomFieldType.TYPE_TIME) { // Time formatting try // We use a try block because getDateInstance() is not guaranteed to return a SimpleDateFormat. { final SimpleDateFormat format = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT, Locale.ROOT); textField.setPattern(format.toPattern()); } catch (final Exception ex) { Log.info("ReportGenerator: The cast of SimpleDateFormat failed."); } } return textField; }
From source file:org.glom.libglom.Document.java
/** * @param element//from w ww . j a va 2 s . c o m * @param type * @return */ private DataItem getNodeTextChildAsValue(final Element element, final GlomFieldType type) { final DataItem result = new DataItem(); final String str = element.getTextContent(); // Unescape "" to ", because to_file_format() escaped ", as specified by the CSV RFC: String unescaped; if (type == GlomFieldType.TYPE_IMAGE) { unescaped = str; // binary data does not have quote characters so we do not bother to escape or unescape it. } else { unescaped = str.replace(QUOTE_FOR_FILE_FORMAT + QUOTE_FOR_FILE_FORMAT, QUOTE_FOR_FILE_FORMAT); } switch (type) { case TYPE_BOOLEAN: { final boolean value = (unescaped.equals("true")); result.setBoolean(value); break; } case TYPE_DATE: { final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ROOT); Date value = null; try { value = dateFormat.parse(unescaped); } catch (final ParseException e) { // e.printStackTrace(); } result.setDate(value); break; } case TYPE_IMAGE: { //Glom (at least since 2.23/24) uses base64 for the images: //This is only used on the server-side, //either to create a database, during tests, //or to return the full data from our OnlineGlomImage service. //It is removed before being passed to the client-side. /* This does not seem to work with the text from g_base64_encode() that Glom uses, * maybe because of the newlines, which are apparently OK: * http://en.wikipedia.org/wiki/Base64#MIME * final byte[] bytes = com.google.gwt.user.server.Base64Utils.fromBase64(unescaped); */ /* Use org.apache.commons.codec.binary.Base64: */ final Base64 decoder = new Base64(); byte[] bytes = decoder.decode(unescaped.getBytes()); result.setImageData(bytes); break; } case TYPE_NUMERIC: { double value = 0; try { value = Double.valueOf(unescaped); } catch (final NumberFormatException e) { // e.printStackTrace(); } result.setNumber(value); break; } case TYPE_TEXT: result.setText(unescaped); break; case TYPE_TIME: // TODO break; default: Logger.log(documentID + ": getNodeTextChildAsValue(): unexpected or invalid field type."); break; } return result; }
From source file:org.glom.web.server.SqlUtils.java
/** * @param dataItem/*from w ww. ja va2s.c om*/ * @param field * @param rsIndex * @param rs * @param primaryKeyValue * @throws SQLException */ public static void fillDataItemFromResultSet(final DataItem dataItem, final LayoutItemField field, final int rsIndex, final ResultSet rs, final String documentID, final String tableName, final TypedDataItem primaryKeyValue) throws SQLException { switch (field.getGlomType()) { case TYPE_TEXT: final String text = rs.getString(rsIndex); dataItem.setText(text != null ? text : ""); break; case TYPE_BOOLEAN: dataItem.setBoolean(rs.getBoolean(rsIndex)); break; case TYPE_NUMERIC: dataItem.setNumber(rs.getDouble(rsIndex)); break; case TYPE_DATE: final Date date = rs.getDate(rsIndex); if (date != null) { // TODO: Pass Date and Time types instead of converting to text here? // TODO: Use a 4-digit-year short form, somehow. final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ROOT); dataItem.setText(dateFormat.format(date)); } else { dataItem.setText(""); } break; case TYPE_TIME: final Time time = rs.getTime(rsIndex); if (time != null) { final DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.ROOT); dataItem.setText(timeFormat.format(time)); } else { dataItem.setText(""); } break; case TYPE_IMAGE: //We don't get the data here. //Instead we provide a way for the client to get the image separately. //This doesn't seem to work, //presumably because the base64 encoding is wrong: //final byte[] imageByteArray = rs.getBytes(rsIndex); //if (imageByteArray != null) { // String base64 = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(imageByteArray); // base64 = "data:image/png;base64," + base64; final String url = Utils.buildImageDataUrl(primaryKeyValue, documentID, tableName, field); dataItem.setImageDataUrl(url); break; case TYPE_INVALID: default: Log.warn(documentID, tableName, "Invalid LayoutItem Field type. Using empty string for value."); dataItem.setText(""); break; } }
From source file:fr.hoteia.qalingo.core.service.impl.EmailServiceImpl.java
/** * @see fr.hoteia.qalingo.core.service.EmailService#buildAndSaveCustomerResetPasswordConfirmationMail(Localization localization, Customer customer, String velocityPath, CustomerResetPasswordConfirmationEmailBean customerResetPasswordConfirmationEmailBean) *//* w ww . j av a2 s . c om*/ public void buildAndSaveCustomerResetPasswordConfirmationMail(final RequestData requestData, final Customer customer, final String velocityPath, final CustomerResetPasswordConfirmationEmailBean customerResetPasswordConfirmationEmailBean) throws Exception { try { final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); // SANITY CHECK checkEmailAddresses(customerResetPasswordConfirmationEmailBean); Map<String, Object> model = new HashMap<String, Object>(); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.FULL, locale); java.sql.Timestamp currentDate = new java.sql.Timestamp((new java.util.Date()).getTime()); model.put("currentDate", dateFormatter.format(currentDate)); model.put("customer", customer); model.put("customerResetPasswordConfirmationEmailBean", customerResetPasswordConfirmationEmailBean); model.put("wording", coreMessageSource.loadWording(Email.WORDING_SCOPE_EMAIL, locale)); String fromEmail = customerResetPasswordConfirmationEmailBean.getFromEmail(); MimeMessagePreparatorImpl mimeMessagePreparator = getMimeMessagePreparator(requestData, Email.EMAIl_TYPE_RESET_PASSWORD_CONFIRMATION, model); mimeMessagePreparator.setTo(customer.getEmail()); mimeMessagePreparator.setFrom(fromEmail); mimeMessagePreparator.setFromName(coreMessageSource.getMessage("email.common.from_name", locale)); mimeMessagePreparator.setReplyTo(fromEmail); Object[] parameters = { customer.getLastname(), customer.getFirstname() }; mimeMessagePreparator.setSubject(coreMessageSource .getMessage("email.reset_password_confirmation.email_subject", parameters, locale)); mimeMessagePreparator.setHtmlContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "reset-password-confirmation-html-content.vm", model)); mimeMessagePreparator.setPlainTextContent(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, velocityPath + "reset-password-confirmation-text-content.vm", model)); Email email = new Email(); email.setType(Email.EMAIl_TYPE_RESET_PASSWORD_CONFIRMATION); email.setStatus(Email.EMAIl_STATUS_PENDING); saveOrUpdateEmail(email, mimeMessagePreparator); } catch (MailException e) { LOG.error("Error, can't save the message :", e); throw e; } catch (VelocityException e) { LOG.error("Error, can't build the message :", e); throw e; } catch (IOException e) { LOG.error("Error, can't serializable the message :", e); throw e; } }