<?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 how to check the file exists or not in the repository in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273543#M226673</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using alfresco for a quite few days. I have learned many things from forums and Alfresco guide.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But presently I am facing a problem. In the alfresco repository I am able to download, upload, do versioning, search etc etc. but the problem is of duplicate entries. If the file already exists in the repository its obviously throw me an exception saying "DUPLICATE ENTRY". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here i want to check the existence of file in the repository. For this I tried many things, but could not yield proper results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anybody here help me out in checking the existence of file in the repository. If the file exists then it should throw me user defined error that file already exists, if not simply adding the file into the repository.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I appreciate and thankful to all the users and alfresco engineers who directly or indirectly helped me in learning from the scratch about Alfresco Content Management.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance and waiting for a positive reply&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HCL power&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Dec 2010 05:15:40 GMT</pubDate>
    <dc:creator>hclpower</dc:creator>
    <dc:date>2010-12-28T05:15:40Z</dc:date>
    <item>
      <title>how to check the file exists or not in the repository</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273543#M226673</link>
      <description>Hi Everyone,I am using alfresco for a quite few days. I have learned many things from forums and Alfresco guide.But presently I am facing a problem. In the alfresco repository I am able to download, upload, do versioning, search etc etc. but the problem is of duplicate entries. If the file already e</description>
      <pubDate>Tue, 28 Dec 2010 05:15:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273543#M226673</guid>
      <dc:creator>hclpower</dc:creator>
      <dc:date>2010-12-28T05:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to check the file exists or not in the repository</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273544#M226674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Code below shows how to know if the node with specific name already exists.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;space = new Reference(WORKSPACE_STORE, null, pathToNode); // Example: /app:company_home/cm:folder1/cm:folder11&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Node[] nodeArray = getRepositoryService().get(new Predicate(new Reference[] { space }, WORKSPACE_STORE, null));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;space = nodeArray[0].getReference();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// If you get to here node already exists&lt;BR /&gt;} catch (Exception e) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// If Exception is thrown node with that name/path does not exist.&lt;BR /&gt;}&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Dec 2010 08:41:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273544#M226674</guid>
      <dc:creator>jcustovic</dc:creator>
      <dc:date>2010-12-28T08:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to check the file exists or not in the repository</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273545#M226675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot jcustovic &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the above code, but no results&amp;nbsp; jcustovic .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you please eloborate it clearly&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thankx&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;HCLPower&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Dec 2010 09:29:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273545#M226675</guid>
      <dc:creator>hclpower</dc:creator>
      <dc:date>2010-12-28T09:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to check the file exists or not in the repository</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273546#M226676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For example you want to create a space with name "TestSpace" in company home if it doesn't exist or if it exists just get the reference (you may want to update it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;Reference space = null;&lt;BR /&gt;try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;space = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:TestSpace");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Node[] nodeArray = getRepositoryService().get(new Predicate(new Reference[] { space }, WORKSPACE_STORE, null));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;space = nodeArray[0].getReference();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Space " + space.getPath() + " exists. No need to create it.");&lt;BR /&gt;} catch (Exception e) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Space doesn't exist… Lets create it.");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ParentReference companyHome = new ParentReference(WORKSPACE_STORE, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;companyHome.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "TestSpace"));&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, "TestSpace")) };&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;CMLCreate create = new CMLCreate("1", companyHome, null, Constants.ASSOC_CONTAINS, null, spaceTypeQName, properties);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;CML cml = new CML();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cml.setCreate(new CMLCreate[] { create });&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;UpdateResult[] results = getRepositoryService().update(cml);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Space " + results[0] + " created.");&lt;BR /&gt;}&lt;BR /&gt;System.out.println("I got reference to " + space.getPath());&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;/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;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>Tue, 28 Dec 2010 09:52:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273546#M226676</guid>
      <dc:creator>jcustovic</dc:creator>
      <dc:date>2010-12-28T09:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to check the file exists or not in the repository</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273547#M226677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jan Čustović&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It really works. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering can i write code in Exception or not, as i never did in my programming.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways thanks a lott Jan Čustović&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;HCLPower&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Dec 2010 10:58:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-to-check-the-file-exists-or-not-in-the-repository/m-p/273547#M226677</guid>
      <dc:creator>hclpower</dc:creator>
      <dc:date>2010-12-28T10:58:30Z</dc:date>
    </item>
  </channel>
</rss>

