Skip to content

Commit

Permalink
Use URIBuilder to construct destination
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Saky <[email protected]>
  • Loading branch information
adityasaky committed Apr 16, 2020
1 parent 001ac3d commit 365ec39
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
<artifactId>plain-credentials</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import io.github.in_toto.models.Link;
import java.net.URI;
import org.apache.http.client.utils.URIBuilder;
import java.net.URISyntaxException;
import java.util.*;
import com.google.gson.Gson;

Expand Down Expand Up @@ -65,7 +67,26 @@ public void submit(Link link) {
Gson gson = new Gson();
String jsonString = gson.toJson(this.occurrence);

String destination = this.uri.toString().split("\\?")[0].substring("grafeas+".length());
String scheme = this.uri.getScheme().split("\\+")[1];

String authority = this.uri.getAuthority();

String path = this.uri.getPath();

URIBuilder uriBuilder = new URIBuilder();

String destination = "";

try {
destination = uriBuilder
.setScheme(scheme)
.setHost(authority)
.setPath(path)
.build()
.toString();
} catch (URISyntaxException e) {
e.printStackTrace();
}

// FIXME: Shamelessly copied from GenericCRUD.java
try {
Expand Down

0 comments on commit 365ec39

Please sign in to comment.