private static String generateUniqueIdentifierForKObject(final KObject kObject) { return kObject.getClusterId() + kObject.getKey(); }
@Override public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) { final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size()); for (final KObject kObject : kObjects) { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); final RefactoringPathPageRow row = new RefactoringPathPageRow(); row.setValue(path); result.add(row); } return result; } }
@Override public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) { final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size()); for (final KObject kObject : kObjects) { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); final RefactoringPathPageRow row = new RefactoringPathPageRow(); row.setValue(path); result.add(row); } return result; } }
@Override public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) { final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size()); for (final KObject kObject : kObjects) { String formId = findFormId(kObject.getProperties()); if (formId != null) { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); Map<String, Path> map = new HashMap<String, Path>(); map.put(formId, path); RefactoringMapPageRow row = new RefactoringMapPageRow(); row.setValue(map); result.add(row); } } return result; }
@Override public List<Path> fullTextSearch(final String _term, final Filter filter, final Path... roots) { final String term = checkNotNull("term", _term).trim(); if (term.isEmpty()) { return Collections.emptyList(); } final List<KObject> kObjects = searchIndex.fullTextSearch(term, filter, buildClusterSegments(roots)); return new ArrayList<Path>() {{ for (KObject kObject : kObjects) { add(ioService.get(URI.create(kObject.getKey()))); } }}; }
@Override public List<Path> fullTextSearch(final String _term, final Filter filter, final Path... roots) { final String term = checkNotNull("term", _term).trim(); if (term.isEmpty()) { return Collections.emptyList(); } final List<KObject> kObjects = searchIndex.fullTextSearch(term, filter, buildClusterSegments(roots)); return new ArrayList<Path>() {{ for (KObject kObject : kObjects) { add(ioService.get(URI.create(kObject.getKey()))); } }}; }
@Override public List<Path> searchByAttrs(final Map<String, ?> attrs, final Filter filter, final Path... roots) { final List<KObject> kObjects = searchIndex.searchByAttrs(attrs, filter, buildClusterSegments(roots)); return new ArrayList<Path>() {{ for (KObject kObject : kObjects) { add(ioService.get(URI.create(kObject.getKey()))); } }}; }
private Map<String, Map<String, String>> getRuleFlowGroupNamesNamesFromKObject(final KObject kObject) { final Map<String, Map<String, String>> ruleFlowGroupNames = new HashMap<String, Map<String, String>>(); if (kObject == null) { return ruleFlowGroupNames; } for (KProperty property : kObject.getProperties()) { if (property.getName().equals(SharedPartIndexTerm.TERM + ":" + PartType.RULEFLOW_GROUP.toString())) { if (ruleFlowGroupNames.containsKey(property.getValue().toString())) { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); ruleFlowGroupNames.get(property.getValue().toString()).put("name", property.getValue().toString()); ruleFlowGroupNames.get(property.getValue().toString()).put("filename", path.getFileName()); ruleFlowGroupNames.get(property.getValue().toString()).put("pathuri", path.toURI()); } else { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); ruleFlowGroupNames.put(property.getValue().toString(), new HashMap<String, String>()); ruleFlowGroupNames.get(property.getValue().toString()).put("name", property.getValue().toString()); ruleFlowGroupNames.get(property.getValue().toString()).put("filename", path.getFileName()); ruleFlowGroupNames.get(property.getValue().toString()).put("pathuri", path.toURI()); } } } return ruleFlowGroupNames; } }
@Override public List<Path> searchByAttrs(final Map<String, ?> attrs, final Filter filter, final Path... roots) { final List<KObject> kObjects = searchIndex.searchByAttrs(attrs, filter, buildClusterSegments(roots)); return new ArrayList<Path>() {{ for (KObject kObject : kObjects) { add(ioService.get(URI.create(kObject.getKey()))); } }}; }
@Override public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) { final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size()); for (final KObject kObject : kObjects) { for (KProperty property : kObject.getProperties()) { if (property.getName().equals(processIdResourceType.toString())) { String bpmnProcessId = (String) property.getValue(); final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); Map<String, Path> map = new HashMap<String, Path>(); map.put(bpmnProcessId, path); RefactoringMapPageRow row = new RefactoringMapPageRow(); row.setValue(map); result.add(row); } } } return result; } }
@Override public boolean equals(final Object obj) { if (obj == null) { return false; } if (!(obj instanceof KObject)) { return false; } final KObject kobj = (KObject) obj; return getClusterId().equals(kobj.getClusterId()) && getId().equals(kobj.getId()) && getKey().equals(kobj.getKey()) && getType().getName().equals(kobj.getType().getName()); }
@Override public boolean accept( final KObject kObject ) { final Path path = ioService.get( URI.create( kObject.getKey() ) ); final org.uberfire.backend.vfs.Path vfsPath = Paths.convert( path ); final KieProject project = projectService.resolveProject( vfsPath ); //All Users are granted access to Resources outside the Project structure boolean authorized = true; if ( project != null ) { authorized = authorizationManager.authorize( project, identity ); } if ( authorized ) { hitsTotalCount++; hitsStartIndex++; if ( hitsStartIndex >= startRow && hitsPageCount < pageSize ) { hitsPageCount++; return true; } } return false; }
protected void assertContains(final Iterable<KObject> results, final Path path) { for (KObject kObject : results) { final String key = kObject.getKey(); final String fileName = path.getFileName().toString(); if (key.endsWith(fileName)) { return; } } fail("Results do not contain expected Path '" + path.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() throws IOException, InterruptedException { setupCountDown(1); final Path path1 = getBasePath(this.getClass().getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(this.getClass().getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(5000); final String index = toKCluster(path1).getClusterId(); TermQuery query = new TermQuery(new Term("name", "value")); List<KObject> hits = config.getIndexProvider().findByQuery(Arrays.asList(index), query, 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() { setupCountDown(1); final Path path1 = getBasePath(this.getClass().getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(this.getClass().getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(5000); final String index = toKCluster(path1).getClusterId(); TermQuery query = new TermQuery(new Term("name", "value")); List<KObject> hits = config.getIndexProvider().findByQuery(Arrays.asList(index), query, 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() { setupCountDown(1); final Path path1 = getBasePath(this.getClass().getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(this.getClass().getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(5000); final String index = toKCluster(path1).getClusterId(); TermQuery query = new TermQuery(new Term("name", "value")); List<KObject> hits = config.getIndexProvider().findByQuery(Arrays.asList(index), query, 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() throws IOException, InterruptedException { setupCountDown(1); final Path path1 = getBasePath(this.getClass().getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(this.getClass().getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(5000); final String index = toKCluster(path1).getClusterId(); TermQuery query = new TermQuery(new Term("name", "value")); List<KObject> hits = config.getIndexProvider().findByQuery(Arrays.asList(index), query, 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() throws IOException, InterruptedException { setupCountDown(2); final Path path1 = getBasePath(getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(10000); List<String> indices = Arrays.asList(toKCluster(path1).getClusterId()); IndexProvider provider = this.config.getIndexProvider(); //Check the file has been indexed List<KObject> hits = provider.findByQuery(indices, new TermQuery(new Term("name", "value")), 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }
@Test public void testIndexedGitInternalDotFile() throws IOException, InterruptedException { setupCountDown(2); final Path path1 = getBasePath(getSimpleName()).resolve(".gitkeep"); ioService().write(path1, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); final Path path2 = getBasePath(getSimpleName()).resolve("afile"); ioService().write(path2, "ooooo!", Collections.<OpenOption>emptySet(), getFileAttributes()); waitForCountDown(10000); List<String> indices = Arrays.asList(toKCluster(path1).getClusterId()); IndexProvider provider = this.config.getIndexProvider(); //Check the file has been indexed List<KObject> hits = provider.findByQuery(indices, new TermQuery(new Term("name", "value")), 10); assertEquals(1, hits.size()); assertEquals(hits.get(0).getKey(), path2.toUri().toString()); }