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:fr.paris.lutece.plugins.genericalert.service.TaskNotifyReminder.java

/**
 * Get message text/*ww  w .  java 2  s. com*/
 * @param msg the text message
 * @param appointment the appointment
 * @return the text message
 */
private String getMessageAppointment(String msg, Appointment appointment) {
    DateFormat formater = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH);
    SimpleDateFormat formatTime = new SimpleDateFormat("HH:mm");
    String strLocation = appointment.getLocation() == null ? StringUtils.EMPTY : appointment.getLocation();
    String strText = StringUtils.EMPTY;
    strText = msg.replace(MARK_FIRST_NAME, appointment.getFirstName());
    strText = strText.replace(MARK_LAST_NAME, appointment.getLastName());
    strText = strText.replace(MARK_DATE_APP, formater.format(appointment.getDateAppointment()));
    strText = strText.replace(MARK_TIME_APP, formatTime.format(appointment.getStartAppointment()));
    strText = strText.replace(MARK_LOCALIZATION, strLocation);
    strText = strText.replace(MARK_CANCEL_APP, AppointmentApp.getCancelAppointmentUrl(appointment));

    return strText;
}

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

public String analyze(String str) {
    try {/*w  ww.ja va2 s  .  c  om*/
        return analyze(str, analyzerProvider.getAnalyzer(Locale.FRENCH));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.webbfontaine.valuewebb.model.util.Utils.java

public static void setLocale(String language) {
    String notEmptyLanguage = StringUtils.defaultIfEmpty(StringUtils.trimToEmpty(language), EN).replaceAll("'",
            "");/*from   w ww.  jav  a2s.c o  m*/

    if (Constants.FR.equals(notEmptyLanguage)) {
        LocaleSelector.instance().setLocale(Locale.FRENCH);
    } else {
        if (Constants.EN.equals(notEmptyLanguage)) {
            LocaleSelector.instance().setLocale(Locale.ENGLISH);
        } else {
            LOGGER.warn("There is no support for locale {0}. English will be set.", notEmptyLanguage);
            LocaleSelector.instance().setLocale(Locale.ENGLISH);
        }
    }
}

From source file:fr.paris.lutece.plugins.document.service.docsearch.DocSearchService.java

/**
 * Format the date/*from w w w  .java2  s .  co m*/
 * @param date the date
 * @return formatedDate the formated date
 */
private String formatDate(String date) {
    DateFormat dateFormat = new SimpleDateFormat(PATTERN_DATE, Locale.FRENCH);
    dateFormat.setLenient(false);

    Date formatedDate;

    try {
        formatedDate = dateFormat.parse(date.trim());
    } catch (ParseException e) {
        AppLogService.error(e);

        return null;
    }

    return dateFormat.format(formatedDate);
}

From source file:org.nuxeo.ecm.core.resolver.TestDocumentModelResolver.java

private void checkMessage(DocumentModelResolver dmrr) {
    for (Locale locale : Arrays.asList(Locale.FRENCH, Locale.ENGLISH)) {
        String message = dmrr.getConstraintErrorMessage("abc123", locale);
        assertNotNull(message);// w  w w.  j a v a 2 s.  co m
        assertFalse(message.trim().isEmpty());
        System.out.println(message);
    }
}

From source file:be.fedict.eid.tsl.BelgianTrustServiceListFactory.java

private static void setupTSL(TrustServiceList trustServiceList) {
    // scheme operator name
    trustServiceList.setSchemeOperatorName("FPS Economy, SMEs, Self-employed and Energy - Quality and Safety",
            Locale.ENGLISH);/*from  w  w  w .  j a  v  a  2 s .  com*/
    trustServiceList.setSchemeOperatorName(
            "FOD Economie, KMO, Middenstand en Energie - Kwaliteit en Veiligheid", new Locale("nl"));
    trustServiceList.setSchemeOperatorName(
            "SPF Economie, PME, Classes moyennes et Energie - Qualit et Scurit", Locale.FRENCH);
    trustServiceList.setSchemeOperatorName(
            "FD Wirtschaft, KMU, Mittelstand und Energie - Qualitt und Sicherheit", Locale.GERMAN);

    // scheme operator postal address
    PostalAddressType schemeOperatorPostalAddress = new PostalAddressType();
    schemeOperatorPostalAddress.setStreetAddress("NG III - Koning Albert II-laan 16");
    schemeOperatorPostalAddress.setLocality("Brussels");
    schemeOperatorPostalAddress.setStateOrProvince("Brussels");
    schemeOperatorPostalAddress.setPostalCode("1000");
    schemeOperatorPostalAddress.setCountryName("BE"); // this one containing
    // an EU country
    // code
    trustServiceList.setSchemeOperatorPostalAddress(schemeOperatorPostalAddress, Locale.ENGLISH);

    schemeOperatorPostalAddress.setStreetAddress("NG III - Koning Albert II-laan 16");
    schemeOperatorPostalAddress.setLocality("Brussel");
    schemeOperatorPostalAddress.setStateOrProvince("Brussel");
    schemeOperatorPostalAddress.setPostalCode("1000");
    schemeOperatorPostalAddress.setCountryName("BE"); // this one containing
    // an EU country
    // code
    trustServiceList.setSchemeOperatorPostalAddress(schemeOperatorPostalAddress, new Locale("nl"));

    // scheme operator electronic address      
    trustServiceList.setSchemeOperatorElectronicAddresses(Locale.ENGLISH, "http://economie.fgov.be");
    trustServiceList.setSchemeOperatorElectronicAddresses(Locale.ENGLISH, "mailto:be.sign@economie.fgov.be");

    // scheme name
    trustServiceList.setSchemeName(
            "BE:Supervision/Accreditation Status List of certification services from Certification Service Providers, which are supervised/accredited by the referenced Scheme Operator's Member State for compliance with the relevant provisions laid down in Directive 1999/93/EC of the European Parliament and of the Council of 13 December 1999 on a Community framework for electronic signatures.",
            Locale.ENGLISH);

    // scheme information URIs
    trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/", Locale.ENGLISH);
    // trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/nl/",
    // new Locale("nl"));
    // trustServiceList.addSchemeInformationUri("http://tsl.belgium.be/fr/",
    // Locale.FRENCH);

    // status determination approach
    trustServiceList.setStatusDeterminationApproach(TrustServiceList.STATUS_DETERMINATION_APPROPRIATE);

    // scheme type
    /*
     * The Scheme Type URIs can actually be visited. We should provide some
     * information to ETSI for the BE schemerules.
     */
    trustServiceList.addSchemeType(TrustServiceList.SCHEME_RULE_COMMON, Locale.ENGLISH);
    /*
     * The BE schemerules MUSH be provided. We can add extra paths for
     * language. For example: http://
     * uri.etsi.org/TrstSvc/eSigDir-1999-93-EC-TrustedList/schemerules/BE/nl
     */
    trustServiceList.addSchemeType("http://uri.etsi.org/TrstSvc/TrustedList/schemerules/BE", Locale.ENGLISH);

    // scheme territory
    trustServiceList.setSchemeTerritory("BE");

    // legal notice
    trustServiceList.addLegalNotice(
            "The applicable legal framework for the present TSL implementation of the Trusted List of supervised/accredited Certification Service Providers for Belgium is Directive 1999/93/EC of the European Parliament and of the Council of 13 December 1999 on a Community framework for electronic signatures and its implementation in Belgian laws. The applicable legal national framework is the Belgian CSP act of 9 July 2001 to create a legal framework for the usage of electronic signatures and certification services.",
            Locale.ENGLISH);

    // historical information period
    /*
     * Volgens de wet van 9 JULI 2001.  Wet houdende vaststelling van
     * bepaalde regels in verband met het juridisch kader voor elektronische
     * handtekeningen en certificatiediensten: Bijlage II - punt i) alle
     * relevante informatie over een gekwalificeerd certificaat te
     * registreren gedurende de nuttige termijn van dertig jaar, in het
     * bijzonder om een certificatiebewijs te kunnen voorleggen bij
     * gerechtelijke procedures.
     */
    trustServiceList.setHistoricalInformationPeriod(21845 * 3);

    trustServiceList.addDistributionPoint("http://tsl.belgium.be/tsl-be.xml");
}

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

public void testDoModifyAdminUser() throws AccessDeniedException, UserNotSignedException {
    AdminUser userToModify = getUserToModify();
    try {/*from   w w w.j av  a 2  s. c  o  m*/
        AdminUserJspBean bean = new AdminUserJspBean();
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.getSession(true).setAttribute("lutece_admin_user",
                getLevel1AdminUserWithCORE_USERS_MANAGEMENTRight());
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        try {
            bean.doModifyAdminUser(request);
            fail("Should not be able to modify a user with a lower level");
        } catch (AccessDeniedException e) {
        }

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        AdminMessage message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        final String modifiedName = userToModify.getAccessCode() + "_mod";

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", modifiedName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", modifiedName);
        request.addParameter("last_name", modifiedName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", modifiedName);
        request.addParameter("last_name", modifiedName);
        request.addParameter("first_name", modifiedName);
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", modifiedName);
        request.addParameter("last_name", modifiedName);
        request.addParameter("first_name", modifiedName);
        request.addParameter("email", "  ");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString(Messages.MANDATORY_FIELDS, Locale.FRENCH),
                message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", "admin");
        request.addParameter("last_name", modifiedName);
        request.addParameter("first_name", modifiedName);
        request.addParameter("email", modifiedName + "@lutece.fr");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.user.accessCodeAlreadyUsed",
                Locale.FRENCH), message.getText(Locale.FRENCH));

        request = new MockHttpServletRequest();
        AdminAuthenticationService.getInstance().registerUser(request, AdminUserHome.findUserByLogin("admin"));
        request.addParameter("id_user", Integer.toString(userToModify.getUserId()));
        request.addParameter("access_code", modifiedName);
        request.addParameter("last_name", modifiedName);
        request.addParameter("first_name", modifiedName);
        request.addParameter("email", "admin@lutece.fr");
        request.setParameter(SecurityTokenService.PARAMETER_TOKEN,
                SecurityTokenService.getInstance().getToken(request, "jsp/admin/user/ModifyUser.jsp"));
        bean.doModifyAdminUser(request);
        message = AdminMessageService.getMessage(request);
        assertNotNull(message);
        assertEquals(I18nService.getLocalizedString("portal.users.message.user.accessEmailUsed", Locale.FRENCH),
                message.getText(Locale.FRENCH));
    } finally {
        disposeOfUser(userToModify);
    }
}

From source file:fr.outadev.android.timeo.TimeoRequestHandler.java

/**
 * Capitalizes the first letter of every word, like WordUtils.capitalize(); except it does it WELL.
 * The determinants will not be capitalized, whereas some acronyms will.
 *
 * @param str The text to capitalize.//from   ww w. jav  a 2s  .  c  o  m
 * @return The capitalized text.
 */
public static String smartCapitalize(String str) {
    String newStr = "";
    str = str.toLowerCase().trim();

    //these words will never be capitalized
    String[] determinants = new String[] { "de", "du", "des", "au", "aux", "", "la", "le", "les", "d", "et",
            "l" };
    //these words will always be capitalized
    String[] specialWords = new String[] { "sncf", "chu", "chr", "chs", "crous", "suaps", "fpa", "za", "zi",
            "zac", "cpam", "efs", "mjc" };

    //explode the string with both spaces and apostrophes
    String[] words = str.split("( |\\-|'|\\/)");

    for (String word : words) {
        if (Arrays.asList(determinants).contains(word)) {
            //if the word should not be capitalized, just append it to the new string
            newStr += word;
        } else if (Arrays.asList(specialWords).contains(word)) {
            //if the word should be in upper case, do eet
            newStr += word.toUpperCase(Locale.FRENCH);
        } else {
            //if it's a normal word, just capitalize it
            newStr += StringUtils.capitalize(word);
        }

        try {
            //we don't know if the next character is a blank space or an apostrophe, so we check that
            char delimiter = str.charAt(newStr.length());
            newStr += delimiter;
        } catch (StringIndexOutOfBoundsException ignored) {
            //will be thrown for the last word of the string
        }
    }

    return StringUtils.capitalize(newStr);
}

From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java

public void setUp() throws Exception {
    dialect = (Dialect) ctx.getBean("dialect");

    nodeService = (NodeService) ctx.getBean("dbNodeService");
    dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    luceneFTS = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer");
    contentService = (ContentService) ctx.getBean("contentService");
    queryRegisterComponent = (QueryRegisterComponent) ctx.getBean("queryRegisterComponent");
    namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService");
    transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("admLuceneIndexerAndSearcherFactory");
    luceneConfig = (LuceneConfig) ctx.getBean("admLuceneIndexerAndSearcherFactory");
    ((LuceneConfig) indexerAndSearcher).setMaxAtomicTransformationTime(1000000);
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
    tenantService = (TenantService) ctx.getBean("tenantService");
    queryEngine = (QueryEngine) ctx.getBean("adm.luceneQueryEngineImpl");

    nodeBulkLoader = (NodeBulkLoader) ctx.getBean("nodeDAO");

    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

    namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO");

    I18NUtil.setLocale(Locale.UK);

    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");

    queryRegisterComponent.loadQueryCollection("testQueryRegister.xml");

    assertEquals(true, ctx.isSingleton("LuceneFullTextSearchIndexer"));

    testTX = transactionService.getUserTransaction();
    testTX.begin();/*from  w ww  .j  a  v  a  2s  .c om*/
    this.authenticationComponent.setSystemUserAsCurrentUser();

    // load in the test model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl
            .getResourceAsStream("org/alfresco/repo/search/impl/lucene/LuceneTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDAO.registerListener(this);
    dictionaryDAO.reset();
    assertNotNull(dictionaryDAO.getClass(testSuperType));

    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE,
            "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);

    n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"),
            testSuperType, getOrderProperties()).getChildRef();
    nodeService.setProperty(n1, QName.createQName("{namespace}property-1"), "ValueOne");

    n2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"),
            testSuperType, getOrderProperties()).getChildRef();
    nodeService.setProperty(n2, QName.createQName("{namespace}property-1"), "valueone");
    nodeService.setProperty(n2, QName.createQName("{namespace}property-2"), "valuetwo");

    n3 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}three"),
            testSuperType, getOrderProperties()).getChildRef();

    ObjectOutputStream oos;
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        oos = new ObjectOutputStream(baos);
        oos.writeObject(n3);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        Object o = ois.readObject();
        ois.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYONE");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-unstored-tokenised-atomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYUNSTORED");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-nonatomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED BUT NOT ATOMICALLY KEYTWO");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "int-ista"), Integer.valueOf(1));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "long-ista"), Long.valueOf(2));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "float-ista"), Float.valueOf(3.4f));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "double-ista"), Double.valueOf(5.6));
    //testDate = new Date(((new Date().getTime() - 10000)));
    Calendar c = new GregorianCalendar();
    c.setTime(new Date(((new Date().getTime() - 10000))));
    //c.add(Calendar.MINUTE, -1);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.MILLISECOND, 999);
    //c.set(Calendar.SECOND, 1);
    //c.set(Calendar.MILLISECOND, 0);
    //c.set(Calendar.SECOND, 0);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.HOUR_OF_DAY, 0);
    //        c.set(Calendar.YEAR, 2000);
    //        c.set(Calendar.MONTH, 12);
    //        c.set(Calendar.DAY_OF_MONTH, 31);
    //        c.set(Calendar.HOUR_OF_DAY, 23);
    //        c.set(Calendar.MINUTE, 59);
    //        c.set(Calendar.SECOND, 59);
    //        c.set(Calendar.MILLISECOND, 999);
    testDate = c.getTime();
    testProperties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "boolean-ista"), Boolean.valueOf(true));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "qname-ista"), QName.createQName("{wibble}wobble"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "category-ista"), new NodeRef(storeRef, "CategoryId"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "noderef-ista"), n1);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "path-ista"), nodeService.getPath(n3));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "locale-ista"), Locale.UK);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "period-ista"), new Period("period|12"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "null"), null);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "list"), new ArrayList<Object>());
    MLText mlText = new MLText();
    mlText.addValue(Locale.ENGLISH, "banana");
    mlText.addValue(Locale.FRENCH, "banane");
    mlText.addValue(Locale.CHINESE, "");
    mlText.addValue(new Locale("nl"), "banaan");
    mlText.addValue(Locale.GERMAN, "banane");
    mlText.addValue(new Locale("el"), "");
    mlText.addValue(Locale.ITALIAN, "banana");
    mlText.addValue(new Locale("ja"), "?");
    mlText.addValue(new Locale("ko"), "");
    mlText.addValue(new Locale("pt"), "banana");
    mlText.addValue(new Locale("ru"), "");
    mlText.addValue(new Locale("es"), "pltano");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "ml"), mlText);
    // Any multivalued
    ArrayList<Serializable> anyValues = new ArrayList<Serializable>();
    anyValues.add(Integer.valueOf(100));
    anyValues.add("anyValueAsString");
    anyValues.add(new UnknownDataType());
    testProperties.put(QName.createQName(TEST_NAMESPACE, "any-many-ista"), anyValues);
    // Content multivalued
    // - note only one the first value is used from the collection
    // - andit has to go in type d:any as d:content is not allowed to be multivalued

    ArrayList<Serializable> contentValues = new ArrayList<Serializable>();
    contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16", Locale.UK));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues);

    // MLText multivalued

    MLText mlText1 = new MLText();
    mlText1.addValue(Locale.ENGLISH, "cabbage");
    mlText1.addValue(Locale.FRENCH, "chou");

    MLText mlText2 = new MLText();
    mlText2.addValue(Locale.ENGLISH, "lemur");
    mlText2.addValue(new Locale("ru"), "");

    ArrayList<Serializable> mlValues = new ArrayList<Serializable>();
    mlValues.add(mlText1);
    mlValues.add(mlText2);

    testProperties.put(QName.createQName(TEST_NAMESPACE, "mltext-many-ista"), mlValues);

    // null in multi valued

    ArrayList<Object> testList = new ArrayList<Object>();
    testList.add(null);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "nullist"), testList);
    ArrayList<Object> testList2 = new ArrayList<Object>();
    testList2.add("woof");
    testList2.add(null);

    n4 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}four"),
            testType, testProperties).getChildRef();

    ContentWriter multiWriter = contentService.getWriter(n4,
            QName.createQName(TEST_NAMESPACE, "content-many-ista"), true);
    multiWriter.setEncoding("UTF-16");
    multiWriter.setMimetype("text/plain");
    multiWriter.putContent("multicontent");

    nodeService.getProperties(n1);
    nodeService.getProperties(n2);
    nodeService.getProperties(n3);
    nodeService.getProperties(n4);

    n5 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}five"), testSuperType,
            getOrderProperties()).getChildRef();
    n6 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}six"), testSuperType,
            getOrderProperties()).getChildRef();
    n7 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}seven"), testSuperType,
            getOrderProperties()).getChildRef();
    n8 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-2"), testSuperType,
            getOrderProperties()).getChildRef();
    n9 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}nine"), testSuperType,
            getOrderProperties()).getChildRef();
    n10 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}ten"), testSuperType,
            getOrderProperties()).getChildRef();
    n11 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eleven"), testSuperType,
            getOrderProperties()).getChildRef();
    n12 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}twelve"), testSuperType,
            getOrderProperties()).getChildRef();
    n13 = nodeService.createNode(n12, ASSOC_TYPE_QNAME, QName.createQName("{namespace}thirteen"), testSuperType,
            getOrderProperties()).getChildRef();

    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();

    MLText desc1 = new MLText();
    desc1.addValue(Locale.ENGLISH, "Alfresco tutorial");
    desc1.addValue(Locale.US, "Alfresco tutorial");

    Date explicitCreatedDate = new Date();
    Thread.sleep(2000);

    properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK));
    properties.put(ContentModel.PROP_DESCRIPTION, desc1);
    properties.put(ContentModel.PROP_CREATED, explicitCreatedDate);

    //Calendar c = new GregorianCalendar();
    //c.setTime(new Date());
    //c.set(Calendar.MILLISECOND, 0);
    //c.set(Calendar.SECOND, 0);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.HOUR_OF_DAY, 0);
    //testDate = c.getTime();
    //properties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate);
    //properties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate);

    // note: cm:content - hence auditable aspect will be applied with any missing mandatory properties (cm:modified, cm:creator, cm:modifier)
    n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"),
            ContentModel.TYPE_CONTENT, properties).getChildRef();
    // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT,
    // properties);

    assertEquals(explicitCreatedDate, nodeService.getProperty(n14, ContentModel.PROP_CREATED));

    // note: cm:thumbnail - hence auditable aspect will be applied with mandatory properties (cm:created, cm:modified, cm:creator, cm:modifier)
    n15 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fifteen"),
            ContentModel.TYPE_THUMBNAIL, getOrderProperties()).getChildRef();
    nodeService.setProperty(n15, ContentModel.PROP_CONTENT,
            new ContentData(null, "text/richtext", 0L, "UTF-8", Locale.FRENCH));

    ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    // InputStream is =
    // this.getClass().getClassLoader().getResourceAsStream("test.doc");
    // writer.putContent(is);
    writer.putContent(
            "The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words;  a an and are"
                    + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: "
                    + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF");
    // System.out.println("Size is " + writer.getSize());

    writer = contentService.getWriter(n15, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    // InputStream is =
    // this.getClass().getClassLoader().getResourceAsStream("test.doc");
    // writer.putContent(is);
    writer.putContent("          ");

    nodeService.addChild(rootNodeRef, n8, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}eight-0"));
    nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-1"));
    nodeService.addChild(n2, n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}link"));

    nodeService.addChild(n1, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n2, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n5, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n6, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n12, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n13, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));

    documentOrder = new NodeRef[] { rootNodeRef, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n3, n1,
            n2 };
}

From source file:org.pengyou.ooo.OpenDialog.java

private String formatList(String[] t) {
    String res = new String();

    if (t[2] == "COLLECTION") {
        if (t[4].length() > SPACES_FILE - 4)
            res = t[4].substring(0, SPACES_FILE - 5) + "";
        else/*from  w w w . j  a  v a 2  s  .co  m*/
            res = t[4];
        res = " " + res;
    } else {
        if (t[4].length() > SPACES_FILE - 2)
            res = t[4].substring(0, SPACES_FILE - 3) + "";
        else
            res = t[4];
    }

    while (res.length() < SPACES_FILE)
        res += " ";

    res += t[6];
    while (res.length() < SPACES_AUTHOR)
        res += " ";

    Locale locale = Locale.FRENCH;
    Date date = null;
    String s = null;

    try {
        date = DateFormat.getDateTimeInstance().parse(t[5]);
        s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date);
        res += s;
        while (res.length() < SPACES_CDATE)
            res += " ";
    } catch (ParseException e) {
        e.printStackTrace();
        log.log(Level.DEBUG, e.getLocalizedMessage());
    }
    date = null;
    s = null;
    try {
        date = DateFormat.getDateTimeInstance().parse(t[3]);
        s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date);
        res += s;
        while (res.length() < SPACES_EDATE)
            res += " ";
    } catch (ParseException e) {
        e.printStackTrace();
        log.log(Level.DEBUG, e.getLocalizedMessage());
    }

    return res;
}