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.wcm.core;
18
19 import javax.jcr.Item;
20 import javax.jcr.Property;
21
22 /**
23 * Created by The eXo Platform SAS
24 * Author : Nguyen Anh Vu
25 * anhvurz90@gmail.com
26 * 5 Jul. 2011
27 */
28 public class PropertyLocation extends ItemLocation {
29
30 /**
31 * Instantiates a new property location.
32 */
33 public PropertyLocation() {
34 super();
35 }
36
37 /**
38 * Instantiates a new property location.
39 *
40 * @param repository the repository
41 * @param workspace the workspace
42 * @param path the path
43 * @param uuid the uuid
44 * @param isSystem if the property session is system
45 */
46 public PropertyLocation(final String repository, final String workspace, final String path, final String uuid,
47 final boolean isSystem) {
48 super(repository, workspace, path, uuid, isSystem);
49 }
50
51 /**
52 * Instantiates a new property location.
53 *
54 * @param repository the repository
55 * @param workspace the workspace
56 * @param path the path
57 * @param uuid the uuid
58 */
59 public PropertyLocation(final String repository, final String workspace, final String path, final String uuid ) {
60 super(repository, workspace, path, uuid, false);
61 }
62
63 /**
64 * Instantiates a new property location.
65 *
66 * @param repository the repository
67 * @param workspace the workspace
68 * @param path the path
69 */
70 public PropertyLocation(final String repository, final String workspace, final String path) {
71 super(repository, workspace, path, null, false);
72 }
73
74 /**
75 * Instantiates a new property location.
76 *
77 */
78 public PropertyLocation(ItemLocation location) {
79 super(location);
80 }
81
82 /**
83 * Get an PropertyLocation object by a property.
84 *
85 * @param property the property
86 *
87 * @return a PropertyLocation object
88 */
89 public static final PropertyLocation getPropertyLocationByProperty(final Property property) {
90 try {
91 ItemLocation itemLocation = ItemLocation.getItemLocationByItem(property);
92 return new PropertyLocation(itemLocation);
93 } catch (Exception e) {
94 return null;
95 }
96 }
97
98 /**
99 * Get a property by a PropertyLocation object.
100 *
101 * @param propertyLocation the PropertyLocation object
102 *
103 * @return a property
104 */
105 public static final Property getPropertyByLocation(final PropertyLocation propertyLocation) {
106 try {
107 Item item = ItemLocation.getItemByLocation(propertyLocation);
108 return (Property)item;
109 } catch (Exception e) {
110 return null;
111 }
112 }
113
114 }