use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method pageIntegrationDingtalk.
// DingTalk
@GetMapping("integration/dingtalk")
public ModelAndView pageIntegrationDingtalk() {
RbAssert.isCommercial(Language.L("免费版不支持钉钉集成 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
ModelAndView mv = createModelAndView("/admin/integration/dingtalk");
for (ConfigurationItem item : ConfigurationItem.values()) {
String name = item.name();
if (name.startsWith("Dingtalk")) {
String value = RebuildConfiguration.get(item);
if (value != null && item == ConfigurationItem.DingtalkAppsecret) {
value = DataDesensitized.any(value);
}
mv.getModel().put(name, value);
if (ID.isId(value) && item == ConfigurationItem.DingtalkSyncUsersRole) {
mv.getModel().put(name + "Label", UserHelper.getName(ID.valueOf(value)));
}
}
}
String homeUrl = RebuildConfiguration.getHomeUrl("/user/dingtalk");
mv.getModel().put("_DingtalkHomeUrl", homeUrl);
String[] authCallUrl = homeUrl.split("/");
mv.getModel().put("_DingtalkAuthCallUrl", authCallUrl[0] + "//" + authCallUrl[2] + "/");
return mv;
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method pageIntegrationWxwork.
// WxWork
@GetMapping("integration/wxwork")
public ModelAndView pageIntegrationWxwork() {
RbAssert.isCommercial(Language.L("免费版不支持企业微信集成 [(查看详情)](https://getrebuild.com/docs/rbv-features)"));
ModelAndView mv = createModelAndView("/admin/integration/wxwork");
for (ConfigurationItem item : ConfigurationItem.values()) {
String name = item.name();
if (name.startsWith("Wxwork")) {
String value = RebuildConfiguration.get(item);
if (value != null && item == ConfigurationItem.WxworkSecret) {
value = DataDesensitized.any(value);
}
mv.getModel().put(name, value);
if (ID.isId(value) && item == ConfigurationItem.WxworkSyncUsersRole) {
mv.getModel().put(name + "Label", UserHelper.getName(ID.valueOf(value)));
}
}
}
String homeUrl = RebuildConfiguration.getHomeUrl("/user/wxwork");
mv.getModel().put("_WxworkHomeUrl", homeUrl);
mv.getModel().put("_WxworkAuthCallUrl", homeUrl.split("//")[1].split("/")[0]);
return mv;
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class ConfigurationController method postSystems.
@PostMapping("systems")
public RespBody postSystems(@RequestBody JSONObject data) {
String dHomeURL = defaultIfBlank(data, ConfigurationItem.HomeURL);
if (!RegexUtils.isUrl(dHomeURL)) {
return RespBody.errorl("无效主页地址/域名");
}
// 验证数字参数
ConfigurationItem[] validNumbers = new ConfigurationItem[] { ConfigurationItem.RecycleBinKeepingDays, ConfigurationItem.RevisionHistoryKeepingDays, ConfigurationItem.DBBackupsKeepingDays, ConfigurationItem.PasswordExpiredDays };
for (ConfigurationItem item : validNumbers) {
String number = defaultIfBlank(data, item);
if (!NumberUtils.isNumber(number)) {
data.put(item.name(), item.getDefaultValue());
}
}
String dLOGO = data.getString(ConfigurationItem.LOGO.name());
String dLOGOWhite = data.getString(ConfigurationItem.LOGOWhite.name());
if (dLOGO != null || dLOGOWhite != null) {
Application.getCommonsCache().evict(ETAG_DIMGLOGOTIME);
}
String dCustomWallpaper = data.getString(ConfigurationItem.CustomWallpaper.name());
if (dCustomWallpaper != null) {
Application.getCommonsCache().evict(ETAG_DIMGBGIMGTIME);
}
setValues(data);
Application.getBean(RebuildWebConfigurer.class).init();
return RespBody.ok();
}
use of com.rebuild.core.support.ConfigurationItem in project rebuild by getrebuild.
the class BootEnvironmentPostProcessor method postProcessEnvironment.
@Override
public void postProcessEnvironment(ConfigurableEnvironment env, SpringApplication application) {
if (env == null)
env = ENV_HOLD;
try {
// LogbackLoggingSystem#beforeInitialize
((LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory()).resetTurboFilterList();
} catch (Exception ignored) {
}
// 从安装文件
File installed;
try {
installed = getInstallFile();
} catch (RebuildException init) {
throw new IllegalStateException("GET INSTALL FILE ERROR!", init);
}
if (installed != null && installed.exists()) {
log.info("Use installed file : {}", installed);
try {
Properties temp = PropertiesLoaderUtils.loadProperties(new FileSystemResource(installed));
Properties filePs = new Properties();
// compatible: v1.x
for (String name : temp.stringPropertyNames()) {
String value = temp.getProperty(name);
if (name.endsWith(".aes")) {
name = name.substring(0, name.length() - 4);
if (StringUtils.isNotBlank(value)) {
value = "AES(" + value + ")";
}
}
if (name.startsWith(Installer.CONF_PREFIX)) {
filePs.put(name, value);
} else {
filePs.put(Installer.CONF_PREFIX + name, value);
}
}
aesDecrypt(filePs);
env.getPropertySources().addFirst(new PropertiesPropertySource(".rebuild", filePs));
} catch (IOException ex) {
throw new IllegalStateException("READ INSTALL FILE FAILED : " + installed, ex);
}
}
Properties confPs = new Properties();
for (ConfigurationItem item : ConfigurationItem.values()) {
String name = V2_PREFIX + item.name();
String value = env.getProperty(name);
if (value != null)
confPs.put(name, value);
name = Installer.CONF_PREFIX + item.name();
value = env.getProperty(name);
if (value != null)
confPs.put(name, value);
}
String dbUrl = env.getProperty("db.url");
// `application-bean.xml` 占位符必填
if (dbUrl == null) {
dbUrl = "jdbc:mysql://127.0.0.1:3306/rebuild20?characterEncoding=UTF8";
confPs.put("db.url", dbUrl);
}
if (env.getProperty("db.user") == null)
confPs.put("db.user", "rebuild");
if (env.getProperty("db.passwd") == null)
confPs.put("db.passwd", "rebuild");
// fix: v2.1
if (dbUrl.contains("jdbc:mysql") && !dbUrl.contains("serverTimezone")) {
confPs.put("db.url", dbUrl + "&" + MYSQL_J8_TIMEZONE);
} else // fix: v2.2 ~ v2.6.1
if (dbUrl.contains("serverTimezone=UTC")) {
confPs.put("db.url", dbUrl.replace("serverTimezone=UTC", MYSQL_J8_TIMEZONE));
log.info("Fix MYSQL_J8_TIMEZONE : {}", confPs.getProperty("db.url"));
}
aesDecrypt(confPs);
env.getPropertySources().addFirst(new PropertiesPropertySource(".configuration", confPs));
ENV_HOLD = env;
log.info("Use RB data directory : {}", RebuildConfiguration.getFileOfData("/"));
}
Aggregations