Skip to content

Commit 107dca7

Browse files
authored
HTM-1979: Add description to uploads (#1722)
* Add description to upload * Add description to the response as a header * Set header name as static value * remove whitespace * Change number of flyway script to 30 * Add description column to revision table
1 parent 8388c60 commit 107dca7

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/org/tailormap/api/controller/UploadsController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@RestController
2727
public class UploadsController {
2828
private final UploadRepository uploadRepository;
29+
private static final String DESCRIPTION_HEADER_NAME = "TM-Description";
2930

3031
public UploadsController(UploadRepository uploadRepository) {
3132
this.uploadRepository = uploadRepository;
@@ -63,6 +64,7 @@ public ResponseEntity<byte[]> getUpload(
6364

6465
return ResponseEntity.ok()
6566
.header("Content-Type", upload.getMimeType())
67+
.header(DESCRIPTION_HEADER_NAME, upload.getDescription())
6668
.lastModified(upload.getLastModified().toInstant())
6769
.contentLength(upload.getContentLength())
6870
.cacheControl(CacheControl.noCache().cachePublic())
@@ -79,6 +81,7 @@ public ResponseEntity<byte[]> getLatestUpload(@PathVariable String category) {
7981
.findFirstWithContentByCategoryOrderByLastModifiedDesc(category)
8082
.map(upload -> ResponseEntity.ok()
8183
.header("Content-Type", upload.getMimeType())
84+
.header(DESCRIPTION_HEADER_NAME, upload.getDescription())
8285
.lastModified(upload.getLastModified().toInstant())
8386
.contentLength(upload.getContentLength())
8487
.cacheControl(CacheControl.noCache().cachePublic())

src/main/java/org/tailormap/api/persistence/Upload.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class Upload extends AuditMetadata {
5858

5959
private String hash;
6060

61+
private String description;
62+
6163
// <editor-fold desc="getters and setters">
6264
public int getContentLength() {
6365
return getContent() == null ? 0 : content.length;
@@ -163,4 +165,13 @@ public void computeHash() {
163165
this.hash = null;
164166
}
165167
}
168+
169+
public String getDescription() {
170+
return description;
171+
}
172+
173+
public Upload setDescription(String description) {
174+
this.description = description;
175+
return this;
176+
}
166177
}

src/main/java/org/tailormap/api/persistence/projections/UploadSummary.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ public interface UploadSummary {
3131
OffsetDateTime getLastModified();
3232

3333
int getContentLength();
34+
35+
String getDescription();
3436
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table if exists upload
2+
add column description varchar(255) default null;
3+
4+
alter table if exists history.upload_revisions
5+
add column description varchar(255) default null;

0 commit comments

Comments
 (0)