@@ -4935,41 +4935,62 @@ public Response getPreviewUrlDatasetVersionCitation(@PathParam("previewUrlToken"
49354935
49364936 @ GET
49374937 @ AuthRequired
4938- @ Path ("{id}/versions/{versionId}/citation" )
4938+ @ Path ("{id}/versions/{versionId}/citation" )
49394939 public Response getDatasetVersionInternalCitation (@ Context ContainerRequestContext crc ,
4940- @ PathParam ("id" ) String datasetId ,
4941- @ PathParam ("versionId" ) String versionId ,
4942- @ QueryParam ("includeDeaccessioned" ) boolean includeDeaccessioned ,
4943- @ Context UriInfo uriInfo ,
4940+ @ PathParam ("id" ) String datasetId , @ PathParam ("versionId" ) String versionId ,
4941+ @ QueryParam ("includeDeaccessioned" ) boolean includeDeaccessioned , @ Context UriInfo uriInfo ,
49444942 @ Context HttpHeaders headers ) {
49454943 try {
4946- return getDatasetVersionCitation (crc , datasetId , versionId , DataCitation .Format .Internal .toString (), false , uriInfo , headers );
4944+ return ok (getDatasetVersionCitationAsString (crc , datasetId , versionId , DataCitation .Format .Internal , false ,
4945+ uriInfo , headers ));
49474946 } catch (WrappedResponse wr ) {
49484947 return wr .getResponse ();
49494948 }
49504949 }
4951-
4950+
4951+ /**
4952+ * Returns one of the DataCitation.Format types as a raw file download (not wrapped in our ok json)
4953+ * @param crc
4954+ * @param datasetId
4955+ * @param versionId
4956+ * @param formatString
4957+ * @param includeDeaccessioned
4958+ * @param uriInfo
4959+ * @param headers
4960+ * @return
4961+ */
49524962 @ GET
49534963 @ AuthRequired
49544964 @ Path ("{id}/versions/{versionId}/citation/{format}" )
4955- public Response getDatasetVersionCitation (@ Context ContainerRequestContext crc ,
4956- @ PathParam ("id" ) String datasetId ,
4957- @ PathParam ("versionId" ) String versionId ,
4958- @ PathParam ("format" ) String formatString ,
4959- @ QueryParam ("includeDeaccessioned" ) boolean includeDeaccessioned ,
4960- @ Context UriInfo uriInfo ,
4961- @ Context HttpHeaders headers ) throws WrappedResponse {
4962- boolean checkFilePerms = false ;
4965+ public Response getDatasetVersionCitation (@ Context ContainerRequestContext crc , @ PathParam ("id" ) String datasetId ,
4966+ @ PathParam ("versionId" ) String versionId , @ PathParam ("format" ) String formatString ,
4967+ @ QueryParam ("includeDeaccessioned" ) boolean includeDeaccessioned , @ Context UriInfo uriInfo ,
4968+ @ Context HttpHeaders headers ) {
4969+
49634970 DataCitation .Format format ;
49644971 try {
49654972 format = DataCitation .Format .valueOf (formatString );
49664973 } catch (IllegalArgumentException e ) {
49674974 return badRequest (BundleUtil .getStringFromBundle ("datasets.api.citation.invalidFormat" ));
49684975 }
4976+ try {
4977+ return Response .ok ().type (DataCitation .getCitationFormatMediaType (format , true )).entity (
4978+ getDatasetVersionCitationAsString (crc , datasetId , versionId , format , false , uriInfo , headers ))
4979+ .build ();
4980+ } catch (WrappedResponse wr ) {
4981+ return wr .getResponse ();
4982+ }
4983+ }
4984+
4985+ public String getDatasetVersionCitationAsString (ContainerRequestContext crc , String datasetId , String versionId ,
4986+ DataCitation .Format format , boolean includeDeaccessioned , UriInfo uriInfo , HttpHeaders headers )
4987+ throws IllegalArgumentException , WrappedResponse {
4988+ boolean checkFilePerms = false ;
4989+
49694990 DataverseRequest req = createDataverseRequest (getRequestUser (crc ));
49704991 DatasetVersion dsv = getDatasetVersionOrDie (req , versionId , findDatasetOrDie (datasetId ), uriInfo , headers ,
49714992 includeDeaccessioned , checkFilePerms );
4972- return Response . ok (). type ( DataCitation . getCitationFormatMediaType ( format , true )). entity ( dsv .getCitation (format , true , false )). build ( );
4993+ return dsv .getCitation (format , true , false );
49734994 }
49744995
49754996 @ POST
0 commit comments