implemented renaming of wiki page

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-12 08:49:43 +02:00
parent ceebcaff4d
commit 7ddd32bb72
3 changed files with 21 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ package de.srsoftware.umbrella.core.model;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.api.UserService;
@@ -71,9 +72,7 @@ public class WikiPage implements Mappable {
var val = json.get(key);
switch (key){
case ID:
if (!(val instanceof String s)) throw invalidFieldException(ID,"String");
title(s);
break;
throw unprocessable("{0} cannot be altered!",ID);
case CONTENT:
if (!(val instanceof String s)) throw invalidFieldException(CONTENT,"String");
content(s);
@@ -101,6 +100,10 @@ public class WikiPage implements Mappable {
}
}
break;
case TITLE:
if (!(val instanceof String t)) throw invalidFieldException(TITLE,"String");
title(t);
break;
}
}
return this;
@@ -113,6 +116,7 @@ public class WikiPage implements Mappable {
private WikiPage title(String newVal) {
if (title.equals(newVal)) return this;
title = newVal;
version++;
dirtyFields.add(TITLE);
return this;
}