@@ -252,20 +252,29 @@ export class FileJSDataverseRepository implements FileRepository {
252252 }
253253
254254 getById ( id : number , datasetVersionNumber ?: string ) : Promise < File > {
255- return getFileAndDataset
256- . execute ( id , datasetVersionNumber )
257- . then ( ( [ jsFile , jsDataset ] ) =>
258- Promise . all ( [
259- jsFile ,
260- jsDataset ,
261- getDatasetCitation . execute ( jsDataset . id , datasetVersionNumber , includeDeaccessioned ) ,
262- FileJSDataverseRepository . getCitationById ( jsFile . id , datasetVersionNumber ) ,
263- FileJSDataverseRepository . getDownloadCountById ( jsFile . id , jsFile . publicationDate ) ,
264- FileJSDataverseRepository . getPermissionsById ( jsFile . id ) ,
265- FileJSDataverseRepository . getThumbnailById ( jsFile . id ) ,
266- FileJSDataverseRepository . getTabularDataById ( jsFile . id , jsFile . tabularData )
267- ] )
268- )
255+ return FileJSDataverseRepository . getPermissionsById ( id )
256+ . then ( ( permissions ) => {
257+ const includeDeaccessioned = permissions ?. canEditOwnerDataset
258+
259+ return getFileAndDataset
260+ . execute ( id , datasetVersionNumber , includeDeaccessioned )
261+ . then ( ( [ jsFile , jsDataset ] ) => {
262+ return Promise . all ( [
263+ jsFile ,
264+ jsDataset ,
265+ getDatasetCitation . execute ( jsDataset . id , datasetVersionNumber , includeDeaccessioned ) ,
266+ FileJSDataverseRepository . getCitationById (
267+ jsFile . id ,
268+ datasetVersionNumber ,
269+ includeDeaccessioned
270+ ) ,
271+ FileJSDataverseRepository . getDownloadCountById ( jsFile . id , jsFile . publicationDate ) ,
272+ Promise . resolve ( permissions ) ,
273+ FileJSDataverseRepository . getThumbnailById ( jsFile . id ) ,
274+ FileJSDataverseRepository . getTabularDataById ( jsFile . id , jsFile . tabularData )
275+ ] )
276+ } )
277+ } )
269278 . then (
270279 ( [
271280 jsFile ,
@@ -293,7 +302,11 @@ export class FileJSDataverseRepository implements FileRepository {
293302 } )
294303 }
295304
296- private static getCitationById ( id : number , datasetVersionNumber ?: string ) : Promise < string > {
305+ private static getCitationById (
306+ id : number ,
307+ datasetVersionNumber ?: string ,
308+ includeDeaccessioned ?: boolean
309+ ) : Promise < string > {
297310 return getFileCitation
298311 . execute ( id , datasetVersionNumber , includeDeaccessioned )
299312 . catch ( ( error : ReadError ) => {
0 commit comments