import { UpdateRepertoireRequest , UpdateRepertoireResponse } from '../../protocol/actions' ; import { assert } from '../../util/assert' ; import { Action } from '../action' ; import { CheckRequestResult } from '../checkrequestresult' ; import { DatabaseWrapper } from '../databasewrapper' ; const MAX_REPERTOIRE_NAME_LENGTH = 200 ; export class UpdateRepertoireAction implements Action < UpdateRepertoireRequest , UpdateRepertoireResponse > { private database_ : DatabaseWrapper ; constructor ( database ) { this . database_ = database ; } checkRequest ( request ) { if ( request . repertoire . name . length > MAX_REPERTOIRE_NAME_LENGTH ) { return Promise . resolve ( { success : false , failureMessage : `Repertoire name must not exceed ` + `${ MAX_REPERTOIRE_NAME_LENGTH } characters.` } ) ; } return Promise . resolve ( { success : true } ) ; } do ( request , user ) { return this . database_ . updateRepertoire ( request . repertoireId , request . repertoire , assert ( user ) ) . then ( ( ) => { return { } ; } ) ; } }