Changeset 24967 for main


Ignore:
Timestamp:
2012-01-24T15:19:50+13:00 (12 years ago)
Author:
sjm84
Message:

Multiple files can now be specified using the fl parameter, separated by :

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r24966 r24967  
    402402                            query_string += "&";
    403403                        }
    404                        
    405                         if(current.getFieldName().equals(GSParams.FILE_LOCATION))
     404
     405                        if (current.getFieldName().equals(GSParams.FILE_LOCATION))
    406406                        {
    407407                            storageLocation = current.getString();
     
    412412                        File file = new File(GlobalProperties.getGSDL3Home() + File.separator + "tmp" + File.separator + current.getName());
    413413                        File tmpFolder = new File(GlobalProperties.getGSDL3Home() + File.separator + "tmp");
    414                         if(!tmpFolder.exists())
     414                        if (!tmpFolder.exists())
    415415                        {
    416416                            tmpFolder.mkdirs();
    417417                        }
    418418                        current.write(file);
    419                        
     419
    420420                        uploadedFile = file;
    421421                    }
    422422                }
    423                
    424                 if(!storageLocation.equals("") && uploadedFile != null)
    425                 {
    426                     File toFile = new File(GlobalProperties.getGSDL3Home() + storageLocation);
    427                     if(toFile.exists())
    428                     {
    429                         File backupFile = new File(toFile.getAbsolutePath() + System.currentTimeMillis());
    430                        
     423
     424                if (!storageLocation.equals("") && uploadedFile != null)
     425                {
     426                    String[] locations = storageLocation.split(":");
     427
     428                    for (String location : locations)
     429                    {
     430                        File toFile = new File(GlobalProperties.getGSDL3Home() + location);
     431                        if (toFile.exists())
     432                        {
     433                            File backupFile = new File(toFile.getAbsolutePath() + System.currentTimeMillis());
     434
     435                            logger.info("Backing up file (" + toFile.getAbsolutePath() + ") to " + backupFile.getAbsolutePath());
     436                            toFile.renameTo(backupFile);
     437                        }
     438
    431439                        logger.info("Moving uploaded file (" + uploadedFile.getAbsolutePath() + ") to " + toFile.getAbsolutePath());
    432                         toFile.renameTo(backupFile);
    433                     }
    434                    
    435                     logger.info("Moving uploaded file (" + uploadedFile.getAbsolutePath() + ") to " + toFile.getAbsolutePath());
    436                     uploadedFile.renameTo(toFile);
     440                        uploadedFile.renameTo(toFile);
     441                    }
    437442                }
    438443            }
Note: See TracChangeset for help on using the changeset viewer.