cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate files and update

sibe
Champ on-the-rise
Champ on-the-rise
Hello,

I want duplicate the same document in differents folders, and together ensure that the contents are upadate if one of them is modify.

I want use association aspect and behaviour.

Thank for yours contributions.
10 REPLIES 10

mitpatoliya
Star Collaborator
Star Collaborator
Well if you want to do with the behavior you can bind the behavior to oncontentupdate policy.and place the logic of replacing the duplicate copy.

If you want to go for the alternate approach one way is via rule.
Create a rule which will create a copy of the any new document at specific location.
Create one more rule which will be invoked on the content update and will execute a script.
That script will search in for the duplicate copy of the document which is going to be updated delete the copy and place the new copy over there.

mrogers
Star Contributor
Star Contributor
Do you want to duplicate a node.  Or share the same node in two folders?   You can do both.

technaton
Champ in-the-making
Champ in-the-making
Do you want to duplicate a node.  Or share the same node in two folders?   You can do both.

Sorry if that is a bit of thread hijacking, but how would one share the same node in two folders?

TIA!

afaust
Legendary Innovator
Legendary Innovator
Hello,

in Alfresco a node can have multiple parents, e.g. child-associations pointing to it. By having multiple child-associations from different folders to the document, it is - for the sake of navigation - shared by all folders without any content duplication. Keep in mind though, that only one of the parent folders - the primary parent - is the one permissions are inherited from.

Regards
Axel

sibe
Champ on-the-rise
Champ on-the-rise
Hi,

mitpatoliya ==> your response is verry important but it's not pratical for my example to put this functionnality by rules.
Here how I want proceed

1. Add a aspect using association

<aspect name="sibe:copyright">
         <title>Copyright</title>
         <properties>
            <property name="sibe:evialia">
               <type>d:text</type>
               <default>TEST</default>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>true</stored>
                  <tokenised>false</tokenised>
               </index>
            </property>
         </properties>
         <associations>
            <association name="sibe:assoc">
               <title>Documents associated</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
            </associations>
      </aspect>


2. Config share-config-custom.xml
And I modify the share-config-custom.xml to view this aspect in share.

<config evaluator="aspect" condition="sibe:copyright">
      <forms>
         <form>
            <field-visibility>
               <show id="sibe:evialia"/>
               <show id="sibe:assoc"/>
            </field-visibility>
            <appearance>
               <set id="sibe-copyrightAspect" appearance="fieldset" label="Sibe Content" />
               <field id="sibe:evialia" read-only="true" set="sibe-copyrightAspect" help="Pour plus d'informations sur ce champ, contactez votre Process Owner" />
               <field id="sibe:assoc" set="sibe-copyrightAspect"> 
                  <control>
                     <control-param name="showTargetLink">true</control-param>
                  </control>
               </field>
            </appearance>
         </form>
      </forms>
   </config>

3. Firstly in share ==> Use Copy Action to copy the document in other space

4. Modify the metadatas to add the documents copy previously as association documents
So I want see the documents duplicate directly in share.

5. My problem is that I want use a behaviour (Java class) to get the documents associated and update content if one of the documents is modify.

I hope that you understan my question.

=======
mrogers ==> Initialy I want share the same node in two or lot of folder and ensure automtically the update content if one of the node copy are modify.

Thank verry much.

mitpatoliya
Star Collaborator
Star Collaborator
then in that case as I mentioned you can use the oncontentupdate policy and associate your custom behaviour to that which will in turn update the associated content whenever the given node is updated.

sibe
Champ on-the-rise
Champ on-the-rise
Thank for your response, but I don't know how I can use the association type with OnContentUpdatePolicy.
I can just use contentService object to get the content but I can't update the other files associated of the current node.

Have you ever realized this kind of action with the Policies ?

Thank

afaust
Legendary Innovator
Legendary Innovator
Hello,

I don't really understand the problem you are having. You are obviously familiar with the content service, one of the foundation services of Alfresco - another foundation service is the node service, with which you can traverse associations between nodes. Using these two services you can access the content on the changed node, look up all associated ones (via your association type) and update their content accordingly.

Regards
Axel

sibe
Champ on-the-rise
Champ on-the-rise
Hello AFaust,

My class implements ContentServicePolicies.OnContentUpdatePolicy
I use contentService but not nodeService object, my question is how I can look up all associated ones(via my association type) with contentService ?

Or else do you think that I must implements other interface ?

Thank you