//handle the case of a store changing workspace
if ( source instanceof StoreInfo ) {
i = event.getPropertyNames().indexOf( "workspace");
if ( i > -1 ) {
WorkspaceInfo newWorkspace = (WorkspaceInfo) event.getNewValues().get( i );
Resource oldDir = dd.get((StoreInfo) source );
moveResToDir(oldDir, dd.get(newWorkspace));
}
}
//handle the case of a feature type changing store
if ( source instanceof FeatureTypeInfo ) {
i = event.getPropertyNames().indexOf( "store");
if ( i > -1 ) {
StoreInfo newStore = (StoreInfo) event.getNewValues().get( i );
Resource oldDir = dd.get((FeatureTypeInfo) source);
Resource newDir = dd.get(newStore);
moveResToDir(oldDir, newDir);
}
}
//handle the case of a style changing workspace
if (source instanceof StyleInfo) {
i = event.getPropertyNames().indexOf("workspace");
if (i > -1) {
WorkspaceInfo newWorkspace = (WorkspaceInfo) event.getNewValues().get( i );
Resource newDir = dd.getStyles(newWorkspace);
//look for any resource files (image, etc...) and copy them over, don't move
// since they could be shared among other styles
for (Resource old : dd.additionalStyleResources((StyleInfo) source)) {
copyResToDir(old, newDir);
}
//move over the config file and the sld
for (Resource old : baseResources((StyleInfo)source)) {
moveResToDir(old, newDir);
}
}
}
//handle the case of a layer group changing workspace
if (source instanceof LayerGroupInfo) {
i = event.getPropertyNames().indexOf("workspace");
if (i > -1) {
final WorkspaceInfo newWorkspace = (WorkspaceInfo) event.getNewValues().get( i );
final Resource oldRes = dd.config((LayerGroupInfo)source);
final Resource newDir = dd.getLayerGroups(newWorkspace);
moveResToDir(oldRes, newDir);
}
}
//handle default workspace