import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.io.FileUtils;
import org.sonar.api.utils.log.Loggers;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
+
class EmbeddedTomcat {
private final Props props;
Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e);
}
}
- FileUtils.deleteQuietly(tomcatBasedir());
+ deleteQuietly(tomcatBasedir());
}
void awaitTermination() {
static class Fs {
void createOrCleanupDir(File dir) throws IOException {
FileUtils.forceMkdir(dir);
- FileUtils.cleanDirectory(dir);
+ org.sonar.core.util.FileUtils.cleanDirectory(dir);
}
}
}
try {
FileUtils.copyInputStreamToFile(reportInput, file);
} catch (Exception e) {
- FileUtils.deleteQuietly(file);
+ org.sonar.core.util.FileUtils.deleteQuietly(file);
IOUtils.closeQuietly(reportInput);
throw new IllegalStateException(format("Fail to copy report to file: %s", file.getAbsolutePath()), e);
}
}
public void deleteIfExists(String taskUuid) {
- FileUtils.deleteQuietly(fileForUuid(taskUuid));
+ org.sonar.core.util.FileUtils.deleteQuietly(fileForUuid(taskUuid));
}
public void deleteAll() {
File dir = reportDir();
if (dir.exists()) {
try {
- FileUtils.cleanDirectory(dir);
+ org.sonar.core.util.FileUtils.cleanDirectory(dir);
} catch (Exception e) {
throw new IllegalStateException(format("Fail to clean directory: %s", dir.getAbsolutePath()), e);
}
File deprecated = getDeprecatedPluginsDir();
try {
FileUtils.forceMkdir(deprecated);
- FileUtils.cleanDirectory(deprecated);
+ org.sonar.core.util.FileUtils.cleanDirectory(deprecated);
} catch (IOException e) {
throw new IllegalStateException("The following directory can not be created: " + deprecated.getAbsolutePath(), e);
}
private void prepareDir(File appsDir) {
if (appsDir.exists() && appsDir.isDirectory()) {
try {
- FileUtils.deleteDirectory(appsDir);
+ org.sonar.core.util.FileUtils.deleteDirectory(appsDir);
} catch (IOException e) {
throw new IllegalStateException("Fail to delete temp directory: " + appsDir, e);
}
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
-import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.apache.commons.io.FileUtils.copyFileToDirectory;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.forceMkdir;
import static org.apache.commons.io.FileUtils.toFile;
import static org.apache.commons.lang.StringUtils.substringAfterLast;
import static org.sonar.core.platform.PluginInfo.jarToPluginInfo;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
/**
* Downloads plugins from update center. Files are copied in the directory extensions/downloads and then
public void cancelDownloads() {
try {
if (downloadDir.exists()) {
- cleanDirectory(downloadDir);
+ org.sonar.core.util.FileUtils.cleanDirectory(downloadDir);
}
} catch (IOException e) {
throw new IllegalStateException("Fail to clean the plugin downloads directory: " + downloadDir, e);
*/
package org.sonar.server.plugins;
+import java.io.File;
import org.apache.commons.io.FileUtils;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.ZipUtils;
import org.sonar.core.platform.ExplodedPlugin;
-import org.sonar.core.platform.PluginJarExploder;
import org.sonar.core.platform.PluginInfo;
+import org.sonar.core.platform.PluginJarExploder;
import org.sonar.server.platform.DefaultServerFileSystem;
-import java.io.File;
-
-import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.io.FileUtils.forceMkdir;
@ServerSide
File toDir = new File(fs.getDeployedPluginsDir(), pluginInfo.getKey());
try {
forceMkdir(toDir);
- cleanDirectory(toDir);
+ org.sonar.core.util.FileUtils.cleanDirectory(toDir);
File jarSource = pluginInfo.getNonNullJarFile();
File jarTarget = new File(toDir, jarSource.getName());
import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;
import static org.apache.commons.io.FileUtils.copyFile;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
import static org.apache.commons.io.FileUtils.moveFile;
import static org.apache.commons.io.FileUtils.moveFileToDirectory;
import static org.sonar.core.platform.PluginInfo.jarToPluginInfo;
private void registerPluginInfo(PluginInfo info) {
if (blacklistedPluginKeys.contains(info.getKey())) {
LOG.warn("Plugin {} [{}] is blacklisted and is being uninstalled.", info.getName(), info.getKey());
- deleteQuietly(info.getNonNullJarFile());
+ org.sonar.core.util.FileUtils.deleteQuietly(info.getNonNullJarFile());
return;
}
PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info);
*/
package org.sonar.server.qualityprofile;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.TempFolder;
-import org.sonar.db.DbSession;
-import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.DbClient;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.db.qualityprofile.QualityProfileDto;
@ServerSide
public class QProfileCopier {
restore(backupFile, QProfileName.createFor(to.getLanguage(), to.getName()));
return to;
} finally {
- FileUtils.deleteQuietly(backupFile);
+ org.sonar.core.util.FileUtils.deleteQuietly(backupFile);
}
}
import java.io.FileOutputStream;
import java.io.IOException;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
+
@BatchSide
public class BatchPluginJarExploder extends PluginJarExploder {
}
} finally {
out.close();
- FileUtils.deleteQuietly(lockFile);
+ deleteQuietly(lockFile);
}
}
return destDir;
*/
package org.sonar.batch.bootstrap;
-import org.picocontainer.ComponentLifecycle;
-
-import org.picocontainer.PicoContainer;
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.apache.commons.io.FileUtils;
-import org.sonar.api.utils.TempFolder;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.utils.internal.DefaultTempFolder;
-
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang.StringUtils;
+import org.picocontainer.ComponentLifecycle;
+import org.picocontainer.PicoContainer;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.utils.System2;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.internal.DefaultTempFolder;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+import static org.sonar.core.util.FileUtils.deleteQuietly;
public class GlobalTempFolderProvider extends ProviderAdapter implements ComponentLifecycle<TempFolder> {
private static final Logger LOG = Loggers.get(GlobalTempFolderProvider.class);
if (Files.exists(path)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, new CleanFilter())) {
for (Path p : stream) {
- FileUtils.deleteQuietly(p.toFile());
+ deleteQuietly(p.toFile());
}
}
}
*/
package org.sonar.batch.cache;
-import org.apache.commons.io.FileUtils;
-
-import org.sonar.home.cache.PersistentCache;
-
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
+import org.sonar.home.cache.PersistentCache;
+
+import static org.sonar.core.util.FileUtils.deleteQuietly;
public class DefaultProjectCacheStatus implements ProjectCacheStatus {
private static final String STATUS_FILENAME = "cache-sync-status";
@Override
public void delete() {
cache.clear();
- FileUtils.deleteQuietly(getStatusFilePath().toFile());
+ deleteQuietly(getStatusFilePath().toFile());
}
@Override
return (Date) objInput.readObject();
}
} catch (IOException | ClassNotFoundException e) {
- FileUtils.deleteQuietly(p.toFile());
+ deleteQuietly(p.toFile());
throw new IllegalStateException("Failed to read cache sync status", e);
}
}
*/
package org.sonar.batch.index;
-import org.sonar.api.utils.TempFolder;
-
import com.persistit.Persistit;
import com.persistit.exception.PersistitException;
import com.persistit.logging.Slf4jAdapter;
-import org.apache.commons.io.FileUtils;
+import java.io.File;
+import java.util.Properties;
import org.picocontainer.Startable;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.BatchSide;
+import org.sonar.api.utils.TempFolder;
-import java.io.File;
-import java.util.Properties;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
/**
* Factory of caches
throw new IllegalStateException("Fail to close caches", e);
}
}
- FileUtils.deleteQuietly(tempDir);
+ deleteQuietly(tempDir);
tempDir = null;
}
import com.google.common.base.Throwables;
import com.google.common.io.Files;
import com.squareup.okhttp.HttpUrl;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.picocontainer.Startable;
import org.sonar.api.CoreProperties;
import org.sonarqube.ws.client.PostRequest;
import org.sonarqube.ws.client.WsResponse;
-import javax.annotation.Nullable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
@BatchSide
public class ReportPublisher implements Startable {
private BatchReportWriter writer;
public ReportPublisher(Settings settings, BatchWsClient wsClient, AnalysisContextReportPublisher contextPublisher,
- ImmutableProjectReactor projectReactor, DefaultAnalysisMode analysisMode, TempFolder temp, ReportPublisherStep[] publishers) {
+ ImmutableProjectReactor projectReactor, DefaultAnalysisMode analysisMode, TempFolder temp, ReportPublisherStep[] publishers) {
this.settings = settings;
this.wsClient = wsClient;
this.contextPublisher = contextPublisher;
@Override
public void stop() {
if (!settings.getBoolean(KEEP_REPORT_PROP_KEY) && !settings.getBoolean(VERBOSE_KEY)) {
- FileUtils.deleteQuietly(reportDir);
+ deleteQuietly(reportDir);
} else {
LOG.info("Analysis report generated in " + reportDir);
}
String effectiveKey = projectReactor.getRoot().getKeyWithBranch();
metadata.put("projectKey", effectiveKey);
metadata.put("serverUrl", publicUrl());
-
+
URL dashboardUrl = HttpUrl.parse(publicUrl()).newBuilder()
.addPathSegment("dashboard").addPathSegment("index").addPathSegment(effectiveKey)
.build()
*/
package org.sonar.batch.scan;
-import org.apache.commons.io.FileUtils;
-import org.picocontainer.injectors.ProviderAdapter;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-
import java.io.File;
import java.io.IOException;
-import java.nio.file.Files;
+import org.picocontainer.injectors.ProviderAdapter;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.core.util.FileUtils;
public class MutableProjectReactorProvider extends ProviderAdapter {
private ProjectReactor reactor = null;
private static void cleanDirectory(File dir) {
try {
- FileUtils.deleteDirectory(dir);
- Files.createDirectories(dir.toPath());
+ FileUtils.cleanDirectory(dir);
} catch (IOException e) {
throw new IllegalStateException("Failed to recreate working directory: " + dir.getAbsolutePath(), e);
}
import com.google.common.io.CharStreams;
import com.google.common.io.Files;
import com.google.common.io.InputSupplier;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
-
import javax.annotation.Nullable;
-
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.Server;
import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.log.Loggers;
+import static org.sonar.core.util.FileUtils.deleteQuietly;
+
/**
* This component downloads HTTP files
*
try {
Files.copy(downloader.newInputSupplier(uri, this.connectTimeout, this.readTimeout), toFile);
} catch (IOException e) {
- FileUtils.deleteQuietly(toFile);
+ deleteQuietly(toFile);
throw failToDownload(uri, e);
}
}