diff --git a/analyzer/common/build.gradle b/analyzer/common/build.gradle index a2b841b671150..97bc34d298dae 100644 --- a/analyzer/common/build.gradle +++ b/analyzer/common/build.gradle @@ -4,7 +4,7 @@ plugins { dependencies { compile project(':model') - compile project(':logging') + compile project(':util') // compile 'org.rocksdb:rocksdbjni:5.13.2' // compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.23.1' testCompile 'junit:junit:4.12' diff --git a/elasticsearch/build.gradle b/elasticsearch/build.gradle index 73b09fcd605a1..f4226ef7c9e46 100644 --- a/elasticsearch/build.gradle +++ b/elasticsearch/build.gradle @@ -4,7 +4,7 @@ plugins { dependencies { compile project(":model") - compile project(":logging") + compile project(":util") compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.4' // Check if lite dep could be used diff --git a/model/src/File.proto b/model/src/File.proto new file mode 100644 index 0000000000000..6f28c2d34c9e0 --- /dev/null +++ b/model/src/File.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +option java_package = "castro.file"; +option java_multiple_files = true; + +message FileLocation { + string fileHash = 1; // git sha1 + string repositoryId = 2; +} + +message RichDocument { + FileLocation fileLocation = 1; + string path = 2; + string fileContent = 3; + repeated string nodes = 4; // TODO +} \ No newline at end of file diff --git a/model/src/Repository.proto b/model/src/Repository.proto index 7d03e76a44313..406cd3cefa651 100644 --- a/model/src/Repository.proto +++ b/model/src/Repository.proto @@ -4,7 +4,7 @@ option java_package = "castro.repository"; option java_multiple_files = true; message Repository { - string uri = 1; + string repositoryId = 1; string domain = 2; string name = 3; diff --git a/model/src/SyntaxHighlight.proto b/model/src/SyntaxHighlight.proto new file mode 100644 index 0000000000000..2b0ee22c6ffe9 --- /dev/null +++ b/model/src/SyntaxHighlight.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +option java_package = "castro.syntaxhighlight"; +option java_multiple_files = true; + +import "File.proto"; + +message FileSyntaxHighlight { + FileLocation fileLocation = 1; + + message LineSyntaxHight { + int32 line = 1; + repeated SyntaxHightTag tags = 2; + } + + message SyntaxHightTag { + int32 start = 1; + int32 end = 2; + string tag = 3; + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 0b84fa9b923d4..0db2d48aa73f9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include 'logging' +include 'util' include 'elasticsearch' include 'backend' diff --git a/logging/build.gradle b/util/build.gradle similarity index 100% rename from logging/build.gradle rename to util/build.gradle diff --git a/util/src/main/java/castro/hash/FileHash.java b/util/src/main/java/castro/hash/FileHash.java new file mode 100644 index 0000000000000..3429b71fd8a51 --- /dev/null +++ b/util/src/main/java/castro/hash/FileHash.java @@ -0,0 +1,28 @@ +package castro.hash; + +import java.io.UnsupportedEncodingException; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class FileHash { + // https://gist.github.com/alecthegeek/333663 + String compute(String content) { + try { + var builder = new StringBuilder(); + builder.append("blob "); + builder.append(content.length()); + builder.append("\0"); + builder.append(content); + var input = builder.toString().getBytes("UTF-8"); + + MessageDigest msdDigest = MessageDigest.getInstance("SHA-1"); + msdDigest.update(input); + BigInteger n = new BigInteger(msdDigest.digest()); + return n.toString(16); + } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) { +// Logger.getLogger(Encriptacion.class.getName()).log(Level.SEVERE, null, e); + } + return null; + } +} diff --git a/logging/src/main/java/castro/logging/ColoredLevel.java b/util/src/main/java/castro/logging/ColoredLevel.java similarity index 100% rename from logging/src/main/java/castro/logging/ColoredLevel.java rename to util/src/main/java/castro/logging/ColoredLevel.java