Commit b58deb6b authored by afabiani's avatar afabiani
Browse files

[Community Backup&Restore] - Unwrap Secured StoreInfo objects during selective restore cloning step

parent 6fcdd34c
......@@ -39,6 +39,7 @@ import org.geoserver.catalog.ValidationResult;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.catalog.impl.CoverageInfoImpl;
import org.geoserver.catalog.impl.CoverageStoreInfoImpl;
import org.geoserver.catalog.impl.DataStoreInfoImpl;
import org.geoserver.catalog.impl.FeatureTypeInfoImpl;
import org.geoserver.catalog.impl.LayerGroupInfoImpl;
import org.geoserver.catalog.impl.LayerInfoImpl;
......@@ -49,6 +50,8 @@ import org.geoserver.config.util.XStreamPersisterFactory;
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.security.GeoServerSecurityManager;
import org.geoserver.security.decorators.SecuredCoverageInfo;
import org.geoserver.security.decorators.SecuredCoverageStoreInfo;
import org.geoserver.security.decorators.SecuredDataStoreInfo;
import org.geoserver.security.decorators.SecuredFeatureTypeInfo;
import org.geoserver.security.decorators.SecuredWMSLayerInfo;
import org.geoserver.security.decorators.SecuredWMTSLayerInfo;
......@@ -514,6 +517,18 @@ public abstract class BackupRestoreItem<T> {
return info;
}
/**
* @param info
* @return
*/
private StoreInfo unwrapSecured(StoreInfo info) {
if (info instanceof SecuredDataStoreInfo)
return ((SecuredDataStoreInfo) info).unwrap(StoreInfo.class);
if (info instanceof SecuredCoverageStoreInfo)
return ((SecuredCoverageStoreInfo) info).unwrap(StoreInfo.class);
return info;
}
/** @param catalog */
protected void syncTo(Catalog srcCatalog) {
// do a manual import
......@@ -547,7 +562,7 @@ public abstract class BackupRestoreItem<T> {
targetDataStore =
(DataStoreInfo)
clone(
(DataStoreInfo) unwrap(store),
(DataStoreInfo) unwrap(unwrapSecured(store)),
targetWorkspace,
DataStoreInfo.class);
if (targetDataStore != null) {
......@@ -588,7 +603,7 @@ public abstract class BackupRestoreItem<T> {
targetCoverageStore =
(CoverageStoreInfo)
clone(
(CoverageStoreInfo) unwrap(store),
(CoverageStoreInfo) unwrap(unwrapSecured(store)),
targetWorkspace,
CoverageStoreInfo.class);
if (targetCoverageStore != null) {
......@@ -730,12 +745,12 @@ public abstract class BackupRestoreItem<T> {
target.setDescription(source.getDescription());
target.setType(source.getType() != null ? source.getType() : "Shapefile");
if (source instanceof StoreInfoImpl) {
((StoreInfoImpl) target).setDefault(((StoreInfoImpl) source).isDefault());
((StoreInfoImpl) target)
if (source instanceof DataStoreInfoImpl) {
((DataStoreInfoImpl) target).setDefault(((StoreInfoImpl) source).isDefault());
((DataStoreInfoImpl) target)
.setConnectionParameters(
((StoreInfoImpl) source).getConnectionParameters());
((StoreInfoImpl) target).setMetadata(((StoreInfoImpl) source).getMetadata());
((DataStoreInfoImpl) source).getConnectionParameters());
((DataStoreInfoImpl) target).setMetadata(((StoreInfoImpl) source).getMetadata());
}
if (source instanceof CoverageStoreInfoImpl) {
......
......@@ -1204,7 +1204,6 @@ public class CatalogBackupRestoreTasklet extends AbstractCatalogBackupRestoreTas
LayerGroupInfo layerGroupInfo = getCatalog().getLayerGroupByName(layerName);
if (layerGroupInfo != null) {
WorkspaceInfo ws =
layerGroupInfo.getWorkspace() != null
? getCatalog()
......@@ -1238,6 +1237,9 @@ public class CatalogBackupRestoreTasklet extends AbstractCatalogBackupRestoreTas
GeoServerTileLayerInfo gwcLayerInfo,
String layerID)
throws IllegalArgumentException {
if (filterIsValid() && gwcCatalog.getLayerByName(layerName) == null) {
return;
}
if (!isDryRun()) {
// - Depersist the GWC Layer Info into the restore folder
GeoServerTileLayerInfo oldValue = gwcCatalog.getLayerByName(layerName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment