本文整理了Java中info.magnolia.cms.core.Path.getTempDirectory()
方法的一些代码示例,展示了Path.getTempDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.getTempDirectory()
方法的具体详情如下:
包路径:info.magnolia.cms.core.Path
类名称:Path
方法名:getTempDirectory
暂无
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
/**
* MGNLDAM-286 For test only; we need a partial mock there otherwise Path fails when getting MAGNOLIA_APP_ROOTDIR system property.
*/
File getTempDirectory() {
return Path.getTempDirectory();
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework
File getTempFile() throws IOException {
if (tempFile == null) {
// Create a temporary file that will hold the data created by the export command.
tempFile = File.createTempFile(tempFileName, tempFileExtension, Path.getTempDirectory());
}
return tempFile;
}
}
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
@Inject
public AssetUploadReceiver(SimpleTranslator i18n, DamAppConfiguration damAppConfig) {
super(Path.getTempDirectory(), i18n);
this.appConfig = damAppConfig;
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
public RemoveCacheTempFilesTask() {
super("Delete cache temp files", "Delete cache temp files if presented in temp directory [" + Path.getTempDirectory().getPath() +"]");
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
@Override
public void execute(InstallContext installContext) throws TaskExecutionException {
File tempDirectory = Path.getTempDirectory();
File[] tempFiles = tempDirectory.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return !file.isDirectory() && file.getName().startsWith(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX);
}
});
for(File tempFile : tempFiles) {
log.warn("Deleting obsolete cache temp file: " + tempFile);
if(!tempFile.delete()){
log.error("Can't remove cache temp file: " + tempFile);
};
}
}
}
代码示例来源:origin: info.magnolia.dam/magnolia-dam-app
private File createAssetFile() {
File tempFile = null;
String tempFileName = null;
InputStream is = null;
FileOutputStream fos = null;
try {
tempFileName = StringUtils.rightPad(currentAsset.getFileName(), 5, "x");
tempFile = File.createTempFile(tempFileName, null, Path.getTempDirectory());
tempFile.deleteOnExit();
fos = new FileOutputStream(tempFile);
is = currentAsset.getContentStream();
IOUtils.copyLarge(is, fos);
fos.flush();
} catch (Exception e) {
log.warn("Could not create tmp file " + tempFileName, e);
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(fos);
}
return tempFile;
}
代码示例来源:origin: info.magnolia/magnolia-module-cache
protected void thresholdReached(OutputStream out) throws IOException {
if (serveIfThresholdReached) {
replayHeadersAndStatus(originalResponse);
out = originalResponse.getOutputStream();
log.debug("Reached threshold for in-memory caching. Will not cache and stream response directly to user.");
}
else {
contentFile = File.createTempFile("cacheStream", null, Path.getTempDirectory());
if (contentFile != null) {
log.debug("Reached threshold for in-memory caching. Will continue caching in new cache temp file {}", contentFile.getAbsolutePath());
contentFile.deleteOnExit();
out = new FileOutputStream(contentFile);
} else {
log.error("Reached threshold for in-memory caching, but unable to create the new cache temp file. Will not cache and stream response directly to user.");
replayHeadersAndStatus(originalResponse);
out = originalResponse.getOutputStream();
}
}
out.write(getBufferedContent());
out.flush();
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
protected OutputStream thresholdReached(OutputStream out) throws IOException {
if (serveIfThresholdReached) {
replayHeadersAndStatus(originalResponse);
out = originalResponse.getOutputStream();
log.debug("Reached threshold for in-memory caching. Will not cache and stream response directly to user.");
} else {
contentFile = File.createTempFile(CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
if (contentFile != null) {
log.debug("Reached threshold for in-memory caching. Will continue caching in new cache temp file {}", contentFile.getAbsolutePath());
contentFile.deleteOnExit();
out = new FileOutputStream(contentFile);
} else {
log.error("Reached threshold for in-memory caching, but unable to create the new cache temp file. Will not cache and stream response directly to user.");
replayHeadersAndStatus(originalResponse);
out = originalResponse.getOutputStream();
}
}
out.write(getBufferedContent());
out.flush();
return out;
}
代码示例来源:origin: info.magnolia/magnolia-4-5-migration
final Session session = src.getSession();
try{
final File file = File.createTempFile("mgnl", null, Path.getTempDirectory());
final FileOutputStream outStream = new FileOutputStream(file);
session.exportSystemView(src.getPath(), outStream, false, false);
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
@Test
public void testDeleteMultipleTempFiles() throws IOException, TaskExecutionException {
// GIVEN
File tempFile = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
File tempFile1 = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
File tempFile2 = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask();
// WHEN
removeCacheTempFilesTask.execute(null);
// THEN
assertFalse(tempFile.exists());
assertFalse(tempFile1.exists());
assertFalse(tempFile2.exists());
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
@Test
public void testFolderWithCacheTempFilePrefixIsNotDeleted() throws IOException, TaskExecutionException {
// GIVEN
File directoryWithCacheTempFilePrefix = new File(Path.getTempDirectory() + "/" + CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX);
directoryWithCacheTempFilePrefix.mkdir();
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask();
// WHEN
removeCacheTempFilesTask.execute(null);
// THEN
assertTrue(directoryWithCacheTempFilePrefix.exists());
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
@Test
public void testTempFileWhichDoesNotStartWithCacheTempPrefixIsNotDeleted() throws IOException, TaskExecutionException {
// GIVEN
File tempFile = File.createTempFile("blablabla" + CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask();
// WHEN
removeCacheTempFilesTask.execute(null);
// THEN
assertTrue(tempFile.exists());
}
代码示例来源:origin: info.magnolia.cache/magnolia-cache-core
@Test
public void testDeleteTempFile() throws IOException, TaskExecutionException {
// GIVEN
File tempFile = File.createTempFile(CacheResponseWrapper.CACHE_TEMP_FILE_PREFIX, null, Path.getTempDirectory());
RemoveCacheTempFilesTask removeCacheTempFilesTask = new RemoveCacheTempFilesTask();
// WHEN
removeCacheTempFilesTask.execute(null);
// THEN
assertFalse(tempFile.exists());
}
代码示例来源:origin: info.magnolia.activation/magnolia-module-activation
final String uuid = content.getUUID();
File file = File.createTempFile("exchange_" + uuid, ".xml.gz", Path.getTempDirectory());
final DigestOutputStream outputStream = SecurityUtil.getDigestOutputStream(new GZIPOutputStream(new FileOutputStream(file)));
代码示例来源:origin: info.magnolia/magnolia-module-exchange-simple
final String uuid = content.getUUID();
File file = File.createTempFile("exchange_" + uuid, ".xml.gz", Path.getTempDirectory());
代码示例来源:origin: info.magnolia.activation/magnolia-module-activation
File resourceFile = File.createTempFile("resources", ".xml", Path.getTempDirectory());
代码示例来源:origin: info.magnolia/magnolia-module-exchange-simple
File resourceFile = File.createTempFile("resources", ".xml", Path.getTempDirectory());
内容来源于网络,如有侵权,请联系作者删除!