From ac7f4d19f6774da7d3dca35f4c48ec8211ce9f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 4 Feb 2021 17:00:49 +0800 Subject: [PATCH 01/29] fix delete repository error --- .../java/com/gitee/kooder/index/IndexManager.java | 3 ++- .../com/gitee/kooder/indexer/FetchTaskThread.java | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/index/IndexManager.java b/core/src/main/java/com/gitee/kooder/index/IndexManager.java index 7acd051..065ddb4 100644 --- a/core/src/main/java/com/gitee/kooder/index/IndexManager.java +++ b/core/src/main/java/com/gitee/kooder/index/IndexManager.java @@ -4,6 +4,7 @@ import com.gitee.kooder.core.Constants; import com.gitee.kooder.queue.QueueTask; import com.gitee.kooder.storage.StorageFactory; import org.apache.lucene.document.Document; +import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.facet.*; import org.apache.lucene.facet.taxonomy.*; import org.apache.lucene.index.*; @@ -123,7 +124,7 @@ public class IndexManager { * @throws IOException */ public static long deleteById(List docs, IndexWriter i_writer) throws IOException { - Query[] queries = docs.stream().map(id -> new TermQuery(new Term(FIELD_ID, String.valueOf(id)))).toArray(Query[]::new); + Query[] queries = docs.stream().map(id -> NumericDocValuesField.newSlowExactQuery(FIELD_ID, id)).toArray(Query[]::new); return i_writer.deleteDocuments(queries); } diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java index 24597e8..eaa3fb5 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java @@ -1,9 +1,11 @@ package com.gitee.kooder.indexer; import com.gitee.kooder.code.*; +import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.Searchable; +import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.queue.QueueFactory; import com.gitee.kooder.queue.QueueProvider; import com.gitee.kooder.queue.QueueTask; @@ -11,8 +13,10 @@ import com.gitee.kooder.storage.StorageFactory; import com.gitee.kooder.utils.BatchTaskRunner; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; +import org.apache.lucene.document.LongPoint; import org.apache.lucene.facet.taxonomy.TaxonomyWriter; import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.search.Query; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -135,8 +139,15 @@ public class FetchTaskThread extends Thread { for(Searchable obj : task.getObjects()) { CodeRepository repo = RepositoryManager.INSTANCE.get(obj.getId()); if (repo != null) { - RepositoryFactory.getProvider(repo.getScm()).delete(repo); - RepositoryManager.INSTANCE.delete(repo.getId()); + + Query query = LongPoint.newExactQuery(Constants.FIELD_REPO_ID, repo.getId()); + try { + writer.deleteDocuments(query); // Delete SourceCode indexes + RepositoryFactory.getProvider(repo.getScm()).delete(repo); // Delete temp project git directory + RepositoryManager.INSTANCE.delete(repo.getId()); // Delete project metadata + } catch (IOException e) { + log.warn("Failed to delete code-repository id = " + repo.getId(), e); + } } } } -- Gitee From fbf7d2ab692c972010309d4814b2ee78ec7532da Mon Sep 17 00:00:00 2001 From: silverballer Date: Thu, 4 Feb 2021 17:56:33 +0800 Subject: [PATCH 02/29] =?UTF-8?q?style:=20add=20code=20comment=E3=80=81cod?= =?UTF-8?q?e=20package=20move=20feat:=20fix=20gitee=20repo=20event=20code?= =?UTF-8?q?=20index=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{models => }/gitee/EnterpriseHook.java | 2 +- .../gitee/kooder/{api => gitee}/GiteeApi.java | 82 +++++++++++++++++-- .../{exception => gitee}/GiteeException.java | 2 +- .../kooder/{models => }/gitee/Issue.java | 2 +- .../{models => }/gitee/IssueWebHook.java | 2 +- .../{models => }/gitee/RepoWebHook.java | 2 +- .../kooder/{models => }/gitee/Repository.java | 12 ++- .../gitee/kooder/{models => }/gitee/User.java | 2 +- .../java/com/gitee/kooder/models/Issue.java | 6 +- .../com/gitee/kooder/models/Repository.java | 4 +- .../com/gitee/kooder/utils/HttpUtils.java | 18 ++++ .../com/gitee/kooder/action/GiteeAction.java | 2 +- .../kooder/server/GiteeWebHookManager.java | 23 ++++-- .../kooder/indexer/GiteeIndexThread.java | 44 +++++++--- 14 files changed, 162 insertions(+), 41 deletions(-) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/EnterpriseHook.java (84%) rename core/src/main/java/com/gitee/kooder/{api => gitee}/GiteeApi.java (81%) rename core/src/main/java/com/gitee/kooder/{exception => gitee}/GiteeException.java (83%) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/Issue.java (98%) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/IssueWebHook.java (91%) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/RepoWebHook.java (93%) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/Repository.java (93%) rename core/src/main/java/com/gitee/kooder/{models => }/gitee/User.java (93%) diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/EnterpriseHook.java b/core/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java similarity index 84% rename from core/src/main/java/com/gitee/kooder/models/gitee/EnterpriseHook.java rename to core/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java index babd424..2c80af3 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/EnterpriseHook.java +++ b/core/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; /** * @author zhanggx diff --git a/core/src/main/java/com/gitee/kooder/api/GiteeApi.java b/core/src/main/java/com/gitee/kooder/gitee/GiteeApi.java similarity index 81% rename from core/src/main/java/com/gitee/kooder/api/GiteeApi.java rename to core/src/main/java/com/gitee/kooder/gitee/GiteeApi.java index defe909..e70395f 100644 --- a/core/src/main/java/com/gitee/kooder/api/GiteeApi.java +++ b/core/src/main/java/com/gitee/kooder/gitee/GiteeApi.java @@ -1,11 +1,7 @@ -package com.gitee.kooder.api; +package com.gitee.kooder.gitee; import com.fasterxml.jackson.core.type.TypeReference; import com.gitee.kooder.core.GiteeSearchConfig; -import com.gitee.kooder.exception.GiteeException; -import com.gitee.kooder.models.gitee.EnterpriseHook; -import com.gitee.kooder.models.gitee.Issue; -import com.gitee.kooder.models.gitee.Repository; import com.gitee.kooder.utils.HttpUtils; import com.gitee.kooder.utils.JsonUtils; import okhttp3.Response; @@ -15,6 +11,8 @@ import org.slf4j.LoggerFactory; import java.util.*; /** + * gitee open api + * * @author zhanggx */ public class GiteeApi { @@ -26,18 +24,37 @@ public class GiteeApi { private static final String URL_GET_REPOS = "/api/v5/enterprises/enterprise/repos"; private static final String URL_GET_ISSUES = "/api/v5/enterprises/enterprise/issues"; + /** + * gitee server url + */ public final String giteeUrl; - private final String presonalAccessToken; + /** + * personal access token + */ + private final String personalAccessToken; private GiteeApi() { giteeUrl = GiteeSearchConfig.getProperty("gitee.url"); - presonalAccessToken = GiteeSearchConfig.getProperty("gitee.personal_access_token"); + personalAccessToken = GiteeSearchConfig.getProperty("gitee.personal_access_token"); } public static GiteeApi getInstance() { return Singleton.INSTANCE; } + /** + * create enterprise hook + * + * @param url enterprise hook url + * @param secretToken enterprise hook password + * @param pushEvents notice push event + * @param repoEvents notice repo event + * @param tagPushEvents notice tag push event + * @param issuesEvents notice issue event + * @param noteEvents notice note event + * @param mergeRequestsEvents notice merge request event + * @throws GiteeException request gitee server error + */ public void createEnterpriseHooks(String url, String secretToken, boolean pushEvents, @@ -65,6 +82,12 @@ public class GiteeApi { } } + /** + * get all enterprise hook + * + * @return all enterprise hook + * @throws GiteeException + */ public List getEnterpriseHooks() throws GiteeException { int pageNo = 1, pageSize = 50; List res = new ArrayList<>(); @@ -75,6 +98,14 @@ public class GiteeApi { return res; } + /** + * paging get enterprise hook + * + * @param pageNo + * @param pageSize + * @return + * @throws GiteeException + */ private List getEnterpriseHooks(int pageNo, int pageSize) throws GiteeException { Map requestParamsMap = getRequestParamsMap(); requestParamsMap.put("page", String.valueOf(pageNo)); @@ -94,6 +125,13 @@ public class GiteeApi { } } + /** + * get all repo + * + * @param afterId + * @return + * @throws GiteeException + */ public List getRepos(int afterId) throws GiteeException { int pageNo = 1, pageSize = 50; List res = new ArrayList<>(); @@ -109,6 +147,14 @@ public class GiteeApi { return res; } + /** + * paging get repo + * + * @param pageNo + * @param pageSize + * @return + * @throws GiteeException + */ private List getRepos(int pageNo, int pageSize) throws GiteeException { Map requestParamsMap = getRequestParamsMap(); requestParamsMap.put("type", "all"); @@ -130,6 +176,13 @@ public class GiteeApi { } } + /** + * get all issue + * + * @param afterId + * @return + * @throws GiteeException + */ public List getIssues(int afterId) throws GiteeException { int pageNo = 1, pageSize = 50; List res = new ArrayList<>(); @@ -145,6 +198,14 @@ public class GiteeApi { return res; } + /** + * paging get issue + * + * @param pageNo + * @param pageSize + * @return + * @throws GiteeException + */ private List getIssues(int pageNo, int pageSize) throws GiteeException { Map requestParamsMap = getRequestParamsMap(); requestParamsMap.put("state", "all"); @@ -166,9 +227,14 @@ public class GiteeApi { } } + /** + * get request params map with personal access token + * + * @return + */ private Map getRequestParamsMap() { Map map = new HashMap<>(); - map.put("access_token", presonalAccessToken); + map.put("access_token", personalAccessToken); return map; } diff --git a/core/src/main/java/com/gitee/kooder/exception/GiteeException.java b/core/src/main/java/com/gitee/kooder/gitee/GiteeException.java similarity index 83% rename from core/src/main/java/com/gitee/kooder/exception/GiteeException.java rename to core/src/main/java/com/gitee/kooder/gitee/GiteeException.java index 252a308..e236a94 100644 --- a/core/src/main/java/com/gitee/kooder/exception/GiteeException.java +++ b/core/src/main/java/com/gitee/kooder/gitee/GiteeException.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.exception; +package com.gitee.kooder.gitee; /** * Gitee related exception diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/Issue.java b/core/src/main/java/com/gitee/kooder/gitee/Issue.java similarity index 98% rename from core/src/main/java/com/gitee/kooder/models/gitee/Issue.java rename to core/src/main/java/com/gitee/kooder/gitee/Issue.java index 7d34d07..e4c9b09 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/Issue.java +++ b/core/src/main/java/com/gitee/kooder/gitee/Issue.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/IssueWebHook.java b/core/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java similarity index 91% rename from core/src/main/java/com/gitee/kooder/models/gitee/IssueWebHook.java rename to core/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java index e784439..127e653 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/IssueWebHook.java +++ b/core/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; /** * @author zhanggx diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/RepoWebHook.java b/core/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java similarity index 93% rename from core/src/main/java/com/gitee/kooder/models/gitee/RepoWebHook.java rename to core/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java index 2f00216..32c9928 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/RepoWebHook.java +++ b/core/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; /** * @author zhanggx diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/Repository.java b/core/src/main/java/com/gitee/kooder/gitee/Repository.java similarity index 93% rename from core/src/main/java/com/gitee/kooder/models/gitee/Repository.java rename to core/src/main/java/com/gitee/kooder/gitee/Repository.java index b7930b3..256d865 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/Repository.java +++ b/core/src/main/java/com/gitee/kooder/gitee/Repository.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; @@ -18,6 +18,8 @@ public class Repository { private String htmlUrl; + private String gitHttpUrl; + private String description; /** @@ -86,6 +88,14 @@ public class Repository { this.htmlUrl = htmlUrl; } + public String getGitHttpUrl() { + return gitHttpUrl; + } + + public void setGitHttpUrl(String gitHttpUrl) { + this.gitHttpUrl = gitHttpUrl; + } + public String getDescription() { return description; } diff --git a/core/src/main/java/com/gitee/kooder/models/gitee/User.java b/core/src/main/java/com/gitee/kooder/gitee/User.java similarity index 93% rename from core/src/main/java/com/gitee/kooder/models/gitee/User.java rename to core/src/main/java/com/gitee/kooder/gitee/User.java index 3373064..b718808 100644 --- a/core/src/main/java/com/gitee/kooder/models/gitee/User.java +++ b/core/src/main/java/com/gitee/kooder/gitee/User.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models.gitee; +package com.gitee.kooder.gitee; /** * @author zhanggx diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index 5dadcfe..71714be 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -79,7 +79,7 @@ public final class Issue extends Searchable { setDocument(doc); } - public Issue(com.gitee.kooder.models.gitee.Issue issue) { + public Issue(com.gitee.kooder.gitee.Issue issue) { this.id = issue.getId(); this.ident = issue.getRepository().getId() + "_" + this.id; this.enterprise = Relation.EMPTY; @@ -92,8 +92,8 @@ public final class Issue extends Searchable { this.labels = new ArrayList<>(issue.getLabels()); this.createdAt = issue.getCreatedAt().getTime(); this.updatedAt = issue.getUpdatedAt().getTime(); - this.state = com.gitee.kooder.models.gitee.Issue.STATE_OPEN.equals(issue.getState()) - || com.gitee.kooder.models.gitee.Issue.STATE_PROGRESSING.equals(issue.getState()) ? STATE_OPENED : STATE_CLOSED; + this.state = com.gitee.kooder.gitee.Issue.STATE_OPEN.equals(issue.getState()) + || com.gitee.kooder.gitee.Issue.STATE_PROGRESSING.equals(issue.getState()) ? STATE_OPENED : STATE_CLOSED; } /** diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index 8fbba9e..2a8aab0 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -69,11 +69,11 @@ public final class Repository extends Searchable { this.setBlock(Constants.REPO_BLOCK_NO); } - public Repository(com.gitee.kooder.models.gitee.Repository repository) { + public Repository(com.gitee.kooder.gitee.Repository repository) { this.id = repository.getId(); this.name = repository.getName(); this.description = repository.getDescription(); - this.url = repository.getHtmlUrl(); + this.url = repository.getGitHttpUrl() == null ? repository.getHtmlUrl() : repository.getGitHttpUrl(); this.enterprise = Relation.EMPTY; this.project = Relation.EMPTY; this.owner = new Relation(repository.getOwner().getId(), repository.getOwner().getName(), repository.getOwner().getHtmlUrl()); diff --git a/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java b/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java index 7c34c53..53b215b 100644 --- a/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java +++ b/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java @@ -7,6 +7,8 @@ import java.util.Map; import java.util.Objects; /** + * http util by okhttp3 + * * @author zhanggx */ public class HttpUtils { @@ -22,11 +24,27 @@ public class HttpUtils { CLIENT = new OkHttpClient(); } + /** + * http get + * + * @param url + * @param params + * @return + * @throws IOException + */ public static Response get(String url, Map params) throws IOException { Request request = getRequestBuilder(url, params).build(); return getResponse(request); } + /** + * http post application/json + * + * @param url + * @param params + * @return + * @throws IOException + */ public static Response postJson(String url, Map params) throws IOException { Request request = getRequestBuilder(url) .post(RequestBody.create(JsonUtils.toJson(params), APPLICATION_JSON_UTF8)) diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java index c8c3d65..151e78e 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java @@ -2,7 +2,7 @@ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; -import com.gitee.kooder.exception.GiteeException; +import com.gitee.kooder.gitee.GiteeException; import com.gitee.kooder.server.Action; import com.gitee.kooder.server.GiteeWebHookManager; import io.vertx.ext.web.RoutingContext; diff --git a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java index 6e3df18..8068919 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java @@ -1,18 +1,16 @@ package com.gitee.kooder.server; import com.gitee.kooder.core.Constants; -import com.gitee.kooder.exception.GiteeException; +import com.gitee.kooder.gitee.GiteeException; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.GiteeWebHookEvent; import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; -import com.gitee.kooder.models.gitee.IssueWebHook; -import com.gitee.kooder.models.gitee.RepoWebHook; +import com.gitee.kooder.gitee.IssueWebHook; +import com.gitee.kooder.gitee.RepoWebHook; import com.gitee.kooder.queue.QueueTask; import com.gitee.kooder.utils.JsonUtils; import io.vertx.ext.web.RoutingContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Objects; import java.util.Optional; @@ -22,8 +20,13 @@ import java.util.Optional; */ public class GiteeWebHookManager { - private final static Logger log = LoggerFactory.getLogger(GiteeWebHookManager.class); - + /** + * handle gitee web hook + * + * @param secretToken + * @param context + * @throws GiteeException + */ public static void handleEvent(String secretToken, RoutingContext context) throws GiteeException { checkSecretToken(secretToken, context); GiteeWebHookEvent giteeWebHookEvent = parseGiteeWebHookEvent(context); @@ -36,18 +39,20 @@ public class GiteeWebHookManager { } if (RepoWebHook.ACTION_CREATE.equals(repoWebHook.getAction())) { + // index repository data Repository repository = new Repository(repoWebHook.getRepository()); QueueTask.add(Constants.TYPE_REPOSITORY, repository); - + // index code data CodeRepository coder = new CodeRepository(repository); coder.setScm(CodeRepository.SCM_GIT); QueueTask.add(Constants.TYPE_CODE, coder); } else if (RepoWebHook.ACTION_DESTROY.equals(repoWebHook.getAction())) { + // delete code data CodeRepository codeRepository = new CodeRepository(); codeRepository.setId(repoWebHook.getRepository().getId()); QueueTask.delete(Constants.TYPE_CODE, codeRepository); - + // delete repository data Repository repository = new Repository(); repository.setId(repoWebHook.getRepository().getId()); QueueTask.delete(Constants.TYPE_REPOSITORY, repository); diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java index 6394d54..4550723 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java @@ -1,13 +1,13 @@ package com.gitee.kooder.indexer; -import com.gitee.kooder.api.GiteeApi; +import com.gitee.kooder.gitee.GiteeApi; import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; -import com.gitee.kooder.exception.GiteeException; +import com.gitee.kooder.gitee.GiteeException; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; -import com.gitee.kooder.models.gitee.EnterpriseHook; +import com.gitee.kooder.gitee.EnterpriseHook; import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.queue.QueueTask; import org.slf4j.Logger; @@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory; import java.util.List; /** - * TODO Check and Index all of Gitee data for first time + * Check and Index all of Gitee data for first time * * @author Winter Lau */ @@ -24,10 +24,17 @@ public class GiteeIndexThread extends Thread { private final static Logger log = LoggerFactory.getLogger("[gitee]"); - private final static int itemsPerPage = 20; - + /** + * local address + */ private String gsearchUrl; + /** + * web hook url + */ private String systemHookUrl; + /** + * web hook password + */ private String secretToken; public static void main(String[] args) { @@ -53,6 +60,11 @@ public class GiteeIndexThread extends Thread { } } + /** + * check and install enterprise hook + * + * @throws GiteeException install enterprise hook error + */ private void checkAndInstallEnterpriseHook() throws GiteeException { List enterpriseHookList = GiteeApi.getInstance().getEnterpriseHooks(); for (EnterpriseHook enterpriseHook : enterpriseHookList) { @@ -61,17 +73,22 @@ public class GiteeIndexThread extends Thread { } } GiteeApi.getInstance().createEnterpriseHooks(systemHookUrl, secretToken, true, true, false, true, false, false); - log.info("Gitlab system hook : {} installed.", systemHookUrl); + log.info("Gitee enterprise hook : {} installed.", systemHookUrl); } + /** + * check and index projects data + * + * @throws GiteeException get projects data error + */ private void checkAndIndexProjects() throws GiteeException { long ct = System.currentTimeMillis(); int pc = 0; Repository lastRepository = (Repository) QueryFactory.REPO().getLastestObject(); int maxId = lastRepository == null ? 0 : Math.toIntExact(lastRepository.getId()); - List repositoryList = GiteeApi.getInstance().getRepos(maxId); - for (com.gitee.kooder.models.gitee.Repository repository : repositoryList) { + List repositoryList = GiteeApi.getInstance().getRepos(maxId); + for (com.gitee.kooder.gitee.Repository repository : repositoryList) { Repository repo = new Repository(repository); QueueTask.add(Constants.TYPE_REPOSITORY, repo); CodeRepository codes = new CodeRepository(); @@ -86,14 +103,19 @@ public class GiteeIndexThread extends Thread { log.info("{} repositories indexed (with id > {}), using {} ms", pc, maxId, System.currentTimeMillis() - ct); } + /** + * check and index issues data + * + * @throws GiteeException get issues data error + */ private void checkAndIndexIssues() throws GiteeException { long ct = System.currentTimeMillis(); int pc = 0; Issue lastIssue = (Issue) QueryFactory.ISSUE().getLastestObject(); int maxId = lastIssue == null ? 0 : Math.toIntExact(lastIssue.getId()); - List issueList = GiteeApi.getInstance().getIssues(maxId); - for (com.gitee.kooder.models.gitee.Issue issue : issueList) { + List issueList = GiteeApi.getInstance().getIssues(maxId); + for (com.gitee.kooder.gitee.Issue issue : issueList) { QueueTask.add(Constants.TYPE_ISSUE, new Issue(issue)); pc++; } -- Gitee From ae734309c877fdef07c49e84093e78e125a4a9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 4 Feb 2021 18:46:42 +0800 Subject: [PATCH 03/29] delete repository and it's related issues and codes --- .../com/gitee/kooder/index/IndexManager.java | 42 +++++++++++++------ .../com/gitee/kooder/action/GitlabAction.java | 5 --- .../kooder/server/GiteeWebHookManager.java | 6 +-- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/index/IndexManager.java b/core/src/main/java/com/gitee/kooder/index/IndexManager.java index 065ddb4..126cdc0 100644 --- a/core/src/main/java/com/gitee/kooder/index/IndexManager.java +++ b/core/src/main/java/com/gitee/kooder/index/IndexManager.java @@ -1,9 +1,12 @@ package com.gitee.kooder.index; import com.gitee.kooder.core.Constants; +import com.gitee.kooder.models.Repository; +import com.gitee.kooder.models.Searchable; import com.gitee.kooder.queue.QueueTask; import com.gitee.kooder.storage.StorageFactory; import org.apache.lucene.document.Document; +import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.facet.*; import org.apache.lucene.facet.taxonomy.*; @@ -15,6 +18,7 @@ import org.slf4j.LoggerFactory; import static com.gitee.kooder.core.Constants.FIELD_ID; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -72,7 +76,31 @@ public class IndexManager { update(docs, i_writer, t_writer); break; case QueueTask.ACTION_DELETE: - deleteById(task.getObjects().stream().map(o -> o.getId()).collect(Collectors.toList()), i_writer); + List objects = task.getObjects().stream().map(o -> o.getId()).collect(Collectors.toList()); + Query[] queries = objects.stream().map(id -> NumericDocValuesField.newSlowExactQuery(FIELD_ID, id)).toArray(Query[]::new); + i_writer.deleteDocuments(queries); + List repos = new ArrayList<>(); + for(Searchable obj : task.getObjects()) { + if(obj instanceof Repository) { + repos.add(obj.getId()); + } + } + log.info("Documents['{}'] {} deleted.", task.getType(), objects); + // Delete repository need to delete it's related issues and codes + if(repos.size() > 0) { + // Delete issues of this repository + try (IndexWriter issues = StorageFactory.getIndexWriter(Constants.TYPE_ISSUE)) { + Query[] i_querys = repos.stream().map(id -> LongPoint.newExactQuery(Constants.FIELD_REPO_ID, id)).toArray(Query[]::new); + issues.deleteDocuments(i_querys); + log.info("Issues of repositories : {} deleted.", repos); + } + // Delete code repositories + try (IndexWriter codes = StorageFactory.getIndexWriter(Constants.TYPE_CODE)) { + Query[] i_querys = repos.stream().map(id -> LongPoint.newExactQuery(Constants.FIELD_REPO_ID, id)).toArray(Query[]::new); + codes.deleteDocuments(i_querys); + log.info("Codes of repositories : {} deleted.", repos); + } + } } return task.getObjects().size(); } @@ -116,18 +144,6 @@ public class IndexManager { return docs.size(); } - /** - * 删除文档 - * @param docs - * @param i_writer - * @return - * @throws IOException - */ - public static long deleteById(List docs, IndexWriter i_writer) throws IOException { - Query[] queries = docs.stream().map(id -> NumericDocValuesField.newSlowExactQuery(FIELD_ID, id)).toArray(Query[]::new); - return i_writer.deleteDocuments(queries); - } - /** * 将普通 document 转成 facet 文档 * @param taxonomyWriter diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java index 50b8045..264dd41 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java @@ -55,11 +55,6 @@ public class GitlabAction implements Action { } break; case GitlabProjectEvent.E_PROJECT_DESTROY: - //delete all source codes of this repository - CodeRepository coder = new CodeRepository(); - coder.setId(event.getProjectId()); - QueueTask.delete(Constants.TYPE_CODE, coder); - //delete repository Repository repo = new Repository(); repo.setId(event.getProjectId()); QueueTask.delete(Constants.TYPE_REPOSITORY, repo); diff --git a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java index 8068919..57c0ab8 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java @@ -48,10 +48,6 @@ public class GiteeWebHookManager { QueueTask.add(Constants.TYPE_CODE, coder); } else if (RepoWebHook.ACTION_DESTROY.equals(repoWebHook.getAction())) { - // delete code data - CodeRepository codeRepository = new CodeRepository(); - codeRepository.setId(repoWebHook.getRepository().getId()); - QueueTask.delete(Constants.TYPE_CODE, codeRepository); // delete repository data Repository repository = new Repository(); repository.setId(repoWebHook.getRepository().getId()); @@ -109,7 +105,7 @@ public class GiteeWebHookManager { private static GiteeWebHookEvent parseGiteeWebHookEvent(RoutingContext context) throws GiteeException { String event = context.request().getHeader("X-Gitee-Event"); if (event == null) { - throw new GiteeException("X-Gitlab-Event header is missing!"); + throw new GiteeException("X-Gitee-Event header is missing!"); } else { GiteeWebHookEvent giteeWebHookEvent = GiteeWebHookEvent.getEvent(event); if (Objects.nonNull(giteeWebHookEvent)) { -- Gitee From 83910d0a76379f25b8f8641f7e206a66ba7b303a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 4 Feb 2021 21:55:19 +0800 Subject: [PATCH 04/29] adjust hook package --- gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java | 3 +-- .../gitee/kooder/{server => action}/GiteeWebHookManager.java | 2 +- .../src/main/java/com/gitee/kooder/action/GitlabAction.java | 2 -- .../kooder/{server => action}/GitlabSystemHookManager.java | 2 +- .../gitee/kooder/{server => action}/GitlabWebhookManager.java | 2 +- 5 files changed, 4 insertions(+), 7 deletions(-) rename gateway/src/main/java/com/gitee/kooder/{server => action}/GiteeWebHookManager.java (99%) rename gateway/src/main/java/com/gitee/kooder/{server => action}/GitlabSystemHookManager.java (99%) rename gateway/src/main/java/com/gitee/kooder/{server => action}/GitlabWebhookManager.java (99%) diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java index 151e78e..4b2658c 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java @@ -4,7 +4,6 @@ import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.gitee.GiteeException; import com.gitee.kooder.server.Action; -import com.gitee.kooder.server.GiteeWebHookManager; import io.vertx.ext.web.RoutingContext; /** @@ -15,7 +14,7 @@ import io.vertx.ext.web.RoutingContext; */ public class GiteeAction implements Action { - private static final String SECRET_TOKEN = GiteeSearchConfig.getProperty("gitlab.secret_token", Constants.DEFAULT_SECRET_TOKEN); + String SECRET_TOKEN = GiteeSearchConfig.getProperty("gitee.secret_token", Constants.DEFAULT_SECRET_TOKEN); /** * Gitee webhook handler diff --git a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java similarity index 99% rename from gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java rename to gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index 57c0ab8..4275de2 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.server; +package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; import com.gitee.kooder.gitee.GiteeException; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java index 264dd41..3ae55b0 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java @@ -9,8 +9,6 @@ import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; import com.gitee.kooder.queue.QueueTask; import com.gitee.kooder.server.Action; -import com.gitee.kooder.server.GitlabSystemHookManager; -import com.gitee.kooder.server.GitlabWebhookManager; import io.vertx.ext.web.RoutingContext; import org.gitlab4j.api.GitLabApiException; import org.gitlab4j.api.models.Project; diff --git a/gateway/src/main/java/com/gitee/kooder/server/GitlabSystemHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java similarity index 99% rename from gateway/src/main/java/com/gitee/kooder/server/GitlabSystemHookManager.java rename to gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java index a185b53..e4b7f34 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GitlabSystemHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.server; +package com.gitee.kooder.action; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; diff --git a/gateway/src/main/java/com/gitee/kooder/server/GitlabWebhookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java similarity index 99% rename from gateway/src/main/java/com/gitee/kooder/server/GitlabWebhookManager.java rename to gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java index 502fd2f..e9f3a6a 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GitlabWebhookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.server; +package com.gitee.kooder.action; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; -- Gitee From 573f083ab03614042e24afd8988424995235196e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 4 Feb 2021 21:58:57 +0800 Subject: [PATCH 05/29] remove public modifier --- .../main/java/com/gitee/kooder/action/GiteeWebHookManager.java | 2 +- .../java/com/gitee/kooder/action/GitlabSystemHookManager.java | 2 +- .../java/com/gitee/kooder/action/GitlabWebhookManager.java | 2 +- .../main/java/com/gitee/kooder/action/SearchActionBase.java | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index 4275de2..c5d332b 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -18,7 +18,7 @@ import java.util.Optional; /** * @author zhanggx */ -public class GiteeWebHookManager { +class GiteeWebHookManager { /** * handle gitee web hook diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java index e4b7f34..fad444a 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java @@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory; * This class provides a handler for processing GitLab System Hook callouts. * @author Winter Lau */ -public class GitlabSystemHookManager { +class GitlabSystemHookManager { private final static Logger log = LoggerFactory.getLogger(GitlabSystemHookManager.class); diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java index e9f3a6a..e6fdf49 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java @@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory; * This class provides a handler for processing GitLab Web Hook callouts. * @author Winter Lau */ -public class GitlabWebhookManager { +class GitlabWebhookManager { private final static org.slf4j.Logger log = LoggerFactory.getLogger(GitlabWebhookManager.class); diff --git a/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java b/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java index 5bf5e36..67df93e 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java +++ b/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java @@ -4,7 +4,6 @@ import com.gitee.kooder.core.Constants; import com.gitee.kooder.models.QueryResult; import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.server.Action; -import io.vertx.core.http.HttpServerRequest; import io.vertx.ext.web.RoutingContext; import org.apache.commons.lang3.StringUtils; @@ -15,7 +14,7 @@ import java.util.Arrays; * Action for search, both for web and api * @author Winter Lau */ -public interface SearchActionBase extends Action { +interface SearchActionBase extends Action { /** * execute search -- Gitee From 1f111819cd59f14ec386fb1815c26d56d0d84fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 4 Feb 2021 22:00:21 +0800 Subject: [PATCH 06/29] add class comment --- .../main/java/com/gitee/kooder/action/GiteeWebHookManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index c5d332b..f8db8ad 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -16,6 +16,7 @@ import java.util.Objects; import java.util.Optional; /** + * This class provides a handler for processing gitee Web Hook callouts. * @author zhanggx */ class GiteeWebHookManager { -- Gitee From 7cd96b392dee30a3f3c5191106213501c66ed307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Fri, 5 Feb 2021 10:58:14 +0800 Subject: [PATCH 07/29] move gitee classes to indexer module --- .../kooder/models/GitlabProjectEvent.java | 15 ------- .../java/com/gitee/kooder/models/Issue.java | 17 -------- .../com/gitee/kooder/models/Repository.java | 21 ---------- core/src/main/resources/kooder.properties | 6 +-- .../kooder/action/GiteeWebHookManager.java | 2 +- .../com/gitee/kooder/action/GitlabAction.java | 14 ++++++- .../java/com/gitee/kooder/server/Gateway.java | 2 +- .../gitee/kooder/gitee/EnterpriseHook.java | 0 .../java/com/gitee/kooder/gitee/GiteeApi.java | 0 .../gitee/kooder/gitee/GiteeException.java | 0 .../{indexer => gitee}/GiteeIndexThread.java | 10 ++--- .../kooder/gitee}/GiteeWebHookEvent.java | 2 +- .../java/com/gitee/kooder/gitee/Issue.java | 33 +++++++++++---- .../com/gitee/kooder/gitee/IssueWebHook.java | 0 .../com/gitee/kooder/gitee/RepoWebHook.java | 0 .../com/gitee/kooder/gitee/Repository.java | 40 ++++++++++++++----- .../java/com/gitee/kooder/gitee/User.java | 0 17 files changed, 78 insertions(+), 84 deletions(-) delete mode 100644 core/src/main/java/com/gitee/kooder/models/GitlabProjectEvent.java rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java (100%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/GiteeApi.java (100%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/GiteeException.java (100%) rename indexer/src/main/java/com/gitee/kooder/{indexer => gitee}/GiteeIndexThread.java (93%) rename {core/src/main/java/com/gitee/kooder/models => indexer/src/main/java/com/gitee/kooder/gitee}/GiteeWebHookEvent.java (94%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/Issue.java (64%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java (100%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java (100%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/Repository.java (70%) rename {core => indexer}/src/main/java/com/gitee/kooder/gitee/User.java (100%) diff --git a/core/src/main/java/com/gitee/kooder/models/GitlabProjectEvent.java b/core/src/main/java/com/gitee/kooder/models/GitlabProjectEvent.java deleted file mode 100644 index d16babc..0000000 --- a/core/src/main/java/com/gitee/kooder/models/GitlabProjectEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gitee.kooder.models; - -/** - * 仓库事件 - * @author Winter Lau - */ -public class GitlabProjectEvent { - - public final static String E_PROJECT_CREATE = "project_create"; - public final static String E_PROJECT_DESTROY = "project_destroy"; - public final static String E_PROJECT_RENAME = "project_rename"; - public final static String E_PROJECT_TRANSFER = "project_transfer"; - public final static String E_PROJECT_UPDATE = "project_update"; - -} diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index 71714be..251fdc9 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -79,23 +79,6 @@ public final class Issue extends Searchable { setDocument(doc); } - public Issue(com.gitee.kooder.gitee.Issue issue) { - this.id = issue.getId(); - this.ident = issue.getRepository().getId() + "_" + this.id; - this.enterprise = Relation.EMPTY; - this.project = Relation.EMPTY; - this.repository = new Relation(issue.getRepository().getId(), issue.getRepository().getName(), issue.getRepository().getUrl()); - this.owner = new Relation(issue.getUser().getId(), issue.getUser().getName(), issue.getUser().getHtmlUrl()); - this.title = issue.getTitle(); - this.description = issue.getBody(); - this.url = issue.getHtmlUrl(); - this.labels = new ArrayList<>(issue.getLabels()); - this.createdAt = issue.getCreatedAt().getTime(); - this.updatedAt = issue.getUpdatedAt().getTime(); - this.state = com.gitee.kooder.gitee.Issue.STATE_OPEN.equals(issue.getState()) - || com.gitee.kooder.gitee.Issue.STATE_PROGRESSING.equals(issue.getState()) ? STATE_OPENED : STATE_CLOSED; - } - /** * Read fields from document * @param doc diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index 2a8aab0..19a272f 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -69,27 +69,6 @@ public final class Repository extends Searchable { this.setBlock(Constants.REPO_BLOCK_NO); } - public Repository(com.gitee.kooder.gitee.Repository repository) { - this.id = repository.getId(); - this.name = repository.getName(); - this.description = repository.getDescription(); - this.url = repository.getGitHttpUrl() == null ? repository.getHtmlUrl() : repository.getGitHttpUrl(); - this.enterprise = Relation.EMPTY; - this.project = Relation.EMPTY; - this.owner = new Relation(repository.getOwner().getId(), repository.getOwner().getName(), repository.getOwner().getHtmlUrl()); - this.visibility = repository.getPrivate() ? Constants.VISIBILITY_PRIVATE : repository.getInternal() ? Constants.VISIBILITY_INTERNAL : Constants.VISIBILITY_PUBLIC; - this.license = repository.getLicense(); - this.lang = repository.getLanguage(); - this.readme = ""; - this.fork = 0; - this.tags = Collections.emptyList(); - this.starsCount = repository.getStargazersCount(); - this.forksCount = repository.getForksCount(); - this.createdAt = repository.getCreatedAt().getTime(); - this.updatedAt = repository.getUpdatedAt().getTime(); - this.setBlock(Constants.REPO_BLOCK_NO); - } - /** * generate lucene document * @return diff --git a/core/src/main/resources/kooder.properties b/core/src/main/resources/kooder.properties index 86ade72..9900e04 100644 --- a/core/src/main/resources/kooder.properties +++ b/core/src/main/resources/kooder.properties @@ -8,8 +8,8 @@ http.log.pattern = /,/index/*,/search/*,/api/* http.webroot = gateway/src/main/webapp http.startup.tasks = indexer,gitlab -#gitlab.url = http://192.168.1.25:10080/ -gitlab.url = http://154.85.53.95:10080/ +gitlab.url = http://192.168.1.25:10080/ +#gitlab.url = http://154.85.53.95:10080/ gitlab.personal_access_token = Bt1H3ZUkD2bBFMbxxPxw gitlab.secret_token = gsearch @@ -29,8 +29,6 @@ queue.redis.key = gsearch-queue # queue.embed.url = http://127.0.0.1:8080/queue/fetch queue.embed.path = ./data/queue queue.embed.batch_size = 10000 -queue.test.auto_generate_task = true -queue.test.types = repo,issue,code # 洢 storage.type = disk diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index f8db8ad..17be755 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -3,7 +3,7 @@ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; import com.gitee.kooder.gitee.GiteeException; import com.gitee.kooder.models.CodeRepository; -import com.gitee.kooder.models.GiteeWebHookEvent; +import com.gitee.kooder.gitee.GiteeWebHookEvent; import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; import com.gitee.kooder.gitee.IssueWebHook; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java index 3ae55b0..5297b11 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java @@ -4,7 +4,6 @@ import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.indexer.Gitlab; -import com.gitee.kooder.models.GitlabProjectEvent; import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; import com.gitee.kooder.queue.QueueTask; @@ -109,5 +108,18 @@ public class GitlabAction implements Action { return null; } + /** + * Gitlab repositories events definition + */ + class GitlabProjectEvent { + + public final static String E_PROJECT_CREATE = "project_create"; + public final static String E_PROJECT_DESTROY = "project_destroy"; + public final static String E_PROJECT_RENAME = "project_rename"; + public final static String E_PROJECT_TRANSFER = "project_transfer"; + public final static String E_PROJECT_UPDATE = "project_update"; + + } + } diff --git a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java index ec1a42b..8818673 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java @@ -3,7 +3,7 @@ package com.gitee.kooder.server; import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.indexer.FetchTaskThread; import com.gitee.kooder.indexer.GiteaIndexThread; -import com.gitee.kooder.indexer.GiteeIndexThread; +import com.gitee.kooder.gitee.GiteeIndexThread; import com.gitee.kooder.indexer.GitlabIndexThread; import io.vertx.core.http.HttpServerResponse; import io.vertx.core.net.SocketAddress; diff --git a/core/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java rename to indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java diff --git a/core/src/main/java/com/gitee/kooder/gitee/GiteeApi.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/GiteeApi.java rename to indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java diff --git a/core/src/main/java/com/gitee/kooder/gitee/GiteeException.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/GiteeException.java rename to indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java similarity index 93% rename from indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java rename to indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java index 4550723..e0f8d1f 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java @@ -1,13 +1,11 @@ -package com.gitee.kooder.indexer; +package com.gitee.kooder.gitee; -import com.gitee.kooder.gitee.GiteeApi; import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; -import com.gitee.kooder.gitee.GiteeException; +import com.gitee.kooder.indexer.GitlabIndexThread; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.Issue; import com.gitee.kooder.models.Repository; -import com.gitee.kooder.gitee.EnterpriseHook; import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.queue.QueueTask; import org.slf4j.Logger; @@ -89,7 +87,7 @@ public class GiteeIndexThread extends Thread { int maxId = lastRepository == null ? 0 : Math.toIntExact(lastRepository.getId()); List repositoryList = GiteeApi.getInstance().getRepos(maxId); for (com.gitee.kooder.gitee.Repository repository : repositoryList) { - Repository repo = new Repository(repository); + Repository repo = repository.toKooderRepository(); QueueTask.add(Constants.TYPE_REPOSITORY, repo); CodeRepository codes = new CodeRepository(); codes.setId(repository.getId()); @@ -116,7 +114,7 @@ public class GiteeIndexThread extends Thread { int maxId = lastIssue == null ? 0 : Math.toIntExact(lastIssue.getId()); List issueList = GiteeApi.getInstance().getIssues(maxId); for (com.gitee.kooder.gitee.Issue issue : issueList) { - QueueTask.add(Constants.TYPE_ISSUE, new Issue(issue)); + QueueTask.add(Constants.TYPE_ISSUE, issue.toKooderIssue()); pc++; } diff --git a/core/src/main/java/com/gitee/kooder/models/GiteeWebHookEvent.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java similarity index 94% rename from core/src/main/java/com/gitee/kooder/models/GiteeWebHookEvent.java rename to indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java index b16097b..4a61ef2 100644 --- a/core/src/main/java/com/gitee/kooder/models/GiteeWebHookEvent.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java @@ -1,4 +1,4 @@ -package com.gitee.kooder.models; +package com.gitee.kooder.gitee; import java.util.Arrays; diff --git a/core/src/main/java/com/gitee/kooder/gitee/Issue.java b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java similarity index 64% rename from core/src/main/java/com/gitee/kooder/gitee/Issue.java rename to indexer/src/main/java/com/gitee/kooder/gitee/Issue.java index e4c9b09..a0efa1e 100644 --- a/core/src/main/java/com/gitee/kooder/gitee/Issue.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java @@ -1,7 +1,9 @@ package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; +import com.gitee.kooder.models.Relation; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -16,27 +18,42 @@ public class Issue { public static final String STATE_REJECTED = "rejected"; private Integer id; - private String htmlUrl; - private String state; - private String title; - private String body; - private List labels; - private User user; - private Repository repository; @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX") private Date createdAt; - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX") private Date updatedAt; + /** + * Turn to kooder issue + * @return + */ + public com.gitee.kooder.models.Issue toKooderIssue() { + com.gitee.kooder.models.Issue iss = new com.gitee.kooder.models.Issue(); + iss.setId(getId()); + iss.setIdent(this.getRepository().getId() + "_" + this.getId()); + iss.setEnterprise(Relation.EMPTY); + iss.setProject(Relation.EMPTY); + iss.setRepository(new Relation(this.getRepository().getId(), this.getRepository().getName(), this.getRepository().getUrl())); + iss.setOwner(new Relation(this.getUser().getId(), this.getUser().getName(), this.getUser().getHtmlUrl())); + iss.setTitle(this.getTitle()); + iss.setDescription(this.getBody()); + iss.setUrl(this.getHtmlUrl()); + iss.setLabels(new ArrayList<>(this.getLabels())); + iss.setCreatedAt(this.getCreatedAt().getTime()); + iss.setUpdatedAt(this.getUpdatedAt().getTime()); + iss.setState((STATE_OPEN.equals(this.getState()) || STATE_PROGRESSING.equals(this.getState())) + ?com.gitee.kooder.models.Issue.STATE_OPENED:com.gitee.kooder.models.Issue.STATE_CLOSED); + return iss; + } + public Integer getId() { return id; } diff --git a/core/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java rename to indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java diff --git a/core/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java rename to indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java diff --git a/core/src/main/java/com/gitee/kooder/gitee/Repository.java b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java similarity index 70% rename from core/src/main/java/com/gitee/kooder/gitee/Repository.java rename to indexer/src/main/java/com/gitee/kooder/gitee/Repository.java index 256d865..6818506 100644 --- a/core/src/main/java/com/gitee/kooder/gitee/Repository.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java @@ -2,7 +2,10 @@ package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; +import com.gitee.kooder.core.Constants; +import com.gitee.kooder.models.Relation; +import java.util.Collections; import java.util.Date; /** @@ -11,15 +14,10 @@ import java.util.Date; public class Repository { private Integer id; - private String name; - private String url; - private String htmlUrl; - private String gitHttpUrl; - private String description; /** @@ -39,13 +37,9 @@ public class Repository { */ @JsonProperty("public") private Boolean isPublic; - private String license; - private String language; - private Integer stargazersCount; - private Integer forksCount; @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssX") @@ -56,6 +50,34 @@ public class Repository { private User owner; + /** + * Turn to kooder repository + * @return + */ + public com.gitee.kooder.models.Repository toKooderRepository() { + com.gitee.kooder.models.Repository repo = new com.gitee.kooder.models.Repository(); + repo.setId(this.getId()); + repo.setName(this.getName()); + repo.setDescription(this.getDescription()); + repo.setUrl(this.getGitHttpUrl() == null ? this.getHtmlUrl() : this.getGitHttpUrl()); + repo.setEnterprise(Relation.EMPTY); + repo.setProject(Relation.EMPTY); + repo.setOwner(new Relation(this.getOwner().getId(), this.getOwner().getName(), this.getOwner().getHtmlUrl())); + repo.setVisibility(this.getPrivate() ? Constants.VISIBILITY_PRIVATE : this.getInternal() ? Constants.VISIBILITY_INTERNAL : Constants.VISIBILITY_PUBLIC); + repo.setLicense(this.getLicense()); + repo.setLang(this.getLanguage()); + repo.setReadme(null); + repo.setFork(0); + repo.setTags(Collections.emptyList()); + repo.setStarsCount(this.getStargazersCount()); + repo.setForksCount(this.getForksCount()); + repo.setCreatedAt(this.getCreatedAt().getTime()); + repo.setUpdatedAt(this.getUpdatedAt().getTime()); + repo.setBlock(Constants.REPO_BLOCK_NO); + return repo; + } + + public Integer getId() { return id; } diff --git a/core/src/main/java/com/gitee/kooder/gitee/User.java b/indexer/src/main/java/com/gitee/kooder/gitee/User.java similarity index 100% rename from core/src/main/java/com/gitee/kooder/gitee/User.java rename to indexer/src/main/java/com/gitee/kooder/gitee/User.java -- Gitee From d9df7e57d5f198817bf555158ee04098448920c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Fri, 5 Feb 2021 10:59:09 +0800 Subject: [PATCH 08/29] remove unused import --- core/src/main/java/com/gitee/kooder/models/Repository.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index 19a272f..f75f1cd 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -8,7 +8,6 @@ import org.apache.lucene.facet.FacetField; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Visibility; -import java.util.Collections; import java.util.List; /** -- Gitee From 4942a67614126e7ae0e7ec0b11361e7ae2b4e150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Fri, 5 Feb 2021 11:05:27 +0800 Subject: [PATCH 09/29] fix method invoke error --- .../java/com/gitee/kooder/action/GiteeWebHookManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index 17be755..faa6fc9 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -41,7 +41,7 @@ class GiteeWebHookManager { if (RepoWebHook.ACTION_CREATE.equals(repoWebHook.getAction())) { // index repository data - Repository repository = new Repository(repoWebHook.getRepository()); + Repository repository = repoWebHook.getRepository().toKooderRepository(); QueueTask.add(Constants.TYPE_REPOSITORY, repository); // index code data CodeRepository coder = new CodeRepository(repository); @@ -72,7 +72,7 @@ class GiteeWebHookManager { throw new GiteeException("Cannot resolve issue web hook!"); } issueWebHook.getIssue().setRepository(issueWebHook.getRepository()); - Issue issue = new Issue(issueWebHook.getIssue()); + Issue issue = issueWebHook.getIssue().toKooderIssue(); QueueTask.update(Constants.TYPE_ISSUE, issue); break; default: -- Gitee From 1bb7c9086feefb31153fe77cfc24fe44fbfbe13a Mon Sep 17 00:00:00 2001 From: silverballer Date: Fri, 5 Feb 2021 16:38:13 +0800 Subject: [PATCH 10/29] gitee add enterprise info fix default branch error bug --- .../kooder/action/GiteeWebHookManager.java | 117 +++++++++++------- .../com/gitee/kooder/action/GitlabAction.java | 15 +-- .../com/gitee/kooder/gitee/Enterprise.java | 36 ++++++ .../java/com/gitee/kooder/gitee/GiteeApi.java | 19 +++ .../gitee/kooder/gitee/GiteeIndexThread.java | 17 ++- .../gitee/kooder/gitee/GiteeWebHookEvent.java | 2 +- .../java/com/gitee/kooder/gitee/Issue.java | 1 - .../com/gitee/kooder/gitee/PushWebHook.java | 17 +++ .../com/gitee/kooder/gitee/Repository.java | 1 - 9 files changed, 168 insertions(+), 57 deletions(-) create mode 100644 indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java create mode 100644 indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index faa6fc9..e8ab4b5 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -1,22 +1,20 @@ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; -import com.gitee.kooder.gitee.GiteeException; +import com.gitee.kooder.gitee.*; import com.gitee.kooder.models.CodeRepository; -import com.gitee.kooder.gitee.GiteeWebHookEvent; import com.gitee.kooder.models.Issue; +import com.gitee.kooder.models.Relation; import com.gitee.kooder.models.Repository; -import com.gitee.kooder.gitee.IssueWebHook; -import com.gitee.kooder.gitee.RepoWebHook; import com.gitee.kooder.queue.QueueTask; import com.gitee.kooder.utils.JsonUtils; import io.vertx.ext.web.RoutingContext; import java.util.Objects; -import java.util.Optional; /** * This class provides a handler for processing gitee Web Hook callouts. + * * @author zhanggx */ class GiteeWebHookManager { @@ -31,55 +29,90 @@ class GiteeWebHookManager { public static void handleEvent(String secretToken, RoutingContext context) throws GiteeException { checkSecretToken(secretToken, context); GiteeWebHookEvent giteeWebHookEvent = parseGiteeWebHookEvent(context); + Enterprise enterprise = GiteeApi.getInstance().getEnterprise(); switch (giteeWebHookEvent) { - case REPO_HOO: - RepoWebHook repoWebHook = JsonUtils.readValue(context.getBodyAsString(), RepoWebHook.class); - if (repoWebHook == null) { - throw new GiteeException("Cannot resolve repo web hook!"); - } - - if (RepoWebHook.ACTION_CREATE.equals(repoWebHook.getAction())) { - // index repository data - Repository repository = repoWebHook.getRepository().toKooderRepository(); - QueueTask.add(Constants.TYPE_REPOSITORY, repository); - // index code data - CodeRepository coder = new CodeRepository(repository); - coder.setScm(CodeRepository.SCM_GIT); - QueueTask.add(Constants.TYPE_CODE, coder); - - } else if (RepoWebHook.ACTION_DESTROY.equals(repoWebHook.getAction())) { - // delete repository data - Repository repository = new Repository(); - repository.setId(repoWebHook.getRepository().getId()); - QueueTask.delete(Constants.TYPE_REPOSITORY, repository); - - } else { - throw new GiteeException("Repo web hook action unsupported!"); - } - + case REPO_HOOK: + handleRepoHookEvent(context, enterprise); break; case PUSH_HOOK: - Integer projectId = Optional.ofNullable(context.getBodyAsJson()) - .map(jsonObject -> jsonObject.getJsonObject("project")) - .map(jsonObject -> jsonObject.getInteger("id")) - .orElseThrow(() -> new GiteeException("Cannot resolve project id!")); - QueueTask.update(Constants.TYPE_CODE, new CodeRepository(projectId)); + handlePushHookEvent(context, enterprise); break; case ISSUE_HOOK: - IssueWebHook issueWebHook = JsonUtils.readValue(context.getBodyAsString(), IssueWebHook.class); - if (issueWebHook == null) { - throw new GiteeException("Cannot resolve issue web hook!"); - } - issueWebHook.getIssue().setRepository(issueWebHook.getRepository()); - Issue issue = issueWebHook.getIssue().toKooderIssue(); - QueueTask.update(Constants.TYPE_ISSUE, issue); + handleIssueHookEvent(context, enterprise); break; default: throw new GiteeException("Web hook event unsupported!"); } } + /** + * handle repo hook + * + * @param context + * @param enterprise + * @throws GiteeException action unsupported! + */ + private static void handleRepoHookEvent(RoutingContext context, Enterprise enterprise) throws GiteeException { + RepoWebHook repoWebHook = JsonUtils.readValue(context.getBodyAsString(), RepoWebHook.class); + if (repoWebHook == null) { + throw new GiteeException("Cannot resolve repo web hook!"); + } + + if (RepoWebHook.ACTION_CREATE.equals(repoWebHook.getAction())) { + // index repository data + Repository repository = repoWebHook.getRepository().toKooderRepository(); + repository.setEnterprise(new Relation(enterprise.getId(), enterprise.getName(), enterprise.getUrl())); + QueueTask.add(Constants.TYPE_REPOSITORY, repository); + + } else if (RepoWebHook.ACTION_DESTROY.equals(repoWebHook.getAction())) { + // delete repository data + Repository repository = new Repository(); + repository.setId(repoWebHook.getRepository().getId()); + QueueTask.delete(Constants.TYPE_REPOSITORY, repository); + + } else { + throw new GiteeException("Repo web hook action unsupported!"); + } + } + + /** + * handle push hook + * + * @param context + * @param enterprise + * @throws GiteeException cannot resolve push web hook + */ + private static void handlePushHookEvent(RoutingContext context, Enterprise enterprise) throws GiteeException { + PushWebHook pushWebHook = JsonUtils.readValue(context.getBodyAsString(), PushWebHook.class); + if (pushWebHook == null) { + throw new GiteeException("Cannot resolve push web hook!"); + } + Repository repository = pushWebHook.getRepository().toKooderRepository(); + repository.setEnterprise(new Relation(enterprise.getId(), enterprise.getName(), enterprise.getUrl())); + CodeRepository codeRepository = new CodeRepository(repository); + codeRepository.setScm(CodeRepository.SCM_GIT); + QueueTask.add(Constants.TYPE_CODE, codeRepository); + } + + /** + * handle issue hook + * + * @param context + * @param enterprise + * @throws GiteeException cannot resolve issue web hook + */ + private static void handleIssueHookEvent(RoutingContext context, Enterprise enterprise) throws GiteeException { + IssueWebHook issueWebHook = JsonUtils.readValue(context.getBodyAsString(), IssueWebHook.class); + if (issueWebHook == null) { + throw new GiteeException("Cannot resolve issue web hook!"); + } + issueWebHook.getIssue().setRepository(issueWebHook.getRepository()); + Issue issue = issueWebHook.getIssue().toKooderIssue(); + issue.setEnterprise(new Relation(enterprise.getId(), enterprise.getName(), enterprise.getUrl())); + QueueTask.update(Constants.TYPE_ISSUE, issue); + } + /** * check web hook secret token * diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java index 5297b11..222bd7e 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java @@ -45,10 +45,6 @@ public class GitlabAction implements Action { if(p != null) { Repository repo = new Repository(p); QueueTask.add(Constants.TYPE_REPOSITORY, repo); - - CodeRepository coder = new CodeRepository(repo); - coder.setScm(CodeRepository.SCM_GIT); - QueueTask.add(Constants.TYPE_CODE, coder); } break; case GitlabProjectEvent.E_PROJECT_DESTROY: @@ -70,9 +66,14 @@ public class GitlabAction implements Action { this.fireCodeUpdate(event.getProjectId()); } - private void fireCodeUpdate(long pid) { - CodeRepository repo = new CodeRepository(pid); - QueueTask.update(Constants.TYPE_CODE, repo); //update source code indexes + private void fireCodeUpdate(int pid) { + Project p = getProject(pid); + if(p != null) { + Repository repo = new Repository(p); + CodeRepository coder = new CodeRepository(repo); + coder.setScm(CodeRepository.SCM_GIT); + QueueTask.add(Constants.TYPE_CODE, coder); //update source code indexes + } } }; hookMgr.handleEvent(context); diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java b/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java new file mode 100644 index 0000000..92b02ad --- /dev/null +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java @@ -0,0 +1,36 @@ +package com.gitee.kooder.gitee; + +/** + * @author zhanggx + */ +public class Enterprise { + + private Integer id; + private String name; + private String url; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java index e70395f..019895a 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java @@ -19,6 +19,7 @@ public class GiteeApi { private final static Logger log = LoggerFactory.getLogger(GiteeApi.class); + private static final String URL_GET_ENTERPRISE = "/api/v5/enterprises/enterprise"; private static final String URL_CREATE_ENTERPRISE_HOOKS = "/api/v5/enterprises/enterprise/hooks/create"; private static final String URL_GET_ENTERPRISE_HOOKS = "/api/v5/enterprises/enterprise/hooks"; private static final String URL_GET_REPOS = "/api/v5/enterprises/enterprise/repos"; @@ -42,6 +43,24 @@ public class GiteeApi { return Singleton.INSTANCE; } + /** + * get enterprise info + * + * @return + */ + public Enterprise getEnterprise() throws GiteeException { + Map requestParamsMap = getRequestParamsMap(); + try (Response response = HttpUtils.get(giteeUrl + URL_GET_ENTERPRISE, requestParamsMap)) { + if (response.isSuccessful()) { + return JsonUtils.readValue(response.body().string(), Enterprise.class); + } + throw new GiteeException(response.body().string()); + } catch (Exception e) { + log.warn("Create gitee enterprise hooks error: {}", e.getMessage()); + throw new GiteeException(e.getMessage()); + } + } + /** * create enterprise hook * diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java index e0f8d1f..99ca276 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java @@ -5,6 +5,7 @@ import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.indexer.GitlabIndexThread; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.Issue; +import com.gitee.kooder.models.Relation; import com.gitee.kooder.models.Repository; import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.queue.QueueTask; @@ -49,9 +50,10 @@ public class GiteeIndexThread extends Thread { public void run() { try { long ct = System.currentTimeMillis(); + Enterprise enterprise = GiteeApi.getInstance().getEnterprise(); checkAndInstallEnterpriseHook(); - checkAndIndexProjects(); - checkAndIndexIssues(); + checkAndIndexProjects(enterprise); + checkAndIndexIssues(enterprise); log.info("Gitee data initialize finished in {} ms.", System.currentTimeMillis() - ct); } catch (GiteeException e) { log.error("Failed to initialize gitlab data.", e); @@ -78,8 +80,9 @@ public class GiteeIndexThread extends Thread { * check and index projects data * * @throws GiteeException get projects data error + * @param enterprise */ - private void checkAndIndexProjects() throws GiteeException { + private void checkAndIndexProjects(Enterprise enterprise) throws GiteeException { long ct = System.currentTimeMillis(); int pc = 0; @@ -88,6 +91,7 @@ public class GiteeIndexThread extends Thread { List repositoryList = GiteeApi.getInstance().getRepos(maxId); for (com.gitee.kooder.gitee.Repository repository : repositoryList) { Repository repo = repository.toKooderRepository(); + repo.setEnterprise(new Relation(enterprise.getId(), enterprise.getName(), enterprise.getUrl())); QueueTask.add(Constants.TYPE_REPOSITORY, repo); CodeRepository codes = new CodeRepository(); codes.setId(repository.getId()); @@ -104,9 +108,10 @@ public class GiteeIndexThread extends Thread { /** * check and index issues data * + * @param enterprise * @throws GiteeException get issues data error */ - private void checkAndIndexIssues() throws GiteeException { + private void checkAndIndexIssues(Enterprise enterprise) throws GiteeException { long ct = System.currentTimeMillis(); int pc = 0; @@ -114,7 +119,9 @@ public class GiteeIndexThread extends Thread { int maxId = lastIssue == null ? 0 : Math.toIntExact(lastIssue.getId()); List issueList = GiteeApi.getInstance().getIssues(maxId); for (com.gitee.kooder.gitee.Issue issue : issueList) { - QueueTask.add(Constants.TYPE_ISSUE, issue.toKooderIssue()); + Issue kooderIssue = issue.toKooderIssue(); + kooderIssue.setEnterprise(new Relation(enterprise.getId(), enterprise.getName(), enterprise.getUrl())); + QueueTask.add(Constants.TYPE_ISSUE, kooderIssue); pc++; } diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java index 4a61ef2..25fbcec 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java @@ -7,7 +7,7 @@ import java.util.Arrays; */ public enum GiteeWebHookEvent { - REPO_HOO("Repo Hook"), + REPO_HOOK("Repo Hook"), PUSH_HOOK("Push Hook"), ISSUE_HOOK("Issue Hook"); diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java index a0efa1e..1a4de7f 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java @@ -39,7 +39,6 @@ public class Issue { com.gitee.kooder.models.Issue iss = new com.gitee.kooder.models.Issue(); iss.setId(getId()); iss.setIdent(this.getRepository().getId() + "_" + this.getId()); - iss.setEnterprise(Relation.EMPTY); iss.setProject(Relation.EMPTY); iss.setRepository(new Relation(this.getRepository().getId(), this.getRepository().getName(), this.getRepository().getUrl())); iss.setOwner(new Relation(this.getUser().getId(), this.getUser().getName(), this.getUser().getHtmlUrl())); diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java new file mode 100644 index 0000000..46b77bd --- /dev/null +++ b/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java @@ -0,0 +1,17 @@ +package com.gitee.kooder.gitee; + +/** + * @author zhanggx + */ +public class PushWebHook { + + private Repository repository; + + public Repository getRepository() { + return repository; + } + + public void setRepository(Repository repository) { + this.repository = repository; + } +} diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java index 6818506..99056ee 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java @@ -60,7 +60,6 @@ public class Repository { repo.setName(this.getName()); repo.setDescription(this.getDescription()); repo.setUrl(this.getGitHttpUrl() == null ? this.getHtmlUrl() : this.getGitHttpUrl()); - repo.setEnterprise(Relation.EMPTY); repo.setProject(Relation.EMPTY); repo.setOwner(new Relation(this.getOwner().getId(), this.getOwner().getName(), this.getOwner().getHtmlUrl())); repo.setVisibility(this.getPrivate() ? Constants.VISIBILITY_PRIVATE : this.getInternal() ? Constants.VISIBILITY_INTERNAL : Constants.VISIBILITY_PUBLIC); -- Gitee From 82c928841e2d36f9d1bcd33a39629b4fcccb7d24 Mon Sep 17 00:00:00 2001 From: silverballer Date: Fri, 5 Feb 2021 18:10:51 +0800 Subject: [PATCH 11/29] style: log print update --- .../src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java index 99ca276..5d6f617 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java @@ -56,7 +56,7 @@ public class GiteeIndexThread extends Thread { checkAndIndexIssues(enterprise); log.info("Gitee data initialize finished in {} ms.", System.currentTimeMillis() - ct); } catch (GiteeException e) { - log.error("Failed to initialize gitlab data.", e); + log.error("Failed to initialize gitee data.", e); } } -- Gitee From 734d682fd538030869d3b530ab08e1d8adeb70e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Sun, 7 Feb 2021 17:39:00 +0800 Subject: [PATCH 12/29] downgrade java from 11 to 8 --- .../kooder/code/GitRepositoryProvider.java | 2 +- .../gitee/kooder/code/RepositoryFactory.java | 2 +- .../gitee/kooder/code/TechCodeTokenizer.java | 2 +- .../gitee/kooder/utils/FileClassifier.java | 28 +++++++++---------- .../java/com/gitee/kooder/server/Gateway.java | 2 +- pom.xml | 4 +-- readme.md | 2 +- readme_en.md | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java index 389c779..a6cceed 100644 --- a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java @@ -337,7 +337,7 @@ public class GitRepositoryProvider implements RepositoryProvider { doc.setLanguage(FileClassifier.languageGuess(path, contents)); //语言 doc.setContents(contents); //源码 doc.setCodeOwner(getCodeOwner(git, path)); //开发者 TODO 如何能支持多个开发者 - var slocCount = slocCounter.countStats(contents, doc.getLanguage()); + SlocCounter.SlocCount slocCount = slocCounter.countStats(contents, doc.getLanguage()); doc.setLines(slocCount.linesCount); //代码行统计 doc.setCommentLines(slocCount.commentCount); doc.setBlankLines(slocCount.blankCount); diff --git a/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java b/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java index 8423ed4..5a6956b 100644 --- a/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java +++ b/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java @@ -14,7 +14,7 @@ public class RepositoryFactory { private final static Logger log = LoggerFactory.getLogger(RepositoryFactory.class); - private final static Map providers = new HashMap<>(){{ + private final static Map providers = new HashMap(){{ put(CodeRepository.SCM_GIT, new GitRepositoryProvider()); put(CodeRepository.SCM_SVN, new SvnRepositoryProvider()); put(CodeRepository.SCM_FILE, new FileRepositoryProvider()); diff --git a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java index 0096c4e..c20ba6e 100644 --- a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java +++ b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java @@ -20,7 +20,7 @@ public final class TechCodeTokenizer extends Tokenizer { public final static char[] beginTokens = {'+','#'}; public final static char[] endTokens = {'.'}; - public final static Map synonymWords = new HashMap<>(){{ + public final static Map synonymWords = new HashMap(){{ put(".net", new String[]{"dotnet"}); put("c#", new String[]{"csharp"}); put("c++", new String[]{"cpp"}); diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java index 1007a6e..f66df2a 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java @@ -19,7 +19,7 @@ public class FileClassifier { static { try (InputStream stream = FileClassifier.class.getResourceAsStream("/languages.json")){ - TypeReference> typeRef = new TypeReference<>(){}; + TypeReference> typeRef = new TypeReference(){}; database = Collections.unmodifiableMap(JsonUtils.readValue(stream, typeRef)); } catch (IOException ex) { ex.printStackTrace(); @@ -39,8 +39,8 @@ public class FileClassifier { */ public static String languageGuess(String fileName, String content) { fileName = fileName.toLowerCase(); - var matches = new ArrayList(); - var extension = ""; + List matches = new ArrayList<>(); + String extension = ""; // Try finding based on full name match matches = checkIfFilenameExists(fileName); @@ -73,11 +73,11 @@ public class FileClassifier { } // We have multiple matches, so try to work out which one is the most likely result - var toSort = new HashMap(); + HashMap toSort = new HashMap(); - for (var m : matches) { + for (String m : matches) { toSort.put(m, 0); - for (var keyword : database.get(m).keywords) { + for (String keyword : database.get(m).keywords) { if (content.contains(keyword)) { toSort.put(m, toSort.get(m) + 1); } @@ -98,13 +98,13 @@ public class FileClassifier { return result; } - private static ArrayList checkIfExtentionExists(String extension) { - var matches = new ArrayList(); + private static List checkIfExtentionExists(String extension) { + List matches = new ArrayList<>(); for (String key : database.keySet()) { - var fileClassifierResult = database.get(key); + FileClassifierResult fileClassifierResult = database.get(key); - for (var ext : fileClassifierResult.extensions) { + for (String ext : fileClassifierResult.extensions) { if (extension.equals(ext)) { matches.add(key); } @@ -114,14 +114,14 @@ public class FileClassifier { return matches; } - private static ArrayList checkIfFilenameExists(String extension) { - var matches = new ArrayList(); + private static List checkIfFilenameExists(String extension) { + List matches = new ArrayList<>(); for (String key : database.keySet()) { - var fileClassifierResult = database.get(key); + FileClassifierResult fileClassifierResult = database.get(key); if (fileClassifierResult.filenames != null) { - for (var ext : fileClassifierResult.filenames) { + for (String ext : fileClassifierResult.filenames) { if (extension.equals(ext)) { matches.add(key); } diff --git a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java index 8818673..6578797 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java @@ -21,7 +21,7 @@ import java.util.Map; public class Gateway extends GatewayBase { private final static String pattern_static_file = "/.*\\.(css|ico|js|html|htm|jpg|png|gif)"; - private final static Map startupTasks = new HashMap<>(){{ + private final static Map startupTasks = new HashMap(){{ put("indexer", new FetchTaskThread()); put("gitlab", new GitlabIndexThread()); put("gitee", new GiteeIndexThread()); diff --git a/pom.xml b/pom.xml index afdf360..de02ef1 100644 --- a/pom.xml +++ b/pom.xml @@ -35,8 +35,8 @@ maven-compiler-plugin 3.8.0 - 11 - 11 + 8 + 8 ${project.build.sourceEncoding} diff --git a/readme.md b/readme.md index 15e1a05..d03b3b3 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ Kooder 服务包含两个模块,分别是 gateway 和 indexer(默认配置 1.依赖 -* openjdk >= 11 +* openjdk >= 8 * maven > 3 2.下载代码 diff --git a/readme_en.md b/readme_en.md index cb0d511..148eb33 100644 --- a/readme_en.md +++ b/readme_en.md @@ -33,7 +33,7 @@ Indexer: 1.Dependencies -* openjdk >= 11 +* openjdk >= 8 * maven > 3 2.Download source code -- Gitee From 54569d76be4c7d93052acf4717abb6db00283664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Sun, 7 Feb 2021 19:30:34 +0800 Subject: [PATCH 13/29] fix #I37LJQ TypeReference init error --- core/src/main/java/com/gitee/kooder/utils/FileClassifier.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java index f66df2a..435119c 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java @@ -19,7 +19,7 @@ public class FileClassifier { static { try (InputStream stream = FileClassifier.class.getResourceAsStream("/languages.json")){ - TypeReference> typeRef = new TypeReference(){}; + TypeReference> typeRef = new TypeReference>(){}; database = Collections.unmodifiableMap(JsonUtils.readValue(stream, typeRef)); } catch (IOException ex) { ex.printStackTrace(); -- Gitee From 75ccc22592f59f5ea0e27e9598b438e632d362b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=BE=E9=A3=8E?= <515298495@qq.com> Date: Mon, 8 Feb 2021 01:04:34 +0800 Subject: [PATCH 14/29] update readme.md. --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index d03b3b3..65c9725 100644 --- a/readme.md +++ b/readme.md @@ -73,6 +73,8 @@ $ cd kooder ``` $ cd Kooder $ mvn install +### 给执行脚本添加权限 +$ chmod +x bin/*.sh ### 启动 gateway $ bin/gateway.sh ### 浏览器访问 http://localhost:8080 -- Gitee From 874e251a90a6972ea8f7736c25956a6a6f47fa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 13:33:25 +0800 Subject: [PATCH 15/29] code index add enterprise field for later isolated storage --- .../com/gitee/kooder/models/CodeRepository.java | 16 ++++++++++++---- .../com/gitee/kooder/gitee/GiteeIndexThread.java | 1 + .../gitee/kooder/indexer/GitlabIndexThread.java | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/models/CodeRepository.java b/core/src/main/java/com/gitee/kooder/models/CodeRepository.java index f809148..2a9809a 100644 --- a/core/src/main/java/com/gitee/kooder/models/CodeRepository.java +++ b/core/src/main/java/com/gitee/kooder/models/CodeRepository.java @@ -21,6 +21,7 @@ public class CodeRepository extends Searchable { public final static String STATUS_DONE = "indexed"; public final static String STATUS_FETCH = "fetched"; + private int enterprise = 0; //所属企业id private String scm; //代码源类型:git/svn/file private String name; //仓库名称 private String url; //仓库地址,ex: https://gitee.com/ld/J2Cache @@ -30,14 +31,11 @@ public class CodeRepository extends Searchable { public CodeRepository(){} - public CodeRepository(long id) { - super.setId(id); - } - public CodeRepository(Repository r) { this.id = r.getId(); this.name = r.getName(); this.url = r.getUrl(); + this.enterprise = (int)r.getEnterprise().getId(); } /** @@ -96,6 +94,14 @@ public class CodeRepository extends Searchable { this.status = status; } + public int getEnterprise() { + return enterprise; + } + + public void setEnterprise(int enterprise) { + this.enterprise = enterprise; + } + /** * generate lucene document * @@ -105,6 +111,7 @@ public class CodeRepository extends Searchable { public Document getDocument() { Document doc = new Document(); doc.add(new StringField(Constants.FIELD_REPO_ID, this.getIdAsString(), Field.Store.YES)); + doc.add(new StoredField(Constants.FIELD_ENTERPRISE_ID, this.getEnterprise())); doc.add(new StoredField(Constants.FIELD_REPO_URL, this.getUrl())); doc.add(new StoredField(Constants.FIELD_REPO_NAME, this.getName())); if(this.getLastCommitId() != null) @@ -125,6 +132,7 @@ public class CodeRepository extends Searchable { @Override public CodeRepository setDocument(Document doc) { this.setId(NumberUtils.toLong(doc.get(Constants.FIELD_REPO_ID), 0)); + this.setEnterprise(NumberUtils.toInt(doc.get(Constants.FIELD_ENTERPRISE_ID), 0)); this.setName(doc.get(Constants.FIELD_REPO_NAME)); this.setUrl(doc.get(Constants.FIELD_REPO_URL)); this.setLastCommitId(doc.get(Constants.FIELD_REVISION)); diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java index 5d6f617..77661aa 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java @@ -95,6 +95,7 @@ public class GiteeIndexThread extends Thread { QueueTask.add(Constants.TYPE_REPOSITORY, repo); CodeRepository codes = new CodeRepository(); codes.setId(repository.getId()); + codes.setEnterprise(enterprise.getId()); codes.setScm(CodeRepository.SCM_GIT); codes.setName(repository.getName()); codes.setUrl(repository.getHtmlUrl()); diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java index ee50a97..c97d306 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java @@ -132,6 +132,7 @@ public class GitlabIndexThread extends Thread { QueueTask.add(Constants.TYPE_REPOSITORY, repo); //index code CodeRepository codes = new CodeRepository(); + codes.setEnterprise(0); //Gitlab doesn't support enterprise codes.setId(p.getId()); codes.setScm(CodeRepository.SCM_GIT); codes.setName(p.getName()); -- Gitee From 2f4a0ab18e54e5dc5247427a07f1b203c74fcfd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 13:46:46 +0800 Subject: [PATCH 16/29] add license for each source file --- .../gitee/kooder/code/CodeFileTraveler.java | 15 +++++++++++++++ .../kooder/code/FileRepositoryProvider.java | 15 +++++++++++++++ .../com/gitee/kooder/code/FileTraveler.java | 15 +++++++++++++++ .../kooder/code/GitRepositoryProvider.java | 15 +++++++++++++++ .../gitee/kooder/code/RepositoryFactory.java | 15 +++++++++++++++ .../gitee/kooder/code/RepositoryManager.java | 15 +++++++++++++++ .../gitee/kooder/code/RepositoryProvider.java | 15 +++++++++++++++ .../kooder/code/SvnRepositoryProvider.java | 15 +++++++++++++++ .../gitee/kooder/code/TechCodeAnalyzer.java | 15 +++++++++++++++ .../gitee/kooder/code/TechCodeTokenizer.java | 15 +++++++++++++++ .../com/gitee/kooder/core/AnalyzerFactory.java | 15 +++++++++++++++ .../com/gitee/kooder/core/Configuration.java | 15 +++++++++++++++ .../java/com/gitee/kooder/core/Constants.java | 15 +++++++++++++++ .../gitee/kooder/core/GiteeSearchConfig.java | 15 +++++++++++++++ .../com/gitee/kooder/core/SearchHelper.java | 15 +++++++++++++++ .../java/com/gitee/kooder/core/SearchKey.java | 15 +++++++++++++++ .../com/gitee/kooder/index/IndexException.java | 15 +++++++++++++++ .../com/gitee/kooder/index/IndexManager.java | 17 ++++++++++++++++- .../java/com/gitee/kooder/models/CodeLine.java | 15 +++++++++++++++ .../com/gitee/kooder/models/CodeOwner.java | 15 +++++++++++++++ .../gitee/kooder/models/CodeRepository.java | 15 +++++++++++++++ .../java/com/gitee/kooder/models/Issue.java | 15 +++++++++++++++ .../com/gitee/kooder/models/QueryResult.java | 15 +++++++++++++++ .../java/com/gitee/kooder/models/Relation.java | 15 +++++++++++++++ .../com/gitee/kooder/models/Repository.java | 15 +++++++++++++++ .../com/gitee/kooder/models/Searchable.java | 15 +++++++++++++++ .../com/gitee/kooder/models/SourceFile.java | 15 +++++++++++++++ .../java/com/gitee/kooder/query/CodeQuery.java | 15 +++++++++++++++ .../java/com/gitee/kooder/query/IQuery.java | 15 +++++++++++++++ .../com/gitee/kooder/query/IssueQuery.java | 15 +++++++++++++++ .../java/com/gitee/kooder/query/QueryBase.java | 18 ++++++++++++++++-- .../com/gitee/kooder/query/QueryException.java | 15 +++++++++++++++ .../com/gitee/kooder/query/QueryFactory.java | 15 +++++++++++++++ .../java/com/gitee/kooder/query/RepoQuery.java | 15 +++++++++++++++ .../gitee/kooder/queue/EmbedQueueProvider.java | 15 +++++++++++++++ .../java/com/gitee/kooder/queue/Queue.java | 15 +++++++++++++++ .../com/gitee/kooder/queue/QueueFactory.java | 15 +++++++++++++++ .../com/gitee/kooder/queue/QueueProvider.java | 15 +++++++++++++++ .../java/com/gitee/kooder/queue/QueueTask.java | 15 +++++++++++++++ .../gitee/kooder/queue/RedisQueueProvider.java | 15 +++++++++++++++ .../gitee/kooder/storage/DiskIndexStorage.java | 17 ++++++++++++++++- .../com/gitee/kooder/storage/IndexStorage.java | 15 +++++++++++++++ .../gitee/kooder/storage/StorageFactory.java | 15 +++++++++++++++ .../gitee/kooder/utils/BatchTaskRunner.java | 15 +++++++++++++++ .../com/gitee/kooder/utils/FileClassifier.java | 15 +++++++++++++++ .../kooder/utils/FileClassifierResult.java | 15 +++++++++++++++ .../java/com/gitee/kooder/utils/HttpUtils.java | 15 +++++++++++++++ .../java/com/gitee/kooder/utils/JsonUtils.java | 15 +++++++++++++++ .../com/gitee/kooder/utils/LanguageQuote.java | 15 +++++++++++++++ .../com/gitee/kooder/utils/TextFileUtils.java | 15 +++++++++++++++ .../main/java/com/gitee/kooder/SearchCmd.java | 15 +++++++++++++++ .../com/gitee/kooder/action/GiteaAction.java | 15 +++++++++++++++ .../com/gitee/kooder/action/GiteeAction.java | 15 +++++++++++++++ .../kooder/action/GiteeWebHookManager.java | 15 +++++++++++++++ .../com/gitee/kooder/action/GitlabAction.java | 15 +++++++++++++++ .../kooder/action/GitlabSystemHookManager.java | 15 +++++++++++++++ .../kooder/action/GitlabWebhookManager.java | 15 +++++++++++++++ .../com/gitee/kooder/action/IndexAction.java | 15 +++++++++++++++ .../com/gitee/kooder/action/SearchAction.java | 15 +++++++++++++++ .../gitee/kooder/action/SearchActionBase.java | 15 +++++++++++++++ .../com/gitee/kooder/action/TaskAction.java | 15 +++++++++++++++ .../java/com/gitee/kooder/server/Action.java | 15 +++++++++++++++ .../gitee/kooder/server/ActionExecutor.java | 15 +++++++++++++++ .../server/AutoContentTypeStaticHandler.java | 15 +++++++++++++++ .../java/com/gitee/kooder/server/Gateway.java | 15 +++++++++++++++ .../com/gitee/kooder/server/GatewayBase.java | 15 +++++++++++++++ .../gitee/kooder/server/TemplateEngine.java | 15 +++++++++++++++ .../java/com/gitee/kooder/server/Tester.java | 15 +++++++++++++++ .../com/gitee/kooder/server/VelocityTool.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/Enterprise.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/EnterpriseHook.java | 15 +++++++++++++++ .../java/com/gitee/kooder/gitee/GiteeApi.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/GiteeException.java | 15 +++++++++++++++ .../gitee/kooder/gitee/GiteeIndexThread.java | 15 +++++++++++++++ .../gitee/kooder/gitee/GiteeWebHookEvent.java | 15 +++++++++++++++ .../java/com/gitee/kooder/gitee/Issue.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/IssueWebHook.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/PushWebHook.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/RepoWebHook.java | 15 +++++++++++++++ .../com/gitee/kooder/gitee/Repository.java | 15 +++++++++++++++ .../main/java/com/gitee/kooder/gitee/User.java | 15 +++++++++++++++ .../gitee/kooder/indexer/FetchTaskThread.java | 15 +++++++++++++++ .../gitee/kooder/indexer/GiteaIndexThread.java | 15 +++++++++++++++ .../java/com/gitee/kooder/indexer/Gitlab.java | 15 +++++++++++++++ .../kooder/indexer/GitlabIndexThread.java | 15 +++++++++++++++ .../com/gitee/kooder/indexer/PathImporter.java | 15 +++++++++++++++ .../kooder/indexer/RepositoryIndexer.java | 15 +++++++++++++++ .../com/gitee/kooder/indexer/ServerDaemon.java | 15 +++++++++++++++ 88 files changed, 1323 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/code/CodeFileTraveler.java b/core/src/main/java/com/gitee/kooder/code/CodeFileTraveler.java index 8c781d6..ebae2d6 100644 --- a/core/src/main/java/com/gitee/kooder/code/CodeFileTraveler.java +++ b/core/src/main/java/com/gitee/kooder/code/CodeFileTraveler.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/code/FileRepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/FileRepositoryProvider.java index c22eb97..961f2cb 100644 --- a/core/src/main/java/com/gitee/kooder/code/FileRepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/FileRepositoryProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.models.CodeRepository; diff --git a/core/src/main/java/com/gitee/kooder/code/FileTraveler.java b/core/src/main/java/com/gitee/kooder/code/FileTraveler.java index c184964..90eaa13 100644 --- a/core/src/main/java/com/gitee/kooder/code/FileTraveler.java +++ b/core/src/main/java/com/gitee/kooder/code/FileTraveler.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.models.SourceFile; diff --git a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java index a6cceed..5093c70 100644 --- a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java b/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java index 5a6956b..e0874c9 100644 --- a/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java +++ b/core/src/main/java/com/gitee/kooder/code/RepositoryFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.models.CodeRepository; diff --git a/core/src/main/java/com/gitee/kooder/code/RepositoryManager.java b/core/src/main/java/com/gitee/kooder/code/RepositoryManager.java index 31c908d..41b9b88 100644 --- a/core/src/main/java/com/gitee/kooder/code/RepositoryManager.java +++ b/core/src/main/java/com/gitee/kooder/code/RepositoryManager.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/code/RepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/RepositoryProvider.java index 61b6036..da19009 100644 --- a/core/src/main/java/com/gitee/kooder/code/RepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/RepositoryProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.models.CodeRepository; diff --git a/core/src/main/java/com/gitee/kooder/code/SvnRepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/SvnRepositoryProvider.java index 4a3d80e..27f7abe 100644 --- a/core/src/main/java/com/gitee/kooder/code/SvnRepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/SvnRepositoryProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import com.gitee.kooder.models.CodeRepository; diff --git a/core/src/main/java/com/gitee/kooder/code/TechCodeAnalyzer.java b/core/src/main/java/com/gitee/kooder/code/TechCodeAnalyzer.java index 71cb62b..73b348a 100644 --- a/core/src/main/java/com/gitee/kooder/code/TechCodeAnalyzer.java +++ b/core/src/main/java/com/gitee/kooder/code/TechCodeAnalyzer.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import org.apache.lucene.analysis.*; diff --git a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java index c20ba6e..09ee234 100644 --- a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java +++ b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.code; import org.apache.lucene.analysis.Tokenizer; diff --git a/core/src/main/java/com/gitee/kooder/core/AnalyzerFactory.java b/core/src/main/java/com/gitee/kooder/core/AnalyzerFactory.java index 1ed9e14..1329b6b 100644 --- a/core/src/main/java/com/gitee/kooder/core/AnalyzerFactory.java +++ b/core/src/main/java/com/gitee/kooder/core/AnalyzerFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; import com.gitee.kooder.code.TechCodeAnalyzer; diff --git a/core/src/main/java/com/gitee/kooder/core/Configuration.java b/core/src/main/java/com/gitee/kooder/core/Configuration.java index c7ae8b1..259b598 100644 --- a/core/src/main/java/com/gitee/kooder/core/Configuration.java +++ b/core/src/main/java/com/gitee/kooder/core/Configuration.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; import org.apache.commons.lang3.math.NumberUtils; diff --git a/core/src/main/java/com/gitee/kooder/core/Constants.java b/core/src/main/java/com/gitee/kooder/core/Constants.java index 8fdc5e7..9a54752 100644 --- a/core/src/main/java/com/gitee/kooder/core/Constants.java +++ b/core/src/main/java/com/gitee/kooder/core/Constants.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; /** diff --git a/core/src/main/java/com/gitee/kooder/core/GiteeSearchConfig.java b/core/src/main/java/com/gitee/kooder/core/GiteeSearchConfig.java index 6ce5b73..0eee273 100644 --- a/core/src/main/java/com/gitee/kooder/core/GiteeSearchConfig.java +++ b/core/src/main/java/com/gitee/kooder/core/GiteeSearchConfig.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; import org.slf4j.Logger; diff --git a/core/src/main/java/com/gitee/kooder/core/SearchHelper.java b/core/src/main/java/com/gitee/kooder/core/SearchHelper.java index 84afff6..43d7b09 100644 --- a/core/src/main/java/com/gitee/kooder/core/SearchHelper.java +++ b/core/src/main/java/com/gitee/kooder/core/SearchHelper.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; import com.gitee.kooder.models.CodeLine; diff --git a/core/src/main/java/com/gitee/kooder/core/SearchKey.java b/core/src/main/java/com/gitee/kooder/core/SearchKey.java index fc807fc..d5fc19e 100644 --- a/core/src/main/java/com/gitee/kooder/core/SearchKey.java +++ b/core/src/main/java/com/gitee/kooder/core/SearchKey.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.core; import java.io.BufferedReader; diff --git a/core/src/main/java/com/gitee/kooder/index/IndexException.java b/core/src/main/java/com/gitee/kooder/index/IndexException.java index 9ff3df4..94a2b86 100644 --- a/core/src/main/java/com/gitee/kooder/index/IndexException.java +++ b/core/src/main/java/com/gitee/kooder/index/IndexException.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.index; /** diff --git a/core/src/main/java/com/gitee/kooder/index/IndexManager.java b/core/src/main/java/com/gitee/kooder/index/IndexManager.java index 126cdc0..442cc89 100644 --- a/core/src/main/java/com/gitee/kooder/index/IndexManager.java +++ b/core/src/main/java/com/gitee/kooder/index/IndexManager.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.index; import com.gitee.kooder.core.Constants; @@ -23,7 +38,7 @@ import java.util.List; import java.util.stream.Collectors; /** - * 索引管理器 + * kooder index mananger * @author Winter Lau */ public class IndexManager { diff --git a/core/src/main/java/com/gitee/kooder/models/CodeLine.java b/core/src/main/java/com/gitee/kooder/models/CodeLine.java index 2ed7155..3233d1d 100644 --- a/core/src/main/java/com/gitee/kooder/models/CodeLine.java +++ b/core/src/main/java/com/gitee/kooder/models/CodeLine.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; /** diff --git a/core/src/main/java/com/gitee/kooder/models/CodeOwner.java b/core/src/main/java/com/gitee/kooder/models/CodeOwner.java index d7d97bf..4b8d8d8 100644 --- a/core/src/main/java/com/gitee/kooder/models/CodeOwner.java +++ b/core/src/main/java/com/gitee/kooder/models/CodeOwner.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; /** diff --git a/core/src/main/java/com/gitee/kooder/models/CodeRepository.java b/core/src/main/java/com/gitee/kooder/models/CodeRepository.java index 2a9809a..0381393 100644 --- a/core/src/main/java/com/gitee/kooder/models/CodeRepository.java +++ b/core/src/main/java/com/gitee/kooder/models/CodeRepository.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.code.RepositoryManager; diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index 251fdc9..0cd4c66 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/models/QueryResult.java b/core/src/main/java/com/gitee/kooder/models/QueryResult.java index f342dcd..e61588f 100644 --- a/core/src/main/java/com/gitee/kooder/models/QueryResult.java +++ b/core/src/main/java/com/gitee/kooder/models/QueryResult.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/models/Relation.java b/core/src/main/java/com/gitee/kooder/models/Relation.java index b929175..850ce77 100644 --- a/core/src/main/java/com/gitee/kooder/models/Relation.java +++ b/core/src/main/java/com/gitee/kooder/models/Relation.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; /** diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index f75f1cd..6c61731 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/models/Searchable.java b/core/src/main/java/com/gitee/kooder/models/Searchable.java index 7c4d606..cba46ad 100644 --- a/core/src/main/java/com/gitee/kooder/models/Searchable.java +++ b/core/src/main/java/com/gitee/kooder/models/Searchable.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/models/SourceFile.java b/core/src/main/java/com/gitee/kooder/models/SourceFile.java index 5428c83..396f547 100644 --- a/core/src/main/java/com/gitee/kooder/models/SourceFile.java +++ b/core/src/main/java/com/gitee/kooder/models/SourceFile.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/query/CodeQuery.java b/core/src/main/java/com/gitee/kooder/query/CodeQuery.java index d398a32..dcdf6c8 100644 --- a/core/src/main/java/com/gitee/kooder/query/CodeQuery.java +++ b/core/src/main/java/com/gitee/kooder/query/CodeQuery.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; import com.gitee.kooder.core.AnalyzerFactory; diff --git a/core/src/main/java/com/gitee/kooder/query/IQuery.java b/core/src/main/java/com/gitee/kooder/query/IQuery.java index 65cda58..e356075 100644 --- a/core/src/main/java/com/gitee/kooder/query/IQuery.java +++ b/core/src/main/java/com/gitee/kooder/query/IQuery.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; import com.gitee.kooder.models.QueryResult; diff --git a/core/src/main/java/com/gitee/kooder/query/IssueQuery.java b/core/src/main/java/com/gitee/kooder/query/IssueQuery.java index 4f4ecc7..47949c7 100644 --- a/core/src/main/java/com/gitee/kooder/query/IssueQuery.java +++ b/core/src/main/java/com/gitee/kooder/query/IssueQuery.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; import com.gitee.kooder.core.AnalyzerFactory; diff --git a/core/src/main/java/com/gitee/kooder/query/QueryBase.java b/core/src/main/java/com/gitee/kooder/query/QueryBase.java index 2844b4f..6e00390 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryBase.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryBase.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; import com.gitee.kooder.core.AnalyzerFactory; @@ -9,7 +24,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.IntPoint; -import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.facet.*; import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; import org.apache.lucene.facet.taxonomy.TaxonomyReader; @@ -28,7 +42,7 @@ import java.util.*; import java.util.stream.Collectors; /** - * 搜索基类 + * base class of query * @author Winter Lau */ public abstract class QueryBase implements IQuery { diff --git a/core/src/main/java/com/gitee/kooder/query/QueryException.java b/core/src/main/java/com/gitee/kooder/query/QueryException.java index c82d213..5242c9a 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryException.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryException.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; /** diff --git a/core/src/main/java/com/gitee/kooder/query/QueryFactory.java b/core/src/main/java/com/gitee/kooder/query/QueryFactory.java index a897856..0318a03 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryFactory.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; /** diff --git a/core/src/main/java/com/gitee/kooder/query/RepoQuery.java b/core/src/main/java/com/gitee/kooder/query/RepoQuery.java index 6af6042..16657de 100644 --- a/core/src/main/java/com/gitee/kooder/query/RepoQuery.java +++ b/core/src/main/java/com/gitee/kooder/query/RepoQuery.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.query; import com.gitee.kooder.core.AnalyzerFactory; diff --git a/core/src/main/java/com/gitee/kooder/queue/EmbedQueueProvider.java b/core/src/main/java/com/gitee/kooder/queue/EmbedQueueProvider.java index 73f53e6..893eb14 100644 --- a/core/src/main/java/com/gitee/kooder/queue/EmbedQueueProvider.java +++ b/core/src/main/java/com/gitee/kooder/queue/EmbedQueueProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/core/src/main/java/com/gitee/kooder/queue/Queue.java b/core/src/main/java/com/gitee/kooder/queue/Queue.java index f1fa272..af6743a 100644 --- a/core/src/main/java/com/gitee/kooder/queue/Queue.java +++ b/core/src/main/java/com/gitee/kooder/queue/Queue.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import java.util.Collection; diff --git a/core/src/main/java/com/gitee/kooder/queue/QueueFactory.java b/core/src/main/java/com/gitee/kooder/queue/QueueFactory.java index e61022c..dc49429 100644 --- a/core/src/main/java/com/gitee/kooder/queue/QueueFactory.java +++ b/core/src/main/java/com/gitee/kooder/queue/QueueFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java b/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java index dfba1e6..5fc99dc 100644 --- a/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java +++ b/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/queue/QueueTask.java b/core/src/main/java/com/gitee/kooder/queue/QueueTask.java index 8d22eca..2a26ebb 100644 --- a/core/src/main/java/com/gitee/kooder/queue/QueueTask.java +++ b/core/src/main/java/com/gitee/kooder/queue/QueueTask.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import java.io.IOException; diff --git a/core/src/main/java/com/gitee/kooder/queue/RedisQueueProvider.java b/core/src/main/java/com/gitee/kooder/queue/RedisQueueProvider.java index ff78910..da90ad9 100644 --- a/core/src/main/java/com/gitee/kooder/queue/RedisQueueProvider.java +++ b/core/src/main/java/com/gitee/kooder/queue/RedisQueueProvider.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.queue; import io.lettuce.core.RedisClient; diff --git a/core/src/main/java/com/gitee/kooder/storage/DiskIndexStorage.java b/core/src/main/java/com/gitee/kooder/storage/DiskIndexStorage.java index 2bcac97..2c06195 100644 --- a/core/src/main/java/com/gitee/kooder/storage/DiskIndexStorage.java +++ b/core/src/main/java/com/gitee/kooder/storage/DiskIndexStorage.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.storage; import com.gitee.kooder.core.AnalyzerFactory; @@ -25,7 +40,7 @@ import java.util.Properties; import static com.gitee.kooder.core.Constants.TYPE_CODE; /** - * 磁盘索引管理器 + * store index in disk * @author Winter Lau */ public class DiskIndexStorage implements IndexStorage { diff --git a/core/src/main/java/com/gitee/kooder/storage/IndexStorage.java b/core/src/main/java/com/gitee/kooder/storage/IndexStorage.java index 9f440c4..caa1789 100644 --- a/core/src/main/java/com/gitee/kooder/storage/IndexStorage.java +++ b/core/src/main/java/com/gitee/kooder/storage/IndexStorage.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.storage; import com.gitee.kooder.core.Constants; diff --git a/core/src/main/java/com/gitee/kooder/storage/StorageFactory.java b/core/src/main/java/com/gitee/kooder/storage/StorageFactory.java index 12c493f..1e3662f 100644 --- a/core/src/main/java/com/gitee/kooder/storage/StorageFactory.java +++ b/core/src/main/java/com/gitee/kooder/storage/StorageFactory.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.storage; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/core/src/main/java/com/gitee/kooder/utils/BatchTaskRunner.java b/core/src/main/java/com/gitee/kooder/utils/BatchTaskRunner.java index 9574d36..8628cb0 100644 --- a/core/src/main/java/com/gitee/kooder/utils/BatchTaskRunner.java +++ b/core/src/main/java/com/gitee/kooder/utils/BatchTaskRunner.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; import java.util.List; diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java index 435119c..04e0227 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java index 6810db6..e45cbae 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; /** diff --git a/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java b/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java index 53b215b..269d13a 100644 --- a/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java +++ b/core/src/main/java/com/gitee/kooder/utils/HttpUtils.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; import okhttp3.*; diff --git a/core/src/main/java/com/gitee/kooder/utils/JsonUtils.java b/core/src/main/java/com/gitee/kooder/utils/JsonUtils.java index e2fc7a7..ac46680 100644 --- a/core/src/main/java/com/gitee/kooder/utils/JsonUtils.java +++ b/core/src/main/java/com/gitee/kooder/utils/JsonUtils.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/core/src/main/java/com/gitee/kooder/utils/LanguageQuote.java b/core/src/main/java/com/gitee/kooder/utils/LanguageQuote.java index 13578ff..bd33330 100644 --- a/core/src/main/java/com/gitee/kooder/utils/LanguageQuote.java +++ b/core/src/main/java/com/gitee/kooder/utils/LanguageQuote.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; /** diff --git a/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java b/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java index 2527b5d..838c85c 100644 --- a/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java +++ b/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.utils; import com.glaforge.i18n.io.CharsetToolkit; diff --git a/gateway/src/main/java/com/gitee/kooder/SearchCmd.java b/gateway/src/main/java/com/gitee/kooder/SearchCmd.java index f044c6b..ace8eb2 100644 --- a/gateway/src/main/java/com/gitee/kooder/SearchCmd.java +++ b/gateway/src/main/java/com/gitee/kooder/SearchCmd.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteaAction.java b/gateway/src/main/java/com/gitee/kooder/action/GiteaAction.java index 97a180c..03cd304 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteaAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteaAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.server.Action; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java index 4b2658c..ae66556 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java index e8ab4b5..0da9e85 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GiteeWebHookManager.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java index 222bd7e..3277df9 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.models.CodeRepository; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java index fad444a..1e08aaa 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabSystemHookManager.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import io.vertx.ext.web.RoutingContext; diff --git a/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java index e6fdf49..d0d1f74 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java +++ b/gateway/src/main/java/com/gitee/kooder/action/GitlabWebhookManager.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import io.vertx.ext.web.RoutingContext; diff --git a/gateway/src/main/java/com/gitee/kooder/action/IndexAction.java b/gateway/src/main/java/com/gitee/kooder/action/IndexAction.java index a841ef5..774ddaa 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/IndexAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/IndexAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.server.Action; diff --git a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java index 09ebbdb..0f410ce 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java b/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java index 67df93e..d098c8e 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java +++ b/gateway/src/main/java/com/gitee/kooder/action/SearchActionBase.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/action/TaskAction.java b/gateway/src/main/java/com/gitee/kooder/action/TaskAction.java index 2f34499..3a0a1ae 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/TaskAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/TaskAction.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; diff --git a/gateway/src/main/java/com/gitee/kooder/server/Action.java b/gateway/src/main/java/com/gitee/kooder/server/Action.java index e6583f3..1ec13a1 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Action.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Action.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.queue.QueueTask; diff --git a/gateway/src/main/java/com/gitee/kooder/server/ActionExecutor.java b/gateway/src/main/java/com/gitee/kooder/server/ActionExecutor.java index 7ea47f7..8334c77 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/ActionExecutor.java +++ b/gateway/src/main/java/com/gitee/kooder/server/ActionExecutor.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import io.netty.handler.codec.http.HttpResponseStatus; diff --git a/gateway/src/main/java/com/gitee/kooder/server/AutoContentTypeStaticHandler.java b/gateway/src/main/java/com/gitee/kooder/server/AutoContentTypeStaticHandler.java index c56020e..1292c64 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/AutoContentTypeStaticHandler.java +++ b/gateway/src/main/java/com/gitee/kooder/server/AutoContentTypeStaticHandler.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java index 6578797..786187b 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Gateway.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Gateway.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/gateway/src/main/java/com/gitee/kooder/server/GatewayBase.java b/gateway/src/main/java/com/gitee/kooder/server/GatewayBase.java index 8811632..e31e1af 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/GatewayBase.java +++ b/gateway/src/main/java/com/gitee/kooder/server/GatewayBase.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/gateway/src/main/java/com/gitee/kooder/server/TemplateEngine.java b/gateway/src/main/java/com/gitee/kooder/server/TemplateEngine.java index fd4c065..36be709 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/TemplateEngine.java +++ b/gateway/src/main/java/com/gitee/kooder/server/TemplateEngine.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/gateway/src/main/java/com/gitee/kooder/server/Tester.java b/gateway/src/main/java/com/gitee/kooder/server/Tester.java index a87a084..f7bb99c 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Tester.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Tester.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import org.apache.commons.lang3.StringUtils; diff --git a/gateway/src/main/java/com/gitee/kooder/server/VelocityTool.java b/gateway/src/main/java/com/gitee/kooder/server/VelocityTool.java index d67b51e..256c548 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/VelocityTool.java +++ b/gateway/src/main/java/com/gitee/kooder/server/VelocityTool.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.server; import com.gitee.kooder.models.CodeLine; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java b/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java index 92b02ad..48f5469 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Enterprise.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java index 2c80af3..191439f 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/EnterpriseHook.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java index 019895a..4448342 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeApi.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; import com.fasterxml.jackson.core.type.TypeReference; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java index e236a94..31c344d 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeException.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java index 77661aa..e59e7a0 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeIndexThread.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; import com.gitee.kooder.core.Constants; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java index 25fbcec..7c6942c 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/GiteeWebHookEvent.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; import java.util.Arrays; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java index 1a4de7f..709132c 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java index 127e653..88831b4 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/IssueWebHook.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java index 46b77bd..0f53b09 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/PushWebHook.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java b/indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java index 32c9928..37f58d7 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/RepoWebHook.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java index 99056ee..31690a9 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/User.java b/indexer/src/main/java/com/gitee/kooder/gitee/User.java index b718808..febdaa6 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/User.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/User.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.gitee; /** diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java index eaa3fb5..3129bc9 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import com.gitee.kooder.code.*; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/GiteaIndexThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/GiteaIndexThread.java index 9547a84..d5b064b 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/GiteaIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/GiteaIndexThread.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/Gitlab.java b/indexer/src/main/java/com/gitee/kooder/indexer/Gitlab.java index 52fc046..85429c0 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/Gitlab.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/Gitlab.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import com.gitee.kooder.core.GiteeSearchConfig; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java index c97d306..6c744d6 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/GitlabIndexThread.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import com.gitee.kooder.models.CodeRepository; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/PathImporter.java b/indexer/src/main/java/com/gitee/kooder/indexer/PathImporter.java index 3ef0ca9..cd2403d 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/PathImporter.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/PathImporter.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import com.gitee.kooder.queue.QueueTask; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/RepositoryIndexer.java b/indexer/src/main/java/com/gitee/kooder/indexer/RepositoryIndexer.java index 166028f..ea0eed4 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/RepositoryIndexer.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/RepositoryIndexer.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import org.eclipse.jgit.api.Git; diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/ServerDaemon.java b/indexer/src/main/java/com/gitee/kooder/indexer/ServerDaemon.java index 12c28ad..cbac801 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/ServerDaemon.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/ServerDaemon.java @@ -1,3 +1,18 @@ +/** + * Copyright (c) 2021, OSChina (oschina.net@gmail.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.gitee.kooder.indexer; import org.apache.commons.daemon.Daemon; -- Gitee From 764025a0426529cc71e81c48ad55130850ba36b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 13:58:57 +0800 Subject: [PATCH 17/29] fix warning in sonarqube --- .../gitee/kooder/code/TechCodeTokenizer.java | 2 +- .../com/gitee/kooder/models/Relation.java | 4 ++ .../kooder/queue/EmbedQueueProvider.java | 2 +- .../com/gitee/kooder/queue/QueueProvider.java | 2 +- .../kooder/examples/RangeFacetsExample.java | 41 +++++++++---------- .../gitee/kooder/indexer/FetchTaskThread.java | 3 +- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java index 09ee234..677b8ea 100644 --- a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java +++ b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java @@ -149,7 +149,7 @@ public final class TechCodeTokenizer extends Tokenizer { if(ew.word.indexOf('.', 1)>0) { String[] pics = ew.word.split("\\."); for(int i=0;ibatched().name(type) .folder(typePath) diff --git a/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java b/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java index 5fc99dc..ed67cb2 100644 --- a/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java +++ b/core/src/main/java/com/gitee/kooder/queue/QueueProvider.java @@ -38,7 +38,7 @@ public interface QueueProvider extends AutoCloseable { * 获取支持的所有任务类型 * @return */ - default List types() { + default List getAllTypes() { return TYPES; } diff --git a/gateway/src/main/java/com/gitee/kooder/examples/RangeFacetsExample.java b/gateway/src/main/java/com/gitee/kooder/examples/RangeFacetsExample.java index 894a01f..1b83e63 100644 --- a/gateway/src/main/java/com/gitee/kooder/examples/RangeFacetsExample.java +++ b/gateway/src/main/java/com/gitee/kooder/examples/RangeFacetsExample.java @@ -126,26 +126,25 @@ public class RangeFacetsExample implements Closeable { /** Runs the search and drill-down examples and prints the results. */ public static void main(String[] args) throws Exception { - RangeFacetsExample example = new RangeFacetsExample(); - example.index(); - - System.out.println("Facet counting example:"); - System.out.println("-----------------------"); - System.out.println(example.search()); - - System.out.println("\n"); - System.out.println("Facet drill-down example (timestamp/Past six hours):"); - System.out.println("---------------------------------------------"); - TopDocs hits = example.drillDown(example.PAST_SIX_HOURS); - System.out.println(hits.totalHits + " totalHits"); - - System.out.println("\n"); - System.out.println("Facet drill-sideways example (timestamp/Past six hours):"); - System.out.println("---------------------------------------------"); - DrillSideways.DrillSidewaysResult sideways = example.drillSideways(example.PAST_SIX_HOURS); - System.out.println(sideways.hits.totalHits + " totalHits"); - System.out.println(sideways.facets.getTopChildren(10, "timestamp")); - - example.close(); + try(RangeFacetsExample example = new RangeFacetsExample()) { + example.index(); + + System.out.println("Facet counting example:"); + System.out.println("-----------------------"); + System.out.println(example.search()); + + System.out.println("\n"); + System.out.println("Facet drill-down example (timestamp/Past six hours):"); + System.out.println("---------------------------------------------"); + TopDocs hits = example.drillDown(example.PAST_SIX_HOURS); + System.out.println(hits.totalHits + " totalHits"); + + System.out.println("\n"); + System.out.println("Facet drill-sideways example (timestamp/Past six hours):"); + System.out.println("---------------------------------------------"); + DrillSideways.DrillSidewaysResult sideways = example.drillSideways(example.PAST_SIX_HOURS); + System.out.println(sideways.hits.totalHits + " totalHits"); + System.out.println(sideways.facets.getTopChildren(10, "timestamp")); + } } } \ No newline at end of file diff --git a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java index 3129bc9..69db8c4 100644 --- a/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java +++ b/indexer/src/main/java/com/gitee/kooder/indexer/FetchTaskThread.java @@ -20,7 +20,6 @@ import com.gitee.kooder.core.Constants; import com.gitee.kooder.core.GiteeSearchConfig; import com.gitee.kooder.models.CodeRepository; import com.gitee.kooder.models.Searchable; -import com.gitee.kooder.query.QueryFactory; import com.gitee.kooder.queue.QueueFactory; import com.gitee.kooder.queue.QueueProvider; import com.gitee.kooder.queue.QueueTask; @@ -65,7 +64,7 @@ public class FetchTaskThread extends Thread { public void run() { while(!this.isInterrupted()) { final AtomicInteger taskCount = new AtomicInteger(0); - BatchTaskRunner.execute(provider.types(), 1, types -> { + BatchTaskRunner.execute(provider.getAllTypes(), 1, types -> { for(String type : types) { List tasks = provider.queue(type).pop(batch_fetch_count); if(tasks != null && tasks.size() > 0) { -- Gitee From 2e07d278e9d41ffdf1f3b2e52b2dca781b34078a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 14:01:42 +0800 Subject: [PATCH 18/29] fix error in sonarqube --- core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java index 677b8ea..8dabf6e 100644 --- a/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java +++ b/core/src/main/java/com/gitee/kooder/code/TechCodeTokenizer.java @@ -149,7 +149,7 @@ public final class TechCodeTokenizer extends Tokenizer { if(ew.word.indexOf('.', 1)>0) { String[] pics = ew.word.split("\\."); for(int i=0;i Date: Thu, 18 Feb 2021 16:44:39 +0800 Subject: [PATCH 19/29] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E5=AD=98=E5=82=A8=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kooder/code/GitRepositoryProvider.java | 3 + .../java/com/gitee/kooder/models/Issue.java | 32 +++----- .../com/gitee/kooder/models/Repository.java | 75 +++++++------------ .../com/gitee/kooder/models/Searchable.java | 22 ++++++ .../com/gitee/kooder/models/SourceFile.java | 35 +++++---- .../com/gitee/kooder/query/QueryBase.java | 14 ++-- .../com/gitee/kooder/action/SearchAction.java | 4 +- 7 files changed, 91 insertions(+), 94 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java index 5093c70..eedfb1c 100644 --- a/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java +++ b/core/src/main/java/com/gitee/kooder/code/GitRepositoryProvider.java @@ -191,6 +191,7 @@ public class GitRepositoryProvider implements RepositoryProvider { for (DiffEntry entry : entries) { if (entry.getChangeType() == DiffEntry.ChangeType.DELETE && traveler != null) { SourceFile doc = new SourceFile(repo.getId(), repo.getName(), entry.getOldPath()); + doc.setEnterprise(repo.getEnterprise()); traveler.deleteDocument(doc); } else { addFileToDocument(repo, git, entry.getNewPath(), entry.getNewId().toObjectId(), traveler); @@ -345,6 +346,7 @@ public class GitRepositoryProvider implements RepositoryProvider { String contents = String.join("\n", codeLines); SourceFile doc = new SourceFile(); + doc.setEnterprise(repo.getEnterprise()); doc.setRepository(new Relation(repo.getId(), repo.getName(), repo.getUrl())); doc.setBranch(git.getRepository().getBranch()); doc.setName(FilenameUtils.getName(path)); //文件名 @@ -380,6 +382,7 @@ public class GitRepositoryProvider implements RepositoryProvider { private SourceFile buildBinaryDocument(CodeRepository repo, Git git, String path, ObjectId objectId) throws IOException { SourceFile doc = new SourceFile(); + doc.setEnterprise(repo.getEnterprise()); doc.setRepository(new Relation(repo.getId(), repo.getName(), repo.getUrl())); doc.setBranch(git.getRepository().getBranch()); doc.setName(FilenameUtils.getName(path)); //文件名 diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index 0cd4c66..77f06a2 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -137,38 +137,26 @@ public final class Issue extends Searchable { doc.add(new StoredField(Constants.FIELD_URL, url)); doc.add(new TextField(Constants.FIELD_TAGS, String.join("\n", labels), Field.Store.NO)); - doc.add(new NumericDocValuesField(Constants.FIELD_CREATED_AT, createdAt)); - doc.add(new StoredField(Constants.FIELD_CREATED_AT, createdAt)); - doc.add(new NumericDocValuesField(Constants.FIELD_UPDATED_AT, updatedAt)); - doc.add(new StoredField(Constants.FIELD_UPDATED_AT, updatedAt)); - doc.add(new NumericDocValuesField(Constants.FIELD_CLOSED_AT, closedAt)); - doc.add(new StoredField(Constants.FIELD_CLOSED_AT, closedAt)); + super.addNumToDoc(doc, Constants.FIELD_CREATED_AT, createdAt); + super.addNumToDoc(doc, Constants.FIELD_UPDATED_AT, updatedAt); + super.addNumToDoc(doc, Constants.FIELD_CLOSED_AT, closedAt); - doc.add(new IntPoint(Constants.FIELD_BLOCK, block)); - doc.add(new StoredField(Constants.FIELD_BLOCK, block)); - - doc.add(new IntPoint(Constants.FIELD_VISIBILITY, visibility)); - doc.add(new StoredField(Constants.FIELD_VISIBILITY, visibility)); - - doc.add(new IntPoint(Constants.FIELD_STATUS, state)); - doc.add(new StoredField(Constants.FIELD_STATUS, state)); + super.addIntToDoc(doc, Constants.FIELD_BLOCK, block); + super.addIntToDoc(doc, Constants.FIELD_VISIBILITY, visibility); + super.addIntToDoc(doc, Constants.FIELD_STATUS, state); //enterprise info (just for gitee) enterprise: - doc.add(new LongPoint(Constants.FIELD_ENTERPRISE_ID, this.enterprise.id)); - doc.add(new StoredField(Constants.FIELD_ENTERPRISE_ID, enterprise.id)); + super.addLongToDoc(doc, Constants.FIELD_ENTERPRISE_ID, this.enterprise.id); //program info (just for gitee) program: - doc.add(new LongPoint(Constants.FIELD_PROGRAM_ID, this.project.id)); - doc.add(new StoredField(Constants.FIELD_PROGRAM_ID, project.id)); + super.addLongToDoc(doc, Constants.FIELD_PROGRAM_ID, this.project.id); //repository info (just for gitee) repository: - doc.add(new LongPoint(Constants.FIELD_REPO_ID, this.repository.id)); - doc.add(new StoredField(Constants.FIELD_REPO_ID, repository.id)); + super.addLongToDoc(doc, Constants.FIELD_REPO_ID, this.repository.id); //owner info owner: - doc.add(new LongPoint(Constants.FIELD_USER_ID, this.owner.id)); - doc.add(new StoredField(Constants.FIELD_USER_ID, owner.id)); + super.addLongToDoc(doc, Constants.FIELD_USER_ID, this.owner.id); return doc; } diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index 6c61731..a94c0bb 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -19,7 +19,6 @@ import com.gitee.kooder.core.Constants; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.lucene.document.*; -import org.apache.lucene.facet.FacetField; import org.gitlab4j.api.models.Project; import org.gitlab4j.api.models.Visibility; @@ -98,43 +97,26 @@ public final class Repository extends Searchable { if(StringUtils.isNotBlank(this.getUrl())) doc.add(new StoredField(Constants.FIELD_URL, this.getUrl())); - doc.add(new NumericDocValuesField(Constants.FIELD_RECOMM, recomm)); - doc.add(new StoredField(Constants.FIELD_RECOMM, recomm)); + super.addNumToDoc(doc, Constants.FIELD_RECOMM, recomm); + super.addNumToDoc(doc, Constants.FIELD_G_INDEX, gindex); + super.addNumToDoc(doc, Constants.FIELD_BLOCK, block); + super.addIntToDoc(doc, Constants.FIELD_VISIBILITY, visibility); - doc.add(new NumericDocValuesField(Constants.FIELD_G_INDEX, gindex)); - doc.add(new StoredField(Constants.FIELD_G_INDEX, gindex)); + if(StringUtils.isNotBlank(license)) + super.addFacetToDoc(doc, Constants.FIELD_LICENSE, license); - doc.add(new IntPoint(Constants.FIELD_BLOCK, block)); - doc.add(new StoredField(Constants.FIELD_BLOCK, block)); - - doc.add(new IntPoint(Constants.FIELD_VISIBILITY, visibility)); - doc.add(new StoredField(Constants.FIELD_VISIBILITY, visibility)); - - if(StringUtils.isNotBlank(license)) { - doc.add(new FacetField(Constants.FIELD_LICENSE, license)); - doc.add(new StringField(Constants.FIELD_LICENSE, license, Field.Store.YES)); - } - - if(StringUtils.isNotBlank(lang)) { - doc.add(new FacetField(Constants.FIELD_LANGUAGE, lang)); - doc.add(new StringField(Constants.FIELD_LANGUAGE, lang, Field.Store.YES)); - } + if(StringUtils.isNotBlank(lang)) + super.addFacetToDoc(doc, Constants.FIELD_LANGUAGE, lang); if(StringUtils.isNotBlank(readme)) doc.add(new TextField(Constants.FIELD_README, readme, Field.Store.NO)); - doc.add(new LongPoint(Constants.FIELD_FORK, fork)); - doc.add(new StoredField(Constants.FIELD_FORK, fork)); - - doc.add(new NumericDocValuesField(Constants.FIELD_STAR_COUNT, starsCount)); - doc.add(new StoredField(Constants.FIELD_STAR_COUNT, starsCount)); - doc.add(new NumericDocValuesField(Constants.FIELD_FORK_COUNT, forksCount)); - doc.add(new StoredField(Constants.FIELD_FORK_COUNT, forksCount)); - doc.add(new NumericDocValuesField(Constants.FIELD_CREATED_AT, createdAt)); - doc.add(new StoredField(Constants.FIELD_CREATED_AT, createdAt)); - doc.add(new NumericDocValuesField(Constants.FIELD_UPDATED_AT, updatedAt)); - doc.add(new StoredField(Constants.FIELD_UPDATED_AT, updatedAt)); + super.addLongToDoc(doc, Constants.FIELD_FORK, fork); + super.addNumToDoc(doc, Constants.FIELD_STAR_COUNT, starsCount); + super.addNumToDoc(doc, Constants.FIELD_FORK_COUNT, forksCount); + super.addNumToDoc(doc, Constants.FIELD_CREATED_AT, createdAt); + super.addNumToDoc(doc, Constants.FIELD_UPDATED_AT, updatedAt); //tags if(tags != null) @@ -145,32 +127,27 @@ public final class Repository extends Searchable { //enterprise info (just for gitee) enterprise: - doc.add(new LongPoint(Constants.FIELD_ENTERPRISE_ID, this.enterprise.id)); - doc.add(new StringField(Constants.FIELD_ENTERPRISE_ID, String.valueOf(enterprise.id), Field.Store.YES)); - if(StringUtils.isNotBlank(enterprise.name)) { - doc.add(new FacetField(Constants.FIELD_ENTERPRISE_NAME, enterprise.name)); - doc.add(new TextField(Constants.FIELD_ENTERPRISE_NAME, enterprise.name, Field.Store.YES)); - } + super.addLongToDoc(doc, Constants.FIELD_ENTERPRISE_ID, this.enterprise.id); + if(StringUtils.isNotBlank(enterprise.name)) + super.addFacetToDoc(doc, Constants.FIELD_ENTERPRISE_NAME, enterprise.name); + if(StringUtils.isNotBlank(enterprise.url)) doc.add(new StoredField(Constants.FIELD_ENTERPRISE_URL, enterprise.url)); //program info (just for gitee) program: - doc.add(new LongPoint(Constants.FIELD_PROGRAM_ID, this.project.id)); - doc.add(new StringField(Constants.FIELD_PROGRAM_ID, String.valueOf(project.id), Field.Store.YES)); - if(StringUtils.isNotBlank(project.name)) { - doc.add(new FacetField(Constants.FIELD_PROGRAM_NAME, project.name)); - doc.add(new TextField(Constants.FIELD_PROGRAM_NAME, project.name, Field.Store.YES)); - } + super.addLongToDoc(doc, Constants.FIELD_PROGRAM_ID, this.project.id); + if(StringUtils.isNotBlank(project.name)) + super.addFacetToDoc(doc, Constants.FIELD_PROGRAM_NAME, project.name); + if(StringUtils.isNotBlank(project.url)) doc.add(new StoredField(Constants.FIELD_PROGRAM_URL, project.url)); //owner info owner: - doc.add(new LongPoint(Constants.FIELD_USER_ID, this.owner.id)); - doc.add(new StringField(Constants.FIELD_USER_ID, String.valueOf(owner.id), Field.Store.YES)); - if(StringUtils.isNotBlank(owner.name)) { - doc.add(new FacetField(Constants.FIELD_USER_NAME, owner.name)); - doc.add(new TextField(Constants.FIELD_USER_NAME, owner.name, Field.Store.YES)); - } + super.addLongToDoc(doc, Constants.FIELD_USER_ID, this.owner.id); + + if(StringUtils.isNotBlank(owner.name)) + super.addFacetToDoc(doc, Constants.FIELD_USER_NAME, owner.name); + if(StringUtils.isNotBlank(owner.url)) doc.add(new StoredField(Constants.FIELD_USER_URL, owner.url)); diff --git a/core/src/main/java/com/gitee/kooder/models/Searchable.java b/core/src/main/java/com/gitee/kooder/models/Searchable.java index cba46ad..0df5e65 100644 --- a/core/src/main/java/com/gitee/kooder/models/Searchable.java +++ b/core/src/main/java/com/gitee/kooder/models/Searchable.java @@ -18,7 +18,9 @@ package com.gitee.kooder.models; import com.gitee.kooder.core.Constants; import org.apache.commons.lang3.math.NumberUtils; import org.apache.lucene.document.*; +import org.apache.lucene.facet.FacetField; +import javax.print.Doc; import java.io.Serializable; /** @@ -86,4 +88,24 @@ public abstract class Searchable implements Serializable { return NumberUtils.toInt(doc.get(fieldName), def); } + protected void addLongToDoc(Document doc, String fn, long fv) { + doc.add(new LongPoint(fn, fv)); + doc.add(new StoredField(fn, String.valueOf(fv))); + } + + protected void addIntToDoc(Document doc, String fn, int fv) { + doc.add(new IntPoint(fn, fv)); + doc.add(new StoredField(fn, String.valueOf(fv))); + } + + protected void addFacetToDoc(Document doc, String fn, String fv) { + doc.add(new FacetField(fn, fv)); + doc.add(new TextField(fn, fv, Field.Store.YES)); + } + + protected void addNumToDoc(Document doc, String fn, long fv) { + doc.add(new NumericDocValuesField(fn, fv)); + doc.add(new StoredField(fn, fv)); + } + } diff --git a/core/src/main/java/com/gitee/kooder/models/SourceFile.java b/core/src/main/java/com/gitee/kooder/models/SourceFile.java index 396f547..08eb729 100644 --- a/core/src/main/java/com/gitee/kooder/models/SourceFile.java +++ b/core/src/main/java/com/gitee/kooder/models/SourceFile.java @@ -20,7 +20,6 @@ import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.lucene.document.*; -import org.apache.lucene.facet.FacetField; /** * Source File Object @@ -29,6 +28,7 @@ import org.apache.lucene.facet.FacetField; public final class SourceFile extends Searchable { private String uuid; // file unique identify + private int enterprise; // enterpise private Relation repository = Relation.EMPTY; //repository, use this field to delete all files of repository private String branch; // branch name @@ -76,6 +76,7 @@ public final class SourceFile extends Searchable { @Override public SourceFile setDocument(Document doc) { this.uuid = doc.get(Constants.FIELD_UUID); + this.enterprise = NumberUtils.toInt(doc.get(Constants.FIELD_ENTERPRISE_ID), 0); this.repository.id = NumberUtils.toInt(doc.get(Constants.FIELD_REPO_ID)); this.repository.name = doc.get(Constants.FIELD_REPO_NAME); this.repository.url = doc.get(Constants.FIELD_REPO_URL); @@ -111,22 +112,19 @@ public final class SourceFile extends Searchable { document.add(new StringField(Constants.FIELD_BRANCH, this.branch, Field.Store.YES)); document.add(new StoredField(Constants.FIELD_URL, this.url)); + super.addLongToDoc(document, Constants.FIELD_ENTERPRISE_ID, this.enterprise); + //repository info - document.add(new LongPoint(Constants.FIELD_REPO_ID, this.repository.id)); - document.add(new StoredField(Constants.FIELD_REPO_ID, this.repository.id)); - document.add(new FacetField(Constants.FIELD_REPO_NAME, this.repository.name)); - document.add(new StringField(Constants.FIELD_REPO_NAME, this.repository.name, Field.Store.YES)); + super.addLongToDoc(document, Constants.FIELD_REPO_ID, this.repository.id); + super.addFacetToDoc(document, Constants.FIELD_REPO_NAME, this.repository.name); document.add(new StringField(Constants.FIELD_REPO_URL, this.repository.url, Field.Store.YES)); //file meta - if (StringUtils.isNotBlank(language)) { - document.add(new FacetField(Constants.FIELD_LANGUAGE, this.getLanguage())); - document.add(new StringField(Constants.FIELD_LANGUAGE, this.getLanguage(), Field.Store.YES)); - } - if (StringUtils.isNotBlank(codeOwner)) { - document.add(new FacetField(Constants.FIELD_CODE_OWNER, this.getCodeOwner())); - document.add(new TextField(Constants.FIELD_CODE_OWNER, this.getCodeOwner(), Field.Store.YES)); - } + if (StringUtils.isNotBlank(language)) + super.addFacetToDoc(document, Constants.FIELD_LANGUAGE, this.language); + + if (StringUtils.isNotBlank(codeOwner)) + super.addFacetToDoc(document, Constants.FIELD_CODE_OWNER, this.codeOwner); //file info document.add(new TextField(Constants.FIELD_FILE_NAME, this.getName(), Field.Store.YES)); @@ -149,8 +147,7 @@ public final class SourceFile extends Searchable { // Extra metadata in this case when it was last indexed long indexTime = System.currentTimeMillis(); - document.add(new NumericDocValuesField(Constants.FIELD_LAST_INDEX, indexTime)); - document.add(new StoredField(Constants.FIELD_LAST_INDEX, indexTime)); + super.addNumToDoc(document, Constants.FIELD_LAST_INDEX, indexTime); return document; } @@ -282,4 +279,12 @@ public final class SourceFile extends Searchable { public void setRevision(String revision) { this.revision = revision; } + + public int getEnterprise() { + return enterprise; + } + + public void setEnterprise(int enterprise) { + this.enterprise = enterprise; + } } diff --git a/core/src/main/java/com/gitee/kooder/query/QueryBase.java b/core/src/main/java/com/gitee/kooder/query/QueryBase.java index 6e00390..c18d4f0 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryBase.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryBase.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.IntPoint; +import org.apache.lucene.document.LongPoint; import org.apache.lucene.facet.*; import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; import org.apache.lucene.facet.taxonomy.TaxonomyReader; @@ -52,14 +53,14 @@ public abstract class QueryBase implements IQuery { public final static FacetsConfig facetsConfig = new FacetsConfig(); private int enterpriseId = 0; // Search in Enterprise - private List repositories = new ArrayList<>(); // Search in repositories + private List repositories = new ArrayList(); // Search in repositories protected String searchKey; // Search Keyword protected boolean parseSearchKey = false; // Escape Search key ? protected String sort; // Sort field name protected int page = 1; // Search result page index protected int pageSize = 20; // Search result page size protected Map facets = new HashMap(); // Search with facets - protected List filters = new ArrayList<>(); // Search filters + protected List filters = new ArrayList(); // Search filters /** * Get max object indexed . @@ -192,11 +193,12 @@ public abstract class QueryBase implements IQuery { return query; BooleanQuery.Builder fBuilder = new BooleanQuery.Builder(); + if(enterpriseId > 0) - fBuilder.add(new TermQuery(new Term(Constants.FIELD_ENTERPRISE_ID, String.valueOf(this.getEnterpriseId()))), BooleanClause.Occur.FILTER); + fBuilder.add(LongPoint.newExactQuery(Constants.FIELD_ENTERPRISE_ID, this.getEnterpriseId()), BooleanClause.Occur.FILTER); if(repositories.size() > 0) - fBuilder.add(IntPoint.newSetQuery(Constants.FIELD_REPO_ID, repositories), BooleanClause.Occur.FILTER); + fBuilder.add(LongPoint.newSetQuery(Constants.FIELD_REPO_ID, repositories), BooleanClause.Occur.FILTER); for(Query filter : filters) fBuilder.add(filter, BooleanClause.Occur.FILTER); @@ -274,11 +276,11 @@ public abstract class QueryBase implements IQuery { return this; } - public List getRepositories() { + public List getRepositories() { return repositories; } - public QueryBase addRepositories(List repositories) { + public QueryBase addRepositories(List repositories) { this.repositories.addAll(repositories); return this; } diff --git a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java index 0f410ce..59a98d7 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java @@ -78,7 +78,7 @@ public class SearchAction implements SearchActionBase { String body = context.getBodyAsString(); if(body != null) repos.addAll(Arrays.asList(body.split(","))); - List iRepos = repos.stream().map(r -> NumberUtils.toInt(r, 0)).filter(r -> (r > 0)).collect(Collectors.toList()); + List iRepos = repos.stream().map(r -> NumberUtils.toLong(r, 0)).filter(r -> (r > 0)).collect(Collectors.toList()); QueryResult result = QueryFactory.REPO() .setEnterpriseId(eid) @@ -129,7 +129,7 @@ public class SearchAction implements SearchActionBase { String body = context.getBodyAsString(); if(body != null) repos.addAll(Arrays.asList(body.split(","))); - List iRepos = repos.stream().map(r -> NumberUtils.toInt(r, 0)).filter(r -> (r > 0)).collect(Collectors.toList()); + List iRepos = repos.stream().map(r -> NumberUtils.toLong(r, 0)).filter(r -> (r > 0)).collect(Collectors.toList()); QueryResult result = QueryFactory.CODE() .setEnterpriseId(eid) -- Gitee From 61ed152daee2688fa94f398c7d1ea44853a428ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 16:45:24 +0800 Subject: [PATCH 20/29] remove unused import --- core/src/main/java/com/gitee/kooder/models/Searchable.java | 1 - core/src/main/java/com/gitee/kooder/query/QueryBase.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/models/Searchable.java b/core/src/main/java/com/gitee/kooder/models/Searchable.java index 0df5e65..2d81812 100644 --- a/core/src/main/java/com/gitee/kooder/models/Searchable.java +++ b/core/src/main/java/com/gitee/kooder/models/Searchable.java @@ -20,7 +20,6 @@ import org.apache.commons.lang3.math.NumberUtils; import org.apache.lucene.document.*; import org.apache.lucene.facet.FacetField; -import javax.print.Doc; import java.io.Serializable; /** diff --git a/core/src/main/java/com/gitee/kooder/query/QueryBase.java b/core/src/main/java/com/gitee/kooder/query/QueryBase.java index c18d4f0..803bce9 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryBase.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryBase.java @@ -23,14 +23,12 @@ import com.gitee.kooder.storage.StorageFactory; import org.apache.commons.lang3.StringUtils; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; -import org.apache.lucene.document.IntPoint; import org.apache.lucene.document.LongPoint; import org.apache.lucene.facet.*; import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; import org.apache.lucene.facet.taxonomy.TaxonomyReader; import org.apache.lucene.index.IndexNotFoundException; import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.Term; import org.apache.lucene.queries.function.FunctionScoreQuery; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.queryparser.classic.QueryParser; -- Gitee From 49b43d50fea09d152c30b626907b5e22d6a8db5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 18:01:29 +0800 Subject: [PATCH 21/29] add code highlight result to code api --- .../com/gitee/kooder/models/SourceFile.java | 18 +++++++++++++++++- .../com/gitee/kooder/action/SearchAction.java | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/gitee/kooder/models/SourceFile.java b/core/src/main/java/com/gitee/kooder/models/SourceFile.java index 08eb729..319138d 100644 --- a/core/src/main/java/com/gitee/kooder/models/SourceFile.java +++ b/core/src/main/java/com/gitee/kooder/models/SourceFile.java @@ -15,12 +15,15 @@ */ package com.gitee.kooder.models; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.gitee.kooder.core.Constants; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.apache.lucene.document.*; +import java.util.List; + /** * Source File Object * @author Winter Lau @@ -48,6 +51,8 @@ public final class SourceFile extends Searchable { private String revision; // last commit id + private List result; // code lines with keyword highlight + public SourceFile() {} public SourceFile(long repoId, String repoName, String fileLocation) { @@ -74,6 +79,7 @@ public final class SourceFile extends Searchable { * @param doc */ @Override + @JsonIgnore public SourceFile setDocument(Document doc) { this.uuid = doc.get(Constants.FIELD_UUID); this.enterprise = NumberUtils.toInt(doc.get(Constants.FIELD_ENTERPRISE_ID), 0); @@ -103,13 +109,15 @@ public final class SourceFile extends Searchable { * @return */ @Override + @JsonIgnore public Document getDocument() { Document document = new Document(); // Uuid is the primary key for documents document.add(new StringField(Constants.FIELD_UUID, this.uuid, Field.Store.YES)); - document.add(new StringField(Constants.FIELD_BRANCH, this.branch, Field.Store.YES)); + if(StringUtils.isNotBlank(this.branch)) + document.add(new StringField(Constants.FIELD_BRANCH, this.branch, Field.Store.YES)); document.add(new StoredField(Constants.FIELD_URL, this.url)); super.addLongToDoc(document, Constants.FIELD_ENTERPRISE_ID, this.enterprise); @@ -287,4 +295,12 @@ public final class SourceFile extends Searchable { public void setEnterprise(int enterprise) { this.enterprise = enterprise; } + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } } diff --git a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java index 59a98d7..57632cb 100644 --- a/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java +++ b/gateway/src/main/java/com/gitee/kooder/action/SearchAction.java @@ -16,7 +16,10 @@ package com.gitee.kooder.action; import com.gitee.kooder.core.Constants; +import com.gitee.kooder.core.SearchHelper; import com.gitee.kooder.models.QueryResult; +import com.gitee.kooder.models.Searchable; +import com.gitee.kooder.models.SourceFile; import com.gitee.kooder.query.QueryFactory; import io.netty.handler.codec.http.HttpResponseStatus; import io.vertx.core.http.HttpServerRequest; @@ -34,6 +37,8 @@ import java.util.stream.Collectors; */ public class SearchAction implements SearchActionBase { + private final static int MAX_LINES = 20; // max code lines in highlight + /** * controller for search.vm * @param context @@ -143,6 +148,11 @@ public class SearchAction implements SearchActionBase { .setPageSize(PAGE_SIZE) .execute(); + for(Searchable obj : result.getObjects()) { + SourceFile file = (SourceFile) obj; + file.setResult(SearchHelper.hl_lines(file.getContents(), q, MAX_LINES)); + } + this.json(context.response(), result.json()); } -- Gitee From 32b390c9eea524bf160f42e03e0cfd67e56473cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 18:02:02 +0800 Subject: [PATCH 22/29] ignore getDocument in json serializable --- core/src/main/java/com/gitee/kooder/models/Issue.java | 3 +++ core/src/main/java/com/gitee/kooder/models/Repository.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index 77f06a2..f1da0f9 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -15,6 +15,7 @@ */ package com.gitee.kooder.models; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.gitee.kooder.core.Constants; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -99,6 +100,7 @@ public final class Issue extends Searchable { * @param doc */ @Override + @JsonIgnore public Issue setDocument(Document doc) { this.id = NumberUtils.toInt(doc.get(Constants.FIELD_ID), 0); this.ident = doc.get(Constants.FIELD_IDENT); @@ -128,6 +130,7 @@ public final class Issue extends Searchable { * @return */ @Override + @JsonIgnore public Document getDocument() { Document doc = super.newDocument(); diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index a94c0bb..ba63442 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -15,6 +15,7 @@ */ package com.gitee.kooder.models; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.gitee.kooder.core.Constants; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -87,6 +88,7 @@ public final class Repository extends Searchable { * @return */ @Override + @JsonIgnore public Document getDocument() { Document doc = super.newDocument(); doc.add(new TextField(Constants.FIELD_NAME, this.getName(), Field.Store.YES)); @@ -160,6 +162,7 @@ public final class Repository extends Searchable { * @param doc */ @Override + @JsonIgnore public Repository setDocument(Document doc) { this.id = NumberUtils.toInt(doc.get(Constants.FIELD_ID), 0); this.name = doc.get(Constants.FIELD_NAME); -- Gitee From 72ab26a207fc616c69a9d84785901f850439c27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 18:02:30 +0800 Subject: [PATCH 23/29] rename properties _id and _score to _doc_id and _doc_score --- .../com/gitee/kooder/models/QueryResult.java | 12 +++++------ .../com/gitee/kooder/models/Searchable.java | 20 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/models/QueryResult.java b/core/src/main/java/com/gitee/kooder/models/QueryResult.java index e61588f..3816587 100644 --- a/core/src/main/java/com/gitee/kooder/models/QueryResult.java +++ b/core/src/main/java/com/gitee/kooder/models/QueryResult.java @@ -58,21 +58,21 @@ public class QueryResult { case Constants.TYPE_REPOSITORY: Repository repo = new Repository(); repo.setDocument(doc); - repo.set_id(doc_score.doc); - repo.set_score(doc_score.score); + repo.set_doc_id(doc_score.doc); + repo.set_doc_score(doc_score.score); addObject(repo); break; case Constants.TYPE_ISSUE: Issue issue = new Issue(doc); - issue.set_id(doc_score.doc); - issue.set_score(doc_score.score); + issue.set_doc_id(doc_score.doc); + issue.set_doc_score(doc_score.score); addObject(issue); break; case Constants.TYPE_CODE: SourceFile file = new SourceFile(); file.setDocument(doc); - file.set_id(doc_score.doc); - file.set_score(doc_score.score); + file.set_doc_id(doc_score.doc); + file.set_doc_score(doc_score.score); addObject(file); } } diff --git a/core/src/main/java/com/gitee/kooder/models/Searchable.java b/core/src/main/java/com/gitee/kooder/models/Searchable.java index 2d81812..b24c744 100644 --- a/core/src/main/java/com/gitee/kooder/models/Searchable.java +++ b/core/src/main/java/com/gitee/kooder/models/Searchable.java @@ -29,8 +29,8 @@ import java.io.Serializable; public abstract class Searchable implements Serializable { protected long id; // object id , ex: repo id, issue id - protected int _id; // document id - protected float _score; // document score + protected int _doc_id; // document id + protected float _doc_score; // document score public long getId() { return id; @@ -40,20 +40,20 @@ public abstract class Searchable implements Serializable { this.id = id; } - public int get_id() { - return _id; + public int get_doc_id() { + return _doc_id; } - public void set_id(int _id) { - this._id = _id; + public void set_doc_id(int _doc_id) { + this._doc_id = _doc_id; } - public float get_score() { - return _score; + public float get_doc_score() { + return _doc_score; } - public void set_score(float _score) { - this._score = _score; + public void set_doc_score(float _doc_score) { + this._doc_score = _doc_score; } protected Document newDocument() { -- Gitee From 6a410436093a5b631e7926c9b35cfbd468ba06a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Thu, 18 Feb 2021 18:40:53 +0800 Subject: [PATCH 24/29] Relation.EMPTY() --- .../main/java/com/gitee/kooder/models/Issue.java | 16 ++++++++-------- .../java/com/gitee/kooder/models/Relation.java | 6 ++++-- .../java/com/gitee/kooder/models/Repository.java | 10 +++++----- .../java/com/gitee/kooder/models/SourceFile.java | 2 +- .../main/java/com/gitee/kooder/gitee/Issue.java | 1 - .../java/com/gitee/kooder/gitee/Repository.java | 1 - 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/models/Issue.java b/core/src/main/java/com/gitee/kooder/models/Issue.java index f1da0f9..e7c3a94 100644 --- a/core/src/main/java/com/gitee/kooder/models/Issue.java +++ b/core/src/main/java/com/gitee/kooder/models/Issue.java @@ -38,10 +38,10 @@ public final class Issue extends Searchable { public final static int STATE_REOPENED = 0x03; protected String ident; - protected Relation enterprise = Relation.EMPTY; - protected Relation project = Relation.EMPTY; - protected Relation repository = Relation.EMPTY; - protected Relation owner = Relation.EMPTY ; + protected Relation enterprise = Relation.EMPTY(); + protected Relation project = Relation.EMPTY(); + protected Relation repository = Relation.EMPTY(); + protected Relation owner = Relation.EMPTY(); protected String title; protected String description; @@ -59,8 +59,8 @@ public final class Issue extends Searchable { public Issue(org.gitlab4j.api.models.Issue issue) { this.id = issue.getId(); this.ident = issue.getProjectId() + "_" + issue.getId(); - this.enterprise = Relation.EMPTY; - this.project = Relation.EMPTY; + //this.enterprise = Relation.EMPTY(); + //this.project = Relation.EMPTY(); this.repository = new Relation(issue.getProjectId(), null, null); this.owner = new Relation(issue.getAuthor().getId(), issue.getAuthor().getName(), issue.getAuthor().getWebUrl()); this.title = issue.getTitle(); @@ -76,8 +76,8 @@ public final class Issue extends Searchable { public Issue(IssueEvent e) { this.id = e.getObjectAttributes().getId(); this.ident = e.getProject().getId() + "_" + this.id; - this.enterprise = Relation.EMPTY; - this.project = Relation.EMPTY; + //this.enterprise = Relation.EMPTY(); + //this.project = Relation.EMPTY(); this.repository = new Relation(e.getProject().getId(), e.getProject().getName(), e.getProject().getUrl()); this.owner = new Relation(e.getObjectAttributes().getAuthorId(), e.getUser().getName(), e.getUser().getWebUrl()); this.title = e.getObjectAttributes().getTitle(); diff --git a/core/src/main/java/com/gitee/kooder/models/Relation.java b/core/src/main/java/com/gitee/kooder/models/Relation.java index 7af0aaf..4c8248b 100644 --- a/core/src/main/java/com/gitee/kooder/models/Relation.java +++ b/core/src/main/java/com/gitee/kooder/models/Relation.java @@ -21,8 +21,6 @@ package com.gitee.kooder.models; */ public final class Relation { - public final static Relation EMPTY = new Relation(0, "NONE", null); - protected long id; protected String name; protected String url; @@ -35,6 +33,10 @@ public final class Relation { this.url = url; } + public final static Relation EMPTY() { + return new Relation(0, "NONE", null); + } + public long getId() { return id; } diff --git a/core/src/main/java/com/gitee/kooder/models/Repository.java b/core/src/main/java/com/gitee/kooder/models/Repository.java index ba63442..df3f0ee 100644 --- a/core/src/main/java/com/gitee/kooder/models/Repository.java +++ b/core/src/main/java/com/gitee/kooder/models/Repository.java @@ -35,9 +35,9 @@ public final class Repository extends Searchable { protected String displayName; //nameWithNamespace protected String description; protected String url; - protected Relation enterprise = Relation.EMPTY; - protected Relation project = Relation.EMPTY; - protected Relation owner = Relation.EMPTY; + protected Relation enterprise = Relation.EMPTY(); + protected Relation project = Relation.EMPTY(); + protected Relation owner = Relation.EMPTY(); protected int recomm; //推荐级别 protected int gindex; // Gitee Index protected int block; //是否屏蔽 1屏蔽,0不屏蔽 @@ -65,8 +65,8 @@ public final class Repository extends Searchable { this.name = p.getName(); this.description = p.getDescription(); this.url = p.getHttpUrlToRepo(); - this.enterprise = Relation.EMPTY; - this.project = Relation.EMPTY; + //this.enterprise = Relation.EMPTY(); + //this.project = Relation.EMPTY(); if(p.getOwner() != null) this.owner = new Relation(p.getOwner().getId(), p.getOwner().getName(), p.getOwner().getWebUrl()); this.setVisibility(p.getVisibility()); diff --git a/core/src/main/java/com/gitee/kooder/models/SourceFile.java b/core/src/main/java/com/gitee/kooder/models/SourceFile.java index 319138d..7e43fbf 100644 --- a/core/src/main/java/com/gitee/kooder/models/SourceFile.java +++ b/core/src/main/java/com/gitee/kooder/models/SourceFile.java @@ -32,7 +32,7 @@ public final class SourceFile extends Searchable { private String uuid; // file unique identify private int enterprise; // enterpise - private Relation repository = Relation.EMPTY; //repository, use this field to delete all files of repository + private Relation repository = Relation.EMPTY(); //repository, use this field to delete all files of repository private String branch; // branch name private String name; // file name diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java index 709132c..1c62ef2 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Issue.java @@ -54,7 +54,6 @@ public class Issue { com.gitee.kooder.models.Issue iss = new com.gitee.kooder.models.Issue(); iss.setId(getId()); iss.setIdent(this.getRepository().getId() + "_" + this.getId()); - iss.setProject(Relation.EMPTY); iss.setRepository(new Relation(this.getRepository().getId(), this.getRepository().getName(), this.getRepository().getUrl())); iss.setOwner(new Relation(this.getUser().getId(), this.getUser().getName(), this.getUser().getHtmlUrl())); iss.setTitle(this.getTitle()); diff --git a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java index 31690a9..17da1fc 100644 --- a/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java +++ b/indexer/src/main/java/com/gitee/kooder/gitee/Repository.java @@ -75,7 +75,6 @@ public class Repository { repo.setName(this.getName()); repo.setDescription(this.getDescription()); repo.setUrl(this.getGitHttpUrl() == null ? this.getHtmlUrl() : this.getGitHttpUrl()); - repo.setProject(Relation.EMPTY); repo.setOwner(new Relation(this.getOwner().getId(), this.getOwner().getName(), this.getOwner().getHtmlUrl())); repo.setVisibility(this.getPrivate() ? Constants.VISIBILITY_PRIVATE : this.getInternal() ? Constants.VISIBILITY_INTERNAL : Constants.VISIBILITY_PUBLIC); repo.setLicense(this.getLicense()); -- Gitee From 00a207961e9d6b870e69cbd99d4bf9303e19163c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Mon, 8 Mar 2021 16:37:13 +0800 Subject: [PATCH 25/29] comment refine --- .../gitee/kooder/utils/FileClassifier.java | 5 ++- .../kooder/utils/FileClassifierResult.java | 3 +- .../com/gitee/kooder/utils/SlocCounter.java | 14 +++----- .../com/gitee/kooder/utils/TextFileUtils.java | 35 ++----------------- core/src/main/resources/kooder.properties | 4 +-- 5 files changed, 13 insertions(+), 48 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java index 04e0227..da99355 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifier.java @@ -50,15 +50,14 @@ public class FileClassifier { } /** - * Given a filename guesses the file type + * Guesses the file type of given filename */ public static String languageGuess(String fileName, String content) { fileName = fileName.toLowerCase(); - List matches = new ArrayList<>(); String extension = ""; // Try finding based on full name match - matches = checkIfFilenameExists(fileName); + List matches = checkIfFilenameExists(fileName); // Try finding using the whole name EG LICENSE if (matches.isEmpty()) { diff --git a/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java b/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java index e45cbae..5899eca 100644 --- a/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java +++ b/core/src/main/java/com/gitee/kooder/utils/FileClassifierResult.java @@ -16,7 +16,8 @@ package com.gitee.kooder.utils; /** - * 对应 languages.json 中的语言定义 + * This class used to mapping language.json segment defined + * @author Winter Lau */ public class FileClassifierResult { diff --git a/core/src/main/java/com/gitee/kooder/utils/SlocCounter.java b/core/src/main/java/com/gitee/kooder/utils/SlocCounter.java index 9d7f7ed..62627d9 100644 --- a/core/src/main/java/com/gitee/kooder/utils/SlocCounter.java +++ b/core/src/main/java/com/gitee/kooder/utils/SlocCounter.java @@ -43,10 +43,6 @@ public class SlocCounter { )); } - public ArrayList> getByteOrderMarks() { - return byteOrderMarks; - } - public boolean checkForMatch(char currentByte, int index, int endPoint, String[] matches, String content) { if (matches == null) { return false; @@ -338,11 +334,11 @@ public class SlocCounter { * found inside the file it was asked to count. */ public class SlocCount { - public int linesCount = 0; - public int blankCount = 0; - public int codeCount = 0; - public int commentCount = 0; - public int complexity = 0; + public int linesCount = 0; // file lines + public int blankCount = 0; // blank code lines + public int codeCount = 0; // code lines + public int commentCount = 0; // comment lines count + public int complexity = 0; // code complexity public SlocCount() { } diff --git a/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java b/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java index 838c85c..136d905 100644 --- a/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java +++ b/core/src/main/java/com/gitee/kooder/utils/TextFileUtils.java @@ -59,17 +59,6 @@ public class TextFileUtils { return true; } - /* - if (!this.isNullEmptyOrWhitespace((String) this.properties.get(Values.DIRECTORY_BLACK_LIST))) { - String[] toIgnoreArray = ((String) this.properties.get(Values.DIRECTORY_BLACK_LIST)).split(","); - - for (String toIgnore : toIgnoreArray) { - if (fileParent.endsWith("/" + toIgnore) || fileParent.endsWith("/" + toIgnore + "/")) { - return true; - } - } - }*/ - return false; } @@ -80,29 +69,9 @@ public class TextFileUtils { * @param maxFileLineDepth 只返回最开始的 N 行,如果该值为负数,则返回所有行 */ public static List readFileLines(File file, int maxFileLineDepth) throws IOException { - return readFileLines(new FileInputStream(file), maxFileLineDepth); - /* - Charset charset = guessCharset(file); - StringBuilder stringBuilder = new StringBuilder(); - - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset))){ - int i = 0; - int count = 0; - char[] buffer = new char[128]; - do { - int rc = reader.read(buffer); - if(rc > 0) { - stringBuilder.append(buffer, 0, rc); - count += rc; - } - if(rc == -1 || count >= DEFAULT_MAX_FILE_LENGTH_READ) - break; - } while (true); + try (InputStream stram = new FileInputStream(file)) { + return readFileLines(stram, maxFileLineDepth); } - - String[] lines = stringBuilder.toString().split("\\r\\n|\\n|\\r"); - return (lines.length > maxFileLineDepth && maxFileLineDepth > 0)?Arrays.asList(lines).subList(0, maxFileLineDepth):Arrays.asList(lines); - */ } /** diff --git a/core/src/main/resources/kooder.properties b/core/src/main/resources/kooder.properties index 9900e04..4deac1b 100644 --- a/core/src/main/resources/kooder.properties +++ b/core/src/main/resources/kooder.properties @@ -8,8 +8,8 @@ http.log.pattern = /,/index/*,/search/*,/api/* http.webroot = gateway/src/main/webapp http.startup.tasks = indexer,gitlab -gitlab.url = http://192.168.1.25:10080/ -#gitlab.url = http://154.85.53.95:10080/ +#gitlab.url = http://192.168.1.25:10080/ +gitlab.url = http://154.85.53.95:10080/ gitlab.personal_access_token = Bt1H3ZUkD2bBFMbxxPxw gitlab.secret_token = gsearch -- Gitee From b01015a92711c9f495771839e7b2cf73056d3f21 Mon Sep 17 00:00:00 2001 From: chenle Date: Tue, 9 Mar 2021 10:57:54 +0800 Subject: [PATCH 26/29] Corrected several misspelled words --- core/src/main/java/com/gitee/kooder/jcseg/JcsegTokenizer.java | 4 ++-- core/src/main/java/com/gitee/kooder/models/SourceFile.java | 2 +- core/src/main/java/com/gitee/kooder/query/QueryBase.java | 2 +- gateway/src/main/java/com/gitee/kooder/server/Action.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/gitee/kooder/jcseg/JcsegTokenizer.java b/core/src/main/java/com/gitee/kooder/jcseg/JcsegTokenizer.java index fce5bff..7f158c8 100644 --- a/core/src/main/java/com/gitee/kooder/jcseg/JcsegTokenizer.java +++ b/core/src/main/java/com/gitee/kooder/jcseg/JcsegTokenizer.java @@ -32,7 +32,7 @@ import org.lionsoul.jcseg.segmenter.SegmenterConfig; * after invoke the reset, global object input will be available *

* - *

jcseg tokennizer for lucene on or after 5.1.0

+ *

jcseg tokenizer for lucene on or after 5.1.0

* * @author chenxin */ @@ -47,7 +47,7 @@ public class JcsegTokenizer extends Tokenizer /** * field level offset tracker for multiple-value field - * like the Array field in Elasticseach or Solr + * like the Array field in Elasticsearch or Solr */ private int fieldOffset = 0; diff --git a/core/src/main/java/com/gitee/kooder/models/SourceFile.java b/core/src/main/java/com/gitee/kooder/models/SourceFile.java index 7e43fbf..dfcd419 100644 --- a/core/src/main/java/com/gitee/kooder/models/SourceFile.java +++ b/core/src/main/java/com/gitee/kooder/models/SourceFile.java @@ -31,7 +31,7 @@ import java.util.List; public final class SourceFile extends Searchable { private String uuid; // file unique identify - private int enterprise; // enterpise + private int enterprise; // enterprise private Relation repository = Relation.EMPTY(); //repository, use this field to delete all files of repository private String branch; // branch name diff --git a/core/src/main/java/com/gitee/kooder/query/QueryBase.java b/core/src/main/java/com/gitee/kooder/query/QueryBase.java index 803bce9..91335a8 100644 --- a/core/src/main/java/com/gitee/kooder/query/QueryBase.java +++ b/core/src/main/java/com/gitee/kooder/query/QueryBase.java @@ -77,7 +77,7 @@ public abstract class QueryBase implements IQuery { } }catch(IndexNotFoundException e) { }catch(Exception e) { - log.error("Failed to get lastest object from index[" + type() + "]", e); + log.error("Failed to get latest object from index[" + type() + "]", e); } return null; } diff --git a/gateway/src/main/java/com/gitee/kooder/server/Action.java b/gateway/src/main/java/com/gitee/kooder/server/Action.java index 1ec13a1..c8b58cf 100644 --- a/gateway/src/main/java/com/gitee/kooder/server/Action.java +++ b/gateway/src/main/java/com/gitee/kooder/server/Action.java @@ -30,7 +30,7 @@ import java.util.Map; /** * Action base - * Eash request has one independent action instance + * Each request has one independent action instance * @author Winter Lau */ public interface Action { -- Gitee From cef4f4b47a3f626656882a98b7830de9c9dfd34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Tue, 9 Mar 2021 12:15:04 +0800 Subject: [PATCH 27/29] api --- docs/API.md | 14 ++++++++++++++ configuration.md => docs/configuration.md | 0 readme.md | 6 +++++- readme_en.md | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 docs/API.md rename configuration.md => docs/configuration.md (100%) diff --git a/docs/API.md b/docs/API.md new file mode 100644 index 0000000..d4de5e1 --- /dev/null +++ b/docs/API.md @@ -0,0 +1,14 @@ +### Kooder Search API + +**搜索接口** + +/search/repositories #仓库搜索 +/search/codes #代码搜索 +/search/issues #Issue 搜索 + + +**WebHook 回调接口** + +/gitlab/system # Gitlab 系统回调接口 +/gitlab/project # Gitlab 仓库回调接口 +/gitee # Gitee Premium 回调接口 diff --git a/configuration.md b/docs/configuration.md similarity index 100% rename from configuration.md rename to docs/configuration.md diff --git a/readme.md b/readme.md index 65c9725..4702edb 100644 --- a/readme.md +++ b/readme.md @@ -66,7 +66,7 @@ $ cd kooder `gitlab.url` 访问 Gitlab 的首页 `gitlab.personal_access_token` Gitlab 管理员账号 root 的 Personal Access Token -更多配置项请看 [configuration.md](configuration.md) +更多配置项请看 [configuration.md](docs/configuration.md) 3. 构建并运行 @@ -80,6 +80,10 @@ $ bin/gateway.sh ### 浏览器访问 http://localhost:8080 ``` +### Kooder Search API + +@see [API.md](docs/API.md) + ### Docker安装 #### docker-compose diff --git a/readme_en.md b/readme_en.md index 148eb33..4d18b2f 100644 --- a/readme_en.md +++ b/readme_en.md @@ -52,7 +52,7 @@ Config kooder's url `http.url`. It will be injected into Git service as the webh ``` http.url = http://:8080 ``` -Click here to see more config options [configuration.md](configuration.md) +Click here to see more config options [configuration.md](docs/configuration.md) ### Install Docker Dependencies -- Gitee From ba2b6ed2a9aed63ca9f76fd9dc37879cd8c940bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Tue, 9 Mar 2021 14:34:05 +0800 Subject: [PATCH 28/29] api detail --- docs/API.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/API.md b/docs/API.md index d4de5e1..f0a2c9d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -3,9 +3,35 @@ **搜索接口** /search/repositories #仓库搜索 + +|参数名 |参数含义 | 示例| +--- | --- | --- +|q|搜索关键字|q=password| +|lang|指定编程语言(不支持多值)|lang=Java| +|e.id|搜索指定企业的仓库(仅限 gitee)|e.id=1213| +|sort|排序方法(stars,forks,update)|sort=update| +|p|页码(每页20条)|p=3| + /search/codes #代码搜索 + +|参数名 |参数含义 | 示例| +--- | --- | --- +|q|搜索关键字|q=password| +|lang|指定编程语言(不支持多值)|lang=Java| +|e.id|搜索指定企业的仓库(仅限 gitee)|e.id=1213| +|repo.id|搜索指定仓库的代码,支持多值,使用逗号隔开|repo.id=1213,32| +|sort|排序方法(stars,forks,update)|sort=update| +|p|页码(每页20条)|p=3| + /search/issues #Issue 搜索 +|参数名 |参数含义 | 示例| +--- | --- | --- +|q|搜索关键字|q=password| +|e.id|搜索指定企业的仓库(仅限 gitee)|e.id=1213| +|sort|排序方法(create,update)|sort=update| +|p|页码(每页20条)|p=3| + **WebHook 回调接口** -- Gitee From 03a71d41125fbea8b387af36ff39134b4b04b0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=A2=E8=96=AF?= Date: Tue, 9 Mar 2021 15:13:34 +0800 Subject: [PATCH 29/29] remove gitlab token in properties --- core/src/main/resources/kooder.properties | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/kooder.properties b/core/src/main/resources/kooder.properties index 4deac1b..b38e28e 100644 --- a/core/src/main/resources/kooder.properties +++ b/core/src/main/resources/kooder.properties @@ -8,9 +8,8 @@ http.log.pattern = /,/index/*,/search/*,/api/* http.webroot = gateway/src/main/webapp http.startup.tasks = indexer,gitlab -#gitlab.url = http://192.168.1.25:10080/ -gitlab.url = http://154.85.53.95:10080/ -gitlab.personal_access_token = Bt1H3ZUkD2bBFMbxxPxw +gitlab.url = +gitlab.personal_access_token = gitlab.secret_token = gsearch # Git ˺ãusername ssh ͬʱã -- Gitee