Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IContentManager |
|
| 1.0;1 |
1 | /** | |
2 | * 2009, Digitalis Informatica. All rights reserved. Distribuicao e Gestao de Informatica, Lda. Estrada de Paco de Arcos | |
3 | * num.9 - Piso -1 2780-666 Paco de Arcos Telefone: (351) 21 4408990 Fax: (351) 21 4408999 http://www.digitalis.pt | |
4 | */ | |
5 | ||
6 | package pt.digitalis.dif.utils.extensions.cms; | |
7 | ||
8 | import java.util.List; | |
9 | import java.util.Set; | |
10 | ||
11 | import pt.digitalis.dif.controller.security.objects.IDIFUser; | |
12 | import pt.digitalis.dif.utils.extensions.cms.exception.ContentItemNotFoundException; | |
13 | import pt.digitalis.dif.utils.extensions.cms.exception.ContentItemWithDuplicateNameAndParentNodeException; | |
14 | import pt.digitalis.dif.utils.extensions.cms.exception.ContentManagerException; | |
15 | import pt.digitalis.dif.utils.extensions.cms.exception.InvalidNameException; | |
16 | import pt.digitalis.dif.utils.extensions.cms.exception.InvalidParentNodeException; | |
17 | import pt.digitalis.dif.utils.extensions.cms.exception.InvalidPathException; | |
18 | import pt.digitalis.dif.utils.extensions.cms.exception.NoAccessException; | |
19 | import pt.digitalis.dif.utils.extensions.cms.exception.NodeNotFoundException; | |
20 | import pt.digitalis.dif.utils.extensions.cms.exception.NodeWithDuplicatePathException; | |
21 | import pt.digitalis.dif.utils.extensions.cms.exception.NodeWithNodesException; | |
22 | ||
23 | /** | |
24 | * @author Pedro Viegas <a href="mailto:pviegas@digitalis.pt">pviegas@digitalis.pt</a><br/> | |
25 | * @created Jun 5, 2009 | |
26 | */ | |
27 | public interface IContentManager { | |
28 | ||
29 | /** | |
30 | * Adds a new content to the repository.<br> | |
31 | * Will assign the ID internally | |
32 | * | |
33 | * @param content | |
34 | * the content to add in the repository | |
35 | * @return the updated content | |
36 | * @throws InvalidParentNodeException | |
37 | * @throws NodeNotFoundException | |
38 | * @throws NoAccessException | |
39 | * @throws ContentItemWithDuplicateNameAndParentNodeException | |
40 | * @throws ContentManagerException | |
41 | */ | |
42 | public ContentItem addContent(ContentItem content) throws InvalidParentNodeException, NodeNotFoundException, | |
43 | NoAccessException, ContentItemWithDuplicateNameAndParentNodeException, ContentManagerException; | |
44 | ||
45 | /** | |
46 | * Adds a new content to the repository<br> | |
47 | * Will assign the ID internally | |
48 | * | |
49 | * @param node | |
50 | * the node to add | |
51 | * @return the added node | |
52 | * @throws InvalidPathException | |
53 | * @throws InvalidNameException | |
54 | * @throws NoAccessException | |
55 | * @throws InvalidParentNodeException | |
56 | * @throws NodeNotFoundException | |
57 | * @throws NodeWithDuplicatePathException | |
58 | * @throws ContentManagerException | |
59 | */ | |
60 | public Node addNode(Node node) throws InvalidPathException, InvalidNameException, NoAccessException, | |
61 | InvalidParentNodeException, NodeNotFoundException, NodeWithDuplicatePathException, ContentManagerException; | |
62 | ||
63 | /** | |
64 | * Begins a Content Manager transaction | |
65 | */ | |
66 | public void beginTransaction(); | |
67 | ||
68 | /** | |
69 | * Commit's a Content Manager transaction | |
70 | */ | |
71 | public void commitTransaction(); | |
72 | ||
73 | /** | |
74 | * Deletes an existing content from the repository | |
75 | * | |
76 | * @param id | |
77 | * the content to delete | |
78 | * @param user | |
79 | * the user that is deleting the content | |
80 | * @return T if all went well | |
81 | * @throws ContentItemNotFoundException | |
82 | * @throws NodeNotFoundException | |
83 | * @throws NoAccessException | |
84 | * @throws ContentManagerException | |
85 | */ | |
86 | public boolean deleteContent(String id, IDIFUser user) throws ContentItemNotFoundException, NodeNotFoundException, | |
87 | NoAccessException, ContentManagerException; | |
88 | ||
89 | /** | |
90 | * Deletes an existing node from the repository | |
91 | * | |
92 | * @param id | |
93 | * the node to delete | |
94 | * @param user | |
95 | * the user that is deleting the node | |
96 | * @return T if all went well | |
97 | * @throws NodeNotFoundException | |
98 | * @throws NoAccessException | |
99 | * @throws NodeWithNodesException | |
100 | * @throws ContentManagerException | |
101 | */ | |
102 | public boolean deleteNode(Long id, IDIFUser user) throws NodeNotFoundException, NoAccessException, | |
103 | NodeWithNodesException, ContentManagerException; | |
104 | ||
105 | /** | |
106 | * Deletes an existing node from the repository. <br> | |
107 | * Will launch an exception if the node is not empty | |
108 | * | |
109 | * @param id | |
110 | * the node to delete | |
111 | * @param user | |
112 | * the user that is deleting the node | |
113 | * @param cascadeDelete | |
114 | * if T will delete all inner nodes and content, if F will launch an exception if the node is not empty | |
115 | * @return T if all went well | |
116 | * @throws NodeNotFoundException | |
117 | * @throws NoAccessException | |
118 | * @throws NodeWithNodesException | |
119 | * @throws ContentManagerException | |
120 | */ | |
121 | public boolean deleteNode(Long id, IDIFUser user, boolean cascadeDelete) throws NodeNotFoundException, | |
122 | NoAccessException, NodeWithNodesException, ContentManagerException; | |
123 | ||
124 | /** | |
125 | * Searches content items by description | |
126 | * | |
127 | * @param description | |
128 | * the content id | |
129 | * @param user | |
130 | * the user who's searching | |
131 | * @return the content list | |
132 | * @throws ContentManagerException | |
133 | */ | |
134 | public List<ContentItem> getContentByDescription(String description, IDIFUser user) throws ContentManagerException; | |
135 | ||
136 | /** | |
137 | * Searches a content item by it's unique identifier | |
138 | * | |
139 | * @param id | |
140 | * the content id | |
141 | * @param user | |
142 | * the user who's searching | |
143 | * @return the content | |
144 | * @throws ContentItemNotFoundException | |
145 | * @throws NoAccessException | |
146 | * @throws NodeNotFoundException | |
147 | * @throws ContentManagerException | |
148 | */ | |
149 | public ContentItem getContentById(String id, IDIFUser user) throws ContentItemNotFoundException, NoAccessException, | |
150 | NodeNotFoundException, ContentManagerException; | |
151 | ||
152 | /** | |
153 | * Searches content items by name | |
154 | * | |
155 | * @param name | |
156 | * the content id | |
157 | * @param user | |
158 | * the user who's searching | |
159 | * @return the content list | |
160 | * @throws ContentManagerException | |
161 | */ | |
162 | public List<ContentItem> getContentByName(String name, IDIFUser user) throws ContentManagerException; | |
163 | ||
164 | /** | |
165 | * Searches content items by parent node | |
166 | * | |
167 | * @param nodeId | |
168 | * the parent node id | |
169 | * @param user | |
170 | * the user who's searching | |
171 | * @return the content list | |
172 | * @throws NodeNotFoundException | |
173 | * @throws ContentManagerException | |
174 | */ | |
175 | public List<ContentItem> getContentByParentNode(Long nodeId, IDIFUser user) throws NodeNotFoundException, | |
176 | ContentManagerException; | |
177 | ||
178 | /** | |
179 | * Searches content items by name and node path | |
180 | * | |
181 | * @param nodeFullPath | |
182 | * the node fullPath from the content will be retrieve | |
183 | * @param name | |
184 | * the content id | |
185 | * @param user | |
186 | * the user who's searching | |
187 | * @return the content object | |
188 | * @throws ContentItemNotFoundException | |
189 | * @throws NodeNotFoundException | |
190 | * @throws NoAccessException | |
191 | * @throws ContentManagerException | |
192 | */ | |
193 | public ContentItem getContentFromNodePathByName(String nodeFullPath, String name, IDIFUser user) | |
194 | throws ContentItemNotFoundException, NodeNotFoundException, NoAccessException, ContentManagerException; | |
195 | ||
196 | /** | |
197 | * get content item ACL | |
198 | * | |
199 | * @param id | |
200 | * the content item ID | |
201 | * @return the ACL | |
202 | * @throws ContentManagerException | |
203 | */ | |
204 | public List<ACLEntry> getContentItemACL(String id) throws ContentManagerException; | |
205 | ||
206 | /** | |
207 | * get node ACL | |
208 | * | |
209 | * @param id | |
210 | * the node ID | |
211 | * @return the ACL | |
212 | * @throws ContentManagerException | |
213 | */ | |
214 | public List<ACLEntry> getNodeACL(Long id) throws ContentManagerException; | |
215 | ||
216 | /** | |
217 | * Searches a node by unique identifier | |
218 | * | |
219 | * @param id | |
220 | * the node ID | |
221 | * @param user | |
222 | * the user who's searching | |
223 | * @return a list of all existing root nodes | |
224 | * @throws NodeNotFoundException | |
225 | * @throws NoAccessException | |
226 | * @throws ContentManagerException | |
227 | */ | |
228 | public Node getNodeById(Long id, IDIFUser user) throws NodeNotFoundException, NoAccessException, | |
229 | ContentManagerException; | |
230 | ||
231 | /** | |
232 | * Searches a node by path | |
233 | * | |
234 | * @param fullPath | |
235 | * the full path of the node the node ID | |
236 | * @param user | |
237 | * the user who's searching | |
238 | * @return a list of all existing root nodes | |
239 | * @throws NodeNotFoundException | |
240 | * @throws NoAccessException | |
241 | * @throws ContentManagerException | |
242 | */ | |
243 | public Node getNodeByPath(String fullPath, IDIFUser user) throws NodeNotFoundException, NoAccessException, | |
244 | ContentManagerException; | |
245 | ||
246 | /** | |
247 | * Searches nodes by description | |
248 | * | |
249 | * @param description | |
250 | * the description of the node to search | |
251 | * @param user | |
252 | * the user who's searching | |
253 | * @return a list of all existing nodes with the description | |
254 | * @throws ContentManagerException | |
255 | */ | |
256 | public List<Node> getNodesByDescription(String description, IDIFUser user) throws ContentManagerException; | |
257 | ||
258 | /** | |
259 | * Searches nodes by description | |
260 | * | |
261 | * @param basePathToSearch | |
262 | * the path to search from | |
263 | * @param description | |
264 | * the name of the node to search | |
265 | * @param user | |
266 | * the user who's searching | |
267 | * @return a list of all existing nodes with the description | |
268 | * @throws ContentManagerException | |
269 | */ | |
270 | public List<Node> getNodesByDescription(String basePathToSearch, String description, IDIFUser user) | |
271 | throws ContentManagerException; | |
272 | ||
273 | /** | |
274 | * Searches nodes by name | |
275 | * | |
276 | * @param name | |
277 | * the name of the node to search | |
278 | * @param user | |
279 | * the user who's searching | |
280 | * @return a list of all existing root nodes. May exist with same name in different parent nodes | |
281 | * @throws ContentManagerException | |
282 | */ | |
283 | public List<Node> getNodesByName(String name, IDIFUser user) throws ContentManagerException; | |
284 | ||
285 | /** | |
286 | * Searches nodes by name | |
287 | * | |
288 | * @param basePathToSearch | |
289 | * the path to search from | |
290 | * @param name | |
291 | * the name of the node to search | |
292 | * @param user | |
293 | * the user who's searching | |
294 | * @return a list of all existing root nodes. May exist with same name in different parent nodes | |
295 | * @throws ContentManagerException | |
296 | */ | |
297 | public List<Node> getNodesByName(String basePathToSearch, String name, IDIFUser user) | |
298 | throws ContentManagerException; | |
299 | ||
300 | /** | |
301 | * Searches nodes by parent node | |
302 | * | |
303 | * @param nodeId | |
304 | * the parent node id | |
305 | * @param user | |
306 | * the user who's searching | |
307 | * @return the content list | |
308 | * @throws NodeNotFoundException | |
309 | * @throws ContentManagerException | |
310 | */ | |
311 | public List<Node> getNodesByParentNode(Long nodeId, IDIFUser user) throws NodeNotFoundException, | |
312 | ContentManagerException; | |
313 | ||
314 | /** | |
315 | * Searches root nodes that user has access | |
316 | * | |
317 | * @param user | |
318 | * the user who's searching | |
319 | * @return a list of all existing root nodes | |
320 | * @throws ContentManagerException | |
321 | */ | |
322 | public List<Node> getRootNodes(IDIFUser user) throws ContentManagerException; | |
323 | ||
324 | /** | |
325 | * Grants group access to content item | |
326 | * | |
327 | * @param contentId | |
328 | * the id of the content to grant access | |
329 | * @param groupId | |
330 | * the group to grant access | |
331 | * @return T if access was granted, F otherwise. | |
332 | * @throws ContentItemNotFoundException | |
333 | * @throws ContentManagerException | |
334 | */ | |
335 | public boolean grantContentAccessToGroup(String contentId, String groupId) throws ContentManagerException; | |
336 | ||
337 | /** | |
338 | * Grants user access to content item | |
339 | * | |
340 | * @param contentId | |
341 | * the id of the content to grant access | |
342 | * @param user | |
343 | * the group to grant access | |
344 | * @return T if access was granted, F otherwise. | |
345 | * @throws ContentItemNotFoundException | |
346 | * @throws ContentManagerException | |
347 | */ | |
348 | public boolean grantContentAccessToUser(String contentId, IDIFUser user) throws ContentItemNotFoundException, | |
349 | ContentManagerException; | |
350 | ||
351 | /** | |
352 | * Grants group access to node | |
353 | * | |
354 | * @param nodeId | |
355 | * the id of the node to grant access | |
356 | * @param groupId | |
357 | * the group to grant access | |
358 | * @return T if access was granted, F otherwise. | |
359 | * @throws NodeNotFoundException | |
360 | * @throws ContentManagerException | |
361 | */ | |
362 | public boolean grantNodeAccessToGroup(Long nodeId, String groupId) throws NodeNotFoundException, | |
363 | ContentManagerException; | |
364 | ||
365 | /** | |
366 | * Grants user access to node | |
367 | * | |
368 | * @param nodeId | |
369 | * the id of the node to grant access | |
370 | * @param user | |
371 | * the user to grant access | |
372 | * @return T if access was granted, F otherwise. | |
373 | * @throws NodeNotFoundException | |
374 | * @throws ContentManagerException | |
375 | */ | |
376 | public boolean grantNodeAccessToUser(Long nodeId, IDIFUser user) throws NodeNotFoundException, | |
377 | ContentManagerException; | |
378 | ||
379 | /** | |
380 | * Grants user access to node | |
381 | * | |
382 | * @param nodePath | |
383 | * the path of the node to grant access | |
384 | * @param user | |
385 | * the user to grant access | |
386 | * @return T if access was granted, F otherwise. | |
387 | * @throws NodeNotFoundException | |
388 | * @throws ContentManagerException | |
389 | */ | |
390 | public boolean grantNodeAccessToUser(String nodePath, IDIFUser user) throws ContentManagerException; | |
391 | ||
392 | /** | |
393 | * Checks if group has access to the content | |
394 | * | |
395 | * @param contentId | |
396 | * the id of the content to check access | |
397 | * @param groupId | |
398 | * the group to check access | |
399 | * @return T if group has access, F otherwise. | |
400 | * @throws ContentItemNotFoundException | |
401 | * @throws NodeNotFoundException | |
402 | * @throws ContentManagerException | |
403 | */ | |
404 | public boolean hasContentAccessGroup(String contentId, String groupId) throws ContentItemNotFoundException, | |
405 | NodeNotFoundException, ContentManagerException; | |
406 | ||
407 | /** | |
408 | * Checks if user has access to the content | |
409 | * | |
410 | * @param content | |
411 | * the content to check access | |
412 | * @param user | |
413 | * the user to check access | |
414 | * @return T if user has access, F otherwise. | |
415 | * @throws ContentItemNotFoundException | |
416 | * @throws NodeNotFoundException | |
417 | * @throws ContentManagerException | |
418 | */ | |
419 | public boolean hasContentAccessUser(ContentItem content, IDIFUser user) throws ContentItemNotFoundException, | |
420 | NodeNotFoundException, ContentManagerException; | |
421 | ||
422 | /** | |
423 | * Checks if user has access to the content | |
424 | * | |
425 | * @param contentId | |
426 | * the id of the content to check access | |
427 | * @param user | |
428 | * the user to check access | |
429 | * @return T if user has access, F otherwise. | |
430 | * @throws ContentItemNotFoundException | |
431 | * @throws NodeNotFoundException | |
432 | * @throws ContentManagerException | |
433 | */ | |
434 | public boolean hasContentAccessUser(String contentId, IDIFUser user) throws ContentItemNotFoundException, | |
435 | NodeNotFoundException, ContentManagerException; | |
436 | ||
437 | /** | |
438 | * Checks if one of the group has access to the node | |
439 | * | |
440 | * @param nodeId | |
441 | * the id of the node to check access | |
442 | * @param groups | |
443 | * the group list to check access | |
444 | * @return T if group has access, F otherwise. | |
445 | * @throws NodeNotFoundException | |
446 | * @throws ContentManagerException | |
447 | */ | |
448 | public boolean hasNodeAccessGroups(Long nodeId, Set<String> groups) throws NodeNotFoundException, | |
449 | ContentManagerException; | |
450 | ||
451 | /** | |
452 | * Checks if user has access to the node | |
453 | * | |
454 | * @param nodeId | |
455 | * the id of the node to check access | |
456 | * @param user | |
457 | * the user to check access | |
458 | * @return T if user has access, F otherwise. | |
459 | * @throws NodeNotFoundException | |
460 | * @throws ContentManagerException | |
461 | */ | |
462 | public boolean hasNodeAccessUser(Long nodeId, IDIFUser user) throws NodeNotFoundException, ContentManagerException; | |
463 | ||
464 | /** | |
465 | * Moves content to another node | |
466 | * | |
467 | * @param contentID | |
468 | * the content ID to move | |
469 | * @param destinationNodeId | |
470 | * the destination node to move to | |
471 | * @param user | |
472 | * the user request the move | |
473 | * @return T if all went well | |
474 | * @throws ContentItemNotFoundException | |
475 | * @throws NodeNotFoundException | |
476 | * @throws NoAccessException | |
477 | * @throws ContentManagerException | |
478 | */ | |
479 | public boolean moveContent(String contentID, Long destinationNodeId, IDIFUser user) | |
480 | throws ContentItemNotFoundException, NodeNotFoundException, NoAccessException, ContentManagerException; | |
481 | ||
482 | /** | |
483 | * Moves a node to another parent node | |
484 | * | |
485 | * @param nodeID | |
486 | * the original node id | |
487 | * @param destinationNodeId | |
488 | * the destination node id | |
489 | * @param user | |
490 | * the user requesting the move operation | |
491 | * @return T if all went well | |
492 | * @throws NodeNotFoundException | |
493 | * @throws NoAccessException | |
494 | * @throws ContentManagerException | |
495 | */ | |
496 | public boolean moveNode(Long nodeID, Long destinationNodeId, IDIFUser user) throws NodeNotFoundException, | |
497 | NoAccessException, ContentManagerException; | |
498 | ||
499 | /** | |
500 | * Revokes group access to content item | |
501 | * | |
502 | * @param contentId | |
503 | * the id of the content to revoke access | |
504 | * @param groupId | |
505 | * the group to revoke access | |
506 | * @return T if access was revoked, F otherwise. | |
507 | * @throws ContentItemNotFoundException | |
508 | * @throws ContentManagerException | |
509 | */ | |
510 | public boolean revokeContentAccessToGroup(String contentId, String groupId) throws ContentItemNotFoundException, | |
511 | ContentManagerException; | |
512 | ||
513 | /** | |
514 | * Revokes user access to content item | |
515 | * | |
516 | * @param contentId | |
517 | * the id of the content to revoke access | |
518 | * @param user | |
519 | * the group to revoke access | |
520 | * @return T if access was revoked, F otherwise. | |
521 | * @throws ContentItemNotFoundException | |
522 | * @throws ContentManagerException | |
523 | */ | |
524 | public boolean revokeContentAccessToUser(String contentId, IDIFUser user) throws ContentItemNotFoundException, | |
525 | ContentManagerException; | |
526 | ||
527 | /** | |
528 | * Revokes group access to node | |
529 | * | |
530 | * @param nodeId | |
531 | * the id of the node to revoke access | |
532 | * @param groupId | |
533 | * the group to revoke access | |
534 | * @return T if access was revoked, F otherwise. | |
535 | * @throws NodeNotFoundException | |
536 | * @throws ContentManagerException | |
537 | */ | |
538 | public boolean revokeNodeAccessToGroup(Long nodeId, String groupId) throws NodeNotFoundException, | |
539 | ContentManagerException; | |
540 | ||
541 | /** | |
542 | * Revokes user access to node | |
543 | * | |
544 | * @param nodeId | |
545 | * the id of the node to revoke access | |
546 | * @param user | |
547 | * the user to revoke access | |
548 | * @return T if access was revoked, F otherwise. | |
549 | * @throws NodeNotFoundException | |
550 | * @throws ContentManagerException | |
551 | */ | |
552 | public boolean revokeNodeAccessToUser(Long nodeId, IDIFUser user) throws NodeNotFoundException, | |
553 | ContentManagerException; | |
554 | ||
555 | /** | |
556 | * Roll back the a Content Manager transaction | |
557 | */ | |
558 | public void rollbackTransaction(); | |
559 | ||
560 | /** | |
561 | * Updates content in the repository | |
562 | * | |
563 | * @param content | |
564 | * the content to update in the repository | |
565 | * @return the updated content | |
566 | * @throws ContentItemNotFoundException | |
567 | * @throws NodeNotFoundException | |
568 | * @throws NoAccessException | |
569 | * @throws ContentItemWithDuplicateNameAndParentNodeException | |
570 | * @throws ContentManagerException | |
571 | */ | |
572 | public ContentItem updateContent(ContentItem content) throws ContentItemNotFoundException, NodeNotFoundException, | |
573 | NoAccessException, ContentItemWithDuplicateNameAndParentNodeException, ContentManagerException; | |
574 | ||
575 | /** | |
576 | * Updates content in the repository | |
577 | * | |
578 | * @param node | |
579 | * the node to update in the repository | |
580 | * @return the updated content | |
581 | * @throws NodeNotFoundException | |
582 | * @throws NoAccessException | |
583 | * @throws ContentManagerException | |
584 | */ | |
585 | public Node updateNode(Node node) throws NodeNotFoundException, NoAccessException, ContentManagerException; | |
586 | ||
587 | } |