Search in sources :

Example 6 with Configuration

use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.

the class ConfigsPanel method onInitialize.

@Override
protected void onInitialize() {
    SearchableDataView<Configuration> dataView = new SearchableDataView<Configuration>("configList", new SearchableDataProvider<>(ConfigurationDao.class)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Configuration> item) {
            final Configuration c = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("key"));
            item.add(new Label("value"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.hideNewRecord();
                    form.setModelObject(c);
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.replace(ATTR_CLASS, getRowClass(c.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<Configuration> container = new DataViewContainer<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderById", "id", container)).addLink(new OmOrderByBorder<>("orderByKey", "key", container)).addLink(new OmOrderByBorder<>("orderByValue", "value", container));
    add(container.getLinks());
    add(navigator);
    form = new ConfigForm("form", listContainer, new Configuration());
    form.showNewRecord();
    add(form);
    super.onInitialize();
}
Also used : ConfigurationDao(org.apache.openmeetings.db.dao.basic.ConfigurationDao) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer)

Example 7 with Configuration

use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.

the class TestLoginUI method testCompleteRegister.

// complex test
@Test
public void testCompleteRegister() throws ReflectiveOperationException, SecurityException {
    // set activation properties
    List<Configuration> cfgs = cfgDao.get(CONFIG_EMAIL_AT_REGISTER, CONFIG_EMAIL_VERIFICATION);
    for (Configuration c : cfgs) {
        c.setValueB(true);
        cfgDao.update(c, null);
    }
    try {
        tester.startPage(SignInPage.class);
        tester.assertRenderedPage(SignInPage.class);
        // number uid is used to prevent password validation errors
        String uid = String.valueOf(Math.abs(rnd.nextLong()));
        performRegister(uid, "warn.notverified");
        // activate
        User u = userDao.getByLogin(getLogin(uid), User.Type.user, null);
        assertNotNull(u);
        assertFalse(u.getRights().contains(User.Right.Login));
        tester.startPage(ActivatePage.class, new PageParameters().add(ActivatePage.ACTIVATION_PARAM, u.getActivatehash()));
        tester.assertRenderedPage(SignInPage.class);
        // check activated
        u = userDao.getByLogin(getLogin(uid), User.Type.user, null);
        assertNotNull(u);
        assertNull(u.getActivatehash());
        assertTrue(u.getRights().contains(User.Right.Login));
        checkLogin(getEmail(uid), userpass);
        // logout
        Locale loc = tester.getSession().getLocale();
        tester.getSession().invalidateNow();
        tester.getSession().setLocale(loc);
        // forget by 'random'
        performForget(uid);
        // reset password
        u = userDao.getByEmail(getEmail(uid));
        assertNotNull(u);
        assertNotNull(u.getResethash());
        tester.startPage(ResetPage.class, new PageParameters().add(ResetPage.RESET_PARAM, u.getResethash()));
        tester.assertRenderedPage(ResetPage.class);
        // check reset
        String passwd = "q1W@e3r4t5";
        FormTester resetTester = tester.newFormTester("resetPassword:form");
        resetTester.setValue("password", passwd);
        resetTester.setValue("confirmPassword", passwd);
        resetTester.submit("submit");
        checkErrors(0);
        tester.assertLabel("resetPassword:confirmReset:container:message", getEscapedString("332"));
    } finally {
        for (Configuration c : cfgs) {
            c.setValueB(false);
            cfgDao.update(c, null);
        }
    }
}
Also used : Locale(java.util.Locale) User(org.apache.openmeetings.db.entity.user.User) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) FormTester(org.apache.wicket.util.tester.FormTester) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Test(org.junit.Test)

Example 8 with Configuration

use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.

the class ConfigurationDao method forceGet.

/**
 * Retrieves Configuration regardless of its deleted status
 *
 * @param key - key of the {@link Configuration} to get
 * @return correspondent {@link Configuration} or null
 */
public Configuration forceGet(String key) {
    try {
        List<Configuration> list = em.createNamedQuery("forceGetConfigurationByKey", Configuration.class).setParameter("key", key).getResultList();
        if (list.isEmpty()) {
            return null;
        }
        Configuration c = list.get(0);
        return c.getKey().equals(key) ? c : null;
    } catch (Exception e) {
        log.error("[forceGet]: ", e);
    }
    return null;
}
Also used : OpenJPAConfiguration(org.apache.openjpa.conf.OpenJPAConfiguration) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) UnknownHostException(java.net.UnknownHostException)

Example 9 with Configuration

use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.

the class TestConfig method getConfigs.

@Test
public void getConfigs() {
    try {
        List<Configuration> list = cfgDao.get(4, 6);
        for (Configuration conf : list) {
            log.error("conf.getKey() " + conf.getKey());
            log.error("conf.getUser() " + conf.getUser());
            if (conf.getUser() != null) {
                log.error("conf.getUsers() " + conf.getUser().getLogin());
            }
        }
        assertEquals(list.size(), 6);
    } catch (Exception err) {
        log.error("[startConversion]", err);
    }
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration) Test(org.junit.Test)

Example 10 with Configuration

use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.

the class TestConfig method getConfigKey.

@Test
public void getConfigKey() {
    System.err.println("THIS");
    Configuration smtp_server = cfgDao.get(CONFIG_SMTP_SERVER);
    System.err.println("smtp_server " + smtp_server.getUser());
    assertNull(smtp_server.getUser());
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration) Test(org.junit.Test)

Aggregations

Configuration (org.apache.openmeetings.db.entity.basic.Configuration)17 Test (org.junit.Test)3 Serializer (org.simpleframework.xml.Serializer)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 Locale (java.util.Locale)1 OpenJPAConfiguration (org.apache.openjpa.conf.OpenJPAConfiguration)1 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)1 ConfigurationDao (org.apache.openmeetings.db.dao.basic.ConfigurationDao)1 Type (org.apache.openmeetings.db.entity.basic.Configuration.Type)1 User (org.apache.openmeetings.db.entity.user.User)1 InstallationConfig (org.apache.openmeetings.installation.InstallationConfig)1 SearchableDataView (org.apache.openmeetings.web.admin.SearchableDataView)1 PagedEntityListPanel (org.apache.openmeetings.web.common.PagedEntityListPanel)1 DataViewContainer (org.apache.openmeetings.web.data.DataViewContainer)1 OmOrderByBorder (org.apache.openmeetings.web.data.OmOrderByBorder)1