Skip to content

Commit

Permalink
update store associated file to use metadata document structure
Browse files Browse the repository at this point in the history
intellij 2018.3 requires a split resources and java directory now so split them
  • Loading branch information
mdavis95 committed Nov 26, 2018
1 parent 53f71fa commit 2ad7992
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 37 deletions.
13 changes: 0 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ subprojects {
testCompile 'org.testng:testng:6.8.21'
}

sourceSets {
main {
resources {
srcDir 'src/main/java'
}
}
test {
resources {
srcDir 'src/test/java'
}
}
}

test {
useTestNG()

Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Nov 26 15:12:55 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
8 changes: 0 additions & 8 deletions zulia-client/build.gradle.kts

This file was deleted.

14 changes: 4 additions & 10 deletions zulia-client/src/main/java/io/zulia/client/ZuliaRESTClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.zulia.ZuliaConstants;
import io.zulia.util.HttpHelper;
import io.zulia.util.StreamHelper;
import org.bson.Document;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -12,9 +13,7 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class ZuliaRESTClient {
private String server;
Expand Down Expand Up @@ -64,7 +63,7 @@ public void storeAssociated(String uniqueId, String indexName, String fileName,
storeAssociated(uniqueId, indexName, fileName, null, source);
}

public void storeAssociated(String uniqueId, String indexName, String fileName, Map<String, String> meta, InputStream source) throws IOException {
public void storeAssociated(String uniqueId, String indexName, String fileName, Document metadata, InputStream source) throws IOException {
HttpURLConnection conn = null;
OutputStream destination = null;
try {
Expand All @@ -73,13 +72,8 @@ public void storeAssociated(String uniqueId, String indexName, String fileName,
parameters.put(ZuliaConstants.ID, uniqueId);
parameters.put(ZuliaConstants.FILE_NAME, fileName);
parameters.put(ZuliaConstants.INDEX, indexName);
if (meta != null) {
ArrayList<Object> list = new ArrayList<>();
parameters.put(ZuliaConstants.META_JSON, list);
for (String key : meta.keySet()) {
String value = meta.get(key);
list.add(key + ":" + value);
}
if (metadata != null) {
parameters.put(ZuliaConstants.META_JSON, metadata.toJson());
}

String url = HttpHelper.createRequestUrl(server, restPort, ZuliaConstants.ASSOCIATED_DOCUMENTS_URL, parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import io.zulia.client.command.base.RESTCommand;
import io.zulia.client.command.base.ShardRoutableCommand;
import io.zulia.client.result.StoreLargeAssociatedResult;
import org.bson.Document;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Map;

public class StoreLargeAssociated extends RESTCommand<StoreLargeAssociatedResult> implements ShardRoutableCommand {

Expand All @@ -17,7 +17,7 @@ public class StoreLargeAssociated extends RESTCommand<StoreLargeAssociatedResult
private String indexName;
private File fileToStore;
private InputStream source;
private Map<String, String> meta;
private Document meta;

public StoreLargeAssociated(String uniqueId, String indexName, String fileName, File fileToStore) {
this.uniqueId = uniqueId;
Expand All @@ -33,11 +33,11 @@ public StoreLargeAssociated(String uniqueId, String indexName, String fileName,
this.source = source;
}

public Map<String, String> getMeta() {
public Document getMeta() {
return meta;
}

public StoreLargeAssociated setMeta(Map<String, String> meta) {
public StoreLargeAssociated setMeta(Document meta) {
this.meta = meta;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static CharArrayMap<char[]> initializeDictHash() {
CharArrayMap<char[]> charMap = new CharArrayMap<>(2000, false);

try {
URL url = Resources.getResource(BritishUSFilter.class, "british.txt");
URL url = BritishUSFilter.class.getResource("/british.txt");
String text = Resources.toString(url, Charsets.UTF8_CHARSET);
String[] lines = text.split("\n");
for (String line : lines) {
Expand Down
File renamed without changes.

0 comments on commit 2ad7992

Please sign in to comment.