<?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: I want to do a POST method when creating a file in a folder. in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116419#M32250</link>
    <description>&lt;P&gt;Instead of making this complex and getting more control over the flow, i would suggest to go with the a custom behavior approach which can listen to node creation event and on create node event it can gather the required info and pass it on to third party system via http post call. You can add validation/check for the specific parent folder node as well if required&lt;/P&gt;
&lt;P&gt;Implementing behvaior :&amp;nbsp;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html#implementing-and-deploying-the-custom-behavior-in-java" target="_blank" rel="noopener nofollow noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html#implementing-and-deploying-the-custom-behavior-in-java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here you can find an example of behvaior which listens to node creation event (&lt;SPAN class="pl-e"&gt;NodeServicePolicies&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN class="pl-e"&gt;OnCreateNodePolicy&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;A href="https://github.com/jpotts/alfresco-developer-series/blob/master/behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/jpotts/alfresco-developer-series/blob/master/behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;A similar example can be found here as well:&amp;nbsp;&lt;A href="https://github.com/jpotts/alfresco-kafka/blob/master/alfresco-kafka-repo/src/main/java/com/metaversant/kafka/behavior/GenerateNodeEvent.java" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/jpotts/alfresco-kafka/blob/master/alfresco-kafka-repo/src/main/java/com/metaversant/kafka/behavior/GenerateNodeEvent.java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;your implementation could be something like;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;public class CreateObjectBehaviour implements
		&lt;STRONG&gt;NodeServicePolicies.OnCreateNodePolicy&lt;/STRONG&gt;, InitializingBean {

	private final NodeService nodeService;
	private final PolicyComponent policyComponent;

	public CreateObjectBehaviour(final ServiceRegistry serviceRegistry,
			final PolicyComponent policyComponent) {
		this.nodeService = serviceRegistry.getNodeService();
		this.policyComponent = policyComponent;
	}

	@Override
	public void afterPropertiesSet() {
		//You can bind on custom types as well based on your requirement. 
		policyComponent.bindClassBehaviour(NodeServicePolicies.OnCreateNodePolicy.QNAME,
				ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT));
	}

	@Override
	public void &lt;STRONG&gt;onCreateNode&lt;/STRONG&gt;(final ChildAssociationRef childAssocRef) {
		final NodeRef createdNode = childAssocRef.getChildRef();
		if (nodeService.exists(createdNode)) {
			&lt;STRONG&gt;//TODO:: 
			//Get the information from created node
			//Prepare the post call payload as needed
			//Send post request&lt;/STRONG&gt;
		}
	}
}
&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 May 2020 23:49:56 GMT</pubDate>
    <dc:creator>abhinavmishra14</dc:creator>
    <dc:date>2020-05-27T23:49:56Z</dc:date>
    <item>
      <title>I want to do a POST method when creating a file in a folder.</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116416#M32247</link>
      <description>&lt;P&gt;Greetings guys.&lt;/P&gt;&lt;P&gt;I want to execute a "POST" method when creating a file in an Alfresco folder.&amp;nbsp;I need to send Alfresco data for a web page. In folder rules I have an option to call a JavaScript function. I thought about doing a POST method with Jquery but it doesn't work for me because it blocks it in Backend.&amp;nbsp;So I am very confused. I can't find a way to do it.&amp;nbsp;The only option I have in the folder rules is JavaScript, so with JavaScript they should call another function in Java maybe?&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 19:17:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116416#M32247</guid>
      <dc:creator>viperboys</dc:creator>
      <dc:date>2020-05-25T19:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: I want to do a POST method when creating a file in a folder.</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116417#M32248</link>
      <description>&lt;P&gt;Can you elaborate little bit, what you want to achieve?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;From what i can understand, you have a folder in repository where there is folder rule when gets fired on content upload. And you want to use a http post call from within rules on event of content upload, right?&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 21:57:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116417#M32248</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-05-25T21:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: I want to do a POST method when creating a file in a folder.</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116418#M32249</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/74498"&gt;@abhinavmishra14&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's correct&lt;/P&gt;&lt;P&gt;I share some images with you.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alfresco » Ficheros compartidos - Google Chrome 2020-05-27 18.02.02.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/670iB8FC6D7CCA60F5BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Alfresco » Reglas de carpeta - Google Chrome 2020-05-13 12.08.28.png" style="width: 971px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/669iB792633D29839A53/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;From a JavaScript code execute a POST method that sends data to a website made in WordPress.&amp;nbsp;I thought it could be done like this. At first I created a POST method with AJAX but it didn't work.&lt;/P&gt;&lt;P&gt;So I'm very confused on how I could do this.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2020 22:17:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116418#M32249</guid>
      <dc:creator>viperboys</dc:creator>
      <dc:date>2020-05-27T22:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: I want to do a POST method when creating a file in a folder.</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116419#M32250</link>
      <description>&lt;P&gt;Instead of making this complex and getting more control over the flow, i would suggest to go with the a custom behavior approach which can listen to node creation event and on create node event it can gather the required info and pass it on to third party system via http post call. You can add validation/check for the specific parent folder node as well if required&lt;/P&gt;
&lt;P&gt;Implementing behvaior :&amp;nbsp;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html#implementing-and-deploying-the-custom-behavior-in-java" target="_blank" rel="noopener nofollow noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html#implementing-and-deploying-the-custom-behavior-in-java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here you can find an example of behvaior which listens to node creation event (&lt;SPAN class="pl-e"&gt;NodeServicePolicies&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN class="pl-e"&gt;OnCreateNodePolicy&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;A href="https://github.com/jpotts/alfresco-developer-series/blob/master/behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/jpotts/alfresco-developer-series/blob/master/behaviors/behavior-tutorial/behavior-tutorial-platform/src/main/java/com/someco/behavior/Rating.java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;A similar example can be found here as well:&amp;nbsp;&lt;A href="https://github.com/jpotts/alfresco-kafka/blob/master/alfresco-kafka-repo/src/main/java/com/metaversant/kafka/behavior/GenerateNodeEvent.java" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/jpotts/alfresco-kafka/blob/master/alfresco-kafka-repo/src/main/java/com/metaversant/kafka/behavior/GenerateNodeEvent.java&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;your implementation could be something like;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;public class CreateObjectBehaviour implements
		&lt;STRONG&gt;NodeServicePolicies.OnCreateNodePolicy&lt;/STRONG&gt;, InitializingBean {

	private final NodeService nodeService;
	private final PolicyComponent policyComponent;

	public CreateObjectBehaviour(final ServiceRegistry serviceRegistry,
			final PolicyComponent policyComponent) {
		this.nodeService = serviceRegistry.getNodeService();
		this.policyComponent = policyComponent;
	}

	@Override
	public void afterPropertiesSet() {
		//You can bind on custom types as well based on your requirement. 
		policyComponent.bindClassBehaviour(NodeServicePolicies.OnCreateNodePolicy.QNAME,
				ContentModel.TYPE_CONTENT, new JavaBehaviour(this, "onCreateNode", NotificationFrequency.EVERY_EVENT));
	}

	@Override
	public void &lt;STRONG&gt;onCreateNode&lt;/STRONG&gt;(final ChildAssociationRef childAssocRef) {
		final NodeRef createdNode = childAssocRef.getChildRef();
		if (nodeService.exists(createdNode)) {
			&lt;STRONG&gt;//TODO:: 
			//Get the information from created node
			//Prepare the post call payload as needed
			//Send post request&lt;/STRONG&gt;
		}
	}
}
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 May 2020 23:49:56 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116419#M32250</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-05-27T23:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: I want to do a POST method when creating a file in a folder.</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116420#M32251</link>
      <description>&lt;P&gt;Hello &lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/80230"&gt;@viperboys&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you manage to do it at the end? I'm stuck in the same place, I could really use some help.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 15:19:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/i-want-to-do-a-post-method-when-creating-a-file-in-a-folder/m-p/116420#M32251</guid>
      <dc:creator>imanez1</dc:creator>
      <dc:date>2023-04-12T15:19:18Z</dc:date>
    </item>
  </channel>
</rss>

