Changeset 28942

Show
Ignore:
Timestamp:
01/11/08 10:44:02 (11 months ago)
Author:
rdarlea
Message:

NXP-1688 restore lost code from 1.3.4 and properly check the existence of the document upon import action.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.ecm.core/trunk/nuxeo-core-io/src/main/java/org/nuxeo/ecm/core/io/impl/AbstractDocumentReader.java

    r24938 r28942  
    4444                break; 
    4545            } 
    46             docs.add(doc); 
     46             
     47            /*NXP-1688 Rux: no ID, it should be a OS folder and not an exported one*/ 
     48            if (doc.getId() != null) 
     49                docs.add(doc); 
    4750        } 
    4851        if (docs.isEmpty()) { 
  • org.nuxeo.ecm.core/trunk/nuxeo-core-io/src/main/java/org/nuxeo/ecm/core/io/impl/plugins/DocumentModelWriter.java

    r27340 r28942  
    8787            Path targetPath) throws ClientException { 
    8888 
    89         DocumentModel previousDoc; 
     89        DocumentModel previousDoc = null; 
     90        /*NXP-1688 Rux: if the document doesn't exist, the thrown ClientException is 
     91         * wrapped. Instead, an explicit query about the existence should do the job. 
     92         */ 
     93        PathRef pathRef = new PathRef(targetPath.toString()); 
    9094        try { 
    91             previousDoc = session.getDocument(new PathRef(targetPath.toString())); 
    92         } catch (ClientException e) { 
     95            if (session.exists(pathRef)) 
     96                previousDoc = session.getDocument(pathRef); 
     97        } catch (ClientException ce) { 
     98            //don't care, document considered inexistent 
    9399            previousDoc = null; 
    94100        } 
    95  
     101         
    96102        DocumentModel doc; 
    97103        if (previousDoc == null) { 
  • org.nuxeo.ecm.core/trunk/nuxeo-core-io/src/main/java/org/nuxeo/ecm/core/io/impl/plugins/XMLDirectoryReader.java

    r28190 r28942  
    3131import org.nuxeo.common.utils.FileTreeIterator; 
    3232import org.nuxeo.common.utils.FileUtils; 
     33import org.nuxeo.common.utils.Path; 
    3334import org.nuxeo.ecm.core.api.impl.blob.StreamingBlob; 
    3435import org.nuxeo.ecm.core.io.api.ExportConstants; 
     
    9192                        Document doc = loadXML(file); 
    9293                        xdoc.setDocument(doc); 
     94                        /*NXP-1688 Rux: the path was somehow left over when migrated from 
     95                          core 1.3.4 to 1.4.0. Pull back.*/ 
     96                        xdoc.setPath(computeRelativePath(dir)); 
    9397                    } else if (name.endsWith(".xml")) { 
    9498                        xdoc.putDocument( 
     
    106110    } 
    107111 
     112    /*NXP-1688 Rux: the path was somehow left over when migrated from 
     113    core 1.3.4 to 1.4.0. Pull back.*/ 
     114    private Path computeRelativePath(File file) { 
     115        return new Path( 
     116                file.getAbsolutePath().substring(source.getAbsolutePath().length())); 
     117    } 
     118     
     119     
    108120    private static Document loadXML(File file) throws IOException { 
    109121        BufferedInputStream in = null;