private File warFile;
private Server server;
+ private boolean potentiallyMissingSchema;
+ private boolean forceSchemaCreate = false;
+
public CDMServer(String dataSourceName, File dataSourcesFile) throws CDMEmbeddedServerException {
if(StringUtil.isBlank(dataSourceName)) {
throw new CDMEmbeddedServerException(ioe);
}
+ //TODO instead of strings, use the constants defined in eu.etaxonomy.cdm.opt.config.DataSourceConfigurer
System.setProperty("spring.profiles.active", "remoting");
System.setProperty("cdm.beanDefinitionFile", dataSourcesFile.getAbsolutePath());
System.setProperty("cdm.datasource", dataSourceName);
Thread serverThread = new Thread() {
+
@Override
public void run() {
try {
+ if(isForceSchemaCreate()) {
+ System.setProperty("cdm.forceSchemaCreate", "true");
+ potentiallyMissingSchema = false; // reset flag
+ setForceSchemaCreate(false); // reset flag
+ }
server.start();
server.join();
} catch (Throwable t) {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
+ Throwable cause = t;
+ while(cause != null) {
+
+ // pure string comparison to avoid dependencies to hibernate or cdmlib-persistance in the taxeditor
+ if(cause.getClass().getSimpleName().equals("SchemaExtractionException") || cause.getClass().getSimpleName().equals("CdmDatabaseException") ) {
+ potentiallyMissingSchema = true;
+ logger.debug(cause.getClass().getName() + " detected which indicates missing or corrupt schema");
+ cause = null;
+ } else {
+ cause = cause.getCause();
+ }
+ }
cdmServerError.handleError(new RuntimeException("Error during CDM server startup", t));
+ } finally {
+ //System.getProperties().remove("cdm.forceSchemaCreate");
}
}
};
}
}
+ public boolean isForceSchemaCreate() {
+ return forceSchemaCreate;
+ }
+
+ public void setForceSchemaCreate(boolean forceSchemaCreate) {
+ this.forceSchemaCreate = forceSchemaCreate;
+ }
+
+ public boolean isPotentiallyMissingSchema() {
+ return potentiallyMissingSchema;
+ }
+
}