mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-3616 add logs for local rm (#1839)
* CB-3616 add logs for local rm * CB-3616 add info about project id in logs --------- Co-authored-by: Serge Rider <serge@jkiss.org> Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
co-authored by
Serge Rider
Daria Marutkina
parent
c79a9a8efa
commit
07fc1f88b7
+14
-2
@@ -289,6 +289,7 @@ public class LocalResourceController implements RMController {
|
||||
throw new DBException("Project '" + name + "' not created");
|
||||
}
|
||||
try {
|
||||
log.debug("Creating project '" + project.getId() + "'");
|
||||
Files.createDirectories(projectPath);
|
||||
if (WebAppUtils.getWebApplication().isMultiNode()) {
|
||||
createResourceTypeFolders(projectPath);
|
||||
@@ -309,6 +310,7 @@ public class LocalResourceController implements RMController {
|
||||
throw new DBException("Project '" + project.getName() + "' doesn't exists");
|
||||
}
|
||||
try {
|
||||
log.debug("Deleting project '" + projectId + "'");
|
||||
IOUtils.deleteDirectory(targetPath);
|
||||
getSecurityController().deleteAllObjectPermissions(projectId, SMObjects.PROJECT);
|
||||
} catch (IOException e) {
|
||||
@@ -346,6 +348,7 @@ public class LocalResourceController implements RMController {
|
||||
BaseWebProjectImpl webProject = getWebProject(projectId, false);
|
||||
doFileWriteOperation(projectId, webProject.getMetadataFilePath(),
|
||||
() -> {
|
||||
log.debug("Updating value for property '" + propName + "' in project '" + projectId + "'");
|
||||
webProject.setProjectProperty(propName, propValue);
|
||||
return null;
|
||||
}
|
||||
@@ -404,6 +407,7 @@ public class LocalResourceController implements RMController {
|
||||
false
|
||||
);
|
||||
registry.checkForErrors();
|
||||
log.debug("Save data sources configuration in project '" + projectId + "'");
|
||||
((DataSourcePersistentRegistry) registry).saveDataSources();
|
||||
registry.checkForErrors();
|
||||
return configChanged;
|
||||
@@ -423,6 +427,7 @@ public class LocalResourceController implements RMController {
|
||||
DBPDataSourceContainer dataSource = registry.getDataSource(dataSourceId);
|
||||
|
||||
if (dataSource != null) {
|
||||
log.debug("Deleting data source '" + dataSourceId + "' in project '" + projectId + "'");
|
||||
registry.removeDataSource(dataSource);
|
||||
} else {
|
||||
log.warn("Could not find datasource " + dataSourceId + " for deletion");
|
||||
@@ -439,6 +444,7 @@ public class LocalResourceController implements RMController {
|
||||
@NotNull String folderPath) throws DBException {
|
||||
try (var projectLock = lockController.lockProject(projectId, "createDatasourceFolder")) {
|
||||
DBPProject project = getWebProject(projectId, false);
|
||||
log.debug("Creating data source folder '" + folderPath + "' in project '" + projectId + "'");
|
||||
doFileWriteOperation(projectId, project.getMetadataFolder(false),
|
||||
() -> {
|
||||
DBPDataSourceRegistry registry = project.getDataSourceRegistry();
|
||||
@@ -468,6 +474,7 @@ public class LocalResourceController implements RMController {
|
||||
for (String folderPath : folderPaths) {
|
||||
DBPDataSourceFolder folder = registry.getFolder(folderPath);
|
||||
if (folder != null) {
|
||||
log.debug("Deleting data source folder '" + folderPath + "' in project '" + projectId + "'");
|
||||
registry.removeFolder(folder, dropContents);
|
||||
} else {
|
||||
log.warn("Can not find folder by path [" + folderPath + "] for deletion");
|
||||
@@ -488,6 +495,7 @@ public class LocalResourceController implements RMController {
|
||||
) throws DBException {
|
||||
try (var projectLock = lockController.lockProject(projectId, "createDatasourceFolder")) {
|
||||
DBPProject project = getWebProject(projectId, false);
|
||||
log.debug("Moving data source folder from '" + oldPath + "' to '" + newPath + "' in project '" + projectId + "'");
|
||||
doFileWriteOperation(projectId, project.getMetadataFolder(false),
|
||||
() -> {
|
||||
DBPDataSourceRegistry registry = project.getDataSourceRegistry();
|
||||
@@ -566,6 +574,7 @@ public class LocalResourceController implements RMController {
|
||||
if (Files.exists(targetPath)) {
|
||||
throw new DBException("Resource '" + resourcePath + "' already exists");
|
||||
}
|
||||
log.debug("Creating resource '" + resourcePath + "' in project '" + projectId + "'");
|
||||
createFolder(targetPath.getParent());
|
||||
doFileWriteOperation(projectId, targetPath, () -> {
|
||||
try {
|
||||
@@ -595,7 +604,8 @@ public class LocalResourceController implements RMController {
|
||||
var normalizedOldResourcePath = CommonUtils.normalizeResourcePath(oldResourcePath);
|
||||
var normalizedNewResourcePath = CommonUtils.normalizeResourcePath(newResourcePath);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Moving resource from '" + normalizedOldResourcePath + "' to '" + normalizedNewResourcePath + "'");
|
||||
log.debug("Moving resource from '" + normalizedOldResourcePath + "' to '" + normalizedNewResourcePath +
|
||||
"' in project '" + projectId + "'") ;
|
||||
}
|
||||
Path oldTargetPath = getTargetPath(projectId, normalizedOldResourcePath);
|
||||
List<RMResource> rmOldResourcePath = makeResourcePath(projectId, oldTargetPath, false);
|
||||
@@ -659,7 +669,7 @@ public class LocalResourceController implements RMController {
|
||||
public void deleteResource(@NotNull String projectId, @NotNull String resourcePath, boolean recursive) throws DBException {
|
||||
try (var projectLock = lockController.lockProject(projectId, "deleteResource")) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Removing resource from '" + resourcePath + "'" + (recursive ? " recursive" : ""));
|
||||
log.debug("Removing resource from '" + resourcePath + "' in project '" + projectId + "'" + (recursive ? " recursive" : ""));
|
||||
}
|
||||
validateResourcePath(resourcePath);
|
||||
Path targetPath = getTargetPath(projectId, resourcePath);
|
||||
@@ -762,6 +772,7 @@ public class LocalResourceController implements RMController {
|
||||
doFileWriteOperation(projectId, targetPath, () -> {
|
||||
createFolder(targetPath.getParent());
|
||||
try {
|
||||
log.debug("Writing data to resource '" + targetPath + " in project " + projectId + "'");
|
||||
Files.write(targetPath, data);
|
||||
} catch (IOException e) {
|
||||
throw new DBException("Error writing resource '" + resourcePath + "'", e);
|
||||
@@ -799,6 +810,7 @@ public class LocalResourceController implements RMController {
|
||||
BaseWebProjectImpl webProject = getWebProject(projectId, false);
|
||||
doFileWriteOperation(projectId, webProject.getMetadataFilePath(),
|
||||
() -> {
|
||||
log.debug("Updating resource property '" + propertyName + "' in project '" + projectId + "'");
|
||||
webProject.setResourceProperty(resourcePath, propertyName, propertyValue);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user