Skip to content

Commit

Permalink
Merge pull request geoserver#4809 from fernandor777/backup_fix2
Browse files Browse the repository at this point in the history
[GEOS-9948] Fix existing layers ID overwrite on Backup & Restore plugin
  • Loading branch information
Alessio Fabiani authored Mar 5, 2021
2 parents b8f21a4 + 98f8b13 commit 0243a85
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private synchronized Catalog createRestoreCatalog() {
restoreCatalog.setResourceLoader(gsCatalog.getResourceLoader());
restoreCatalog.setResourcePool(gsCatalog.getResourcePool());

keepExistingWorkspaces(restoreCatalog, gsCatalog);
syncCatalogs(restoreCatalog, gsCatalog);

for (CatalogListener listener : gsCatalog.getListeners()) {
restoreCatalog.addListener(listener);
Expand All @@ -116,24 +116,11 @@ private synchronized Catalog createRestoreCatalog() {
return restoreCatalog;
}

/** Pass existing workspaces and namespaces to the resulting restore catalog. */
private void keepExistingWorkspaces(CatalogImpl restoreCatalog, Catalog gsCatalog) {
gsCatalog
.getNamespaces()
.forEach(
nsInfo -> {
restoreCatalog.add(nsInfo);
restoreCatalog.save(
restoreCatalog.getNamespaceByPrefix(nsInfo.getPrefix()));
});
gsCatalog
.getWorkspaces()
.forEach(
wsInfo -> {
restoreCatalog.add(wsInfo);
restoreCatalog.save(
restoreCatalog.getWorkspaceByName(wsInfo.getName()));
});
/** Synchronizes catalogs content. */
private void syncCatalogs(CatalogImpl restoreCatalog, Catalog gsCatalog) {
if (gsCatalog instanceof CatalogImpl) {
restoreCatalog.sync((CatalogImpl) gsCatalog);
}
}

@Override
Expand Down
Loading

0 comments on commit 0243a85

Please sign in to comment.