1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.wiki.mow.core.api.wiki;
18
19 import java.util.Collection;
20 import java.util.Map;
21
22 import org.chromattic.api.annotations.OneToMany;
23 import org.chromattic.api.annotations.Path;
24 import org.chromattic.api.annotations.PrimaryType;
25
26 @PrimaryType(name = WikiNodeType.WIKI_TRASH)
27 public abstract class Trash {
28
29 @Path
30 public abstract String getPath();
31
32
33
34
35
36
37
38
39 @OneToMany
40 public abstract Map<String, PageImpl> getChildren();
41
42 public Collection<PageImpl> getChildPages() {
43 return getChildren().values();
44 }
45
46 public boolean isHasPage(String name) {
47 return getChildren().containsKey(name) ;
48 }
49
50 public void addRemovedWikiPage(PageImpl page) {
51 if (page == null) {
52 throw new NullPointerException();
53 }
54 addChild(page.getName(), page);
55 }
56
57 public void addChild(String pageName, PageImpl page) {
58 if (pageName == null) {
59 throw new NullPointerException();
60 }
61 if (page == null) {
62 throw new NullPointerException();
63 }
64 Map<String, PageImpl> children = getChildren();
65 if (children.containsKey(pageName)) {
66 throw new IllegalStateException();
67 }
68 children.put(pageName, page);
69 }
70
71 public PageImpl getPage(String pageName) {
72 if (pageName == null) {
73 throw new NullPointerException();
74 }
75 Map<String, PageImpl> children = getChildren();
76 return children.get(pageName);
77 }
78
79 }