<?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: JavaAPI for assigning content store in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87775#M26404</link>
    <description>&lt;P&gt;Where are you using that Java code? Inside a behaviour?&lt;/P&gt;
&lt;P&gt;There is no need to save in Java API, as it's included on a DB Transaction that will be commited eventually.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Feb 2020 11:22:04 GMT</pubDate>
    <dc:creator>angelborroy</dc:creator>
    <dc:date>2020-02-25T11:22:04Z</dc:date>
    <item>
      <title>JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87774#M26403</link>
      <description>&lt;P&gt;Hi there ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to convert&amp;nbsp; javascript API&amp;nbsp; code&amp;nbsp; to&amp;nbsp; java API &amp;nbsp;which move files to different content store('&amp;nbsp;storeB').&amp;nbsp; &amp;nbsp;We have&amp;nbsp; storeB defined in&amp;nbsp; - 'content-store-selector-context.xml'.&amp;nbsp; We are using Enterrprises version of Alfresco 5.2.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;java script code as follows ,&amp;nbsp; &amp;nbsp;- Works perfectly fine . its working code.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; for each (var n in node.children) {
          if (n.isDocument) {
			  
             	       //Apply script for moving files to DMS Store 01   
			n.removeAspect("cm:versionable");
			n.addAspect("cm:storeSelector");
			n.properties['cm:storeName'] = "storeB";	  
			&lt;STRONG&gt;n.save();	&lt;/STRONG&gt;		  
          }
     }&lt;/PRE&gt;&lt;P&gt;Java API Code&amp;nbsp; -&amp;nbsp;But this code is not moving files to 'storeB'.&amp;nbsp; Is there anything i am missing ? I can see a save method is java script API. Is there any similiar method available in java APIs.&amp;nbsp; is there anything missing in the code ?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;		List&amp;lt;ChildAssociationRef&amp;gt; children = nodeService.getChildAssocs(dayFolderRef);
		Map&amp;lt;QName, Serializable&amp;gt; aspectsProps = new HashMap&amp;lt;QName, Serializable&amp;gt;(1);
		aspectsProps.put(ContentModel.PROP_STORE_NAME, "storeB");
		LOG.info("Folder::" + dayFolderRef.getId());
		LOG.info("Number of Subfolder to be moved is ::" + children.size());
		for (ChildAssociationRef childAssoc : children) {
			NodeRef childNodeRef = childAssoc.getChildRef();
			if (ContentModel.TYPE_CONTENT.equals(nodeService.getType(childNodeRef))) {
				LOG.info("Moving the file to secondary storae "+childNodeRef.getId());
				nodeService.removeAspect(childNodeRef, ContentModel.ASPECT_VERSIONABLE);
				nodeService.addAspect(childNodeRef, ContentModel.ASPECT_STORE_SELECTOR, aspectsProps);				
				
			}
		}&lt;/PRE&gt;&lt;P&gt;Thanks ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brijesh&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 14:44:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87774#M26403</guid>
      <dc:creator>brijeshnk</dc:creator>
      <dc:date>2020-02-24T14:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87775#M26404</link>
      <description>&lt;P&gt;Where are you using that Java code? Inside a behaviour?&lt;/P&gt;
&lt;P&gt;There is no need to save in Java API, as it's included on a DB Transaction that will be commited eventually.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 11:22:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87775#M26404</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2020-02-25T11:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87776#M26405</link>
      <description>&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/5487"&gt;@angelborroy&lt;/A&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;thanks for the reponse. This is an action class triggered by scheduler .&amp;nbsp;&amp;nbsp; As soon as after executing this i was checking in DB using following query&lt;/P&gt;&lt;P&gt;SELECT * FROM alf_content_url WHERE orphan_time IS NOT NULL;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before and after quey result is same.&lt;/P&gt;&lt;P&gt;After execution of above mentioned code, I was exepecting&amp;nbsp; query&amp;nbsp; to return higher number&amp;nbsp; , as number of nodes become orhan.&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 12:41:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87776#M26405</guid>
      <dc:creator>brijeshnk</dc:creator>
      <dc:date>2020-02-25T12:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87777#M26406</link>
      <description>&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/5487"&gt;@angelborroy&lt;/A&gt;&amp;nbsp; ,&amp;nbsp; you mentioned above 'Transaction that will be commited eventually' . Is there time lag to commit transaction ? is it not immiedately after execting the code or wait for some other process to complete ?&amp;nbsp; code is executed inside an action method , inititated by scheduler.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 11:43:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87777#M26406</guid>
      <dc:creator>brijeshnk</dc:creator>
      <dc:date>2020-02-26T11:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87778#M26407</link>
      <description>&lt;P&gt;The transaction will be commited once the executeJob method is finished.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/community/references/dev-extension-points-scheduled-jobs.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://docs.alfresco.com/community/references/dev-extension-points-scheduled-jobs.html&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 12:17:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87778#M26407</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2020-02-26T12:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87779#M26408</link>
      <description>&lt;P&gt;the following&amp;nbsp; trick worked&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;setting content store name , using setProperty . See code below&lt;/P&gt;&lt;PRE&gt;nodeService.addAspect(childNodeRef, ContentModel.ASPECT_STORE_SELECTOR , null);
nodeService.setProperty(childNodeRef, ContentModel.PROP_STORE_NAME, "storeB"); &lt;/PRE&gt;&lt;P&gt;Still no idea why earlier code failed .&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 13:17:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87779#M26408</guid>
      <dc:creator>brijeshnk</dc:creator>
      <dc:date>2020-02-27T13:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87780#M26409</link>
      <description>&lt;P&gt;You were adding it also in your JavaScript code, so I guess that it's a required property.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 15:03:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87780#M26409</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2020-02-27T15:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: JavaAPI for assigning content store</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87781#M26410</link>
      <description>&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/5487"&gt;@angelborroy&lt;/A&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;Agree&amp;nbsp; its mandatory and&amp;nbsp; I was adding in java script code , But&amp;nbsp; I was adding content store property in earlier java code- the one which was not working - please&amp;nbsp; see below code:&lt;/P&gt;&lt;PRE&gt;Map&amp;lt;QName, Serializable&amp;gt; aspectsProps = new HashMap&amp;lt;QName, Serializable&amp;gt;(1);&lt;BR /&gt;aspectsProps.put(ContentModel.PROP_STORE_NAME, "storeB"); nodeService.removeAspect(childNodeRef, ContentModel.ASPECT_VERSIONABLE); nodeService.addAspect(childNodeRef, ContentModel.ASPECT_STORE_SELECTOR, aspectsProps);&lt;/PRE&gt;&lt;P&gt;But the , following code works . its pretty much same code but the way i set the property is different . I used here setPreperty for setting conent store -&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;nodeService.removeAspect(childNodeRef, ContentModel.ASPECT_VERSIONABLE);&lt;BR /&gt;nodeService.addAspect(childNodeRef, ContentModel.ASPECT_STORE_SELECTOR , null);
nodeService.setProperty(childNodeRef, ContentModel.PROP_STORE_NAME, "storeB"); &lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 19:41:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/javaapi-for-assigning-content-store/m-p/87781#M26410</guid>
      <dc:creator>brijeshnk</dc:creator>
      <dc:date>2020-02-27T19:41:49Z</dc:date>
    </item>
  </channel>
</rss>

