final LayerGroupInfo localObject = catalog
.getLayerGroupByName(name);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof LayerInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((LayerInfo) info).getName();
}
final LayerInfo localObject = catalog.getLayerByName(name);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof MapInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((MapInfo) info).getName();
}
final MapInfo localObject = catalog.getMapByName(name);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof NamespaceInfo) {
final String uri;
final Object uriObj = getOldValue(catalog, modifyEv, "uRI");
if (uriObj != null) {
uri = uriObj.toString();
} else {
// uri is unchanged
uri = ((NamespaceInfo) info).getURI();
}
final NamespaceInfo localObject = catalog.getNamespaceByURI(uri);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " uri: " + uri + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof StoreInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((StoreInfo) info).getName();
}
// check if workspace is changed
final WorkspaceInfo workspace;
final Object objWorkpsace = getOldValue(catalog, modifyEv,
"workspace");
if (objWorkpsace != null) {
workspace = (WorkspaceInfo) objWorkpsace;
} else {
// workspace is unchanged
workspace = ((StoreInfo) info).getWorkspace();
}
final StoreInfo localObject;
if (info instanceof CoverageStoreInfo) {
localObject = catalog.getStoreByName(workspace, name,
CoverageStoreInfo.class);
} else if (info instanceof DataStoreInfo) {
localObject = catalog.getStoreByName(workspace, name,
DataStoreInfo.class);
} else if (info instanceof WMSStoreInfo) {
localObject = catalog.getStoreByName(workspace, name,
WMSStoreInfo.class);
} else {
throw new IllegalArgumentException(
"Unable to provide localization for the passed instance");
}
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof ResourceInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((ResourceInfo) info).getName();
}
// check if namespace is changed
final NamespaceInfo namespace;
final Object objWorkpsace = getOldValue(catalog, modifyEv,
"namespace");
if (objWorkpsace != null) {
namespace = (NamespaceInfo) objWorkpsace;
} else {
// workspace is unchanged
namespace = ((ResourceInfo) info).getNamespace();
}
final ResourceInfo localObject;
if (info instanceof CoverageInfo) {
// coverage
localObject = catalog.getCoverageByName(namespace, name);
} else if (info instanceof FeatureTypeInfo) {
// feature
localObject = catalog.getFeatureTypeByName(namespace, name);
} else if (info instanceof WMSLayerInfo) {
// wmslayer
localObject = catalog.getResourceByName(namespace, name,
WMSLayerInfo.class);
} else {
throw new IllegalArgumentException(
"Unable to provide localization for the passed instance");
}
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof StyleInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((StyleInfo) info).getName();
}
final StyleInfo localObject = catalog.getStyleByName(name);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());
catalog.save(localObject);
} else if (info instanceof WorkspaceInfo) {
// check if name is changed
if (name == null) {
// name is unchanged
name = ((WorkspaceInfo) info).getName();
}
final WorkspaceInfo localObject = catalog.getWorkspaceByName(name);
if (localObject == null) {
throw new CatalogException("Unable to locate " + info
+ " named: " + name + " locally.");
}
BeanUtils.smartUpdate(localObject, modifyEv.getPropertyNames(),
modifyEv.getNewValues());