4

When I trace code in alfresce, I found following code in node-header.get.html.ftl

<#if item.workingCopy??>
    <#if item.workingCopy.isWorkingCopy??>
        <#assign lockUser = node.properties["cm:workingCopyOwner"]>
    <#else>
        <#assign lockUser = node.properties["cm:lockOwner"]>
    </#if>
......
<#elseif>

My understanding is

When a user click "Edit Offline", working copy of document is created and workingCopyOwner is same as lockOwner.

If so, why do we need to write like this? Is my understanding wrong???

swemon
  • 5,840
  • 4
  • 32
  • 54

3 Answers3

3

The property cm:workingCopyOwner belongs to the aspect cm:workingCopy and cm:lockOwner belongs to cm:lockable.

When you click "Edit offline" a copy of the node is created and assigned the aspect cm:workingCopy, cm:workingCopyOwner is set to your user. The original node is assigned the aspect cm:lockable and this one gets the property cm:lockOwner. So yes, the two properties get the same user, but those are assigned on different nodes.

/Erik

billerby
  • 1,977
  • 12
  • 22
3

Next to what already explained by @billerby, the main difference is that a node can be locked without having been checked out (e.g. by explicit locking calls), while it can't happen that a document is checked out BUT not locked.

Thus, cm:workingCopy and cm:lockable capture two different, albeit somehow related, lifecycle phases of a document, and the use of the respective properties to declare the lock ownership is simply made consistent when checking out documents.

billerby
  • 1,977
  • 12
  • 22
skuro
  • 13,414
  • 1
  • 48
  • 67
2

In Alfresco, like in most CMS, you can check out a document. When you do so, the original document is locked and a working copy is created for you to edit safely.

So in the content store there are actually 2 documents existing, both the original and the working copy.

The cm:workingCopyOwner property is only available on the working copy node, whereas the cm:lockOwner property is only available on the original document node. They both hold the same functionnal information (the lock user) but on different nodes.

So in your code above, it test which kind of node it is (original or working copy) by testing node.workingCopy?? and node.workingCopy.isWorkingCopy and then assign the right property accordingly to feed the lock user.

plus-
  • 45,453
  • 15
  • 60
  • 73