use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class Application method init.
/**
* 系统初始化
*
* @throws Exception
*/
public static boolean init() throws Exception {
if (_READY)
throw new IllegalStateException("REBUILD ALREADY STARTED");
log.info("Initializing Rebuild context [ {} ] ...", _CONTEXT.getClass().getSimpleName());
if (!(_READY = ServerStatus.checkAll())) {
log.error(RebuildBanner.formatBanner("REBUILD STARTUP FILAED DURING THE STATUS CHECK.", "PLEASE VIEW LOGS FOR MORE DETAILS."));
return false;
}
// 升级数据库
new UpgradeDatabase().upgradeQuietly();
// 版本升级会清除缓存
int lastBuild = ObjectUtils.toInt(RebuildConfiguration.get(ConfigurationItem.AppBuild, true), 0);
if (lastBuild < BUILD) {
log.warn("Clean up the cache once when upgrading : {}", BUILD);
Installer.clearAllCache();
RebuildConfiguration.set(ConfigurationItem.AppBuild, BUILD);
}
// 刷新配置缓存
for (ConfigurationItem item : ConfigurationItem.values()) {
RebuildConfiguration.get(item, true);
}
// 加载自定义实体
log.info("Loading customized/business entities ...");
((DynamicMetadataFactory) _CONTEXT.getBean(PersistManagerFactory.class).getMetadataFactory()).refresh();
// 实体对应的服务类
_ESS = new HashMap<>();
for (Map.Entry<String, ServiceSpec> e : _CONTEXT.getBeansOfType(ServiceSpec.class).entrySet()) {
ServiceSpec s = e.getValue();
if (s.getEntityCode() > 0) {
_ESS.put(s.getEntityCode(), s);
if (devMode()) {
log.info("Service specification : {} for [ {} ]", s.getClass().getName(), s.getEntityCode());
}
}
}
// 初始化业务组件
List<Initialization> ordered = new ArrayList<>(_CONTEXT.getBeansOfType(Initialization.class).values());
OrderComparator.sort(ordered);
for (Initialization bean : ordered) {
bean.init();
}
License.isRbvAttached();
DataMigrator.dataMigrateIfNeed();
return true;
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method pageSystems.
@GetMapping("systems")
public ModelAndView pageSystems() {
ModelAndView mv = createModelAndView("/admin/system-cfg");
for (ConfigurationItem item : ConfigurationItem.values()) {
mv.getModel().put(item.name(), RebuildConfiguration.get(item));
}
// Available langs
mv.getModel().put("availableLangs", JSON.toJSON(Application.getLanguage().availableLocales()));
JSONObject auth = License.queryAuthority();
mv.getModel().put("LicenseType", auth.getString("authType") + " (" + auth.getString("authObject") + ")");
mv.getModel().put("Version", Application.VER);
return mv;
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method setValues.
private void setValues(JSONObject data) {
for (Map.Entry<String, Object> e : data.entrySet()) {
try {
ConfigurationItem item = ConfigurationItem.valueOf(e.getKey());
RebuildConfiguration.set(item, e.getValue());
} catch (Exception ex) {
log.error("Invalid item : {} = {}", e.getKey(), e.getValue(), ex);
}
}
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method pageIntegrationSsoSaml.
// SAML
@GetMapping("integration/sso-saml")
public ModelAndView pageIntegrationSsoSaml() {
RbAssert.isCommercial(Language.L("免费版不支持企业身份认证 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
ModelAndView mv = createModelAndView("/admin/integration/sso-saml");
for (ConfigurationItem item : ConfigurationItem.values()) {
String name = item.name();
if (name.startsWith("Saml")) {
mv.getModel().put(name, RebuildConfiguration.get(item));
}
}
mv.getModel().put("_SamlSpEndpoint", RebuildConfiguration.getHomeUrl("/user/sso-saml2-login"));
mv.getModel().put("_SamlSpSloEndpoint", RebuildConfiguration.getHomeUrl("/user/logout"));
mv.getModel().put("_SamlSpEntityid", RebuildConfiguration.getHomeUrl());
return mv;
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class AdminCLI2 method execSyscfg.
/**
* @return
* @see ConfigurationItem
*/
protected String execSyscfg() {
if (commands.length < 2)
return "Bad arguments";
String name = commands[1];
try {
ConfigurationItem item = ConfigurationItem.valueOf(name);
// Get
if (commands.length <= 2) {
return RebuildConfiguration.get(item);
}
String value = commands[2];
RebuildConfiguration.set(item, value);
return "OK";
} catch (IllegalArgumentException ex) {
return "Bad arguments [1] : " + name;
}
}
Aggregations