View Javadoc
1   
2   /*
3    * Copyright (C) 2003-2007 eXo Platform SAS.
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Affero General Public License
7    * as published by the Free Software Foundation; either version 3
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, see<http://www.gnu.org/licenses/>.
17   */
18  package org.exoplatform.services.cms;
19  
20  import java.util.Map;
21  
22  import javax.jcr.Node;
23  
24  /**
25   * Stores and moves nodes based on different criteria.
26   *
27   * @LevelAPI Experimental
28   */
29  public interface CmsService {
30  
31  
32    public final static String POST_CREATE_CONTENT_EVENT = "CmsService.event.postCreate";
33    public final static String POST_EDIT_CONTENT_EVENT = "CmsService.event.postEdit";
34    public final static String PRE_CREATE_CONTENT_EVENT = "CmsService.event.preCreate";
35    public final static String PRE_EDIT_CONTENT_EVENT = "CmsService.event.preEdit";
36  
37    /**
38     * Constant string to refer to the property of node in Map.
39     * For getting properties of a specific node in Map,
40     * use key = NODE + propertyName.
41     */
42    public static final String NODE = "/node";
43  
44    /**
45     * Stores a node in a given workspace and repository with given properties.
46     *
47     * @param workspace Name of the workspace.
48     * @param nodetypeName Name of the nodetype.
49     * @param storePath Path of the store node.
50     * @param inputProperties Map of node's properties, including property name and value.
51     * @throws Exception The exception
52     * @return Path of the saved node.
53     */
54    public String storeNode(String workspace,
55                            String nodetypeName,
56                            String storePath,
57                            Map inputProperties) throws Exception;
58    
59    /**
60     * Stores a node in a given repository with given properties.
61     * @param nodetypeName Name of the nodetype.
62     * @param storeHomeNode The parent node where the node is stored.
63     * @param inputProperties Map of node's properties, including property name and value.
64     * @param isAddNew If "true", the new node is added. If "false", the node is updated.
65     * @return Path to the saved node.
66     * @throws Exception The exception
67     */
68    public String storeNode(String nodetypeName,
69                            Node storeHomeNode,
70                            Map inputProperties,
71                            boolean isAddNew) throws Exception;
72    
73    /**
74     * Stores the edited node in a given repository with given properties
75     * used in case that user only has permission to access storeNode but
76     * cannot access parent of storeNode (storeHomeNode).
77     * @param nodetypeName Name of the nodetype.
78     * @param storeNode The store node.
79     * @param inputProperties Map of node's properties, including property name and value.
80     * @param isAddNew If "true", the new node is added. If "false", the node is updated.
81     * @return Path of the saved node.
82     * @throws Exception The exception
83     */
84    public String storeEditedNode(String nodetypeName,
85                                  Node storeNode,
86                                  Map inputProperties,
87                                  boolean isAddNew) throws Exception;
88    
89  
90    /**
91     * Stores a node in a repository with given properties.
92     *
93     * @param nodetypeName Name of the nodetype.
94     * @param storeNode The store node.
95     * @param inputProperties Map of node's properties, including property name and value.
96     * @param isAddNew If "true", the new node is added. If "false", the node is updated.
97     * @return UUID of the saved node.
98     * @throws Exception The exception
99     */
100   public String storeNodeByUUID(String nodetypeName,
101                                 Node storeNode,
102                                 Map inputProperties,
103                                 boolean isAddNew) throws Exception;
104   
105   /**
106    * Moves a node from one workspace to the other, with the same repository.
107    *
108    * @param nodePath Path to the node in the source workspace.
109    * @param srcWorkspace Name of the source workspace.
110    * @param destWorkspace Name of the destination workspace.
111    * @param destPath Path of the destination node.
112    */
113   public void moveNode(String nodePath, String srcWorkspace, String destWorkspace, String destPath);
114 
115   /**
116    * Gets all properties of a node.
117    *
118    * @return Map of properties.
119    */
120   public Map<String, Object> getPreProperties();  
121   
122 }