View Javadoc
1   /*
2    * Copyright (C) 2003-2011 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.cms.documents.model.Document;
20  import org.exoplatform.services.cms.drives.DriveData;
21  
22  import javax.jcr.Node;
23  import javax.jcr.RepositoryException;
24  import java.util.List;
25  
26  /**
27   * Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Mar
28   * 22, 2011
29   */
30  public interface DocumentService {
31    public Document findDocById(String id) throws RepositoryException;
32  
33    /**
34     * Get the short link to display a document in the Documents app by its id.
35     * @param workspaceName The workspace of the node
36     * @param nodeId The id of the node
37     * @return The link to open the document
38     * @throws Exception
39     */
40    public String getShortLinkInDocumentsApp(String workspaceName, String nodeId) throws Exception;
41  
42    /** return the URL of the shared document in the Shared Personal Documents folder of the user destination
43     *
44     * @param currentNode
45     * @param username
46     * @return
47     * @throws Exception
48     */
49    default String getDocumentUrlInPersonalDocuments(Node currentNode, String username) throws Exception {
50      return null;
51    }
52  
53    /** return the URL of the shared document in the Shared Documents folder of the space destination
54     *
55     * @param currentNode
56     * @param spaceId
57     * @return
58     * @throws Exception
59     */
60    default String getDocumentUrlInSpaceDocuments(Node currentNode, String spaceId) throws Exception {
61      return null;
62    }
63  
64    /**
65     * Get the link to display a document in the Documents app.
66     * It will try to get the best matching context (personal doc, space doc, ...).
67     * @param nodePath The path of the node
68     * @return The link to open the document
69     * @throws Exception
70     */
71    public String getLinkInDocumentsApp(String nodePath) throws Exception;
72  
73    /**
74     * Get the link to display a document in the Documents app in the given drive.
75     * It will try to get the best matching context (personal doc, space doc, ...).
76     * @param nodePath The path of the node
77     * @param drive The drive to use
78     * @return The link to open the document
79     * @throws Exception
80     */
81    public String getLinkInDocumentsApp(String nodePath, DriveData drive) throws Exception;
82  
83    /**
84     * Get the drive containing the node with the given node path, for the current user.
85     * If several drives contain the node, try to find the best matching.
86     * @param nodePath The path of the node
87     * @return The drive containing the node
88     * @throws Exception
89     */
90    DriveData getDriveOfNode(String nodePath) throws Exception;
91  
92    /**
93     * Get the drive containing the node with the given node path.
94     * If several drives contain the node, try to find the best matching.
95     * @param nodePath The path of the node
96     * @param userId The user id
97     * @param memberships The user memberships
98     * @return The drive containing the node
99     * @throws Exception
100    */
101   public DriveData getDriveOfNode(String nodePath, String userId, List<String> memberships) throws Exception;
102 }