List of usage examples for java.util Locale FRENCH
Locale FRENCH
To view the source code for java.util Locale FRENCH.
Click Source Link
From source file:com.doculibre.constellio.lucene.impl.SkosIndexHelperImpl.java
@Override public void delete(Thesaurus thesaurus) { try {/* w ww .jav a 2 s . c o m*/ Directory directory = FSDirectory.open(getIndexDir()); if (DirectoryReader.indexExists(directory)) { Analyzer analyzer = getAnalyzerProvider().getAnalyzer(Locale.FRENCH); IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_44, analyzer)); Term term = new Term(THESAURUS_ID, thesaurus.getId().toString()); indexWriter.deleteDocuments(term); indexWriter.close(); } directory.close(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.apache.tiles.definition.TestUrlDefinitionsFactory.java
/** * Tests the addDefinitions method under normal * circumstances./*from w w w . j a va 2 s.c om*/ * * @throws Exception If something goes wrong. */ @SuppressWarnings("unchecked") public void testReadByLocale() throws Exception { MockPublicUrlDefinitionsFactory factory = new MockPublicUrlDefinitionsFactory(); // Set up multiple data sources. URL url1 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs1.xml"); assertNotNull("Could not load defs1 file.", url1); URL url2 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs2.xml"); assertNotNull("Could not load defs2 file.", url2); URL url3 = this.getClass().getClassLoader().getResource("org/apache/tiles/config/defs3.xml"); assertNotNull("Could not load defs3 file.", url3); factory.init(Collections.EMPTY_MAP); factory.addSource(url1); factory.addSource(url2); factory.addSource(url3); // Parse files. Definitions definitions = factory.readDefinitions(); factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.US)); factory.addDefinitions(definitions, new MockOnlyLocaleTilesContext(Locale.FRENCH)); assertNotNull("test.def1 definition not found.", definitions.getDefinition("test.def1")); assertNotNull("test.def1 US definition not found.", definitions.getDefinition("test.def1", Locale.US)); assertNotNull("test.def1 France definition not found.", definitions.getDefinition("test.def1", Locale.FRENCH)); assertNotNull("test.def1 China should return default.", definitions.getDefinition("test.def1", Locale.CHINA)); assertEquals("Incorrect default country value", "default", definitions.getDefinition("test.def1").getAttribute("country").getValue()); assertEquals("Incorrect US country value", "US", definitions.getDefinition("test.def1", Locale.US).getAttribute("country").getValue()); assertEquals("Incorrect France country value", "France", definitions.getDefinition("test.def1", Locale.FRENCH).getAttribute("country").getValue()); assertEquals("Incorrect Chinese country value (should default)", "default", definitions.getDefinition("test.def1", Locale.CHINA).getAttribute("country").getValue()); }
From source file:com.silverpeas.silvercrawler.control.SilverCrawlerSessionController.java
public FolderZIPInfo zipFolder(String folderName) { FolderZIPInfo zipInfo = new FolderZIPInfo(); File downloadPath = FileUtils.getFile(getFullPath(folderName)); SilverTrace.info("silverCrawler", "SilverCrawlerRequestRouter.zipFolder()", "root.MSG_GEN_PARAM_VALUE", "downloadPath = " + downloadPath.getPath()); Calendar calendar = Calendar.getInstance(Locale.FRENCH); String date = createDate(calendar); File zipFile = FileUtils.getFile(FileRepositoryManager.getTemporaryPath(), folderName + "_" + date + ".zip"); SilverTrace.debug("silverCrawler", "SilverCrawlerSessionController.zipFolder()", "root.MSG_GEN_PARAM_VALUE", "fileZip = " + zipFile.getName()); long sizeMax = UnitUtil.convertTo(getSizeMax(), MemoryUnit.MB, MemoryUnit.B); long zipSize = 0; String url = ""; SilverTrace.debug("silverCrawler", "SilverCrawlerSessionController.zipFolder()", "root.MSG_GEN_PARAM_VALUE", "sizeMax = " + sizeMax); // rechercher si la taille du rpertoire est < la taille maxi boolean sizeOk = getSize(downloadPath.getPath(), sizeMax); SilverTrace.debug("silverCrawler", "SilverCrawlerSessionController.zipFolder()", "root.MSG_GEN_PARAM_VALUE", "sizeOk = " + sizeOk); // si la taille est inferieur celle autorise : if (sizeOk) { try {/*from w w w . j a v a 2s. c o m*/ zipSize = ZipManager.compressPathToZip(downloadPath, zipFile); url = FileServerUtils.getSilverCrawlerUrl(zipFile.getName(), zipFile.getName(), getComponentId(), downloadPath.getPath().substring(getRootPath().length())); } catch (Exception e) { throw new SilverCrawlerRuntimeException("SilverCrawlerSessionController.zipFolder()", SilverpeasRuntimeException.ERROR, "root.EX_CANT_ZIP_DIRECTORY", e); } } else { zipFile = FileUtils.getFile(""); } // Fill in ZipFolderInfo object zipInfo.setFileZip(zipFile.getName()); zipInfo.setSize(zipSize); zipInfo.setMaxiSize(getSizeMaxString()); zipInfo.setUrl(url); SilverTrace.info("silverCrawler", "SilverCrawlerSessionController.zipFolder()", "root.MSG_GEN_PARAM_VALUE", "fileZip = " + zipFile.getName()); return zipInfo; }
From source file:de.schildbach.pte.AbstractTsiProvider.java
private NearbyLocationsResult jsonCoordRequest(final int lat, final int lon, final int maxDistance, final int maxStations) throws IOException { final HttpUrl.Builder url = stopFinderEndpoint.newBuilder().addPathSegments("SearchTripPoint/json"); appendCommonRequestParams(url);/* w ww . j a v a2 s.c o m*/ url.addQueryParameter("Latitude", String.format(Locale.FRENCH, "%2.6f", latLonToDouble(lat))); url.addQueryParameter("Longitude", String.format(Locale.FRENCH, "%2.6f", latLonToDouble(lon))); url.addQueryParameter("MaxItems", Integer.toString(maxStations != 0 ? maxStations : 50)); url.addQueryParameter("Perimeter", Integer.toString(maxDistance != 0 ? maxDistance : 1320)); url.addQueryParameter("PointTypes", "Stop_Place"); final CharSequence page = httpClient.get(url.build()); try { final List<Location> stations = new ArrayList<>(); final JSONObject head = new JSONObject(page.toString()); final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT); final int status = head.getInt("StatusCode"); if (status != 200) { return new NearbyLocationsResult(header, status == 300 ? NearbyLocationsResult.Status.INVALID_ID : NearbyLocationsResult.Status.SERVICE_DOWN); } JSONArray dataArray = head.getJSONArray("Data"); for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); stations.add(parseJsonTransportLocation(data)); } return new NearbyLocationsResult(header, stations); } catch (final JSONException x) { throw new ParserException(x); } }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTest.java
@Test public void buildRequestLocaleFr() { webRequest.setAdditionalHeader("Accept-Language", "fr"); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getLocale()).isEqualTo(Locale.FRENCH); }
From source file:com.doculibre.constellio.lucene.BaseLuceneIndexHelper.java
private void createIndexIfNecessary() { try {//from ww w. j av a 2 s. co m 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)); indexWriter.addDocument(new Document()); indexWriter.close(); } directory.close(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java
@Test public void buildRequestLocaleFr() { webRequest.setAdditionalHeader("Accept-Language", "fr"); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getLocale(), equalTo(Locale.FRENCH)); }
From source file:org.opencommercesearch.EmbeddedSearchServer.java
/** * Shutdown the cores for this server, however the coreContainer is left running. This method is intented for the * integration testing framework only. Don't use. *///from w w w . j a v a2s .c om public void shutdownCores() throws SolrServerException, IOException { if (isLoggingInfo()) { logInfo("Shutting down core for collection " + getCatalogCollection()); logInfo("Shutting down core for collection " + getRulesCollection()); } boolean deleteIndex = !getInMemoryIndex(); // @TODO add support to shuutdown all localized cores CoreAdminRequest.unloadCore(getCatalogCollection(Locale.ENGLISH), deleteIndex, getCatalogSolrServer(Locale.ENGLISH)); CoreAdminRequest.unloadCore(getRulesCollection(Locale.ENGLISH), deleteIndex, getRulesSolrServer(Locale.ENGLISH)); CoreAdminRequest.unloadCore(getCatalogCollection(Locale.FRENCH), deleteIndex, getCatalogSolrServer(Locale.FRENCH)); CoreAdminRequest.unloadCore(getRulesCollection(Locale.FRENCH), deleteIndex, getRulesSolrServer(Locale.FRENCH)); }
From source file:fr.paris.lutece.plugins.workflow.modules.ticketing.service.task.TaskEditTicket.java
/** * Process the task for user side// w w w . ja va2 s .c o m * @param nIdResourceHistory the ResourceHistory id * @param request the request * @param locale the locale * @param config the task configuration * @return the information message to store */ private String processUserTask(int nIdResourceHistory, HttpServletRequest request, Locale locale, TaskEditTicketConfig config) { String strTaskInformation = StringUtils.EMPTY; StringBuilder sbEntries = new StringBuilder(); String strUserMessage = request.getParameter(PARAMETER_USER_MESSAGE); // We get the ticket to modify Ticket ticket = getTicket(nIdResourceHistory); EditableTicket editableTicket = _editableTicketService.findByIdTicket(ticket.getId()); List<Entry> listEntriesToEdit = _editableTicketService.buildListEntriesToEdit(request, editableTicket.getListEditableTicketFields()); for (Entry entry : listEntriesToEdit) { Iterator<Response> iterator = ticket.getListResponse().iterator(); while (iterator.hasNext()) { Response response = iterator.next(); if (response.getEntry().getIdEntry() == entry.getIdEntry()) { iterator.remove(); } } _ticketFormService.getResponseEntry(request, entry.getIdEntry(), request.getLocale(), ticket); sbEntries.append(entry.getTitle()).append(SEPARATOR); } // remove and add generic attributes responses TicketHome.removeTicketResponse(ticket.getId()); if ((ticket.getListResponse() != null) && !ticket.getListResponse().isEmpty()) { for (Response response : ticket.getListResponse()) { ResponseHome.create(response); TicketHome.insertTicketResponse(ticket.getId(), response.getIdResponse()); } } if (sbEntries.length() != 0) { sbEntries.delete(sbEntries.length() - SEPARATOR.length(), sbEntries.length()); } ticket.setUserMessage(strUserMessage); TicketHome.update(ticket); editableTicket.setIsEdited(true); _editableTicketService.update(editableTicket); if (StringUtils.isEmpty(strUserMessage)) { strUserMessage = I18nService.getLocalizedString(MESSAGE_EDIT_TICKET_INFORMATION_NO_MESSAGE, Locale.FRENCH); } if (sbEntries.length() == 0) { strTaskInformation = MessageFormat.format(I18nService.getLocalizedString( MESSAGE_EDIT_TICKET_INFORMATION_VIEW_USER_NO_FIELD_EDITED, Locale.FRENCH), strUserMessage); } else { strTaskInformation = MessageFormat.format( I18nService.getLocalizedString(MESSAGE_EDIT_TICKET_INFORMATION_VIEW_USER, Locale.FRENCH), sbEntries.toString(), strUserMessage); } return strTaskInformation; }
From source file:com.doculibre.constellio.lucene.BaseLuceneIndexHelper.java
public String highlight(String strToHighlight, String fieldName, Query luceneQuery) { String highlightedText;/*from ww w . j a v a 2s .c o m*/ Analyzer analyzer = analyzerProvider.getAnalyzer(Locale.FRENCH); try { Directory directory = FSDirectory.open(indexDir); IndexReader indexReader = DirectoryReader.open(directory); Query rewrittenLuceneQuery = luceneQuery.rewrite(indexReader); QueryScorer luceneScorer = new QueryScorer(rewrittenLuceneQuery); SimpleHTMLFormatter luceneFormatter = new SimpleHTMLFormatter("<span class=\"hit\">", "</span>"); Highlighter luceneHighlighter = new Highlighter(luceneFormatter, luceneScorer); Fragmenter luceneFragmenter; // Si la chaine highlighter est sup 250 carac if (strToHighlight.length() > TAILLE_CHAINE_NON_FRAGMENTEE) { // Cration de best fragments de 100 carac chaque luceneFragmenter = new SimpleFragmenter(TAILLE_FRAGMENT); } else { // Toute la chaine est highlight luceneFragmenter = new SimpleFragmenter(Integer.MAX_VALUE); } luceneHighlighter.setTextFragmenter(luceneFragmenter); TokenStream luceneTokenStream = analyzer.tokenStream(fieldName, new StringReader(strToHighlight)); String fragment = null; if (strToHighlight.length() > TAILLE_CHAINE_NON_FRAGMENTEE) { fragment = luceneHighlighter.getBestFragments(luceneTokenStream, strToHighlight, NB_BEST_FRAGMENT, FRAGMENT_SEP); } else { fragment = luceneHighlighter.getBestFragment(luceneTokenStream, strToHighlight); } if (StringUtils.isBlank(fragment) && fieldName.equalsIgnoreCase("titre")) { fragment = strToHighlight; } indexReader.close(); directory.close(); highlightedText = fragment; } catch (IOException e) { throw new RuntimeException(e); } catch (InvalidTokenOffsetsException e) { throw new RuntimeException(e); } return highlightedText; }