Search in sources :

Example 1 with ConfigurationItem

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;
}
Also used : ConfigurationItem(com.rebuild.core.support.ConfigurationItem) UpgradeDatabase(com.rebuild.core.support.setup.UpgradeDatabase) ServiceSpec(com.rebuild.core.service.ServiceSpec) DynamicMetadataFactory(com.rebuild.core.metadata.impl.DynamicMetadataFactory)

Example 2 with ConfigurationItem

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;
}
Also used : ConfigurationItem(com.rebuild.core.support.ConfigurationItem) JSONObject(com.alibaba.fastjson.JSONObject) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 3 with ConfigurationItem

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);
        }
    }
}
Also used : ConfigurationItem(com.rebuild.core.support.ConfigurationItem) JSONObject(com.alibaba.fastjson.JSONObject) Map(java.util.Map) QiniuException(com.qiniu.common.QiniuException)

Example 4 with ConfigurationItem

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;
}
Also used : ConfigurationItem(com.rebuild.core.support.ConfigurationItem) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 5 with ConfigurationItem

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;
    }
}
Also used : ConfigurationItem(com.rebuild.core.support.ConfigurationItem)

Aggregations

ConfigurationItem (com.rebuild.core.support.ConfigurationItem)9 ModelAndView (org.springframework.web.servlet.ModelAndView)4 JSONObject (com.alibaba.fastjson.JSONObject)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 QiniuException (com.qiniu.common.QiniuException)1 DynamicMetadataFactory (com.rebuild.core.metadata.impl.DynamicMetadataFactory)1 ServiceSpec (com.rebuild.core.service.ServiceSpec)1 UpgradeDatabase (com.rebuild.core.support.setup.UpgradeDatabase)1 RebuildWebConfigurer (com.rebuild.web.RebuildWebConfigurer)1 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Properties (java.util.Properties)1 PropertiesPropertySource (org.springframework.core.env.PropertiesPropertySource)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1