Example usage for java.util Locale FRENCH

List of usage examples for java.util Locale FRENCH

Introduction

In this page you can find the example usage for java.util Locale FRENCH.

Prototype

Locale FRENCH

To view the source code for java.util Locale FRENCH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:com.doculibre.constellio.lucene.BaseLuceneIndexHelper.java

@Override
public synchronized void delete(T object) {
    int docNum = getDocNum(object);
    if (docNum != -1) {
        try {// w w  w  .java2 s .  co  m
            String uniqueIndexFieldName = getUniqueIndexFieldName();
            String uniqueIndexFieldValue = getUniqueIndexFieldValue(object);
            Directory directory = FSDirectory.open(indexDir);
            if (DirectoryReader.indexExists(directory)) {
                Analyzer analyzer = analyzerProvider.getAnalyzer(Locale.FRENCH);
                IndexWriter indexWriter = new IndexWriter(directory,
                        new IndexWriterConfig(Version.LUCENE_44, analyzer));
                Term term = new Term(uniqueIndexFieldName, uniqueIndexFieldValue);
                indexWriter.deleteDocuments(term);
                indexWriter.close();
            }
            directory.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:fr.gouv.diplomatie.applitutoriel.mail.service.MailContactServiceImpl.java

/** {@inheritDoc} */
@Override/*from   w  w  w.  ja v a 2 s . co  m*/
public void envoyerMail(final String nom, final String prenom, final String fromAddress, final String message) {

    try {
        final String sujet = String.format(objetContactMail, applicationName, WordUtils.capitalize(prenom),
                WordUtils.capitalize(nom));

        final Map<String, Object> params = new HashMap<String, Object>();
        params.put("nom", WordUtils.capitalize(nom));
        params.put("prenom", WordUtils.capitalize(prenom));
        params.put("corps", message);
        final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy '' HH:mm:ss", Locale.FRENCH);
        params.put("date", sdf.format(new Date()));
        params.put("applicationName", applicationName);
        params.put("applicationUrl", applicationUrl);

        // Exemple d'utilisation d'un NO_REPLY ou d'ajout d'un CC
        // params.put(MailServiceImpl.SMTP_HEADER_REPLYTO, NO_REPLY);
        // params.put(MailServiceImpl.SMTP_HEADER_CC, "root@localhost.com");

        mailService.envoyerDepuisModele(fromAddress, sujet, corpsContactMail, params, destinataires);

    } catch (final Exception e) {
        MailContactServiceImpl.LOGGER.error("Erreur lors de la tentative d'envoi de mail de contact.", e);
        throw new BusinessException("ERR-CODE-MAIL-001", e);
    }

}

From source file:test.unit.be.fedict.eid.tsl.BelgianTrustServiceListFactoryTest.java

@Test
public void testBelgianTrustList() throws Exception {
    // setup//  w w  w .j  a  v a2 s . c  o  m
    TrustServiceList trustServiceList = BelgianTrustServiceListFactory.newInstance(2014, Trimester.FIRST);

    assertNotNull(trustServiceList.getType());

    File unsignedTslFile = File.createTempFile("tsl-be-2014-T1-candidatetest", ".xml");
    trustServiceList.saveAs(unsignedTslFile);

    // sign trust list
    KeyPair keyPair = TrustTestUtils.generateKeyPair(2048);
    PrivateKey privateKey = keyPair.getPrivate();
    DateTime notBefore = new DateTime();
    DateTime notAfter = notBefore.plusYears(5);
    X509Certificate certificate = TrustTestUtils.generateSelfSignedCertificate(keyPair,
            "C=BE, CN=Belgium Trust List Scheme Operator", notBefore, notAfter);
    trustServiceList.sign(privateKey, certificate);

    // operate
    File tmpTslFile = File.createTempFile("tsl-be-", ".xml");
    // tmpTslFile.deleteOnExit();
    trustServiceList.saveAs(tmpTslFile);

    // --------------- VERIFY TRUST LIST --------------------
    LOG.debug("TSL: " + FileUtils.readFileToString(tmpTslFile));
    Document document = TrustTestUtils.loadDocument(tmpTslFile);

    // XML schema validation
    SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
    LSResourceResolver resourceResolver = new TSLLSResourceResolver();
    factory.setResourceResolver(resourceResolver);
    InputStream tslSchemaInputStream = BelgianTrustServiceListFactoryTest.class
            .getResourceAsStream("/ts_119612v010101_xsd.xsd");
    Source tslSchemaSource = new StreamSource(tslSchemaInputStream);
    Schema tslSchema = factory.newSchema(tslSchemaSource);
    Validator tslValidator = tslSchema.newValidator();
    LOG.debug("Starting validate");
    tslValidator.validate(new DOMSource(document));

    Validator eccValidator = factory
            .newSchema(BelgianTrustServiceListFactoryTest.class.getResource("/ts_119612v010101_sie_xsd.xsd"))
            .newValidator();
    NodeList eccQualificationsNodeList = document.getElementsByTagNameNS(
            "http://uri.etsi.org/TrstSvc/SvcInfoExt/eSigDir-1999-93-EC-TrustedList/#", "Qualifications");
    for (int idx = 0; idx < eccQualificationsNodeList.getLength(); idx++) {
        Node eccQualificationsNode = eccQualificationsNodeList.item(idx);
        eccValidator.validate(new DOMSource(eccQualificationsNode));
    }

    Validator xadesValidator = factory
            .newSchema(BelgianTrustServiceListFactoryTest.class.getResource("/XAdES.xsd")).newValidator();
    NodeList xadesQualifyingPropertiesNodeList = document
            .getElementsByTagNameNS("http://uri.etsi.org/01903/v1.3.2#", "QualifyingProperties");
    for (int idx = 0; idx < xadesQualifyingPropertiesNodeList.getLength(); idx++) {
        Node xadesQualifyingPropertiesNode = xadesQualifyingPropertiesNodeList.item(idx);
        xadesValidator.validate(new DOMSource(xadesQualifyingPropertiesNode));
    }

    // signature
    trustServiceList = TrustServiceListFactory.newInstance(tmpTslFile);
    X509Certificate resultCertificate = trustServiceList.verifySignature();
    assertEquals(certificate, resultCertificate);

    File pdfExportFile = File.createTempFile("tsl-be-", ".pdf");
    trustServiceList.humanReadableExport(pdfExportFile);

    // scheme operator name
    String schemeOperatorNameEn = trustServiceList.getSchemeOperatorName(Locale.ENGLISH);
    assertEquals("FPS Economy, SMEs, Self-employed and Energy - Quality and Safety", schemeOperatorNameEn);
    LOG.debug("Locale.ENGLISH: " + Locale.ENGLISH.getLanguage());
    assertEquals("SPF Economie, PME, Classes moyennes et Energie - Qualit et Scurit",
            trustServiceList.getSchemeOperatorName(Locale.FRENCH));

    Node schemeOperatorNameEnNode = XPathAPI.selectSingleNode(document,
            "tsl:TrustServiceStatusList/tsl:SchemeInformation/tsl:SchemeOperatorName/tsl:Name[@xml:lang='en']");
    assertNotNull(schemeOperatorNameEnNode);
    assertEquals("FPS Economy, SMEs, Self-employed and Energy - Quality and Safety",
            schemeOperatorNameEnNode.getTextContent());

    // scheme operator postal address
    PostalAddressType resultPostalAddress = trustServiceList.getSchemeOperatorPostalAddress(Locale.ENGLISH);
    assertNotNull(resultPostalAddress);
    assertEquals("NG III - Koning Albert II-laan 16", resultPostalAddress.getStreetAddress());
    assertEquals("Brussels", resultPostalAddress.getLocality());
    assertEquals("Brussel", trustServiceList.getSchemeOperatorPostalAddress(new Locale("nl")).getLocality());

    // scheme operator electronic address
    assertEquals(2, trustServiceList.getSchemeOperatorElectronicAddresses().size());
    LOG.debug("electronic addresses: " + trustServiceList.getSchemeOperatorElectronicAddresses());

    // scheme name
    assertTrue(trustServiceList.getSchemeName(Locale.ENGLISH).startsWith("BE:"));

    // scheme information uri
    List<String> schemeInformationUris = trustServiceList.getSchemeInformationUris();
    assertNotNull(schemeInformationUris);
    // assertEquals(3, schemeInformationUris.size());
    assertEquals("http://tsl.belgium.be/", schemeInformationUris.get(0));

    // status determination approach
    assertEquals("http://uri.etsi.org/TrstSvc/TrustedList/TSLType/StatusDetn/EUappropriate",
            trustServiceList.getStatusDeterminationApproach());

    // scheme types

    /*List<String> schemeTypes = trustServiceList.getSchemeTypes();
    assertNotNull(schemeTypes);
    assertEquals(2, schemeTypes.size());
     */
    // scheme territory
    assertEquals("BE", trustServiceList.getSchemeTerritory());

    // legal notice
    String resultLegalNotice = trustServiceList.getLegalNotice(Locale.ENGLISH);
    assertNotNull(resultLegalNotice);
    assertTrue(resultLegalNotice.indexOf("1999/93/EC") != -1);
    assertTrue(resultLegalNotice.indexOf("Belgium") != -1);

    // historical information period
    assertEquals(new Integer(21845 * 3), trustServiceList.getHistoricalInformationPeriod());

    // list issue date time
    DateTime resultListIssueDateTime = trustServiceList.getListIssueDateTime();
    assertNotNull(resultListIssueDateTime);

    // next update
    DateTime resultNextUpdateDateTime = trustServiceList.getNextUpdate();
    assertNotNull(resultNextUpdateDateTime);

    // trust service provider list
    List<TrustServiceProvider> trustServiceProviders = trustServiceList.getTrustServiceProviders();
    assertEquals(2, trustServiceProviders.size());
    TrustServiceProvider certipostTrustServiceProvider = trustServiceProviders.get(0);
    assertEquals("Certipost n.v./s.a.", certipostTrustServiceProvider.getName(Locale.ENGLISH));

    // postal address
    PostalAddressType certipostPostalAddress = certipostTrustServiceProvider.getPostalAddress(Locale.ENGLISH);
    assertNotNull(certipostPostalAddress);
    assertEquals("Muntcentrum", certipostPostalAddress.getStreetAddress());
    assertEquals("BE", certipostPostalAddress.getCountryName());

    // electronic address
    /*
    List<String> resultElectronicAddress = certipostTrustServiceProvider
    .getElectronicAddress();
    assertEquals(2, resultElectronicAddress.size());
     */
    // information uri
    /*
    List<String> resultInformationUris = certipostTrustServiceProvider
    .getInformationUris(Locale.ENGLISH);
    assertEquals(2, resultInformationUris.size());
    assertEquals("http://repository.eid.belgium.be/EN/Index.htm",
    resultInformationUris.get(0));
    */

    LOG.debug("unsigned TSL: " + unsignedTslFile.getAbsolutePath());
    LOG.debug("TSL: " + tmpTslFile.getAbsolutePath());
    LOG.debug("PDF: " + pdfExportFile.getAbsolutePath());
}

From source file:org.talend.designer.core.ui.preferences.I18nPreferencePage.java

@Override
protected void createFieldEditors() {
    // Adds a combo for language selection.

    String spanish = "Espa\u00F1ol"; //$NON-NLS-1$
    byte[] utf8Bytes;
    try {/*from  ww  w . j av a  2 s  .c  o m*/
        utf8Bytes = spanish.getBytes("UTF8"); //$NON-NLS-1$
        spanish = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        spanish = "Spanish"; //$NON-NLS-1$
    }

    String russian = "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"; //$NON-NLS-1$
    try {
        utf8Bytes = russian.getBytes("UTF8"); //$NON-NLS-1$
        russian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        russian = "Russian"; //$NON-NLS-1$
    }

    String greek = "\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"; //$NON-NLS-1$
    try {
        utf8Bytes = greek.getBytes("UTF8"); //$NON-NLS-1$
        greek = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        greek = "Greek"; //$NON-NLS-1$
    }

    String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0647"; //$NON-NLS-1$
    try {
        utf8Bytes = arabic.getBytes("UTF8"); //$NON-NLS-1$
        arabic = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        arabic = "Arabic"; //$NON-NLS-1$
    }

    String serbian = "\u0421\u0440\u043f\u0441\u043a\u0438"; //$NON-NLS-1$
    try {
        utf8Bytes = serbian.getBytes("UTF8"); //$NON-NLS-1$
        serbian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e1) {
        // could be translated, but it's only in case of error when change UTF8 characters.
        serbian = "Serbian"; //$NON-NLS-1$
    }

    String[][] entryNamesAndValues = {
            { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() },
            { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() },
            { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" },
            { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() },
            { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() },
            { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() },
            { "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { spanish, "es" }, { russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ 
            { Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, { "Turkish", "tr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
            { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" },
            { "Romanian", "ro" }, { "Netherlands", "nl" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$ 
    languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR,
            Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, getFieldEditorParent()); //$NON-NLS-1$
    addField(languageSelectionEditor);

    Composite composite = getFieldEditorParent();
    LabelFieldEditor importAll = new LabelFieldEditor(
            Messages.getString("I18nPreferencePage.translationInformation"), //$NON-NLS-1$
            composite);
    addField(importAll);

    Button allUpdate = new Button(composite, SWT.FLAT);
    allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili")); //$NON-NLS-1$
    allUpdate.setLayoutData(new GridData());

    allUpdate.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // import all update from Babili
            // select the .zip file
            FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    SWT.OPEN);
            fd.setText("Open"); //$NON-NLS-1$
            fd.setFilterPath("C:" + fs); //$NON-NLS-1$
            String[] filterExtensions = { "*.zip" }; //$NON-NLS-1$
            fd.setFilterExtensions(filterExtensions);
            String selected = fd.open();
            if (selected != null) {
                isBabiliButtonClicked = true;
                runProgressMonitorDialog(selected);
                if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        Messages.getString("I18nPreferencePage.restart"), //$NON-NLS-1$
                        Messages.getString("I18nPreferencePage.restartButton"))) {
                    PlatformUI.getWorkbench().restart();
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }
    });

    // added by nma
    Button restoredefault = new Button(composite, SWT.FLAT);
    restoredefault.setText("Restore Defaults"); //$NON-NLS-1$
    restoredefault.setLayoutData(new GridData());
    restoredefault.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing to do
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            isBabiliButtonClicked = true;
            runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault")); //$NON-NLS-1$
            if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    Messages.getString("I18nPreferencePage.restart"),
                    Messages.getString("I18nPreferencePage.restartButton"))) {
                PlatformUI.getWorkbench().restart();
            }
        }
    });
}

From source file:divya.myvision.TessActivity.java

public void setLang(String lang) {
    Locale locale;/* w  ww .  ja  v  a 2 s  .c om*/
    if (lang.equals("Spanish")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locSpanish = new Locale("spa", "MEX");
                tts.setLanguage(locSpanish);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("spa", "MEX");
    }

    else if (lang.equals("French")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.FRENCH);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("fr");
    } else if (lang.equals("Japanese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.JAPANESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ja");
    } else if (lang.equals("Chinese")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.CHINESE);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("zh");
    } else if (lang.equals("German")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.GERMAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("de");
    } else if (lang.equals("Italian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.ITALIAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("it");
    } else if (lang.equals("Korean")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.KOREAN);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ko");
    } else if (lang.equals("Hindi")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("hi");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("hi");
    } else if (lang.equals("Russian")) {
        // Set up the Text To Speech engine.
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                Locale locHindhi = new Locale("ru");
                tts.setLanguage(locHindhi);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("ru");
    } else {
        TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(final int status) {
                tts.setLanguage(Locale.US);
            }
        };
        tts = new TextToSpeech(this.getApplicationContext(), listener);
        locale = new Locale("en");
    }
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.setLocale(locale);
    this.getApplicationContext().getResources().updateConfiguration(config, null);

}

From source file:com.espertech.esper.regression.resultset.TestOrderBySimple.java

public void testCollatorSortLocale() {
    String frenchForSin = "p\u00E9ch\u00E9";
    String frenchForFruit = "p\u00EAche";

    String[] sortedFrench = (frenchForFruit + "," + frenchForSin).split(",");

    assertEquals(1, frenchForFruit.compareTo(frenchForSin));
    assertEquals(-1, frenchForSin.compareTo(frenchForFruit));
    Locale.setDefault(Locale.FRENCH);
    assertEquals(1, frenchForFruit.compareTo(frenchForSin));
    assertEquals(-1, Collator.getInstance().compare(frenchForFruit, frenchForSin));
    assertEquals(-1, frenchForSin.compareTo(frenchForFruit));
    assertEquals(1, Collator.getInstance().compare(frenchForSin, frenchForFruit));
    assertFalse(frenchForSin.equals(frenchForFruit));

    /*/*from  w  w  w.j  a  va2 s.  c  o m*/
    Collections.sort(items);
    System.out.println("Sorted default" + items);
            
    Collections.sort(items, new Comparator<String>() {
    Collator collator = Collator.getInstance(Locale.FRANCE);
    public int compare(String o1, String o2)
    {
        return collator.compare(o1, o2);
    }
    });
    System.out.println("Sorted FR" + items);
    */

    Configuration config = SupportConfigFactory.getConfiguration();
    config.getEngineDefaults().getLanguage().setSortUsingCollator(true);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    epService.getEPAdministrator().getConfiguration().addEventType("SupportBean", SupportBean.class.getName());

    // test order by
    String stmtText = "select theString from SupportBean.win:keepall() order by theString asc";
    EPStatement stmtOne = epService.getEPAdministrator().createEPL(stmtText);
    epService.getEPRuntime().sendEvent(new SupportBean(frenchForSin, 1));
    epService.getEPRuntime().sendEvent(new SupportBean(frenchForFruit, 1));
    EPAssertionUtil.assertPropsPerRow(stmtOne.iterator(), "theString".split(","),
            new Object[][] { { sortedFrench[0] }, { sortedFrench[1] } });

    // test sort view
    SupportUpdateListener listener = new SupportUpdateListener();
    stmtText = "select irstream theString from SupportBean.ext:sort(2, theString asc)";
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(stmtText);
    stmtTwo.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean(frenchForSin, 1));
    epService.getEPRuntime().sendEvent(new SupportBean(frenchForFruit, 1));
    epService.getEPRuntime().sendEvent(new SupportBean("abc", 1));

    assertEquals(frenchForSin, listener.getLastOldData()[0].get("theString"));
    Locale.setDefault(Locale.US);
}

From source file:org.esco.grouperui.web.controllers.SessionController.java

/**
 * Getter for local./*from   w  w  w . j  ava 2  s  .  c  o  m*/
 * 
 * @return the local to get.
 */
public final Locale getLocale() {
    if (this.getUser() == null) {
        return Locale.FRENCH;
    }
    return this.getUser().getLocale();
}

From source file:fr.paris.lutece.portal.web.user.AdminUserJspBeanTest.java

public void testDoCreateAdminUser()
        throws PasswordResetException, AccessDeniedException, UserNotSignedException {
    AdminUserJspBean bean = new AdminUserJspBean();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
            SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
    bean.doCreateAdminUser(request);//from  w w w.j av  a 2 s .c  om
    AdminMessage message = AdminMessageService.getMessage(request);
    assertNotNull(message);
    assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
            message.getText(Locale.FRENCH));

    String randomUserName = "User_" + new SecureRandom().nextLong();
    try {
        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", "   ");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", "admin");
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.user.accessCodeAlreadyUsed",
                Locale.FRENCH), message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", "admin@lutece.fr");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.user.accessEmailUsed", Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.addParameter("user_level", "0");
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel1AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.init(request, "CORE_USERS_MANAGEMENT");
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.USER_ACCESS_DENIED, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.addParameter("user_level", "0");
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel0AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.init(request, "CORE_USERS_MANAGEMENT");
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.addParameter("user_level", "0");
        request.addParameter("first_password", randomUserName);
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel0AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.init(request, "CORE_USERS_MANAGEMENT");
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.differentsPassword", Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.addParameter("user_level", "0");
        request.addParameter("first_password", randomUserName);
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel0AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.init(request, "CORE_USERS_MANAGEMENT");
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.differentsPassword", Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        request.addParameter("access_code", randomUserName);
        request.addParameter("last_name", randomUserName);
        request.addParameter("first_name", randomUserName);
        request.addParameter("email", randomUserName + "@lutece.fr");
        request.addParameter("user_level", "0");
        request.addParameter("first_password", randomUserName);
        request.addParameter("second_password", randomUserName);
        request.addParameter("status", Integer.toString(AdminUser.ACTIVE_CODE)); // NPE if absent
        request.addParameter("language", "fr"); // NPE if absent
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel0AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/CreateUser.jsp"));
        bean.init(request, "CORE_USERS_MANAGEMENT");
        bean.doCreateAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNull(message);
        AdminUser createdUser = AdminUserHome.findUserByLogin(randomUserName);
        assertNotNull(createdUser);
        LuteceDefaultAdminUser createdUserWithPassword = AdminUserHome
                .findLuteceDefaultAdminUserByPrimaryKey(createdUser.getUserId());
        assertNotNull(createdUserWithPassword);
        assertTrue(createdUserWithPassword.getPassword().check(randomUserName));
    } finally {
        AdminUser user = AdminUserHome.findUserByLogin(randomUserName);
        if (user != null) {
            AdminUserHome.remove(user.getUserId());
        }
    }
}

From source file:fr.gouv.diplomatie.applitutoriel.business.service.MailContactServiceImpl.java

/** {@inheritDoc} */
@Override//ww  w. j  a  v  a 2 s. c  om
public void envoyerMail(final String nom, final String prenom, final String fromAddress, final String message) {

    try {
        final String sujet = String.format(this.objetContactMail, this.applicationName,
                WordUtils.capitalize(prenom), WordUtils.capitalize(nom));

        final Map<String, Object> params = new HashMap<String, Object>();
        params.put("nom", WordUtils.capitalize(nom));
        params.put("prenom", WordUtils.capitalize(prenom));
        params.put("corps", message);
        final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy '' HH:mm:ss", Locale.FRENCH);
        params.put("date", sdf.format(new Date()));
        params.put("applicationName", this.applicationName);
        params.put("applicationUrl", this.applicationUrl);

        // Exemple d'utilisation d'un NO_REPLY ou d'ajout d'un CC
        // params.put(MailServiceImpl.SMTP_HEADER_REPLYTO, NO_REPLY);
        // params.put(MailServiceImpl.SMTP_HEADER_CC, "root@localhost.com");

        this.mailService.envoyerDepuisModele(fromAddress, sujet, this.corpsContactMail, params,
                this.destinataires);

    } catch (final Exception e) {
        MailContactServiceImpl.LOGGER.error("Erreur lors de la tentative d'envoi de mail de contact.", e);
        throw new BusinessException("ERR-CODE-MAIL-001", e);
    }

}

From source file:org.zoumbox.mh_dla_notifier.MhDlaNotifierUtils.java

public static String formatHourNoSecondsForDisplay(Context context, Date input) {
    String result = N_C;/*w  ww.  j a v a  2  s.com*/
    if (input != null) {
        DateFormat outputDF = new SimpleDateFormat(HOUR_NO_SEC_DATE_FORMAT, Locale.FRENCH);
        outputDF.setTimeZone(getDisplayTimeZone(context));
        result = outputDF.format(input);
    }
    return result;
}