Skip to content
This repository was archived by the owner on Jun 12, 2022. It is now read-only.

Commit dcf3860

Browse files
committed
Add kotlin and create ConduitClient
1 parent ffb2075 commit dcf3860

File tree

5 files changed

+142
-10
lines changed

5 files changed

+142
-10
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ charset = utf-8
1111
trim_trailing_whitespace = true
1212
insert_final_newline = true
1313

14-
[**.java]
14+
[**.{java,kt}]
1515
indent_size = 4
1616

1717
[**.md]

pom.xml

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<!-- Minimal version of SonarQube to support -->
3333
<sonar.apiVersion>5.6</sonar.apiVersion>
3434
<jdk.min.version>1.8</jdk.min.version>
35+
<kotlin.version>1.1.3-2</kotlin.version>
3536
</properties>
3637

3738
<dependencies>
@@ -58,6 +59,20 @@
5859
<scope>provided</scope>
5960
</dependency>
6061

62+
<!-- https://mvnrepository.com/artifact/org.json/json -->
63+
<dependency>
64+
<groupId>org.json</groupId>
65+
<artifactId>json</artifactId>
66+
<version>20170516</version>
67+
</dependency>
68+
69+
70+
<dependency>
71+
<groupId>org.jetbrains.kotlin</groupId>
72+
<artifactId>kotlin-stdlib-jre8</artifactId>
73+
<version>${kotlin.version}</version>
74+
</dependency>
75+
6176
<!-- unit tests -->
6277
<dependency>
6378
<groupId>org.sonarsource.sonarqube</groupId>
@@ -71,6 +86,12 @@
7186
<version>4.11</version>
7287
<scope>test</scope>
7388
</dependency>
89+
<dependency>
90+
<groupId>org.jetbrains.kotlin</groupId>
91+
<artifactId>kotlin-test</artifactId>
92+
<version>${kotlin.version}</version>
93+
<scope>test</scope>
94+
</dependency>
7495
</dependencies>
7596

7697
<build>
@@ -86,15 +107,6 @@
86107
<!-- advanced properties can be set here -->
87108
</configuration>
88109
</plugin>
89-
<plugin>
90-
<groupId>org.apache.maven.plugins</groupId>
91-
<artifactId>maven-compiler-plugin</artifactId>
92-
<version>3.5.1</version>
93-
<configuration>
94-
<source>${jdk.min.version}</source>
95-
<target>${jdk.min.version}</target>
96-
</configuration>
97-
</plugin>
98110
<plugin>
99111
<!-- UTF-8 bundles are not supported by Java, so they must be converted durbuildReportuild -->
100112
<groupId>org.codehaus.mojo</groupId>
@@ -108,6 +120,66 @@
108120
</execution>
109121
</executions>
110122
</plugin>
123+
<plugin>
124+
<groupId>org.jetbrains.kotlin</groupId>
125+
<artifactId>kotlin-maven-plugin</artifactId>
126+
<version>${kotlin.version}</version>
127+
<executions>
128+
<execution>
129+
<id>compile</id>
130+
<phase>compile</phase>
131+
<goals>
132+
<goal>compile</goal>
133+
</goals>
134+
<configuration>
135+
<sourceDirs>
136+
<source>src/main/java</source>
137+
<source>src/main/kotlin</source>
138+
</sourceDirs>
139+
</configuration>
140+
</execution>
141+
<execution>
142+
<id>test-compile</id>
143+
<phase>test-compile</phase>
144+
<goals>
145+
<goal>test-compile</goal>
146+
</goals>
147+
</execution>
148+
</executions>
149+
</plugin>
150+
<plugin>
151+
<groupId>org.apache.maven.plugins</groupId>
152+
<artifactId>maven-compiler-plugin</artifactId>
153+
<version>3.5.1</version>
154+
<executions>
155+
<execution>
156+
<id>default-compile</id>
157+
<phase>none</phase>
158+
</execution>
159+
<execution>
160+
<id>default-testCompile</id>
161+
<phase>none</phase>
162+
</execution>
163+
<execution>
164+
<id>compile</id>
165+
<phase>compile</phase>
166+
<goals>
167+
<goal>compile</goal>
168+
</goals>
169+
</execution>
170+
<execution>
171+
<id>testCompile</id>
172+
<phase>test-compile</phase>
173+
<goals>
174+
<goal>testCompile</goal>
175+
</goals>
176+
</execution>
177+
</executions>
178+
<configuration>
179+
<source>${jdk.min.version}</source>
180+
<target>${jdk.min.version}</target>
181+
</configuration>
182+
</plugin>
111183
</plugins>
112184
</build>
113185

src/main/java/io/nthienan/phdiff/PhabricatorDifferentialBot.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.nthienan.phdiff;
22

3+
import io.nthienan.phdiff.differential.Differential;
34
import io.nthienan.phdiff.issue.IssueComparator;
45
import io.nthienan.phdiff.report.GlobalReportBuilder;
56
import org.sonar.api.batch.postjob.PostJob;
@@ -49,5 +50,7 @@ public void execute(PostJobContext context) {
4950
.forEach(reportBuilder::add);
5051
}
5152
LOG.error(reportBuilder.buildReport());
53+
Differential differential = new Differential("", "", "");
54+
differential.getRevisionID();
5255
}
5356
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.nthienan.phdiff.conduit
2+
3+
import org.apache.http.NameValuePair
4+
import org.apache.http.client.entity.UrlEncodedFormEntity
5+
import org.apache.http.client.methods.HttpPost
6+
import org.apache.http.impl.client.HttpClientBuilder
7+
import org.apache.http.message.BasicNameValuePair
8+
import org.json.JSONObject
9+
import org.sonar.api.internal.google.gson.JsonObject
10+
import java.net.URL
11+
import java.util.*
12+
13+
/**
14+
* Created on 17-Jul-17.
15+
* @author nthienan
16+
*/
17+
class ConduitClient(var url: String, var token: String) {
18+
19+
fun perform(action: String, params: JSONObject): JsonObject? {
20+
val httpClient = HttpClientBuilder.create().build()
21+
val postRequest = makeRequest(action, params)
22+
return null
23+
}
24+
25+
private fun makeRequest(action: String, params: JSONObject): HttpPost {
26+
val postRequest = HttpPost(URL(URL(URL(url), "/api/"), action).toURI())
27+
28+
val conduitMetadata = JSONObject()
29+
conduitMetadata.append("token", token)
30+
params.append("__conduit__", conduitMetadata)
31+
32+
val formData = ArrayList<NameValuePair>()
33+
formData.add(BasicNameValuePair("params", params.toString()))
34+
val entity = UrlEncodedFormEntity(formData, "UTF-8")
35+
postRequest.setEntity(entity)
36+
37+
return postRequest
38+
}
39+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.nthienan.phdiff.differential
2+
3+
import java.util.*
4+
5+
/**
6+
* Created on 17-Jul-17.
7+
* @author nthienan
8+
*/
9+
class Differential(var id: String, var phid: String, var revisionID: String) {
10+
var title: String = ""
11+
var uri: String = ""
12+
var dateCreated: Date? = null
13+
var dateModified: Date? = null
14+
var authorPHID: String = ""
15+
var status: Int = 0
16+
var StatusName: String = ""
17+
var branch: String = ""
18+
}

0 commit comments

Comments
 (0)