diff --git a/.classpath b/.classpath
deleted file mode 100644
index 461d9623..00000000
--- a/.classpath
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..ef644755
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target/
+derby.log
\ No newline at end of file
diff --git a/.project b/.project
deleted file mode 100644
index 03476b75..00000000
--- a/.project
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- graffito-jcr-mapping
- This subproject contains the JCR Mapping tools
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..d6456956
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/NOTICE.txt b/NOTICE.txt
new file mode 100644
index 00000000..514416eb
--- /dev/null
+++ b/NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Jackrabbit Object Content Mapping
+Copyright 2009 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.txt b/README.txt
new file mode 100644
index 00000000..560ea97c
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,49 @@
+===============================================
+Apache Jackrabbit Object Content Mapping
+
+===============================================
+
+Object Content Mapping (OCM) is an object/JCR persistence and query service.
+This tools lets you to persist Java objects into a JCR compliant repository
+- including association, inheritance, polymorphism, composition, and the
+Java Collections framework.
+
+Furthermore, this object-content mapping component allows you to express
+queries with Java-based criteria, as well as in JCR query language. It
+offers also features like version support and object locking.
+
+OCM is a part of the JCR Commons subproject of Apache Jackrabbit.
+Jackrabbit is a project of the Apache Software Foundation.
+
+Build instructions
+==================
+
+To build OCM, run the following command in this directory:
+
+ mvn clean install
+
+You need Java 5 (or higher) and Maven 2.0.9 (or higher) to do this.
+
+After the build finishes successfully, you can find the compiled OCM
+component in ./target/. The component will also have been installed in your
+local Maven repository.
+
+License (see also LICENSE.txt)
+==============================
+
+Collective work: Copyright 2009 The Apache Software Foundation.
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
new file mode 100644
index 00000000..6c0959bb
--- /dev/null
+++ b/RELEASE-NOTES.txt
@@ -0,0 +1,54 @@
+Release Notes -- Apache Jackrabbit OCM -- Version 2.0.0
+
+Introduction
+------------
+
+This is Apache Jackrabbit OCM 2.0, a subproject of Apache Jackrabbit
+
+Apache Jackrabbit OCM 2.0.0 is release that contains fixes and
+improvements over Jackrabbit OCM 1.5. Apart from the test classes, it
+does not depend on Apache Jackrabbit core, but only on the JCR 2.0 specification
+
+Changes since Jackrabbit 1.5
+------------------------------
+Improvements
+ [OCM-49] ObjectContentManagerImpl should not use workspace move but rather do it through the jcr session
+ [OCM-51] Replace itemExists and getItem logic in ObjectConverterImpl and ObjectContentManagerImpl to nodeExists and getNode
+ [OCM-43] Reviving OCM framework with Jackrabbit 2.x
+ [OCM-52] Replace inefficient ObjectContentManagerImpl#getObjects(Class objectClass, String path) path ....
+ [OCM-58] Make OCM jackrabbit independent and rely on JCR 2.0 only
+ [OCM-54] ObjectContentManagerImpl should not use workspace copy but rather do it through the jcr session
+ [OCM-55] Replace commons logging LogFactory with slf4j LoggerFactory
+
+
+Bug fixes
+ [OCM-53] Fixes needed to work with latest jr 2.4.1 tag
+ [OCM-50] AnnotationDescriptorReader in case of a @Collection annotation incorrectly ....
+ [OCM-48] DefaultCollectionConverterImpl should take nodetype into account for doInsertCollection ....
+ [OCM-42] OCM Versioning is not working as expected
+ [OCM-33] Running the tests without "mvn clean" provides errors
+ [OCM-45] ReflectionUtils.implementsInterface() only checks one interface and returns
+ [OCM-40] Doesn't compile with jackrabbit 2.0.0
+ [OCM-59] Run all unit tests against an in memory repository and extend from AbstractJcrTestCase
+ [OCM-34] referential integrity problem due to ObjectContentManagerImpl usage of ObjectCache
+ [OCM-44] getObjectByUuid throws exception instead of returning null as described in javadoc
+
+New features
+
+Tasks
+ [OCM-56] Remove UserTransactionImpl tests for transactions from OCM project
+ [OCM-1] Move jackrabbit-ocm to JCR Commons
+ [OCM-57] Cleanup exceptions that are outdated or not needed any more
+
+
+About The Apache Software Foundation
+------------------------------------
+
+Established in 1999, The Apache Software Foundation provides organizational,
+legal, and financial support for more than 100 freely-available,
+collaboratively-developed Open Source projects. The pragmatic Apache License
+enables individual and commercial users to easily deploy Apache software;
+the Foundation's intellectual property framework limits the legal exposure
+of its 2,500+ contributors.
+
+For more information, visit http://www.apache.org/
diff --git a/locator.ent b/locator.ent
deleted file mode 100644
index 90b562ad..00000000
--- a/locator.ent
+++ /dev/null
@@ -1,2 +0,0 @@
-
- %locator-ent;
diff --git a/locator.path b/locator.path
deleted file mode 100644
index 6581736d..00000000
--- a/locator.path
+++ /dev/null
@@ -1 +0,0 @@
-../../
\ No newline at end of file
diff --git a/maven.xml b/maven.xml
deleted file mode 100644
index b7c44055..00000000
--- a/maven.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/nbactions.xml b/nbactions.xml
new file mode 100644
index 00000000..e042184a
--- /dev/null
+++ b/nbactions.xml
@@ -0,0 +1,26 @@
+
+
+
+ CUSTOM-Deploy
+ Deploy
+ false
+
+ deploy
+
+
+ true
+
+
+
+ CUSTOM-Build
+ Build
+ false
+
+ clean
+ install
+
+
+ true
+
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..6a453ddd
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,271 @@
+
+
+
+
+
+ 4.0.0
+
+
+ org.apache
+ apache
+ 10
+
+
+
+ jackrabbit-ocm
+ 3.0.3
+ Jackrabbit Object Content Mapping 2.x
+
+ This Jackrabbit subproject is an object/JCR persistence and
+ query service. This tools lets you to persist java objects into
+ a JCR compliant repository - including association, inheritance,
+ polymorphism, composition, and the Java collections framework.
+ Furthermore, this jcr-mapping allows you to express queries in
+ Java-based Criteria, as well as in JCR query language. It offers
+ also features like version support and object locking.
+
+ http://jackrabbit.apache.org/object-content-mapping.html
+ 2004
+
+
+ 2.0
+ 2.8.0
+ 2.1
+ 2.6
+ 3.2.1
+ 1.7.0
+ 1.7.5
+ 4.7
+ 2.9.1
+
+
+
+
+ scm:svn:http://svn.apache.org/repos/asf/jackrabbit/commons/ocm/trunk
+ scm:svn:https://svn.apache.org/repos/asf/jackrabbit/commons/ocm/trunk
+ http://svn.apache.org/viewvc/asf/jackrabbit/commons/ocm/trunk
+
+
+
+
+
+ Jackrabbit Developer List
+ dev-subscribe@jackrabbit.apache.org
+ dev-unsubscribe@jackrabbit.apache.org
+ mailto:dev@jackrabbit.apache.org
+ http://mail-archives.apache.org/mod_mbox/jackrabbit-dev/
+
+
+
+ Jackrabbit User List
+ users-subscribe@jackrabbit.apache.org
+ users-unsubscribe@jackrabbit.apache.org
+ mailto:users@jackrabbit.apache.org
+ http://mail-archives.apache.org/mod_mbox/jackrabbit-users/
+
+
+
+
+
+ https://issues.apache.org/jira/browse/OCM
+
+
+
+
+
+ pedantic
+
+
+
+ org.apache.rat
+ apache-rat-plugin
+
+
+ verify
+
+ check
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ maven-compiler-plugin
+
+ 1.5
+ 1.5
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+ maven-surefire-plugin
+
+
+
+ org.apache.jackrabbit.repository.home
+ target/repository
+
+
+
+
+
+
+ org.apache.rat
+ apache-rat-plugin
+
+
+ derby.log
+
+
+
+
+
+
+
+
+
+
+
+
+
+ javax.jcr
+ jcr
+ ${javax.jcr.version}
+
+
+ commons-digester
+ commons-digester
+ ${commons.digester.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ commons-collections
+ commons-collections
+ ${commons.collection.version}
+
+
+ commons-lang
+ commons-lang
+ ${commons.lang.version}
+
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+
+ cglib
+ cglib
+ 2.2
+
+
+
+ commons-beanutils
+ commons-beanutils
+ ${commons.beanutils.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+
+
+
+ org.apache.jackrabbit
+ jackrabbit-core
+ ${apache.jackrabbit.version}
+ test
+
+
+
+ org.apache.jackrabbit
+ jackrabbit-jcr-tests
+ ${apache.jackrabbit.version}
+ test
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.slf4j
+ slf4j-log4j12
+ ${org.slf4j.version}
+ test
+
+
+ xerces
+ xercesImpl
+ ${xerces.version}
+ test
+
+
+
+
+
+
+ internal
+ Internal Release Repository
+ http://mvn:8080/archiva/repository/internal/
+
+
+ snapshots
+ Internal Snapshot Repository
+ http://mvn:8080/archiva/repository/snapshots/
+
+
+
+
+
diff --git a/project.properties b/project.properties
deleted file mode 100644
index 6234e5a0..00000000
--- a/project.properties
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2004 The Apache Software Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-#-----------------------------------------------------------------------------------------------------
-# MAVEN REPORISTORIES
-#-----------------------------------------------------------------------------------------------------
-maven.repo.remote = http://www.bluesunrise.com/maven/, http://www.ibiblio.org/maven/, http://dist.codehaus.org/, http://cvs.apache.org/repository
-
-#-----------------------------------------------------------------------------------------------------
-# MULTIPROJECTS
-#-----------------------------------------------------------------------------------------------------
-maven.multiproject.type=jar
-maven.license.licenseFile=../../LICENSE.TXT
-#-----------------------------------------------------------------------------------------------------
-# DOC : SITE & PDF DOC
-#-----------------------------------------------------------------------------------------------------
-maven.docs.dest=${basedir}/../../../site/jcr-mapping
-
-# Display the date on the Maven web site
-maven.xdoc.date = left
-
-maven.xdoc.version = ${pom.currentVersion}
-maven.pdf.navigationFile=navigation_pdf.xml
-
-#-----------------------------------------------------------------------------------------------------
-# COMPILE
-#-----------------------------------------------------------------------------------------------------
-maven.compile.deprecation=on
-#maven.compile.source=1.4
-#maven.compile.target=1.4
-#maven.test.source=1.4
diff --git a/project.xml b/project.xml
deleted file mode 100644
index 6865cb1a..00000000
--- a/project.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
- ${basedir}/../../project.xml
- 3
- graffito-jcr-mapping
- org.apache.portals.graffito
- Graffito JCR Mapping
- 1.0-a1-dev
- org.apache.portals.graffito
-
- This subproject contains the JCR Mapping tools
-
- Graffito JCR Mapping Tools
-
-
-
- scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr/jcr-mapping
-
-
- scm:subversion:https://svn.apache.org/repos/asf/incubator/graffito/trunk/jcr/jcr-mapping
-
- http://svn.apache.org/viewcvs
-
-
-
-
-
- org.apache.jackrabbit
- jackrabbit
- 1.0-20060108-SNAPSHOT
-
-
- concurrent
- concurrent
- 1.3.4
-
-
- junit
- junit
- 3.8.1
-
- test
-
-
-
- commons-collections
- commons-collections
- 3.1
-
-
- geronimo-spec
- geronimo-spec-jta
- 1.0-M1
-
-
- jsr170
- jcr
- 1.0
- http://jcp.org/en/jsr/detail?id=170
-
-
- log4j
- log4j
- 1.2.8
-
-
- lucene
- lucene
- 1.4.3
-
-
- xerces
- xercesImpl
- 2.6.2
-
-
- xerces
- xmlParserAPIs
- 2.0.2
-
-
- org.apache.derby
- derby
- 10.1.1.0
-
-
-
-
- commons-beanutils
- jar
- commons-beanutils
- 1.7.0
-
-
-
-
- commons-digester
- jar
- commons-digester
- 1.7
-
-
-
- commons-logging
- 1.0.2
- http://jakarta.apache.org/commons/logging.html
-
-
- commons-lang
- commons-lang
- 2.1
- jar
-
- true
-
-
-
-
-
-
-
- src/java
-
-
- ${basedir}/src/test
-
-
-
-
- org/apache/portals/graffito/jcr/testmodel/**/*.java
-
- **/*TestBase.java
-
-
-
- ${basedir}/src/test
-
- **/*.java
-
-
-
-
-
-
-
- ${basedir}/src/java
-
- **/*.java
-
-
-
-
-
-
-
- maven-javadoc-plugin
- maven-changelog-plugin
- maven-file-activity-plugin
- maven-jcoverage-plugin
- maven-changelog-plugin
- maven-changes-plugin
-
- maven-junit-report-plugin
- maven-jxr-plugin
- maven-pmd-plugin
-
-
-
-
diff --git a/src/docbook/test-docbook.xml b/src/docbook/test-docbook.xml
deleted file mode 100644
index 73206fe0..00000000
--- a/src/docbook/test-docbook.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-Test
-
-
-This is a test
-
-
-
-
-
-
-
-
-
-
-
-
-Col1
-
-
-Col2
-
-
-Col3
-
-
-Col4
-
-
-
-
-
-kklkl
-
-
-kkk
-
-
-klkl
-
-
-kp
-
-
-
-
diff --git a/src/dtd/graffito-jcr-mapping.dtd b/src/dtd/graffito-jcr-mapping.dtd
deleted file mode 100644
index 8cba6a42..00000000
--- a/src/dtd/graffito-jcr-mapping.dtd
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/LockingException.java b/src/java/org/apache/portals/graffito/jcr/exception/LockingException.java
deleted file mode 100644
index 8bc656dc..00000000
--- a/src/java/org/apache/portals/graffito/jcr/exception/LockingException.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-/**
- * Base exception for all exceptions related to JCR Locking feature.
- *
- * @author markoc
- */
-abstract public class LockingException extends PersistenceException {
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/NestableRuntimeException.java b/src/java/org/apache/portals/graffito/jcr/exception/NestableRuntimeException.java
deleted file mode 100644
index 9faeca42..00000000
--- a/src/java/org/apache/portals/graffito/jcr/exception/NestableRuntimeException.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * Nestable runtime exception. Able to wrap a cause exception in JDK previous to 1.4
- *
- * @author Spring framework
- */
-public class NestableRuntimeException extends RuntimeException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = -1939051127461985443L;
-
- /** Root cause of this nested exception */
- private Throwable cause;
-
- /**
- * No-arg constructor used by markup exceptions.
- */
- protected NestableRuntimeException() {
- }
-
- /**
- * Construct a NestableRuntimeException with the specified detail message.
- * @param msg the detail message
- */
- public NestableRuntimeException(String msg) {
- super(msg);
- }
-
- /**
- * Construct a NestableRuntimeException with the specified detail message
- * and nested exception.
- * @param msg the detail message
- * @param ex the nested exception
- */
- public NestableRuntimeException(String msg, Throwable ex) {
- super(msg);
- this.cause = ex;
- }
-
- /**
- * Construct a NestableRuntimeException with the specified
- * nested exception.
- *
- * @param ex the nested exception
- */
- public NestableRuntimeException(Throwable ex) {
- this.cause = ex;
- }
-
- /**
- * Return the nested cause, or null if none.
- */
- public Throwable getCause() {
- // Even if you cannot set the cause of this exception other than through
- // the constructor, we check for the cause being "this" here, as the cause
- // could still be set to "this" via reflection: for example, by a remoting
- // deserializer like Hessian's.
- return ((this.cause == this) ? null : this.cause);
- }
-
- /**
- * Return the detail message, including the message from the nested exception
- * if there is one.
- */
- public String getMessage() {
- if (getCause() == null) {
- return super.getMessage();
- } else {
- return super.getMessage()
- + "; nested exception is "
- + getCause().getClass().getName()
- + ": " + getCause().getMessage();
- }
- }
-
- /**
- * Print the composite message and the embedded stack trace to the specified stream.
- * @param ps the print stream
- */
- public void printStackTrace(PrintStream ps) {
- if (getCause() == null) {
- super.printStackTrace(ps);
- } else {
- ps.println(this);
- getCause().printStackTrace(ps);
- }
- }
-
- /**
- * Print the composite message and the embedded stack trace to the specified writer.
- * @param pw the print writer
- */
- public void printStackTrace(PrintWriter pw) {
- if (getCause() == null) {
- super.printStackTrace(pw);
- } else {
- pw.println(this);
- getCause().printStackTrace(pw);
- }
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java b/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
deleted file mode 100644
index 3f1fe272..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper;
-
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-
-/**
- * This component read the mapping file and gives an access to the ClassDescriptors (the mapping object model)
- *
- * @author Lombart Christophe
- *
- */
-public interface Mapper
-{
- /**
- * Get the mapping defition to be used for a specific java bean
- * @param clazz The java bean class
- * @return The mapping class found for the desired java bean class
- */
- public abstract ClassDescriptor getClassDescriptor(Class clazz);
-}
\ No newline at end of file
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java b/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
deleted file mode 100644
index ac0f0b2b..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2000-20045 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper.impl;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.apache.commons.digester.Digester;
-import org.apache.portals.graffito.jcr.exception.InitMapperException;
-import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.MappingDescriptor;
-
-/**
- * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
- *
- * @author Lombart Christophe
- *
- */
-public class DigesterDescriptorReader
-{
- /**
- * Load all class descriptors found in the xml mapping file.
- *
- * @param stream the xml mapping file reference
- * @return a {@link MappingDescriptor}
- *
- */
- public static MappingDescriptor loadClassDescriptors(InputStream stream)
- {
- try
- {
- Digester digester = new Digester();
- digester.setValidating(true);
-
- digester.addObjectCreate("graffito-jcr", MappingDescriptor.class);
-
- // --------------------------------------------------------------------------------
- // Rules used for the class-descriptor element
- // --------------------------------------------------------------------------------
-
- digester.addObjectCreate("graffito-jcr/class-descriptor", ClassDescriptor.class);
- digester.addSetProperties("graffito-jcr/class-descriptor", "className", "className");
- digester.addSetProperties("graffito-jcr/class-descriptor", "jcrNodeType", "jcrNodeType");
- digester.addSetProperties("graffito-jcr/class-descriptor", "jcrSuperTypes", "jcrSuperTypes");
-
- digester.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");
-
- // --------------------------------------------------------------------------------
- // Rules used for the field-descriptor element
- // --------------------------------------------------------------------------------
-
- digester.addObjectCreate("graffito-jcr/class-descriptor/field-descriptor", FieldDescriptor.class);
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "fieldName", "fieldName");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "fieldType", "fieldType");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrName", "jcrName");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "id", "id");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "path", "path");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrType", "jcrType");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrAutoCreated", "jcrAutoCreated");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrMandatory", "jcrMandatory");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrOnParentVersion", "jcrOnParentVersion");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrProtected", "jcrProtected");
- digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrMultiple", "jcrMultiple");
- digester.addSetNext("graffito-jcr/class-descriptor/field-descriptor", "addFieldDescriptor");
-
- // --------------------------------------------------------------------------------
- // Rules used for the bean-descriptor element
- // --------------------------------------------------------------------------------
-
- digester.addObjectCreate("graffito-jcr/class-descriptor/bean-descriptor", BeanDescriptor.class);
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "fieldName", "fieldName");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrName", "jcrName");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "proxy", "proxy");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrNodeType", "jcrNodeType");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrAutoCreated", "jcrAutoCreated");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrMandatory", "jcrMandatory");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrOnParentVersion", "jcrOnParentVersion");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrProtected", "jcrProtected");
- digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrSameNameSiblings", "jcrSameNameSiblings");
- digester.addSetNext("graffito-jcr/class-descriptor/bean-descriptor", "addBeanDescriptor");
-
- // --------------------------------------------------------------------------------
- // Rules used for the collection-descriptor element
- // --------------------------------------------------------------------------------
-
- digester.addObjectCreate("graffito-jcr/class-descriptor/collection-descriptor", CollectionDescriptor.class);
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "fieldName", "fieldName");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrName", "jcrName");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "proxy", "proxy");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "elementClassName", "elementClassName");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "collectionConverter", "collectionConverterClassName");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "collectionClassName", "collectionClassName");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrNodeType", "jcrNodeType");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrAutoCreated", "jcrAutoCreated");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrMandatory", "jcrMandatory");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrOnParentVersion", "jcrOnParentVersion");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrProtected", "jcrProtected");
- digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "jcrSameNameSiblings", "jcrSameNameSiblings");
- digester.addSetNext("graffito-jcr/class-descriptor/collection-descriptor", "addCollectionDescriptor");
-
- MappingDescriptor mappingDescriptor = (MappingDescriptor) digester.parse(stream);
- return mappingDescriptor;
- }
- catch (Exception e)
- {
- throw new InitMapperException("Impossible to read the xml mapping file", e);
- }
- }
-
- /**
- * Load all class descriptors found in the xml mapping file.
- *
- * @param xmlFile the xml mapping file reference
- * @return a {@link MappingDescriptor}
- *
- */
- public static MappingDescriptor loadClassDescriptors(String xmlFile)
- {
- try
- {
- return loadClassDescriptors(new FileInputStream(xmlFile));
- }
- catch (FileNotFoundException e)
- {
- throw new InitMapperException(e);
- }
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java b/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
deleted file mode 100644
index b2ff1eab..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper.impl;
-
-import java.io.InputStream;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.MappingDescriptor;
-
-/**
- *
- * Digester implementation for {@link org.apache.portals.graffito.jcr.mapper.Mapper}
- *
- * @author Lombart Christophe
- */
-public class DigesterMapperImpl implements Mapper
-{
- private MappingDescriptor mappingDescriptor;
- private Log log = LogFactory.getLog(DigesterMapperImpl.class);
-
- /**
- * Constructor
- *
- * @param xmlFile The xml mapping file to read
- *
- */
- public DigesterMapperImpl(String xmlFile)
- {
- log.info("Read the xml mapping file : " + xmlFile);
- mappingDescriptor = DigesterDescriptorReader.loadClassDescriptors(xmlFile);
- }
-
- /**
- * Constructor
- *
- * @param files a set of xml mapping files to read
- *
- */
- public DigesterMapperImpl(String[] files)
- {
- log.info("Read the xml mapping file : " + files[0]);
- mappingDescriptor = DigesterDescriptorReader.loadClassDescriptors(files[0]);
- for (int i=1; iLombart Christophe
- *
- */
-public class BeanDescriptor
-{
-
- private String fieldName;
- private String jcrName;
- private boolean proxy;
- private String jcrNodeType;
- private boolean jcrAutoCreated;
- private boolean jcrMandatory;
- private String jcrOnParentVersion;
- private boolean jcrProtected;
- private boolean jcrSameNameSiblings;
-
- /**
- * @return Returns the fieldName.
- */
- public String getFieldName()
- {
- return fieldName;
- }
- /**
- * @param fieldName The fieldName to set.
- */
- public void setFieldName(String fieldName)
- {
- this.fieldName = fieldName;
- }
- /**
- * @return Returns the jcrName.
- */
- public String getJcrName()
- {
- return jcrName;
- }
- /**
- * @param jcrName The jcrName to set.
- */
- public void setJcrName(String jcrName)
- {
- this.jcrName = jcrName;
- }
-
-
- /**
- * @return Returns the proxy.
- */
- public boolean isProxy()
- {
- return proxy;
- }
- /**
- * @param proxy The proxy to set.
- */
- public void setProxy(boolean proxy)
- {
- this.proxy = proxy;
- }
-
- /** Getter for property jcrNodeType.
- *
- * @return jcrNodeType
- */
- public String getJcrNodeType()
- {
- return jcrNodeType;
- }
-
- /** Setter for property jcrNodeType.
- *
- * @param value jcrNodeType
- */
- public void setJcrNodeType(String value)
- {
- this.jcrNodeType = value;
- }
-
- /** Getter for property jcrAutoCreated.
- *
- * @return jcrAutoCreated
- */
- public boolean isJcrAutoCreated()
- {
- return jcrAutoCreated;
- }
-
- /** Setter for property jcrAutoCreated.
- *
- * @param value jcrAutoCreated
- */
- public void setJcrAutoCreated(boolean value)
- {
- this.jcrAutoCreated = value;
- }
-
- /** Getter for property jcrMandatory.
- *
- * @return jcrMandatory
- */
- public boolean isJcrMandatory()
- {
- return jcrMandatory;
- }
-
- /** Setter for property jcrMandatory.
- *
- * @param value jcrMandatory
- */
- public void setJcrMandatory(boolean value)
- {
- this.jcrMandatory = value;
- }
-
- /** Getter for property jcrOnParentVersion.
- *
- * @return jcrOnParentVersion
- */
- public String getJcrOnParentVersion()
- {
- return jcrOnParentVersion;
- }
-
- /** Setter for property jcrOnParentVersion.
- *
- * @param value jcrOnParentVersion
- */
- public void setJcrOnParentVersion(String value)
- {
- this.jcrOnParentVersion = value;
- }
-
- /** Getter for property jcrProtected.
- *
- * @return jcrProtected
- */
- public boolean isJcrProtected()
- {
- return jcrProtected;
- }
-
- /** Setter for property jcrProtected.
- *
- * @param value jcrProtected
- */
- public void setJcrProtected(boolean value)
- {
- this.jcrProtected = value;
- }
-
- /** Getter for property jcrSameNameSiblings.
- *
- * @return jcrSameNameSiblings
- */
- public boolean isJcrSameNameSiblings()
- {
- return jcrSameNameSiblings;
- }
-
- /** Setter for property jcrSameNameSiblings.
- *
- * @param value jcrSameNameSiblings
- */
- public void setJcrSameNameSiblings(boolean value)
- {
- this.jcrSameNameSiblings = value;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java b/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
deleted file mode 100644
index 7cd54d7b..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper.model;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-/**
- *
- * ClassDescriptor is used by the mapper to read general information on a class
- *
- * @author Lombart Christophe
- *
- */
-public class ClassDescriptor
-{
-
- private String className;
- private String jcrNodeType;
- private String jcrSuperTypes;
- private FieldDescriptor idFieldDescriptor;
- private FieldDescriptor pathFieldDescriptor;
-
- private HashMap fieldDescriptors = new HashMap();
- private HashMap beanDescriptors = new HashMap();
- private HashMap collectionDescriptors = new HashMap();
- private HashMap fieldNames = new HashMap();
-
-
- /**
- * @return Returns the className.
- */
- public String getClassName()
- {
- return className;
- }
- /**
- * @param className The className to set.
- */
- public void setClassName(String className)
- {
- this.className = className;
- }
-
-
- /**
- * @return Returns the jcrNodeType.
- */
- public String getJcrNodeType()
- {
- return jcrNodeType;
- }
- /**
- * @param jcrNodeType The jcrNodeType to set.
- */
- public void setJcrNodeType(String jcrNodeType)
- {
- this.jcrNodeType = jcrNodeType;
- }
-
- /**
- * Add a new FielDescriptor
- * @param fieldDescriptor the new field descriptor to add
- */
- public void addFieldDescriptor(FieldDescriptor fieldDescriptor )
- {
- fieldDescriptor.setClassDescriptor(this);
- if (fieldDescriptor.isId())
- {
- this.idFieldDescriptor = fieldDescriptor;
- }
-
- if (fieldDescriptor.isPath())
- {
- this.pathFieldDescriptor = fieldDescriptor;
- }
-
- fieldDescriptors.put(fieldDescriptor.getFieldName(), fieldDescriptor);
- fieldNames.put(fieldDescriptor.getFieldName(), fieldDescriptor.getJcrName());
- }
-
- /**
- * Get the FieldDescriptor to used for a specific java bean attribute
- * @param fieldName The java bean attribute name
- *
- * @return the {@link FieldDescriptor} found or null
- */
- public FieldDescriptor getFieldDescriptor(String fieldName)
- {
- return (FieldDescriptor) fieldDescriptors.get(fieldName);
- }
-
- /**
- *
- * @return all {@link FieldDescriptor} defined in this ClassDescriptor
- */
- public Collection getFieldDescriptors()
- {
- return fieldDescriptors.values();
- }
-
- /**
- * Add a new BeanDescriptor
- * @param beanDescriptor the new bean descriptor to add
- */
-
- public void addBeanDescriptor(BeanDescriptor beanDescriptor )
- {
- beanDescriptors.put(beanDescriptor.getFieldName(), beanDescriptor);
- fieldNames.put(beanDescriptor.getFieldName(), beanDescriptor.getJcrName());
- }
-
- /**
- * Get the BeanDescriptor to used for a specific java bean attribute
- * @param fieldName The java bean attribute name
- *
- * @return the {@link BeanDescriptor} found or null
- */
- public BeanDescriptor getBeanDescriptor(String fieldName)
- {
- return (BeanDescriptor) beanDescriptors.get(fieldName);
- }
-
-
- /**
- * @return all {@link BeanDescriptor} defined in this ClassDescriptor
- */
- public Collection getBeanDescriptors()
- {
- return beanDescriptors.values();
- }
-
-
- /**
- * Add a new CollectionDescriptor
- * @param collectionDescriptor the new collection descriptor to add
- */
-
- public void addCollectionDescriptor(CollectionDescriptor collectionDescriptor )
- {
- collectionDescriptor.setClassDescriptor(this);
- collectionDescriptors.put(collectionDescriptor.getFieldName(), collectionDescriptor);
- fieldNames.put(collectionDescriptor.getFieldName(), collectionDescriptor.getJcrName());
- }
-
- /**
- * Get the CollectionDescriptor to used for a specific java bean attribute
- * @param fieldName The java bean attribute name
- *
- * @return the {@link CollectionDescriptor} found or null
- */
- public CollectionDescriptor getCollectionDescriptor(String fieldName)
- {
- return (CollectionDescriptor) collectionDescriptors.get(fieldName);
- }
-
- /**
- * @return all {@link BeanDescriptor} defined in this ClassDescriptor
- */
- public Collection getCollectionDescriptors()
- {
- return collectionDescriptors.values();
- }
-
- /**
- * @return the fieldDescriptor ID
- */
- public FieldDescriptor getIdFieldDescriptor()
- {
- return idFieldDescriptor;
- }
-
- /**
- * @return the fieldDescriptor path
- */
- public FieldDescriptor getPathFieldDescriptor()
- {
- return pathFieldDescriptor;
- }
-
- /**
- * Check if this class has an ID
- * @return true if the class has an ID
- */
- public boolean hasIdField()
- {
- return this.idFieldDescriptor != null;
- }
-
- /**
- * Get the JCR name used for one of the object attributes
- * @param fieldName the object attribute name (can be an atomic field, bean field or a collection field)
- * @return the JCR name found
- */
- public String getJcrName(String fieldName)
- {
- return (String) this.fieldNames.get(fieldName);
- }
-
- /** Get the JCR node super types.
- *
- * @return jcrSuperTypes
- */
- public String getJcrSuperTypes()
- {
- return jcrSuperTypes;
- }
-
- /** Setter for JCR super types.
- *
- * @param superTypes Comma separated list of JCR node super types
- */
- public void setJcrSuperTypes(String superTypes)
- {
- this.jcrSuperTypes = superTypes;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java b/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
deleted file mode 100644
index ce708697..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper.model;
-
-/**
- *
- *
- * FieldDescriptor is used by the mapper to read general information on a atomic field
- *
- * @author Lombart Christophe
- *
- */
-public class FieldDescriptor
-{
- private String fieldName;
- private String fieldType;
- private Class fieldTypeClass;
- private String jcrName;
- private String jcrType;
- private boolean jcrAutoCreated;
- private boolean jcrMandatory;
- private String jcrOnParentVersion;
- private boolean jcrProtected;
- private boolean jcrMultiple;
- private ClassDescriptor classDescriptor;
- private boolean id;
- private boolean path;
-
- /**
- * @return Returns the fieldName.
- */
- public String getFieldName()
- {
- return fieldName;
- }
-
- /**
- * @param fieldName The fieldName to set.
- */
- public void setFieldName(String fieldName)
- {
- this.fieldName = fieldName;
- }
-
- /**
- * @return the primitive or fully qualified class of the field
- * or null if not specified in the mapping
- */
- public String getFieldType()
- {
- return this.fieldType;
- }
-
- /**
- * Sets the type of the field. It supports primitive types, specified as
- * int, long, etc or fully qualified class names.
- *
- * @param fieldType the type of the field
- */
- public void setFieldType(String fieldType)
- {
- this.fieldType = fieldType;
- }
-
- /**
- * @return the field class of the field
- * or null if not specified in the mapping
- * or if the class was not found
- */
- public Class getFieldTypeClass()
- {
- if (this.fieldType == null) {
- return null;
- }
- if (this.fieldTypeClass == null) {
- this.fieldTypeClass = loadFieldTypeClass();
- }
-
- return this.fieldTypeClass;
- }
-
- /**
- * @return Returns the jcrName.
- */
- public String getJcrName()
- {
- return jcrName;
- }
-
- /**
- * @param jcrName The jcrName to set.
- */
- public void setJcrName(String jcrName)
- {
- this.jcrName = jcrName;
- }
-
- /**
- *
- * @return the associated class descriptor
- */
- public ClassDescriptor getClassDescriptor()
- {
- return classDescriptor;
- }
-
- /**
- * Set the associated class descriptor
- * @param classDescriptor the class descriptor to set
- */
- public void setClassDescriptor(ClassDescriptor classDescriptor)
- {
- this.classDescriptor = classDescriptor;
- }
-
- /**
- * @return true if the field is the class ID
- */
- public boolean isId()
- {
- return id;
- }
-
- /**
- *
- * @param id
- */
- public void setId(boolean id)
- {
- this.id = id;
- }
-
- /**
- * @return Returns true if the field is the object JCR path.
- */
- public boolean isPath()
- {
- return path;
- }
-
- /**
- * @param path The path to set.
- */
- public void setPath(boolean path)
- {
- this.path = path;
- }
-
- /** Getter for property jcrType.
- *
- * @return jcrType
- */
- public String getJcrType()
- {
- return jcrType;
- }
-
- /** Setter for property jcrType.
- *
- * @param value jcrType
- */
- public void setJcrType(String value)
- {
- this.jcrType = value;
- }
-
- /** Getter for propery jcrAutoCreated.
- *
- * @return jcrAutoCreated
- */
- public boolean isJcrAutoCreated()
- {
- return jcrAutoCreated;
- }
-
- /** Setter for property jcrAutoCreated.
- *
- * @param value jcrAutoCreated
- */
- public void setJcrAutoCreated(boolean value)
- {
- this.jcrAutoCreated = value;
- }
-
- /** Getter for property jcrMandatory.
- *
- * @return jcrMandatory
- */
- public boolean isJcrMandatory()
- {
- return jcrMandatory;
- }
-
- /** Setter for property jcrMandatory.
- *
- * @param value jcrMandatory
- */
- public void setJcrMandatory(boolean value)
- {
- this.jcrMandatory = value;
- }
-
- /** Getter for property jcrOnParentVersion.
- *
- * @return jcrOnParentVersion
- */
- public String getJcrOnParentVersion()
- {
- return jcrOnParentVersion;
- }
-
- /** Setter for property jcrOnParentVersion.
- *
- * @param value jcrOnParentVersion
- */
- public void setJcrOnParentVersion(String value)
- {
- this.jcrOnParentVersion = value;
- }
-
- /** Getter for property jcrProtected.
- *
- * @return jcrProtected
- */
- public boolean isJcrProtected()
- {
- return jcrProtected;
- }
-
- /** Setter for property jcrProtected.
- *
- * @param value jcrProtected
- */
- public void setJcrProtected(boolean value)
- {
- this.jcrProtected = value;
- }
-
- /** Getter for property jcrMultiple.
- *
- * @return jcrMultiple
- */
- public boolean isJcrMultiple()
- {
- return jcrMultiple;
- }
-
- /** Setter for property jcrMultiple.
- *
- * @param value jcrMultiple
- */
- public void setJcrMultiple(boolean value)
- {
- this.jcrMultiple = value;
- }
-
- /**
- * Initialize the fieldTypeClass.
- *
- * @return the primitive class or the class accordign to fieldType
- */
- private Class loadFieldTypeClass() {
- if (this.fieldType == null)
- {
- return null;
- }
- if ("byte".equals(this.fieldType))
- {
- return byte.class;
- }
- else if ("short".equals(this.fieldType))
- {
- return short.class;
- }
- else if ("int".equals(this.fieldType))
- {
- return int.class;
- }
- else if ("long".equals(this.fieldType))
- {
- return long.class;
- }
- else if ("float".equals(this.fieldType))
- {
- return float.class;
- }
- else if ("double".equals(this.fieldType))
- {
- return double.class;
- }
- else if ("char".equals(this.fieldType))
- {
- return char.class;
- }
- else if ("boolean".equals(this.fieldType))
- {
- return boolean.class;
- }
- else
- {
- try {
- return Class.forName(this.fieldType);
- }
- catch (ClassNotFoundException cnfe)
- {
- ; // nothing to do; it will be dynamically determined
- }
- }
-
- return null;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java b/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
deleted file mode 100644
index a9b472dd..00000000
--- a/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.mapper.model;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This class match to the complete xml mapping files.
- * it contains mainly a collection of {@link ClassDescriptor}
- *
- * @author Lombart Christophe
- * @version $Id: Exp $
- */
-public class MappingDescriptor
-{
- private HashMap classDescriptors = new HashMap();
-
- /**
- * Add a new ClassDescriptor
- *
- * @param classDescriptor The class descriptor to add
- */
- public void addClassDescriptor(ClassDescriptor classDescriptor)
- {
- classDescriptors.put(classDescriptor.getClassName(), classDescriptor);
- }
-
- /**
- * Get the classdescriptor to used for the class
- * @param className the class name
- * @return the class descriptor found or null
- */
- public ClassDescriptor getClassDescriptor(String className)
- {
- return (ClassDescriptor) classDescriptors.get(className);
- }
-
- /**
- * Get all class descriptors
- * @return all class descriptors found
- */
- public Map getClassDescriptors()
- {
- return classDescriptors;
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java b/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
deleted file mode 100644
index 2652171b..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.jcr.version.VersionException;
-
-import org.apache.portals.graffito.jcr.exception.IllegalUnlockException;
-import org.apache.portals.graffito.jcr.exception.LockedException;
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.query.Query;
-import org.apache.portals.graffito.jcr.query.QueryManager;
-import org.apache.portals.graffito.jcr.version.Version;
-import org.apache.portals.graffito.jcr.version.VersionIterator;
-
-/**
- * The persistence manager encapsulates a JCR session.
- * This is the main component used to manage objects into the JCR repository.
- *
- * @author Sandro Boehme
- * @author Lombart Christophe
- *
- */
-public interface PersistenceManager
-{
-
- /**
- * Check if an object exists
- * @param path the object path
- * @return true if the item exists
- * @throws PersistenceException when it is not possible to check if the item exist
- */
- public boolean objectExists(String path) throws PersistenceException;
-
-
- /**
- * Can this persistence manager insert, update, delete, ... that type?
- *
- * @param clazz class for question
- * @return true if the class is persistence
- */
- boolean isPersistent(Class clazz);
-
-
- /**
- * Insert an object into the JCR repository
- *
- * @param object the object to add
- * @throws PersistenceException when it is not possible to insert the object
- */
- public void insert(Object object) throws PersistenceException;
-
- /**
- * Update an object
- *
- * @param object the object to update
- * @throws PersistenceException when it is not possible to update the object
- */
- public void update(Object object) throws PersistenceException;
-
- /**
- * Get an object from the JCR repository
- * @param objectClass the object class
- * @param path the object path
- * @return the object found or null
- *
- * @throws PersistenceException when it is not possible to retrieve the object
- */
- public Object getObject(Class objectClass, String path) throws PersistenceException;
-
- /**
- * Get an object from the JCR repository
- * @param objectClass the object class
- * @param path the object path
- * @param versionNumber The desired object version number
- * @return the object found or null
- *
- * @throws PersistenceException when it is not possible to retrieve the object
- */
- public Object getObject(Class objectClass, String path, String versionNumber) throws PersistenceException;
-
-
- /**
- * Remove an object from a JCR repository
- * @param path the object path
- * @throws PersistenceException when it is not possible to remove the object
- *
- */
- public void remove(String path) throws PersistenceException;
-
-
- /**
- * Remove an object from a JCR repository
- * @param object the object to remove
- * @throws PersistenceException when it is not possible to remove the object
- *
- */
- public void remove(Object object) throws PersistenceException;
-
- /**
- * Remove all objects matching to a query
- * @param query The query used to find the objects to remove
- * @throws PersistenceException when it is not possible to remove all objects
- *
- */
- public void remove(Query query) throws PersistenceException;
-
-
- /**
- * Retrieve an object matching to a query
- * @param query The Graffito Query object used to seach the object
- * @return The object found or null
- * @throws PersistenceException when it is not possible to retrieve the object
- *
- */
- public Object getObject(Query query) throws PersistenceException;
-
-
- /**
- * Retrieve some objects matching to a query
- * @param query The query used to seach the objects
- * @return a collection of objects found
- * @throws PersistenceException when it is not possible to retrieve the objects
- *
- */
- public Collection getObjects(Query query) throws PersistenceException;
-
-
- /**
- * Retrieve some objects matching to a query.
- *
- * @param query The query used to seach the objects
- * @return an iterator of objects found
- * @throws PersistenceException when it is not possible to retrieve the objects
- */
- public Iterator getObjectIterator (Query query) throws PersistenceException;
-
-
- /**
- * Checkout - Create a new version
- * This is only possible if the object is based on mix:versionable node type
- *
- * @param path The object path
- * @throws VersionException when it is not possible to create a new version
- */
- public void checkout(String path) throws VersionException;
-
- /**
- * Checkin an object
- * @param path the object path
- * @throws VersionException when it is not possible to checkin
- */
- public void checkin(String path) throws VersionException;
-
- /**
- * Checkin an object and apply some labels to this new version
- * Within a particular object path, a given label may appear a maximum of once
- * @param path The object path
- * @param versionLabels the version labels to apply to the new version
- * @throws VersionException when it is possible to checkin
- */
- public void checkin(String path, String[] versionLabels) throws VersionException;
-
-
- /**
- * Get all version labels assigned to a particular object version
- * @param path the object path
- * @param versionName the object version name (1.0, ...)
- * @return a array of string (version labels)
- * @throws VersionException when it is not to get all version labels
- */
- public String[] getVersionLabels(String path, String versionName) throws VersionException;
-
-
- /**
- * Get all version labels assigned to all versions
- * @param path the object path
- * @return a array of string (version labels)
- * @throws VersionException when it is not to get all version labels
- */
- public String[] getAllVersionLabels(String path) throws VersionException;
-
- /**
- * Add a new label to a particular version
- * @param path the object path
- * @param versionName the object versio name (1.0, 1.1, ...)
- * @param versionLabel The new label to apply
- * @throws VersionException when it is not possible to add a new version label to this version
- */
- public void addVersionLabel(String path, String versionName, String versionLabel) throws VersionException;
-
-
- /**
- * Get all object versions
- * @param path the object path
- * @return a version iterator
- * @throws VersionException when it is not possible to retrieve all versions
- */
- public VersionIterator getAllVersions(String path) throws VersionException;
-
- /**
- * Get the first object version
- * @param path the object path
- * @return the first version found
- * @throws VersionException when it is not possible to get the root version
- */
- public Version getRootVersion(String path) throws VersionException;
-
- /**
- * Get the lastest object version
- * @param path the object path
- * @return the last version found
- * @throws VersionException when it is not possible to get the last version
- */
- public Version getBaseVersion(String path) throws VersionException;
- /**
- * Get a particular version
- * @param path the object path
- * @param versionName the version name
- * @return the version found or null
- * @throws VersionException when it is not possible to retrieve this particular version
- */
- public Version getVersion(String path, String versionName) throws VersionException;
-
-
- /**
- * Save all modifications made by the persistence manager
- *
- * @throws PersistenceException when it is not possible to save all pending operation into the JCR repo
- */
- public void save() throws PersistenceException;
-
- /**
- * Close the session
- * @throws PersistenceException when it is not possible to logout
- */
- public void logout() throws PersistenceException;
-
- /**
- * Lock object saved on {@param path }.
- *
- * @param path
- * path to saved object.
- * @param isDeep
- * is lock deep? See JCR spec: 8.4.3 Shallow and Deep Locks
- * @param isSessionScoped
- * is lock session scoped? See JCR spec: Session-scoped and Open-scoped Locks
- * @return lock token - see JCR spec: 8.4.6 Lock Token; Other user with this token can perform unlock
- *
- * @throws LockedException
- * if path is locked (cannot lock same path again)
- */
- String lock(String path, boolean isDeep, boolean isSessionScoped) throws LockedException;
-
- /**
- * Unlock object stored on {@param path }.
- *
- * @param path path to stored object
- *
- *
- * @param lockToken
- * see JCR spec: 8.4.6 Lock Token; can be null
- *
- * @throws IllegalUnlockException
- * throws if the current operation does not own the current lock
- */
- void unlock(String path, String lockToken) throws IllegalUnlockException;
-
- /**
- * Is that path locked?
- *
- * @param absPath
- * @return true if path locked
- */
- boolean isLocked(String absPath);
-
- /**
- *
- * @return The query manager reference
- */
- QueryManager getQueryManager();
-
-}
\ No newline at end of file
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java
deleted file mode 100644
index 49e18ae3..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
-
-/**
- * Abstract implementation for {@link org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter}
- *
- * @author Christophe Lombart
- *
- */
-public abstract class AbstractAtomicTypeConverterImpl implements AtomicTypeConverter
-{
-
- private ValueFactory valueFactory;
-
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public AbstractAtomicTypeConverterImpl()
- {
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public AbstractAtomicTypeConverterImpl(ValueFactory factory)
- {
- super();
- valueFactory = factory;
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public abstract Value getValue(Object propValue);
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public abstract Object getObject(Value value);
-
- /**
- * Set the JCR value factory
- *
- * @param valueFactory The value factory to set
- */
- public void setValueFactory(ValueFactory valueFactory)
- {
- this.valueFactory = valueFactory;
- }
-
- /**
- * @return the JCR value factory
- */
- public ValueFactory getValueFactory()
- {
- return this.valueFactory;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java
deleted file mode 100644
index d1043493..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import java.io.InputStream;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- *
- * Binary Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class BinaryTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public BinaryTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public BinaryTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- return this.getValueFactory().createValue((InputStream) propValue);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- return value.getStream();
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString() , e);
- }
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
- throw new IncorrectAtomicTypeException("Binary cannot be convert into string");
- }
-
-
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java
deleted file mode 100644
index ffd8c169..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- * Boolean Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class BooleanTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public BooleanTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public BooleanTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- boolean value = ((Boolean) propValue).booleanValue();
- return this.getValueFactory().createValue(value);
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- return new Boolean(value.getBoolean());
- }
- catch (Exception e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString() , e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return ((Boolean) object).booleanValue() ? "true()" : "false()";
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
deleted file mode 100644
index 0edd5c84..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- *
- * Byte Array Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class ByteArrayTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public ByteArrayTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public ByteArrayTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- String value = new String((byte[]) propValue);
- return getValueFactory().createValue(value);
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- return value.getString().getBytes();
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString() , e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return "'" + object.toString() + "'";
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java
deleted file mode 100644
index 2377ce8a..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import java.util.Calendar;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- * Calendar Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class CalendarTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public CalendarTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public CalendarTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- return this.getValueFactory().createValue(((Calendar) propValue).getTimeInMillis());
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
-
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(value.getLong());
- return calendar;
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- Calendar calendar = (Calendar) object;
- return new Long(calendar.getTimeInMillis()).toString();
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java
deleted file mode 100644
index 1d308b63..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- * Double Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class DoubleTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public DoubleTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
-
- public DoubleTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- double value = ((Double) propValue).doubleValue();
- return this.getValueFactory().createValue(value);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- double beanPropValue = value.getDouble();
- return new Double(beanPropValue);
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return object.toString();
- }
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java
deleted file mode 100644
index 8f27e6be..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- * Int Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class IntTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public IntTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public IntTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- long value = ((Integer) propValue).intValue();
- return this.getValueFactory().createValue(value);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- int beanPropValue = (int) value.getLong();
- return new Integer(beanPropValue);
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return object.toString();
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java
deleted file mode 100644
index 3b4c8c38..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- *
- * Long Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class LongTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public LongTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public LongTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
-
- long value = ((Long) propValue).longValue();
- return this.getValueFactory().createValue(value);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- long beanPropValue = value.getLong();
- return new Long(beanPropValue);
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return object.toString();
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java
deleted file mode 100644
index d9a75852..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- *
- * String Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class StringTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public StringTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public StringTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- return this.getValueFactory().createValue((String) propValue);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- return value.getString();
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return "'" + object.toString() + "'";
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java
deleted file mode 100644
index 1475bcbe..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import java.sql.Timestamp;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- *
- * Timestamp Type Converter
- *
- * @author Christophe Lombart
- *
- */
-public class TimestampTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public TimestampTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public TimestampTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- return null;
- long value = ((Timestamp) propValue).getTime();
- return this.getValueFactory().createValue(value);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- long beanPropValue = value.getLong();
- return new Timestamp(beanPropValue);
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return new Long(((Timestamp) object).getTime()).toString();
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
deleted file mode 100644
index af474ad8..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
-
-import java.util.Date;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFactory;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-/**
- * Util Date Converter
- *
- * @author Christophe Lombart
- *
- */
-public class UtilDateTypeConverterImpl extends AbstractAtomicTypeConverterImpl
-{
- /**
- * No-arg constructor.
- * When using it you should provide later the javax.jcr.ValueFactory.
- *
- * @see #setValueFactory(ValueFactory)
- */
- public UtilDateTypeConverterImpl()
- {
- super();
- }
-
- /**
- * Constructor
- * @param factory The JCR Value factory to used
- */
- public UtilDateTypeConverterImpl(ValueFactory factory)
- {
- super(factory);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
- */
- public Value getValue(Object propValue)
- {
- if (propValue == null)
- {
- return null;
- }
- return this.getValueFactory().createValue(((java.util.Date) propValue).getTime());
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
- */
- public Object getObject(Value value)
- {
- try
- {
- long time = value.getLong();
- return new Date(time);
-
- }
- catch (RepositoryException e)
- {
- throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
- */
- public String getStringValue(Object object)
- {
-
- return new Long(((java.util.Date) object).getTime()).toString();
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/CollectionConverter.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/CollectionConverter.java
deleted file mode 100644
index 3add79c1..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/CollectionConverter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.collectionconverter;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-
-/**
- * Convert any kind of {@link ManageableCollection} into severals JCR nodes.
- *
- * @author Lombart Christophe
- *
- */
-public interface CollectionConverter
-{
-
- /**
- * Insert/convert collection elements into some JCR nodes
- * @param session The JCR session
- * @param parentNode the node which will contains the collection element
- * @param collectionDescriptor The collection descriptor
- * @param collection the collection to insert
- *
- * @throws PersistenceException when it is not possible to insert the collection
- *
- */
- public void insertCollection(Session session, Node parentNode,
- CollectionDescriptor collectionDescriptor, ManageableCollection collection) throws PersistenceException;
-
- /**
- * Update collection elements already present in the JCR repository
- * @param session The JCR session
- * @param parentNode the node which will contains the collection element
- * @param collectionDescriptor The collection descriptor
- * @param collection the collection to update
- *
- * @throws PersistenceException when it is not possible to update the collection
- */
- public void updateCollection(Session session, Node parentNode,
- CollectionDescriptor collectionDescriptor, ManageableCollection collection) throws PersistenceException;
-
- /**
- * Get a {@link ManageableCollection} from the JCR repository
- * @param session The JCR session
- * @param parentNode the node which contains the collection element
- * @param collectionDescriptor The collection descriptor
- * @param collectionFieldClass The collection class to used (ArrayList, Vector, ..)
- * @return The collection populates with all elements found in the JCR repository
- *
- * @throws PersistenceException when it is not possible to retrieve the collection
- */
- public ManageableCollection getCollection(Session session, Node parentNode,
- CollectionDescriptor collectionDescriptor, Class collectionFieldClass) throws PersistenceException;
-
-}
\ No newline at end of file
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java
deleted file mode 100644
index 00c93658..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollectionUtil.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.collectionconverter;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManageableArrayList;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManageableVector;
-
-/**
- * Utility class used to instantiate {@link ManageableCollection}
- *
- * @author Christophe Lombart
- *
- */
-public class ManageableCollectionUtil
-{
-
- /**
- * Instantiate a new {@link ManageableCollection}
- * @param manageableCollectionClassName The manageable collection class name
- * @return an emtpy created {@link ManageableCollection}
- */
- public static ManageableCollection getManageableCollection(String manageableCollectionClassName)
- {
- try
- {
- Class collectionClass = Class.forName(manageableCollectionClassName);
- return (ManageableCollection) collectionClass.newInstance();
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to create the manageable collection : " + manageableCollectionClassName, e);
- }
- }
-
- /**
- * Instantiate a new {@link ManageableCollection}
- * @param collectionClass the collection class name
- * @return an emtpy created {@link ManageableCollection}
- */
-
- public static ManageableCollection getManageableCollection(Class collectionClass)
- {
- try
- {
-
- if (collectionClass.equals(ArrayList.class))
- {
- return new ManageableArrayList();
- }
-
- if (collectionClass.equals(Vector.class))
- {
- return new ManageableVector();
- }
-
- if (collectionClass.equals(Collection.class) || collectionClass.equals(List.class))
- {
- return new ManageableArrayList();
- }
-
- Object collection = collectionClass.newInstance();
- if (! (collection instanceof ManageableCollection))
- {
- throw new PersistenceException("Unsupported collection type :" + collectionClass.getName());
- }
- else
- {
- return (ManageableCollection) collection;
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to create the manageable collection", e);
- }
- }
-
- /**
- * Convert a java Collection object into a {@link ManageableCollection}.
- * Until now, only the following class are supported :
- * Collection, List, ArrayList, Vector
- *
- * If you need a Map, you have to write your own {@link ManageableCollection}.
- * @param object the java collection or Map
- * @return The converted {@link ManageableCollection}
- *
- */
- public static ManageableCollection getManageableCollection(Object object)
- {
- try
- {
- if (object == null)
- {
- return null;
- }
-
- if (object instanceof ManageableCollection)
- {
- return (ManageableCollection) object;
-
- }
- if (object.getClass().equals(ArrayList.class))
- {
- ManageableArrayList manageableArrayList = new ManageableArrayList();
- manageableArrayList.addAll((Collection) object);
- return manageableArrayList;
- }
-
- if (object.getClass().equals(Vector.class))
- {
- ManageableVector manageableVector = new ManageableVector();
- manageableVector.addAll((Collection) object);
- return manageableVector;
- }
-
- if (object.getClass().equals(Collection.class) || object.getClass().equals(List.class))
- {
- ManageableArrayList manageableArrayList = new ManageableArrayList();
- manageableArrayList.addAll((Collection) object);
- return manageableArrayList;
- }
-
- throw new PersistenceException("Unsupported collection type :" + object.getClass().getName());
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to create the manageable collection", e);
- }
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java
deleted file mode 100644
index 982c05c0..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/AbstractCollectionConverterImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
-
-import java.util.Map;
-
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-
-/**
- * Abstract class used for all CollectionConverter
- *
- * @author Christophe Lombart
- *
- */
-public abstract class AbstractCollectionConverterImpl implements CollectionConverter
-{
- protected Map atomicTypeConverters;
- protected ObjectConverter objectConverter;
- protected Mapper mapper;
-
- /**
- * Constructor
- *
- * @param atomicTypeConverters The atomic type converter to used
- * @param objectConverter The object converter to used
- * @param mapper The mapper to used
- */
- public AbstractCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
- {
- this.atomicTypeConverters = atomicTypeConverters;
- this.objectConverter = objectConverter;
- this.mapper = mapper;
- }
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
deleted file mode 100644
index 1caecfb7..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Session;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-
-/**
- * Default Collection Mapping/convertion implementation.
- *
- * This collection mapping strategy maps a collection under an extra JCR node (specify by the jcrName in the CollectionDescriptor).
- * It is usefull when the node type "nt:unstructured" is applied to the collection elements. By this way, it is possible
- * to distinguish the collection elements from the other main object fields.
- *
- * If the collection element class contains an id (see the FieldDescriptor definition), this id value is used to build the collection element node.
- * Otherwise, the element node name is a simple indexed constant.
- *
- * Example - without an id attribute:
- * /test (Main object containing the collection field )
- * /mycollection (extra node used to store the entire collection)
- * /collection-element1 (node used to store the first collection element)
- * /item-prop
- * ....
- * /collection-element2 (node used to store the second collection element)
- * ...
- *
- * Example - with an id attribute:
- * /test (Main object containing the collection field )
- * /mycollection (extra node used to store the entire collection)
- * /aValue (id value assigned to the first element)
- * /item-prop
- * ....
- * /anotherValue (id value assigned to the first element)
- * ...
-
- * @author Christophe Lombart
- *
- */
-public class DefaultCollectionConverterImpl extends AbstractCollectionConverterImpl
-{
-
- private static final String COLLECTION_ELEMENT_NAME = "collection-element";
-
- /**
- * Constructor
- * @param atomicTypeConverters
- * @param objectConverter
- * @param mapper
- */
- public DefaultCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
- {
- super(atomicTypeConverters, objectConverter, mapper);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
- */
- public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
- {
-
- try
- {
-
- if (collection == null)
- {
- return;
- }
-
- String jcrName = collectionDescriptor.getJcrName();
-
- if (jcrName == null)
- {
- throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
- + collectionDescriptor.getCollectionConverterClassName());
- }
-
- Node collectionNode = parentNode.addNode(jcrName);
-
- Iterator collectionIterator = collection.getIterator();
- ClassDescriptor elementClassDescriptor = mapper.getClassDescriptor(Class.forName(collectionDescriptor
- .getElementClassName()));
-
- int elementCollectionCount = 0;
- while (collectionIterator.hasNext())
- {
- Object item = collectionIterator.next();
- String elementJcrName = null;
-
- // If the element object has a unique id => the element jcr node name = the id value
- if (elementClassDescriptor.hasIdField())
- {
- String idFieldName = elementClassDescriptor.getIdFieldDescriptor().getFieldName();
- elementJcrName = PropertyUtils.getNestedProperty(item, idFieldName).toString();
- }
- else
- {
-
- elementCollectionCount++;
- elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
- }
-
- objectConverter.insert(session, collectionNode, elementJcrName, item);
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
- */
- public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
- {
- try
- {
-
- String jcrName = collectionDescriptor.getJcrName();
-
- if (jcrName == null)
- {
- throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
- + collectionDescriptor.getCollectionConverterClassName());
- }
-
- if (collection == null)
- {
- if (parentNode.hasNode(jcrName))
- {
- parentNode.getNode(jcrName).remove();
-
- }
- return;
- }
-
- Node collectionNode = parentNode.getNode(jcrName);
- ClassDescriptor elementClassDescriptor = mapper.getClassDescriptor(Class.forName(collectionDescriptor
- .getElementClassName()));
- Iterator collectionIterator = collection.getIterator();
- int elementCollectionCount = 0;
-
- // If the collection elements have not an id, it is not possible to find the matching JCR nodes => delete the complete collection
- if (!elementClassDescriptor.hasIdField())
- {
- collectionNode.remove();
- collectionNode = parentNode.addNode(jcrName);
- }
-
- HashMap updatedItems = new HashMap();
- while (collectionIterator.hasNext())
- {
- Object item = collectionIterator.next();
-
- elementCollectionCount++;
- String elementJcrName = null;
-
- if (elementClassDescriptor.hasIdField())
- {
-
- String idFieldName = elementClassDescriptor.getIdFieldDescriptor().getFieldName();
- elementJcrName = PropertyUtils.getNestedProperty(item, idFieldName).toString();
-
- // Update existing JCR Nodes
- if (collectionNode.hasNode(elementJcrName))
- {
- objectConverter.update(session, collectionNode, elementJcrName, item);
- }
- else
- {
- // Add new collection elements
- objectConverter.insert(session, collectionNode, elementJcrName, item);
- }
-
- updatedItems.put(elementJcrName, item);
-
- }
- else
- {
-
- elementCollectionCount++;
- elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
- objectConverter.insert(session, collectionNode, elementJcrName, item);
- }
-
- }
-
- // Delete JCR nodes that are not present in the collection
- if (elementClassDescriptor.hasIdField())
- {
- NodeIterator nodeIterator = collectionNode.getNodes();
- while (nodeIterator.hasNext())
- {
- Node child = nodeIterator.nextNode();
- if (! updatedItems.containsKey(child.getName()))
- {
- child.remove();
- }
- }
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, java.lang.Class)
- */
- public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
- {
- try
- {
- String jcrName = collectionDescriptor.getJcrName();
- if (!parentNode.hasNode(jcrName))
- {
- return null;
- }
-
- Node collectionNode = parentNode.getNode(jcrName);
- NodeIterator children = collectionNode.getNodes();
-
- ManageableCollection collection = ManageableCollectionUtil.getManageableCollection(collectionFieldClass);
-
- while (children.hasNext())
- {
- Node itemNode = children.nextNode();
- Object item = objectConverter.getObject(session, Class.forName(collectionDescriptor.getElementClassName()),
- itemNode.getPath());
- collection.addObject(item);
- }
-
- return collection;
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java
deleted file mode 100644
index 42be80f5..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableArrayList.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-
-/**
- *
- * {@link ManageableCollection} ArrayList implementation
- *
- * @author Christophe Lombart
- *
- */
-public class ManageableArrayList extends ArrayList implements ManageableCollection
-{
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#addObject(java.lang.Object)
- */
- public void addObject(Object object)
- {
- this.add(object);
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getIterator()
- */
- public Iterator getIterator()
- {
- return this.iterator();
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getSize()
- */
- public int getSize()
- {
-
- return this.size();
- }
-
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java
deleted file mode 100644
index 13afbfaa..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ManageableVector.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-
-/**
- *
- * {@link ManageableCollection} Vector implementation
- * @author Christophe Lombart
- *
- */
-public class ManageableVector extends Vector implements ManageableCollection
-{
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#addObject(java.lang.Object)
- */
- public void addObject(Object object)
- {
- this.add(object);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getIterator()
- */
- public Iterator getIterator()
- {
- return this.iterator();
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getSize()
- */
- public int getSize()
- {
-
- return this.size();
- }
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java
deleted file mode 100644
index 33e34db3..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImpl.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.Session;
-import javax.jcr.Value;
-
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-
-/**
- * Collection Mapping/convertion implementation used for multi values properties
- *
- * This collection mapping strategy maps a collection into a JCR multi value property
- *
- * @author Christophe Lombart
- *
- */
-public class MultiValueCollectionConverterImpl extends AbstractCollectionConverterImpl
-{
- /**
- * Constructor
- *
- * @param atomicTypeConverters
- * @param objectConverter
- * @param mapper
- */
- public MultiValueCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
- {
- super(atomicTypeConverters, objectConverter, mapper);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
- */
- public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
- {
-
- try
- {
-
- if (collection == null)
- {
- return;
- }
-
- String jcrName = collectionDescriptor.getJcrName();
-
- if (jcrName == null)
- {
- throw new PersistenceException("The JcrName attribute is not defined for the CollectionDescriptor : "
- + collectionDescriptor.getCollectionConverterClassName());
- }
-
- Value[] values = new Value[collection.getSize()];
- Iterator collectionIterator = collection.getIterator();
- for (int i=0; iChristophe Lombart
- *
- */
-public class NTCollectionConverterImpl extends AbstractCollectionConverterImpl
-{
-
- private final static Log log = LogFactory.getLog(NTCollectionConverterImpl.class);
-
- private static final String COLLECTION_ELEMENT_NAME = "collection-element";
-
- /**
- * Constructor
- *
- * @param atomicTypeConverters
- * @param objectConverter
- * @param mapper
- */
- public NTCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper)
- {
- super(atomicTypeConverters, objectConverter, mapper);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
- */
- public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
- {
-
- try
- {
-
- if (collection == null)
- {
- return;
- }
-
-
- Iterator collectionIterator = collection.getIterator();
- ClassDescriptor elementClassDescriptor = mapper.getClassDescriptor(Class.forName(collectionDescriptor
- .getElementClassName()));
-
- int elementCollectionCount = 0;
- while (collectionIterator.hasNext())
- {
- Object item = collectionIterator.next();
- String elementJcrName = null;
-
- // If the element object has a unique id => the element jcr node name = the id value
- if (elementClassDescriptor.hasIdField())
- {
- String idFieldName = elementClassDescriptor.getIdFieldDescriptor().getFieldName();
- elementJcrName = PropertyUtils.getNestedProperty(item, idFieldName).toString();
- }
- else
- {
-
- elementCollectionCount++;
- elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
- }
-
- objectConverter.insert(session, parentNode, elementJcrName, item);
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection)
- */
- public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, ManageableCollection collection)
- {
- try
- {
-
- ClassDescriptor elementClassDescriptor = mapper.getClassDescriptor(Class.forName(collectionDescriptor
- .getElementClassName()));
-
- if (collection == null)
- {
- this.deleteCollectionItems(session, parentNode, elementClassDescriptor.getJcrNodeType());
- return;
- }
-
- if (!elementClassDescriptor.hasIdField())
- {
- this.deleteCollectionItems(session, parentNode, elementClassDescriptor.getJcrNodeType());
- }
-
- Iterator collectionIterator = collection.getIterator();
- int elementCollectionCount = 0;
-
- HashMap updatedItems = new HashMap();
- while (collectionIterator.hasNext())
- {
- Object item = collectionIterator.next();
-
- elementCollectionCount++;
- String elementJcrName = null;
-
- if (elementClassDescriptor.hasIdField())
- {
-
- String idFieldName = elementClassDescriptor.getIdFieldDescriptor().getFieldName();
- elementJcrName = PropertyUtils.getNestedProperty(item, idFieldName).toString();
-
- // Update existing JCR Nodes
- if (parentNode.hasNode(elementJcrName))
- {
- objectConverter.update(session, parentNode, elementJcrName, item);
- }
- else
- {
- // Add new collection elements
- objectConverter.insert(session, parentNode, elementJcrName, item);
- }
-
- updatedItems.put(elementJcrName, item);
-
- }
- else
- {
-
- elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
- objectConverter.insert(session, parentNode, elementJcrName, item);
- }
-
- }
-
- // Delete JCR nodes that are not present in the collection
- if (elementClassDescriptor.hasIdField())
- {
- Iterator nodeIterator = this.getCollectionNodes(session, parentNode, elementClassDescriptor.getJcrNodeType()).iterator();
- while (nodeIterator.hasNext())
- {
- Node child = (Node) nodeIterator.next();
- if (! updatedItems.containsKey(child.getName()))
- {
- child.remove();
- }
- }
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to update the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor, java.lang.Class)
- */
- public ManageableCollection getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass)
- {
- try
- {
- ClassDescriptor elementClassDescriptor = mapper.getClassDescriptor(Class.forName(collectionDescriptor
- .getElementClassName()));
- Iterator children = this.getCollectionNodes(session, parentNode, elementClassDescriptor.getJcrNodeType()).iterator();
-
- ManageableCollection collection = ManageableCollectionUtil.getManageableCollection(collectionFieldClass);
-
- while (children.hasNext())
- {
- Node itemNode = (Node) children.next();
- log.debug("Collection node found : " + itemNode.getPath());
- Object item = objectConverter.getObject(session, Class.forName(collectionDescriptor.getElementClassName()),
- itemNode.getPath());
- collection.addObject(item);
- }
-
- return collection;
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the collection field : " + collectionDescriptor.getFieldName()
- + "for " + collectionDescriptor.getElementClassName(), e);
- }
- }
-
- private Collection getCollectionNodes (Session session, Node parentNode, String itemNodeType) throws Exception
- {
-
- ArrayList collectionNodes = new ArrayList();
-
- // TODO : review this workaround used to support version nodes
- // Searching on the version storage has some bugs => loop on all child noded and check the property jcr:frozenPrimaryType
- // I have to investigate in more detail what's happen exactly
- if (! parentNode.getPath().startsWith("/jcr:system/jcr:versionStorage"))
- {
- NodeIterator nodeIterator = parentNode.getNodes();
- while (nodeIterator.hasNext())
- {
- Node child = nodeIterator.nextNode();
-
- if (child.isNodeType(itemNodeType))
- {
- collectionNodes.add(child);
- }
- }
- }
- else
- {
-
- NodeIterator nodeIterator = parentNode.getNodes();
- while (nodeIterator.hasNext())
- {
- Node child = nodeIterator.nextNode();
-
- if (child.getProperty("jcr:frozenPrimaryType").getString().equals(itemNodeType))
- {
- collectionNodes.add(child);
- }
- }
-
- }
-
- return collectionNodes;
-
- }
-
- private void deleteCollectionItems(Session session, Node parentNode, String itemNodeType) throws Exception
- {
- Iterator nodeIterator = this.getCollectionNodes(session, parentNode, itemNodeType).iterator();
- while (nodeIterator.hasNext())
- {
- Node node = (Node) nodeIterator.next();
- node.remove();
- }
- }
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java b/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java
deleted file mode 100644
index c0e7f5c1..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.persistence.impl;
-
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Session;
-
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-
-
-/**
- * ObjectIterator is a wrapper class for JCR NodeIterator
- *
- * @author Christophe Lombart
- *
- */
-public class ObjectIterator implements Iterator
-{
-
- private NodeIterator nodeIterator;
-
- private Class objectClass;
-
- private Session session;
-
- private ObjectConverter objectConverter;
-
-
- /**
- * Constructor
- *
- * @param iterator JCR node iterator
- * @param objectClass the object class used to instantiate the objects
- * @param converter The object converter
- * @param session the JCR session
- */
- public ObjectIterator(NodeIterator iterator, Class objectClass, ObjectConverter converter, Session session)
- {
- nodeIterator = iterator;
- this.objectClass = objectClass;
- objectConverter = converter;
- this.session = session;
- }
-
- /**
- *
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext()
- {
- return nodeIterator.hasNext();
- }
-
- /**
- *
- * @see java.util.Iterator#next()
- */
- public Object next()
- {
-
- try
- {
- Node node = nodeIterator.nextNode();
- return objectConverter.getObject(session, objectClass, node.getPath());
- }
- catch (Exception e)
- {
- return null;
- }
-
- }
-
- /**
- *
- * @see java.util.Iterator#remove()
- */
- public void remove()
- {
- nodeIterator.remove();
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
deleted file mode 100644
index 0f1facc6..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
+++ /dev/null
@@ -1,910 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-import javax.jcr.query.QueryResult;
-import javax.jcr.version.VersionHistory;
-
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.jcr.exception.IllegalUnlockException;
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
-import org.apache.portals.graffito.jcr.exception.LockedException;
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.exception.VersionException;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
-import org.apache.portals.graffito.jcr.query.Query;
-import org.apache.portals.graffito.jcr.query.QueryManager;
-import org.apache.portals.graffito.jcr.version.Version;
-import org.apache.portals.graffito.jcr.version.VersionIterator;
-
-/**
- *
- * Default implementation for {@link org.apache.portals.graffito.jcr.persistence.PersistenceManager}
- *
- * @author Sandro Boehme
- * @author Lombart Christophe
- * @author Martin Koci
- *
- */
-public class PersistenceManagerImpl implements PersistenceManager
-{
- /**
- * Logger.
- */
- private final static Log log = LogFactory
- .getLog(PersistenceManagerImpl.class);
-
- /**
- * JCR session.
- */
- protected Session session;
-
- protected Mapper mapper;
-
- /**
- * The Graffito query manager
- */
- protected QueryManager queryManager;
-
- /**
- * Object Converter
- */
- protected ObjectConverter objectConverter;
-
- /**
- * Contructor
- *
- * @param mapper the Mapper component
- * @param atomicTypeConverters Atomic type converters to used
- * @param queryManager the query manager to used
- * @param session The JCR session
- *
- */
- public PersistenceManagerImpl(Mapper mapper, Map atomicTypeConverters,
- QueryManager queryManager, Session session)
- {
- this.mapper = mapper;
- this.session = session;
- this.objectConverter = new ObjectConverterImpl(mapper,
- atomicTypeConverters);
- this.queryManager = queryManager;
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(java.lang.Class, java.lang.String)
- */
- public Object getObject(Class objectClass, String path)
- {
- try
- {
- if (!session.itemExists(path))
- {
- return null;
- }
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the object at "
- + path, e);
- }
-
- return objectConverter.getObject(session, objectClass, path);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(java.lang.Class, java.lang.String, java.lang.String)
- */
- public Object getObject(Class objectClass, String path, String versionName)
- throws PersistenceException
- {
- String pathVersion = null;
- try
- {
- if (!session.itemExists(path))
- {
- return null;
- }
-
- Version version = this.getVersion(path, versionName);
- pathVersion = version.getPath() + "/jcr:frozenNode";
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the object at "
- + path + " - version :" + versionName, e);
- }
-
- return objectConverter.getObject(session, objectClass, pathVersion);
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#insert(java.lang.Object)
- */
- public void insert(Object object)
- {
- String path = objectConverter.getPath(session, object);
-
- try
- {
-
- if (session.itemExists(path))
- {
- Item item = session.getItem(path);
- if (item.isNode())
- {
- if (!((Node) item).getDefinition().allowsSameNameSiblings())
- {
- throw new PersistenceException(
- "Path already exists and it is not supporting the same name sibling : "
- + path);
- }
- }
- else
- {
- throw new PersistenceException(
- "Path already exists and it is a property : "
- + path);
- }
-
- }
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to insert the object at " + path, e);
- }
-
- objectConverter.insert(session, object);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#update(java.lang.Object)
- */
- public void update(Object object)
- {
- String path = objectConverter.getPath(session, object);
- try
- {
- if (!session.itemExists(path))
- {
- throw new PersistenceException("Path is not existing : " + path);
- }
- else
- {
- checkIfNodeLocked(path);
- }
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException("Impossible to update", e);
- }
-
- objectConverter.update(session, object);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(java.lang.String)
- */
- public void remove(String path)
- {
-
- try
- {
- if (!session.itemExists(path))
- {
- throw new PersistenceException("Path is not existing : " + path);
- }
- else
- {
- checkIfNodeLocked(path);
- }
-
- Item item = session.getItem(path);
- item.remove();
-
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to remove the object at " + path);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(java.lang.Object)
- */
- public void remove(Object object) throws PersistenceException
- {
- this.remove(objectConverter.getPath(session, object));
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(org.apache.portals.graffito.jcr.query.Query)
- */
- public void remove(Query query)
- {
- try
- {
-
- String jcrExpression = this.queryManager.buildJCRExpression(query);
- log.debug("Remove Objects with expression : " + jcrExpression);
-
- javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(jcrExpression,javax.jcr.query.Query.XPATH);
- QueryResult queryResult = jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
- ArrayList nodes = new ArrayList();
-
- while (nodeIterator.hasNext())
- {
- Node node = nodeIterator.nextNode();
- log.debug("Remove node : " + node.getPath());
- // it is not possible to remove nodes from an NodeIterator
- // So, we add the node found in a collection to remove them after
- nodes.add(node);
- }
-
- // Remove all collection nodes
- for (int i = 0; i < nodes.size(); i++)
- {
- Node node = (Node) nodes.get(i);
- checkIfNodeLocked(node.getPath());
- node.remove();
- }
-
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException("Impossible to get the object collection", e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#objectExists(java.lang.String)
- */
- public boolean objectExists(String path)
- {
- try
- {
- //TODO : Check also if it is an object
- return session.itemExists(path);
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to check if the object exist", e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#isPersistent(java.lang.Class)
- */
- public boolean isPersistent(final Class clazz)
- {
- boolean isPersistent = false;
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(clazz);
- if (classDescriptor != null)
- {
- isPersistent = true;
- }
- return isPersistent;
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(org.apache.portals.graffito.jcr.query.Query)
- */
- public Object getObject(Query query)
- {
-
- try
- {
-
- String jcrExpression = this.queryManager.buildJCRExpression(query);
- log.debug("Get Object with expression : " + jcrExpression);
-
- javax.jcr.query.Query jcrQuery = session.getWorkspace()
- .getQueryManager().createQuery(jcrExpression,
- javax.jcr.query.Query.XPATH);
- QueryResult queryResult = jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
-
- if (nodeIterator.getSize() > 1)
- {
- throw new PersistenceException(
- "Impossible to get the object - the query returns more than one object");
- }
-
- Object object = null;
- if (nodeIterator.hasNext())
- {
- Node node = nodeIterator.nextNode();
- object = objectConverter.getObject(session, query.getFilter()
- .getFilterClass(), node.getPath());
- }
-
- return object;
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the object collection", e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjects(org.apache.portals.graffito.jcr.query.Query)
- */
- public Collection getObjects(Query query)
- {
- try
- {
-
- String jcrExpression = this.queryManager.buildJCRExpression(query);
- log.debug("Get Objects with expression : " + jcrExpression);
-
- javax.jcr.query.Query jcrQuery = session.getWorkspace()
- .getQueryManager().createQuery(jcrExpression,
- javax.jcr.query.Query.XPATH);
- QueryResult queryResult = jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
-
- ArrayList result = new ArrayList();
- while (nodeIterator.hasNext())
- {
- Node node = nodeIterator.nextNode();
- log.debug("Node found : " + node.getPath());
- result.add(objectConverter.getObject(session, query.getFilter()
- .getFilterClass(), node.getPath()));
- }
-
- return result;
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the object collection", e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjectIterator(org.apache.portals.graffito.jcr.query.Query)
- */
- public Iterator getObjectIterator(Query query)
- {
- try
- {
-
- String jcrExpression = this.queryManager.buildJCRExpression(query);
- log.debug("Get Object with expression : " + jcrExpression);
-
- javax.jcr.query.Query jcrQuery = session.getWorkspace()
- .getQueryManager().createQuery(jcrExpression,
- javax.jcr.query.Query.XPATH);
- QueryResult queryResult = jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
- return new ObjectIterator(nodeIterator, query.getFilter()
- .getFilterClass(), this.objectConverter, this.session);
-
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the object collection", e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#checkin(java.lang.String)
- */
- public void checkin(String path)
- {
- this.checkin(path, null);
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#checkin(java.lang.String, java.lang.String[])
- */
- public void checkin(String path, String[] versionLabels)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- checkIfNodeLocked(node.getPath());
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
- javax.jcr.version.Version newVersion = node.checkin();
-
- if (versionLabels != null)
- {
- VersionHistory versionHistory = node.getVersionHistory();
- for (int i = 0; i < versionLabels.length; i++)
- {
- versionHistory.addVersionLabel(newVersion.getName(),
- versionLabels[i], false);
- }
- }
- }
- catch (RepositoryException e)
- {
- throw new VersionException("Impossible to checkin the object "
- + path, e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#checkout(java.lang.String)
- */
- public void checkout(String path)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- node.checkout();
-
- }
- catch (RepositoryException e)
- {
- throw new VersionException("Impossible to checkout the object "
- + path, e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#addVersionLabel(java.lang.String, java.lang.String, java.lang.String)
- */
- public void addVersionLabel(String path, String versionName,
- String versionLabel)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- checkIfNodeLocked(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
- history.addVersionLabel(versionName, versionLabel, false);
- }
- catch (RepositoryException e)
- {
- throw new VersionException(
- "Impossible to add a new version label to " + path
- + " - version name : " + versionName, e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getVersion(java.lang.String, java.lang.String)
- */
- public Version getVersion(String path, String versionName)
- {
-
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
-
- return new Version(history.getVersion(versionName));
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException("Impossible to get the version : "
- + path + " - version name : " + versionName, e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getVersionLabels(java.lang.String, java.lang.String)
- */
- public String[] getVersionLabels(String path, String versionName)
- {
-
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
- javax.jcr.version.Version version = history.getVersion(versionName);
- return history.getVersionLabels(version);
-
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the version labels : " + path
- + " - version name : " + versionName, e);
- }
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getAllVersionLabels(java.lang.String)
- */
- public String[] getAllVersionLabels(String path)
- throws javax.jcr.version.VersionException
- {
-
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
- return history.getVersionLabels();
-
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the all version labels : " + path, e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getAllVersions(java.lang.String)
- */
- public VersionIterator getAllVersions(String path)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
- return new VersionIterator(history.getAllVersions());
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException("Impossible to checkin the object "
- + path, e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getRootVersion(java.lang.String)
- */
- public Version getRootVersion(String path)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- VersionHistory history = node.getVersionHistory();
-
- return new Version(history.getRootVersion());
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the root version for the object "
- + path, e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getBaseVersion(java.lang.String)
- */
- public Version getBaseVersion(String path)
- {
- try
- {
- Node node = (Node) session.getItem(path);
- if (!node.isNodeType("mix:versionable"))
- {
- throw new VersionException("The object " + path
- + "is not versionable");
- }
-
- return new Version(node.getBaseVersion());
- }
- catch (RepositoryException e)
- {
- throw new PersistenceException(
- "Impossible to get the base version for the object " + path,
- e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#lock(java.lang.String, java.lang.Object, boolean, boolean)
- */
- public String lock(final String absPath, final boolean isDeep, final boolean isSessionScoped) throws LockedException
- {
- try
- {
-
- // Calling this method will throw exception if node is locked
- // and this operation cant be done (exception translation)
- checkIfNodeLocked(absPath);
-
- Node node = getNode(absPath);
- Lock lock = node.lock(isDeep, isSessionScoped);
- return lock.getLockToken();
- }
- catch (LockException e)
- {
- // Only one case with LockException remains: if node is not mix:lockable, propably error in custom node types definitions
- throw new org.apache.portals.graffito.jcr.exception.RepositoryException("Node of type is not type mix:lockable", e);
- }
- catch (RepositoryException e)
- {
- throw new org.apache.portals.graffito.jcr.exception.RepositoryException(e.getMessage(), e);
- }
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#unlock(java.lang.String, java.lang.Object, java.lang.String)
- */
- public void unlock(final String absPath, final String lockToken) throws JcrMappingException, IllegalUnlockException
- {
- Node node;
- Lock lock;
- String lockOwner = null;
- try
- {
- maybeAddLockToken(lockToken);
-
- node = getNode(absPath);
-
- if (node.isLocked() == false)
- {
- // Safe - if not locked return
- return;
- }
-
- lock = node.getLock();
- lockOwner = lock.getLockOwner();
-
- node.unlock();
- }
- catch (LockException e)
- {
- // LockException if this node does not currently hold a lock (see upper code)
- // or holds a lock for which this Session does not have the correct lock token
- log.error("Cannot unlock path: "
- + absPath
- + " Jcr user: "
- + session.getUserID()
- + " has no lock token to do this. Lock was placed with user: "
- + lockOwner);
- throw new IllegalUnlockException(lockOwner, absPath);
- }
- catch (RepositoryException e)
- {
- // This also catch UnsupportedRepositoryOperationException - we assume that implementation supports it (jackrabbit does)
- throw new org.apache.portals.graffito.jcr.exception.RepositoryException(
- e.getMessage(), e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#isLocked(java.lang.String)
- */
- public boolean isLocked(final String absPath)
- {
- try
- {
- final Node node = getNode(absPath);
- return node.isLocked();
- }
- catch (RepositoryException e)
- {
- // node.isLocked() RepositoryException if an error occurs.
- throw new org.apache.portals.graffito.jcr.exception.RepositoryException(
- "General error with JCR", e);
- }
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getQueryManager()
- */
- public QueryManager getQueryManager()
- {
-
- return this.queryManager;
- }
-
- /**
- * Throws {@link LockedException} id node is locked so alter nopde cannot be done
- *
- * @param absPath
- * abs path to node
- * @throws RepositoryException
- * @throws LockedException
- * if node is locked
- */
- protected void checkIfNodeLocked(final String absPath) throws RepositoryException, LockedException
- {
- Node node = getNode(absPath);
- // Node can hold nock or can be locked with precedencor
- if (node.isLocked())
- {
- Lock lock = node.getLock();
- String lockOwner = lock.getLockOwner();
- final String path = lock.getNode().getPath();
- throw new LockedException(lockOwner, path);
- }
- }
-
- protected void maybeAddLockToken(final String lockToken)
- {
- if (lockToken != null)
- {
- // This user (this instance of PM) potentionally placed lock so
- // session already has lock token
- final String[] lockTokens = getSession().getLockTokens();
- if (ArrayUtils.contains(lockTokens, lockToken))
- {
- // Ok = this session can unlock
- }
- else
- {
- getSession().addLockToken(lockToken);
- }
- }
- }
-
- protected Node getNode(final String absPath) throws PathNotFoundException,
- RepositoryException
- {
-
- if (!getSession().itemExists(absPath))
- {
- throw new org.apache.portals.graffito.jcr.exception.PersistenceException(
- "No object stored on path: " + absPath);
- }
- Item item = getSession().getItem(absPath);
- if (!item.isNode())
- {
- throw new org.apache.portals.graffito.jcr.exception.PersistenceException(
- "No object stored on path: " + absPath
- + " on absPath is item (leaf)");
- }
- Node node = (Node) item;
- return node;
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#logout()
- */
- public void logout()
- {
- try
- {
- session.save();
- session.logout();
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to logout", e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#save()
- */
- public void save()
- {
- try
- {
- session.save();
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to save", e);
- }
- }
-
- /**
- * @return The JCR Session
- */
- public Session getSession()
- {
- return this.session;
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java b/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java
deleted file mode 100644
index a91f4b6a..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.objectconverter;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-
-
-/**
- * Convert any kind of beans into JCR nodes & properties
- *
- * @author Lombart Christophe
- * @version $Id: Exp $
- */
-public interface ObjectConverter
-{
- /**
- * Insert the object
- *
- * @param session the JCR session
- * @param object the object to insert
- * @throws PersistenceException when it is not possible to insert the object
- *
- */
- public void insert(Session session, Object object) throws PersistenceException;
-
- /**
- * Update the object
- *
- * @param session the JCR session
- * @param object the object to update
- * @throws PersistenceException when it is not possible to update the object
- */
- public void update(Session session, Object object) throws PersistenceException;
-
- /**
- * Retrieve an object from the JCR repo
- *
- * @param session The JCR session
- * @param clazz The class assigned to the object to retrieve
- * @param path the JCR path
- * @return The object found or null
- *
- * @throws PersistenceException when it is not possible to retrieve the object
- */
- public Object getObject(Session session, Class clazz, String path) throws PersistenceException;
-
-
- /**
- * Insert the object
- *
- * @param session the JCR session
- * @param parentNode The parent node used to store the new JCR element (object)
- * @param nodeName The node name used to store the object
- * @param object the object to insert
- * @throws PersistenceException when it is not possible to insert the object
- */
- public void insert(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
-
- /**
- * Update the object
- *
- * @param session the JCR session
- * @param parentNode The parent node used to store the new JCR element (object)
- * @param nodeName The node name used to store the object
- * @param object the object to update
- * @throws PersistenceException when it is not possible to update the object
- */
- public void update(Session session, Node parentNode, String nodeName, Object object) throws PersistenceException;
-
-
- /**
- * Get the object JCR path
- *
- * @param session the JCR session
- * @param object the object for which the path has to be retrieve
- * @return the object JCR path
- * @throws PersistenceException when it is not possible to retrieve the object path
- */
- public String getPath(Session session , Object object) throws PersistenceException;
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java b/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
deleted file mode 100644
index 2980363d..00000000
--- a/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.persistence.objectconverter.impl;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.nodetype.PropertyDefinition;
-import javax.jcr.version.VersionException;
-
-import org.apache.commons.beanutils.ConstructorUtils;
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.portals.graffito.jcr.exception.JcrMappingException;
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
-import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
-import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.DefaultCollectionConverterImpl;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
-
-/**
- * Default implementation for {@link ObjectConverterImpl}
- *
- * @author Lombart Christophe
- *
- */
-public class ObjectConverterImpl implements ObjectConverter
-{
- private Mapper mapper;
-
- private Map atomicTypeConverters;
-
- /**
- * Constructor
- *
- * @param mapper The mapper to used
- * @param atomicTypeConverters The atomic type converters to used
- *
- */
- public ObjectConverterImpl(Mapper mapper, Map atomicTypeConverters)
- {
- this.mapper = mapper;
- this.atomicTypeConverters = atomicTypeConverters;
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#insert(javax.jcr.Session, java.lang.Object)
- */
- public void insert(Session session, Object object)
- {
- String path = this.getPath(session, object);
- try
- {
- String parentPath = RepositoryUtil.getParentPath(path);
- String nodeName = RepositoryUtil.getNodeName(path);
- Node parentNode = (Node) session.getItem(parentPath);
- this.insert(session, parentNode, nodeName, object);
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the object at " + path, e);
- }
-
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#insert(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
- */
- public void insert(Session session, Node parentNode, String nodeName, Object object)
- {
- try
- {
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
- if (classDescriptor == null)
- {
- throw new PersistenceException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
- }
-
- String jcrNodeType = classDescriptor.getJcrNodeType();
- if (jcrNodeType == null || jcrNodeType.equals(""))
- {
- throw new PersistenceException("Undefined node type for " + parentNode);
- }
-
- Node objectNode = null;
- objectNode = parentNode.addNode(nodeName, jcrNodeType);
-
- storeSimpleFields(object, classDescriptor, objectNode);
- insertBeanFields(session, object, classDescriptor, objectNode);
- insertCollectionFields(session, object, classDescriptor, objectNode);
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the object at " + parentNode, e);
- }
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#update(javax.jcr.Session, java.lang.Object)
- */
- public void update(Session session, Object object)
- {
- String path = this.getPath(session, object);
- try
- {
- String parentPath = RepositoryUtil.getParentPath(path);
- String nodeName = RepositoryUtil.getNodeName(path);
- Node parentNode = (Node) session.getItem(parentPath);
- this.update(session, parentNode, nodeName, object);
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to update the object at " + path, e);
- }
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#update(javax.jcr.Session, javax.jcr.Node, java.lang.String, java.lang.Object)
- */
- public void update(Session session, Node parentNode, String nodeName, Object object)
- {
- try
- {
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
- if (classDescriptor == null)
- {
- throw new PersistenceException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
- }
-
- String jcrNodeType = classDescriptor.getJcrNodeType();
- if (jcrNodeType == null || jcrNodeType.equals(""))
- {
- throw new PersistenceException("Undefined node type for " + parentNode);
- }
-
- Node objectNode = null;
- objectNode = parentNode.getNode(nodeName);
-
- storeSimpleFields(object, classDescriptor, objectNode);
- updateBeanFields(session, object, classDescriptor, objectNode);
- updateCollectionFields(session, object, classDescriptor, objectNode);
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to update the node : " + parentNode, e);
- }
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#getObject(javax.jcr.Session, java.lang.Class, java.lang.String)
- */
- public Object getObject(Session session, Class clazz, String path)
- {
- try
- {
-
- if (!session.itemExists(path))
- {
- return null;
- }
-
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(clazz);
- if (classDescriptor == null)
- {
- throw new PersistenceException("Class of type: " + clazz.getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
- }
-
- Node node = (Node) session.getItem(path);
- Object object = clazz.newInstance();
-
- retrieveSimpleFields(classDescriptor, node, object);
- retrieveBeanFields(session, path, classDescriptor, object);
- retrieveCollectionFields(session, classDescriptor, node, object);
-
- return object;
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the object at " + path, e);
- }
- }
-
-
- public String getPath(Session session, Object object)
- {
- try
- {
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
- if (classDescriptor == null)
- {
- throw new PersistenceException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
- }
-
- final FieldDescriptor pathFieldDescriptor = classDescriptor.getPathFieldDescriptor();
- if (pathFieldDescriptor == null)
- {
- throw new PersistenceException("Class of type: " + object.getClass().getName() + " has no path mapping. Maybe attribute path=\"true\" for a field element of this class in jcrmapping.xml is missing?");
- }
- String pathField = pathFieldDescriptor.getFieldName();
- return (String) PropertyUtils.getNestedProperty(object, pathField);
-
-
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to get the path", e);
- }
-
- }
-
- /**
- * Retrieve simple fields (atomic fields)
- */
- private void retrieveSimpleFields(ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, ValueFormatException, IllegalAccessException,
- InvocationTargetException, NoSuchMethodException
- {
- Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
-
- while (fieldDescriptorIterator.hasNext())
- {
- FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-
- String fieldName = fieldDescriptor.getFieldName();
- String propertyName = fieldDescriptor.getJcrName();
-
- if (fieldDescriptor.isPath())
- {
- PropertyUtils.setNestedProperty(object, fieldName, node.getPath());
- }
- else
- {
- Class fieldTypeClass = fieldDescriptor.getFieldTypeClass() != null
- ? fieldDescriptor.getFieldTypeClass()
- : PropertyUtils.getPropertyType(object, fieldName);
-
- AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters
- .get(fieldTypeClass);
- if (node.hasProperty(propertyName))
- {
- Object fieldValue = converter.getObject(node.getProperty(propertyName).getValue());
- PropertyUtils.setNestedProperty(object, fieldName, fieldValue);
- }
- }
- }
- }
-
- /**
- * Retrieve bean fields
- */
- private void retrieveBeanFields(Session session, String path, ClassDescriptor classDescriptor, Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
- {
- Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
- while (beanDescriptorIterator.hasNext())
- {
- BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
- String beanName = beanDescriptor.getFieldName();
- Class beanClass = PropertyUtils.getPropertyDescriptor(object, beanName).getPropertyType();
- Object bean = this.getObject(session, beanClass, path + "/" + beanDescriptor.getJcrName());
- PropertyUtils.setNestedProperty(object, beanName, bean);
- }
- }
-
- /**
- * Retrieve Collection fields
- */
- private void retrieveCollectionFields(Session session, ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, JcrMappingException,
- ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, InstantiationException
- {
- Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
- while (collectionDescriptorIterator.hasNext())
- {
- CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
- CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
- Class collectionFieldClass = PropertyUtils.getPropertyDescriptor(object, collectionDescriptor.getFieldName()).getPropertyType();
- ManageableCollection collection = collectionConverter.getCollection(session, node, collectionDescriptor, collectionFieldClass);
- PropertyUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), collection);
- }
- }
-
- /**
- * Insert Bean fields
- */
- private void insertBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
- {
- try
- {
- Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
- while (beanDescriptorIterator.hasNext())
- {
- BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
- String jcrName = beanDescriptor.getJcrName();
- Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
- if (bean != null)
- {
- this.insert(session, objectNode, jcrName, bean);
- }
-
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the bean fields", e);
- }
-
- }
-
- /**
- * Update Bean fields
- */
- private void updateBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
- {
- try
- {
- Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
- while (beanDescriptorIterator.hasNext())
- {
- BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
- String jcrName = beanDescriptor.getJcrName();
- Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
-
- // if the bean is null, remove existing node
- if ((bean == null))
- {
- if (objectNode.hasNode(jcrName))
- {
- objectNode.getNode(jcrName).remove();
- }
- }
- else
- {
- this.update(session, objectNode, jcrName, bean);
- }
-
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to update the bean fields", e);
- }
-
- }
-
- private void insertCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
- {
- try
- {
- Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
- while (collectionDescriptorIterator.hasNext())
- {
- CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
- CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
- Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
- ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
- collectionConverter.insertCollection(session, objectNode, collectionDescriptor, manageableCollection);
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to insert the collection fields", e);
- }
-
- }
-
- private void updateCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode)
- {
- try
- {
- Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
- while (collectionDescriptorIterator.hasNext())
- {
- CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
- CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
- Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
- ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
- collectionConverter.updateCollection(session, objectNode, collectionDescriptor, manageableCollection);
- }
- }
- catch (Exception e)
- {
- throw new PersistenceException("Impossible to store the bean fields", e);
- }
-
- }
-
- private void storeSimpleFields(Object object, ClassDescriptor classDescriptor, Node objectNode)
- throws PathNotFoundException, ValueFormatException, VersionException, LockException, ConstraintViolationException,
- RepositoryException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
- {
-
-
- Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
- while (fieldDescriptorIterator.hasNext())
- {
-
- FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-
- //Of course, Path field is not updated as property
- if (fieldDescriptor.isPath())
- {
- continue;
- }
-
- String fieldName = fieldDescriptor.getFieldName();
- String jcrName = fieldDescriptor.getJcrName();
-
- // Check the node properties
- boolean autoCreated = false;
-
- if (objectNode.hasProperty(jcrName))
- {
- autoCreated = objectNode.getProperty(jcrName).getDefinition().isAutoCreated();
- }
-
- // All auto created JCR properties are ignored
- if (!autoCreated)
- {
-
- Object fieldValue = PropertyUtils.getNestedProperty(object, fieldName);
- Class fieldTypeClass = fieldDescriptor.getFieldTypeClass() != null
- ? fieldDescriptor.getFieldTypeClass()
- : PropertyUtils.getPropertyType(object, fieldName);
- AtomicTypeConverter converter = (AtomicTypeConverter) atomicTypeConverters.get(fieldTypeClass);
- Value value = converter.getValue(fieldValue);
- // Check if mandatory property are not null
- this.checkMandatoryProperty(objectNode, fieldDescriptor, value);
-
- objectNode.setProperty(jcrName, value);
- }
-
- }
-
- }
-
- private CollectionConverter getCollectionConverter(CollectionDescriptor collectionDescriptor)
- throws ClassNotFoundException, NoSuchMethodException, InstantiationException, InvocationTargetException, IllegalAccessException
- {
-
- String className = collectionDescriptor.getCollectionConverterClassName();
- if (className == null)
- {
- return new DefaultCollectionConverterImpl(this.atomicTypeConverters, this, this.mapper);
- }
- else
- {
- Class converterClass = Class.forName(className);
- Object[] param =
- { this.atomicTypeConverters, this, this.mapper };
- return (CollectionConverter) ConstructorUtils.invokeConstructor(converterClass, param);
- }
-
- }
-
- private void checkMandatoryProperty(Node objectNode, FieldDescriptor fieldDescriptor, Value value) throws RepositoryException
- {
- PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getDeclaredPropertyDefinitions();
- for (int i = 0; i < propertyDefinitions.length; i++)
- {
- PropertyDefinition definition = propertyDefinitions[i];
- if (definition.getName().equals(fieldDescriptor.getJcrName()) && definition.isMandatory() && definition.isAutoCreated() == false && value == null)
- {
- throw new PersistenceException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName() + " has property: " + fieldDescriptor.getFieldName()
- + " declared as JCR property: " + fieldDescriptor.getJcrName() + " This property is mandatory but property in bean has value null");
- }
- }
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/query/Filter.java b/src/java/org/apache/portals/graffito/jcr/query/Filter.java
deleted file mode 100644
index 7bcb3260..00000000
--- a/src/java/org/apache/portals/graffito/jcr/query/Filter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.query;
-
-import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
-
-
-/**
- *
- * Graffito JCR Filter interface.
- *
- * @author Christophe Lombart
- *
- */
-public interface Filter
-{
-
-
- /**
- * Set the filter scope. The scope is an Node path specifying where to search in the content tree.
- * For example,
- * /mynode/mysecondnode/', the search engine will search on child objects in the /mynode/mysecondnode
- * /mynode/mysecondnode//', the search engine will search on desncendant objects in the /mynode/mysecondnode (the complete subnode tree)
- *
- * @param scope The filter scope
- *
- */
- public void setScope(String scope);
-
-
- /**
- * Get the filter scope.
- *
- * @return The filter scope
- */
- public String getScope();
-
-
- /**
- * Search content based on a fullTextSearch.
- * Depending on the full text search engine, you can also filter on properties.
- *
- * @param scope either a a jcr node or propserty. If a node is used, all properties of this node are searche (following the internal index
- * @param fullTextSearch The full text search string
- */
- public void addContains(String scope, String fullTextSearch) throws IncorrectAtomicTypeException;
-
- public void addBetween(String arg0, Object arg1, Object arg2) throws IncorrectAtomicTypeException;
-
- public void addEqualTo(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addGreaterOrEqualThan(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addGreaterThan(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addLessOrEqualThan(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addLessThan(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addLike(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addNotEqualTo(String arg0, Object arg1) throws IncorrectAtomicTypeException;
-
- public void addNotNull(String arg0) throws IncorrectAtomicTypeException;
-
- public void addIsNull(String arg0) throws IncorrectAtomicTypeException;
-
- public void addOrFilter(Filter arg0) throws IncorrectAtomicTypeException;
-
- public void addJCRExpression(String jcrExpression) throws IncorrectAtomicTypeException;
-
- public Class getFilterClass();
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java b/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
deleted file mode 100644
index db0737ff..00000000
--- a/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.query.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
-import org.apache.portals.graffito.jcr.query.Filter;
-
-/**
- * {@link org.apache.portals.graffito.jcr.query.Filter}
- *
- * @author Christophe Lombart
- *
- */
-public class FilterImpl implements Filter
-{
-
- private Class claszz;
- private String scope = "";
- private ArrayList jcrExpressions = new ArrayList();
-
-
- private ClassDescriptor classDescriptor;
- private Map atomicTypeConverters;
-
- private String orJcrExpression;
-
- private final static Log log = LogFactory.getLog(FilterImpl.class);
-
- /**
- * Construtor
- *
- * @param classDescriptor
- * @param atomicTypeConverters
- * @param clazz
- */
- public FilterImpl(ClassDescriptor classDescriptor, Map atomicTypeConverters, Class clazz)
- {
- this.claszz = clazz;
- this.atomicTypeConverters = atomicTypeConverters;
- this.classDescriptor = classDescriptor;
- }
-
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.query.Filter#getFilterClass()
- */
- public Class getFilterClass()
- {
- return claszz;
- }
-
-
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#setScope(java.lang.String)
- */
- public void setScope(String scope)
- {
- this.scope = scope;
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#getScope()
- */
- public String getScope()
- {
-
- return this.scope;
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addContains(java.lang.String)
- */
- public void addContains(String scope, String fullTextSearch)
- {
- String jcrExpression = null;
- if (scope.equals("."))
- {
- jcrExpression = "jcr:contains(., '" + fullTextSearch + "')";
- }
- else
- {
- jcrExpression = "jcr:contains(@" + this.getJcrFieldName(scope) + ", '" + fullTextSearch + "')";
- }
-
- jcrExpressions.add(jcrExpression);
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addBetween(java.lang.String, java.lang.Object, java.lang.Object)
- */
- public void addBetween(String fieldAttributeName, Object value1, Object value2)
- {
- String jcrExpression = "( @" + this.getJcrFieldName(fieldAttributeName) + " >= " + this.getStringValue(value1) +
- " and @" + this.getJcrFieldName(fieldAttributeName) + " <= " + this.getStringValue(value2) + ")";
- jcrExpressions.add(jcrExpression) ;
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addEqualTo(java.lang.String, java.lang.Object)
- */
- public void addEqualTo(String fieldAttributeName, Object value)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " = " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addGreaterOrEqualThan(java.lang.String, java.lang.Object)
- */
- public void addGreaterOrEqualThan(String fieldAttributeName, Object value)
- {
-
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " >= " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addGreaterThan(java.lang.String, java.lang.Object)
- */
- public void addGreaterThan(String fieldAttributeName, Object value)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " > " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
-
- }
-
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addLessOrEqualThan(java.lang.String, java.lang.Object)
- */
- public void addLessOrEqualThan(String fieldAttributeName, Object value)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " <= " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addLessOrEqualThan(java.lang.String, java.lang.Object)
- */
- public void addLessThan(String fieldAttributeName, Object value)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " < " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addLike(java.lang.Object, java.lang.Object)
- */
- public void addLike(String fieldAttributeName, Object value)
- {
- String jcrExpression = "jcr:like(" + "@" + this.getJcrFieldName(fieldAttributeName) + ", '" + value + "')";
- jcrExpressions.add(jcrExpression);
- }
-
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addNotEqualTo(java.lang.String, java.lang.Object)
- */
- public void addNotEqualTo(String fieldAttributeName, Object value)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName) + " != " + this.getStringValue(value);
- jcrExpressions.add(jcrExpression);
- }
-
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addNotNull(java.lang.String)
- */
- public void addNotNull(String fieldAttributeName)
- {
- String jcrExpression = "@" + this.getJcrFieldName(fieldAttributeName);
- jcrExpressions.add(jcrExpression);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addIsNull(java.lang.String)
- */
- public void addIsNull(String fieldAttributeName)
- {
- String jcrExpression = "not(@" + this.getJcrFieldName(fieldAttributeName)+")";
- jcrExpressions.add(jcrExpression);
-
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Filter#addOrFilter(org.apache.portals.graffito.jcr.query.Filter)
- */
- public void addOrFilter(Filter filter)
- {
-
- orJcrExpression = ((FilterImpl)filter).getJcrExpression();
-
- }
-
- public void addJCRExpression(String jcrExpression)
- {
- jcrExpressions.add(jcrExpression);
- }
-
-
- private String getJcrFieldName(String fieldAttribute)
- {
- String jcrFieldName = classDescriptor.getJcrName(fieldAttribute);
- if (jcrFieldName == null)
- {
- log.error("Impossible to find the jcrFieldName for the attribute :" + fieldAttribute);
- }
- return jcrFieldName;
-
- }
-
- private String getStringValue (Object value)
- {
- AtomicTypeConverter atomicTypeConverter = (AtomicTypeConverter) atomicTypeConverters.get(value.getClass());
- return atomicTypeConverter.getStringValue(value);
- }
-
- public String getJcrExpression()
- {
- if (orJcrExpression == null || orJcrExpression.equals(""))
- {
- return buildJcrExpression();
- }
- else
- {
- return "(" + buildJcrExpression() + ") or (" + this.orJcrExpression + ")";
- }
-
- }
-
- private String buildJcrExpression()
- {
- int count = 1;
- String jcrExp = "";
-
-
- Iterator criteriaIterator = jcrExpressions.iterator();
- while (criteriaIterator.hasNext())
- {
- if (count > 1)
- {
- jcrExp += " and ";
- }
- jcrExp += (String) criteriaIterator.next();
- count++;
-
- }
-
-
- return jcrExp;
-
- }
-
-
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java b/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java
deleted file mode 100644
index b6a017d5..00000000
--- a/src/java/org/apache/portals/graffito/jcr/query/impl/QueryImpl.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.query.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.query.Filter;
-import org.apache.portals.graffito.jcr.query.Query;
-
-/**
- * Default Query implementation
- *
- * @author Christophe Lombart
- *
- */
-public class QueryImpl implements Query
-{
-
- private Filter filter;
-
- ClassDescriptor classDescriptor;
-
- private ArrayList orderByExpressions = new ArrayList();
-
- /**
- * Constructor
- *
- * @param filter
- * @param mapper
- */
- public QueryImpl(Filter filter, Mapper mapper)
- {
- this.filter = filter;
- classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Query#setFilter(org.apache.portals.graffito.jcr.query.Filter)
- */
- public void setFilter(Filter filter)
- {
- this.filter = filter;
- }
-
- /**
- * @see org.apache.portals.graffito.jcr.query.Query#getFilter()
- */
- public Filter getFilter()
- {
- return this.filter;
- }
-
- public void addOrderByDescending(String fieldNameAttribute)
- {
- orderByExpressions.add("@" + this.getJcrFieldName(fieldNameAttribute) + " descending");
- }
-
- /**
- *
- * @see org.apache.portals.graffito.jcr.query.Query#addOrderByAscending(java.lang.String)
- */
- public void addOrderByAscending(String fieldNameAttribute)
- {
- orderByExpressions.add("@" + this.getJcrFieldName(fieldNameAttribute) + " ascending");
- }
-
- public String getOrderByExpression()
- {
-
- if (orderByExpressions.size() == 0)
- {
- return "";
- }
-
- String orderByExpression = "order by ";
- Iterator iterator = orderByExpressions.iterator();
- int count=1;
- while (iterator.hasNext())
- {
- if (count > 1)
- {
- orderByExpression += " , ";
- }
- orderByExpression+= (String) iterator.next();
- count++;
- }
-
- return orderByExpression;
- }
-
-
- private String getJcrFieldName(String fieldAttribute)
- {
-
- return classDescriptor.getJcrName(fieldAttribute);
-
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java b/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
deleted file mode 100644
index 16daab97..00000000
--- a/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.query.impl;
-
-import java.util.Map;
-
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
-import org.apache.portals.graffito.jcr.query.Filter;
-import org.apache.portals.graffito.jcr.query.Query;
-import org.apache.portals.graffito.jcr.query.QueryManager;
-
-public class QueryManagerImpl implements QueryManager
-{
-
- private Mapper mapper;
- private Map atomicTypeConverters;
- public QueryManagerImpl(Mapper mapper, Map atomicTypeConverters)
- {
- this.mapper = mapper;
- this.atomicTypeConverters = atomicTypeConverters;
- }
-
- public Filter createFilter(Class classQuery)
- {
-
- return new FilterImpl(mapper.getClassDescriptor(classQuery), atomicTypeConverters, classQuery);
- }
-
- public Query createQuery(Filter filter)
- {
-
- return new QueryImpl(filter, mapper);
- }
-
- public String buildJCRExpression(Query query)
- {
-
- Filter filter = query.getFilter();
-
- String jcrExp = "";
-
- // Add scope
- if ((filter.getScope() != null && ( ! filter.getScope().equals(""))))
- {
- jcrExp += "/jcr:root" + filter.getScope() + "element(*, ";
- }
- else
- {
- jcrExp += "//element(*, ";
- }
-
- // Add node type
- jcrExp += this.getNodeType(filter) + ") ";
-
- // Add filter criteria
- String filterExp = ((FilterImpl)filter).getJcrExpression();
- if ((filterExp != null) && ( ! filterExp.equals("")))
- {
- jcrExp += "[" + filterExp + "]";
- }
-
- // Add order by
- jcrExp += ((QueryImpl)query).getOrderByExpression();
-
- return jcrExp;
-
- }
-
- private String getNodeType(Filter filter)
- {
- ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
- return classDescriptor.getJcrNodeType();
-
- }
-
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java b/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java
deleted file mode 100644
index 895c60a6..00000000
--- a/src/java/org/apache/portals/graffito/jcr/repository/RepositoryUtil.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.repository;
-
-import java.util.Hashtable;
-
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
-import org.apache.jackrabbit.util.ISO9075;
-import org.apache.jackrabbit.util.Text;
-import org.apache.portals.graffito.jcr.exception.PersistenceException;
-import org.apache.portals.graffito.jcr.exception.RepositoryException;
-
-/**
-* Utility class for managing JCR repositories.
-*
-* @author Lombart Christophe
-* @version $Id: Exp $
-*/
-public class RepositoryUtil
-{
-
- /** Graffito namespace prefix constant.
- */
- private static final String GRAFFITO_NAMESPACE_PREFIX = "graffito";
-
- /** Graffito namespace constant.
- */
- private static final String GRAFFITO_NAMESPACE = "http://incubator.apache.org/graffito";
- /** Item path separator */
- public static final String PATH_SEPARATOR = "/";
-
- private final static Log log = LogFactory.getLog(RepositoryUtil.class);
- /**
- * Register a new repository
- *
- * @param repositoryName The repository unique name
- * @param configFile The JCR config file
- * @param homeDir The directory containing the complete repository settings (workspace, node types, ...)
- *
- * @throws RepositoryException when it is not possible to register the repository
- */
- public static void registerRepository(String repositoryName, String configFile, String homeDir) throws RepositoryException
- {
- try
- {
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- RegistryHelper.registerRepository(ctx, repositoryName, configFile, homeDir, true);
-
- }
- catch (Exception e)
- {
- throw new RepositoryException("Impossible to register the respository : " +
- repositoryName + " - config file : " + configFile, e);
- }
-
- }
-
-
- /**
- * Unregister a repository
- *
- * @param repositoryName The repository unique name
- *
- * @throws RepositoryException when it is not possible to unregister the repository
- */
- public static void unRegisterRepository(String repositoryName) throws RepositoryException
- {
- try
- {
-
-
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- RegistryHelper.unregisterRepository(ctx, repositoryName);
-
- }
- catch (Exception e)
- {
- throw new RepositoryException("Impossible to unregister the respository : " +
- repositoryName , e);
- }
-
- }
-
- /**
- * Get a repository
- *
- * @param repositoryName The repository name
- * @return a JCR repository reference
- *
- * @throws RepositoryException when it is not possible to get the repository.
- * Before calling this method, the repository has to be registered (@see RepositoryUtil#registerRepository(String, String, String)
- */
- public static Repository getRepository(String repositoryName) throws RepositoryException
- {
- try
- {
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
- env.put(Context.PROVIDER_URL, "localhost");
- InitialContext ctx = new InitialContext(env);
-
- Repository repository = (Repository) ctx.lookup(repositoryName);
- return repository;
- }
- catch (Exception e)
- {
- throw new RepositoryException("Impossible to get the repository : " + repositoryName, e);
- }
- }
-
- /**
- * Connect to a JCR repository
- *
- * @param repository The JCR repository
- * @param user The user name
- * @param password The password
- * @return a valid JCR session
- *
- * @throws RepositoryException when it is not possible to connect to the JCR repository
- */
- public static Session login(Repository repository, String user, String password) throws RepositoryException
- {
- try
- {
- Session session = repository.login(new SimpleCredentials(user, password.toCharArray()), null);
- setupSession(session);
-
- return session;
-
- }
- catch (Exception e)
- {
- throw new RepositoryException("Impossible to login ", e);
- }
- }
-
- /**
- * Check if a path is valid
- *
- * @param path The path to validate
- * @return true if the path is valid, else false
- */
- public static boolean isValidPath(String path)
- {
- if ((path == null) ||
- (path.equals(PATH_SEPARATOR)) ||
- (path.endsWith(PATH_SEPARATOR)) ||
- (! path.startsWith(PATH_SEPARATOR)) ||
- (path.equals("")))
- {
- return false;
- }
- return true;
- }
-
- /**
- * Get the parent path
- * @param path The path from wich the parent path has to be returned
- * @return The parent path
- *
- * @throws PersistenceException when the path is invalid
- */
- public static String getParentPath(String path) throws PersistenceException
- {
- String parentPath = "";
-
- if (!isValidPath(path))
- {
- throw new PersistenceException("Invalid path : " + path);
- }
-
- String[] pathElements = path.split(PATH_SEPARATOR);
-
- // Firts path element should be = empty string because a uri always start with '/'
- // So, if len=2, means it is a root folder like '/foo'.
- // In this case the uri has not parent folder => return "/"
- if (pathElements.length == 2)
- {
- return PATH_SEPARATOR;
- }
-
- for(int i=0; i < pathElements.length -1; i++)
- {
- if (! pathElements[i].equals(""))
- {
- parentPath += PATH_SEPARATOR + pathElements[i];
- }
- }
- return parentPath;
- }
-
- /**
- * Get the node name
- * @param path The path from which the node name has to be retrieved
- * @return The node name
- *
- * @throws PersistenceException when the path is invalid
- */
- public static String getNodeName(String path) throws PersistenceException
- {
-
- String[] pathElements = path.split(PATH_SEPARATOR);
-
- if (! isValidPath(path))
- {
- throw new PersistenceException("Invalid path : " + path);
- }
- return pathElements[pathElements.length-1];
- }
-
- /**
- * Setup the session.
- * Until now, we check only if the Graffito namespace prefix exist in the repository
- *
- */
- private static void setupSession(Session session) throws RepositoryException
- {
- try
- {
- String[] jcrNamespaces = session.getWorkspace().getNamespaceRegistry().getPrefixes();
- boolean createGraffitoNamespace = true;
- for (int i = 0; i < jcrNamespaces.length; i++)
- {
- if (jcrNamespaces[i].equals(GRAFFITO_NAMESPACE_PREFIX))
- {
- createGraffitoNamespace = false;
- log.debug("Graffito namespace exists.");
- }
- }
-
- if (createGraffitoNamespace)
- {
- session.getWorkspace().getNamespaceRegistry().registerNamespace(GRAFFITO_NAMESPACE_PREFIX, GRAFFITO_NAMESPACE);
- log.info("Successfully created graffito namespace.");
- }
-
- if (session.getRootNode() != null)
- {
- log.info("Jcr repository setup successfull.");
- }
-
-
- }
- catch (Exception e)
- {
- log.error("Error while setting up the jcr repository.", e);
- throw new RepositoryException(e.getMessage());
- }
- }
-
- /**
- * Encode a path
- * @TODO : drop Jackrabbit dependency
- *
- * @param path the path to encode
- * @return the encoded path
- *
- */
- public static String encodePath(String path)
- {
- String[] pathElements = Text.explode(path, '/');
- for (int i=0;iSimpleAccessManager ...
- */
-public class SimpleAccessManager implements AccessManager
-{
-
- private static Logger log = Logger.getLogger(SimpleAccessManager.class);
-
- /**
- * Subject whose access rights this AccessManager should reflect
- */
- protected Subject subject;
-
- /**
- * hierarchy manager used for ACL-based access control model
- */
- protected HierarchyManager hierMgr;
-
- private boolean initialized;
-
- protected boolean system;
-
- protected boolean anonymous;
-
- /**
- * Empty constructor
- */
- public SimpleAccessManager()
- {
- initialized = false;
- anonymous = false;
- system = false;
- }
-
- //--------------------------------------------------------< AccessManager >
- /**
- * {@inheritDoc}
- */
- public void init(AMContext context) throws AccessDeniedException, Exception
- {
- if (initialized)
- {
- throw new IllegalStateException("already initialized");
- }
-
- subject = context.getSubject();
- hierMgr = context.getHierarchyManager();
- anonymous = !subject.getPrincipals(AnonymousPrincipal.class).isEmpty();
- system = !subject.getPrincipals(SystemPrincipal.class).isEmpty();
-
- // @todo check permission to access given workspace based on principals
- initialized = true;
- }
-
- /**
- * {@inheritDoc}
- */
- public synchronized void close() throws Exception
- {
- if (!initialized)
- {
- throw new IllegalStateException("not initialized");
- }
-
- initialized = false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void checkPermission(ItemId id, int permissions) throws AccessDeniedException, ItemNotFoundException, RepositoryException
- {
- if (!initialized)
- {
- throw new IllegalStateException("not initialized");
- }
-
- if (system)
- {
- // system has always all permissions
- return;
- }
- else if (anonymous)
- {
- // anonymous is always denied WRITE & REMOVE premissions
- if ((permissions & WRITE) == WRITE || (permissions & REMOVE) == REMOVE)
- {
- throw new AccessDeniedException();
- }
- }
- // @todo check permission based on principals
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isGranted(ItemId id, int permissions) throws ItemNotFoundException, RepositoryException
- {
- if (!initialized)
- {
- throw new IllegalStateException("not initialized");
- }
-
- if (system)
- {
- // system has always all permissions
- return true;
- }
- else if (anonymous)
- {
- // anonymous is always denied WRITE & REMOVE premissions
- if ((permissions & WRITE) == WRITE || (permissions & REMOVE) == REMOVE)
- {
- return false;
- }
- }
-
- // @todo check permission based on principals
- return true;
-
-
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean canAccess(String workspaceName) throws NoSuchWorkspaceException, RepositoryException
- {
- // @todo check permission to access given workspace based on principals
- return true;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/security/SimpleLoginModule.java b/src/java/org/apache/portals/graffito/jcr/security/SimpleLoginModule.java
deleted file mode 100644
index 0cfbc68c..00000000
--- a/src/java/org/apache/portals/graffito/jcr/security/SimpleLoginModule.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.security;
-
-import org.apache.jackrabbit.core.security.AnonymousPrincipal;
-import org.apache.jackrabbit.core.security.CredentialsCallback;
-import org.apache.jackrabbit.core.security.SecurityConstants;
-import org.apache.jackrabbit.core.security.UserPrincipal;
-import org.apache.log4j.Logger;
-
-import javax.jcr.Credentials;
-import javax.jcr.SimpleCredentials;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.FailedLoginException;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A SimpleLoginModule ...
- */
-public class SimpleLoginModule implements LoginModule
-{
-
- private static Logger log = Logger.getLogger(SimpleLoginModule.class);
-
- /**
- * Name of the anonymous user id option in the LoginModule configuration
- */
- private static final String OPT_ANONYMOUS = "anonymousId";
-
- /**
- * The default user id for anonymous login
- */
- private static final String DEFAULT_ANONYMOUS_ID = "anonymous";
-
- // initial state
- private Subject subject;
-
- private CallbackHandler callbackHandler;
-
- private Map sharedState;
-
- private Map options;
-
- // configurable options
- //private boolean someOpt = false;
-
- // local authentication state:
- // the principals, i.e. the authenticated identities
- private final Set principals = new HashSet();
-
- /**
- * Id of an anonymous user login
- */
- private String anonymousUserId = DEFAULT_ANONYMOUS_ID;
-
- /**
- * Constructor
- */
- public SimpleLoginModule()
- {
- }
-
- //----------------------------------------------------------< LoginModule >
- /**
- * {@inheritDoc}
- */
- public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
- {
- this.subject = subject;
- this.callbackHandler = callbackHandler;
- this.sharedState = sharedState;
- this.options = options;
-
- // initialize any configured options
- //someOpt = "true".equalsIgnoreCase((String)options.get("someOpt"));
- String userId = (String) options.get(OPT_ANONYMOUS);
- if (userId != null)
- {
- anonymousUserId = userId;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean login() throws LoginException
- {
- // prompt for a user name and password
- if (callbackHandler == null)
- {
- throw new LoginException("no CallbackHandler available");
- }
-
- Callback[] callbacks = new Callback[]
- { new CredentialsCallback() };
-
- boolean authenticated = false;
- principals.clear();
- try
- {
- callbackHandler.handle(callbacks);
- // credentials
- CredentialsCallback ccb = (CredentialsCallback) callbacks[0];
- Credentials creds = ccb.getCredentials();
- if (creds != null)
- {
- if (creds instanceof SimpleCredentials)
- {
- SimpleCredentials sc = (SimpleCredentials) creds;
- // authenticate
-
- Object attr = sc.getAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE);
- if (attr != null && attr instanceof Subject)
- {
- Subject impersonator = (Subject) attr;
- // @todo check privileges to 'impersonate' the user represented by the supplied credentials
- }
- else
- {
- // @todo implement simple username/password authentication
- }
-
- if (anonymousUserId.equals(sc.getUserID()))
- {
- principals.add(new AnonymousPrincipal());
- }
- else
- {
- // else assume the user we authenticated is the UserPrincipal
- principals.add(new UserPrincipal(sc.getUserID()));
- }
- authenticated = true;
- }
- }
- }
- catch (java.io.IOException ioe)
- {
- throw new LoginException(ioe.toString());
- }
- catch (UnsupportedCallbackException uce)
- {
- throw new LoginException(uce.getCallback().toString() + " not available");
- }
-
- if (authenticated)
- {
- return !principals.isEmpty();
- }
- else
- {
- // authentication failed: clean out state
- principals.clear();
- throw new FailedLoginException();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean commit() throws LoginException
- {
- if (principals.isEmpty())
- {
- return false;
- }
- else
- {
- // add a principals (authenticated identities) to the Subject
- subject.getPrincipals().addAll(principals);
- return true;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean abort() throws LoginException
- {
- if (principals.isEmpty())
- {
- return false;
- }
- else
- {
- logout();
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean logout() throws LoginException
- {
- subject.getPrincipals().removeAll(principals);
- principals.clear();
- return true;
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/transaction/jackrabbit/UserTransactionImpl.java b/src/java/org/apache/portals/graffito/jcr/transaction/jackrabbit/UserTransactionImpl.java
deleted file mode 100644
index 913febf9..00000000
--- a/src/java/org/apache/portals/graffito/jcr/transaction/jackrabbit/UserTransactionImpl.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.transaction.jackrabbit;
-
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import javax.transaction.xa.XAException;
-import javax.transaction.UserTransaction;
-import javax.transaction.Status;
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.core.XASession;
-
-/**
- * Internal {@link javax.transaction.UserTransaction} implementation.
- */
-public class UserTransactionImpl implements UserTransaction {
-
- /**
- * Global transaction id counter
- */
- private static byte counter = 0;
-
- /**
- * XAResource
- */
- private final XAResource xares;
-
- /**
- * Xid
- */
- private Xid xid;
-
- /**
- * Status
- */
- private int status = Status.STATUS_NO_TRANSACTION;
-
- /**
- * Create a new instance of this class. Takes a session as parameter.
- * @param session session. If session is not of type
- * {@link XASession}, an IllegalArgumentException
- * is thrown
- */
- public UserTransactionImpl(Session session) {
- if (session instanceof XASession) {
- xares = ((XASession) session).getXAResource();
- } else {
- throw new IllegalArgumentException("Session not of type XASession");
- }
- }
-
- /**
- * @see javax.transaction.UserTransaction#begin
- */
- public void begin() throws NotSupportedException, SystemException {
- if (status != Status.STATUS_NO_TRANSACTION) {
- throw new IllegalStateException("Transaction already active");
- }
-
- try {
- xid = new XidImpl(counter++);
- xares.start(xid, XAResource.TMNOFLAGS);
- status = Status.STATUS_ACTIVE;
-
- } catch (XAException e) {
-
- throw new SystemException("Unable to begin transaction: " +
- "XA_ERR=" + e.errorCode);
- }
- }
-
- /**
- * @see javax.transaction.UserTransaction#commit
- */
- public void commit() throws HeuristicMixedException,
- HeuristicRollbackException, IllegalStateException,
- RollbackException, SecurityException, SystemException {
-
- if (status != Status.STATUS_ACTIVE) {
- throw new IllegalStateException("Transaction not active");
- }
-
- try {
- xares.end(xid, XAResource.TMSUCCESS);
-
- status = Status.STATUS_PREPARING;
- xares.prepare(xid);
- status = Status.STATUS_PREPARED;
-
- status = Status.STATUS_COMMITTING;
- xares.commit(xid, false);
- status = Status.STATUS_COMMITTED;
-
- } catch (XAException e) {
-
- if (e.errorCode >= XAException.XA_RBBASE &&
- e.errorCode <= XAException.XA_RBEND) {
- throw new RollbackException();
- } else {
- throw new SystemException("Unable to commit transaction: " +
- "XA_ERR=" + e.errorCode);
- }
- }
- }
-
- /**
- * @see javax.transaction.UserTransaction#getStatus
- */
- public int getStatus() throws SystemException {
- return status;
- }
-
- /**
- * @see javax.transaction.UserTransaction#rollback
- */
- public void rollback() throws IllegalStateException, SecurityException,
- SystemException {
-
- if (status != Status.STATUS_ACTIVE &&
- status != Status.STATUS_MARKED_ROLLBACK) {
-
- throw new IllegalStateException("Transaction not active");
- }
-
- try {
- xares.end(xid, XAResource.TMFAIL);
-
- status = Status.STATUS_ROLLING_BACK;
- xares.rollback(xid);
- status = Status.STATUS_ROLLEDBACK;
-
- } catch (XAException e) {
-
- throw new SystemException("Unable to rollback transaction: " +
- "XA_ERR=" + e.errorCode);
- }
- }
-
- /**
- * @see javax.transaction.UserTransaction#setRollbackOnly()
- */
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- if (status != Status.STATUS_ACTIVE) {
- throw new IllegalStateException("Transaction not active");
- }
- status = Status.STATUS_MARKED_ROLLBACK;
- }
-
- /**
- * @see javax.transaction.UserTransaction#setTransactionTimeout
- */
- public void setTransactionTimeout(int seconds) throws SystemException {}
-
-
- /**
- * Internal {@link Xid} implementation.
- */
- class XidImpl implements Xid {
-
- /** Global transaction id */
- private final byte[] globalTxId;
-
- /**
- * Create a new instance of this class. Takes a global
- * transaction number as parameter
- * @param globalTxNumber global transaction number
- */
- public XidImpl(byte globalTxNumber) {
- this.globalTxId = new byte[] { globalTxNumber };
- }
-
- /**
- * @see javax.transaction.xa.Xid#getFormatId()
- */
- public int getFormatId() {
- return 0;
- }
-
- /**
- * @see javax.transaction.xa.Xid#getBranchQualifier()
- */
- public byte[] getBranchQualifier() {
- return new byte[0];
- }
-
- /**
- * @see javax.transaction.xa.Xid#getGlobalTransactionId()
- */
- public byte[] getGlobalTransactionId() {
- return globalTxId;
- }
- }
-}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/CustomNodeTypeCreationException.java
similarity index 75%
rename from src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/CustomNodeTypeCreationException.java
index 22bae1ff..5a097c75 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/CustomNodeTypeCreationException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/CustomNodeTypeCreationException.java
@@ -1,57 +1,58 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/** This exception is thrown during repository setup while creating the
- * custom graffito node types.
- *
- * @author Oliver Kiessler
- * @version $Id: Exp $
- */
-public class CustomNodeTypeCreationException extends JcrMappingException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = 3991714987182739219L;
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public CustomNodeTypeCreationException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public CustomNodeTypeCreationException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public CustomNodeTypeCreationException(String message, Throwable nested) {
- super(message, nested);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/** This exception is thrown during repository setup while creating the
+ * custom node types.
+ *
+ * @author Oliver Kiessler
+ * @version $Id: Exp $
+ */
+public class CustomNodeTypeCreationException extends JcrMappingException {
+
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = 3991714987182739219L;
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public CustomNodeTypeCreationException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public CustomNodeTypeCreationException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public CustomNodeTypeCreationException(String message, Throwable nested) {
+ super(message, nested);
+ }
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/IllegalUnlockException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/IllegalUnlockException.java
similarity index 72%
rename from src/java/org/apache/portals/graffito/jcr/exception/IllegalUnlockException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/IllegalUnlockException.java
index 7191fbe6..b92bf66d 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/IllegalUnlockException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/IllegalUnlockException.java
@@ -1,56 +1,57 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * If user cannot unlock path, for example if he/she have not correct lockTokens
- *
- * @author Martin Koci
- * @author Alexandru Popescu
- */
-public class IllegalUnlockException extends LockingException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = 5078216219061716697L;
-
- private final String lockOwner;
-
- private final String path;
-
- /**
- *
- * @return The JCR Lock Owner
- */
- public String getLockOwner() {
- return lockOwner;
- }
-
- /**
- *
- * @return the JCR path
- */
- public String getPath() {
- return path;
- }
-
- public IllegalUnlockException(String lockOwner, String path) {
- super();
- this.lockOwner = lockOwner;
- this.path = path;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * If user cannot unlock path, for example if he/she have not correct lockTokens
+ *
+ * @author Martin Koci
+ * @author Alexandru Popescu
+ */
+public class IllegalUnlockException extends LockingException {
+
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = 5078216219061716697L;
+
+ private final String lockOwner;
+
+ private final String path;
+
+ /**
+ *
+ * @return The JCR Lock Owner
+ */
+ public String getLockOwner() {
+ return lockOwner;
+ }
+
+ /**
+ *
+ * @return the JCR path
+ */
+ public String getPath() {
+ return path;
+ }
+
+ public IllegalUnlockException(String lockOwner, String path) {
+ super();
+ this.lockOwner = lockOwner;
+ this.path = path;
+ }
+
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectAtomicTypeException.java
similarity index 71%
rename from src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectAtomicTypeException.java
index f09d6579..84f598d3 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectAtomicTypeException.java
@@ -1,44 +1,44 @@
-/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * Occurs when the jcr mapping converters try to assign or read an incorrect atomic field type.
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-public class IncorrectAtomicTypeException extends JcrMappingException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = 8819724602193665601L;
-
- public IncorrectAtomicTypeException(String message, Throwable nested) {
- super(message, nested);
- }
-
- public IncorrectAtomicTypeException(String message) {
- super(message);
- }
-
- public IncorrectAtomicTypeException(Throwable nested) {
- super(nested);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when the jcr mapping converters try to assign or read an incorrect atomic field type.
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class IncorrectAtomicTypeException extends JcrMappingException {
+
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = 8819724602193665601L;
+
+ public IncorrectAtomicTypeException(String message, Throwable nested) {
+ super(message, nested);
+ }
+
+ public IncorrectAtomicTypeException(String message) {
+ super(message);
+ }
+
+ public IncorrectAtomicTypeException(Throwable nested) {
+ super(nested);
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectPersistentClassException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectPersistentClassException.java
new file mode 100644
index 00000000..28e76603
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/IncorrectPersistentClassException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when the ocm try to manage an object which is not based on a persistent class.
+ *
+ * @author Christophe Lombart
+ */
+public class IncorrectPersistentClassException extends JcrMappingException {
+
+
+ public IncorrectPersistentClassException(String message, Throwable nested) {
+ super(message, nested);
+ }
+
+ public IncorrectPersistentClassException(String message) {
+ super(message);
+ }
+
+ public IncorrectPersistentClassException(Throwable nested) {
+ super(nested);
+ }
+
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/InitMapperException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/InitMapperException.java
similarity index 76%
rename from src/java/org/apache/portals/graffito/jcr/exception/InitMapperException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/InitMapperException.java
index d2b3973b..2640066e 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/InitMapperException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/InitMapperException.java
@@ -1,56 +1,57 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * Occurs when it is not possible to initialise the Mapper
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-public class InitMapperException extends JcrMappingException {
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = 8845469719898820727L;
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public InitMapperException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public InitMapperException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public InitMapperException(String message, Throwable nested) {
- super(message, nested);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when it is not possible to initialise the Mapper
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class InitMapperException extends JcrMappingException {
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = 8845469719898820727L;
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public InitMapperException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public InitMapperException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public InitMapperException(String message, Throwable nested) {
+ super(message, nested);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
new file mode 100644
index 00000000..79eb3902
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/InvalidQueryException.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+/**
+ * The InvalidQuerySyntaxException is an
+ * ObjectContentManagerException thrown if the query of the
+ * {@link org.apache.jackrabbit.ocm.manager.ObjectContentManager#getObjectIterator(String, String)}
+ * is invalid. This exception actually wraps a standard JCR
+ * javax.jcr.InvalidQueryException to make it an unchecked
+ * exception. The cause of this exception will always be the original
+ * InvalidQueryException and the message will always be the
+ * original exception's message.
+ */
+public class InvalidQueryException extends ObjectContentManagerException {
+
+ /**
+ * Create an exception wrapping the given checked JCR exception
+ *
+ * @param cause The wrapped JCR InvalidQueryException
+ */
+ public InvalidQueryException(javax.jcr.query.InvalidQueryException cause) {
+ super(cause.getMessage(), cause);
+ }
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/JcrMappingException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/JcrMappingException.java
similarity index 73%
rename from src/java/org/apache/portals/graffito/jcr/exception/JcrMappingException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/JcrMappingException.java
index 9918dfbb..71566f2f 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/JcrMappingException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/JcrMappingException.java
@@ -1,59 +1,60 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- *
- * Base class of all runtime exceptions used in the JCR mapping.
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-
-public class JcrMappingException extends NestableRuntimeException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = -5237713309666840905L;
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public JcrMappingException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public JcrMappingException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public JcrMappingException(String message, Throwable nested) {
- super(message, nested);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ *
+ * Base class of all runtime exceptions used in the JCR mapping.
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+
+public class JcrMappingException extends RuntimeException {
+
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = -5237713309666840905L;
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public JcrMappingException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public JcrMappingException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public JcrMappingException(String message, Throwable nested) {
+ super(message, nested);
+ }
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/LockedException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/LockedException.java
similarity index 65%
rename from src/java/org/apache/portals/graffito/jcr/exception/LockedException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/LockedException.java
index 9aa915f2..a6640fb0 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/LockedException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/LockedException.java
@@ -1,23 +1,24 @@
/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.portals.graffito.jcr.exception;
+package org.apache.jackrabbit.ocm.exception;
/**
- * Throwed if a path is locked and a operation cannot be performed
- *
+ * Throwed if a path is locked and a operation cannot be performed
+ *
* @author markoc
*/
@@ -34,7 +35,7 @@ public LockedException(String lockOwner, String lockedNodePath) {
}
/**
- *
+ *
* @return The JCR Lock Owner
*/
public String getLockOwner() {
@@ -42,8 +43,8 @@ public String getLockOwner() {
}
/**
- *
- * @return The JCR locked node path
+ *
+ * @return The JCR locked node path
*/
public String getLockedNodePath() {
return lockedNodePath;
diff --git a/src/main/java/org/apache/jackrabbit/ocm/exception/LockingException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/LockingException.java
new file mode 100644
index 00000000..414e6cf7
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/LockingException.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+/**
+ * Base exception for all exceptions related to JCR Locking feature.
+ *
+ * @author markoc
+ */
+abstract public class LockingException extends ObjectContentManagerException {
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/PersistenceException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/ObjectContentManagerException.java
similarity index 63%
rename from src/java/org/apache/portals/graffito/jcr/exception/PersistenceException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/ObjectContentManagerException.java
index a25469e3..07e2d734 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/PersistenceException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/ObjectContentManagerException.java
@@ -1,62 +1,63 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * Occurs when it is not possible to persist an object
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-public class PersistenceException extends NestableRuntimeException {
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = -643089296035094427L;
-
- /**
- * Not intended for usage.
- */
- protected PersistenceException() {
- }
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public PersistenceException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public PersistenceException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public PersistenceException(String message, Throwable nested) {
- super(message, nested);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when it is not possible to persist an object
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class ObjectContentManagerException extends RuntimeException {
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = -643089296035094427L;
+
+ /**
+ * Not intended for usage.
+ */
+ protected ObjectContentManagerException() {
+ }
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public ObjectContentManagerException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public ObjectContentManagerException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public ObjectContentManagerException(String message, Throwable nested) {
+ super(message, nested);
+ }
}
\ No newline at end of file
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/RepositoryException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/RepositoryException.java
similarity index 75%
rename from src/java/org/apache/portals/graffito/jcr/exception/RepositoryException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/RepositoryException.java
index b5c9f2d7..22bc0f62 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/RepositoryException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/RepositoryException.java
@@ -1,63 +1,64 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * Occurs when it is not possible to manage the JCR repository (register, login, ...)
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-public class RepositoryException extends NestableRuntimeException {
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = 910346108378604638L;
-
- /**
- * No-arg constructor used by markup exceptions.
- */
- protected RepositoryException() {
- }
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public RepositoryException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public RepositoryException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public RepositoryException(String message, Throwable nested) {
- super(message, nested);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when it is not possible to manage the JCR repository (register, login, ...)
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class RepositoryException extends RuntimeException {
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = 910346108378604638L;
+
+ /**
+ * No-arg constructor used by markup exceptions.
+ */
+ protected RepositoryException() {
+ }
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public RepositoryException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public RepositoryException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public RepositoryException(String message, Throwable nested) {
+ super(message, nested);
+ }
+
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/exception/VersionException.java b/src/main/java/org/apache/jackrabbit/ocm/exception/VersionException.java
similarity index 76%
rename from src/java/org/apache/portals/graffito/jcr/exception/VersionException.java
rename to src/main/java/org/apache/jackrabbit/ocm/exception/VersionException.java
index 67a70521..4e9d0830 100644
--- a/src/java/org/apache/portals/graffito/jcr/exception/VersionException.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/exception/VersionException.java
@@ -1,58 +1,59 @@
-/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.graffito.jcr.exception;
-
-
-/**
- * Occurs when it is not possible to read information on version or manage versions
- *
- * @author Christophe Lombart
- * @author Alexandru Popescu
- */
-public class VersionException extends RepositoryException {
-
- /** Use serialVersionUID for interoperability. */
- private final static long serialVersionUID = -7727568152521484252L;
-
- /**
- * Constructor with message.
- *
- * @param message the message associated to the exception
- */
- public VersionException(String message) {
- super(message);
- }
-
- /**
- * Constructor with throwable object.
- *
- * @param nested the associated throwable object
- */
- public VersionException(Throwable nested) {
- super(nested);
- }
-
- /**
- * Constructor with message and throwable object.
- *
- * @param message the message associated to the exception
- * @param nested the associated throwable object
- */
- public VersionException(String message, Throwable nested) {
- super(message, nested);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.exception;
+
+
+/**
+ * Occurs when it is not possible to read information on version or manage versions
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class VersionException extends RepositoryException {
+
+ /** Use serialVersionUID for interoperability. */
+ private final static long serialVersionUID = -7727568152521484252L;
+
+ /**
+ * Constructor with message.
+ *
+ * @param message the message associated to the exception
+ */
+ public VersionException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with throwable object.
+ *
+ * @param nested the associated throwable object
+ */
+ public VersionException(Throwable nested) {
+ super(nested);
+ }
+
+ /**
+ * Constructor with message and throwable object.
+ *
+ * @param message the message associated to the exception
+ * @param nested the associated throwable object
+ */
+ public VersionException(String message, Throwable nested) {
+ super(message, nested);
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/lock/Lock.java b/src/main/java/org/apache/jackrabbit/ocm/lock/Lock.java
new file mode 100644
index 00000000..671b097a
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/lock/Lock.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.lock;
+
+import javax.jcr.Node;
+
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+
+/**
+ * Wrapper class for a JCR Lock object
+ *
+ * @author Lombart Christophe
+ *
+ */
+public class Lock
+{
+
+ private javax.jcr.lock.Lock lock;
+
+ public Lock(javax.jcr.lock.Lock lock)
+ {
+ this.lock = lock;
+ }
+
+ public String getLockOwner() {
+ return lock.getLockOwner();
+ }
+
+ public String getLockToken() {
+ return lock.getLockToken();
+ }
+
+ public Node getNode() {
+ return lock.getNode();
+ }
+
+ public boolean isDeep() {
+ return lock.isDeep();
+ }
+
+ public boolean isLive() {
+ try
+ {
+ return lock.isLive();
+ }
+ catch (javax.jcr.RepositoryException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public boolean isSessionScoped() {
+ return lock.isSessionScoped();
+ }
+
+ public void refresh() {
+ try
+ {
+ lock.refresh();
+ }
+ catch (javax.jcr.RepositoryException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ }
+
+
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/CustomNodeTypeCreator.java b/src/main/java/org/apache/jackrabbit/ocm/manager/CustomNodeTypeCreator.java
similarity index 57%
rename from src/java/org/apache/portals/graffito/jcr/persistence/CustomNodeTypeCreator.java
rename to src/main/java/org/apache/jackrabbit/ocm/manager/CustomNodeTypeCreator.java
index efdf30cc..daf9018f 100644
--- a/src/java/org/apache/portals/graffito/jcr/persistence/CustomNodeTypeCreator.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/CustomNodeTypeCreator.java
@@ -1,22 +1,23 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.portals.graffito.jcr.persistence;
+package org.apache.jackrabbit.ocm.manager;
-import org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException;
-import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
+import org.apache.jackrabbit.ocm.exception.CustomNodeTypeCreationException;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
/** Interface for custom node type creator implementations.
*
@@ -27,21 +28,21 @@ public interface CustomNodeTypeCreator {
/** This method is supposed to create custom node types on repository
* setup.
- *
- * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException
- * @return true/false True if custom node type creation succeeded
+ *
+ * @throws org.apache.jackrabbit.ocm.exception.CustomNodeTypeCreationException
+ * @return true/false True if custom node type creation succeeded
*/
boolean createInitialJcrCustomNodeTypes() throws CustomNodeTypeCreationException;
/** Method to add a jcr custom node type to an existing jcr repository.
- *
- * @throws org.apache.portals.graffito.jcr.exception.CustomNodeTypeCreationException
+ *
+ * @throws org.apache.jackrabbit.ocm.exception.CustomNodeTypeCreationException
* @return true/false True if custom node type creation succeeded
*/
boolean addJcrCustomNodeType() throws CustomNodeTypeCreationException;
-
+
/** Jcr session to be injected into implementation.
* @param jcrSession JcrSession
*/
- void setJcrSession(PersistenceManagerImpl jcrSession);
+ void setJcrSession(ObjectContentManagerImpl jcrSession);
}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/ManagerConstant.java b/src/main/java/org/apache/jackrabbit/ocm/manager/ManagerConstant.java
new file mode 100644
index 00000000..ad211dbc
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/ManagerConstant.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager;
+
+
+
+/**
+ *
+ * General Object Content Manager Constants use in several classes
+ *
+ * @author Lombart Christophe
+ *
+ */
+public interface ManagerConstant
+{
+ public static final String NT_UNSTRUCTURED = "nt:unstructured";
+ public static final String DISCRIMINATOR_NODE_TYPE = "ocm:discriminator";
+ public static final String DISCRIMINATOR_CLASS_NAME_PROPERTY = "ocm_classname";
+
+
+ public static final String FROZEN_NODE_TYPE = "nt:frozenNode";
+ public static final String FROZEN_PRIMARY_TYPE_PROPERTY = "jcr:frozenPrimaryType";
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java b/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
new file mode 100644
index 00000000..e42e0d74
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/ObjectContentManager.java
@@ -0,0 +1,559 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.ocm.exception.IllegalUnlockException;
+import org.apache.jackrabbit.ocm.exception.LockedException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.lock.Lock;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.apache.jackrabbit.ocm.version.Version;
+import org.apache.jackrabbit.ocm.version.VersionIterator;
+
+/**
+ * The object content manager encapsulates a JCR session. This is the main
+ * component used to manage objects into the JCR repository.
+ *
+ * @author Sandro Boehme
+ * @author Lombart
+ * Christophe
+ *
+ */
+public interface ObjectContentManager {
+
+ /**
+ * Check if an object exists
+ *
+ * @param path
+ * the object path
+ * @return true if the item exists
+ * @throws ObjectContentManagerException
+ * when it is not possible to check if the item exist
+ */
+ public boolean objectExists(String path)
+ throws ObjectContentManagerException;
+
+ /**
+ * Can this object content manager insert, update, delete, ... that type?
+ *
+ * @param clazz
+ * class for question
+ * @return true if the class is persistence
+ */
+ boolean isPersistent(Class clazz);
+
+ /**
+ * Insert an object into the JCR repository
+ *
+ * @param object
+ * the object to add
+ * @throws ObjectContentManagerException
+ * when it is not possible to insert the object
+ */
+ public void insert(Object object) throws ObjectContentManagerException;
+
+ /**
+ * Update an object
+ *
+ * @param object
+ * the object to update
+ * @throws ObjectContentManagerException
+ * when it is not possible to update the object
+ */
+ public void update(Object object) throws ObjectContentManagerException;
+
+ /**
+ * Get an object from the JCR repository
+ *
+ * @param path
+ * the object path
+ * @return the object found or null
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ */
+ public Object getObject(String path) throws ObjectContentManagerException;
+
+ /**
+ * Get an object from the JCR repository
+ *
+ * @param uuid the object uuid
+ * @return the object found or null
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ */
+ public Object getObjectByUuid(String uuid)
+ throws ObjectContentManagerException;
+
+ /**
+ * Get an object from the JCR repository
+ *
+ * @param path
+ * the object path
+ * @param versionNumber
+ * The desired object version number
+ * @return the object found or null
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ */
+ public Object getObject(String path, String versionNumber)
+ throws ObjectContentManagerException;
+
+ /**
+ * Get an object from the JCR repository
+ *
+ * @param objectClass
+ * the object class
+ * @param path
+ * the object path
+ * @return the object found or null
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ */
+ public Object getObject(Class objectClass, String path)
+ throws ObjectContentManagerException;
+
+ /**
+ * Get an object from the JCR repository
+ *
+ * @param objectClass
+ * the object class
+ * @param path
+ * the object path
+ * @param versionNumber
+ * The desired object version number
+ * @return the object found or null
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ */
+ public Object getObject(Class objectClass, String path, String versionNumber)
+ throws ObjectContentManagerException;
+
+ /**
+ *
+ * @param query
+ *
+ * @return NodeIterator
+ */
+ public NodeIterator getNodes(Query query);
+
+ /**
+ * Retrieve the specified attribute for the given persistent object. this
+ * attribute is either a bean or a collection. This method is usefull if the
+ * corresponding descriptor has an autoRetrieve="false"
+ *
+ * @param object
+ * The persistent object
+ * @param attributeName
+ * The name of the attribute to retrieve
+ */
+ public void retrieveMappedAttribute(Object object, String attributeName);
+
+ /**
+ * Retrieve all mapped attributes for the given persistent object.
+ *
+ * @param object
+ * The persistent object
+ */
+ public void retrieveAllMappedAttributes(Object object);
+
+ /**
+ * Remove an object from a JCR repository
+ *
+ * @param path
+ * the object path
+ * @throws ObjectContentManagerException
+ * when it is not possible to remove the object
+ *
+ */
+ public void remove(String path) throws ObjectContentManagerException;
+
+ /**
+ * Remove an object from a JCR repository
+ *
+ * @param object
+ * the object to remove
+ * @throws ObjectContentManagerException
+ * when it is not possible to remove the object
+ *
+ */
+ public void remove(Object object) throws ObjectContentManagerException;
+
+ /**
+ * Remove all objects matching to a query
+ *
+ * @param query
+ * The query used to find the objects to remove
+ * @throws ObjectContentManagerException
+ * when it is not possible to remove all objects
+ *
+ */
+ public void remove(Query query) throws ObjectContentManagerException;
+
+ /**
+ * Retrieve an object matching to a query
+ *
+ * @param query
+ * The Query object used to seach the object
+ * @return The object found or null
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the object
+ *
+ */
+ public Object getObject(Query query) throws ObjectContentManagerException;
+
+ /**
+ * Retrieve some objects matching to a query
+ *
+ * @param query
+ * The query used to search the objects
+ * @return a collection of objects found
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the objects
+ *
+ */
+ public Collection getObjects(Query query)
+ throws ObjectContentManagerException;
+
+ /**
+ * Returns a list of objects (not supertypes) of that particular class which are associated to a specific path.
+ * This method is helpfull when same name sibling is used to create nodes.
+ * This would not return the objects anywhere below the denoted path.
+ *
+ * @param objectClass
+ * @param path Node path.
+ * @return a collection of object found and empty collection if there is no node for path or when objectClass is not mapped
+ */
+
+ public Collection getObjects(Class objectClass, String path)
+ throws ObjectContentManagerException;
+
+ /**
+ * Returns a list of objects (not supertypes) of that particular class which are child nodes of a specific path.
+ * This would not return the objects anywhere below the immediate children of the specified path.
+ *
+ * @param objectClass
+ * @param path Node path.
+ * @return a collection of object found and empty collection if there is no node for path or when objectClass is not mapped
+ */
+
+ public Collection getChildObjects(Class objectClass, String path)
+ throws ObjectContentManagerException;
+
+
+ /**
+ * Return a list of object matching to a JCR query
+ *
+ * @param query the JCR query
+ * @param language the JCR Language ("XPATH" or "SQL").
+ * @return
+ */
+ public Collection getObjects(String query, String language);
+
+ /**
+ * Retrieve some objects matching to a query.
+ *
+ * @param query
+ * The query used to seach the objects
+ * @return an iterator of objects found
+ * @throws ObjectContentManagerException
+ * when it is not possible to retrieve the objects
+ */
+ public Iterator getObjectIterator(Query query)
+ throws ObjectContentManagerException;
+
+ /**
+ * Retrieve an objects matching a query specified in a specific query
+ * language. This method is expected to call create a Query
+ * using the session's QueryManager with the given query
+ * exception and language parameters.
+ *
+ * If the query statement is syntactically invalid, given the
+ * language specified, an InvalidQueryException is thrown.
+ * The language must be a string from among those returned by
+ * javax.jcr.QueryManager.getSupportedQueryLanguages(); if
+ * it is not, then an InvalidQueryException is thrown.
+ *
+ * @param query
+ * The query to execute to find the objects.
+ * @param language
+ * The language in which the query is written
+ *
+ * @return An iterator of objects instances. Each entry in the iterator
+ * represents the mapping of a node returned by the query. If the
+ * query returns a node, which may not be mapped, the respective
+ * node is ignored.
+ *
+ * @throws org.apache.jackrabbit.ocm.exception.InvalidQueryException
+ * If the query is not a valid JCR Query according to the
+ * specified language
+ * @throws ObjectContentManagerException
+ * If an error occurrs querying for the objects.
+ *
+ * @see javax.jcr.query.QueryManager#createQuery(String, String)
+ * @see javax.jcr.query.QueryManager#getSupportedQueryLanguages()
+ */
+ public Iterator getObjectIterator(String query, String language);
+
+ /**
+ * Checkout - Create a new version This is only possible if the object is
+ * based on mix:versionable node type
+ *
+ * @param path
+ * The object path
+ * @throws VersionException
+ * when it is not possible to create a new version
+ */
+ public void checkout(String path) throws VersionException;
+
+ /**
+ * Checkin an object
+ *
+ * @param path
+ * the object path
+ * @throws VersionException
+ * when it is not possible to checkin
+ */
+ public void checkin(String path) throws VersionException;
+
+ /**
+ * Checkin an object and apply some labels to this new version Within a
+ * particular object path, a given label may appear a maximum of once
+ *
+ * @param path
+ * The object path
+ * @param versionLabels
+ * the version labels to apply to the new version
+ * @throws VersionException
+ * when it is possible to checkin
+ */
+ public void checkin(String path, String[] versionLabels)
+ throws VersionException;
+
+ /**
+ * Get all version labels assigned to a particular object version
+ *
+ * @param path
+ * the object path
+ * @param versionName
+ * the object version name (1.0, ...)
+ * @return a array of string (version labels)
+ * @throws VersionException
+ * when it is not to get all version labels
+ */
+ public String[] getVersionLabels(String path, String versionName)
+ throws VersionException;
+
+ /**
+ * Get all version labels assigned to all versions
+ *
+ * @param path
+ * the object path
+ * @return a array of string (version labels)
+ * @throws VersionException
+ * when it is not to get all version labels
+ */
+ public String[] getAllVersionLabels(String path) throws VersionException;
+
+ /**
+ * Add a new label to a particular version
+ *
+ * @param path
+ * the object path
+ * @param versionName
+ * the object versio name (1.0, 1.1, ...)
+ * @param versionLabel
+ * The new label to apply
+ * @throws VersionException
+ * when it is not possible to add a new version label to this
+ * version
+ */
+ public void addVersionLabel(String path, String versionName,
+ String versionLabel) throws VersionException;
+
+ /**
+ * Get all object versions
+ *
+ * @param path
+ * the object path
+ * @return a version iterator
+ * @throws VersionException
+ * when it is not possible to retrieve all versions
+ */
+ public VersionIterator getAllVersions(String path) throws VersionException;
+
+ /**
+ * Get the first object version
+ *
+ * @param path
+ * the object path
+ * @return the first version found
+ * @throws VersionException
+ * when it is not possible to get the root version
+ */
+ public Version getRootVersion(String path) throws VersionException;
+
+ /**
+ * Get the lastest object version
+ *
+ * @param path
+ * the object path
+ * @return the last version found
+ * @throws VersionException
+ * when it is not possible to get the last version
+ */
+ public Version getBaseVersion(String path) throws VersionException;
+
+ /**
+ * Get a particular version
+ *
+ * @param path
+ * the object path
+ * @param versionName
+ * the version name
+ * @return the version found or null
+ * @throws VersionException
+ * when it is not possible to retrieve this particular version
+ */
+ public Version getVersion(String path, String versionName)
+ throws VersionException;
+
+ /**
+ * Save all modifications made by the object content manager
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to save all pending operation into
+ * the JCR repo
+ */
+ public void save() throws ObjectContentManagerException;
+
+ /**
+ * Close the session
+ *
+ * @throws ObjectContentManagerException
+ * when it is not possible to logout
+ */
+ public void logout() throws ObjectContentManagerException;
+
+ /**
+ * Lock object saved on {@param path }.
+ *
+ * @param path
+ * path to saved object.
+ * @param isDeep
+ * is lock deep? See JCR spec: 8.4.3 Shallow and Deep Locks
+ * @param isSessionScoped
+ * is lock session scoped? See JCR spec: Session-scoped and
+ * Open-scoped Locks
+ * @return lock - Wrapper object for a JCR lock
+ *
+ * @throws LockedException
+ * if path is locked (cannot lock same path again)
+ */
+ public Lock lock(String path, boolean isDeep, boolean isSessionScoped)
+ throws LockedException;
+
+ /**
+ * Unlock object stored on {@param path }.
+ *
+ * @param path
+ * path to stored object
+ *
+ *
+ * @param lockToken
+ * see JCR spec: 8.4.6 Lock Token; can be null
+ *
+ * @throws IllegalUnlockException
+ * throws if the current operation does not own the current lock
+ */
+ public void unlock(String path, String lockToken)
+ throws IllegalUnlockException;
+
+ /**
+ * Is that path locked?
+ *
+ * @param absPath
+ * @return true if path locked
+ */
+ public boolean isLocked(String absPath);
+
+ /**
+ *
+ * @return The query manager reference
+ */
+ public QueryManager getQueryManager();
+
+ /**
+ * Refresh the underlying jcr session (see the jcr spec)
+ *
+ * @param keepChanges
+ */
+ public void refresh(boolean keepChanges);
+
+ /**
+ * Move an object
+ *
+ * @param srcPath
+ * path of the object to move
+ * @param destPath
+ * destination path
+ *
+ * @throws ObjectContentManagerException
+ */
+ public void move(String srcPath, String destPath)
+ throws ObjectContentManagerException;
+
+ /**
+ * Copy an object from scrPath to destPath. When there does not exist a node yet at
+ * destPath a new node will be created there if the parent {@link javax.jcr.Node} exists already. If
+ * the parent does not exist, an {@link ObjectContentManagerException} will be thrown
+ *
+ * If there already exists a node at destPath, we
+ * try to add the {@link javax.jcr.Node} from srcPath. If not possible, an {@link ObjectContentManagerException}
+ * will be thrown.
+ *
+ * @param srcPath
+ * path of the object to copy
+ * @param destPath
+ * destination path
+ *
+ * @throws ObjectContentManagerException when the copy did not succeed for example because there exists no {@link javax.jcr.Node} at
+ * srcPath the parent of destPath does not exist or there already exists an (incompatible) node at destPath
+ */
+ public void copy(String srcPath, String destPath)
+ throws ObjectContentManagerException;
+
+ /**
+ * This method returns the JCR session. The JCR session could be used to
+ * make some JCR specific calls.
+ *
+ * @return the associated JCR session
+ */
+ public Session getSession();
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverter.java
similarity index 54%
rename from src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java
rename to src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverter.java
index e52367d3..001be348 100644
--- a/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverter.java
@@ -1,10 +1,10 @@
/*
- * Copyright 2004-2005 The Apache Software Foundation or its licensors,
- * as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -15,54 +15,48 @@
* limitations under the License.
*/
-package org.apache.portals.graffito.jcr.persistence.atomictypeconverter;
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
/**
- *
+ *
* AtomicTypeConverter interface.
- *
+ *
* The Object converter used atomic type converters to map atomic fields to JCR Value objects.
* Amotic fields are primitive java types and their wrapper classes.
- *
- *
- * @author Christophe Lombart
*
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
*/
public interface AtomicTypeConverter
{
-
/**
* Convert an object into a JCR value.
- *
+ *
+ * @param valueFactory The JCR ValueFactory
* @param object The object to convert
* @return the corresponding JCR value
- *
+ *
*/
- public Value getValue(Object object);
+ public Value getValue(ValueFactory valueFactory, Object object);
/**
* Convert a jcr property value into an object
- *
+ *
* @param value The JCR property value
* @return the corresponding object
*/
public Object getObject(Value value);
/**
- * Get the string converted value
+ * Get the string converted value. This is mainly used to build xpath expressions
+ *
+ * @param valueFactory The JCR ValueFactory
* @param object The object value
- * @return The string converted value
+ * @return The string converted value
*/
- public String getStringValue(Object object);
-
- /**
- * Set the underlying ValueFactory to be used
- * when creating the Value.
- *
- * @param valueFactory javax.jcr.ValueFactory
- */
- public void setValueFactory(ValueFactory valueFactory);
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object);
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverterProvider.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverterProvider.java
new file mode 100644
index 00000000..e782f8ee
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/AtomicTypeConverterProvider.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter;
+
+
+import java.util.Map;
+
+/**
+ * This interface defines a provider for accessing
+ * {@link org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter}
+ *
+ * @author Alexandru Popescu
+ */
+public interface AtomicTypeConverterProvider {
+ /**
+ * Retrieves the AtomicTypeConverter associated with a class.
+ *
+ * @param clazz a class
+ * @return the corresponding AtomicTypeConverter or null
+ * if the class has no AtomicTypeConverter associated
+ */
+ AtomicTypeConverter getAtomicTypeConverter(Class clazz);
+
+ /**
+ * Returns a map of all registered AtomicTypeConverters.
+ *
+ * @return Map
+ */
+ Map getAtomicTypeConverters();
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/AtomicTypeConverterProviderImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/AtomicTypeConverterProviderImpl.java
new file mode 100644
index 00000000..cded2376
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/AtomicTypeConverterProviderImpl.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+
+
+/**
+ * Implementation of {@link AtomicTypeConverterProvider}.
+ *
+ * @author Alexandru Popescu
+ */
+public class AtomicTypeConverterProviderImpl implements AtomicTypeConverterProvider {
+ protected Map m_converters;
+ protected Map m_converterInstances = new HashMap();
+
+ /**
+ * No-arg constructor.
+ */
+ public AtomicTypeConverterProviderImpl() {
+ }
+
+ /**
+ * Full constructor.
+ *
+ * @param converters a map of classes and their associated AtomicTypeConverter
+ * classes.
+ */
+ public AtomicTypeConverterProviderImpl(Map converters) {
+ m_converters= converters;
+ }
+
+ /**
+ * Sets the associations of classes and their AtomicTypeConverter
+ * classes.
+ *
+ * @param converters Map
+ */
+ public void setAtomicTypeConvertors(Map converters) {
+ m_converters= converters;
+ }
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider#getAtomicTypeConverter(java.lang.Class)
+ */
+ public AtomicTypeConverter getAtomicTypeConverter(Class clazz) {
+ AtomicTypeConverter converter= (AtomicTypeConverter) m_converterInstances.get(clazz);
+ if(null != converter) {
+ return converter;
+ }
+ Class converterClass= (Class) m_converters.get(clazz);
+ if(null == converterClass) {
+ throw new IncorrectAtomicTypeException("No registered converter for a field based on the class :'" + clazz + "'");
+ }
+
+ try {
+ converter= (AtomicTypeConverter) converterClass.newInstance();
+ m_converterInstances.put(clazz, converter);
+ }
+ catch(Exception ex) {
+ throw new IncorrectAtomicTypeException(
+ "Cannot create converter instance from class '" + clazz + "'", ex);
+
+ }
+
+ return converter;
+ }
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider#getAtomicTypeConverters()
+ */
+ public Map getAtomicTypeConverters() {
+ Map result= new HashMap();
+ for(Iterator it= m_converters.keySet().iterator(); it.hasNext(); ) {
+ Class clazz= (Class) it.next();
+ result.put(clazz, getAtomicTypeConverter(clazz));
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BinaryTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BinaryTypeConverterImpl.java
new file mode 100644
index 00000000..742aeba0
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BinaryTypeConverterImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.io.InputStream;
+
+import javax.jcr.Binary;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Binary Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class BinaryTypeConverterImpl implements AtomicTypeConverter
+{
+
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+
+ Binary binaryvalue = null;
+ try {
+ binaryvalue = valueFactory.createBinary((InputStream) propValue);
+ } catch (RepositoryException ex) {
+ throw new IncorrectAtomicTypeException("Impossible to create binary value from stream!", ex);
+ }
+ if (binaryvalue == null) {
+ return null;
+ }
+
+ return valueFactory.createValue(binaryvalue);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return value.getBinary().getStream();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString() , e);
+ }
+ }
+
+ public String getXPathQueryValue(ValueFactory valueFactory,Object object)
+ {
+ throw new IncorrectAtomicTypeException("Binary cannot be used in queries");
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BooleanTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BooleanTypeConverterImpl.java
new file mode 100644
index 00000000..ccb11268
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/BooleanTypeConverterImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Boolean Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class BooleanTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ boolean value = ((Boolean) propValue).booleanValue();
+ return valueFactory.createValue(value);
+ }
+
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return new Boolean(value.getBoolean());
+ }
+ catch (Exception e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString() , e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory,Object object)
+ {
+ return ((Boolean) object).booleanValue() ? "true()" : "false()";
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
new file mode 100644
index 00000000..25375f9e
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Byte Array Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class ByteArrayTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ InputStream ins = new ByteArrayInputStream((byte[]) propValue);
+ return new BinaryTypeConverterImpl().getValue(valueFactory, ins);
+ }
+
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return inputStreamToBytes(value.getBinary().getStream());
+ }
+ catch (Exception e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert a binary value." , e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ throw new IncorrectAtomicTypeException("Binary cannot be used in queries");
+ }
+
+ private byte[] inputStreamToBytes(InputStream in) throws IOException {
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+ byte[] buffer = new byte[1024];
+ int len;
+
+ while((len = in.read(buffer)) >= 0)
+ out.write(buffer, 0, len);
+
+ in.close();
+ out.close();
+ return out.toByteArray();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/CalendarTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/CalendarTypeConverterImpl.java
new file mode 100644
index 00000000..75baae8c
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/CalendarTypeConverterImpl.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.util.Calendar;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Calendar Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class CalendarTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+
+ return valueFactory.createValue(((Calendar) propValue).getTimeInMillis());
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(value.getLong());
+ return calendar;
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ Calendar calendar = (Calendar) object;
+ return new Long(calendar.getTimeInMillis()).toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/Date2LongTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/Date2LongTypeConverterImpl.java
new file mode 100644
index 00000000..0e68186f
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/Date2LongTypeConverterImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.util.Date;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Util Date Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class Date2LongTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ return valueFactory.createValue(((java.util.Date) propValue).getTime());
+ }
+
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ long time = value.getLong();
+ return new Date(time);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return new Long(((java.util.Date) object).getTime()).toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DefaultAtomicTypeConverterProvider.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DefaultAtomicTypeConverterProvider.java
new file mode 100644
index 00000000..53081819
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DefaultAtomicTypeConverterProvider.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * An AtomicTypeConverterProvider that registers by default the
+ * convertes available in OCM.
+ *
+ * @author Alexandru Popescu
+ */
+public class DefaultAtomicTypeConverterProvider extends AtomicTypeConverterProviderImpl {
+ /**
+ * No-arg constructor.
+ */
+ public DefaultAtomicTypeConverterProvider() {
+ m_converters= registerDefaultAtomicTypeConverters();
+ }
+
+ /**
+ * Full constructor.
+ *
+ * @param converters a map of classes and their associated AtomicTypeConverter
+ * classes.
+ */
+ public DefaultAtomicTypeConverterProvider(Map converters) {
+ this();
+ m_converters.putAll(converters);
+ }
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.AtomicTypeConverterProviderImpl#setAtomicTypeConvertors(java.util.Map)
+ */
+ public void setAtomicTypeConvertors(Map converters) {
+ m_converters.putAll(converters);
+ }
+
+ protected Map registerDefaultAtomicTypeConverters() {
+ Map converters= new HashMap();
+
+ converters.put(String.class, StringTypeConverterImpl.class);
+ converters.put(InputStream.class, BinaryTypeConverterImpl.class);
+ converters.put(long.class, LongTypeConverterImpl.class);
+ converters.put(Long.class, LongTypeConverterImpl.class);
+ converters.put(int.class, IntTypeConverterImpl.class);
+ converters.put(Integer.class, IntTypeConverterImpl.class);
+ converters.put(double.class, DoubleTypeConverterImpl.class);
+ converters.put(Double.class, DoubleTypeConverterImpl.class);
+ converters.put(boolean.class, BooleanTypeConverterImpl.class);
+ converters.put(Boolean.class, BooleanTypeConverterImpl.class);
+ converters.put(Calendar.class, CalendarTypeConverterImpl.class);
+ converters.put(GregorianCalendar.class, CalendarTypeConverterImpl.class);
+ converters.put(Date.class, UtilDateTypeConverterImpl.class);
+ converters.put(byte[].class, ByteArrayTypeConverterImpl.class);
+ converters.put(Timestamp.class, TimestampTypeConverterImpl.class);
+
+ return converters;
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DoubleTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DoubleTypeConverterImpl.java
new file mode 100644
index 00000000..393913e0
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/DoubleTypeConverterImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Double Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class DoubleTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+
+ double value = ((Double) propValue).doubleValue();
+ return valueFactory.createValue(value);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ double beanPropValue = value.getDouble();
+ return new Double(beanPropValue);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return object.toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/IntTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/IntTypeConverterImpl.java
new file mode 100644
index 00000000..e5199e5a
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/IntTypeConverterImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Int Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class IntTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ long value = ((Integer) propValue).intValue();
+ return valueFactory.createValue(value);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ int beanPropValue = (int) value.getLong();
+ return new Integer(beanPropValue);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return object.toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/LongTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/LongTypeConverterImpl.java
new file mode 100644
index 00000000..89fcf5f1
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/LongTypeConverterImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Long Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class LongTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+
+ long value = ((Long) propValue).longValue();
+ return valueFactory.createValue(value);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ long beanPropValue = value.getLong();
+ return new Long(beanPropValue);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return object.toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NameTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NameTypeConverterImpl.java
new file mode 100644
index 00000000..fbc4c47c
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NameTypeConverterImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Name Type Converter
+ *
+ * @author Christophe Lombart
+ *
+ */
+public class NameTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ try
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ return valueFactory.createValue((String) propValue, PropertyType.NAME);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + propValue.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return value.getString();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return "'" + object.toString() + "'";
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NullTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NullTypeConverterImpl.java
new file mode 100644
index 00000000..33a08af5
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/NullTypeConverterImpl.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Double Type Converter
+ *
+ * @author Alexandru Popescu
+ */
+public class NullTypeConverterImpl implements AtomicTypeConverter {
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object) {
+ return null;
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/PathTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/PathTypeConverterImpl.java
new file mode 100644
index 00000000..d36a07a2
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/PathTypeConverterImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Name Type Converter
+ *
+ * @author Christophe Lombart
+ *
+ */
+public class PathTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ try
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ return valueFactory.createValue((String) propValue, PropertyType.PATH);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value into a path property : " + propValue.toString() + ". Check if it is a valid path.", e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return value.getString();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the path into a string", e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return "'" + object.toString() + "'";
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ReferenceTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ReferenceTypeConverterImpl.java
new file mode 100644
index 00000000..9d218387
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/ReferenceTypeConverterImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Reference Type Converter(java string attribute into a JCR property based on the REFERENCE type)
+ *
+ *
+ * @author Christophe Lombart
+ *
+ */
+public class ReferenceTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ try
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ return valueFactory.createValue((String) propValue, PropertyType.REFERENCE);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value into a reference property : " + propValue.toString() + ". Check if it is a correct uuid", e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return value.getString();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the uuid into a string ", e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return "'" + object.toString() + "'";
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/StringTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/StringTypeConverterImpl.java
new file mode 100644
index 00000000..9242e68f
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/StringTypeConverterImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * String Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class StringTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ return valueFactory.createValue((String) propValue);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ return value.getString();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return "'" + object.toString() + "'";
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/TimestampTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/TimestampTypeConverterImpl.java
new file mode 100644
index 00000000..f624daac
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/TimestampTypeConverterImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.sql.Timestamp;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Timestamp Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class TimestampTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ return null;
+ long value = ((Timestamp) propValue).getTime();
+ return valueFactory.createValue(value);
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ long beanPropValue = value.getLong();
+ return new Timestamp(beanPropValue);
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return new Long(((Timestamp) object).getTime()).toString();
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UndefinedTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UndefinedTypeConverterImpl.java
new file mode 100644
index 00000000..88e83069
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UndefinedTypeConverterImpl.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ *
+ * Undefined Type Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ * @author : Boni Gopalan
+ */
+public class UndefinedTypeConverterImpl implements AtomicTypeConverter
+{
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+
+
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+
+ if (propValue == null)
+ {
+ return null;
+ }
+
+ if (propValue instanceof String )
+ {
+ return valueFactory.createValue((String) propValue);
+ }
+
+ if (propValue instanceof InputStream)
+ {
+ return new BinaryTypeConverterImpl().getValue(valueFactory, propValue);
+ }
+
+ if ((propValue instanceof Long || propValue instanceof Integer))
+ {
+ return valueFactory.createValue(((Number) propValue).longValue());
+ }
+
+ if (propValue instanceof Double )
+ {
+ return valueFactory.createValue(((Double) propValue).doubleValue());
+ }
+
+ if (propValue instanceof Boolean )
+ {
+ return valueFactory.createValue(((Boolean) propValue).booleanValue());
+ }
+
+ if (propValue instanceof Calendar )
+ {
+
+ return valueFactory.createValue((Calendar) propValue);
+ }
+
+ if (propValue instanceof GregorianCalendar )
+ {
+ return valueFactory.createValue((GregorianCalendar) propValue);
+ }
+
+
+ if (propValue instanceof Date )
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date) propValue);
+ return valueFactory.createValue(calendar);
+ }
+
+ throw new IncorrectAtomicTypeException("Impossible to convert the value - property type not found");
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+
+ if (value.getType() == PropertyType.STRING )
+ {
+ return value.getString();
+ }
+
+ if (value.getType() == PropertyType.DATE)
+ {
+ return value.getDate();
+ }
+
+ if (value.getType() == PropertyType.BINARY)
+ {
+ return value.getBinary().getStream();
+ }
+
+ if (value.getType() == PropertyType.DOUBLE)
+ {
+ return new Double(value.getDouble());
+ }
+
+ if (value.getType() == PropertyType.LONG)
+ {
+ return new Long(value.getLong());
+ }
+
+ if (value.getType() == PropertyType.BOOLEAN)
+ {
+ return new Boolean(value.getBoolean());
+ }
+
+ if (value.getType() == PropertyType.NAME)
+ {
+ return value.getString();
+ }
+
+ if (value.getType() == PropertyType.PATH)
+ {
+ return value.getString();
+ }
+
+ if (value.getType() == PropertyType.REFERENCE || value.getType() == PropertyType.WEAKREFERENCE)
+ {
+ return value.getString();
+ }
+
+ throw new IncorrectAtomicTypeException("Impossible to create the value object - unsupported class");
+
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ return "'" + object.toString() + "'";
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UtilDateTypeConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
new file mode 100644
index 00000000..766a362b
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.jackrabbit.ocm.exception.IncorrectAtomicTypeException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Util Date Converter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public class UtilDateTypeConverterImpl implements AtomicTypeConverter
+{
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+ */
+ public Value getValue(ValueFactory valueFactory, Object propValue)
+ {
+ if (propValue == null)
+ {
+ return null;
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime((Date) propValue);
+ return valueFactory.createValue(calendar);
+ }
+
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
+ */
+ public Object getObject(Value value)
+ {
+ try
+ {
+ Calendar calendar = value.getDate();
+ return calendar.getTime();
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
+ }
+
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
+ */
+ public String getXPathQueryValue(ValueFactory valueFactory, Object object)
+ {
+ try
+ {
+ Calendar calendar = Calendar.getInstance();
+
+ calendar.setTime((Date) object);
+
+ return "xs:dateTime('" + valueFactory.createValue(calendar).getString() + "')";
+
+ }
+ catch (RepositoryException e)
+ {
+ throw new IncorrectAtomicTypeException("Impossible to get the sting value ", e);
+ }
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/BeanConverter.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/BeanConverter.java
new file mode 100644
index 00000000..6ef45f34
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/BeanConverter.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter;
+
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.beanconverter.impl.ParentBeanConverterImpl;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+
+/**
+ * Interface describing a custom bean converter.
+ *
+ * @author Alexandru Popescu
+ */
+public interface BeanConverter {
+
+
+ /**
+ * Insert the object.
+ *
+ * @param session the JCR session
+ * @param parentNode The node which will contain the converter bean
+ * @param beanDescriptor The bean descriptor
+ * @param beanClassDescriptor the Class Descriptor associated to the bean to insert
+ * @param bean the bean to convert( insert into the JCR structure)
+ * @param parentClassDescriptor The Class Descriptor associated to the parent object
+ * @param parent the object which will contain the bean to convert
+ *
+ * @throws ObjectContentManagerException thrown in case the insert fails; marks a failure due to logic of
+ * the insert (parent node cannot be accessed, the insert fails, etc.)
+ * @throws RepositoryException thrown in case the underlying repository has thrown a
+ * javax.jcr.RepositoryException that is not possible to be handled or
+ * wrapped in ObjectContentManagerException; marks a repository failure
+ * @throws JcrMappingException throws in case the mapping of the bean is not correct
+ */
+ void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object bean, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+ /**
+ * Update repository from bean values.
+ *
+ * @param session the JCR session
+ * @param parentNode The node which will contain the converter bean
+ * @param beanDescriptor The bean descriptor
+ * @param beanClassDescriptor the Class Descriptor associated to the bean to update
+ * @param bean the bean to convert( insert into the JCR structure)
+ * @param parentClassDescriptor The Class Descriptor associated to the parent object
+ * @param parent the object which will contain the bean to convert
+ *
+ * @throws ObjectContentManagerException thrown in case the update fails; marks a failure due to logic
+ * of update (parent node cannot be accessed, the update fails, etc.)
+ * @throws RepositoryException thrown in case the underlying repository has thrown a
+ * javax.jcr.RepositoryException that is not possible to be handled or
+ * wrapped in ObjectContentManagerException; marks a repository failure
+ * @throws JcrMappingException throws in case the mapping of the bean is not correct
+ */
+ void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object bean, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+ /**
+ * Retrieve a bean from the repository.
+ *
+ * @param session the JCR session
+ * @param parentNode The parent node
+ * @param beanDescriptor The bean descriptor
+ * @param beanClassDescriptor the Class Descriptor associated to the bean to insert
+ * @param beanClass The bean Class
+ * @param parent The parent which contain the bean to retrieve
+ *
+ * @throws ObjectContentManagerException thrown in case the bean cannot be retrieved or initialized;
+ * marks a failure due to logic of retrieval
+ * @throws RepositoryException thrown in case the underlying repository has thrown a
+ * javax.jcr.RepositoryException that is not possible to be handled or
+ * wrapped in ObjectContentManagerException; marks a repository failure
+ * @throws JcrMappingException throws in case the mapping of the bean is not correct
+ */
+ Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+
+ /**
+ * Remove the bean from the repository.
+ *
+ * @param session the JCR session
+ * @param parentNode The node which will contain the converter bean
+ * @param beanDescriptor The bean descriptor
+ * @param beanClassDescriptor the Class Descriptor associated to the bean to update
+ * @param bean the bean to convert( insert into the JCR structure)
+ * @param parentClassDescriptor The Class Descriptor associated to the parent object
+ * @param parent the object which contains the bean to convert
+ *
+ * @throws ObjectContentManagerException thrown in case the bean cannot be removed;
+ * marks a failure due to logic of removal
+ * @throws RepositoryException thrown in case the underlying repository has thrown a
+ * javax.jcr.RepositoryException that is not possible to be handled or
+ * wrapped in ObjectContentManagerException; marks a repository failure
+ * @throws JcrMappingException throws in case the mapping of the bean is not correct
+ */
+ void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object bean, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+ /**
+ * Get the bean path.
+ *
+ * When the bean is mapped to a subnode, the bean path is the parent node path + the jcrname of the current bean.
+ * Sometime a BeanConverter can be used to access to a bean which is not mapped to a subnode. In this case,
+ * another implementation can be provided in this method getPath. {@link ParentBeanConverterImpl} is a good example.
+ *
+ * @param session the JCR session
+ * @param beanDescriptor The descriptor of the bean to convert
+ * @param parentNode the node which contain this bean (its corresponfing subnode)
+ * @return the bean path
+ *
+ * @throws RepositoryException thrown in case the underlying repository has thrown a
+ * javax.jcr.RepositoryException that is not possible to be handled or
+ * wrapped in ObjectContentManagerException; marks a repository failure
+ *
+ */
+ String getPath(Session session, BeanDescriptor beanDescriptor, Node parentNode)
+ throws ObjectContentManagerException;
+
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/AbstractBeanConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/AbstractBeanConverterImpl.java
new file mode 100644
index 00000000..59d32ea7
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/AbstractBeanConverterImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+import org.apache.jackrabbit.ocm.manager.beanconverter.BeanConverter;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerUtil;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+/**
+ *
+ * Abstract Bean Converter Class
+ *
+ * @author Lombart Christophe
+ *
+ */
+public abstract class AbstractBeanConverterImpl implements BeanConverter {
+
+ protected ObjectConverter objectConverter;
+ protected Mapper mapper;
+ protected AtomicTypeConverterProvider atomicTypeConverterProvider;
+
+ public AbstractBeanConverterImpl(Mapper mapper, ObjectConverter objectConverter, AtomicTypeConverterProvider atomicTypeConverterProvider)
+ {
+ this.mapper = mapper;
+ this.objectConverter = objectConverter;
+ this.atomicTypeConverterProvider = atomicTypeConverterProvider;
+ }
+
+ /**
+ *
+ * Default implementation for many BeanConverter. This method can be overridden in specific BeanConverter
+ *
+ */
+ public String getPath(Session session, BeanDescriptor beanDescriptor, Node parentNode)
+ throws ObjectContentManagerException
+ {
+ return ObjectContentManagerUtil.getPath(session, beanDescriptor, parentNode);
+ }
+
+ public abstract void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+ public abstract void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException;
+
+ public abstract Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object parent)
+ throws ObjectContentManagerException, RepositoryException,JcrMappingException ;
+
+ public abstract void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException ;
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/DefaultBeanConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/DefaultBeanConverterImpl.java
new file mode 100644
index 00000000..1395173e
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/DefaultBeanConverterImpl.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+import org.apache.jackrabbit.ocm.manager.beanconverter.BeanConverter;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Default Bean Converter
+ *
+ *
+ * @author Lombart Christophe
+ *
+ */
+public class DefaultBeanConverterImpl extends AbstractBeanConverterImpl implements BeanConverter {
+
+ private final static Logger log = LoggerFactory.getLogger(DefaultBeanConverterImpl.class);
+
+ public DefaultBeanConverterImpl(Mapper mapper, ObjectConverter objectConverter, AtomicTypeConverterProvider atomicTypeConverterProvider)
+ {
+ super(mapper, objectConverter, atomicTypeConverterProvider);
+ }
+
+ public void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ objectConverter.insert(session, parentNode, beanDescriptor.getJcrName(), object);
+ }
+
+ public void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ try
+ {
+ String jcrNodeName = beanDescriptor.getJcrName();
+ if (parentNode.hasNode(jcrNodeName))
+ {
+ objectConverter.update(session, parentNode, beanDescriptor.getJcrName() , object);
+ }
+ else
+ {
+ objectConverter.insert(session, parentNode, beanDescriptor.getJcrName() , object);
+ }
+ }
+ catch (javax.jcr.RepositoryException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object parent)
+ throws ObjectContentManagerException, RepositoryException,JcrMappingException
+ {
+ return objectConverter.getObject(session, beanClass, this.getPath(session, beanDescriptor, parentNode));
+
+ }
+
+ public void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ try {
+ if (parentNode.hasNode(beanDescriptor.getJcrName()))
+ {
+ parentNode.getNode(beanDescriptor.getJcrName()).remove();
+ }
+
+ } catch (javax.jcr.RepositoryException e) {
+
+ throw new RepositoryException(e);
+ }
+
+ }
+
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/InlineBeanConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/InlineBeanConverterImpl.java
new file mode 100644
index 00000000..10c004a3
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/InlineBeanConverterImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+import org.apache.jackrabbit.ocm.manager.beanconverter.BeanConverter;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.manager.objectconverter.impl.SimpleFieldsHelper;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+/**
+ *
+ * Bean converter used to map some node properties into one nested bean field.
+ * The corresponding bean field is not associated to a subnode.
+ *
+ * @author Lombart Christophe
+ *
+ */
+public class InlineBeanConverterImpl extends AbstractBeanConverterImpl implements BeanConverter {
+
+ SimpleFieldsHelper simpleFieldsHelper;
+
+ public InlineBeanConverterImpl(Mapper mapper, ObjectConverter objectConverter, AtomicTypeConverterProvider atomicTypeConverterProvider)
+ {
+ super(mapper, objectConverter, atomicTypeConverterProvider);
+ this.simpleFieldsHelper = new SimpleFieldsHelper(atomicTypeConverterProvider);
+ }
+
+ public void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+
+ simpleFieldsHelper.storeSimpleFields(session, object, beanClassDescriptor, parentNode);
+ }
+
+ public void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+ simpleFieldsHelper.storeSimpleFields(session, object, beanClassDescriptor, parentNode);
+ }
+
+ public Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object bean)
+ throws ObjectContentManagerException, RepositoryException,JcrMappingException {
+
+ return simpleFieldsHelper.retrieveSimpleFields(session, beanClassDescriptor, parentNode, bean);
+
+ }
+
+ public void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+
+ simpleFieldsHelper.storeSimpleFields(session, object, beanClassDescriptor, parentNode);
+ }
+
+
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ParentBeanConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ParentBeanConverterImpl.java
new file mode 100644
index 00000000..b2af9dfb
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ParentBeanConverterImpl.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+import org.apache.jackrabbit.ocm.manager.beanconverter.BeanConverter;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Bean converter used to access to the parent object.
+ * the mixin type referenceable is not mandatory for the node matching to the parent object.
+ *
+ *
+ * @author Lombart Christophe
+ *
+ */
+public class ParentBeanConverterImpl extends AbstractBeanConverterImpl implements BeanConverter {
+
+ private final static Logger log = LoggerFactory.getLogger(ParentBeanConverterImpl.class);
+
+ public ParentBeanConverterImpl(Mapper mapper, ObjectConverter objectConverter, AtomicTypeConverterProvider atomicTypeConverterProvider)
+ {
+ super(mapper, objectConverter, atomicTypeConverterProvider);
+ }
+
+ public void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+ }
+
+ public void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+ }
+
+ public Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object parent)
+ throws ObjectContentManagerException, RepositoryException,JcrMappingException {
+ try
+ {
+ Node grandParentNode = parentNode.getParent();
+ if (grandParentNode.getPath().equals("/"))
+ {
+ return null;
+ }
+ return objectConverter.getObject(session, grandParentNode.getPath());
+
+ }
+ catch (javax.jcr.RepositoryException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ }
+
+ public void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException {
+
+ }
+
+ /**
+ *
+ * Default implementation for many BeanConverter. This method can be overridden in specific BeanConverter
+ *
+ */
+ public String getPath(Session session, BeanDescriptor beanDescriptor, Node parentNode)
+ throws ObjectContentManagerException
+ {
+ try
+ {
+ if (parentNode != null)
+ {
+
+ return parentNode.getParent().getPath();
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (javax.jcr.RepositoryException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ReferenceBeanConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ReferenceBeanConverterImpl.java
new file mode 100644
index 00000000..8bfdb71b
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/beanconverter/impl/ReferenceBeanConverterImpl.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.beanconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.PropertyType;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
+import org.apache.jackrabbit.ocm.manager.beanconverter.BeanConverter;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Map a bean attribute into a reference jcr property. It is not possible to update direclty the referenced bean.
+ * Only the corresponding uuid can be updated in the main object. The modifications on the referenced bean attributes are ignored
+ *
+ *
+ * @author Lombart Christophe
+ *
+ */
+public class ReferenceBeanConverterImpl extends AbstractBeanConverterImpl implements BeanConverter {
+
+ private final static Logger log = LoggerFactory.getLogger(ReferenceBeanConverterImpl.class);
+
+ public ReferenceBeanConverterImpl(Mapper mapper, ObjectConverter objectConverter, AtomicTypeConverterProvider atomicTypeConverterProvider)
+ {
+ super(mapper, objectConverter, atomicTypeConverterProvider);
+ }
+
+ public void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ updateReferenceProperty(parentNode, beanDescriptor, beanClassDescriptor, object);
+
+ }
+
+ public void update(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ updateReferenceProperty(parentNode, beanDescriptor, beanClassDescriptor, object);
+ }
+
+ public Object getObject(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Class beanClass, Object parent)
+ throws ObjectContentManagerException, RepositoryException,JcrMappingException
+ {
+ try {
+ String uuid = parentNode.getProperty(beanDescriptor.getJcrName()).getString();
+ String path = session.getNodeByIdentifier(uuid).getPath();
+
+ return objectConverter.getObject(session, path);
+ } catch (Exception e) {
+ return null;
+
+ }
+
+ }
+
+ public void remove(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
+ throws ObjectContentManagerException, RepositoryException, JcrMappingException
+ {
+ updateReferenceProperty(parentNode, beanDescriptor, beanClassDescriptor, null);
+ }
+
+ private void updateReferenceProperty(Node parentNode, BeanDescriptor beanDescriptor,ClassDescriptor beanClassDescriptor, Object object) {
+ try {
+ if (object == null)
+ {
+ parentNode.setProperty(beanDescriptor.getJcrName(), (Value) null);
+ }
+
+ FieldDescriptor fieldDescriptor = beanClassDescriptor.getUuidFieldDescriptor();
+ if (fieldDescriptor == null)
+ {
+ throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : " + beanClassDescriptor.getClassName());
+ }
+
+ String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
+ parentNode.setProperty(beanDescriptor.getJcrName(), uuid, PropertyType.REFERENCE);
+ } catch (Exception e) {
+ throw new ObjectContentManagerException("Impossible to insert the bean attribute into the repository", e);
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/cache/ObjectCache.java b/src/main/java/org/apache/jackrabbit/ocm/manager/cache/ObjectCache.java
new file mode 100644
index 00000000..5ec20ce1
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/cache/ObjectCache.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.cache;
+
+/**
+ *
+ *
+ * Interface use for an object cache.
+ *
+ * @author Lombart Christophe
+ *
+ */
+public interface ObjectCache {
+
+ /**
+ * Put an object to current session's object cache
+ *
+ * @param path Path to object
+ * @param object Cached object
+ */
+ void cache(String path, Object object);
+
+ /**
+ * Clear current session's object cache
+ */
+ void clear();
+
+ /**
+ * Check for object presence in the current session's object cache If the object is not in the current session's
+ * object cache, it is copied to current session's object cache from the global object cache.
+ *
+ * @param path Path to object
+ * @return true if the object is present in the current session's object cache
+ */
+ boolean isCached(String path);
+
+ /**
+ * Get the object from the current session's object cache. If the object is not in the current session's object
+ * cache, it is copied to current session's object cache from the global object cache.
+ *
+ * @param path Path to object
+ * @return Object (perhaps partially loaded), or null otherwise
+ */
+ Object getObject(String path);
+
+ /**
+ * Remove an object from the current session's object cache. Also remove the object and all its subobjects from the
+ * global object cache.
+ *
+ * @param path Path to object
+ */
+ void evict(String path);
+
+ /**
+ * Transfer a fully loaded object into the global object cache.
+ *
+ * @param path Path to object
+ * @param object A fully loaded object
+ */
+ void ready(String path, Object object);
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/cache/impl/RequestObjectCacheImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/cache/impl/RequestObjectCacheImpl.java
new file mode 100644
index 00000000..34dc4a58
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/cache/impl/RequestObjectCacheImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.cache.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jackrabbit.ocm.manager.cache.ObjectCache;
+
+/**
+ *
+ * This is a simple cache implementation that can be used per retrieve requests.
+ * This avoids to load duplicated object instance.
+ *
+ * @author Lombart Christophe
+ *
+*/
+public class RequestObjectCacheImpl implements ObjectCache {
+
+ private final Map alreadyCachedObjects = new HashMap();
+
+ public void cache(String path, Object object) {
+ alreadyCachedObjects.put(path, object);
+ }
+
+ public void clear() {
+ alreadyCachedObjects.clear();
+ }
+
+ public boolean isCached(String path) {
+ return alreadyCachedObjects.containsKey(path);
+ }
+
+ public Object getObject(String path) {
+ return alreadyCachedObjects.get(path);
+ }
+
+ public void evict(String path) {
+ alreadyCachedObjects.remove(path);
+ }
+
+ public void ready(String path, Object object) {
+ /* noop - no global cache */
+ }
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/CollectionConverter.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/CollectionConverter.java
new file mode 100644
index 00000000..28f686e3
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/CollectionConverter.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
+
+/**
+ * Convert any kind of {@link ManageableObjects} into severals JCR nodes.
+ *
+ * @author Lombart Christophe
+ *
+ */
+public interface CollectionConverter
+{
+
+ /**
+ * Insert/convert collection elements (a Collection or a Map) into some JCR nodes
+ * @param session The JCR session
+ * @param parentNode the node which will contains the collection element
+ * @param collectionDescriptor The collection descriptor
+ * @param objects The objects to insert
+ *
+ * @throws ObjectContentManagerException when it is not possible to insert the collection
+ *
+ */
+ public void insertCollection(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor, ManageableObjects objects) throws ObjectContentManagerException;
+
+ /**
+ * Update collection elements (a Collection or a Map) already present in the JCR repository
+ * @param session The JCR session
+ * @param parentNode the node which will contains the collection element
+ * @param collectionDescriptor The collection descriptor
+ * @param objects The objects to update
+ *
+ * @throws ObjectContentManagerException when it is not possible to update the collection
+ */
+ public void updateCollection(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor, ManageableObjects objects) throws ObjectContentManagerException;
+
+ /**
+ * Get a {@link ManageableObjects} from the JCR repository
+ * @param session The JCR session
+ * @param parentNode the node which contains the collection element
+ * @param collectionDescriptor The collection descriptor
+ * @param collectionFieldClass The collection class to used (ArrayList, Vector, ..)
+ * @return The collection or a map populates with all elements found in the JCR repository
+ *
+ * @throws ObjectContentManagerException when it is not possible to retrieve the collection
+ */
+ public ManageableObjects getCollection(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor, Class collectionFieldClass) throws ObjectContentManagerException;
+
+
+ /**
+ * Check if the collection is null. This method is mainly used in the Proxy manager to return a null value or a proxy object
+ * Without proxy proxy, this method is never called.
+ *
+ * @param session The JCR session
+ * @param parentNode the node which contains the collection element
+ * @param collectionDescriptor The collection descriptor
+ * @param collectionFieldClass The collection class to used (ArrayList, Vector, ..)
+ * @return true if the collection contains elements.
+ *
+ *
+ * @throws ObjectContentManagerException when it is not possible to retrieve the collection
+ */
+ public boolean isNull(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor, Class collectionFieldClass) throws ObjectContentManagerException;
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableCollection.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableCollection.java
new file mode 100644
index 00000000..fb78161f
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableCollection.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+
+/**
+ * Common interface used to persist any kind of Collection.
+ *
+ *
+ * @author Christophe Lombart
+ *
+ */
+public interface ManageableCollection extends ManageableObjects
+{
+ /**
+ * Add an object into this ManageableCollection
+ * @param object the object to add
+ */
+ public void addObject(Object object);
+
+
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableMap.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableMap.java
new file mode 100644
index 00000000..fbd7572c
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableMap.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+
+/**
+ * Common interface used to persist any kind of Map.
+ *
+ *
+ * @author Christophe Lombart
+ *
+ */
+public interface ManageableMap extends ManageableObjects
+{
+ /**
+ * Add an object into this ManageableMap
+ * @param key the object key
+ * @param object the object to add
+ */
+ public void addObject(Object key, Object object);
+
+
+}
diff --git a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollection.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java
similarity index 52%
rename from src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollection.java
rename to src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java
index d64ea528..77e1c109 100644
--- a/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/ManageableCollection.java
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java
@@ -1,47 +1,46 @@
/*
- * Copyright 2000-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package org.apache.portals.graffito.jcr.persistence.collectionconverter;
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
import java.util.Iterator;
-/**
+/**
* Common interface used to persist any kind of Collection or Map.
- *
+ *
*
* @author Christophe Lombart
- *
+ *
*/
-public interface ManageableCollection
+public interface ManageableObjects
{
- /**
- * Add an object into this ManageableCollection
- * @param object the object to add
- */
- public void addObject(Object object);
-
/**
* @return The ManageableCollection iterator
*/
public Iterator getIterator();
-
- /**
+
+ /**
* @return The ManageableCollection size
*/
public int getSize();
-
-
+
+ /**
+ * @return The objects managed by the underlying Collection or Map
+ */
+ public Object getObjects();
+
+
}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java
new file mode 100644
index 00000000..8a087206
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter;
+
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableCollectionImpl;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableMapImpl;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
+
+/**
+ * Utility class used to instantiate {@link ManageableObjects}
+ * A ManageableObjects is a Collection or a Map
+ *
+ * @author Christophe Lombart
+ *
+ */
+public class ManageableObjectsUtil {
+
+ /**
+ * Instantiate a new {@link ManageableObjects}
+ * @param manageableObjectsClassName The manageable objects class name
+ * @return an emtpy created {@link ManageableObjects}
+ */
+ public static ManageableObjects getManageableObjects(String manageableObjectsClassName) {
+ try {
+ return (ManageableObjects) ReflectionUtils.newInstance(manageableObjectsClassName);
+ }
+ catch (Exception e) {
+ throw new JcrMappingException("Cannot create manageable collection : "
+ + manageableObjectsClassName,
+ e);
+ }
+ }
+
+ /**
+ * Instantiate a new {@link ManageableObjects}
+ * @param manageableObjectsClass the collection class name
+ * @return an emtpy created {@link ManageableCollection}
+ */
+
+ public static ManageableObjects getManageableObjects(Class manageableObjectsClass) {
+ try {
+
+ // if the class is an interface, try to find the default class implementation
+ if (manageableObjectsClass.isInterface())
+ {
+
+ Class defaultImplementation = ReflectionUtils.getDefaultImplementation(manageableObjectsClass);
+ if (defaultImplementation == null)
+ {
+ throw new JcrMappingException("No default implementation for the interface " + manageableObjectsClass);
+ }
+ else
+ {
+ manageableObjectsClass = defaultImplementation;
+ }
+ }
+
+ //if the class is implementing the Collection interface
+ if (ReflectionUtils.implementsInterface(manageableObjectsClass, Collection.class))
+ {
+ return new ManageableCollectionImpl((Collection) ReflectionUtils.newInstance(manageableObjectsClass));
+ }
+
+ //if the class is implementing the Map interface
+ if (ReflectionUtils.implementsInterface(manageableObjectsClass, Map.class))
+ {
+ return new ManageableMapImpl((Map) ReflectionUtils.newInstance(manageableObjectsClass));
+ }
+
+
+ Object manageableObjects = manageableObjectsClass.newInstance();
+ if (!(manageableObjects instanceof ManageableObjects)) {
+ throw new JcrMappingException("Unsupported collection type :"
+ + manageableObjectsClass.getName());
+ }
+ else {
+ return (ManageableObjects) manageableObjects;
+ }
+ }
+ catch (Exception e) {
+ throw new JcrMappingException("Cannot create manageable objects (Collection or Map)", e);
+ }
+ }
+
+ /**
+ * Convert a java Collection or a Map into a {@link ManageableObjects}.
+ *
+ * The elements of a Map should have an ID field (see the field descriptor definition).
+ * @param object the collection or the Map objet
+ * @return The converted {@link ManageableObjects}
+ *
+ */
+ public static ManageableObjects getManageableObjects(Object object) {
+ try {
+ if (object == null) {
+ return null;
+ }
+
+ if (object instanceof ManageableObjects) {
+ return (ManageableObjects) object;
+
+ }
+
+ //if the class is implementing the Collection interface
+ if (ReflectionUtils.implementsInterface(object.getClass(), Collection.class))
+ {
+ return new ManageableCollectionImpl((Collection) object);
+ }
+
+ //if the class is implementing the Map interface
+ if (ReflectionUtils.implementsInterface(object.getClass(), Map.class))
+ {
+ return new ManageableMapImpl((Map) object);
+ }
+
+
+ }
+ catch (Exception e) {
+ throw new JcrMappingException("Impossible to create the manageable collection", e);
+ }
+
+ throw new JcrMappingException("Unsupported collection type :" + object.getClass().getName());
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/AbstractCollectionConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/AbstractCollectionConverterImpl.java
new file mode 100644
index 00000000..9f3813d2
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/AbstractCollectionConverterImpl.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.collectionconverter.impl;
+
+import java.util.Map;
+
+import javax.jcr.ItemExistsException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.CollectionConverter;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjects;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
+
+/**
+ * Abstract class used for all CollectionConverter
+ *
+ * @author Christophe Lombart
+ * @author Alexandru Popescu
+ */
+public abstract class AbstractCollectionConverterImpl implements CollectionConverter {
+ protected Map atomicTypeConverters;
+ protected ObjectConverter objectConverter;
+ protected Mapper mapper;
+
+ /**
+ * Constructor
+ *
+ * @param atomicTypeConverters The atomic type converter to used
+ * @param objectConverter The object converter to used
+ * @param mapper The mapper to used
+ */
+ public AbstractCollectionConverterImpl(Map atomicTypeConverters, ObjectConverter objectConverter, Mapper mapper) {
+ this.atomicTypeConverters = atomicTypeConverters;
+ this.objectConverter = objectConverter;
+ this.mapper = mapper;
+ }
+
+ protected abstract void doInsertCollection(Session session, Node parentNode, CollectionDescriptor descriptor,
+ ManageableObjects objects) throws RepositoryException;
+
+ protected abstract void doUpdateCollection(Session session, Node parentNode, CollectionDescriptor descriptor,
+ ManageableObjects objects) throws RepositoryException;
+
+ protected abstract ManageableObjects doGetCollection(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor, Class collectionFieldClass) throws RepositoryException;
+
+ protected abstract boolean doIsNull(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
+ Class collectionFieldClass) throws RepositoryException;
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.collectionconverter.CollectionConverter#insertCollection(javax.jcr.Session, javax.jcr.Node, org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor, org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection)
+ */
+ public void insertCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
+ ManageableObjects objects) {
+ try {
+ doInsertCollection(session, parentNode, collectionDescriptor, objects);
+ } catch (ItemExistsException iee) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName() + ". An item already exists.", iee);
+ } catch (PathNotFoundException pnfe) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName(), pnfe);
+ } catch (VersionException ve) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName(), ve);
+ } catch (ConstraintViolationException cve) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName() + ". Constraint violation.", cve);
+ } catch (LockException le) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName() + " on locked parent.", le);
+ } catch (RepositoryException re) {
+ throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Cannot insert collection field : "
+ + collectionDescriptor.getFieldName() + " of class "
+ + collectionDescriptor.getClassDescriptor().getClassName(), re);
+ }
+ }
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.collectionconverter.CollectionConverter#updateCollection(javax.jcr.Session, javax.jcr.Node, org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor, org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection)
+ */
+ public void updateCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
+ ManageableObjects objects) {
+ try {
+
+ doUpdateCollection(session, parentNode, collectionDescriptor, objects);
+ } catch (VersionException ve) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName(), ve);
+ } catch (LockException le) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName() + " on locked node", le);
+ } catch (ConstraintViolationException cve) {
+ throw new ObjectContentManagerException("Cannot insert collection field : " + collectionDescriptor.getFieldName()
+ + " of class " + collectionDescriptor.getClassDescriptor().getClassName() + " Constraint violation.", cve);
+ } catch (RepositoryException re) {
+ throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Cannot insert collection field : "
+ + collectionDescriptor.getFieldName() + " of class "
+ + collectionDescriptor.getClassDescriptor().getClassName(), re);
+ }
+ }
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.collectionconverter.CollectionConverter#getCollection(javax.jcr.Session, javax.jcr.Node, org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor, java.lang.Class)
+ */
+ public ManageableObjects getCollection(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
+ Class collectionFieldClass) {
+ try {
+ return doGetCollection(session, parentNode, collectionDescriptor, collectionFieldClass);
+ } catch (RepositoryException re) {
+ throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Cannot get collection field : "
+ + collectionDescriptor.getFieldName() + " for " + collectionDescriptor.getClassDescriptor().getClassName(), re);
+ }
+ }
+
+ /**
+ * @see org.apache.jackrabbit.ocm.manager.collectionconverter.CollectionConverter#isNull(Session, Node, CollectionDescriptor, Class)
+ */
+ public boolean isNull(Session session, Node parentNode, CollectionDescriptor collectionDescriptor,
+ Class collectionFieldClass) {
+ try {
+ return doIsNull(session, parentNode, collectionDescriptor, collectionFieldClass);
+ } catch (RepositoryException re) {
+ throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Cannot check if the collections has elements : "
+ + collectionDescriptor.getFieldName() + "for " + collectionDescriptor.getClassDescriptor().getClassName(), re);
+ }
+ }
+ protected String getCollectionJcrName(CollectionDescriptor descriptor) {
+ String jcrName = descriptor.getJcrName();
+
+ if (null == jcrName) {
+ throw new JcrMappingException("The JcrName attribute is not defined for the CollectionDescriptor : "
+ + descriptor.getFieldName());
+ }
+
+ return jcrName;
+ }
+}
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceCollectionConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceCollectionConverterImpl.java
new file mode 100644
index 00000000..3b0bb6a9
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceCollectionConverterImpl.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.collectionconverter.impl;
+
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjects;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjectsUtil;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
+
+/**
+ * Collection Mapping used to map a reference/uuid property list into a java bean collection (readonly).
+ * Only the uuid can be modified, not the associated object
+ *
+ * @author Christophe Lombart
+ *
+ */
+public class BeanReferenceCollectionConverterImpl extends AbstractCollectionConverterImpl {
+
+ /**
+ * Constructor
+ *
+ * @param atomicTypeConverters
+ * @param objectConverter
+ * @param mapper
+ */
+ public BeanReferenceCollectionConverterImpl(Map atomicTypeConverters,
+ ObjectConverter objectConverter,
+ Mapper mapper) {
+ super(atomicTypeConverters, objectConverter, mapper);
+ }
+
+ /**
+ *
+ * @see AbstractCollectionConverterImpl#doInsertCollection(Session, Node, CollectionDescriptor, ManageableCollection)
+ */
+ protected void doInsertCollection(Session session,
+ Node parentNode,
+ CollectionDescriptor collectionDescriptor,
+ ManageableObjects objects) throws RepositoryException {
+ addUuidProperties(session, parentNode, collectionDescriptor, objects);
+ }
+
+
+ /**
+ *
+ * @see AbstractCollectionConverterImpl#doUpdateCollection(Session, Node, CollectionDescriptor, ManageableCollection)
+ */
+ protected void doUpdateCollection(Session session,
+ Node parentNode,
+ CollectionDescriptor collectionDescriptor,
+ ManageableObjects objects) throws RepositoryException
+ {
+ String jcrName = getCollectionJcrName(collectionDescriptor);
+
+ // Delete existing values
+ if (parentNode.hasProperty(jcrName)) {
+ parentNode.setProperty(jcrName, (Value[]) null);
+ }
+
+ if (objects == null) {
+ return;
+ }
+
+ addUuidProperties(session, parentNode, collectionDescriptor, objects);
+
+ }
+
+ /**
+ * @see AbstractCollectionConverterImpl#doGetCollection(Session, Node, CollectionDescriptor, Class)
+ */
+ protected ManageableObjects doGetCollection(Session session,
+ Node parentNode,
+ CollectionDescriptor collectionDescriptor,
+ Class collectionFieldClass) throws RepositoryException {
+ try {
+ String jcrName = getCollectionJcrName(collectionDescriptor);
+ if (!parentNode.hasProperty(jcrName)) {
+ return null;
+ }
+ Property property = parentNode.getProperty(jcrName);
+ Value[] values = property.getValues();
+
+ ManageableObjects objects = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);
+
+ // For collection of bean references, only Collections are supported
+ if (! (objects instanceof ManageableCollection))
+ {
+
+ throw new JcrMappingException("Impossible to retrieve the attribute "
+ + collectionDescriptor.getFieldName() + " in the class "
+ + collectionDescriptor.getClassDescriptor().getClassName()
+ + " because it is not a collection");
+ }
+
+ for (int i = 0; i < values.length; i++) {
+ String uuid = values[i].getString();
+ String path = session.getNodeByIdentifier(uuid).getPath();
+ Object object = objectConverter.getObject(session, path);
+ ((ManageableCollection) objects).addObject(object);
+ }
+
+ return objects;
+ }
+ catch(Exception e) {
+ throw new ObjectContentManagerException("Cannot get the collection field : "
+ + collectionDescriptor.getFieldName()
+ + "for class " + collectionDescriptor.getClassDescriptor().getClassName(), e);
+ }
+ }
+
+ /**
+ * @see AbstractCollectionConverterImpl#doIsNull(Session, Node, CollectionDescriptor, Class)
+ */
+ protected boolean doIsNull(Session session, Node parentNode, CollectionDescriptor collectionDescriptor, Class collectionFieldClass) throws RepositoryException
+ {
+ String jcrName = getCollectionJcrName(collectionDescriptor);
+ return ! parentNode.hasProperty(jcrName);
+ }
+
+ private void addUuidProperties(Session session, Node parentNode,
+ CollectionDescriptor collectionDescriptor,
+ ManageableObjects objects)
+ throws UnsupportedRepositoryOperationException, RepositoryException, VersionException, LockException, ConstraintViolationException {
+ try {
+ if (objects == null) {
+ return;
+ }
+
+ String jcrName = getCollectionJcrName(collectionDescriptor);
+ Value[] values = new Value[objects.getSize()];
+ ValueFactory valueFactory = session.getValueFactory();
+ Iterator collectionIterator = objects.getIterator();
+ for (int i = 0; i < objects.getSize(); i++) {
+ Object object = collectionIterator.next();
+ if (object != null)
+ {
+ ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(object.getClass());
+
+ FieldDescriptor fieldDescriptor = classDescriptor.getUuidFieldDescriptor();
+ if (fieldDescriptor == null)
+ {
+ throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : "
+ + classDescriptor.getClassName());
+ }
+
+ String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
+ values[i] = valueFactory.createValue(uuid, PropertyType.REFERENCE);
+ }
+ }
+
+ parentNode.setProperty(jcrName, values);
+ }
+ catch(Exception e) {
+ throw new ObjectContentManagerException("Cannot insert collection field : "
+ + collectionDescriptor.getFieldName()
+ + " of class "
+ + collectionDescriptor.getClassDescriptor().getClassName(), e);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceMapConverterImpl.java b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceMapConverterImpl.java
new file mode 100644
index 00000000..07e6ac31
--- /dev/null
+++ b/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/BeanReferenceMapConverterImpl.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.ocm.manager.collectionconverter.impl;
+
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.jackrabbit.ocm.exception.JcrMappingException;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjects;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjectsUtil;
+import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
+import org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
+
+/**
+ * Map converter used to map reference/uuid property by key into a java.util.Map.
+ *
+ * This implementation takes for granted that the keys to the map are of type java.lang.String.
+ *
+ * Further development will be required to fully support Map