Changeset 18606 for gli

Show
Ignore:
Timestamp:
02.03.2009 13:41:33 (11 years ago)
Author:
kjdon
Message:

when basing a collection on an existing one, don't add the default/required metadata sets. Just use what the base collection uses. Also, copy over all dirs apart from listed ones. Previously just copied images and macros, but there may be other arbitrary dirs, eg style, so just copy all that we don't know about

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gli/trunk/src/org/greenstone/gatherer/collection/CollectionManager.java

    r18412 r18606  
    419419 
    420420    /** When basing a new collection on an existing one, we need to copy  
    421      *  over some extra directories: images and macros   
     421     *  over some extra directories: all except import, archives, building, index  
     422     * really we just want images, macros, perllib, but there may also be eg style, or other dirs. 
    422423     */ 
    423424    private boolean copyExtraBaseCollStuff(File new_coll_dir, File base_coll_dir) { 
     
    425426        return false; 
    426427    } 
    427     DebugStream.println("Copying images and macros dirs from the base collection"); 
    428     try { 
    429         // do the images dir 
    430         File base_coll_images = new File(base_coll_dir, "images"); 
    431         if (base_coll_images.isDirectory()) { 
    432         // copy all the images over 
    433         File new_coll_images = new File(new_coll_dir, "images"); 
    434         new_coll_images.mkdirs(); 
    435          
    436         // copy the contents over 
    437         Gatherer.f_man.getQueue().copyDirectoryContents(base_coll_images, new_coll_images); 
    438         } 
    439     } 
    440     catch (Exception e) { 
    441         DebugStream.println("Couldn't copy over the images dir from the base collection: "+e.toString()); 
    442     } 
    443     try { 
    444         // do the macros dir 
    445         File base_coll_macros = new File(base_coll_dir, "macros"); 
    446         if (base_coll_macros.isDirectory()) { 
    447         // copy all the macros over 
    448         File new_coll_macros = new File(new_coll_dir, "macros"); 
    449         new_coll_macros.mkdirs(); 
    450          
    451         // copy the contents over 
    452         Gatherer.f_man.getQueue().copyDirectoryContents(base_coll_macros, new_coll_macros); 
    453         }  
    454     } 
    455     catch (Exception e) { 
    456         DebugStream.println("Couldn't copy over the macros dir from the base collection: "+e.toString()); 
    457     } 
     428    DebugStream.println("Copying extra dirs from the base collection"); 
     429     
     430     
     431    File subdirs[] = base_coll_dir.listFiles(); 
     432    for (int i = 0; subdirs != null && i < subdirs.length; i++) { 
     433      File subdir = subdirs[i]; 
     434      if (subdir.isDirectory()) { 
     435        String dir_name = subdir.getName(); 
     436        // ignore those we don't need, (archives, buildng, index) and  
     437        // those we are handling in another place (import, etc, metadata) 
     438        if (dir_name.startsWith ("import") || dir_name.startsWith("archives") || dir_name.startsWith("building") || dir_name.startsWith("index") || dir_name.startsWith("etc") || dir_name.startsWith("metadata") || dir_name.startsWith("log") || dir_name.startsWith("tmp")) { 
     439          continue; 
     440        } 
     441        try { 
     442          // copy the directory 
     443          File new_coll_subdir = new File(new_coll_dir, dir_name); 
     444          new_coll_subdir.mkdirs(); 
     445          Gatherer.f_man.getQueue().copyDirectoryContents(subdir, new_coll_subdir); 
     446        } 
     447        catch (Exception e) { 
     448          DebugStream.println("Couldn't copy over the" + subdir+" dir from the base collection: "+e.toString()); 
     449        } 
     450      } 
     451    } 
     452 
    458453    return true; 
    459454    } 
    460  
     455   
    461456    /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the collection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl. 
    462457     * @param description a description of the collection as a String 
     
    613608        } 
    614609        } 
    615  
    616         // Load the default metadata sets 
    617         addDefaultMetadataSets(); 
    618  
    619         // Make sure we always have the extracted metadata set 
    620         addRequiredMetadataSets(); 
    621  
     610        else { 
     611          // only load metadata sets here if we have not based the collection on any other. 
     612          // Load the default metadata sets 
     613          addDefaultMetadataSets(); 
     614           
     615          // Make sure we always have the extracted metadata set 
     616          addRequiredMetadataSets(); 
     617        } 
     618         
    622619        collection.cdm = new CollectionDesignManager(new File(getLoadedCollectionCfgFilePath())); 
    623620