-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dataset files API extension for file display data with pagination and sorting #9693
Changes from 26 commits
73c3235
dc31788
fff2119
e8951a4
6264fa4
639cff8
886a508
6ead834
9f35bf7
a2bc4d4
ec75534
86865f5
31c306d
489b990
8c2781b
867fb8a
f2b374e
6437e5d
2cb77d4
c86a1d7
742036a
991641b
1ff9d90
a8a367a
7a9c2b3
b52b33d
d16264d
0952a62
02cecd4
6722777
90ef2f1
a7b2485
cd8e229
a64199f
24944eb
719fc67
1224311
0c0ddae
4b276db
6b59a5b
35e4547
6b45d82
0df8ca7
6b19648
2e2fb38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The following API endpoints have been added: | ||
|
||
- /api/files/{id}/guestbookResponses/count | ||
- /api/files/{id}/canBeDownloaded | ||
- /api/files/{id}/thumbnailClass | ||
- /api/files/{id}/dataTables | ||
|
||
The getVersionFiles endpoint (/api/datasets/{id}/versions/{versionId}/files) has been extended to support pagination and ordering | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This addition should be documented in the API guide. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is not done, sorry: 😄
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added now, sorry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, looks good, thanks! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import com.google.gson.Gson; | ||
import com.google.gson.JsonObject; | ||
import edu.harvard.iq.dataverse.DataFile; | ||
import edu.harvard.iq.dataverse.DataFileServiceBean; | ||
import edu.harvard.iq.dataverse.Dataset; | ||
import edu.harvard.iq.dataverse.DatasetLock; | ||
import edu.harvard.iq.dataverse.DatasetServiceBean; | ||
|
@@ -11,7 +12,9 @@ | |
import edu.harvard.iq.dataverse.DataverseRequestServiceBean; | ||
import edu.harvard.iq.dataverse.DataverseServiceBean; | ||
import edu.harvard.iq.dataverse.EjbDataverseEngine; | ||
import edu.harvard.iq.dataverse.FileDownloadServiceBean; | ||
import edu.harvard.iq.dataverse.FileMetadata; | ||
import edu.harvard.iq.dataverse.GuestbookResponseServiceBean; | ||
import edu.harvard.iq.dataverse.TermsOfUseAndAccessValidator; | ||
import edu.harvard.iq.dataverse.UserNotificationServiceBean; | ||
import edu.harvard.iq.dataverse.api.auth.AuthRequired; | ||
|
@@ -73,6 +76,8 @@ | |
import javax.ws.rs.core.HttpHeaders; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import static edu.harvard.iq.dataverse.util.json.JsonPrinter.jsonDT; | ||
import static javax.ws.rs.core.Response.Status.BAD_REQUEST; | ||
import javax.ws.rs.core.UriInfo; | ||
import org.glassfish.jersey.media.multipart.FormDataBodyPart; | ||
|
@@ -102,7 +107,11 @@ public class Files extends AbstractApiBean { | |
SettingsServiceBean settingsService; | ||
@Inject | ||
MakeDataCountLoggingServiceBean mdcLogService; | ||
|
||
@Inject | ||
GuestbookResponseServiceBean guestbookResponseService; | ||
@Inject | ||
DataFileServiceBean dataFileServiceBean; | ||
|
||
private static final Logger logger = Logger.getLogger(Files.class.getName()); | ||
|
||
|
||
|
@@ -818,4 +827,37 @@ public Response getExternalToolFMParams(@Context ContainerRequestContext crc, @P | |
public Response getFixityAlgorithm() { | ||
return ok(systemConfig.getFileFixityChecksumAlgorithm().toString()); | ||
} | ||
|
||
@GET | ||
@AuthRequired | ||
@Path("{id}/guestbookResponses/count") | ||
public Response getCountGuestbookResponses(@Context ContainerRequestContext crc, @PathParam("id") String dataFileId) { | ||
return response(req -> { | ||
DataFile dataFile = execCommand(new GetDataFileCommand(req, findDataFileOrDie(dataFileId))); | ||
return ok(guestbookResponseService.getCountGuestbookResponsesByDataFileId(dataFile.getId()).toString()); | ||
}, getRequestUser(crc)); | ||
} | ||
|
||
@GET | ||
@AuthRequired | ||
@Path("{id}/thumbnailClass") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moot point if we move this logic into the SPA code... But "defaultIcon" or "defaultIconType" would probably better describe what this does (?). |
||
public Response getFileThumbnailClass(@Context ContainerRequestContext crc, @PathParam("id") String dataFileId) { | ||
return response(req -> { | ||
DataFile dataFile = execCommand(new GetDataFileCommand(req, findDataFileOrDie(dataFileId))); | ||
return ok(dataFileServiceBean.getFileThumbnailClass(dataFile)); | ||
}, getRequestUser(crc)); | ||
} | ||
|
||
@GET | ||
@AuthRequired | ||
@Path("{id}/dataTables") | ||
public Response getFileDataTables(@Context ContainerRequestContext crc, @PathParam("id") String dataFileId) { | ||
return response(req -> { | ||
DataFile dataFile = execCommand(new GetDataFileCommand(req, findDataFileOrDie(dataFileId))); | ||
if (!dataFile.isTabularData()) { | ||
return error(BAD_REQUEST, "This operation is only available for tabular files."); | ||
} | ||
return ok(jsonDT(dataFile.getDataTables())); | ||
}, getRequestUser(crc)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need docs for all these in the API Guide.