Moving to root below branch label

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2005 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2005-12-08 07:13:07 +00:00
commit e1e6508fec
1095 changed files with 230566 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import java.text.MessageFormat;
/**
* @author Roy Wetherall
*/
public class ReservedVersionNameException extends RuntimeException
{
/**
* Serial verison UID
*/
private static final long serialVersionUID = 3690478030330015795L;
/**
* Error message
*/
private static final String MESSAGE = "The version property name {0} clashes with a reserved verison property name.";
/**
* Constructor
*
* @param propertyName the name of the property that clashes with
* a reserved property name
*/
public ReservedVersionNameException(String propertyName)
{
super(MessageFormat.format(MESSAGE, new Object[]{propertyName}));
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Version interface.
*
* Allows access to version property values and frozen state node references.
* The version history tree can also be navigated.
*
* @author Roy Wetherall
*/
public interface Version extends Serializable
{
/**
* Names of the system version properties
*/
public static final String PROP_DESCRIPTION = "description";
/**
* Helper method to get the created date from the version property data.
*
* @return the date the version was created
*/
public Date getCreatedDate();
/**
* Helper method to get the creator of the version.
*
* @return the creator of the version
*/
public String getCreator();
/**
* Helper method to get the version label from the version property data.
*
* @return the version label
*/
public String getVersionLabel();
/**
* Helper method to get the version type.
*
* @return the value of the version type as an enum value
*/
public VersionType getVersionType();
/**
* Helper method to get the version description.
*
* @return the version description
*/
public String getDescription();
/**
* Get the map containing the version property values
*
* @return the map containing the version properties
*/
public Map<String, Serializable> getVersionProperties();
/**
* Gets the value of a named version property.
*
* @param name the name of the property
* @return the value of the property
*
*/
public Serializable getVersionProperty(String name);
/**
* Gets a reference to the node that this version was created from.
* <p>
* Note that this reference will be to the current state of the versioned
* node which may now correspond to a later version.
*
* @return a node reference
*/
public NodeRef getVersionedNodeRef();
/**
* Gets the reference to the node that contains the frozen state of the
* version.
*
* @return a node reference
*/
public NodeRef getFrozenStateNodeRef();
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import java.text.MessageFormat;
/**
* Version does not exist exception class.
*
* @author Roy Wetherall
*/
public class VersionDoesNotExistException extends VersionServiceException
{
private static final long serialVersionUID = 3258133548417233463L;
private static final String ERROR_MESSAGE = "The version with label {0} does not exisit in the version store.";
/**
* Constructor
*/
public VersionDoesNotExistException(String versionLabel)
{
super(MessageFormat.format(ERROR_MESSAGE, new Object[]{versionLabel}));
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import java.io.Serializable;
import java.util.Collection;
/**
* Version history interface.
*
* Collects the versions that make-up a version history.
*
* @author Roy Wetherall
*/
public interface VersionHistory extends Serializable
{
/**
* Gets the root (or initial) version of the version history.
*
* @return the root version
*/
public Version getRootVersion();
/**
* Gets a collection containing all the versions within the
* version history.
* <p>
* The order of the versions is not guarenteed.
*
* @return collection containing all the versions
*/
public Collection<Version> getAllVersions();
/**
* Gets the predecessor of a specified version
*
* @param version the version object
* @return the predeceeding version, null if root version
*/
public Version getPredecessor(Version version);
/**
* Gets the succeeding versions of a specified version.
*
* @param version the version object
* @return a collection containing the succeeding version, empty is none
*/
public Collection<Version> getSuccessors(Version version);
/**
* Gets a version with a specified version label. The version label is guarenteed
* unique within the version history.
*
* @param versionLabel the version label
* @return the version object
* @throws VersionDoesNotExistException indicates requested version does not exisit
*/
public Version getVersion(String versionLabel);
}

View File

@@ -0,0 +1,261 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import org.alfresco.service.cmr.repository.AspectMissingException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
/**
* Interface for public and internal version operations.
*
* @author Roy Wetherall
*/
public interface VersionService
{
/**
* The version store protocol label, used in store references
*/
public static final String VERSION_STORE_PROTOCOL = "versionStore";
/**
* Gets the reference to the version store
*
* @return reference to the version store
*/
public StoreRef getVersionStoreReference();
/**
* Creates a new version based on the referenced node.
* <p>
* If the node has not previously been versioned then a version history and
* initial version will be created.
* <p>
* If the node referenced does not or can not have the version aspect
* applied to it then an exception will be raised.
* <p>
* The version properties are sotred as version meta-data against the newly
* created version.
*
* @param nodeRef a node reference
* @param versionProperties the version properties that are stored with the newly created
* version
* @return the created version object
* @throws ReservedVersionNameException
* thrown if a reserved property name is used int he version properties
* provided
* @throws AspectMissingException
* thrown if the version aspect is missing
*/
public Version createVersion(
NodeRef nodeRef,
Map<String, Serializable> versionProperties)
throws ReservedVersionNameException, AspectMissingException;
/**
* Creates a new version based on the referenced node.
* <p>
* If the node has not previously been versioned then a version history and
* initial version will be created.
* <p>
* If the node referenced does not or can not have the version aspect
* applied to it then an exception will be raised.
* <p>
* The version properties are sotred as version meta-data against the newly
* created version.
*
* @param nodeRef a node reference
* @param versionProperties the version properties that are stored with the newly created
* version
* @param versionChildren if true then the children of the referenced node are also
* versioned, false otherwise
* @return the created version object(s)
* @throws ReservedVersionNameException
* thrown if a reserved property name is used int he version properties
* provided
* @throws AspectMissingException
* thrown if the version aspect is missing
*/
public Collection<Version> createVersion(
NodeRef nodeRef,
Map<String, Serializable> versionProperties,
boolean versionChildren)
throws ReservedVersionNameException, AspectMissingException;
/**
* Creates new versions based on the list of node references provided.
*
* @param nodeRefs a list of node references
* @param versionProperties version property values
* @return a collection of newly created versions
* @throws ReservedVersionNameException
* thrown if a reserved property name is used int he version properties
* provided
* @throws AspectMissingException
* thrown if the version aspect is missing
*/
public Collection<Version> createVersion(
Collection<NodeRef> nodeRefs,
Map<String, Serializable> versionProperties)
throws ReservedVersionNameException, AspectMissingException;
/**
* Gets the version history information for a node.
* <p>
* If the node has not been versioned then null is returned.
* <p>
* If the node referenced does not or can not have the version aspect
* applied to it then an exception will be raised.
*
* @param nodeRef a node reference
* @return the version history information
* @throws AspectMissingException
* thrown if the version aspect is missing
*/
public VersionHistory getVersionHistory(NodeRef nodeRef)
throws AspectMissingException;
/**
* Gets the version object for the current version of the node reference
* passed.
* <p>
* Returns null if the node is not versionable or has not been versioned.
* @param nodeRef the node reference
* @return the version object for the current version
*/
public Version getCurrentVersion(NodeRef nodeRef);
/**
* The node reference will be reverted to the current version.
* <p>
* A deep revert will be performed.
*
* @see VersionService#revert(NodeRef, Version, boolean)
*
* @param nodeRef the node reference
*/
public void revert(NodeRef nodeRef);
/**
* The node reference will be reverted to the current version.
*
* @see VersionService#revert(NodeRef, Version, boolean)
*
* @param nodeRef the node reference
* @param deep true if a deep revert is to be performed, flase otherwise
*/
public void revert(NodeRef nodeRef, boolean deep);
/**
* A deep revert will take place by default.
*
* @see VersionService#revert(NodeRef, Version, boolean)
*
* @param nodeRef the node reference
* @param version the version to revert to
*/
public void revert(NodeRef nodeRef, Version version);
/**
* Revert the state of the node to the specified version.
* <p>
* Any changes made to the node will be lost and the state of the node will reflect
* that of the version specified.
* <p>
* The version label property on the node reference will remain unchanged.
* <p>
* If the node is further versioned then the new version will be created at the head of
* the version history graph. A branch will not be created.
* <p>
* If a deep revert is to be performed then any child nodes that are no longer present will
* be deep restored (if appropriate) otherwise child associations to deleted, versioned nodes
* will not be restored.
*
* @param nodeRef the node reference
* @param version the version to revert to
* @param deep true is a deep revert is to be performed, false otherwise.
*/
public void revert(NodeRef nodeRef, Version version, boolean deep);
/**
* By default a deep restore is performed.
*
* @see org.alfresco.service.cmr.version.VersionService#restore(NodeRef, NodeRef, QName, QName, boolean)
*
* @param nodeRef the node reference to a node that no longer exists in the store
* @param parentNodeRef the new parent of the restored node
* @param assocTypeQName the assoc type qname
* @param assocQName the assoc qname
* @return the newly restored node reference
*/
public NodeRef restore(
NodeRef nodeRef,
NodeRef parentNodeRef,
QName assocTypeQName,
QName assocQName);
/**
* Restores a node not currenlty present in the store, but that has a version
* history.
* <p>
* The restored node will be at the head (most resent version).
* <p>
* Resoration will fail if there is no version history for the specified node id in
* the specified store.
* <p>
* If the node already exists in the store then an exception will be raised.
* <p>
* Once the node is restored it is reverted to the head version in the appropriate
* version history tree. If deep is set to true then this will be a deep revert, false
* otherwise.
*
* @param nodeRef the node reference to a node that no longer exists in
* the store
* @param parentNodeRef the new parent of the resotred node
* @param assocTypeQName the assoc type qname
* @param assocQName the assoc qname
* @param deep true is a deep revert shoudl be performed once the node has been
* restored, false otherwise
* @return the newly restored node reference
*/
public NodeRef restore(
NodeRef nodeRef,
NodeRef parentNodeRef,
QName assocTypeQName,
QName assocQName,
boolean deep);
/**
* Delete the version history associated with a node reference.
* <p>
* This operation is perminant, all versions in the version history are
* deleted and cannot be retrieved.
* <p>
* The current version label for the node reference is reset and any subsequent versions
* of the node will result in a new version history being created.
*
* @param nodeRef the node reference
* @throws AspectMissingException thrown if the version aspect is missing
*/
public void deleteVersionHistory(NodeRef nodeRef)
throws AspectMissingException;
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Version service exception class.
*
* @author Roy Wetherall
*/
public class VersionServiceException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 3544671772030349881L;
public VersionServiceException(String msgId, Throwable cause)
{
super(msgId, cause);
}
public VersionServiceException(String msgId, Object[] msgParams, Throwable cause)
{
super(msgId, msgParams, cause);
}
public VersionServiceException(String msgId, Object[] msgParams)
{
super(msgId, msgParams);
}
public VersionServiceException(String msgId)
{
super(msgId);
}
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* 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.alfresco.service.cmr.version;
/**
* Version type enum.
* <p>
* Commonly used in the version meta data to indicate whether the version is a major ro minor
* change.
*
* @author Roy Wetherall
*/
public enum VersionType {MAJOR, MINOR}