Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.SchemaTO


@FixMethodOrder(MethodSorters.JVM)
public class ConfigurationTestITCase extends AbstractTest {

    @Test
    public void create() {
        SchemaTO testKey = new SchemaTO();
        testKey.setName("testKey");
        testKey.setType(AttributeSchemaType.String);
        createSchema(AttributableType.CONFIGURATION, SchemaType.NORMAL, testKey);

        AttributeTO conf = new AttributeTO();
        conf.setSchema("testKey");
        conf.getValues().add("testValue");
View Full Code Here


        assertTrue(configExport.length() > 1000);
    }

    @Test
    public void issueSYNCOPE418() {
        SchemaTO failing = new SchemaTO();
        failing.setName("http://schemas.examples.org/security/authorization/organizationUnit");
        failing.setType(AttributeSchemaType.String);

        try {
            createSchema(AttributableType.CONFIGURATION, SchemaType.NORMAL, failing);
            fail();
        } catch (SyncopeClientException e) {
View Full Code Here

    }

    @Test
    public void createWithMandatorySchemaNotTemplate() {
        // 1. create a role mandatory schema
        SchemaTO badge = new SchemaTO();
        badge.setName("badge");
        badge.setMandatoryCondition("true");
        schemaService.create(AttributableType.ROLE, SchemaType.NORMAL, badge);

        // 2. create a role *without* an attribute for that schema: it works
        RoleTO roleTO = buildRoleTO("lastRole");
        assertFalse(roleTO.getAttrMap().containsKey(badge.getName()));
        roleTO = createRole(roleTO);
        assertNotNull(roleTO);
        assertFalse(roleTO.getAttrMap().containsKey(badge.getName()));

        // 3. add a template for badge to the role just created -
        // failure since no values are provided and it is mandatory
        RoleMod roleMod = new RoleMod();
        roleMod.setId(roleTO.getId());
        roleMod.setModRAttrTemplates(true);
        roleMod.getRAttrTemplates().add("badge");

        try {
            updateRole(roleMod);
            fail();
        } catch (SyncopeClientException e) {
            assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
        }

        // 4. also add an actual attribute for badge - it will work       
        roleMod.getAttrsToUpdate().add(attributeMod(badge.getName(), "xxxxxxxxxx"));

        roleTO = updateRole(roleMod);
        assertNotNull(roleTO);
        assertTrue(roleTO.getAttrMap().containsKey(badge.getName()));
    }
View Full Code Here

    }

    public <T extends AbstractNormalSchema> SchemaTO getSchemaTO(
            final T schema, final AttributableUtil attributableUtil) {

        SchemaTO schemaTO = new SchemaTO();
        BeanUtils.copyProperties(schema, schemaTO);

        return schemaTO;
    }
View Full Code Here

     *
     * @param name (e.g.:surname)
     * @return schemaTO
     */
    public SchemaTO readSchema(final AttributableType type, final String name) {
        SchemaTO schema = null;

        try {
            schema = getService(SchemaService.class).read(type, SchemaType.NORMAL, name);
        } catch (SyncopeClientException e) {
            LOG.error("While reading a user schema", e);
View Full Code Here

     *
     * @param name (e.g.:surname)
     * @return schemaTO
     */
    public SchemaTO deleteSchema(final AttributableType type, final String name) {
        SchemaTO response = getService(SchemaService.class).read(type, SchemaType.NORMAL, name);
        getService(SchemaService.class).delete(type, SchemaType.NORMAL, name);
        return response;
    }
View Full Code Here

    @Override
    public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window,
            final SchemaTO schemaTO, final boolean createFlag) {

        final SchemaTO schema = schemaTO == null
                ? new SchemaTO()
                : schemaTO;

        final Form<SchemaTO> schemaForm = new Form<SchemaTO>(FORM);

        schemaForm.setModel(new CompoundPropertyModel<SchemaTO>(schema));
        schemaForm.setOutputMarkupId(true);

        final AjaxTextFieldPanel name =
                new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(schema, "name"));
        name.addRequiredLabel();
        name.setEnabled(createFlag);
        schemaForm.add(name);

        final AjaxDropDownChoicePanel<AttributeSchemaType> type = new AjaxDropDownChoicePanel<AttributeSchemaType>(
                "type", getString("type"), new PropertyModel<AttributeSchemaType>(schema, "type"));
        type.setChoices(Arrays.asList(AttributeSchemaType.values()));
        type.addRequiredLabel();
        schemaForm.add(type);

        // -- long, double, date
        final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern",
                getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern"));
        schemaForm.add(conversionPattern);

        final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams");
        conversionParams.setOutputMarkupPlaceholderTag(true);
        conversionParams.add(conversionPattern);
        schemaForm.add(conversionParams);

        // -- enum
        final AjaxTextFieldPanel enumerationValuesPanel =
                new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null));
        @SuppressWarnings({ "unchecked", "rawtypes" })
        final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<String>("enumerationValues",
                new Model(),
                enumerationValuesPanel);
        enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues()));

        @SuppressWarnings({ "unchecked", "rawtypes" })
        final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<String>("enumerationKeys",
                new Model(),
                new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null)));
        enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys()));

        final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams");
        enumParams.setOutputMarkupPlaceholderTag(true);
        enumParams.add(enumerationValues);
        enumParams.add(enumerationKeys);
        schemaForm.add(enumParams);

        // -- encrypted
        final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey",
                getString("secretKey"), new PropertyModel<String>(schema, "secretKey"));

        final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<CipherAlgorithm>(
                "cipherAlgorithm", getString("cipherAlgorithm"),
                new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm"));
        cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values()));

        final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams");
        encryptedParams.setOutputMarkupPlaceholderTag(true);
        encryptedParams.add(secretKey);
        encryptedParams.add(cipherAlgorithm);
        schemaForm.add(encryptedParams);

        // -- binary
        final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType",
                getString("mimeType"), new PropertyModel<String>(schema, "mimeType"));
        mimeType.setChoices(mimeTypesInitializer.getMimeTypes());
       
        final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams");
        binaryParams.setOutputMarkupPlaceholderTag(true);
        binaryParams.add(mimeType);
        schemaForm.add(binaryParams);

        // -- show or hide
        showHide(schema, type,
                conversionParams, conversionPattern,
                enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys,
                encryptedParams, secretKey, cipherAlgorithm,
                binaryParams, mimeType);
        type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                SchemaModalPage.this.showHide(schema, type,
                        conversionParams, conversionPattern,
                        enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys,
                        encryptedParams, secretKey, cipherAlgorithm,
                        binaryParams, mimeType);
                target.add(schemaForm);
            }
        });

        final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() {

            private static final long serialVersionUID = 5275935387613157437L;

            @Override
            protected List<String> load() {
                return schemaRestClient.getAllValidatorClasses();
            }
        };
        final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass",
                getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass"));
        ((DropDownChoice) validatorClass.getField()).setNullValid(true);
        validatorClass.setChoices(validatorsList.getObject());
        schemaForm.add(validatorClass);

        final AutoCompleteTextField<String> mandatoryCondition =
                new AutoCompleteTextField<String>("mandatoryCondition") {

                    private static final long serialVersionUID = -2428903969518079100L;

                    @Override
                    protected Iterator<String> getChoices(final String input) {
                        List<String> choices = new ArrayList<String>();

                        if (Strings.isEmpty(input)) {
                            choices = Collections.emptyList();
                        } else if ("true".startsWith(input.toLowerCase())) {
                            choices.add("true");
                        } else if ("false".startsWith(input.toLowerCase())) {
                            choices.add("false");
                        }

                        return choices.iterator();
                    }
                };
        mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
            }
        });
        schemaForm.add(mandatoryCondition);

        final WebMarkupContainer pwdJexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp");

        final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp, "questionMarkJexlHelp");
        schemaForm.add(pwdQuestionMarkJexlHelp);
        pwdQuestionMarkJexlHelp.add(pwdJexlHelp);

        final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"),
                new PropertyModel<Boolean>(schema, "multivalue"));
        schemaForm.add(multivalue);

        final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"),
                new PropertyModel<Boolean>(schema, "readonly"));
        schemaForm.add(readonly);

        final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint",
                getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint"));
        schemaForm.add(uniqueConstraint);

        final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) {

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                final SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject();

                schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject()));
                schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject()));

                if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) {
                    error(getString("multivalueAndUniqueConstr.validation"));
                    feedbackPanel.refresh(target);
                    return;
                }
View Full Code Here

        connInstanceTO.setId(connInstanceId);
       
        List<String> schemaNames = controller.getSchemaNames(connInstanceTO, includeSpecial);
        List<SchemaTO> result = new ArrayList<SchemaTO>(schemaNames.size());
        for (String name : schemaNames) {
            SchemaTO schemaTO = new SchemaTO();
            schemaTO.setName(name);
            result.add(schemaTO);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.SchemaTO

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.