@Test public void shouldReturnOneResultWhenOneDocInES() throws Exception { startSessionAs("john"); InitParams initParams = buildInitParams(); when(elasticSearchingClient.sendRequest(anyString(), anyString(), anyString())).thenReturn(ES_RESPONSE_ONE_DOC); FileSearchServiceConnector fileSearchServiceConnector = new FileSearchServiceConnector(initParams, elasticSearchingClient, repositoryService, documentService); Collection<SearchResult> searchResults = fileSearchServiceConnector.search(new SearchContext(new Router(new ControllerDescriptor()), "site"), "", null, 0, -1, "", ""); assertNotNull(searchResults); assertEquals(1, searchResults.size()); SearchResult searchResult = searchResults.iterator().next(); assertEquals("exo-documentation.pdf", searchResult.getTitle()); assertEquals("exo-tag-doc-john", ((EcmsSearchResult) searchResult).getTags().get(0)); assertEquals(1505312333066L, searchResult.getDate()); assertEquals("/rest/thumbnailImage/medium/repository/collaboration/sites/intranet/documents/exo-documentation.pdf", searchResult.getImageUrl()); }
protected String getImageUrl(String workspace, String nodePath) { try { String path = nodePath.replaceAll("'", "\\\\'"); String encodedPath = URLEncoder.encode(path, "utf-8"); encodedPath = encodedPath.replaceAll ("%2F", "/"); String restContextName = WCMCoreUtils.getRestContextName(); String repositoryName = null; try { repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); } catch (RepositoryException e) { LOG.error("Cannot get repository name", e); } String thumbnailImage = "/" + restContextName + "/thumbnailImage/medium/" + repositoryName + "/" + workspace + encodedPath; return thumbnailImage; } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode path " + nodePath, e); return ""; } }
FileSearchServiceConnector extends ElasticSearchServiceConnector { protected String getImageUrl(String workspace, String nodePath) { try { String path = nodePath.replaceAll("'", "\\\\'"); String encodedPath = URLEncoder.encode(path, "utf-8"); encodedPath = encodedPath.replaceAll ("%2F", "/"); String restContextName = WCMCoreUtils.getRestContextName(); String repositoryName = null; try { repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); } catch (RepositoryException e) { LOG.error("Cannot get repository name", e); } String thumbnailImage = "/" + restContextName + "/thumbnailImage/medium/" + repositoryName + "/" + workspace + encodedPath; return thumbnailImage; } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode path " + nodePath, e); return ""; } } }
FileSearchServiceConnector extends ElasticSearchServiceConnector { protected String getImageUrl(String workspace, String nodePath) { try { String path = nodePath.replaceAll("'", "\\\\'"); String encodedPath = URLEncoder.encode(path, "utf-8"); encodedPath = encodedPath.replaceAll ("%2F", "/"); String restContextName = WCMCoreUtils.getRestContextName(); String repositoryName = null; try { repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); } catch (RepositoryException e) { LOG.error("Cannot get repository name", e); } String thumbnailImage = "/" + restContextName + "/thumbnailImage/medium/" + repositoryName + "/" + workspace + encodedPath; return thumbnailImage; } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode path " + nodePath, e); return ""; } } FileSearchServiceConnector(InitParams initParams, ElasticSearchingClient client, RepositoryService repositoryService, DocumentService documentService); }
FileSearchServiceConnector extends ElasticSearchServiceConnector { protected String getImageUrl(String workspace, String nodePath) { try { String path = nodePath.replaceAll("'", "\\\\'"); String encodedPath = URLEncoder.encode(path, "utf-8"); encodedPath = encodedPath.replaceAll ("%2F", "/"); String restContextName = WCMCoreUtils.getRestContextName(); String repositoryName = null; try { repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); } catch (RepositoryException e) { LOG.error("Cannot get repository name", e); } String thumbnailImage = "/" + restContextName + "/thumbnailImage/medium/" + repositoryName + "/" + workspace + encodedPath; return thumbnailImage; } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode path " + nodePath, e); return ""; } } FileSearchServiceConnector(InitParams initParams, ElasticSearchingClient client, RepositoryService repositoryService, DocumentService documentService);  }
FileSearchServiceConnector extends ElasticSearchServiceConnector { protected String getImageUrl(String workspace, String nodePath) { try { String path = nodePath.replaceAll("'", "\\\\'"); String encodedPath = URLEncoder.encode(path, "utf-8"); encodedPath = encodedPath.replaceAll ("%2F", "/"); String restContextName = WCMCoreUtils.getRestContextName(); String repositoryName = null; try { repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); } catch (RepositoryException e) { LOG.error("Cannot get repository name", e); } String thumbnailImage = "/" + restContextName + "/thumbnailImage/medium/" + repositoryName + "/" + workspace + encodedPath; return thumbnailImage; } catch (UnsupportedEncodingException e) { LOG.error("Cannot encode path " + nodePath, e); return ""; } } FileSearchServiceConnector(InitParams initParams, ElasticSearchingClient client, RepositoryService repositoryService, DocumentService documentService);   }