1 53 54 package com.Yasna.forum; 55 56 import java.util.Date ; 57 import java.util.Iterator ; 58 import java.util.Enumeration ; 59 60 68 public class CategoryProxy implements Category { 69 70 private Category category; 71 private Authorization authorization; 72 private ForumPermissions permissions; 73 74 81 public CategoryProxy(Category category, Authorization authorization, 82 ForumPermissions permissions) 83 { 84 this.category = category; 85 this.authorization = authorization; 86 this.permissions = permissions; 87 } 88 89 public String getName() { 91 return category.getName(); 92 } 93 public int getOrder(){ 94 return category.getOrder(); 95 } 96 public void setOrder(int param) throws UnauthorizedException{ 97 if (permissions.isSystemOrForumAdmin()) { 98 category.setOrder(param); 99 } 100 else { 101 throw new UnauthorizedException(); 102 } 103 } 104 public int getID() { 105 return category.getID(); 106 } 107 108 public String getDescription() { 109 return category.getDescription(); 110 } 111 112 public Date getCreationDate() { 113 return category.getCreationDate(); 114 } 115 116 public Date getModifiedDate() { 117 return category.getModifiedDate(); 118 } 119 120 public void setModifiedDate(Date modifiedDate) throws UnauthorizedException { 121 if (permissions.isSystemOrForumAdmin()) { 122 category.setModifiedDate(modifiedDate); 123 } 124 else { 125 throw new UnauthorizedException(); 126 } 127 } 128 129 public void setCreationDate(Date creationDate) throws UnauthorizedException { 130 if (permissions.isSystemOrForumAdmin()) { 131 category.setCreationDate(creationDate); 132 } 133 else { 134 throw new UnauthorizedException(); 135 } 136 } 137 138 public void setName(String name) throws UnauthorizedException, 139 CategoryAlreadyExistsException { 140 if (permissions.isSystemOrForumAdmin()) { 141 category.setName(name); 142 } 143 else { 144 throw new UnauthorizedException(); 145 } 146 } 147 148 public void setDescription(String description) throws UnauthorizedException { 149 if (permissions.isSystemOrForumAdmin()) { 150 category.setDescription(description); 151 } 152 else { 153 throw new UnauthorizedException(); 154 } 155 } 156 157 public Iterator forumGroups() { 158 Iterator iterator = category.forumGroups(); 159 return new ForumGroupIteratorProxy(iterator, authorization, permissions); 160 } 161 162 public ForumGroup getForumGroup(int forumGroupID) throws ForumGroupNotFoundException 163 { 164 ForumGroup forumGroup = category.getForumGroup(forumGroupID); 165 return new ForumGroupProxy(forumGroup, authorization, permissions); 167 } 168 169 public void deleteForumGroup(ForumGroup forumGroup) throws UnauthorizedException 170 { 171 if (permissions.isSystemOrForumAdmin()) { 172 category.deleteForumGroup(forumGroup); 173 } 174 else { 175 throw new UnauthorizedException(); 176 } 177 } 178 179 public ForumGroup createForumGroup(String name, String description) throws UnauthorizedException 180 { 181 if (permissions.isSystemOrForumAdmin()) { 182 ForumGroup forumGroup = category.createForumGroup(name, description); 183 return new ForumGroupProxy(forumGroup, authorization, permissions); 184 } 185 else { 186 throw new UnauthorizedException(); 187 } 188 } 189 190 } | Popular Tags |