Example usage for java.lang Exception getCause

List of usage examples for java.lang Exception getCause

Introduction

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

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:fr.paris.lutece.plugins.search.solr.indexer.SolrIndexerService.java

/**
 * Build the message error of an exception
 * @param exception The exception//ww  w . j  a va  2 s.  c  o m
 * @return the message error of the exception
 */
public static String buildErrorMessage(Exception exception) {
    StringBuilder sb = new StringBuilder();
    sb.append(exception.getMessage());

    if (exception.getCause() != null) {
        sb.append(SolrConstants.CONSTANT_SPACE).append(SolrConstants.CONSTANT_COLON)
                .append(SolrConstants.CONSTANT_SPACE);
        sb.append(exception.getCause().getMessage());
    }

    return sb.toString();
}

From source file:fr.paris.lutece.plugins.search.solr.indexer.SolrIndexerService.java

/**
 * Del sorl index related to this site.//from  www.j av  a2s . co m
 * @return log of what appended
 */
public static String processDel() {
    String strLog = "";
    String strSite = AppPropertiesService.getProperty(PROPERTY_SITE);

    try {
        SOLR_SERVER.deleteByQuery(SolrItem.FIELD_SITE + ":\"" + strSite + "\"");
        SOLR_SERVER.commit();
        SOLR_SERVER.optimize();
        strLog = "Delete site : " + strSite;
        AppLogService.info(strLog);
    } catch (Exception e) {
        AppLogService.error("Erreur lors de la suppression de l'index solr", e);
        strLog = (e.getCause() != null ? e.getCause().toString() : e.toString());
    }

    return strLog;
}

From source file:de.tudarmstadt.lt.seg.app.Segmenter.java

public static void split_and_tokenize(Reader reader, String docid, ISentenceSplitter sentenceSplitter,
        ITokenizer tokenizer, int level_filter, int level_normalize, boolean merge_types, boolean merge_tokens,
        String separator_sentence, String separator_token, String separator_desc, PrintWriter writer) {
    try {//from   w w w  .j a  v a 2s  .  co m
        final StringBuffer buf = new StringBuffer(); // used for checking of stream is empty; take care when not running sequentially but in parallel!
        sentenceSplitter.init(reader).stream().sequential().forEach(sentence_segment -> {
            if (DEBUG) {
                writer.format("%s%s", docid, separator_desc);
                writer.println(sentence_segment.toString());
                writer.print(separator_sentence);
            }
            if (sentence_segment.type != SegmentType.SENTENCE)
                return;
            tokenizer.init(sentence_segment.asString());
            Stream<String> tokens = null;
            if (DEBUG)
                tokens = tokenizer.stream().map(x -> x.toString() + separator_token);
            else
                tokens = StreamSupport.stream(tokenizer
                        .filteredAndNormalizedTokens(level_filter, level_normalize, merge_types, merge_tokens)
                        .spliterator(), false).map(x -> x + separator_token);
            Spliterator<String> spliterator = tokens.spliterator();
            tokens = StreamSupport.stream(spliterator, false);
            buf.setLength(0);
            boolean empty = !spliterator.tryAdvance(x -> {
                buf.append(x);
            });
            if (empty)
                return;
            synchronized (writer) {
                // writer.write(Thread.currentThread().getId() + "\t");
                writer.format("%s%s", docid, separator_desc);
                writer.print(buf);
                tokens.forEach(writer::print);
                writer.print(separator_sentence);
                writer.flush();
            }
        });
    } catch (Exception e) {
        Throwable t = e;
        while (t != null) {
            System.err.format("%s: %s%n", e.getClass(), e.getMessage());
            t = e.getCause();
        }
    }
}

From source file:de.thischwa.pmcms.gui.dialog.DialogManager.java

/**
 * Open the progress dialog and run a {@link IProgressViewer}.
 *//*ww w. j a v a  2s.  c  o m*/
public static void startProgressDialog(final Shell parentShell, final IProgressViewer progressViewer) {
    IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {
        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            progressViewer.setMonitor(monitor);
            try {
                progressViewer.run();
            } catch (Exception e) {
                logger.error("While IProgressViewer was running: " + e.getMessage(), e);
                throw new ProgressException(e);
            }
        }
    };

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(parentShell);
    try {
        dialog.run(true, true, runnableWithProgress);
    } catch (Exception e) {
        throw new FatalException(e.getCause().getMessage(), e.getCause());
    }
}

From source file:net.naijatek.myalumni.util.mail.SendMailUtil.java

public static void sendBirthdayWish(final MemberVO memberVO, SystemConfigVO sysConfig) throws Exception {

    try {// ww  w  .  ja v  a2s  . c om
        Map<String, String> map = new HashMap<String, String>();

        map.put("fullName", memberVO.getFullName());
        map.put("memberUserName", memberVO.getMemberUserName());
        map.put("schoolName", StringUtil.safeString(sysConfig.getOrganizationName()));
        map.put("serverName", StringUtil.safeString(sysConfig.getServerUrl()));
        map.put("adminSignature", StringUtil.safeString(sysConfig.getAdminSignature()));

        String subjectTemplatePrefix = TEMPLATE_BIRTHDAY_WISH_SUBJECT + "-text." + TEMPLATE_EXTENSION;
        String bodyTemplatePrefix = TEMPLATE_BIRTHDAY_WISH_BODY + "-text." + TEMPLATE_EXTENSION;
        new FreeMarkerTemplateMailerImpl(mailSender, configuration).mail(memberVO.getEmail(), map,
                bodyTemplatePrefix, subjectTemplatePrefix);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("sendBirthdayWish: " + e.getMessage());
        throw new MailServerException("Error encountered sendBirthdayWish " + e.getCause().toString());
    }
}

From source file:com.glaf.core.security.RSAUtils.java

/**
 * ?//from  w  w w  .j  a  v  a2  s  . c  o  m
 * <p />
 * ? {@code null} {@code encrypttext}  {@code null}
 * {@code null} ??? {@code null}
 * 
 * @param privateKey
 *            ?
 * @param encrypttext
 *            
 * @return 
 */
public static String decryptString(PrivateKey privateKey, String encrypttext) {
    if (privateKey == null || StringUtils.isEmpty(encrypttext)) {
        return null;
    }
    try {
        byte[] en_data = Hex.decodeHex(encrypttext.toCharArray());
        byte[] data = decrypt(privateKey, en_data);
        return new String(data);
    } catch (Exception ex) {
        LOGGER.error(
                String.format("\"%s\" Decryption failed. Cause: %s", encrypttext, ex.getCause().getMessage()));
    }
    return null;
}

From source file:net.naijatek.myalumni.util.mail.SendMailUtil.java

/**
 *
 * @param pm PrivateMessage/*from  w  ww.  ja va 2s  .co  m*/
 * @throws MessagingException
 * @throws Exception
 */
public static void sendEmail(final PrivateMessageVO pm, final SystemConfigVO sysConfigVO) throws Exception {

    try {
        Map<String, String> map = new HashMap<String, String>();
        map.put("subject", pm.getSubject());
        map.put("body", pm.getMessageText());
        map.put("serverName", StringUtil.safeString(sysConfigVO.getServerUrl()));
        map.put("adminSignature", StringUtil.safeString(sysConfigVO.getAdminSignature()));

        String subjectTemplatePrefix = TEMPLATE_EMAIL_MEMBER_SUBJECT + "-text." + TEMPLATE_EXTENSION;
        String bodyTemplatePrefix = TEMPLATE_EMAIL_MEMBER_BODY + "-text." + TEMPLATE_EXTENSION;
        new FreeMarkerTemplateMailerImpl(mailSender, configuration).mail(pm.getGuestEmail(), map,
                bodyTemplatePrefix, subjectTemplatePrefix);
    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error("sendEmail: " + ex.getMessage());
        throw new MailServerException("Error encountered when sending sendEmail " + ex.getCause().toString());
    }
}

From source file:net.naijatek.myalumni.util.mail.SendMailUtil.java

/**
   * Send welcome notice to_email user/*from   w  w  w  .ja v a2 s . c om*/
   * 
   * @param email String
   * @param userName String
   * @throws MessagingException
   * @throws Exception
   */
// Done
public static void sendWelcomeNotice(final String email, final String userName, SystemConfigVO sysConfig)
        throws Exception {
    try {
        Map<String, String> map = new HashMap<String, String>();

        map.put("userName", userName);
        map.put("schoolName", StringUtil.safeString(sysConfig.getOrganizationName()));
        map.put("serverName", StringUtil.safeString(sysConfig.getServerUrl()));
        map.put("adminSignature", StringUtil.safeString(sysConfig.getAdminSignature()));

        String subjectTemplatePrefix = TEMPLATE_NEW_MEMBER_WELCOME_NOTIFICATION_SUBJECT + "-text."
                + TEMPLATE_EXTENSION;
        String bodyTemplatePrefix = TEMPLATE_NEW_MEMBER_WELCOME_NOTIFICATION_BODY + "-text."
                + TEMPLATE_EXTENSION;
        new FreeMarkerTemplateMailerImpl(mailSender, configuration).mail(email, map, bodyTemplatePrefix,
                subjectTemplatePrefix);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("sendWelcomeNotice: " + e.getMessage());
        throw new MailServerException("Error encountered sendWelcomeNotice " + e.getCause().toString());
    }
}

From source file:net.naijatek.myalumni.util.mail.SendMailUtil.java

public static void sendUserNameReminderMail(String email, String fullName, String memberUserName,
        SystemConfigVO sysConfig) throws Exception {

    try {//w  w  w  .j  av a  2 s .  c o m
        Map<String, String> map = new HashMap<String, String>();

        map.put("fullName", fullName);
        map.put("memberUserName", memberUserName);
        map.put("schoolName", StringUtil.safeString(sysConfig.getOrganizationName()));
        map.put("serverName", StringUtil.safeString(sysConfig.getServerUrl()));
        map.put("adminSignature", StringUtil.safeString(sysConfig.getAdminSignature()));

        String subjectTemplatePrefix = TEMPLATE_USERNAME_REMINDER_SUBJECT + "-text." + TEMPLATE_EXTENSION;
        String bodyTemplatePrefix = TEMPLATE_USERNAME_REMINDER_BODY + "-text." + TEMPLATE_EXTENSION;
        new FreeMarkerTemplateMailerImpl(mailSender, configuration).mail(email, map, bodyTemplatePrefix,
                subjectTemplatePrefix);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("sendPasswordReminderMail: " + e.getMessage());
        throw new MailServerException("Error encountered sendPasswordReminderMail " + e.getCause().toString());
    }

}

From source file:net.naijatek.myalumni.util.mail.SendMailUtil.java

public static void sendPasswordReminderMail(String email, String fullName, String newPasswd,
        SystemConfigVO sysConfig) throws Exception {

    try {//from   w ww  . j a v  a  2  s.co  m
        Map<String, String> map = new HashMap<String, String>();

        map.put("fullName", fullName);
        map.put("newPasswd", newPasswd);
        map.put("schoolName", StringUtil.safeString(sysConfig.getOrganizationName()));
        map.put("serverName", StringUtil.safeString(sysConfig.getServerUrl()));
        map.put("adminSignature", StringUtil.safeString(sysConfig.getAdminSignature()));

        String subjectTemplatePrefix = TEMPLATE_PASSWORD_REMINDER_SUBJECT + "-text." + TEMPLATE_EXTENSION;
        String bodyTemplatePrefix = TEMPLATE_PASSWORD_REMINDER_BODY + "-text." + TEMPLATE_EXTENSION;
        new FreeMarkerTemplateMailerImpl(mailSender, configuration).mail(email, map, bodyTemplatePrefix,
                subjectTemplatePrefix);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("sendPasswordReminderMail: " + e.getMessage());
        throw new MailServerException("Error encountered sendPasswordReminderMail " + e.getCause().toString());
    }

}