Search in sources :

Example 1 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class AppPropertiesEdit method ok.

public void ok() {
    AppPropertyEntity appPropertyEntity = appPropertyDs.getItem();
    // Save property through the client-side cache to ensure it is updated in the cache immediately
    Configuration configuration = AppBeans.get(Configuration.class);
    ConfigStorageService configStorageService = ((ConfigurationClientImpl) configuration).getConfigStorageService();
    configStorageService.setDbProperty(appPropertyEntity.getName(), appPropertyEntity.getCurrentValue());
    close(COMMIT_ACTION_ID);
}
Also used : AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity) Configuration(com.haulmont.cuba.core.global.Configuration) ConfigurationClientImpl(com.haulmont.cuba.client.sys.ConfigurationClientImpl) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService)

Example 2 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class NonEntityQueryTest method testInMemoryAndSeveralConstraintsWithError.

@Test
public void testInMemoryAndSeveralConstraintsWithError() throws Exception {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    configStorageService.setDbProperty("cuba.disableLoadValuesIfConstraints", "true");
    LoginWorker lw = AppBeans.get(LoginWorker.NAME);
    UserSession userSession = lw.login(USER_NAME_2, passwordEncryption.getPlainHash(USER_PASSWORD), Locale.getDefault());
    assertNotNull(userSession);
    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        ValueLoadContext context = ValueLoadContext.create();
        context.setQueryString("select s.viewXml from sys$EntitySnapshot s");
        context.addProperty("viewXml");
        try {
            dataManager.secure().loadValues(context);
            fail();
        } catch (RowLevelSecurityException e) {
        }
        context = ValueLoadContext.create();
        context.setQueryString("select s.name, sn.viewXml from sys$Server s, sys$EntitySnapshot sn");
        context.addProperty("name");
        context.addProperty("viewXml");
        try {
            dataManager.secure().loadValues(context);
            fail();
        } catch (RowLevelSecurityException e) {
        }
    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
Also used : LoginWorker(com.haulmont.cuba.security.app.LoginWorker) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) UserSession(com.haulmont.cuba.security.global.UserSession) Test(org.junit.Test)

Example 3 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class NonEntityQueryTest method testIncorrectPathInWhere.

@Test
public void testIncorrectPathInWhere() throws Exception {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    configStorageService.setDbProperty("cuba.disableLoadValuesIfConstraints", "true");
    LoginWorker lw = AppBeans.get(LoginWorker.NAME);
    UserSession userSession = lw.login(USER_NAME_1, passwordEncryption.getPlainHash(USER_PASSWORD), Locale.getDefault());
    assertNotNull(userSession);
    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        ValueLoadContext context = ValueLoadContext.create();
        context.setQueryString("select s.viewXml from sys$EntitySnapshot s where s.name1 = '1'");
        context.addProperty("viewXml");
        dataManager.secure().loadValues(context);
    } catch (NullPointerException e) {
        fail("Handling property path error");
    } catch (IllegalStateException e) {
        if (!"query path 's.name1' is unresolved".equals(e.getMessage())) {
            throw e;
        }
    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
Also used : LoginWorker(com.haulmont.cuba.security.app.LoginWorker) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) UserSession(com.haulmont.cuba.security.global.UserSession) Test(org.junit.Test)

Example 4 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class NonEntityQueryTest method testInMemoryAndSeveralConstraints.

@Test
public void testInMemoryAndSeveralConstraints() throws Exception {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    configStorageService.setDbProperty("cuba.disableLoadValuesIfConstraints", "false");
    LoginWorker lw = AppBeans.get(LoginWorker.NAME);
    UserSession userSession = lw.login(USER_NAME_2, passwordEncryption.getPlainHash(USER_PASSWORD), Locale.getDefault());
    assertNotNull(userSession);
    UserSessionSource uss = AppBeans.get(UserSessionSource.class);
    UserSession savedUserSession = uss.getUserSession();
    ((TestUserSessionSource) uss).setUserSession(userSession);
    try {
        ValueLoadContext context = ValueLoadContext.create();
        context.setQueryString("select s.viewXml from sys$EntitySnapshot s");
        context.addProperty("viewXml");
        List<KeyValueEntity> list = dataManager.secure().loadValues(context);
        assertEquals(1, list.size());
        context = ValueLoadContext.create();
        context.setQueryString("select s.name, sn.viewXml from sys$Server s, sys$EntitySnapshot sn");
        context.addProperty("name");
        context.addProperty("viewXml");
        list = dataManager.secure().loadValues(context);
        assertEquals(0, list.size());
    } finally {
        ((TestUserSessionSource) uss).setUserSession(savedUserSession);
    }
}
Also used : LoginWorker(com.haulmont.cuba.security.app.LoginWorker) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService) TestUserSessionSource(com.haulmont.cuba.testsupport.TestUserSessionSource) UserSession(com.haulmont.cuba.security.global.UserSession) KeyValueEntity(com.haulmont.cuba.core.entity.KeyValueEntity) Test(org.junit.Test)

Example 5 with ConfigStorageService

use of com.haulmont.cuba.core.app.ConfigStorageService in project cuba by cuba-platform.

the class AppPropertiesDatasource method loadAppPropertyEntities.

public List<AppPropertyEntity> loadAppPropertyEntities() {
    ConfigStorageService configStorageService = AppBeans.get(ConfigStorageService.class);
    List<AppPropertyEntity> entities = configStorageService.getAppProperties();
    AppPropertiesLocator appPropertiesLocator = AppBeans.get(AppPropertiesLocator.class);
    entities.addAll(appPropertiesLocator.getAppProperties());
    return entities;
}
Also used : AppPropertiesLocator(com.haulmont.cuba.core.config.AppPropertiesLocator) AppPropertyEntity(com.haulmont.cuba.core.config.AppPropertyEntity) ConfigStorageService(com.haulmont.cuba.core.app.ConfigStorageService)

Aggregations

ConfigStorageService (com.haulmont.cuba.core.app.ConfigStorageService)6 LoginWorker (com.haulmont.cuba.security.app.LoginWorker)4 UserSession (com.haulmont.cuba.security.global.UserSession)4 TestUserSessionSource (com.haulmont.cuba.testsupport.TestUserSessionSource)4 Test (org.junit.Test)4 AppPropertyEntity (com.haulmont.cuba.core.config.AppPropertyEntity)2 ConfigurationClientImpl (com.haulmont.cuba.client.sys.ConfigurationClientImpl)1 AppPropertiesLocator (com.haulmont.cuba.core.config.AppPropertiesLocator)1 KeyValueEntity (com.haulmont.cuba.core.entity.KeyValueEntity)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 List (java.util.List)1