<?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: How to get noderef of file during file creation in share in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111206#M31054</link>
    <description>&lt;P&gt;Try :&amp;nbsp;org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy&lt;/P&gt;
&lt;P&gt;&lt;U&gt;You can do something like this:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;public void onCreateNode(final ChildAssociationRef childAssocRef) {
	final NodeRef nodeRef = childAssocRef.getChildRef();//node which is being created.
	if (nodeService.exists(nodeRef)) {
		final String fileName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
		final String mimetype = mimetypeService.guessMimetype(fileName); //find mimetype by extension of the file.
		if (restrictedMimeList.contains(mimetype)) {// check whether the result is one of the restricted mime types from the list?
			throw new AlfrescoRuntimeException("Mimetype " + mimetype + " is unsupported");
		}
	}
}&lt;/PRE&gt;</description>
    <pubDate>Mon, 23 Nov 2020 20:51:42 GMT</pubDate>
    <dc:creator>abhinavmishra14</dc:creator>
    <dc:date>2020-11-23T20:51:42Z</dc:date>
    <item>
      <title>How to get noderef of file during file creation in share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111205#M31053</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I have requirement to restrict&amp;nbsp;from creation of exe file.&lt;/P&gt;&lt;P&gt;User is creating plain text file from share UI and entering&amp;nbsp;name like test.exe.&lt;/P&gt;&lt;P&gt;I have created rule that checks if file name ends with exe, it throws exception. But rule is not executing somehow.&lt;/P&gt;&lt;P&gt;Then i have created behaviour that executes on node creation, I am getting parentref using below code.&lt;/P&gt;&lt;PRE&gt;public void init() {
		policyComponent.bindClassBehaviour(NodeServicePolicies.BeforeCreateNodePolicy.QNAME,
				ContentModel.TYPE_CONTENT,
				new JavaBehaviour(this, "beforeCreateNode", Behaviour.NotificationFrequency.EVERY_EVENT));
	}
	
	@Override
	public void beforeCreateNode(NodeRef parentRef, QName assocTypeQName, QName assocQName, QName nodeTypeQName) {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("Started executing FileCreationRestrictionBehaviour ..");
			
			LOGGER.debug("parentref --&amp;gt; "+parentRef);
			
			LOGGER.debug("parentref NAME --&amp;gt; "+nodeService.getProperty(parentRef, ContentModel.PROP_NAME));
			
			System.out.println("parentref --&amp;gt; "+parentRef + 
					"parentref NAME --&amp;gt; "+nodeService.getProperty(parentRef, ContentModel.PROP_NAME));
			
			
		}
		
	}&lt;/PRE&gt;&lt;P&gt;So,my requirement is to restrict&amp;nbsp;file creation, if users enters .exe in file name, how can i get the noderef/filename of that file, so, i can throw exception.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Hardik&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 06:43:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111205#M31053</guid>
      <dc:creator>hardik_thakkar</dc:creator>
      <dc:date>2020-11-23T06:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get noderef of file during file creation in share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111206#M31054</link>
      <description>&lt;P&gt;Try :&amp;nbsp;org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy&lt;/P&gt;
&lt;P&gt;&lt;U&gt;You can do something like this:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;public void onCreateNode(final ChildAssociationRef childAssocRef) {
	final NodeRef nodeRef = childAssocRef.getChildRef();//node which is being created.
	if (nodeService.exists(nodeRef)) {
		final String fileName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
		final String mimetype = mimetypeService.guessMimetype(fileName); //find mimetype by extension of the file.
		if (restrictedMimeList.contains(mimetype)) {// check whether the result is one of the restricted mime types from the list?
			throw new AlfrescoRuntimeException("Mimetype " + mimetype + " is unsupported");
		}
	}
}&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Nov 2020 20:51:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111206#M31054</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-11-23T20:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get noderef of file during file creation in share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111207#M31055</link>
      <description>&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/14220"&gt;@hardik_thakkar&lt;/A&gt;&amp;nbsp; you can also try this add-on which covers several other scenarios while blocking blacklisted mimetypes.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/abhinavmishra14/alfresco-mimetype-blocker/releases" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/abhinavmishra14/alfresco-mimetype-blocker/releases&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;originally forked from&amp;nbsp;&lt;A href="https://github.com/keensoft/alfresco-mimetype-blocker" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/keensoft/alfresco-mimetype-blocker&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 15:41:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111207#M31055</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-11-25T15:41:22Z</dc:date>
    </item>
    <item>
      <title>Hi Re: How to get noderef of file during file creation in share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111208#M31056</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;I have configured that add-on and that works perfectly during file upload part.&lt;BR /&gt;&lt;BR /&gt;Written behaviour for file creation part as per your suggestion&amp;nbsp;and that's working fine.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hardik&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 11:32:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111208#M31056</guid>
      <dc:creator>hardik_thakkar</dc:creator>
      <dc:date>2020-11-27T11:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hi Re: How to get noderef of file during file creation in share</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111209#M31057</link>
      <description>&lt;P&gt;Good to hear that everything works fine for you. Good luck&amp;nbsp;&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/14220"&gt;@hardik_thakkar&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 14:55:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-get-noderef-of-file-during-file-creation-in-share/m-p/111209#M31057</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-11-27T14:55:48Z</dc:date>
    </item>
  </channel>
</rss>

