Skip to content

Commit 8ea5540

Browse files
feature/#46 Change field name 'type' to 'contentType' in Record class
1 parent 1ca00ff commit 8ea5540

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Add exists option to BucketSettings. [PR-42](https://github.com/reductstore/reduct-java/issues/42)
3333
- Bucket.writeRecord receives entry name and bucket. [PR-43](https://github.com/reductstore/reduct-java/issues/43)
3434
- Add getBucket method to ReductClient. [PR-44](https://github.com/reductstore/reduct-java/issues/44)
35+
- Change field name 'type' to 'contentType' in Record class. [PR-46](https://github.com/reductstore/reduct-java/issues/46)
3536
### Infrastructure:
3637

3738
- Added GitHub Actions for CI/CD [PR-35](https://github.com/reductstore/reduct-java/pull/35)

src/main/java/store/reduct/model/bucket/Bucket.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void writeRecord(String entryName, @NonNull Record record) throws ReductE
165165

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

171171
reductClient.sendAndGetOnlySuccess(builder, HttpResponse.BodyHandlers.ofString());
@@ -195,7 +195,7 @@ public void writeRecords(String entryName, Iterator<Record> records)
195195
byte[] byteBodyArray = record.getBody();
196196
body = ArrayUtils.addAll(body, byteBodyArray);
197197
builder.header(getXReductTimeWithNumberHeader(record.getTimestamp()),
198-
byteBodyArray.length + "," + record.getType());
198+
byteBodyArray.length + "," + record.getContentType());
199199
}
200200
if (Objects.nonNull(body)) {
201201
builder.POST(HttpRequest.BodyPublishers.ofByteArray(body));
@@ -225,7 +225,7 @@ public Record readRecord(String entryName, Long timestamp) throws ReductExceptio
225225
return Record.builder().body(httpResponse.body())
226226
.timestamp(httpResponse.headers().firstValue(getXReductTimeHeader()).map(Long::parseLong)
227227
.orElseThrow(() -> new ReductException(X_REDUCT_TIME_IS_NOT_SUCH_LONG_FORMAT)))
228-
.type(httpResponse.headers().firstValue(getContentTypeHeader())
228+
.contentType(httpResponse.headers().firstValue(getContentTypeHeader())
229229
.orElseThrow(() -> new ReductException(CONTENT_TYPE_IS_NOT_SET_IN_THE_RECORD)))
230230
.length(httpResponse.headers().firstValue(getContentLengthHeader()).map(Integer::parseInt)
231231
.orElseThrow(() -> new ReductException(CONTENT_LENGTH_IS_NOT_SET_IN_THE_RECORD)))
@@ -255,7 +255,7 @@ public Record getMetaInfo(String entryName, Long timestamp) throws ReductExcepti
255255
return Record.builder()
256256
.timestamp(httpResponse.headers().firstValue(getXReductTimeHeader()).map(Long::parseLong)
257257
.orElseThrow(() -> new ReductException(X_REDUCT_TIME_IS_NOT_SUCH_LONG_FORMAT)))
258-
.type(httpResponse.headers().firstValue(getContentTypeHeader())
258+
.contentType(httpResponse.headers().firstValue(getContentTypeHeader())
259259
.orElseThrow(() -> new ReductException(CONTENT_TYPE_IS_NOT_SET_IN_THE_RECORD)))
260260
.length(httpResponse.headers().firstValue(getContentLengthHeader()).map(Integer::parseInt)
261261
.orElseThrow(() -> new ReductException(CONTENT_LENGTH_IS_NOT_SET_IN_THE_RECORD)))
@@ -389,7 +389,7 @@ public Record next() {
389389
byteBuffer.position(instance.getOffset());
390390
byteBuffer.get(nextBody, 0, instance.getLength());
391391

392-
return Record.builder().body(nextBody).timestamp(instance.getTs()).type(instance.getType())
392+
return Record.builder().body(nextBody).timestamp(instance.getTs()).contentType(instance.getType())
393393
.length(instance.getLength()).build();
394394
}
395395
}

src/main/java/store/reduct/model/record/Record.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
public class Record {
1313
private Long timestamp;
1414
private byte[] body;
15-
private String type;
15+
private String contentType;
1616
private Integer length;
1717
}

src/test/java/store/reduct/model/bucket/BucketTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void test1() {
4343

4444
Bucket bucket = new Bucket(expectedBucketName, client);
4545

46-
Record record = Record.builder().body(expectedBody).type(expectedType).timestamp(timestamp).build();
46+
Record record = Record.builder().body(expectedBody).contentType(expectedType).timestamp(timestamp).build();
4747

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

0 commit comments

Comments
 (0)