//workspaces, stores, and resources
File workspaces = resourceLoader.find( "workspaces" );
if ( workspaces != null ) {
//do a first quick scan over all workspaces, setting the default
File dws = new File(workspaces, "default.xml");
WorkspaceInfo defaultWorkspace = null;
if (dws.exists()) {
try {
defaultWorkspace = depersist(xp, dws, WorkspaceInfo.class);
LOGGER.info("Loaded default workspace " + defaultWorkspace.getName());
}
catch( Exception e ) {
LOGGER.log(Level.WARNING, "Failed to load default workspace", e);
}
}
else {
LOGGER.warning("No default workspace was found.");
}
for ( File wsd : list(workspaces, DirectoryFileFilter.INSTANCE ) ) {
File f = new File( wsd, "workspace.xml");
if ( !f.exists() ) {
continue;
}
WorkspaceInfo ws = null;
try {
ws = depersist( xp, f, WorkspaceInfo.class );
catalog.add( ws );
}
catch( Exception e ) {
LOGGER.log( Level.WARNING, "Failed to load workspace '" + wsd.getName() + "'" , e );
continue;
}
LOGGER.info( "Loaded workspace '" + ws.getName() +"'");
//load the namespace
File nsf = new File( wsd, "namespace.xml" );
NamespaceInfo ns = null;
if ( nsf.exists() ) {
try {
ns = depersist( xp, nsf, NamespaceInfo.class );
catalog.add( ns );
}
catch( Exception e ) {
LOGGER.log( Level.WARNING, "Failed to load namespace for '" + wsd.getName() + "'" , e );
}
}
//set the default workspace, this value might be null in the case of coming from a
// 2.0.0 data directory. See http://jira.codehaus.org/browse/GEOS-3440
if (defaultWorkspace != null ) {
if (ws.getName().equals(defaultWorkspace.getName())) {
catalog.setDefaultWorkspace(ws);
if (ns != null) {
catalog.setDefaultNamespace(ns);
}
}