|
|
|
|
@ -22,6 +22,7 @@ public class WikiPage implements Mappable {
@@ -22,6 +22,7 @@ public class WikiPage implements Mappable {
|
|
|
|
|
private final Map<Long,Member> members = new HashMap<>(); |
|
|
|
|
private String content; |
|
|
|
|
private Set<String> dirtyFields = new HashSet<>(); |
|
|
|
|
private boolean guestAllowed = false; |
|
|
|
|
|
|
|
|
|
public WikiPage(long id, String title, int version, String content) { |
|
|
|
|
this.id = id; |
|
|
|
|
@ -46,6 +47,15 @@ public class WikiPage implements Mappable {
@@ -46,6 +47,15 @@ public class WikiPage implements Mappable {
|
|
|
|
|
return Set.copyOf(dirtyFields); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean guestAllowed() { |
|
|
|
|
return guestAllowed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void guestAllowed(boolean guestAllowed) { |
|
|
|
|
this.guestAllowed = guestAllowed; |
|
|
|
|
dirtyFields.add(GUEST_ALLOWED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public long id(){ |
|
|
|
|
return id; |
|
|
|
|
} |
|
|
|
|
@ -72,6 +82,10 @@ public class WikiPage implements Mappable {
@@ -72,6 +82,10 @@ public class WikiPage implements Mappable {
|
|
|
|
|
if (!(val instanceof String s)) throw invalidFieldException(CONTENT,"String"); |
|
|
|
|
content(s); |
|
|
|
|
break; |
|
|
|
|
case GUEST_ALLOWED: |
|
|
|
|
if (!(val instanceof Boolean b)) throw invalidFieldException(GUEST_ALLOWED,"Boolean"); |
|
|
|
|
guestAllowed(b); |
|
|
|
|
break; |
|
|
|
|
case MEMBERS: |
|
|
|
|
if (!(val instanceof JSONObject membersJson)) throw invalidFieldException(MEMBERS,"Json"); |
|
|
|
|
for (var uid : membersJson.keySet()){ |
|
|
|
|
@ -131,6 +145,7 @@ public class WikiPage implements Mappable {
@@ -131,6 +145,7 @@ public class WikiPage implements Mappable {
|
|
|
|
|
return Map.of( |
|
|
|
|
ID,id, |
|
|
|
|
CONTENT,Map.of(SOURCE,content,RENDERED,markdown(content)), |
|
|
|
|
GUEST_ALLOWED,guestAllowed, |
|
|
|
|
MEMBERS,memberMap, |
|
|
|
|
TITLE,title, |
|
|
|
|
VERSION,version, |
|
|
|
|
|