<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create/Reuse a node in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233124#M186254</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did think of using a child association to connect the generated node to the original node. But the relationship between these two nodes is complicated. Once the second node has been generated based on the first, it (the second node) becomes more important than the first. I might even want to keep it even if the first node is deleted for some reason. And the second node is only going to be generated once all edits have been made to the first node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do like the idea of using declarative code to model the relationship between the nodes, and getting cool stuff for free like cascading updates and deletions. But my particular use doesn't quite fit in. Maybe I should rethink my requirements, so that it does.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Oct 2010 10:01:23 GMT</pubDate>
    <dc:creator>swithun</dc:creator>
    <dc:date>2010-10-27T10:01:23Z</dc:date>
    <item>
      <title>Create/Reuse a node</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233120#M186250</link>
      <description>I'm having difficulty writing to the content of a node, if the node already exists. I have an action which tries create a node and write some content to it based on the node on which the action is run. This is fine if a node with the given name doesn't already exist. But if such a node already exist</description>
      <pubDate>Thu, 14 Oct 2010 09:22:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233120#M186250</guid>
      <dc:creator>swithun</dc:creator>
      <dc:date>2010-10-14T09:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create/Reuse a node</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233121#M186251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I suppose you should check the existence of that particular file with say FileFolderService#searchSimple() BEFORE you attempt to create a new node!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The approach of catching the FileExistsException will not work for the following reason: Usually all actions in Alfresco are executed within some Transaction; if some exception occurs in any of the service invocations, the underlying transaction is marked for rollback. Thus, even if you catch that exception and create some node afterwards, it will be all eventually undone by the Tranaction-Manager…&amp;nbsp; :mrgreen: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Which is usually a good thing, but in cases like yours i sometimes wish the programmer had more control on transaction handling….&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gyro&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 09:47:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233121#M186251</guid>
      <dc:creator>gyro_gearless</dc:creator>
      <dc:date>2010-10-14T09:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create/Reuse a node</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233122#M186252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good advice. Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;fileRef = fileFolderService.searchSimple(dirRef, fileName);&lt;BR /&gt;if (null == fileRef)&lt;BR /&gt;&amp;nbsp; {&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fileRef = fileFolderService.create(dirRef, fileName, PROP_QNAME_CONTENT).getNodeRef();&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;ContentWriter writer = contentService.getWriter(fileRef, ContentModel.PROP_CONTENT, true);&lt;BR /&gt;writer.putContent(output);&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 10:49:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233122#M186252</guid>
      <dc:creator>swithun</dc:creator>
      <dc:date>2010-10-14T10:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create/Reuse a node</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233123#M186253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The previous poster is right: even if you catch exceptions, your transaction may have been marked for rollback, so that's not the way to go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It sounds like you may have made progress on your problem, Swithun. But the description of your action makes me think: Are you using a custom content model? If you have an action that is creating new content - or updating existing content - based on some source node, then a common approach in such a scenario would be to use a custom content model to model that relationship.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, the RenditionService defines an aspect rn:renditioned that defines a child-association to an rn:rendition type. That way, the rendition node being generated/updated is still connected to its source node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Neil.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Oct 2010 10:20:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233123#M186253</guid>
      <dc:creator>neilm</dc:creator>
      <dc:date>2010-10-25T10:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create/Reuse a node</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233124#M186254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did think of using a child association to connect the generated node to the original node. But the relationship between these two nodes is complicated. Once the second node has been generated based on the first, it (the second node) becomes more important than the first. I might even want to keep it even if the first node is deleted for some reason. And the second node is only going to be generated once all edits have been made to the first node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do like the idea of using declarative code to model the relationship between the nodes, and getting cool stuff for free like cascading updates and deletions. But my particular use doesn't quite fit in. Maybe I should rethink my requirements, so that it does.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Oct 2010 10:01:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/create-reuse-a-node/m-p/233124#M186254</guid>
      <dc:creator>swithun</dc:creator>
      <dc:date>2010-10-27T10:01:23Z</dc:date>
    </item>
  </channel>
</rss>

