@@ -442,44 +442,44 @@ protected File downloadStructure(String pdbId) throws IOException{
442442 // decide whether download is required
443443 File existing = getLocalFile (pdbId );
444444 switch (fetchBehavior ) {
445- case LOCAL_ONLY :
446- if ( existing == null ) {
447- throw new IOException (String .format ("Structure %s not found in %s "
448- + "and configured not to download." ,pdbId ,getPath ()));
445+ case LOCAL_ONLY :
446+ if ( existing == null ) {
447+ throw new IOException (String .format ("Structure %s not found in %s "
448+ + "and configured not to download." ,pdbId ,getPath ()));
449+ } else {
450+ return existing ;
451+ }
452+ case FETCH_FILES :
453+ // Use existing if present
454+ if ( existing != null ) {
455+ return existing ;
456+ }
457+ // existing is null, downloadStructure(String,String,boolean,File) will download it
458+ break ;
459+ case FETCH_IF_OUTDATED :
460+ // here existing can be null or not:
461+ // existing == null : downloadStructure(String,String,boolean,File) will download it
462+ // existing != null : downloadStructure(String,String,boolean,File) will check its date and download if older
463+ break ;
464+ case FETCH_REMEDIATED :
465+ // Use existing if present and recent enough
466+ if ( existing != null ) {
467+ long lastModified = existing .lastModified ();
468+
469+ if (lastModified < LAST_REMEDIATION_DATE ) {
470+ // the file is too old, replace with newer version
471+ logger .warn ("Replacing file {} with latest remediated (remediation of {}) file from PDB." ,
472+ existing , LAST_REMEDIATION_DATE_STRING );
473+ existing = null ;
474+ break ;
449475 } else {
450476 return existing ;
451477 }
452- case FETCH_FILES :
453- // Use existing if present
454- if ( existing != null ) {
455- return existing ;
456- }
457- // existing is null, downloadStructure(String,String,boolean,File) will download it
458- break ;
459- case FETCH_IF_OUTDATED :
460- // here existing can be null or not:
461- // existing == null : downloadStructure(String,String,boolean,File) will download it
462- // existing != null : downloadStructure(String,String,boolean,File) will check its date and download if older
463- break ;
464- case FETCH_REMEDIATED :
465- // Use existing if present and recent enough
466- if ( existing != null ) {
467- long lastModified = existing .lastModified ();
468-
469- if (lastModified < LAST_REMEDIATION_DATE ) {
470- // the file is too old, replace with newer version
471- logger .warn ("Replacing file {} with latest remediated (remediation of {}) file from PDB." ,
472- existing , LAST_REMEDIATION_DATE_STRING );
473- existing = null ;
474- break ;
475- } else {
476- return existing ;
477- }
478- }
479- case FORCE_DOWNLOAD :
480- // discard the existing file to force redownload
481- existing = null ; // downloadStructure(String,String,boolean,File) will download it
482- break ;
478+ }
479+ case FORCE_DOWNLOAD :
480+ // discard the existing file to force redownload
481+ existing = null ; // downloadStructure(String,String,boolean,File) will download it
482+ break ;
483483 }
484484
485485 // Force the download now
@@ -521,7 +521,7 @@ private File downloadStructure(String pdbId, String pathOnServer, boolean obsole
521521 ftp = CodecUtils .getMmtfEntryUrl (pdbId , true , false );
522522 } else {
523523 ftp = String .format ("%s%s/%s/%s" ,
524- serverName , pathOnServer , pdbId .substring (1 ,3 ).toLowerCase (), getFilename (pdbId ));
524+ serverName , pathOnServer , pdbId .substring (1 ,3 ).toLowerCase (), getFilename (pdbId ));
525525 }
526526
527527 URL url = new URL (ftp );
@@ -771,4 +771,4 @@ protected void initPaths() {
771771 * @return A list of directories, relative to the /pub/pdb directory on the server
772772 */
773773 protected abstract String [] getObsoleteDirPath ();
774- }
774+ }
0 commit comments