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.impl;
17  
18  import javax.jcr.Node;
19  import javax.jcr.Session;
20  
21  import org.apache.commons.logging.Log;
22  import org.apache.commons.logging.LogFactory;
23  import org.apache.portals.graffito.jcr.exception.JcrMappingException;
24  import org.apache.portals.graffito.jcr.exception.PersistenceException;
25  import org.apache.portals.graffito.jcr.exception.RepositoryException;
26  import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
27  import org.apache.portals.graffito.jcr.persistence.objectconverter.BeanConverter;
28  import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
29  
30  public class ParentBeanConverterImpl extends AbstractBeanConverterImpl  implements BeanConverter {
31  
32  	private final static Log log = LogFactory.getLog(ParentBeanConverterImpl.class);
33  	
34  	public ParentBeanConverterImpl(ObjectConverter objectConverter) 
35  	{
36  		super(objectConverter);	
37  	}
38  
39  	public void insert(Session session, Node parentNode, BeanDescriptor descriptor, Object object)
40  			throws PersistenceException, RepositoryException, 	JcrMappingException {
41  	}
42  
43  	public void update(Session session, Node parentNode, 	BeanDescriptor descriptor, Object object)
44  			throws PersistenceException, RepositoryException,	JcrMappingException {
45  	}
46  
47  	public Object getObject(Session session, Node parentNode,BeanDescriptor descriptor, Class beanClass)
48  			throws PersistenceException, RepositoryException,JcrMappingException {
49          try {			
50  			Node grandParentNode = parentNode.getParent();
51  			if (grandParentNode.getPath().equals("/"))
52  			{
53  				return null;
54  			}
55  			return objectConverter.getObject(session, grandParentNode.getPath());
56  			
57  		} catch (javax.jcr.RepositoryException e) {
58  			throw new RepositoryException(e);
59  		} 
60  		
61  	}
62  
63  	public void remove(Session session, Node parentNode,	BeanDescriptor descriptor)
64  	          throws PersistenceException,	RepositoryException, JcrMappingException {
65  
66  	}
67  
68  }