Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add exists option to BucketSettings. [PR-42](https://github.com/reductstore/reduct-java/issues/42)
- Bucket.writeRecord receives entry name and bucket. [PR-43](https://github.com/reductstore/reduct-java/issues/43)
- Add getBucket method to ReductClient. [PR-44](https://github.com/reductstore/reduct-java/issues/44)
- Change field name 'type' to 'contentType' in Record class. [PR-46](https://github.com/reductstore/reduct-java/issues/46)
### Infrastructure:

- Added GitHub Actions for CI/CD [PR-35](https://github.com/reductstore/reduct-java/pull/35)
11 changes: 6 additions & 5 deletions src/main/java/store/reduct/model/bucket/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ public void writeRecord(String entryName, @NonNull Record record) throws ReductE

URI uri = URI.create(reductClient.getServerProperties().url()
+ String.format(RecordURL.WRITE_ENTRY.getUrl(), name, entryName) + new Queries(TS, timestamp));
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(uri).header(getContentTypeHeader(), record.getType())
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(uri)
.header(getContentTypeHeader(), record.getContentType())
.POST(HttpRequest.BodyPublishers.ofByteArray(record.getBody()));

reductClient.sendAndGetOnlySuccess(builder, HttpResponse.BodyHandlers.ofString());
Expand Down Expand Up @@ -195,7 +196,7 @@ public void writeRecords(String entryName, Iterator<Record> records)
byte[] byteBodyArray = record.getBody();
body = ArrayUtils.addAll(body, byteBodyArray);
builder.header(getXReductTimeWithNumberHeader(record.getTimestamp()),
byteBodyArray.length + "," + record.getType());
byteBodyArray.length + "," + record.getContentType());
}
if (Objects.nonNull(body)) {
builder.POST(HttpRequest.BodyPublishers.ofByteArray(body));
Expand Down Expand Up @@ -225,7 +226,7 @@ public Record readRecord(String entryName, Long timestamp) throws ReductExceptio
return Record.builder().body(httpResponse.body())
.timestamp(httpResponse.headers().firstValue(getXReductTimeHeader()).map(Long::parseLong)
.orElseThrow(() -> new ReductException(X_REDUCT_TIME_IS_NOT_SUCH_LONG_FORMAT)))
.type(httpResponse.headers().firstValue(getContentTypeHeader())
.contentType(httpResponse.headers().firstValue(getContentTypeHeader())
.orElseThrow(() -> new ReductException(CONTENT_TYPE_IS_NOT_SET_IN_THE_RECORD)))
.length(httpResponse.headers().firstValue(getContentLengthHeader()).map(Integer::parseInt)
.orElseThrow(() -> new ReductException(CONTENT_LENGTH_IS_NOT_SET_IN_THE_RECORD)))
Expand Down Expand Up @@ -255,7 +256,7 @@ public Record getMetaInfo(String entryName, Long timestamp) throws ReductExcepti
return Record.builder()
.timestamp(httpResponse.headers().firstValue(getXReductTimeHeader()).map(Long::parseLong)
.orElseThrow(() -> new ReductException(X_REDUCT_TIME_IS_NOT_SUCH_LONG_FORMAT)))
.type(httpResponse.headers().firstValue(getContentTypeHeader())
.contentType(httpResponse.headers().firstValue(getContentTypeHeader())
.orElseThrow(() -> new ReductException(CONTENT_TYPE_IS_NOT_SET_IN_THE_RECORD)))
.length(httpResponse.headers().firstValue(getContentLengthHeader()).map(Integer::parseInt)
.orElseThrow(() -> new ReductException(CONTENT_LENGTH_IS_NOT_SET_IN_THE_RECORD)))
Expand Down Expand Up @@ -389,7 +390,7 @@ public Record next() {
byteBuffer.position(instance.getOffset());
byteBuffer.get(nextBody, 0, instance.getLength());

return Record.builder().body(nextBody).timestamp(instance.getTs()).type(instance.getType())
return Record.builder().body(nextBody).timestamp(instance.getTs()).contentType(instance.getType())
.length(instance.getLength()).build();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/store/reduct/model/record/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
public class Record {
private Long timestamp;
private byte[] body;
private String type;
private String contentType;
private Integer length;
}
2 changes: 1 addition & 1 deletion src/test/java/store/reduct/model/bucket/BucketTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void test1() {

Bucket bucket = new Bucket(expectedBucketName, client);

Record record = Record.builder().body(expectedBody).type(expectedType).timestamp(timestamp).build();
Record record = Record.builder().body(expectedBody).contentType(expectedType).timestamp(timestamp).build();

Mockito.when(client.getServerProperties()).thenReturn(serverProperties);

Expand Down
Loading