View Javadoc

1   /*
2    * Copyright 2000-2005 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.portals.graffito.jcr.persistence.objectconverter;
17  
18  import javax.jcr.Node;
19  import javax.jcr.Session;
20  
21  import org.apache.portals.graffito.jcr.exception.PersistenceException;
22  
23  
24  /***
25   * Convert any kind of beans into JCR nodes & properties
26   * 
27   * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
28   * @version $Id: Exp $
29   */
30  public interface ObjectConverter
31  {
32  	/***
33  	 * Insert the object 
34  	 * 
35  	 * @param session the JCR session  
36  	 * @param object the object to insert
37  	 * @throws PersistenceException when it is not possible to insert the object
38  	 * 
39  	 */
40      public void insert(Session session, Object object) throws PersistenceException;
41      
42  	/***
43  	 * Update the object 
44  	 * 
45  	 * @param session the JCR session 
46  	 * @param object the object to update
47  	 * @throws PersistenceException when it is not possible to update the object
48  	 */    
49      public void update(Session session, Object object) throws PersistenceException;
50      
51      /***
52       * Retrieve an object from the JCR repo
53       * 
54       * @param session The JCR session 
55       * @param clazz The class assigned to the object to retrieve
56       * @param path the JCR path
57       * @return The object found or null
58       * 
59       * @throws PersistenceException when it is not possible to retrieve the object
60       */
61      public Object getObject(Session session, String path) throws PersistenceException;
62      
63      /***
64       * Retrieve an object from the JCR repo
65       * 
66       * @param session The JCR session 
67       * @param clazz The class assigned to the object to retrieve
68       * @param path the JCR path
69       * @return The object found or null
70       * 
71       * @throws PersistenceException when it is not possible to retrieve the object
72       */
73      public Object getObject(Session session, Class clazz, String path) throws PersistenceException;
74      
75      
76      /***
77       * Retrieve the specified attribute  for the given persistent object.
78       * this attribute is either a bean or a collection. This method is usefull if the corresponding descriptor has an autoRetrieve="false"
79       * 
80       * @param session The JCR session
81       * @param object The persistent object
82       * @param attributeName The name of the attribute to retrieve
83       */
84      public void retrieveMappedAttribute(Session session, Object object, String attributeName);
85  
86      
87      /***
88       * Retrieve all mapped  attributes for the given persistent object.
89       * 
90       * @param session The JCR session     
91       * @param object The persistent object
92       */
93      public void retrieveAllMappedAttributes(Session session, Object object);
94      
95  	/***
96  	 * Insert the object 
97  	 * 
98  	 * @param session the JCR session 
99  	 * @param parentNode The parent node used to store the new JCR element (object) 
100 	 * @param nodeName The node name used to store the object
101 	 * @param object the object to insert
102 	 * @throws PersistenceException when it is not possible to insert the object
103 	 */
104     public void insert(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
105     
106 	/***
107 	 * Update the object 
108 	 * 
109 	 * @param session the JCR session 
110 	 * @param parentNode The parent node used to store the new JCR element (object) 
111 	 * @param nodeName The node name used to store the object
112 	 * @param object the object to update
113 	 * @throws PersistenceException when it is not possible to update the object
114 	 */    
115     public void update(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
116     
117    
118     /***
119      * Get the object JCR path 
120      * 
121      * @param session the JCR session 
122      * @param object the object for which the path has to be retrieve 
123      * @return the object JCR path 
124      * @throws PersistenceException when it is not possible to retrieve the object path
125      */
126     public String getPath(Session session , Object object)  throws PersistenceException;
127 
128 }