org.alfresco.service.cmr.version.Version Java Examples

The following examples show how to use org.alfresco.service.cmr.version.Version. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualVersionServiceExtension.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void revert(NodeRef nodeRef, Version version)
{

    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null)
    {
        theTrait.revert(nodeRef,
                        version);
    }
    else
    {
        NodeRef materialNode = smartStore.materialize(reference);
        Version actualVersion = VirtualVersionServiceExtension.this.materializeVersionIfReference(version);
        theTrait.revert(materialNode,
                        actualVersion);
    }
}
 
Example #2
Source File: VersionHistoryImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test getVersion
 */
public void testGetVersion()
{
    VersionHistoryImpl vh = testAddVersionImpl();
   
    Version version1 = vh.getVersion("1");
    assertEquals(version1.getVersionLabel(), this.rootVersion.getVersionLabel());
    
    Version version2 = vh.getVersion("2");
    assertEquals(version2.getVersionLabel(), this.childVersion1.getVersionLabel());
    
    Version version3 = vh.getVersion("3");
    assertEquals(version3.getVersionLabel(), this.childVersion2.getVersionLabel());
    
    try
    {
        vh.getVersion("invalidLabel");
        fail("An exception should have been thrown if the version can not be retrieved.");
    }
    catch (VersionDoesNotExistException exception)
    {
        System.out.println("Error message: " + exception.getMessage());
    }
}
 
Example #3
Source File: VersionHistoryNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor
 * 
 * @param version       Descriptor of the node version information
 */
public VersionHistoryNode(Version version, TemplateNode parent, ServiceRegistry services)
{
    if (version == null)
    {
        throw new IllegalArgumentException("Version history descriptor is mandatory.");
    }
    if (parent == null)
    {
        throw new IllegalArgumentException("Parent TemplateNode is mandatory.");
    }
    if (services == null)
    {
        throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
    }
    this.version = version;
    this.parent = parent;
    this.services = services;
    this.properties = new QNameMap<String, Serializable>(this);
}
 
Example #4
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testCheckInLockableAspectDoesntCopies_ALF16194()
{
    // Check-out nodeRef
    NodeRef workingCopy = this.cociService.checkout(
            this.nodeRef, 
            this.rootNodeRef, 
            ContentModel.ASSOC_CHILDREN, 
            QName.createQName("workingCopy"));
    assertNotNull(workingCopy);
    
    // Check-in 
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");      
    cociService.checkin(workingCopy, versionProperties);
    
    if(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE))
    {
        fail("Lockable aspect should not be copied from the working copy to the original document");
    }
}
 
Example #5
Source File: VersionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test versioning the children of a versionable node
 */
@Test
public void testVersioningChildren()
{
    NodeRef versionableNode = createNewVersionableNode();
    
    // Snap shot data
    String expectedVersionLabel = peekNextVersionLabel(versionableNode, versionProperties);
    
    // Snap-shot the node created date-time
    long beforeVersionTime = ((Date)nodeService.getProperty(versionableNode, ContentModel.PROP_CREATED)).getTime();
    
    // Version the node and its children
    Collection<Version> versions = this.versionService.createVersion(
            versionableNode, 
            this.versionProperties,
            true);
    
    // Check the returned versions are correct
    CheckVersionCollection(expectedVersionLabel, beforeVersionTime, versions);
    
    // TODO check the version history is correct
}
 
Example #6
Source File: TemplateNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @return a list of objects representing the version history of this node.
 *         @see VersionHistoryNode
 */
public List<VersionHistoryNode> getVersionHistory()
{
    List<VersionHistoryNode> records = Collections.<VersionHistoryNode>emptyList();
    
    if (this.getAspects().contains(ContentModel.ASPECT_VERSIONABLE))
    {
        VersionHistory history = this.services.getVersionService().getVersionHistory(this.nodeRef);
        if (history != null)
        {
            records = new ArrayList<VersionHistoryNode>(8);
            for (Version version : history.getAllVersions())
            {
                // create a wrapper for the version information
                VersionHistoryNode record = new VersionHistoryNode(version, this, this.services);
                
                // add the client side version to the list
                records.add(record);
            }
        }
    }
    
    return records;
}
 
Example #7
Source File: Version2ServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get the head version given a node reference
 *
 * @param nodeRef   the node reference
 * @return          the 'head' version
 */
private Version getHeadVersion(NodeRef nodeRef)
{
    NodeRef versionHistoryNodeRef = getVersionHistoryNodeRef(nodeRef);
    
    Version headVersion = null;
    if (versionHistoryNodeRef != null)
    {
        VersionHistory versionHistory = buildVersionHistory(versionHistoryNodeRef, nodeRef);
        if (versionHistory != null)
        {
            headVersion = versionHistory.getHeadVersion();
        }
    }
    return headVersion;
}
 
Example #8
Source File: NodeServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test getParentAssocs
 */
@Test
public void testGetParentAssocs()
{
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    NodeRef nodeRef = version.getFrozenStateNodeRef();
    
    List<ChildAssociationRef> results = this.versionStoreNodeService.getParentAssocs(nodeRef);
    assertNotNull(results);
    assertEquals(1, results.size());
    ChildAssociationRef childAssoc = results.get(0);
    assertEquals(nodeRef, childAssoc.getChildRef());
    NodeRef versionStoreRoot = this.dbNodeService.getRootNode(this.versionService.getVersionStoreReference());
    assertEquals(versionStoreRoot, childAssoc.getParentRef());
}
 
Example #9
Source File: ImporterComponent.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Fixes things up for versionable nodes after importing.
 * Because version information is stored in a different store,
 *  the past versions are not included in the ACP. 
 * However, because the node has the versionable aspect applied to 
 *  it, we still need it to have a single version in the version store.
 * This method arranges for that. 
 */
private void generateVersioningForVersionableNode(final NodeRef nodeRef)
{
    // Is versioning already turned on?
    if(versionService.getVersionHistory(nodeRef) != null)
    {
        // There is already version history, so we don't need to do anything
        return;
    }
    
    // Take a copy of the version label, as it'll be reset when
    //  we request that versioning occurs
    final String label = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
    
    // Have versioning enabled
    Version version = versionService.createVersion(nodeRef, null);
    final NodeRef versionNodeRef = VersionUtil.convertNodeRef(version.getFrozenStateNodeRef());
    
    // Put the version label back how it should be on the main node
    dbNodeService.setProperty(nodeRef, ContentModel.PROP_VERSION_LABEL, label);
    
    // Fix up the versioned version node to be what it should be
    // (The previous version label should be off, and the current label is the new one)
    dbNodeService.setProperty(versionNodeRef, ContentModel.PROP_VERSION_LABEL, null);
    dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_VERSION_LABEL, label);
}
 
Example #10
Source File: VirtualVersionServiceExtensionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testGetCurrentVersion() throws Exception
{
    ChildAssociationRef contentWithVersionsAssocRef = createContent(node2_1,
                                                                    "ContentWithVersions");
    NodeRef contentWithVersionsNodeRef = contentWithVersionsAssocRef.getChildRef();

    Version currentVersion = versionService.getCurrentVersion(contentWithVersionsNodeRef);
    assertNull(currentVersion);

    Version newVersion = versionService.createVersion(contentWithVersionsNodeRef,
                                                      null);
    assertNotNull(newVersion);

    Version newCurrentVersion = versionService.getCurrentVersion(contentWithVersionsNodeRef);
    assertNotNull(newCurrentVersion);

    assertSameVersion(newVersion,
                      newCurrentVersion);

}
 
Example #11
Source File: NodeVersionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Version findVersion(String nodeId, String versionLabelId)
{
    NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);
    VersionHistory vh = versionService.getVersionHistory(nodeRef);
    if (vh != null) 
    {
        return vh.getVersion(versionLabelId);
    }
    return null;
}
 
Example #12
Source File: NodeVersionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * List version history
 *
 * @param nodeId String id of (live) node
 */
@Override
@WebApiDescription(title = "Return version history as a paged list of version node infos")
public CollectionWithPagingInfo<Node> readAll(String nodeId, Parameters parameters)
{
    NodeRef nodeRef = nodes.validateOrLookupNode(nodeId, null);

    VersionHistory vh = versionService.getVersionHistory(nodeRef);

    Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
    List<String> includeParam = parameters.getInclude();
    
    List<Node> collection = null;
    if (vh != null)
    {
        collection = new ArrayList<>(vh.getAllVersions().size());
        for (Version v : vh.getAllVersions())
        {
            Node node = nodes.getFolderOrDocument(v.getFrozenStateNodeRef(), null, null, includeParam, mapUserInfo);
            mapVersionInfo(v, node);
            collection.add(node);
        }
    }
    
    return listPage(collection, parameters.getPaging());
}
 
Example #13
Source File: CMISNodeInfoImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected Version getVersion()
{
    if (version == null && isDocument())
    {
        try
        {
            VersionHistory versionHistory = getVersionHistory();
            if (versionHistory == null)         // Avoid unnecessary NPE
            {
                return null;
            }
            version = versionHistory.getVersion(versionLabel);
        } catch (Exception e)
        {
        }
    }

    return version;
}
 
Example #14
Source File: RenditionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeRef findVersionIfApplicable(NodeRef nodeRef, String versionLabelId)
{
    if (versionLabelId != null)
    {
        nodeRef = nodes.validateOrLookupNode(nodeRef.getId(), null);
        VersionHistory vh = versionService.getVersionHistory(nodeRef);
        if (vh != null)
        {
            try
            {
                Version v = vh.getVersion(versionLabelId);
                nodeRef = VersionUtil.convertNodeRef(v.getFrozenStateNodeRef());
            }
            catch (VersionDoesNotExistException vdne)
            {
                throw new NotFoundException("Couldn't find version: [" + nodeRef.getId() + ", " + versionLabelId + "]");
            }
        }
    }

    return nodeRef;
}
 
Example #15
Source File: VirtualVersionServiceExtension.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void deleteVersion(NodeRef nodeRef, Version version)
{
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null)
    {
        theTrait.deleteVersion(nodeRef,
                               version);
    }
    else
    {
        NodeRef materialNode = smartStore.materialize(reference);
        Version actualVersion = materializeVersionIfReference(version);
        theTrait.deleteVersion(materialNode,
                               actualVersion);
    }
}
 
Example #16
Source File: VersionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Sets an optional comparator to sort a versions in descending order (eg. 2.1, 2.0, 1.1, 1.0).
 * Really only needed in a 4.1.3 system (or above) that has been upgraded from an earlier system
 * that used NON ordered sequence numbers in a cluster. Not something we really support but was
 * the subject of MNT-226.
 * @param versionComparatorClass the name of a comparator. For example
 *        "org.alfresco.repo.version.common.VersionLabelComparator".
 */
@SuppressWarnings("unchecked")
public void setVersionComparatorClass(String versionComparatorClass)
{
    if (versionComparatorClass != null && versionComparatorClass.trim().length() != 0)
    {
        try
        {
            versionComparatorDesc = (Comparator<Version>) getClass().getClassLoader().
                    loadClass(versionComparatorClass.trim()).newInstance();
        }
        catch (Exception e)
        {
            throw new AlfrescoRuntimeException(
                    "Failed to create a Comparator<Version> using the class name "+
                    versionComparatorClass, e);
        }
    }
}
 
Example #17
Source File: VersionServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see VersionService#createVersion(NodeRef, Map)
 */
public Version createVersion(
        NodeRef nodeRef,
        Map<String, Serializable> versionProperties)
        throws ReservedVersionNameException, AspectMissingException
{
    if (logger.isDebugEnabled())
    {
        logger.debug("Run as user " + AuthenticationUtil.getRunAsUser());
        logger.debug("Fully authenticated " + AuthenticationUtil.getFullyAuthenticatedUser());
    }
    
    long startTime = System.currentTimeMillis();
    
    int versionNumber = 0; // deprecated (unused)
    
    // Create the version
    Version version = createVersion(nodeRef, versionProperties, versionNumber);
    
    if (logger.isDebugEnabled())
    {
        logger.debug("created version (" + VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()) + ") in " + (System.currentTimeMillis()-startTime) + " ms");
    }
    
    return version;
}
 
Example #18
Source File: VersionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void CheckVersionHistory(VersionHistory vh, List<Version> expectedVersions)
{
    if (vh == null)
    {
        assertNull(expectedVersions);
    }
    else
    {
        Iterator<Version> itr = expectedVersions.iterator();
        
        for (Version version : vh.getAllVersions())
        {
            Version expectedVersion = itr.next();
            
            assertEquals(version.getVersionLabel(), expectedVersion.getVersionLabel());
            assertEquals(version.getFrozenStateNodeRef(), expectedVersion.getFrozenStateNodeRef());
        }
        
        assertFalse(itr.hasNext());
    }
}
 
Example #19
Source File: VirtualVersionServiceExtension.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Version createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties)
            throws ReservedVersionNameException, AspectMissingException
{
    VersionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null)
    {
        return theTrait.createVersion(nodeRef,
                                      versionProperties);
    }
    else
    {
        NodeRef materialNode = smartStore.materializeIfPossible(nodeRef);
        Version actualVersion = theTrait.createVersion(materialNode,
                                                       versionProperties);    
        return virtualizeVersion(reference,
                                 actualVersion);
    }
}
 
Example #20
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testCheckOutCheckInWithDifferentLocales()
{
    // Check-out nodeRef using the locale fr_FR
    Locale.setDefault(Locale.FRANCE);
    NodeRef workingCopy = this.cociService.checkout(
            this.nodeRef, 
            this.rootNodeRef, 
            ContentModel.ASSOC_CHILDREN, 
            QName.createQName("workingCopy"));
    assertNotNull(workingCopy);
    
    // Check that the working copy name has been set correctly
    String workingCopyName = (String) nodeService.getProperty(workingCopy, PROP_NAME_QNAME);
    assertEquals("Working copy name not correct", "myDocument (Copie de Travail).doc", workingCopyName);
    
    // Check-in using the locale en_GB
    Locale.setDefault(Locale.UK);
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");      
    cociService.checkin(workingCopy, versionProperties);
    
    String name = (String) nodeService.getProperty(nodeRef, PROP_NAME_QNAME);
    assertEquals("Working copy label was not removed.", "myDocument.doc", name);
}
 
Example #21
Source File: EditionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void dumpFrozenMetaData(Version editionVersion)
{
    System.out.println("---------------------------------------------------");
    //Get current version label
    System.out.println("Version Label: " + editionVersion.getVersionLabel());
    System.out.println("---------------------------------------------------");
    //Map<QName,Serializable> mapOfFrozenProps = editionService.getVersionedMetadatas(editionVersion);
    Map<String,Serializable> mapOfFrozenProps = editionVersion.getVersionProperties();
    if(mapOfFrozenProps == null )
    {
        System.out.println("Nul... ");
        return;
    }

    for(String  q: mapOfFrozenProps.keySet())
    {
        String val = mapOfFrozenProps.get(q)==null?"null":mapOfFrozenProps.get(q).toString();
        System.out.println("QName:" + q + ":" +  val);
    }
}
 
Example #22
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testCheckOutCheckInWithTranslatableAspect()
{
    // Create a node to be used as the translation
    NodeRef translationNodeRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("translation"),
            ContentModel.TYPE_CONTENT).getChildRef();
    
    nodeService.addAspect(this.nodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translatable"), null);
    nodeService.createAssociation(this.nodeRef, translationNodeRef, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "translations"));
            
    // Check it out
    NodeRef workingCopy = cociService.checkout(
            this.nodeRef, 
            this.rootNodeRef, 
            ContentModel.ASSOC_CHILDREN, 
            QName.createQName("workingCopy"));
    
            
    // Check it back in again
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
    cociService.checkin(workingCopy, versionProperties);
}
 
Example #23
Source File: NodeVersionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void mapVersionInfo(Version v, Node aNode, NodeRef nodeRef)
{
    aNode.setNodeRef(nodeRef);
    aNode.setVersionComment(v.getDescription());

    Map<String, Object> props = aNode.getProperties();
    if (props != null)
    {
        // special case (as per Version2Service)
        props.put("cm:"+Version2Model.PROP_VERSION_TYPE, v.getVersionProperty(Version2Model.PROP_VERSION_TYPE));
    }

    //Don't show parentId, createdAt, createdByUser
    aNode.setParentId(null);
    aNode.setCreated(null);
    aNode.setCreatedByUser(null);
}
 
Example #24
Source File: VersionHistoryImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test getPredecessor
 */
public void testGetPredecessor()
{
    VersionHistoryImpl vh = testAddVersionImpl();
    
    Version version1 = vh.getPredecessor(this.childVersion1);
    assertEquals(version1.getVersionLabel(), this.rootVersion.getVersionLabel());
    
    Version version2 = vh.getPredecessor(this.childVersion2);
    assertEquals(version2.getVersionLabel(), this.rootVersion.getVersionLabel());
    
    Version version3 = vh.getPredecessor(this.rootVersion);
    assertNull(version3);
    
    try
    {
        Version version4 = vh.getPredecessor(null);
        assertNull(version4);
    }
    catch (Exception exception)
    {
        fail("Should continue by returning null.");
    }
}
 
Example #25
Source File: NodeServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test getPrimaryParent
 */
@Test
public void testGetPrimaryParent()
{
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    NodeRef nodeRef = version.getFrozenStateNodeRef();
    
    ChildAssociationRef childAssoc = this.versionStoreNodeService.getPrimaryParent(nodeRef);
    assertNotNull(childAssoc);
    assertEquals(nodeRef, childAssoc.getChildRef());
    NodeRef versionStoreRoot = this.dbNodeService.getRootNode(this.versionService.getVersionStoreReference());
    assertEquals(versionStoreRoot, childAssoc.getParentRef());        
}
 
Example #26
Source File: VersionHistoryImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor, ensures the root version is set.
 * 
 * @param rootVersion  the root version, can not be null.
 * @param versionComparatorDesc optional comparator of versions.
 */
public VersionHistoryImpl(Version rootVersion, Comparator<Version> versionComparatorDesc)
{
    if (rootVersion == null)
    {
        // Exception - a version history can not be created unless
        //             a root version is specified
        throw new VersionServiceException(VersionHistoryImpl.ERR_MSG);
    }
    
    this.versionHistory = new HashMap<String, String>();
    this.versionsByLabel = new LinkedHashMap<String, Version>();
    this.versionComparatorDesc = versionComparatorDesc;
    
    addVersion(rootVersion, null);
}
 
Example #27
Source File: NodeServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test hasAspect
 */
@Test
public void testHasAspect()
{
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    
    boolean test1 = this.versionStoreNodeService.hasAspect(
            version.getFrozenStateNodeRef(), 
            ApplicationModel.ASPECT_UIFACETS);
    assertFalse(test1);
    
    boolean test2 = this.versionStoreNodeService.hasAspect(
            version.getFrozenStateNodeRef(),
            ContentModel.ASPECT_VERSIONABLE);
    assertTrue(test2);
}
 
Example #28
Source File: NodeServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test getAspects
 */
@Test
public void testGetAspects() 
{
    // Create a new versionable node
    NodeRef versionableNode = createNewVersionableNode();
    Set<QName> origAspects = this.dbNodeService.getAspects(versionableNode);
    
    // Create a new version
    Version version = createVersion(versionableNode, this.versionProperties);
    
    Set<QName> aspects = this.versionStoreNodeService.getAspects(version.getFrozenStateNodeRef());
    assertEquals(origAspects.size(), aspects.size());
    
    for (QName origAspect : origAspects)
    { 
        assertTrue(origAspect+"",aspects.contains(origAspect));
    }
}
 
Example #29
Source File: VersionHistoryImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets a version with a specified version label.  The version label is guaranteed 
 * unique within the version history.
 * 
 * @param versionLabel                   the version label
 * @return                               the version object
 * @throws VersionDoesNotExistException  indicates requested version does not exist
 */
public Version getVersion(String versionLabel)
{
    Version result = null;
    if (versionLabel != null)
    {
        result = this.versionsByLabel.get(versionLabel);
        
        if (result == null)
        {
            // Throw exception indicating that the version does not exit
            throw new VersionDoesNotExistException(versionLabel);
        }
    }
    return result;
}
 
Example #30
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testCanCheckInWhenOriginalHasUndeletableAspect()
{
    nodeService.addAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE, null);
    // Pre-condition of test, original must have sys:undeletable
    assertTrue(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE));

    // Check-out nodeRef
    NodeRef workingCopy = this.cociService.checkout(
            this.nodeRef,
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("workingCopy"));
    assertNotNull(workingCopy);

    // Check that the working copy does not have the sys:undeletable aspect
    assertFalse(nodeService.hasAspect(workingCopy, ContentModel.ASPECT_UNDELETABLE));

    // Check-in: must work despite original having the sys:undeletable aspect (MNT-18546)
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
    cociService.checkin(workingCopy, versionProperties);
}