-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathUpdateFileMetadata.ts
More file actions
32 lines (29 loc) · 1.54 KB
/
UpdateFileMetadata.ts
File metadata and controls
32 lines (29 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { IFilesRepository } from '../repositories/IFilesRepository'
import { UpdateFileMetadataDTO } from '../dtos/UpdateFileMetadataDTO'
export class UpdateFileMetadata implements UseCase<void> {
private filesRepository: IFilesRepository
constructor(filesRepository: IFilesRepository) {
this.filesRepository = filesRepository
}
/**
* Updates the metadata for a particular File.
* More detailed information about updating a file's metadata behavior can be found in https://guides.dataverse.org/en/latest/api/native-api.html#updating-file-metadata
*
* @param {number | string} [fileId] - The file identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
* @param {UpdateFileMetadataDTO} [updateFileMetadataDTO] - The DTO containing the metadata updates.
* @param {string} [sourceLastUpdateTime] - The lastUpdateTime value from the file. If another user updates the file metadata before you send the update request, data inconsistencies may occur. To prevent this, you can use the optional sourceLastUpdateTime parameter. This parameter must include the lastUpdateTime value corresponding to the file being updated.
* @returns {Promise<void>}
*/
async execute(
fileId: number | string,
updateFileMetadataDTO: UpdateFileMetadataDTO,
sourceLastUpdateTime?: string
): Promise<void> {
await this.filesRepository.updateFileMetadata(
fileId,
updateFileMetadataDTO,
sourceLastUpdateTime
)
}
}