Search in sources :

Example 1 with Unstable

use of org.xwiki.stability.Unstable in project xwiki-platform by xwiki.

the class MailStorageScriptService method resendAsynchronously.

/**
 * Resend the serialized MimeMessage asynchronously.
 *
 * @param batchId the name of the directory that contains serialized MimeMessage
 * @param uniqueMessageId the unique id of the serialized MimeMessage
 * @return the result and status of the send batch; null if an error occurred when getting the message from the
 *         store
 * @since 9.3RC1
 */
@Unstable
public ScriptMailResult resendAsynchronously(String batchId, String uniqueMessageId) {
    try {
        MailStatusResult statusResult = this.mailResender.resendAsynchronously(batchId, uniqueMessageId);
        ScriptMailResult scriptMailResult = new ScriptMailResult(new DefaultMailResult(batchId), statusResult);
        return scriptMailResult;
    } catch (MailStoreException e) {
        // Save the exception for reporting through the script services's getLastError() API
        setError(e);
        return null;
    }
}
Also used : MailStoreException(org.xwiki.mail.MailStoreException) MailStatusResult(org.xwiki.mail.MailStatusResult) DefaultMailResult(org.xwiki.mail.internal.DefaultMailResult) Unstable(org.xwiki.stability.Unstable)

Example 2 with Unstable

use of org.xwiki.stability.Unstable in project xwiki-platform by xwiki.

the class LocalizationScriptService method getAvailableLocales.

/**
 * @return the list of available locales for XWiki translations
 * @since 9.7RC1
 * @since 8.4.6
 * @since 9.6.1
 */
@Unstable
public Set<Locale> getAvailableLocales() {
    Set<Locale> locales = new HashSet<>();
    locales.addAll(Arrays.asList(Locale.getAvailableLocales()));
    try (InputStream resource = environment.getResourceAsStream("/WEB-INF/xwiki-locales.txt")) {
        LineIterator iterator = IOUtils.lineIterator(resource, StandardCharsets.US_ASCII);
        while (iterator.hasNext()) {
            String line = iterator.nextLine();
            if (StringUtils.isNotBlank(line)) {
                locales.add(new Locale(line));
            }
        }
        iterator.close();
    } catch (Exception e) {
        logger.warn("Exception while looking for XWiki Locales.", e);
    }
    return locales;
}
Also used : Locale(java.util.Locale) InputStream(java.io.InputStream) LineIterator(org.apache.commons.io.LineIterator) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) HashSet(java.util.HashSet) Unstable(org.xwiki.stability.Unstable)

Aggregations

Unstable (org.xwiki.stability.Unstable)2 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 LineIterator (org.apache.commons.io.LineIterator)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 MailStatusResult (org.xwiki.mail.MailStatusResult)1 MailStoreException (org.xwiki.mail.MailStoreException)1 DefaultMailResult (org.xwiki.mail.internal.DefaultMailResult)1