Skip to content

Commit 678d1b4

Browse files
author
subhra74
committed
minor fixes
1 parent e472260 commit 678d1b4

14 files changed

Lines changed: 747 additions & 718 deletions

File tree

app/src/main/java/webshell/app/AppController.java

Lines changed: 317 additions & 312 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
1-
/**
2-
*
3-
*/
4-
package webshell.app.files;
5-
6-
import java.util.Map;
7-
import java.util.concurrent.ConcurrentHashMap;
8-
import java.util.concurrent.ExecutorService;
9-
import java.util.concurrent.Executors;
10-
import java.util.stream.Collectors;
11-
12-
import org.springframework.stereotype.Component;
13-
14-
import webshell.app.files.search.SearchResult;
15-
import webshell.app.files.search.SearchTask;
16-
17-
/**
18-
* @author subhro
19-
*
20-
*/
21-
@Component
22-
public class SearchOperations {
23-
private final Map<String, SearchTask> pendingOperations = new ConcurrentHashMap<>();
24-
private final ExecutorService threadPool = Executors.newFixedThreadPool(5);
25-
26-
public String createSearchTask(String folder, String searchText) {
27-
SearchTask task = new SearchTask(folder, searchText);
28-
pendingOperations.put(task.getId(), task);
29-
threadPool.submit(task);
30-
return task.getId();
31-
}
32-
33-
public SearchResult getSearchResult(String id, int fileIndex,
34-
int folderIndex) {
35-
SearchTask task = pendingOperations.get(id);
36-
SearchResult res = new SearchResult(task.isDone(),
37-
task.getFiles().stream().skip(fileIndex)
38-
.collect(Collectors.toList()),
39-
task.getFolders().stream().skip(folderIndex)
40-
.collect(Collectors.toList()));
41-
return res;
42-
}
43-
44-
public void cancelSearch(String id) {
45-
SearchTask task = pendingOperations.get(id);
46-
task.stop();
47-
}
48-
}
1+
/**
2+
*
3+
*/
4+
package webshell.app.files;
5+
6+
import java.util.Map;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
import java.util.concurrent.ExecutorService;
9+
import java.util.concurrent.Executors;
10+
import java.util.stream.Collectors;
11+
12+
import org.springframework.stereotype.Component;
13+
14+
import webshell.app.files.search.SearchResult;
15+
import webshell.app.files.search.SearchTask;
16+
17+
/**
18+
* @author subhro
19+
*
20+
*/
21+
@Component
22+
public class SearchOperations {
23+
private final Map<String, SearchTask> pendingOperations = new ConcurrentHashMap<>();
24+
private final ExecutorService threadPool = Executors.newFixedThreadPool(5);
25+
26+
public String createSearchTask(String folder, String searchText) {
27+
SearchTask task = new SearchTask(folder, searchText);
28+
pendingOperations.put(task.getId(), task);
29+
threadPool.submit(task);
30+
return task.getId();
31+
}
32+
33+
public SearchResult getSearchResult(String id, int fileIndex,
34+
int folderIndex) {
35+
SearchTask task = pendingOperations.get(id);
36+
SearchResult res = new SearchResult(task.isDone(), task.getFiles()
37+
.stream().skip(fileIndex).collect(Collectors.toList()));
38+
return res;
39+
}
40+
41+
public void cancelSearch(String id) {
42+
SearchTask task = pendingOperations.get(id);
43+
task.stop();
44+
}
45+
}
Lines changed: 57 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,57 @@
1-
/**
2-
*
3-
*/
4-
package webshell.app.files.search;
5-
6-
import java.util.ArrayList;
7-
import java.util.List;
8-
9-
/**
10-
* @author subhro
11-
*
12-
*/
13-
public class SearchResult {
14-
/**
15-
* @param isDone
16-
* @param files
17-
* @param folders
18-
*/
19-
public SearchResult(boolean isDone, List<String> files,
20-
List<String> folders) {
21-
super();
22-
this.isDone = isDone;
23-
this.files = files;
24-
this.folders = folders;
25-
}
26-
27-
private boolean isDone;
28-
private List<String> files = new ArrayList<>(), folders = new ArrayList<>();
29-
30-
/**
31-
* @return the isDone
32-
*/
33-
public boolean isDone() {
34-
return isDone;
35-
}
36-
37-
/**
38-
* @param isDone the isDone to set
39-
*/
40-
public void setDone(boolean isDone) {
41-
this.isDone = isDone;
42-
}
43-
44-
/**
45-
* @return the files
46-
*/
47-
public List<String> getFiles() {
48-
return files;
49-
}
50-
51-
/**
52-
* @param files the files to set
53-
*/
54-
public void setFiles(List<String> files) {
55-
this.files = files;
56-
}
57-
58-
/**
59-
* @return the folders
60-
*/
61-
public List<String> getFolders() {
62-
return folders;
63-
}
64-
65-
/**
66-
* @param folders the folders to set
67-
*/
68-
public void setFolders(List<String> folders) {
69-
this.folders = folders;
70-
}
71-
}
1+
/**
2+
*
3+
*/
4+
package webshell.app.files.search;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
import webshell.app.files.FileInfo;
10+
11+
/**
12+
* @author subhro
13+
*
14+
*/
15+
public class SearchResult {
16+
/**
17+
* @param isDone
18+
* @param files
19+
* @param folders
20+
*/
21+
public SearchResult(boolean isDone, List<FileInfo> files) {
22+
super();
23+
this.isDone = isDone;
24+
this.files = files;
25+
}
26+
27+
private boolean isDone;
28+
private List<FileInfo> files = new ArrayList<>();
29+
30+
/**
31+
* @return the isDone
32+
*/
33+
public boolean isDone() {
34+
return isDone;
35+
}
36+
37+
/**
38+
* @param isDone the isDone to set
39+
*/
40+
public void setDone(boolean isDone) {
41+
this.isDone = isDone;
42+
}
43+
44+
/**
45+
* @return the files
46+
*/
47+
public List<FileInfo> getFiles() {
48+
return files;
49+
}
50+
51+
/**
52+
* @param files the files to set
53+
*/
54+
public void setFiles(List<FileInfo> files) {
55+
this.files = files;
56+
}
57+
}

0 commit comments

Comments
 (0)