Rev 1814 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
75 | jmachado | 1 | package pt.estgp.estgweb.domain; |
2 | |||
146 | jmachado | 3 | import pt.estgp.estgweb.utils.RoleManager; |
1814 | jmachado | 4 | import pt.estgp.estgweb.utils.Globals; |
146 | jmachado | 5 | |
6 | import java.util.List; |
||
7 | import java.io.Serializable; |
||
8 | |||
9 | import org.apache.log4j.Logger; |
||
10 | |||
75 | jmachado | 11 | /** |
12 | * @author Jorge Machado |
||
13 | * @date 21/Abr/2008 |
||
14 | * @time 14:37:50 |
||
15 | * @see pt.estgp.estgweb.domain |
||
16 | */ |
||
202 | jmachado | 17 | public class BlogImpl extends Blog implements IAddContents, IOwned, IInternal, ITargetRoles, IValid, ICanLoad |
75 | jmachado | 18 | { |
146 | jmachado | 19 | |
20 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(BlogImpl.class); |
||
21 | |||
22 | |||
23 | public BlogImpl() |
||
24 | { |
||
214 | jmachado | 25 | super.setType(null); |
146 | jmachado | 26 | } |
27 | |||
28 | public boolean canAddPost(GenericUserImpl user) |
||
29 | { |
||
208 | jmachado | 30 | return canAddPost(user,false); |
146 | jmachado | 31 | } |
32 | |||
208 | jmachado | 33 | public boolean canAddPost(GenericUserImpl user, boolean transaction) |
34 | { |
||
1782 | jmachado | 35 | return RoleManager.hasRole(getTargetRolesList(), Globals.ALL_ROLE) || (user != null && (user.hasRole(getTargetRolesList()) || user.isSuperuserOrAdmin())) || checkIsOwnedBy(user, transaction); |
208 | jmachado | 36 | } |
37 | |||
146 | jmachado | 38 | public boolean canAddContent(GenericUserImpl u) |
39 | { |
||
40 | return canAddPost(u); |
||
41 | } |
||
208 | jmachado | 42 | public boolean canAddContent(GenericUserImpl u, boolean transaction) |
43 | { |
||
44 | return canAddPost(u,transaction); |
||
45 | } |
||
146 | jmachado | 46 | |
47 | public List<String> getTargetRolesList() |
||
48 | { |
||
49 | return RoleManager.getRolesFromSerial(getTargetRoles()); |
||
50 | } |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Not implemented |
||
55 | * @return null |
||
56 | */ |
||
57 | public List<String> getOwnerRoles() |
||
58 | { |
||
59 | logger.warn("Invoke not implemented method in class:" + getClass().getName()); |
||
60 | return null; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Not implemented here |
||
65 | * @return null |
||
66 | */ |
||
67 | public 1.5.0/docs/api/java/lang/String.html">String getChoosedOwnerRole() |
||
68 | { |
||
69 | logger.warn("Invoke not implemented method in class:" + getClass().getName()); |
||
70 | return null; |
||
71 | } |
||
72 | |||
73 | public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() |
||
74 | { |
||
75 | return getId(); |
||
76 | } |
||
201 | jmachado | 77 | |
78 | public boolean isValid() |
||
79 | { |
||
80 | return isStatus(); |
||
81 | } |
||
202 | jmachado | 82 | |
83 | |||
84 | public boolean canLoad(GenericUserImpl u) |
||
85 | { |
||
1782 | jmachado | 86 | return isStatus() || checkIsOwnedBy(u) || (u != null && u.isSuperuserOrAdmin()); |
202 | jmachado | 87 | } |
88 | |||
89 | public boolean canLoadInOpenTransaction(GenericUserImpl u) |
||
90 | { |
||
205 | jmachado | 91 | return canLoad(u); |
202 | jmachado | 92 | } |
75 | jmachado | 93 | } |