cancel
Showing results for 
Search instead for 
Did you mean: 

JCR & versioning

anweber
Champ in-the-making
Champ in-the-making
Hi,

   I have a little problem when I try to create a node with "versionable" aspect.  When I look at the created node with the webClient, I see it as checked-out (without the working node) but I want to obtain a checked-in node.

There is an extract of my code :


            Node document = folder.addNode("cm:aweTestDoc", "cm:content");
            document.setProperty("cm:name", "AWE test doc");
            document.setProperty("cm:description", "AWE test document, created with JCR");
            document.setProperty("cm:title", "AWE document");
            document.setProperty("cm:content", "xxxxxxxxxxxxx");
            document.addMixin("mix:versionable");
           
            document.checkin();
           
             session.save();



          Thanks for your help,

                Andr
13 REPLIES 13

davidc
Star Contributor
Star Contributor
Hi,

The pattern of code you have looks fine.

The JCR checkout/checkin calls do not translate directly to Web Client checkout/checkin, so it's slightly odd that the Web Client believes it's checked-out.

Using the node browser, can you navigate to the node in question, and provide a dump of that page.  It will provide the raw state of the node, which should help diagnose.

anweber
Champ in-the-making
Champ in-the-making
There is the code returned by the node browser (sorry to send it to you like this but I do not know how to attach a file in this post) :


<html><head><title>Alfresco Node Browser</title></head><body>
<script language="JavaScript1.2" src="/alfresco/scripts/menu.js"></script>
<script language="JavaScript1.2" src="/alfresco/scripts/webdav.js"></script>
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
<form id="node-browser-titlebar" name="node-browser-titlebar" method="post" action="/alfresco/faces/jsp/admin/node-browser.jsp" enctype="application/x-www-form-urlencoded">
<table width="100%">
<tr>
<td>
<img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" />
</td>
<td>
<nobr><span class="mainTitle">Alfresco Node Browser</span></nobr>
</td>
<td width="100%" align="right">
<input id="node-browser-titlebar:_id2" name="node-browser-titlebar:_id2" type="submit" value="Close" onclick="clear_node_2Dbrowser_2Dtitlebar();" />
</td>
</tr>
</table>

<input type="hidden" name="node-browser-titlebar_SUBMIT" value="1" /><input type="hidden" name="node-browser-titlebar:_link_hidden_" /><script type="text/javascript"><!–
function clear_node_2Dbrowser_2Dtitlebar() {
  var f = document.forms['node-browser-titlebar'];
  f.elements['node-browser-titlebar:_link_hidden_'].value='';
  f.target='';
}
clear_node_2Dbrowser_2Dtitlebar();
//–></script></form>
<br>
<a href="#" onclick="clear_linkDummyForm();document.forms['linkDummyForm'].elements['linkDummyForm:_link_hidden_'].value='selectStores';if(document.forms['linkDummyForm'].onsubmit){if(document.forms['linkDummyForm'].onsubmit()) document.forms['linkDummyForm'].submit();}else{document.forms['linkDummyForm'].submit();}return false;" id="selectStores"><span class="mainSubText">Stores</span></a>
<br>
<br>

<span class="mainTitle">Search</span>

<form id="searchForm" name="searchForm" method="post" action="/alfresco/faces/jsp/admin/node-browser.jsp" enctype="application/x-www-form-urlencoded">
<table>
<tr>
<td>


<select id="searchForm:queryLanguage" name="searchForm:queryLanguage" size="1">   <option value="noderef">noderef</option>   <option value="xpath">xpath</option>   <option value="lucene">lucene</option>   <option value="selectnodes">selectnodes</option></select>
</td>
<td>
<input id="searchForm:query" name="searchForm:query" type="text" value="" size="100" />
</td>
<td>
<input id="searchForm:submitSearch" name="searchForm:submitSearch" type="submit" value="Search" onclick="clear_searchForm();" />
</td>
</tr>
<tr>
<td></td>
<td>

</td>
<td></td>
</tr>
</table>
<input type="hidden" name="searchForm_SUBMIT" value="1" /><input type="hidden" name="searchForm:_link_hidden_" /><script type="text/javascript"><!–
function clear_searchForm() {
  var f = document.forms['searchForm'];
  f.elements['searchForm:_link_hidden_'].value='';
  f.target='';
}
clear_searchForm();
//–></script></form>

<span class="mainTitle">Node Identifier</span>

<table>
<tr>
<td><nobr><b>Primary Path:</b></nobr></td><td>
<nobr>


<a href="#" onclick="clear_linkDummyForm();document.forms['linkDummyForm'].elements['linkDummyForm:_link_hidden_'].value='selectPrimaryPath';if(document.forms['linkDummyForm'].onsubmit){if(document.forms['linkDummyForm'].onsubmit()) document.forms['linkDummyForm'].submit();}else{document.forms['linkDummyForm'].submit();}return false;" id="selectPrimaryPath"><span id="primaryPath">/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1....</span></a>
</nobr>
</td>
</tr>
<tr>
<td><b>Reference:</b></td><td><span id="nodeRef">workspace://SpacesStore/777683bc-d044-11da-b480-29c273d29d12</span></td>
</tr>
<tr>
<td><b>Type:</b></td><td><span id="nodeType">{custom.model}ep_doc</span></td>
</tr>
<tr>
<td><b>Parent:</b></td>
<td>


<a href="#" onclick="clear_linkDummyForm();document.forms['linkDummyForm'].elements['linkDummyForm:_link_hidden_'].value='selectPrimaryParent';if(document.forms['linkDummyForm'].onsubmit){if(document.forms['linkDummyForm'].onsubmit()) document.forms['linkDummyForm'].submit();}else{document.forms['linkDummyForm'].submit();}return false;" id="selectPrimaryParent"><span id="primaryParent">workspace://SpacesStore/774ba32a-d044-11da-b480-29c273d29d12</span></a>
</td>
</tr>
</table>

<br>
<span class="mainTitle">Properties</span>


<table id="properties" border="1">
<thead>
<tr><th>Name</th><th>Value</th><th>Property Type</th><th>Value Type</th><th>Residual</th></tr></thead>
<tbody id="properties:tbody_element">
<tr><td>{http://www.alfresco.org/model/content/1.0}description</td><td>
<table id="properties_0:values" border="0" cellspacing="0">
<tbody id="properties_0:values:tbody_element">
<tr><td>AWE test EP document, created with JCR</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_0:valueTypes" border="0" cellspacing="0">
<tbody id="properties_0:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/system/1.0}node-uuid</td><td>
<table id="properties_1:values" border="0" cellspacing="0">
<tbody id="properties_1:values:tbody_element">
<tr><td>777683bc-d044-11da-b480-29c273d29d12</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_1:valueTypes" border="0" cellspacing="0">
<tbody id="properties_1:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}lockType</td><td>
<table id="properties_2:values" border="0" cellspacing="0">
<tbody id="properties_2:values:tbody_element">
<tr><td>READ_ONLY_LOCK</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_2:valueTypes" border="0" cellspacing="0">
<tbody id="properties_2:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}content</td><td>
<table id="properties_3:values" border="0" cellspacing="0">
<tbody id="properties_3:values:tbody_element">
<tr><td><a id="properties_3:values_0:_id15" href="/alfresco/download/direct/workspace/SpacesStore/777683bc-d044-11da-b480-29c273d29d12/file.bin?property={http://www.alfresco.org/model/content/1.0}content" target="_blank">contentUrl=store://2006/4/20/10/777ff99d-d044-11da-b480-29c273d29d12.bin|mimetype=application/octet-stream|size=18|encoding=UTF-8</a></td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}content</td><td>
<table id="properties_3:valueTypes" border="0" cellspacing="0">
<tbody id="properties_3:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}versionLabel</td><td>
<table id="properties_4:values" border="0" cellspacing="0">
<tbody id="properties_4:values:tbody_element">
<tr><td>1.0</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_4:valueTypes" border="0" cellspacing="0">
<tbody id="properties_4:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}title</td><td>
<table id="properties_5:values" border="0" cellspacing="0">
<tbody id="properties_5:values:tbody_element">
<tr><td>AWE's document</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_5:valueTypes" border="0" cellspacing="0">
<tbody id="properties_5:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{custom.model}language</td><td>
<table id="properties_6:values" border="0" cellspacing="0">
<tbody id="properties_6:values:tbody_element">
<tr><td>EN</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_6:valueTypes" border="0" cellspacing="0">
<tbody id="properties_6:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}lockOwner</td><td>
<table id="properties_7:values" border="0" cellspacing="0">
<tbody id="properties_7:values:tbody_element">
<tr><td>admin</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_7:valueTypes" border="0" cellspacing="0">
<tbody id="properties_7:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}created</td><td>
<table id="properties_8:values" border="0" cellspacing="0">
<tbody id="properties_8:values:tbody_element">
<tr><td>Thu Apr 20 10:05:44 CEST 2006</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}datetime</td><td>
<table id="properties_8:valueTypes" border="0" cellspacing="0">
<tbody id="properties_8:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}modifier</td><td>
<table id="properties_9:values" border="0" cellspacing="0">
<tbody id="properties_9:values:tbody_element">
<tr><td>admin</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_9:valueTypes" border="0" cellspacing="0">
<tbody id="properties_9:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}expiryDate</td><td>
<table id="properties_10:values" border="0" cellspacing="0">
<tbody id="properties_10:values:tbody_element">
<tr><td><span class="errorMessage">–null–</span></td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}date</td><td>
<table id="properties_10:valueTypes" border="0" cellspacing="0">
<tbody id="properties_10:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}initialVersion</td><td>
<table id="properties_11:values" border="0" cellspacing="0">
<tbody id="properties_11:values:tbody_element">
<tr><td>false</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}boolean</td><td>
<table id="properties_11:valueTypes" border="0" cellspacing="0">
<tbody id="properties_11:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}modified</td><td>
<table id="properties_12:values" border="0" cellspacing="0">
<tbody id="properties_12:values:tbody_element">
<tr><td>Thu Apr 20 10:05:45 CEST 2006</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}datetime</td><td>
<table id="properties_12:valueTypes" border="0" cellspacing="0">
<tbody id="properties_12:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}creator</td><td>
<table id="properties_13:values" border="0" cellspacing="0">
<tbody id="properties_13:values:tbody_element">
<tr><td>admin</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_13:valueTypes" border="0" cellspacing="0">
<tbody id="properties_13:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/system/1.0}store-protocol</td><td>
<table id="properties_14:values" border="0" cellspacing="0">
<tbody id="properties_14:values:tbody_element">
<tr><td>workspace</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_14:valueTypes" border="0" cellspacing="0">
<tbody id="properties_14:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}autoVersion</td><td>
<table id="properties_15:values" border="0" cellspacing="0">
<tbody id="properties_15:values:tbody_element">
<tr><td>false</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}boolean</td><td>
<table id="properties_15:valueTypes" border="0" cellspacing="0">
<tbody id="properties_15:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}name</td><td>
<table id="properties_16:values" border="0" cellspacing="0">
<tbody id="properties_16:values:tbody_element">
<tr><td>AWE test EP concrete doc</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_16:valueTypes" border="0" cellspacing="0">
<tbody id="properties_16:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr>
<tr><td>{http://www.alfresco.org/model/system/1.0}store-identifier</td><td>
<table id="properties_17:values" border="0" cellspacing="0">
<tbody id="properties_17:values:tbody_element">
<tr><td>SpacesStore</td></tr></tbody></table>
</td><td>{http://www.alfresco.org/model/dictionary/1.0}text</td><td>
<table id="properties_17:valueTypes" border="0" cellspacing="0">
<tbody id="properties_17:valueTypes:tbody_element">
<tr><td></td></tr></tbody></table>
</td><td>false</td></tr></tbody></table>


<br>
<span class="mainTitle">Aspects</span>


<table id="aspects">
<tbody id="aspects:tbody_element">
<tr><td>{http://www.alfresco.org/model/content/1.0}auditable</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}lockable</td></tr>
<tr><td>{http://www.alfresco.org/model/system/1.0}referenceable</td></tr>
<tr><td>{http://www.alfresco.org/model/content/1.0}versionable</td></tr></tbody></table>


<br>
<span class="mainTitle">Permissions</span>

<table>
<tr>
<td><b>Inherit:</b></td><td><span id="inheritPermissions">true</span></td>
</tr>
</table>

<br>

<table id="permissions" border="1">
<thead>
<tr><th>Assigned Permission</th><th>To Authority</th><th>Access</th></tr></thead>
<tbody id="permissions:tbody_element"></tbody></table>


<br>
<span class="mainTitle">Children</span>


<table id="children" border="1">
<thead>
<tr><th>Child Name</th><th>Child Node</th><th>Primary</th><th>Association Type</th><th>Index</th></tr></thead>
<tbody id="children:tbody_element"></tbody></table>


<br>
<span class="mainTitle">Associations</span>


<table id="assocs" border="1">
<thead>
<tr><th>To Node</th><th>Association Type</th></tr></thead>
<tbody id="assocs:tbody_element"></tbody></table>


<br>
<span class="mainTitle">Parents</span>


<table id="parents" border="1">
<thead>
<tr><th>Child Name</th><th>Parent Node</th><th>Primary</th><th>Association Type</th></tr></thead>
<tbody id="parents:tbody_element">
<tr><td>{http://www.alfresco.org/model/content/1.0}aweTestDoc</td><td><a href="#" onclick="clear_linkDummyForm();document.forms['linkDummyForm'].elements['linkDummyForm:_link_hidden_'].value='parents_0:selectParent';if(document.forms['linkDummyForm'].onsubmit){if(document.forms['linkDummyForm'].onsubmit()) document.forms['linkDummyForm'].submit();}else{document.forms['linkDummyForm'].submit();}return false;" id="parents_0:selectParent">workspace://SpacesStore/774ba32a-d044-11da-b480-29c273d29d12</a></td><td>true</td><td>{http://www.alfresco.org/model/content/1.0}contains</td></tr></tbody></table>


<br>
<form id="linkDummyForm" name="linkDummyForm" style="display:inline" method="post" action="/alfresco/faces/jsp/admin/node-browser.jsp"><input type="hidden" name="linkDummyForm:_link_hidden_" /><script type="text/javascript"><!–
function clear_linkDummyForm() {
  var f = document.forms['linkDummyForm'];
  f.elements['linkDummyForm:_link_hidden_'].value='';
  f.target='';
}
clear_linkDummyForm();
//–></script></form>

<center><a href='http://www.alfresco.com'><img border=0 alt='' title='Content managed by Alfresco' align=absmiddle src='/alfresco/images/logo/alfresco_logo.gif'></a> <span style='font-family:Arial,Helvetica,sans-serif;font-size:10px'>Alfresco Software Inc. ? 2005 All rights reserved.</span></center>
</body></html>

steel
Champ in-the-making
Champ in-the-making
I am having the same problem.

davidc
Star Contributor
Star Contributor
I've raised the following JIRA Issue http://www.alfresco.org/jira/browse/AR-659.

Could you add any further details on how to reproduce to the JIRA issue.

Thanks.

steel
Champ in-the-making
Champ in-the-making
My code is:

  documentNode.checkout();
            documentNode.setProperty("cm:content", version.getContent());
            Version newVersion = documentNode.checkin();

I will investigate some more.  On another note can you provide some details on how the lightweightversion store works?

I am migrating some documents over from another type of repository, and would like to just create the version nodes myself rather than doing a checkin/checkout each time for the new version as I have specific version labels as well.

thanks.

steel
Champ in-the-making
Champ in-the-making
I've raised the following JIRA Issue http://www.alfresco.org/jira/browse/AR-659.

Could you add any further details on how to reproduce to the JIRA issue.

Thanks.

Link doesn't work.

davidc
Star Contributor
Star Contributor
Oops, there's a trailing full stop in the URL.

Try this…

http://www.alfresco.org/jira/browse/AR-659

davidc
Star Contributor
Star Contributor
The problem here is that the JCR API is following the versioning semantics of the JSR-170 specification, which are different to those exposed in the Alfresco Web Client.  When a JSR-170 node supports mix:versionable, it is locked whilst checked-in and unlocked whilst checked-out.  Essentially, you are seeing the checked-in item in the Web Client, but it's locked, which is why there's a lock icon and no associated working copy.

The workaround for Alfresco Web Client compatibility is to assign the cm:versionable aspect via the JSR-170 api, and then use the Alfresco native api calls on the COCIService to checkin/out.  This will provide the same behaviour as exhibited in the web client.

It's possible to mix JCR/Alfresco native api calls as described in http://wiki.alfresco.com/wiki/Introducing_the_Alfresco_Java_Content_Repository_API#Mixing_JCR_and_Al....

davidc
Star Contributor
Star Contributor
> I am migrating some documents over from another type of repository, and would like to just create the version nodes myself rather than doing a checkin/checkout each time for the new version as I have specific version labels as well.

You might be able to use the Alfresco VersionService interface directly to create versions of a node.  I think you can set the version label too.

An alternative approach is to use the Importer to populate the version store directly.  For an example of the xml, you can perform a 'Complete Repository Export' in v1.3 and view the contents of the file 'xxx_version.acp'.