From 356b73e611f02daa726a94da2d025dd41c41dfca Mon Sep 17 00:00:00 2001 From: Serge Rider Date: Wed, 15 Sep 2021 19:17:57 +0300 Subject: [PATCH] CB-1240 Object rename fix --- .../navigator/impl/WebServiceNavigator.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java index a8300575d0..43e7bb777b 100644 --- a/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java +++ b/server/bundles/io.cloudbeaver.server/src/io/cloudbeaver/service/navigator/impl/WebServiceNavigator.java @@ -227,11 +227,7 @@ public class WebServiceNavigator implements DBWServiceNavigator { Map options = new LinkedHashMap<>(); for (Map.Entry ne : nodes.entrySet()) { DBSObject object = ne.getKey().getObject(); - DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true); - if (executionContext == null) { - // It may happen in case of lazy context initialization - executionContext = DBUtils.getDefaultContext(object.getDataSource(), true); - } + DBCExecutionContext executionContext = getCommandExecutionContext(object); DBECommandContext commandContext = new WebCommandContext(executionContext, false); ne.getValue().deleteObject(commandContext, object, options); commandContext.saveChanges(session.getProgressMonitor(), options); @@ -250,7 +246,7 @@ public class WebServiceNavigator implements DBWServiceNavigator { DBEObjectRenamer objectRenamer = DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager( object.getClass(), DBEObjectRenamer.class); if (objectRenamer != null) { - DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true); + DBCExecutionContext executionContext = getCommandExecutionContext(object); Map options = new LinkedHashMap<>(); DBECommandContext commandContext = new WebCommandContext(executionContext, false); objectRenamer.renameObject(commandContext, object, options, newName); @@ -262,4 +258,13 @@ public class WebServiceNavigator implements DBWServiceNavigator { throw new DBException("Node " + node.getNodeItemPath() + " rename is not supported"); } + public DBCExecutionContext getCommandExecutionContext(DBSObject object) { + DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true); + if (executionContext == null) { + // It may happen in case of lazy context initialization + executionContext = DBUtils.getDefaultContext(object.getDataSource(), true); + } + return executionContext; + } + }