use of org.entando.entando.aps.system.init.model.SystemInstallationReport in project entando-core by entando.
the class InitializerManagerTest method should_get_currentReport.
@Test
public void should_get_currentReport() {
when(cacheWrapper.getReport()).thenReturn(createMockReport());
SystemInstallationReport report = this.initializerManager.getCurrentReport();
assertThat(report, is(not(nullValue())));
}
use of org.entando.entando.aps.system.init.model.SystemInstallationReport in project entando-core by entando.
the class AbstractInitializerManager method extractReport.
protected SystemInstallationReport extractReport() throws ApsSystemException {
SystemInstallationReport report = null;
try {
InstallationReportDAO dao = new InstallationReportDAO();
DataSource dataSource = (DataSource) this.getBeanFactory().getBean("portDataSource");
dao.setDataSource(dataSource);
report = dao.loadReport(this.getConfigVersion());
} catch (Throwable t) {
_logger.error("error Error extracting report", t);
throw new ApsSystemException("Error extracting report", t);
}
return report;
}
use of org.entando.entando.aps.system.init.model.SystemInstallationReport in project entando-core by entando.
the class DatabaseManager method initComponentDefaultResources.
private void initComponentDefaultResources(Component componentConfiguration, SystemInstallationReport report, boolean checkOnStatup) throws ApsSystemException {
String logPrefix = "| ";
System.out.println("+ [ Component: " + componentConfiguration.getCode() + " ] :: DATA\n" + logPrefix);
ComponentInstallationReport componentReport = report.getComponentReport(componentConfiguration.getCode(), false);
if (componentReport.getStatus().equals(SystemInstallationReport.Status.OK)) {
logger.debug(logPrefix + "( ok ) Already installed\n" + logPrefix);
System.out.println(logPrefix + "( ok ) Already installed\n" + logPrefix);
return;
} else if (componentReport.getStatus().equals(SystemInstallationReport.Status.UNINSTALLED)) {
logger.debug(logPrefix + "( ok ) Uninstalled\n" + logPrefix);
System.out.println(logPrefix + "( ok ) Uninstalled\n" + logPrefix);
return;
}
DataInstallationReport dataReport = componentReport.getDataReport();
try {
System.out.println(logPrefix + "Starting installation\n" + logPrefix);
String[] dataSourceNames = this.extractBeanNames(DataSource.class);
for (String dataSourceName : dataSourceNames) {
if ((report.getStatus().equals(SystemInstallationReport.Status.PORTING) || report.getStatus().equals(SystemInstallationReport.Status.RESTORE)) && checkOnStatup) {
dataReport.getDatabaseStatus().put(dataSourceName, report.getStatus());
System.out.println("| ( ok ) " + dataSourceName);
report.setUpdated();
continue;
}
DataSource dataSource = (DataSource) this.getBeanFactory().getBean(dataSourceName);
SystemInstallationReport.Status dataStatus = dataReport.getDatabaseStatus().get(dataSourceName);
if (SystemInstallationReport.isSafeStatus(dataStatus)) {
logger.debug(logPrefix + "( ok ) Already installed\n" + logPrefix);
System.out.println(logPrefix + "( ok ) Already installed\n" + logPrefix);
continue;
}
Map<String, ComponentEnvironment> environments = componentConfiguration.getEnvironments();
String compEnvKey = (Environment.test.equals(this.getEnvironment())) ? Environment.test.toString() : Environment.production.toString();
ComponentEnvironment componentEnvironment = (null != environments) ? environments.get(compEnvKey) : null;
Resource resource = (null != componentEnvironment) ? componentEnvironment.getSqlResources(dataSourceName) : null;
String script = (null != resource) ? this.readFile(resource) : null;
if (null != script && script.trim().length() > 0) {
if (checkOnStatup) {
dataReport.getDatabaseStatus().put(dataSourceName, SystemInstallationReport.Status.INCOMPLETE);
this.getDatabaseRestorer().initOracleSchema(dataSource);
TableDataUtils.valueDatabase(script, dataSourceName, dataSource, dataReport);
System.out.println("| ( ok ) " + dataSourceName);
dataReport.getDatabaseStatus().put(dataSourceName, SystemInstallationReport.Status.OK);
} else {
dataReport.getDatabaseStatus().put(dataSourceName, SystemInstallationReport.Status.SKIPPED);
}
report.setUpdated();
} else {
System.out.println(logPrefix + "( !! ) skipping " + dataSourceName + ": not available");
dataReport.getDatabaseStatus().put(dataSourceName, SystemInstallationReport.Status.NOT_AVAILABLE);
report.setUpdated();
}
}
System.out.println(logPrefix + "\n" + logPrefix + "Installation complete\n" + logPrefix);
logger.debug(logPrefix + "\n" + logPrefix + "Installation complete\n" + logPrefix);
} catch (Throwable t) {
logger.error("Error restoring default resources of component {}", componentConfiguration.getCode(), t);
throw new ApsSystemException("Error restoring default resources of component " + componentConfiguration.getCode(), t);
}
}
use of org.entando.entando.aps.system.init.model.SystemInstallationReport in project entando-core by entando.
the class InitializerManager method executePostInitProcesses.
public void executePostInitProcesses() throws BeansException {
SystemInstallationReport report = null;
try {
report = this.extractReport();
List<Component> components = this.getComponentManager().getCurrentComponents();
for (int i = 0; i < components.size(); i++) {
Component component = components.get(i);
ComponentInstallationReport componentReport = report.getComponentReport(component.getCode(), false);
SystemInstallationReport.Status postProcessStatus = componentReport.getPostProcessStatus();
if (!postProcessStatus.equals(SystemInstallationReport.Status.INIT)) {
continue;
}
String compEnvKey = (AbstractInitializerManager.Environment.test.equals(this.getEnvironment())) ? AbstractInitializerManager.Environment.test.toString() : AbstractInitializerManager.Environment.production.toString();
ComponentEnvironment componentEnvironment = (null != component.getEnvironments()) ? component.getEnvironments().get(compEnvKey) : null;
List<IPostProcess> postProcesses = (null != componentEnvironment) ? componentEnvironment.getPostProcesses() : null;
if (null == postProcesses || postProcesses.isEmpty()) {
postProcessStatus = SystemInstallationReport.Status.NOT_AVAILABLE;
} else if (!this.isCheckOnStartup()) {
postProcessStatus = SystemInstallationReport.Status.SKIPPED;
} else if (!componentReport.isPostProcessExecutionRequired()) {
// Porting or restore
postProcessStatus = SystemInstallationReport.Status.NOT_AVAILABLE;
} else {
postProcessStatus = this.executePostProcesses(postProcesses);
}
componentReport.setPostProcessStatus(postProcessStatus);
report.setUpdated();
}
} catch (Throwable t) {
logger.error("Error while executing post processes", t);
throw new FatalBeanException("Error while executing post processes", t);
} finally {
if (null != report && report.isUpdated()) {
this.saveReport(report);
}
}
}
use of org.entando.entando.aps.system.init.model.SystemInstallationReport in project entando-core by entando.
the class InitializerManager method reloadCurrentReport.
@Override
public void reloadCurrentReport() {
try {
SystemInstallationReport report = this.extractReport();
this.getCacheWrapper().setCurrentReport(report);
} catch (Throwable t) {
logger.error("Error reloading report", t);
throw new RuntimeException("Error reloading report", t);
}
}
Aggregations