/** * Returns the base directory to be used for storing temporary files. * * @return the base directory, never <code>null</code> */ public static synchronized File getBaseDir() { if ( baseDir == null ) { init(); } return baseDir; } }
private File getTargetFile( ServletContext sc, String target, String fileName ) throws IOException { File targetFile = null; if ( target != null ) { if ( !target.endsWith( "/" ) ) { target += "/"; } targetFile = new File( sc.getRealPath( target + fileName ) ); } else { // use deegree's temp directory File tempDir = TempFileManager.getBaseDir(); targetFile = File.createTempFile( "upload", "", tempDir ); } LOG.info( "Uploading file '" + fileName + "' to: '" + targetFile + "'" ); return targetFile; }
@Override public List<ResourceMetadata<ConnectionProvider>> getAdditionalResources( Workspace workspace ) { List<ResourceMetadata<ConnectionProvider>> list = new ArrayList<ResourceMetadata<ConnectionProvider>>(); String lockDb = new File( TempFileManager.getBaseDir(), "lockdb" ).getAbsolutePath(); LOG.info( "Using '" + lockDb + "' for h2 lock database." ); String url = "jdbc:h2:" + lockDb; ResourceLocation<ConnectionProvider> location = getSyntheticProvider( "LOCK_DB", url, "SA", "" ); list.add( new LegacyConnectionProviderMetadata( workspace, location, this ) ); return list; }
/** * Initializes the {@link TempFileManager} to use a random String for creating unique temporary file names. */ public static synchronized void init() { String contextId = UUID.randomUUID().toString(); init( contextId ); }