Package org.apache.syncope.core.persistence.beans.conf

Examples of org.apache.syncope.core.persistence.beans.conf.CAttr


                LOG.error("While loading job instance for task " + task.getId(), e);
            }
        }

        // 2. NotificationJob
        CAttr notificationJobCronExp = confDAO.find("notificationjob.cronExpression", NotificationJob.DEFAULT_CRON_EXP);
        if (StringUtils.isBlank(notificationJobCronExp.getValuesAsStrings().get(0))) {
            LOG.debug("Empty value provided for NotificationJob's cron, not registering anything on Quartz");
        } else {
            LOG.debug("NotificationJob's cron expression: {} - registering Quartz job and trigger",
                    notificationJobCronExp);

            try {
                registerJob(null, NotificationJob.class.getName(), notificationJobCronExp.getValuesAsStrings().get(0));
            } catch (Exception e) {
                LOG.error("While loading NotificationJob instance", e);
            }
        }
View Full Code Here


        userTO.getMemberships().add(membershipTO);

        userController.create(userTO, true);

        // 3. Set number of retries
        CAttr maxRetries = confDAO.find("notification.maxRetries", "5");
        maxRetries.getValues().clear();
        maxRetries.addValue("5", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
        confDAO.save(maxRetries);
        confDAO.flush();

        // 4. Stop mail server to force error sending mail
        stopGreenMail();

        // 5. force Quartz job execution multiple times
        for (int i = 0; i < 10; i++) {
            notificationJob.execute(null);
        }

        // 6. get NotificationTask, count number of executions
        NotificationTask foundTask = null;
        for (NotificationTask task : taskDAO.findAll(NotificationTask.class)) {
            if (sender.equals(task.getSender())) {
                foundTask = task;
            }
        }
        assertNotNull(foundTask);
        assertEquals(6, notificationManager.countExecutionsWithStatus(foundTask.getId(),
                NotificationJob.Status.NOT_SENT.name()));

        // 7. start mail server again
        startGreenMail();

        // 8. reset number of retries
        maxRetries = confDAO.find("notification.maxRetries", "5");
        maxRetries.getValues().clear();
        maxRetries.addValue("0", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
        confDAO.save(maxRetries);
        confDAO.flush();
    }
View Full Code Here

    @Autowired
    private SchemaDAO schemaDAO;

    @Test
    public void read() {
        CAttr conf = confDAO.find("selfRegistration.allowed");
        assertNotNull(conf);
        assertTrue(conf.getValues().get(0).getBooleanValue());

        conf = confDAO.find("authentication.statuses");
        assertNotNull(conf);
        assertEquals(2, conf.getValues().size());

        conf = confDAO.find("non.existing");
        assertNull(conf);
    }
View Full Code Here

        useless.setType(AttributeSchemaType.Date);
        useless.setConversionPattern("yyyy-MM-dd");
        useless = schemaDAO.save(useless);

        // 2. create conf
        CAttr newConf = new CAttr();
        newConf.setSchema(useless);
        newConf.addValue("2014-06-20", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
        confDAO.save(newConf);

        CAttr actual = confDAO.find("useless");
        assertEquals(actual.getValuesAsStrings(), newConf.getValuesAsStrings());

        // 3. update conf
        newConf.getValues().clear();
        newConf.addValue("2014-06-20", AttributableUtil.getInstance(AttributableType.CONFIGURATION));
        confDAO.save(newConf);

        actual = confDAO.find("useless");
        assertEquals(actual.getValuesAsStrings(), newConf.getValuesAsStrings());

        // 4. delete conf
        confDAO.delete("useless");
        assertNull(confDAO.find("useless"));
    }
View Full Code Here

        if (schema == null) {
            throw new NotFoundException("Conf schema " + attributeTO.getSchema());
        } else {
            SyncopeClientException invalidValues = SyncopeClientException.build(ClientExceptionType.InvalidValues);

            CAttr attr = new CAttr();
            attr.setSchema(schema);
            fillAttribute(attributeTO.getValues(), AttributableUtil.getInstance(AttributableType.CONFIGURATION),
                    schema, attr, invalidValues);

            if (!invalidValues.isEmpty()) {
                throw invalidValues;
View Full Code Here

    }

    @Transactional(readOnly = true)
    @Override
    public CAttr find(final String key, final String defaultValue) {
        CAttr result = find(key);
        if (result == null) {
            result = new CAttr();
            result.setSchema(schemaDAO.find(key, CSchema.class));

            result.addValue(defaultValue, AttributableUtil.getInstance(AttributableType.CONFIGURATION));
        }

        return result;
    }
View Full Code Here

    }

    @Override
    public SyncopeConf delete(final String key) {
        SyncopeConf instance = get();
        CAttr attr = instance.getAttr(key);
        if (attr != null) {
            instance.removeAttr(attr);
            instance = entityManager.merge(instance);
        }
View Full Code Here

        return binder.getConfTO(confDAO.get());
    }

    @PreAuthorize("hasRole('CONFIGURATION_READ')")
    public AttributeTO read(final String key) {
        CAttr conf = confDAO.find(key);
        if (conf == null) {
            throw new NotFoundException("Configuration key " + key);
        }

        return binder.getAttributeTO(conf);
View Full Code Here

                break;
            case MEMBERSHIP:
                result = (T) new MAttr();
                break;
            case CONFIGURATION:
                result = (T) new CAttr();
            default:
        }

        return result;
    }
View Full Code Here

            if (user != null) {
                if (user.isSuspended() != null && user.isSuspended()) {
                    throw new DisabledException("User " + user.getUsername() + " is suspended");
                }

                CAttr authStatuses = confDAO.find("authentication.statuses");
                if (authStatuses != null && !authStatuses.getValuesAsStrings().contains(user.getStatus())) {
                    throw new DisabledException("User " + user.getUsername() + " not allowed to authenticate");
                }

                authenticated = authenticate(user, authentication.getCredentials().toString());
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.conf.CAttr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.