View Javadoc
1   /*
2    * Copyright (C) 2003-2009 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.link;
18  
19  import java.io.InputStream;
20  import java.util.Calendar;
21  
22  import javax.jcr.Node;
23  import javax.jcr.Property;
24  import javax.jcr.RepositoryException;
25  import javax.jcr.Value;
26  import javax.jcr.ValueFormatException;
27  import javax.jcr.lock.LockException;
28  import javax.jcr.nodetype.ConstraintViolationException;
29  import javax.jcr.nodetype.PropertyDefinition;
30  import javax.jcr.version.VersionException;
31  
32  import org.exoplatform.services.wcm.core.PropertyLocation;
33  
34  /**
35   * Created by The eXo Platform SAS
36   * Author : eXoPlatform
37   *          nicolas.filotto@exoplatform.com
38   * 1 avr. 2009
39   */
40  public class PropertyLinkAware extends ItemLinkAware implements Property {
41  
42    private final PropertyLocation propertyLocation;
43  
44    public PropertyLinkAware(String originalWorkspace, String virtualPath, Property property) {
45      super(originalWorkspace, virtualPath, property);
46      this.propertyLocation = PropertyLocation.getPropertyLocationByProperty(property);
47    }
48  
49    public Property getRealProperty() {
50      return PropertyLocation.getPropertyByLocation(propertyLocation);
51    }
52  
53    /**
54     * {@inheritDoc}
55     */
56    public boolean getBoolean() throws ValueFormatException, RepositoryException {
57      return getRealProperty().getBoolean();
58    }
59  
60    /**
61     * {@inheritDoc}
62     */
63    public Calendar getDate() throws ValueFormatException, RepositoryException {
64      return getRealProperty().getDate();
65    }
66  
67    /**
68     * {@inheritDoc}
69     */
70    public PropertyDefinition getDefinition() throws RepositoryException {
71      return getRealProperty().getDefinition();
72    }
73  
74    /**
75     * {@inheritDoc}
76     */
77    public double getDouble() throws ValueFormatException, RepositoryException {
78      return getRealProperty().getDouble();
79    }
80  
81    /**
82     * {@inheritDoc}
83     */
84    public long getLength() throws ValueFormatException, RepositoryException {
85      return getRealProperty().getLength();
86    }
87  
88    /**
89     * {@inheritDoc}
90     */
91    public long[] getLengths() throws ValueFormatException, RepositoryException {
92      return getRealProperty().getLengths();
93    }
94  
95    /**
96     * {@inheritDoc}
97     */
98    public long getLong() throws ValueFormatException, RepositoryException {
99      return getRealProperty().getLong();
100   }
101 
102   /**
103    * {@inheritDoc}
104    */
105   public Node getNode() throws ValueFormatException, RepositoryException {
106     return getRealProperty().getNode();
107   }
108 
109   /**
110    * {@inheritDoc}
111    */
112   public InputStream getStream() throws ValueFormatException, RepositoryException {
113     return getRealProperty().getStream();
114   }
115 
116   /**
117    * {@inheritDoc}
118    */
119   public String getString() throws ValueFormatException, RepositoryException {
120     return getRealProperty().getString();
121   }
122 
123   /**
124    * {@inheritDoc}
125    */
126   public int getType() throws RepositoryException {
127     return getRealProperty().getType();
128   }
129 
130   /**
131    * {@inheritDoc}
132    */
133   public Value getValue() throws ValueFormatException, RepositoryException {
134     return getRealProperty().getValue();
135   }
136 
137   /**
138    * {@inheritDoc}
139    */
140   public Value[] getValues() throws ValueFormatException, RepositoryException {
141     return getRealProperty().getValues();
142   }
143 
144   /**
145    * {@inheritDoc}
146    */
147   public void setValue(Value value) throws ValueFormatException,
148                                   VersionException,
149                                   LockException,
150                                   ConstraintViolationException,
151                                   RepositoryException {
152     getRealProperty().setValue(value);
153   }
154 
155   /**
156    * {@inheritDoc}
157    */
158   public void setValue(Value[] values) throws ValueFormatException,
159                                     VersionException,
160                                     LockException,
161                                     ConstraintViolationException,
162                                     RepositoryException {
163     getRealProperty().setValue(values);
164   }
165 
166   /**
167    * {@inheritDoc}
168    */
169   public void setValue(String value) throws ValueFormatException,
170                                    VersionException,
171                                    LockException,
172                                    ConstraintViolationException,
173                                    RepositoryException {
174     getRealProperty().setValue(value);
175   }
176 
177   /**
178    * {@inheritDoc}
179    */
180   public void setValue(String[] values) throws ValueFormatException,
181                                      VersionException,
182                                      LockException,
183                                      ConstraintViolationException,
184                                      RepositoryException {
185     getRealProperty().setValue(values);
186   }
187 
188   /**
189    * {@inheritDoc}
190    */
191   public void setValue(InputStream value) throws ValueFormatException,
192                                         VersionException,
193                                         LockException,
194                                         ConstraintViolationException,
195                                         RepositoryException {
196     getRealProperty().setValue(value);
197   }
198 
199   /**
200    * {@inheritDoc}
201    */
202   public void setValue(long value) throws ValueFormatException,
203                                  VersionException,
204                                  LockException,
205                                  ConstraintViolationException,
206                                  RepositoryException {
207     getRealProperty().setValue(value);
208   }
209 
210   /**
211    * {@inheritDoc}
212    */
213   public void setValue(double value) throws ValueFormatException,
214                                    VersionException,
215                                    LockException,
216                                    ConstraintViolationException,
217                                    RepositoryException {
218     getRealProperty().setValue(value);
219   }
220 
221   /**
222    * {@inheritDoc}
223    */
224   public void setValue(Calendar value) throws ValueFormatException,
225                                      VersionException,
226                                      LockException,
227                                      ConstraintViolationException,
228                                      RepositoryException {
229     getRealProperty().setValue(value);
230   }
231 
232   /**
233    * {@inheritDoc}
234    */
235   public void setValue(boolean value) throws ValueFormatException,
236                                     VersionException,
237                                     LockException,
238                                     ConstraintViolationException,
239                                     RepositoryException {
240     getRealProperty().setValue(value);
241   }
242 
243   /**
244    * {@inheritDoc}
245    */
246   public void setValue(Node value) throws ValueFormatException,
247                                  VersionException,
248                                  LockException,
249                                  ConstraintViolationException,
250                                  RepositoryException {
251     getRealProperty().setValue(value);
252   }
253 }