Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/pro#2795 Editors for objects under a path with special symbols don't get restored #29993

Merged
merged 20 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6270dad
dbeaver/pro#2795 Editors for objects under a path with special symbols
serjiokov May 8, 2024
25157b2
dbeaver/pro#2795 Editors for objects under a path with special symbols
serjiokov May 8, 2024
c2523c0
Merge branch 'devel' into dbeaver/pro#2795-editor-restore-path
serjiokov May 8, 2024
bc0e1c6
dbeaver/pro#2795 Extracted to upper method
serjiokov May 8, 2024
bc14ea6
Merge branch 'dbeaver/pro#2795-editor-restore-path' of git@github.com…
serjiokov May 8, 2024
e779148
Merge branch 'dbeaver/pro#2795-editor-restore-path' of
serjiokov May 8, 2024
148bdc3
dbeaver/pro#2795-editor-restore-path - normalize - to - denormalize
serjiokov May 8, 2024
5de71dc
dbeaver/pro#2795-editor-restore-path Minor
serjiokov May 8, 2024
577ddd2
dbeaver/pro#2795-editor-restore-path Remane method
serjiokov May 8, 2024
9fefcd8
dbeaver/pro#2795-editor-restore-path decode from any Ascii code to
serjiokov May 9, 2024
d156def
dbeaver/pro#2795 Check before decode
serjiokov May 10, 2024
12c6b14
dbeaver/pro#2795 Illigal argument of "%"
serjiokov May 10, 2024
2cbc3e9
dbeaver/pro#2795 Fixed encoding/ decoding of path segment
serjiokov May 10, 2024
736c589
dbeaver/pro#2795 Fixed encoding/ decoding of path segment
serjiokov May 10, 2024
226a2c5
dbeaver/pro#2795 Removed constant
serjiokov May 10, 2024
3773339
Merge branch 'dbeaver/pro#2795-editor-restore-path' of git@github.com…
serjiokov May 10, 2024
0b70e2e
Merge branch 'dbeaver/pro#2795-editor-restore-path' of
serjiokov May 10, 2024
f9180ff
Merge branch 'devel' into dbeaver/pro#2795-editor-restore-path
serjiokov May 10, 2024
9bbe064
dbeaver/pro#2795 - Unrelated changes
serjiokov May 13, 2024
863e777
Merge branch 'dbeaver/pro#2795-editor-restore-path' of git@github.com…
serjiokov May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ public String getNodeItemPath() {
if (pathName.length() > 0) {
pathName.insert(0, '/');
}
pathName.insert(0, node.getNodeDisplayName().replace("/", DBNModel.SLASH_ESCAPE_TOKEN));
ShadelessFox marked this conversation as resolved.
Show resolved Hide resolved
pathName.insert(0, DBNUtils.encodeNodePath(node.getNodeDisplayName()));
}
return pathName.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static DBNNode legacyFindNodeByPath(

final List<String> pathItems = nodePath.pathItems;
for (int i = firstItem, itemsSize = pathItems.size(); i < itemsSize; i++) {
String item = pathItems.get(i).replace(DBNModel.SLASH_ESCAPE_TOKEN, "/");
String item = pathItems.get(i);
if (nodePath.type == DBNNode.NodePathType.ext && curNode instanceof DBNProject pn) {
// Trigger project to load extra nodes
pn.getExtraNode(DBNFileSystems.class);
Expand Down Expand Up @@ -173,7 +173,7 @@ private static DBNNode legacyFindNodeByPath(
}

if (!pathItems.isEmpty()) {
String lastItemName = pathItems.get(pathItems.size() - 1).replace(DBNModel.SLASH_ESCAPE_TOKEN, "/");
String lastItemName = pathItems.get(pathItems.size() - 1);
if (!nodeMatchesPath(nodePath, curNode, lastItemName)) {
// Tail node doesn't match tail node from the desired path
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
* (e.g. TreeViewer sometimes update only first TreeItem corresponding to model certain model object).
*/
public class DBNModel implements IResourceChangeListener {
public static final String SLASH_ESCAPE_TOKEN = "%2F";

private static final Log log = Log.getLog(DBNModel.class);

Expand Down Expand Up @@ -271,7 +270,9 @@ private static NodePath getNodePath(@NotNull String path) {
break;
}
}
return new NodePath(nodeType, CommonUtils.splitString(path, '/'));
final List<String> items = CommonUtils.splitString(path, '/');
items.replaceAll(DBNUtils::decodeNodePath);
return new NodePath(nodeType, items);
}

@Nullable
Expand Down Expand Up @@ -327,7 +328,8 @@ public DBNNode getNodeByPath(
log.debug("Project node not found");
return null;
}
final NodePath nodePath = getNodePath(path);
NodePath nodePath = getNodePath(path);

Comment on lines +331 to +332
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant change

if (nodePath.legacyFormat) {
return DBNLegacyUtils.legacyGetNodeByPath(monitor, projectNode, nodePath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public final String getNodeUri() {
if (!pathBuilder.isEmpty()) {
pathBuilder.insert(0, '/');
}
String nodeId = currentNode.getNodeId().replace("/", DBNModel.SLASH_ESCAPE_TOKEN);
String nodeId = DBNUtils.encodeNodePath(currentNode.getNodeId());
if (currentNode instanceof DBNResource && currentNode.getParentNode() instanceof DBNProject) {
//FIXME: remove after migration to the real resource root node
nodeId = DBNResource.FAKE_RESOURCE_ROOT_NODE + "/" + nodeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,24 @@ public boolean has(String name) {
};
}

/**
* The method decode symbols('%2F','%25')
*
* @param nodePath - path
* @return - node path object
*/
public static String decodeNodePath(@NotNull String nodePath) {
return nodePath.replace("%2F", "/").replace("%25", "%");
}

/**
* The method encode symbols('/','%')
*
* @param path - path
* @return - string path segment
*/
public static String encodeNodePath(@NotNull String path) {
return path.replace("%", "%25").replace("/", "%2F");
}

}