* Changes the Subject of a Resource. Checks if the new name is already taken, * errors if so.
(oldSubject: string, newSubject: string)
| 260 | * errors if so. |
| 261 | */ |
| 262 | async renameSubject(oldSubject: string, newSubject: string): Promise<void> { |
| 263 | tryValidURL(newSubject); |
| 264 | const old = this.resources.get(oldSubject); |
| 265 | if (old == undefined) { |
| 266 | throw Error(`Old subject does not exist in store: ${oldSubject}`); |
| 267 | } |
| 268 | if (await this.checkSubjectTaken(newSubject)) { |
| 269 | throw Error(`New subject name is already taken: ${newSubject}`); |
| 270 | } |
| 271 | old.setSubject(newSubject); |
| 272 | this.resources.set(newSubject, old); |
| 273 | this.removeResource(oldSubject); |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * Sets the current Agent, used for signing commits. Warning: doing this |
no test coverage detected