Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifecycleManager.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifecycleManager.java (revision 0) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifecycleManager.java (revision 0) @@ -0,0 +1,47 @@ +/* + * 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.jcr2spi; + +import javax.jcr.RepositoryException; + +import org.apache.jackrabbit.jcr2spi.state.NodeState; + +/** + * There's one LifecycleManager instance per Workspace + * instance. It handles all the operations related to lifecycle management. + */ +public interface LifecycleManager { + + /** + * Causes the lifecycle state of this node to undergo the specified + * transition. + * + * @param nodeState + * @param transition + * @throws RepositoryException + */ + void followLifecycleTransition(NodeState nodeState, String transition) throws RepositoryException; + + /** + * Returns the list of valid state transitions for this node. + * + * @param nodeState + * @throws RepositoryException + */ + String[] getAllowedLifecycleTransistions(NodeState nodeState) throws RepositoryException; + +} Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifeCyleManagerImpl.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifeCyleManagerImpl.java (revision 0) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/LifeCyleManagerImpl.java (revision 0) @@ -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.jcr2spi; + +import javax.jcr.RepositoryException; + +import org.apache.jackrabbit.jcr2spi.state.NodeState; + +public class LifeCyleManagerImpl implements LifecycleManager { + private WorkspaceManager wspManager; + + public LifeCyleManagerImpl(WorkspaceManager wspManager) { + this.wspManager = wspManager; + } + + public void followLifecycleTransition(NodeState nodeState, String transition) throws RepositoryException { + wspManager.followLifecycleTransition(nodeState, transition); + } + + public String[] getAllowedLifecycleTransistions(NodeState nodeState) throws RepositoryException { + return wspManager.getAllowedLifecycleTransistions(nodeState); + } +} Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (revision 1049382) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (working copy) @@ -1266,16 +1266,16 @@ * @see javax.jcr.Node#followLifecycleTransition(String) */ public void followLifecycleTransition(String transition) throws RepositoryException { - // TODO: implementation missing - throw new UnsupportedRepositoryOperationException("JCR-1104"); + checkStatus(); + session.getLifecycleManager().followLifecycleTransition(getNodeState(), transition); } /** * @see javax.jcr.Node#getAllowedLifecycleTransistions() */ public String[] getAllowedLifecycleTransistions() throws RepositoryException { - // TODO: implementation missing - throw new UnsupportedRepositoryOperationException("JCR-1104"); + checkStatus(); + return session.getLifecycleManager().getAllowedLifecycleTransistions(getNodeState()); } /** Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (revision 1049382) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (working copy) @@ -835,6 +835,10 @@ NodeTypeManagerImpl getNodeTypeManager() { return ntManager; } + + LifecycleManager getLifecycleManager() throws RepositoryException { + return workspace.getLifecycleManager(); + } CacheBehaviour getCacheBehaviour() { return config.getCacheBehaviour(); Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java (revision 1049382) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceImpl.java (working copy) @@ -108,6 +108,8 @@ private LockManager jcrLockManager; private javax.jcr.version.VersionManager jcrVersionManager; + + private LifecycleManager lifecycleManager; public WorkspaceImpl(String name, SessionImpl session, RepositoryConfig config, SessionInfo sessionInfo) throws RepositoryException { this.name = name; @@ -530,6 +532,15 @@ ItemStateFactory getItemStateFactory() { return wspManager.getItemStateFactory(); } + + LifecycleManager getLifecycleManager() throws RepositoryException { + session.checkIsAlive(); + session.checkSupportedOption(Repository.OPTION_LIFECYCLE_SUPPORTED); + if (lifecycleManager == null) { + lifecycleManager = new LifeCyleManagerImpl(wspManager); + } + return lifecycleManager; + } /** * Returns the validator of the session Index: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java =================================================================== --- jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (revision 1049382) +++ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java (working copy) @@ -437,6 +437,14 @@ public void setUserData(String userData) throws RepositoryException { sessionInfo.setUserData(userData); } + + public void followLifecycleTransition(NodeState nodeState, String transition) throws RepositoryException { + service.followLifecycleTransition(sessionInfo, (NodeId) nodeState.getWorkspaceId(), transition); + } + + public String[] getAllowedLifecycleTransistions(NodeState nodeState) throws RepositoryException { + return service.getAllowedLifecycleTransistions(sessionInfo, (NodeId) nodeState.getWorkspaceId()); + } //-------------------------------------------------------------------------- /** @@ -1175,5 +1183,4 @@ } } } - } Index: jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java =================================================================== --- jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java (revision 1049382) +++ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AbstractJCR2SPITest.java (working copy) @@ -627,6 +627,16 @@ public void deleteWorkspace(SessionInfo sessionInfo, String name) throws RepositoryException { repositoryService.deleteWorkspace(sessionInfo, name); } + + //-----------------------------------------------< Lifecycle Management >--- + + public String[] getAllowedLifecycleTransistions(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException { + return repositoryService.getAllowedLifecycleTransistions(sessionInfo, nodeId); + } + + public void followLifecycleTransition(SessionInfo sessionInfo, NodeId nodeId, String transition) throws RepositoryException { + repositoryService.followLifecycleTransition(sessionInfo, nodeId, transition); + } } Index: jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java =================================================================== --- jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java (revision 1049382) +++ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractRepositoryService.java (working copy) @@ -877,4 +877,18 @@ throw new UnsupportedRepositoryOperationException(); } + //-----------------------------------------------< Lifecycle Management >--- + /** + * @throws UnsupportedRepositoryOperationException always. + */ + public String[] getAllowedLifecycleTransistions(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException { + throw new UnsupportedRepositoryOperationException(); + } + + /** + * @throws UnsupportedRepositoryOperationException always. + */ + public void followLifecycleTransition(SessionInfo sessionInfo, NodeId nodeId, String transition) throws RepositoryException { + throw new UnsupportedRepositoryOperationException(); + } } Index: jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java =================================================================== --- jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java (revision 1049382) +++ jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/logging/RepositoryServiceLogger.java (working copy) @@ -779,7 +779,24 @@ }, "deleteWorkspace(SessionInfo, String, String)", new Object[]{unwrap(sessionInfo), name}); } + + public String[] getAllowedLifecycleTransistions(final SessionInfo sessionInfo, final NodeId nodeId) throws RepositoryException { + return (String[]) execute(new Callable() { + public Object call() throws RepositoryException { + return service.getAllowedLifecycleTransistions(unwrap(sessionInfo), nodeId); + } + }, "getAllowedLifecycleTransistions(SessionInfo, NodeId)", new Object[]{unwrap(sessionInfo), nodeId}); + } + public void followLifecycleTransition(final SessionInfo sessionInfo, final NodeId nodeId, final String transition) throws RepositoryException { + execute(new Callable() { + public Object call() throws RepositoryException { + service.followLifecycleTransition(unwrap(sessionInfo), nodeId, transition); + return null; + } + }, "followLifecycleTransition(SessionInfo, NodeId, String)", new Object[]{unwrap(sessionInfo), nodeId, transition}); + } + // -----------------------------------------------------< private >--- private static SessionInfo unwrap(SessionInfo sessionInfo) { @@ -799,5 +816,4 @@ return batch; } } - } Index: jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java =================================================================== --- jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (revision 1049382) +++ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (working copy) @@ -2263,8 +2263,24 @@ // TODO throw new UnsupportedOperationException("JCR-2003. Implementation missing"); } + + /** + * {@inheritDoc} + */ + public String[] getAllowedLifecycleTransistions(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException { + // TODO + throw new UnsupportedOperationException("JCR-2003. Implementation missing"); + } /** + * {@inheritDoc} + */ + public void followLifecycleTransition(SessionInfo sessionInfo, NodeId nodeId, String transition) throws RepositoryException { + // TODO + throw new UnsupportedOperationException("JCR-2003. Implementation missing"); + } + + /** * * @param sessionInfo * @param reportDoc Index: jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java =================================================================== --- jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (revision 1049382) +++ jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (working copy) @@ -1366,7 +1366,23 @@ Workspace wsp = sInfo.getSession().getWorkspace(); wsp.deleteWorkspace(name); } + + /** + * {@inheritDoc} + */ + public String[] getAllowedLifecycleTransistions(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException { + SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); + return getNode(nodeId, sInfo).getAllowedLifecycleTransistions(); + } + /** + * {@inheritDoc} + */ + public void followLifecycleTransition(SessionInfo sessionInfo, NodeId nodeId, String transition) throws RepositoryException { + SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo); + getNode(nodeId, sInfo).followLifecycleTransition(transition); + } + //----------------------------< internal >---------------------------------- private final class BatchImpl implements Batch { Index: jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java =================================================================== --- jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java (revision 1049382) +++ jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java (working copy) @@ -1280,4 +1280,28 @@ */ public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException; + //-----------------------------------------------< Lifecycle Management >--- + + /** + * Returns the list of valid state transitions for this node. + * + * @param sessionInfo + * @param nodeId + * @throws RepositoryException + * @see javax.jcr.Node#getAllowedLifecycleTransistions() + * @since JCR 2.0 + */ + public String[] getAllowedLifecycleTransistions(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException; + + /** + * Causes the lifecycle state of this node to undergo the specified transition. + * + * @param sessionInfo + * @param nodeId + * @param transition + * @throws RepositoryException + * @see javax.jcr.Node#followLifecycleTransition(String) + * @since JCR 2.0 + */ + public void followLifecycleTransition(SessionInfo sessionInfo, NodeId nodeId, String transition) throws RepositoryException; }