Fixes #790 Refactor app properties and show them in JMX interface

This commit is contained in:
Konstantin Krivopustov 2011-06-30 07:34:03 +00:00
parent 3bfaea4964
commit 44b4c8dcf5
24 changed files with 279 additions and 168 deletions

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2011 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.client;
import com.haulmont.cuba.core.config.Config;
import com.haulmont.cuba.core.config.Property;
import com.haulmont.cuba.core.config.Source;
import com.haulmont.cuba.core.config.SourceType;
import com.haulmont.cuba.core.config.defaults.Default;
import com.haulmont.cuba.core.config.defaults.DefaultBoolean;
import com.haulmont.cuba.core.config.defaults.DefaultString;
/**
* <p>$Id$</p>
*
* @author krivopustov
*/
@Source(type = SourceType.APP)
public interface ClientConfig extends Config {
@Property("cuba.collectionDatasourceDbSortEnabled")
@DefaultBoolean(true)
boolean getCollectionDatasourceDbSortEnabled();
@Property("cuba.screenIdsToSaveHistory")
@Default("sec$User.edit,sec$Group.edit,sec$Role.edit")
String getScreenIdsToSaveHistory();
@Property("cuba.passwordPolicyEnabled")
@DefaultBoolean(false)
public boolean getPasswordPolicyEnabled();
@Property("cuba.passwordPolicyRegExp")
@DefaultString("((?=.*\\d)(?=.*\\p{javaLowerCase})(?=.*\\p{javaUpperCase}).{6,20})")
public String getPasswordPolicyRegExp();
}

View File

@ -12,11 +12,15 @@ package com.haulmont.cuba.core.app;
import com.haulmont.cuba.core.*;
import com.haulmont.cuba.core.entity.Config;
import com.haulmont.cuba.core.sys.AppContext;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang.text.StrBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.annotation.ManagedBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -40,11 +44,11 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
return this;
}
public String printProperties() {
return printProperties(null);
public String printDbProperties() {
return printDbProperties(null);
}
public String printProperties(String prefix) {
public String printDbProperties(String prefix) {
Transaction tx = Locator.createTransaction();
try {
login();
@ -55,7 +59,7 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
(prefix == null ? "" : "where c.name like ?1"));
Query query = em.createQuery(s);
if (prefix != null) {
query.setParameter(1, prefix);
query.setParameter(1, prefix + "%");
}
List<Config> list = query.getResultList();
for (Config config : list) {
@ -71,11 +75,11 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
}
}
public String getProperty(String name) {
public String getDbProperty(String name) {
try {
login();
String value = getConfigProperty(name);
return value;
return name + "=" + value;
} catch (Exception e) {
return ExceptionUtils.getStackTrace(e);
} finally {
@ -83,11 +87,11 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
}
}
public String setProperty(String name, String value) {
public String setDbProperty(String name, String value) {
try {
login();
setConfigProperty(name, value);
return "Done";
return "Property " + name + " set to " + value;
} catch (Exception e) {
return ExceptionUtils.getStackTrace(e);
} finally {
@ -95,7 +99,7 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
}
}
public String removeProperty(String name) {
public String removeDbProperty(String name) {
Transaction tx = Locator.createTransaction();
try {
login();
@ -105,7 +109,7 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
query.executeUpdate();
tx.commit();
cache.remove(name);
return "Done";
return "Property " + name + " removed";
} catch (Exception e) {
return ExceptionUtils.getStackTrace(e);
} finally {
@ -118,6 +122,30 @@ public class ConfigStorage extends ManagementBean implements ConfigStorageMBean,
cache.clear();
}
public String printAppProperties() {
return printAppProperties(null);
}
public String printAppProperties(String prefix) {
List<String> list = new ArrayList<String>();
for (String name : AppContext.getPropertyNames()) {
if (prefix == null || name.startsWith(prefix)) {
list.add(name + "=" + AppContext.getProperty(name));
}
}
Collections.sort(list);
return new StrBuilder().appendWithSeparators(list, "\n").toString();
}
public String getAppProperty(String name) {
return name + "=" + AppContext.getProperty(name);
}
public String setAppProperty(String name, String value) {
AppContext.setProperty(name, value);
return "Property " + name + " set to " + value;
}
public String getConfigProperty(String name) {
String value = cache.get(name);
if (value == nullValue)

View File

@ -17,15 +17,23 @@ public interface ConfigStorageMBean
{
String OBJECT_NAME = "haulmont.cuba:service=ConfigStorage";
String printProperties();
String printDbProperties();
String printProperties(String prefix);
String printDbProperties(String prefix);
String getProperty(String name);
String getDbProperty(String name);
String setProperty(String name, String value);
String setDbProperty(String name, String value);
String removeProperty(String name);
String removeDbProperty(String name);
void clearCache();
String printAppProperties();
String printAppProperties(String prefix);
String getAppProperty(String name);
String setAppProperty(String name, String value);
}

View File

@ -228,7 +228,7 @@ public class DataServiceBean implements DataService {
String str = StringHelper.removeExtraSpaces(query.replace("\n", " "));
if (ConfigProvider.getConfig(LogConfig.class).getCutLoadListQueries()) {
if (ConfigProvider.getConfig(ServerConfig.class).getCutLoadListQueries()) {
str = StringUtils.abbreviate(str.replaceAll("[\\n\\r]", " "), 50);
}

View File

@ -41,7 +41,7 @@ public class FileStorage implements FileStorageMBean, FileStorageAPI {
}
public String getStoragePath() {
String storagePath = ConfigProvider.getConfig(FileStorageConfig.class).getFileStorageDir();
String storagePath = ConfigProvider.getConfig(ServerConfig.class).getFileStorageDir();
if (StringUtils.isBlank(storagePath)) {
String dataDir = ConfigProvider.getConfig(GlobalConfig.class).getDataDir();
storagePath = dataDir + "/filestorage/";
@ -159,7 +159,7 @@ public class FileStorage implements FileStorageMBean, FileStorageAPI {
}
private File getStorageDir(Date createDate) {
String storageDir = ConfigProvider.getConfig(FileStorageConfig.class).getFileStorageDir();
String storageDir = ConfigProvider.getConfig(ServerConfig.class).getFileStorageDir();
if (StringUtils.isBlank(storageDir)) {
String dataDir = ConfigProvider.getConfig(GlobalConfig.class).getDataDir();
storageDir = dataDir + "/filestorage/";

View File

@ -1,23 +0,0 @@
/*
* Copyright (c) 2009 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 29.10.2009 17:41:56
*
* $Id$
*/
package com.haulmont.cuba.core.app;
import com.haulmont.cuba.core.config.Config;
import com.haulmont.cuba.core.config.Source;
import com.haulmont.cuba.core.config.SourceType;
import com.haulmont.cuba.core.config.Property;
@Source(type = SourceType.APP)
public interface FileStorageConfig extends Config {
@Property("cuba.fileStorageDir")
String getFileStorageDir();
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) 2009 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 20.10.2009 11:25:32
*
* $Id$
*/
package com.haulmont.cuba.core.app;
import com.haulmont.cuba.core.config.Config;
import com.haulmont.cuba.core.config.Source;
import com.haulmont.cuba.core.config.SourceType;
import com.haulmont.cuba.core.config.Property;
import com.haulmont.cuba.core.config.defaults.DefaultBoolean;
@Source(type = SourceType.APP)
public interface LogConfig extends Config {
@Property("cuba.log.cutLoadListQueries")
@DefaultBoolean(false)
boolean getCutLoadListQueries();
}

View File

@ -33,6 +33,13 @@ public interface ServerConfig extends Config {
@Property("cuba.userSessionProviderUrl")
String getUserSessionProviderUrl();
/**
* Password to use LoginService.loginTrusted() method
*/
@Property("cuba.trustedClientPassword")
@DefaultString("")
String getTrustedClientPassword();
/**
* User session expiration timeout in seconds.
* Not the same as HTTP session timeout, but should have the same value.
@ -77,4 +84,10 @@ public interface ServerConfig extends Config {
@DefaultBoolean(false)
boolean getDisplayDeviceUnavailable();
@Property("cuba.fileStorageDir")
String getFileStorageDir();
@Property("cuba.log.cutLoadListQueries")
@DefaultBoolean(false)
boolean getCutLoadListQueries();
}

View File

@ -13,7 +13,6 @@ package com.haulmont.cuba.security.app;
import com.haulmont.cuba.core.*;
import com.haulmont.cuba.core.app.ServerConfig;
import com.haulmont.cuba.core.global.ConfigProvider;
import com.haulmont.cuba.core.global.GlobalConfig;
import com.haulmont.cuba.core.global.MessageProvider;
import com.haulmont.cuba.security.entity.User;
import com.haulmont.cuba.security.global.LoginException;
@ -113,7 +112,7 @@ public class LoginWorkerBean implements LoginWorker
}
public UserSession loginTrusted(String login, String password, Locale locale) throws LoginException {
String trustedClientPassword = ConfigProvider.getConfig(GlobalConfig.class).getTrustedClientPassword();
String trustedClientPassword = ConfigProvider.getConfig(ServerConfig.class).getTrustedClientPassword();
if (StringUtils.isBlank(trustedClientPassword) || !trustedClientPassword.equals(password))
throw new LoginException(
String.format(MessageProvider.getMessage(getClass(), "LoginException.InvalidLoginOrPassword", locale), login)

View File

@ -35,12 +35,6 @@ public interface GlobalConfig extends Config {
@DefaultString("cuba")
String getWebContextName();
/**
* List of entitys' id which can restore into the restore screen
*/
@Property("cuba.restoreScreenEntityIds")
String getRestoreEntityId();
/**
* Config directory. Root of all not deployable application configuration and logic.
* Does not end with "/"
@ -69,20 +63,6 @@ public interface GlobalConfig extends Config {
@Property("cuba.dataDir")
String getDataDir();
/**
* Support e-mail. All feedback mails will be sent on this address.
*/
@Property("cuba.supportEmail")
@DefaultString("cubasupport@haulmont.com")
String getSupportEmail();
/**
* System ID. Use for identification. (Support emails)
*/
@Property("cuba.systemId")
@DefaultString("CUBA")
String getSystemID();
/**
* Used to support automatic testing
*/
@ -97,17 +77,6 @@ public interface GlobalConfig extends Config {
@DefaultBoolean(true)
boolean isGroovyClassLoaderEnabled();
/**
* Password to use LoginService.loginTrusted() method
*/
@Property("cuba.trustedClientPassword")
@DefaultString("")
String getTrustedClientPassword();
@Property("cuba.collectionDatasourceDbSortEnabled")
@DefaultBoolean(true)
boolean getCollectionDatasourceDbSortEnabled();
/**
* Used to show alternative locales on user login
*/
@ -115,10 +84,6 @@ public interface GlobalConfig extends Config {
@Default("English|en;Russian|ru")
Map<String, Locale> getAvailableLocales();
@Property("cuba.screenIdsToSaveHistory")
@Default("sec$User.edit,sec$Group.edit,sec$Role.edit")
String getScreenIdsToSaveHistory();
@Property("cuba.useAstBasedJpqlTransformer")
@DefaultBoolean(false)
boolean getUseAstBasedJpqlTransformer();

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2011 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Devyatkin
* Created: 15.03.11 10:55
*
* $Id$
*/
package com.haulmont.cuba.security.app;
import com.haulmont.cuba.core.config.*;
import com.haulmont.cuba.core.config.defaults.DefaultBoolean;
import com.haulmont.cuba.core.config.defaults.DefaultString;
@Prefix("cuba.")
@Source(type = SourceType.APP)
public interface SecurityConfig extends Config {
@DefaultBoolean(false)
public boolean getPasswordPolicyEnabled();
@DefaultString("((?=.*\\d)(?=.*\\p{javaLowerCase})(?=.*\\p{javaUpperCase}).{6,20})")
public String getPasswordPolicyRegExp();
}

View File

@ -7,6 +7,7 @@
package com.haulmont.cuba.gui;
import com.haulmont.chile.core.model.Instance;
import com.haulmont.cuba.client.ClientConfig;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.core.global.UserSessionProvider;
@ -30,7 +31,7 @@ public class ScreenHistorySupport {
private List<String> screenIds;
public ScreenHistorySupport() {
GlobalConfig config = ConfigProvider.getConfig(GlobalConfig.class);
ClientConfig config = ConfigProvider.getConfig(ClientConfig.class);
String property = config.getScreenIdsToSaveHistory();
if (property != null && StringUtils.isNotBlank(property))
screenIds = Arrays.asList(StringUtils.split(property, ','));

View File

@ -5,12 +5,12 @@
*/
package com.haulmont.cuba.gui.app.security.user.changepassw;
import com.haulmont.cuba.client.ClientConfig;
import com.haulmont.cuba.core.global.ConfigProvider;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.haulmont.cuba.gui.components.IFrame;
import com.haulmont.cuba.gui.components.TextField;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.security.app.SecurityConfig;
import com.haulmont.cuba.security.entity.User;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.ObjectUtils;
@ -41,7 +41,7 @@ public class UserChangePassw extends AbstractEditor
if (StringUtils.isBlank(passw) || StringUtils.isBlank(confPassw)) {
showNotification(getMessage("emptyPassword"), NotificationType.WARNING);
} else if (ObjectUtils.equals(passw, confPassw)) {
SecurityConfig passwordPolicyConfig = ConfigProvider.getConfig(SecurityConfig.class);
ClientConfig passwordPolicyConfig = ConfigProvider.getConfig(ClientConfig.class);
if (passwordPolicyConfig.getPasswordPolicyEnabled()) {
String regExp = passwordPolicyConfig.getPasswordPolicyRegExp();
if (passw.matches(regExp)) {

View File

@ -6,11 +6,11 @@
package com.haulmont.cuba.gui.app.security.user.edit;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.client.ClientConfig;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.gui.AppConfig;
import com.haulmont.cuba.gui.ServiceLocator;
import com.haulmont.cuba.gui.UserSessionClient;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.app.security.role.edit.PermissionsLookup;
import com.haulmont.cuba.gui.app.security.user.NameBuilderListener;
@ -21,7 +21,6 @@ import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
import com.haulmont.cuba.security.app.SecurityConfig;
import com.haulmont.cuba.security.app.UserSessionService;
import com.haulmont.cuba.security.entity.*;
import com.haulmont.cuba.security.global.UserSession;
@ -81,7 +80,7 @@ public class UserEditor extends AbstractEditor {
}
public void afterCommit(CommitContext<Entity> context, Map<Entity, Entity> result) {
UserSession us = UserSessionClient.getUserSession();
UserSession us = UserSessionProvider.getUserSession();
for (Map.Entry<Entity, Entity> entry : result.entrySet()) {
if (entry.getKey().equals(us.getUser())) {
us.setUser((User) entry.getValue());
@ -101,7 +100,7 @@ public class UserEditor extends AbstractEditor {
if (PersistenceHelper.isNew(item)) {
addDefaultRoles();
languageLookup.setValue(UserSessionClient.getUserSession().getLocale().getLanguage());
languageLookup.setValue(UserSessionProvider.getUserSession().getLocale().getLanguage());
}
}
@ -250,7 +249,7 @@ public class UserEditor extends AbstractEditor {
return false;
} else {
if (ObjectUtils.equals(passw, confPassw)) {
SecurityConfig passwordPolicyConfig = ConfigProvider.getConfig(SecurityConfig.class);
ClientConfig passwordPolicyConfig = ConfigProvider.getConfig(ClientConfig.class);
if (passwordPolicyConfig.getPasswordPolicyEnabled()) {
String regExp = passwordPolicyConfig.getPasswordPolicyRegExp();
if (passw.matches(regExp)) {

View File

@ -13,6 +13,7 @@ import com.haulmont.chile.core.model.Instance;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.MetaPropertyPath;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.client.ClientConfig;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.gui.components.AggregationInfo;
@ -61,7 +62,7 @@ public class CollectionDatasourceImpl<T extends Entity<K>, K>
protected int firstResult;
protected boolean sortOnDb = ConfigProvider.getConfig(GlobalConfig.class).getCollectionDatasourceDbSortEnabled();
protected boolean sortOnDb = ConfigProvider.getConfig(ClientConfig.class).getCollectionDatasourceDbSortEnabled();
/**
* This constructor is invoked by DsContextLoader, so inheritors must contain a constructor

View File

@ -11,7 +11,6 @@
package com.haulmont.cuba.web;
import com.haulmont.cuba.core.global.ConfigProvider;
import com.haulmont.cuba.core.global.GlobalConfig;
import com.haulmont.cuba.security.global.LoginException;
import com.haulmont.cuba.web.sys.ActiveDirectoryHelper;
@ -44,7 +43,7 @@ public class DefaultConnection extends AbstractConnection implements ActiveDirec
if (locale == null)
throw new IllegalArgumentException("Locale is null");
String password = ConfigProvider.getConfig(GlobalConfig.class).getTrustedClientPassword();
String password = ConfigProvider.getConfig(WebConfig.class).getTrustedClientPassword();
update(getLoginService().loginTrusted(login, password, locale));
}

View File

@ -11,10 +11,7 @@
package com.haulmont.cuba.web;
import com.haulmont.cuba.core.config.*;
import com.haulmont.cuba.core.config.defaults.Default;
import com.haulmont.cuba.core.config.defaults.DefaultBoolean;
import com.haulmont.cuba.core.config.defaults.DefaultInt;
import com.haulmont.cuba.core.config.defaults.DefaultInteger;
import com.haulmont.cuba.core.config.defaults.*;
import com.haulmont.cuba.core.config.type.Factory;
import com.haulmont.cuba.core.config.type.StringListTypeFactory;
@ -34,6 +31,13 @@ public interface WebConfig extends Config
@DefaultBoolean(true)
boolean getUseLocalServiceInvocation();
/**
* Password to use LoginService.loginTrusted() method
*/
@Property("cuba.trustedClientPassword")
@DefaultString("")
String getTrustedClientPassword();
/** Default user login to place into login dialog */
String getLoginDialogDefaultUser();
@ -138,4 +142,24 @@ public interface WebConfig extends Config
@Property("cuba.web.testModeParamName")
@Default("jmeter")
String getTestModeParamName();
/**
* List of entitys' id which can restore into the restore screen
*/
@Property("cuba.restoreScreenEntityIds")
String getRestoreEntityId();
/**
* Support e-mail. All feedback mails will be sent on this address.
*/
@Property("cuba.supportEmail")
@DefaultString("cubasupport@haulmont.com")
String getSupportEmail();
/**
* System ID. Use for identification. (Support emails)
*/
@Property("cuba.systemId")
@DefaultString("CUBA")
String getSystemID();
}

View File

@ -17,7 +17,9 @@ import com.haulmont.cuba.gui.ServiceLocator;
import com.haulmont.cuba.gui.UserSessionClient;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.data.ValueListener;
import com.haulmont.cuba.security.entity.User;
import com.haulmont.cuba.web.AppWindow;
import com.haulmont.cuba.web.WebConfig;
import com.haulmont.cuba.web.app.UserSettingHelper;
import com.haulmont.cuba.web.gui.WebWindow;
import org.apache.commons.lang.StringUtils;
@ -74,22 +76,32 @@ public class FeedbackWindow extends AbstractWindow {
}
if (result) {
try {
WebConfig webConfig = ConfigProvider.getConfig(WebConfig.class);
EmailService emailService = ServiceLocator.lookup(EmailService.NAME);
String infoHeader = "";
infoHeader += (MessageProvider.getMessage(getClass(), "supportEmail") + ".\n");
infoHeader += (MessageProvider.getMessage(getClass(), "systemID") + ": " + (ConfigProvider.getConfig(GlobalConfig.class).getSystemID() == null ? "none" : ConfigProvider.getConfig(GlobalConfig.class).getSystemID()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userLogin") + ": " + (UserSessionClient.getUserSession().getUser().getLogin() == null ? "none" : UserSessionClient.getUserSession().getUser().getLogin()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userEmail") + ": " + (UserSessionClient.getUserSession().getUser().getEmail() == null ? "none" : UserSessionClient.getUserSession().getUser().getEmail()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userFirstName") + ": " + (UserSessionClient.getUserSession().getUser().getFirstName() == null ? "none" : UserSessionClient.getUserSession().getUser().getFirstName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userMiddleName") + ": " + (UserSessionClient.getUserSession().getUser().getMiddleName() == null ? "none" : UserSessionClient.getUserSession().getUser().getMiddleName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userLastName") + ": " + (UserSessionClient.getUserSession().getUser().getLastName() == null ? "none" : UserSessionClient.getUserSession().getUser().getLastName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "timestamp") + ": " + (Datatypes.getInstance().get(Date.class).format(TimeProvider.currentTimestamp())) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "reason") + ": " + (otherReason.equals((String) ((LookupField) getComponent("reason")).getValue()) ? (String) ((TextField) getComponent("reasonFreeText")).getValue() : (String) ((LookupField) getComponent("reason")).getValue()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "systemID") + ": " + (webConfig.getSystemID() == null ? "none" : webConfig.getSystemID()) + "\n");
User user = UserSessionProvider.getUserSession().getUser();
infoHeader += (MessageProvider.getMessage(getClass(), "userLogin") + ": " + (user.getLogin() == null ? "none" : user.getLogin()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userEmail") + ": " + (user.getEmail() == null ? "none" : user.getEmail()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userFirstName") + ": " + (user.getFirstName() == null ? "none" : user.getFirstName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userMiddleName") + ": " + (user.getMiddleName() == null ? "none" : user.getMiddleName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "userLastName") + ": " + (user.getLastName() == null ? "none" : user.getLastName()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "timestamp") + ": " + (Datatypes.get(Date.class).format(TimeProvider.currentTimestamp())) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "reason") + ": "
+ (otherReason.equals(((LookupField) getComponent("reason")).getValue())
? (String) ((TextField) getComponent("reasonFreeText")).getValue()
: (String) ((LookupField) getComponent("reason")).getValue()) + "\n");
infoHeader += (MessageProvider.getMessage(getClass(), "mailBody") + ": \n");
infoHeader += ((String) ((TextField) getComponent("mainBody")).getValue());
EmailInfo emailInfo = new EmailInfo(
ConfigProvider.getConfig(GlobalConfig.class).getSupportEmail(),
"[Feedback Form][" + ConfigProvider.getConfig(GlobalConfig.class).getSystemID() + "][" + UserSessionClient.getUserSession().getUser().getLogin() + "][" + Datatypes.getInstance().get(Date.class).format(TimeProvider.currentTimestamp()) + "] " + (otherReason.equals((String) ((LookupField) getComponent("reason")).getValue()) ? (String) ((TextField) getComponent("reasonFreeText")).getValue() : (String) ((LookupField) getComponent("reason")).getValue()),
webConfig.getSupportEmail(),
"[Feedback Form][" + webConfig.getSystemID() + "]["
+ user.getLogin() + "]["
+ Datatypes.get(Date.class).format(TimeProvider.currentTimestamp()) + "] "
+ (otherReason.equals(((LookupField) getComponent("reason")).getValue())
? (String) ((TextField) getComponent("reasonFreeText")).getValue()
: (String) ((LookupField) getComponent("reason")).getValue()),
null,
null,
null,

View File

@ -15,21 +15,20 @@ import com.haulmont.chile.core.model.MetaProperty;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.entity.SoftDelete;
import com.haulmont.cuba.core.global.ConfigProvider;
import com.haulmont.cuba.core.global.GlobalConfig;
import com.haulmont.cuba.core.global.MessageProvider;
import com.haulmont.cuba.core.global.MetadataProvider;
import com.haulmont.cuba.core.sys.AppContext;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.data.impl.GenericDataService;
import com.haulmont.cuba.gui.data.impl.GroupDatasourceImpl;
import com.haulmont.cuba.web.WebConfig;
import com.haulmont.cuba.web.gui.components.WebButton;
import com.haulmont.cuba.web.gui.components.WebFilter;
import com.haulmont.cuba.web.gui.components.WebTable;
import com.haulmont.cuba.web.gui.components.WebVBoxLayout;
import org.apache.commons.lang.StringUtils;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class EntityRestore extends AbstractWindow{
@ -146,8 +145,7 @@ public class EntityRestore extends AbstractWindow{
});
primaryFilter.setVisible(false);
tablePanel = getComponent("table-panel");
GlobalConfig globalConfig = ConfigProvider.getConfig(GlobalConfig.class);
String restoreEntitys = globalConfig.getRestoreEntityId();
String restoreEntitys = ConfigProvider.getConfig(WebConfig.class).getRestoreEntityId();
Map<String,Object> options = new java.util.TreeMap<String,Object>();
if (restoreEntitys == null || StringUtils.isBlank(restoreEntitys)) {
for (MetaClass metaClass : MetadataProvider.getSession().getClasses()) {

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2011 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.jmx;
import com.haulmont.cuba.core.sys.AppContext;
import org.apache.commons.lang.text.StrBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <p>$Id$</p>
*
* @author krivopustov
*/
public class Configuration implements ConfigurationMBean {
@Override
public String printAppProperties() {
return printAppProperties(null);
}
@Override
public String printAppProperties(String prefix) {
List<String> list = new ArrayList<String>();
for (String name : AppContext.getPropertyNames()) {
if (prefix == null || name.startsWith(prefix)) {
list.add(name + "=" + AppContext.getProperty(name));
}
}
Collections.sort(list);
return new StrBuilder().appendWithSeparators(list, "\n").toString();
}
@Override
public String getAppProperty(String name) {
return name + "=" + AppContext.getProperty(name);
}
@Override
public String setAppProperty(String name, String value) {
AppContext.setProperty(name, value);
return "Property " + name + " set to " + value;
}
}

View File

@ -0,0 +1,24 @@
/*
* Copyright (c) 2011 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.jmx;
/**
* <p>$Id$</p>
*
* @author krivopustov
*/
public interface ConfigurationMBean {
String printAppProperties();
String printAppProperties(String prefix);
String getAppProperty(String name);
String setAppProperty(String name, String value);
}

View File

@ -29,6 +29,10 @@ public class OperationResultWindow extends AbstractWindow {
protected void init(Map<String, Object> params) {
super.init(params);
getDialogParams().setResizable(true);
getDialogParams().setWidth(800);
getDialogParams().setHeight(600);
Throwable ex = (Throwable) params.get("param$exception");
Object result = params.get("param$result");

View File

@ -10,15 +10,14 @@
</dsContext>
<layout expand="table-panel" expandLayout="space">
<scrollbox id="scrollbox" height="350px">
<vbox spacing="true" id="container">
<layout expand="content">
<vbox id="content">
<scrollbox id="scrollbox">
<vbox spacing="true" id="container">
</vbox>
</scrollbox>
</vbox>
</scrollbox>
</vbox>
<button id="close" icon="icons/ok.png"/>
<hbox id="space">
</hbox>
</layout>
</window>

View File

@ -28,6 +28,27 @@
<constructor-arg index="0" ref="cuba_ConfigProvider"/>
</bean>
<bean id="cuba_web_Configuration" class="com.haulmont.cuba.web.jmx.Configuration"/>
<!-- MBeans registration -->
<bean id="cuba_web_MBeanExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
<entry key="${cuba.webContextName}.cuba:service=Configuration" value-ref="cuba_web_Configuration"/>
</map>
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="interfaceMappings">
<map>
<entry key="cuba_PersistenceManager" value="com.haulmont.cuba.web.jmx.ConfigurationMBean"/>
</map>
</property>
</bean>
</property>
</bean>
<!-- Remote stubs -->
<bean id="cuba_proxyCreator" class="com.haulmont.cuba.web.sys.remoting.WebRemoteProxyBeanCreator">