1 /*
2 * Copyright (C) 2003-2008 eXo Platform SAS.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Affero General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see<http://www.gnu.org/licenses/>.
16 */
17 package org.exoplatform.services.cms.documents;
18
19 import org.exoplatform.services.jcr.ext.common.SessionProvider;
20
21 import javax.jcr.Node;
22 import javax.jcr.RepositoryException;
23 import javax.jcr.query.InvalidQueryException;
24
25 import java.util.List;
26
27 /**
28 * Created by The eXo Platform SARL
29 * Author : Dang Van Minh
30 * minh.dang@exoplatform.com
31 * Oct 6, 2009
32 * 3:38:23 AM
33 */
34
35 /**
36 * This service used to move documents to trash foder or restore
37 */
38
39 public interface TrashService {
40
41 final static public String EXO_RESTORE_LOCATION = "exo:restoreLocation";
42 final static public String RESTORE_PATH = "exo:restorePath";
43 final static public String RESTORE_WORKSPACE = "exo:restoreWorkspace";
44 final static public String TRASH_ID = "exo:trashId";
45
46 /**
47 * Move node to trash location
48 * @param node Node will be moved to trash
49 * @param sessionProvider User session provider which will be used to get session
50 * @throws Exception
51 * @return -1: move failed.
52 * trashId if moved succesfully
53 */
54 public String moveToTrash(Node node,
55 SessionProvider sessionProvider) throws Exception;
56
57 /**
58 * Move node to trash location with deep
59 * @param node
60 * @param sessionProvider
61 * @param deep
62 * @return -1: move failed.
63 * trashId if moved succesfully
64 * @throws Exception
65 */
66 public String moveToTrash(Node node, SessionProvider sessionProvider, int deep) throws Exception;
67
68 /**
69 * Restore node from trash
70 *
71 * @param trashNodePath The path.
72 * @param sessionProvider The session provider.
73 * @throws Exception
74 */
75 public void restoreFromTrash(String trashNodePath, SessionProvider sessionProvider) throws Exception;
76
77
78 /**
79 * Get all nodes in trash location
80 *
81 * @param sessionProvider
82 * @return All nodes in trash
83 * @throws Exception
84 */
85 public List<Node> getAllNodeInTrash(SessionProvider sessionProvider) throws Exception;
86
87
88 /**
89 * Get all nodes by user in trash location
90 * @param sessionProvider
91 * @param userName
92 * @return all node in trash which moved by user
93 * @throws Exception
94 */
95 public List<Node> getAllNodeInTrashByUser(SessionProvider sessionProvider,
96 String userName) throws Exception;
97
98
99 /**
100 * Removes all 'relationable' property of nodes that have relation to this node
101 * @param node
102 * @param sessionProvider
103 * @throws Exception
104 */
105 public void removeRelations(Node node, SessionProvider sessionProvider) throws Exception;
106
107 /**
108 * Check whether a given node is in Trash or not
109 * @param node a specify node
110 * @return <code>true</code> if node is in Trash, <code>false</code> otherwise.
111 * @throws RepositoryException
112 */
113 public boolean isInTrash(Node node) throws RepositoryException;
114
115 /**
116 * Get the trash hone's node
117 * @return <code>Node</code> the node of trash home
118 */
119 public Node getTrashHomeNode();
120 /**
121 * Get <code>Node</code> in trash folder by trashId
122 * @param trashId ID of node will return
123 * @return <code>Node</code> in trash folder with thrashId, <code>null</code> if thrashId doesn't exist in trash folder
124 * @throws InvalidQueryException
125 * @throws RepositoryException
126 * */
127 public Node getNodeByTrashId(String trashId) throws InvalidQueryException, RepositoryException;
128 }