Skip to content

Commit

Permalink
fixes #13435 - changed so rename only happens based on ARCHIVE_IMPORT…
Browse files Browse the repository at this point in the history
…ED_LICENSE_PACKS being true. Also logs failure if appropriate.
  • Loading branch information
Brent Griffin committed Jan 18, 2018
1 parent 7ee38b2 commit a6436a4
Showing 1 changed file with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

public class Task00020LoadClusterLicenses implements StartupTask {



private static final String now= new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date());
private FileFilter licensePacks = new FileFilter() {

Expand All @@ -45,36 +43,27 @@ public boolean forceRun() {

@Override
public void executeUpgrade() throws DotDataException, DotRuntimeException {


for(File pack : licensePackFiles()){
Logger.info(this.getClass(), "found license pack: " + pack);
File oldPack = new File(pack.getParent() + File.separator + "imported_" + now + "_" + pack.getName());
pack.renameTo(oldPack);
try(InputStream in = Files.newInputStream(oldPack.toPath())){
try(InputStream in = Files.newInputStream(pack.toPath())){
LicenseUtil.uploadLicenseRepoFile(in);
if(Config.getBooleanProperty("ARCHIVE_IMPORTED_LICENSE_PACKS", true)){
pack.renameTo(oldPack);
boolean status = pack.renameTo(oldPack);
if(status == false)
Logger.warn(this.getClass(), "Unable to rename license file - consider setting ARCHIVE_IMPORTED_LICENSE_PACKS to false if you do not want license file renamed after it is loaded.");
}
} catch (IOException e) {
Logger.info(this.getClass(), "Unable to import licenses: " + e.getMessage());
}

Logger.warn(this.getClass(), "Unable to import licenses: " + e.getMessage(), e);
}
}



}

private File[] licensePackFiles(){

return new File(APILocator.getFileAssetAPI().getRealAssetsRootPath()).listFiles(licensePacks);
}








}

0 comments on commit a6436a4

Please sign in to comment.