|
Author: sascharodekamp
Date: Tue Aug 7 11:31:04 2012 New Revision: 1370189 URL: http://svn.apache.org/viewvc?rev=1370189&view=rev Log: Update Jackrabbit to version 2.5.1, fix tests to run with the new jackrabbit version Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-api-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-core-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jca-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar (with props) ofbiz/branches/jackrabbit20120501/framework/jcr/lib/lucene-core-3.6.0.jar (with props) Removed: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-api-2.3.3.jar ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-core-2.3.3.jar ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jca-2.3.3.jar ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jcr-commons-2.3.3.jar ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-2.3.3.jar ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-commons-2.3.3.jar Modified: ofbiz/branches/jackrabbit20120501/.classpath ofbiz/branches/jackrabbit20120501/LICENSE ofbiz/branches/jackrabbit20120501/framework/jcr/config/jackrabbit.xml ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitDataTests.java ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitFilesTests.java ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitQueryTests.java ofbiz/branches/jackrabbit20120501/framework/jcr/testdef/jcrtests.xml Modified: ofbiz/branches/jackrabbit20120501/.classpath URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/.classpath?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/.classpath (original) +++ ofbiz/branches/jackrabbit20120501/.classpath Tue Aug 7 11:31:04 2012 @@ -205,13 +205,13 @@ <classpathentry kind="src" path="specialpurpose/webpos/src"/> <classpathentry kind="src" path="specialpurpose/workflow/src"/> <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-api-2.3.3.jar"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-core-2.3.3.jar"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jca-2.3.3.jar"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jcr-commons-2.3.3.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-api-2.5.1.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-core-2.5.1.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jca-2.5.1.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar"/> <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-ocm-2.0.jar"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-2.3.3.jar"/> - <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-commons-2.3.3.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-2.5.1.jar"/> + <classpathentry kind="lib" path="framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar"/> <classpathentry kind="lib" path="framework/jcr/lib/jcr-2.0.jar"/> <classpathentry kind="lib" path="framework/catalina/lib/tomcat-7.0.29-catalina-ha.jar"/> <classpathentry kind="lib" path="framework/catalina/lib/tomcat-7.0.29-catalina-tribes.jar"/> Modified: ofbiz/branches/jackrabbit20120501/LICENSE URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/LICENSE?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/LICENSE (original) +++ ofbiz/branches/jackrabbit20120501/LICENSE Tue Aug 7 11:31:04 2012 @@ -82,15 +82,14 @@ ofbiz/framework/catalina/lib/tomcat-7.0. ofbiz/trunk/framework/entity/lib/commons-dbcp-1.4.jar ofbiz/trunk/framework/entity/lib/jdbc/derby-10.8.2.2.jar ofbiz/trunk/framework/entity/lib/jdbc/derbytools-10.8.2.2.jar -ofbiz/trunk/framework/jcr/lib/cglib-2.2.jar ofbiz/trunk/framework/jcr/lib/concurrent-1.3.4.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-api-2.3.3.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-core-2.3.3.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-jca-2.3.3.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-jcr-commons-2.3.3.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-api-2.5.1.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-core-2.5.1.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-jca-2.5.1.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar ofbiz/trunk/framework/jcr/lib/jackrabbit-ocm-2.0.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-spi-2.3.3.jar -ofbiz/trunk/framework/jcr/lib/jackrabbit-spi-commons-2.3.3.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-spi-2.5.1.jar +ofbiz/trunk/framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar ofbiz/trunk/framework/jcr/lib/jcr-2.0.jar ofbiz/trunk/framework/jcr/lib/tagsoup-1.2.1.jar ofbiz/trunk/framework/jcr/lib/tika-core-1.0.jar Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/config/jackrabbit.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/config/jackrabbit.xml?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/config/jackrabbit.xml (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/config/jackrabbit.xml Tue Aug 7 11:31:04 2012 @@ -96,12 +96,11 @@ <!-- Search index and the file system it uses. class: FQN of class implementing the QueryHandler interface - + --> <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> <param name="path" value="${wsp.home}/index"/> <param name="supportHighlighting" value="true"/> </SearchIndex> - --> </Workspace> <!-- @@ -131,10 +130,9 @@ <!-- Search index for content that is shared repository wide (/jcr:system tree, contains mainly versions) - + --> <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> <param name="path" value="${rep.home}/repository/index"/> <param name="supportHighlighting" value="true"/> </SearchIndex> - --> </Repository> \ No newline at end of file Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-api-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-api-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-api-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-core-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-core-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-core-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jca-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jca-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jca-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-jcr-commons-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/jackrabbit-spi-commons-2.5.1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/lucene-core-3.6.0.jar URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/lib/lucene-core-3.6.0.jar?rev=1370189&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/branches/jackrabbit20120501/framework/jcr/lib/lucene-core-3.6.0.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/access/jackrabbit/VersioningManagerJackrabbit.java Tue Aug 7 11:31:04 2012 @@ -29,6 +29,7 @@ import javax.jcr.NodeIterator; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; import javax.jcr.UnsupportedRepositoryOperationException; +import javax.jcr.nodetype.NodeType; import javax.jcr.version.VersionException; import org.apache.jackrabbit.ocm.manager.ObjectContentManager; @@ -40,245 +41,265 @@ import org.ofbiz.jcr.util.jackrabbit.Jac public class VersioningManagerJackrabbit implements VersioningManager { - private final static String module = VersioningManagerJackrabbit.class.getName(); + private final static String module = VersioningManagerJackrabbit.class.getName(); - private final ObjectContentManager ocm; + private final ObjectContentManager ocm; - private final Set<String> checkedOutNodeStore = Collections.synchronizedSet(new HashSet<String>()); - private final static String NOVERSION = "-0.0"; + private final Set<String> checkedOutNodeStore = Collections.synchronizedSet(new HashSet<String>()); + private final static String NOVERSION = "-0.0"; - VersioningManagerJackrabbit(ObjectContentManager ocm) { - this.ocm = ocm; - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#getVersionList(java.lang.String) - */ - @Override - public List<String> getVersionList(String nodePath) { - List<String> result = new ArrayList<String>(); - VersionIterator versionIterator = null; - try { - versionIterator = this.ocm.getAllVersions(nodePath); - } catch (VersionException e) { - Debug.logError(e, module); - return result; - } - - // write the versions to the array list. - while (versionIterator.hasNext()) { - Version version = (Version) versionIterator.next(); - // filter the root version string, because it's not needed each node - // starts with the version number 1.0 - if (isNotRootVersion(version)) { - result.add(version.getName()); - } - } - - return result; - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#checkIfVersionExist(java.lang. - * String, java.lang.String) - */ - @Override - public boolean checkIfVersionExist(String nodePath, String version) { - return getVersionList(nodePath).contains(version); - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#checkOutContentObject(java.lang - * .String) - */ - @Override - public void checkOutContentObject(String nodePath) { - // check if the parent node is the root node, because the - // root node can not be checked out. - if (JackrabbitUtils.isARootNode(nodePath)) { - return; - } - - try { - if (doNodeExist(nodePath) && isNodeNotCheckedOut(nodePath)) { - this.ocm.checkout(nodePath); - this.addContentToCheckInList(nodePath); - } - } catch (VersionException e) { - Debug.logError(e, module); - } catch (UnsupportedRepositoryOperationException e) { - Debug.logError(e, module); - } catch (RepositoryException e) { - Debug.logError(e, module); - } - } - - public void checkOutContentObject(String nodePath, boolean checkOutAllSubnodes) { - if (checkOutAllSubnodes) { - try { - checkOutRelatedNodes(nodePath); - } catch (RepositoryException e) { - Debug.logError(e, module); - } - } else { - checkOutContentObject(nodePath); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#addContentToCheckInList(java.lang - * .String) - */ - @Override - public void addContentToCheckInList(String nodePath) { - checkedOutNodeStore.add(nodePath); - } - - /* - * (non-Javadoc) - * - * @see org.ofbiz.jcr.access.VersioningManager#checkInContentAndSaveState() - */ - @Override - public void checkInContentAndSaveState() { - ocm.save(); - - try { - for (String nodePath : checkedOutNodeStore) { - checkinNode(nodePath); - } - - // reset the node store after everything is checked in - checkedOutNodeStore.clear(); - } catch (VersionException e) { - Debug.logError(e, module); - } catch (UnsupportedRepositoryOperationException e) { - Debug.logError(e, module); - } catch (RepositoryException e) { - Debug.logError(e, module); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#getBaseVersion(java.lang.String) - */ - @Override - public String getBaseVersion(String nodePath) { - try { - return ocm.getBaseVersion(nodePath).getName(); - } catch (VersionException e) { - Debug.logError(e, module); - return NOVERSION; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.ofbiz.jcr.access.VersioningManager#getRootVersion(java.lang.String) - */ - @Override - public String getRootVersion(String nodePath) { - try { - return ocm.getRootVersion(nodePath).getName(); - } catch (VersionException e) { - Debug.logError(e, module); - return NOVERSION; - } - } - - /** - * Checks out recursively all related nodes (parent, all child's (if exists) - * and the node itself) - * - * @param startNode - * @throws RepositoryException - */ - private void checkOutRelatedNodes(String startNodePath) throws RepositoryException { - Node startNode = getNode(startNodePath); - List<String> nodesToCheckOut = new ArrayList<String>(); - - nodesToCheckOut.add(startNodePath); - nodesToCheckOut.add(startNode.getParent().getPath()); - - if (startNode.hasNodes()) { - List<String> allChildNodes = getAllChildNodes(startNode); - nodesToCheckOut.addAll(allChildNodes); - } - - for (String node : nodesToCheckOut) { - this.checkOutContentObject(node); - } - - } - - /** - * Return recursively all child nodes - * - * @param startNode - * @return - * @throws RepositoryException - */ - private List<String> getAllChildNodes(Node startNode) throws RepositoryException { - List<String> nodes = new ArrayList<String>(); - - NodeIterator subNodeIterator = startNode.getNodes(); - while (subNodeIterator.hasNext()) { - Node subNode = subNodeIterator.nextNode(); - - if (subNode.hasNodes()) { - nodes.addAll(getAllChildNodes(subNode)); - } - - nodes.add(subNode.getPath()); - } - - return nodes; - } - - private void checkinNode(String nodePath) throws RepositoryException, UnsupportedRepositoryOperationException, VersionException { - if (doNodeExist(nodePath) && this.isNodeCheckedOut(nodePath)) { - this.ocm.checkin(nodePath); - } - } - - private Node getNode(String startNodePath) throws PathNotFoundException, RepositoryException { - return ocm.getSession().getNode(startNodePath); - } - - private boolean isNotRootVersion(Version version) { - return !ConstantsJackrabbit.ROOTVERSION.equals(version.getName()); - } - - private boolean doNodeExist(String nodePath) throws RepositoryException { - return this.ocm.getSession().nodeExists(nodePath); - } - - private boolean isNodeNotCheckedOut(String nodePath) throws RepositoryException, UnsupportedRepositoryOperationException { - return !isNodeCheckedOut(nodePath); - } - - private boolean isNodeCheckedOut(String nodePath) throws UnsupportedRepositoryOperationException, RepositoryException { - boolean isNodeMarkedAsCheckedOut = this.ocm.getSession().getWorkspace().getVersionManager().isCheckedOut(nodePath); - boolean isNodeInCheckedOutNodeStore = checkedOutNodeStore.contains(nodePath); + VersioningManagerJackrabbit(ObjectContentManager ocm) { + this.ocm = ocm; + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#getVersionList(java.lang.String) + */ + @Override + public List<String> getVersionList(String nodePath) { + List<String> result = new ArrayList<String>(); + VersionIterator versionIterator = null; + try { + versionIterator = this.ocm.getAllVersions(nodePath); + } catch (VersionException e) { + Debug.logError(e, module); + return result; + } + + // write the versions to the array list. + while (versionIterator.hasNext()) { + Version version = (Version) versionIterator.next(); + // filter the root version string, because it's not needed each node + // starts with the version number 1.0 + if (isNotRootVersion(version)) { + result.add(version.getName()); + } + } + + return result; + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#checkIfVersionExist(java.lang. + * String, java.lang.String) + */ + @Override + public boolean checkIfVersionExist(String nodePath, String version) { + return getVersionList(nodePath).contains(version); + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#checkOutContentObject(java.lang + * .String) + */ + @Override + public void checkOutContentObject(String nodePath) { + // check if the parent node is the root node, because the + // root node can not be checked out. + if (JackrabbitUtils.isARootNode(nodePath)) { + return; + } + + try { + if (doNodeExist(nodePath) && isNodeVersionable(nodePath) && isNodeNotCheckedOut(nodePath)) { + this.ocm.checkout(nodePath); + this.addContentToCheckInList(nodePath); + } + } catch (VersionException e) { + Debug.logError(e, module); + } catch (UnsupportedRepositoryOperationException e) { + Debug.logError(e, module); + } catch (RepositoryException e) { + Debug.logError(e, module); + } + } + + private boolean isNodeVersionable(String nodePath) { + boolean isVersionable = false; + try { + NodeType[] nodeType = this.ocm.getSession().getNode(nodePath).getMixinNodeTypes(); + for (NodeType type : nodeType) { + isVersionable = type.isNodeType(NodeType.MIX_VERSIONABLE); + } + + } catch (PathNotFoundException e) { + Debug.logError(e, module); + } catch (RepositoryException e) { + Debug.logError(e, module); + } + return isVersionable; + } + + public void checkOutContentObject(String nodePath, boolean checkOutAllSubnodes) { + if (checkOutAllSubnodes) { + try { + checkOutRelatedNodes(nodePath); + } catch (RepositoryException e) { + Debug.logError(e, module); + } + } else { + checkOutContentObject(nodePath); + } + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#addContentToCheckInList(java.lang + * .String) + */ + @Override + public void addContentToCheckInList(String nodePath) { + checkedOutNodeStore.add(nodePath); + } + + /* + * (non-Javadoc) + * + * @see org.ofbiz.jcr.access.VersioningManager#checkInContentAndSaveState() + */ + @Override + public void checkInContentAndSaveState() { + ocm.save(); + + try { + for (String nodePath : checkedOutNodeStore) { + checkinNode(nodePath); + } + + // reset the node store after everything is checked in + checkedOutNodeStore.clear(); + } catch (VersionException e) { + Debug.logError(e, module); + } catch (UnsupportedRepositoryOperationException e) { + Debug.logError(e, module); + } catch (RepositoryException e) { + Debug.logError(e, module); + } + + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#getBaseVersion(java.lang.String) + */ + @Override + public String getBaseVersion(String nodePath) { + try { + return ocm.getBaseVersion(nodePath).getName(); + } catch (VersionException e) { + Debug.logError(e, module); + return NOVERSION; + } + } + + /* + * (non-Javadoc) + * + * @see + * org.ofbiz.jcr.access.VersioningManager#getRootVersion(java.lang.String) + */ + @Override + public String getRootVersion(String nodePath) { + try { + return ocm.getRootVersion(nodePath).getName(); + } catch (VersionException e) { + Debug.logError(e, module); + return NOVERSION; + } + } + + /** + * Checks out recursively all related nodes (parent, all child's (if exists) + * and the node itself) + * + * @param startNode + * @throws RepositoryException + */ + private void checkOutRelatedNodes(String startNodePath) throws RepositoryException { + Node startNode = getNode(startNodePath); + List<String> nodesToCheckOut = new ArrayList<String>(); + + nodesToCheckOut.add(startNodePath); + nodesToCheckOut.add(startNode.getParent().getPath()); + + if (startNode.hasNodes()) { + List<String> allChildNodes = getAllChildNodes(startNode); + nodesToCheckOut.addAll(allChildNodes); + } + + for (String node : nodesToCheckOut) { + this.checkOutContentObject(node); + } + + } + + /** + * Return recursively all child nodes + * + * @param startNode + * @return + * @throws RepositoryException + */ + private List<String> getAllChildNodes(Node startNode) throws RepositoryException { + List<String> nodes = new ArrayList<String>(); + + NodeIterator subNodeIterator = startNode.getNodes(); + while (subNodeIterator.hasNext()) { + Node subNode = subNodeIterator.nextNode(); + + if (subNode.hasNodes()) { + nodes.addAll(getAllChildNodes(subNode)); + } + + nodes.add(subNode.getPath()); + } + + return nodes; + } + + private void checkinNode(String nodePath) throws RepositoryException, UnsupportedRepositoryOperationException, + VersionException { + if (doNodeExist(nodePath) && this.isNodeCheckedOut(nodePath)) { + this.ocm.checkin(nodePath); + } + } + + private Node getNode(String startNodePath) throws PathNotFoundException, RepositoryException { + return ocm.getSession().getNode(startNodePath); + } + + private boolean isNotRootVersion(Version version) { + return !ConstantsJackrabbit.ROOTVERSION.equals(version.getName()); + } + + private boolean doNodeExist(String nodePath) throws RepositoryException { + return this.ocm.getSession().nodeExists(nodePath); + } + + private boolean isNodeNotCheckedOut(String nodePath) throws RepositoryException, + UnsupportedRepositoryOperationException { + return !isNodeCheckedOut(nodePath); + } + + private boolean isNodeCheckedOut(String nodePath) throws UnsupportedRepositoryOperationException, + RepositoryException { + boolean isNodeMarkedAsCheckedOut = this.ocm.getSession().getWorkspace().getVersionManager() + .isCheckedOut(nodePath); + boolean isNodeInCheckedOutNodeStore = checkedOutNodeStore.contains(nodePath); - return (isNodeMarkedAsCheckedOut && isNodeInCheckedOutNodeStore); - } + return (isNodeMarkedAsCheckedOut && isNodeInCheckedOutNodeStore); + } } Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitDataTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitDataTests.java?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitDataTests.java (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitDataTests.java Tue Aug 7 11:31:04 2012 @@ -59,21 +59,21 @@ public class JackrabbitDataTests extends protected void tearDown() throws Exception { } - public void testAccessorConstructor() throws RepositoryException { - JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin, delegator); + public void testAccessorDataTree() throws RepositoryException { + JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin, delegator); - assertNotNull(accessor); - assertEquals("/", accessor.getSession().getRootNode().getPath()); + JSONArray array = accessor.getJsonDataTree(); + // should be 0 because there are no entries in the repository yet + assertEquals(0, array.size()); - accessor.closeAccess(); + accessor.closeAccess(); } - public void testAccessorDataTree() throws RepositoryException { + public void testAccessorConstructor() throws RepositoryException { JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin, delegator); - JSONArray array = accessor.getJsonDataTree(); - // should be 0 because there are no entries in the repository yet - assertEquals(0, array.size()); + assertNotNull(accessor); + assertEquals("/", accessor.getSession().getRootNode().getPath()); accessor.closeAccess(); } Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitFilesTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitFilesTests.java?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitFilesTests.java (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitFilesTests.java Tue Aug 7 11:31:04 2012 @@ -18,62 +18,73 @@ under the License. */ package org.ofbiz.jcr.test; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import javax.jcr.RepositoryException; + +import net.sf.json.JSONArray; + import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; +import org.ofbiz.jcr.access.JcrRepositoryAccessor; +import org.ofbiz.jcr.access.jackrabbit.JackrabbitRepositoryAccessor; +import org.ofbiz.jcr.api.JcrFileHelper; +import org.ofbiz.jcr.api.jackrabbit.JackrabbitFileHelper; import org.ofbiz.service.testtools.OFBizTestCase; public class JackrabbitFilesTests extends OFBizTestCase { - private GenericValue userLogin = null; + private GenericValue userLogin = null; - public JackrabbitFilesTests(String name) { - super(name); - } + public JackrabbitFilesTests(String name) { + super(name); + } - @Override - protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + @Override + protected void setUp() throws Exception { + userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); - } + } - @Override - protected void tearDown() throws Exception { - } + @Override + protected void tearDown() throws Exception { + } - /* - public void testAccessorFileTree() throws RepositoryException { - JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin); + public void testAccessorFileTree() throws RepositoryException { + JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin, delegator); - JSONArray array = accessor.getJsonFileTree(); - assertEquals(0, array.size()); // should be 0 because there are no - // entries in the repository yet - accessor.closeAccess(); - }*/ + JSONArray array = accessor.getJsonFileTree(); + assertEquals(0, array.size()); // should be 0 because there are no + // entries in the repository yet + accessor.closeAccess(); + } - /* - * Test the File upload - */ /* - public void testCreateRepositoryFileNode() throws Exception { - File f = new File("stopofbiz.sh"); - File f2 = new File("README"); - assertTrue(f.exists() && f2.exists()); + /* + * Test the File upload + */ + public void testCreateRepositoryFileNode() throws Exception { + File f = new File("LICENSE"); + File f2 = new File("README"); + assertTrue(f.exists() && f2.exists()); - InputStream file = new FileInputStream(f); + InputStream file = new FileInputStream(f); - JcrFileHelper helper = new JackrabbitFileHelper(userLogin); - helper.storeContentInRepository(file, f.getName(), "/fileHome"); + JcrFileHelper helper = new JackrabbitFileHelper(userLogin, delegator); + helper.storeContentInRepository(file, f.getName(), "/fileHome"); - assertNotNull(helper.getRepositoryContent("/fileHome/" + f.getName())); + assertNotNull(helper.getRepositoryContent("/fileHome/" + f.getName())); - // add a second file to the same folder - file = new FileInputStream(f2); + // add a second file to the same folder + file = new FileInputStream(f2); - helper.storeContentInRepository(file, f2.getName(), "/fileHome"); - assertNotNull(helper.getRepositoryContent("/fileHome/" + f2.getName())); + helper.storeContentInRepository(file, f2.getName(), "/fileHome"); + assertNotNull(helper.getRepositoryContent("/fileHome/" + f2.getName())); - // remove all files in folder - helper.removeContentObject("/fileHome"); + // remove all files in folder + helper.removeContentObject("/fileHome"); - helper.closeContentSession(); - }*/ + helper.closeContentSession(); + } } \ No newline at end of file Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitQueryTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitQueryTests.java?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitQueryTests.java (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/src/org/ofbiz/jcr/test/JackrabbitQueryTests.java Tue Aug 7 11:31:04 2012 @@ -18,57 +18,66 @@ under the License. */ package org.ofbiz.jcr.test; +import java.util.Calendar; +import java.util.List; +import java.util.Map; + +import javax.jcr.RepositoryException; +import javax.jcr.query.QueryResult; + import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.GenericValue; +import org.ofbiz.jcr.access.JcrRepositoryAccessor; +import org.ofbiz.jcr.access.jackrabbit.JackrabbitRepositoryAccessor; +import org.ofbiz.jcr.api.JcrDataHelper; +import org.ofbiz.jcr.api.jackrabbit.JackrabbitArticleHelper; import org.ofbiz.service.testtools.OFBizTestCase; public class JackrabbitQueryTests extends OFBizTestCase { - private GenericValue userLogin = null; + private GenericValue userLogin = null; - public JackrabbitQueryTests(String name) { - super(name); - } + public JackrabbitQueryTests(String name) { + super(name); + } - @Override - protected void setUp() throws Exception { - userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); + @Override + protected void setUp() throws Exception { + userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true); - } + } - @Override - protected void tearDown() throws Exception { - } + @Override + protected void tearDown() throws Exception { + } - /* - public void testAccessorQuery() throws RepositoryException { - JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin); - QueryResult results = accessor.queryForRepositoryData("SELECT * FROM [rep:root]"); + public void testAccessorQuery() throws RepositoryException { + JcrRepositoryAccessor accessor = new JackrabbitRepositoryAccessor(userLogin, delegator); + QueryResult results = accessor.queryForRepositoryData("SELECT * FROM [rep:root]"); - assertNotNull(results); - assertEquals(1, results.getNodes().getSize()); + assertNotNull(results); + assertEquals(1, results.getNodes().getSize()); - accessor.closeAccess(); - }*/ + accessor.closeAccess(); + } - /* - public void testQuery() throws Exception { - JcrDataHelper helper = new JackrabbitArticleHelper(userLogin); + public void testQuery() throws Exception { + JcrDataHelper helper = new JackrabbitArticleHelper(userLogin, delegator); - helper.storeContentInRepository("/query", "en", "query", "query test", new GregorianCalendar()); + helper.storeContentInRepository("/query", "en", "query", "query test", Calendar.getInstance()); - List<Map<String, String>> queryResult = helper.queryData("SELECT * FROM [nt:unstructured]"); + List<Map<String, String>> queryResult = helper.queryData("SELECT * FROM [nt:unstructured]"); - assertEquals(3, queryResult.size()); // the list should contain 3 result - // sets + assertEquals(3, queryResult.size()); // the list should contain 3 result + // sets - assertEquals("/", queryResult.get(0).get("path")); - assertEquals("/query", queryResult.get(1).get("path")); - assertEquals("/query/en", queryResult.get(2).get("path")); + assertEquals("/", queryResult.get(0).get("path")); + assertEquals("/query", queryResult.get(1).get("path")); + assertEquals("/query/en", queryResult.get(2).get("path")); - helper.removeContentObject("query"); + helper.removeContentObject("query"); - helper.closeContentSession(); + helper.closeContentSession(); - }*/ + } } \ No newline at end of file Modified: ofbiz/branches/jackrabbit20120501/framework/jcr/testdef/jcrtests.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20120501/framework/jcr/testdef/jcrtests.xml?rev=1370189&r1=1370188&r2=1370189&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20120501/framework/jcr/testdef/jcrtests.xml (original) +++ ofbiz/branches/jackrabbit20120501/framework/jcr/testdef/jcrtests.xml Tue Aug 7 11:31:04 2012 @@ -32,10 +32,8 @@ <test-group case-name="jackrabbit-tests"> <junit-test-suite class-name="org.ofbiz.jcr.test.JackrabbitBaseTests"/> <junit-test-suite class-name="org.ofbiz.jcr.test.JackrabbitDataTests"/> - <!-- <junit-test-suite class-name="org.ofbiz.jcr.test.JackrabbitFilesTests"/> <junit-test-suite class-name="org.ofbiz.jcr.test.JackrabbitQueryTests"/> - --> </test-group> <!-- |
| Free forum by Nabble | Edit this page |
