Bug in executing inplace import in Windows environment

25 views
Skip to first unread message

Deepak R

unread,
Aug 24, 2017, 1:54:58 PM8/24/17
to Alfresco Bulk Import Tool
Hi Peter,
  Thanks for this excellent tool. I downloaded this for evaluation and works great. I found a bug when using the in window 7 OS with Alfresco enterprise 5.2.1 version. After setting source data as per documentation tool always did Streaming import the problem for this is there is mismatch between ContentStore and Source Directory file path which is used to check weather inplace is possible or not. I think the way alfresco returns content store file path is different from the way source directory path is determined. When I printed values for Content Store path and File Store path in logs I got below values. I think we should correct the methods that generates these paths based on OS.

 Source Directory: C:\\alfrescoenterprise\\alf_data\\contentstore\\Sample Pictures
Content Store: C:/ALFRES~1/alf_data/contentstore

Peter Monks

unread,
Aug 24, 2017, 3:07:38 PM8/24/17
to alfresco-bulk-f...@googlegroups.com
G'day Deepak,

That shouldn't matter, since the tool doesn't do naive String comparisons for this (as you say, this is highly unlikely to work correctly across OSes).  Instead the tool constructs java.io.File objects and walks the tree, comparing paths to see if they become congruent.  You can see the actual code here [1].

Cheers,
Peter


--
You received this message because you are subscribed to the Google Groups "Alfresco Bulk Import Tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesystem-import+unsubscribe@googlegroups.com.
To post to this group, send email to alfresco-bulk-filesystem-imp...@googlegroups.com.
Visit this group at https://groups.google.com/group/alfresco-bulk-filesystem-import.
For more options, visit https://groups.google.com/d/optout.

Deepak R

unread,
Aug 25, 2017, 9:24:06 AM8/25/17
to Alfresco Bulk Import Tool
Hi Peter,
   Thanks for your response. I think the issue is with Java file equals method.From Java API documentation.

 
_______________________________________________________________
public boolean equals(Object obj)
Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is an abstract pathname that denotes the same file or directory as this abstract pathname. Whether or not two abstract pathnames are equal depends upon the underlying system. On UNIX systems, alphabetic case is significant in comparing pathnames; on Microsoft Windows systems it is not.
________________________________________________________________________________________
I compared using canonical paths and it worked in Windows system.  (My changes in bold)

 private final static boolean isInDirectoryImpl(final File directory, final File suspectedChild)
    {
        boolean result = false;
       
        if (directory != null && suspectedChild != null)
        {
            try {
            if (suspectedChild.getCanonicalPath().equals(directory.getCanonicalPath()))
            {
                result = true;
            }
            else
            {
                result = isInDirectoryImpl(directory, suspectedChild.getParentFile());//true;
            }
        }
        catch(IOException ie) {
           
        }
        }
        return(result);
    }


Thanks,
Deepak

Peter Monks

unread,
Aug 25, 2017, 11:51:21 AM8/25/17
to alfresco-bulk-f...@googlegroups.com
What do you think about using java.io.File.isSameFile() instead?  That's relatively new (added Java 1.7), but seems to do exactly what's needed.

Cheers,
Peter

To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesystem-import+unsu...@googlegroups.com.
To post to this group, send email to alfresco-bulk-filesystem-import...@googlegroups.com.

Deepak R

unread,
Aug 26, 2017, 12:02:04 PM8/26/17
to Alfresco Bulk Import Tool
Yeah this should work. Only catch is that this method will not check weather the files exist during execution. But since you are mandating we should not touch source files during batch run this should work.

regards,
Deepak
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesystem-import+unsubscribe@googlegroups.com.
To post to this group, send email to alfresco-bulk-filesystem-imp...@googlegroups.com.
Visit this group at https://groups.google.com/group/alfresco-bulk-filesystem-import.
For more options, visit https://groups.google.com/d/optout.

Peter Monks

unread,
Aug 26, 2017, 2:04:14 PM8/26/17
to alfresco-bulk-f...@googlegroups.com
Recall that this logic is run once, at the commencement of an import, to determine whether the source directory is "within" Alfresco's configured content store.  If that condition somehow changes mid-import then you have much bigger problems on your hands.  😉

Cheers,
Peter

Apologes for speling & gramar erorrs - sent from mobil deivce
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesys...@googlegroups.com.
To post to this group, send email to alfresco-bulk-f...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages