Package org.apache.syncope.common.to

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


        }
    }

    @Test
    public void read() {
        VirSchemaTO vSchemaTO = schemaService.read(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL,
                "mvirtualdata");
        assertNotNull(vSchemaTO);
    }
View Full Code Here


        assertNotNull(vSchemaTO);
    }

    @Test
    public void create() {
        VirSchemaTO schema = new VirSchemaTO();
        schema.setName("virtual");

        VirSchemaTO actual = createSchema(AttributableType.USER, SchemaType.VIRTUAL, schema);
        assertNotNull(actual);

        actual = schemaService.read(AttributableType.USER, SchemaType.VIRTUAL, actual.getName());
        assertNotNull(actual);
    }
View Full Code Here

        assertNotNull(actual);
    }

    @Test
    public void delete() {
        VirSchemaTO schema = schemaService.read(AttributableType.ROLE, SchemaType.VIRTUAL, "rvirtualdata");
        assertNotNull(schema);

        schemaService.delete(AttributableType.ROLE, SchemaType.VIRTUAL, schema.getName());

        try {
            schemaService.read(AttributableType.ROLE, SchemaType.VIRTUAL, "rvirtualdata");
            fail();
        } catch (SyncopeClientException e) {
View Full Code Here

        }
    }

    @Test
    public void issueSYNCOPE323() {
        VirSchemaTO actual = schemaService.read(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL, "mvirtualdata");
        assertNotNull(actual);

        try {
            createSchema(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL, actual);
            fail();
        } catch (SyncopeClientException e) {
            assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus());
            assertEquals(ClientExceptionType.EntityExists, e.getType());
        }

        actual.setName(null);
        try {
            createSchema(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL, actual);
            fail();
        } catch (SyncopeClientException e) {
            assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus());
View Full Code Here

        }
    }

    @Test
    public void issueSYNCOPE418() {
        VirSchemaTO schema = new VirSchemaTO();
        schema.setName("http://schemas.examples.org/security/authorization/organizationUnit");

        try {
            createSchema(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL, schema);
            fail();
        } catch (SyncopeClientException e) {
View Full Code Here

            private static final long serialVersionUID = 5275935387613157437L;

            private void filter(final List<VirSchemaTO> schemaTOs, final Set<String> allowed) {
                for (ListIterator<VirSchemaTO> itor = schemaTOs.listIterator(); itor.hasNext();) {
                    VirSchemaTO schema = itor.next();
                    if (!allowed.contains(schema.getName())) {
                        itor.remove();
                    }
                }
            }

            @Override
            protected List<String> load() {
                List<VirSchemaTO> schemaTOs;

                if (entityTO instanceof RoleTO) {
                    final RoleTO roleTO = (RoleTO) entityTO;

                    schemaTOs = schemaRestClient.getVirSchemas(AttributableType.ROLE);
                    Set<String> allowed;
                    if (attrTemplates == null) {
                        allowed = new HashSet<String>(roleTO.getRVirAttrTemplates());
                    } else {
                        allowed = new HashSet<String>(attrTemplates.getSelected(
                                AttrTemplatesPanel.Type.rVirAttrTemplates));
                        if (roleTO.isInheritTemplates() && roleTO.getParent() != 0) {
                            allowed.addAll(roleRestClient.read(roleTO.getParent()).getRVirAttrTemplates());
                        }
                    }
                    filter(schemaTOs, allowed);
                } else if (entityTO instanceof UserTO) {
                    schemaTOs = schemaRestClient.getVirSchemas(AttributableType.USER);
                } else {
                    schemaTOs = schemaRestClient.getVirSchemas(AttributableType.MEMBERSHIP);
                    Set<String> allowed = new HashSet<String>(
                            roleRestClient.read(((MembershipTO) entityTO).getRoleId()).getMVirAttrTemplates());
                    filter(schemaTOs, allowed);
                }

                schemas.clear();

                for (VirSchemaTO schemaTO : schemaTOs) {
                    schemas.put(schemaTO.getName(), schemaTO);
                }

                return new ArrayList<String>(schemas.keySet());
            }
        };

        final WebMarkupContainer attributesContainer = new WebMarkupContainer("virAttrContainer");
        attributesContainer.setOutputMarkupId(true);
        add(attributesContainer);

        AjaxButton addAttributeBtn = new IndicatingAjaxButton("addAttributeBtn", new ResourceModel("addAttributeBtn")) {

            private static final long serialVersionUID = -4804368561204623354L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                entityTO.getVirAttrs().add(new AttributeTO());
                target.add(attributesContainer);
            }

            @Override
            protected void onError(final AjaxRequestTarget target, final Form<?> form) {
                target.add(attributesContainer);
            }
        };

        add(addAttributeBtn.setDefaultFormProcessing(Boolean.FALSE));

        ListView<AttributeTO> attributes = new ListView<AttributeTO>("attrs",
                new PropertyModel<List<? extends AttributeTO>>(entityTO, "virAttrs")) {

            private static final long serialVersionUID = 9101744072914090143L;

            @Override
            @SuppressWarnings("unchecked")
            protected void populateItem(final ListItem<AttributeTO> item) {
                final AttributeTO attributeTO = item.getModelObject();

                item.add(new AjaxDecoratedCheckbox("toRemove", new Model<Boolean>(Boolean.FALSE)) {

                    private static final long serialVersionUID = 7170946748485726506L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        entityTO.getVirAttrs().remove(attributeTO);
                        target.add(attributesContainer);
                    }

                    @Override
                    protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
                        super.updateAjaxAttributes(attributes);

                        final AjaxCallListener ajaxCallListener = new AjaxCallListener() {

                            private static final long serialVersionUID = 7160235486520935153L;

                            @Override
                            public CharSequence getPrecondition(final Component component) {
                                return "if (!confirm('" + getString("confirmDelete") + "')) return false;";
                            }
                        };
                        attributes.getAjaxCallListeners().add(ajaxCallListener);
                    }
                });

                if (attributeTO.getValues().isEmpty()) {
                    attributeTO.getValues().add("");
                }

                if (attributeTO.getSchema() != null) {
                    VirSchemaTO attributeSchema = schemas.get(attributeTO.getSchema());
                    if (attributeSchema != null) {
                        attributeTO.setReadonly(attributeSchema.isReadonly());
                    }
                }

                final AjaxTextFieldPanel panel;
                final MultiFieldPanel multiPanel;
                if (templateMode) {
                    panel = new AjaxTextFieldPanel("values", "values", new Model<String>());
                    panel.setReadOnly(attributeTO.isReadonly());
                    multiPanel = null;
                } else {
                    panel = new AjaxTextFieldPanel("panel", "values", new Model<String>(null));
                    panel.setReadOnly(attributeTO.isReadonly());
                    multiPanel = new MultiFieldPanel("values",
                            new PropertyModel<List<String>>(attributeTO, "values"), panel);
                }

                final DropDownChoice<String> schemaChoice = new DropDownChoice<String>("schema",
                        new PropertyModel<String>(attributeTO, "schema"), virSchemas,
                        new ChoiceRenderer<String>() {

                    private static final long serialVersionUID = 3109256773218160485L;

                    @Override
                    public Object getDisplayValue(final String object) {
                        final StringBuilder text = new StringBuilder(object);
                        if (templateMode) {
                            text.append(" (JEXL)");
                        }
                        return text.toString();
                    }
                });

                schemaChoice.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) {

                    private static final long serialVersionUID = -1107858522700306810L;

                    @Override
                    protected void onUpdate(final AjaxRequestTarget target) {
                        attributeTO.setSchema(schemaChoice.getModelObject());

                        VirSchemaTO virSchema = schemas.get(attributeTO.getSchema());
                        if (virSchema != null) {
                            attributeTO.setReadonly(virSchema.isReadonly());
                            panel.setReadOnly(attributeTO.isReadonly());
                        }

                        if (multiPanel != null) {
                            multiPanel.getView().setEnabled(false);
View Full Code Here

    public <T extends AbstractVirSchema> T update(final VirSchemaTO virSchemaTO, final T virSchema) {
        return fill(virSchema, virSchemaTO);
    }

    public <T extends AbstractVirSchema> VirSchemaTO getVirSchemaTO(final T virSchema) {
        VirSchemaTO virtualSchemaTO = new VirSchemaTO();
        BeanUtils.copyProperties(virSchema, virtualSchemaTO);

        return virtualSchemaTO;
    }
View Full Code Here

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

        if (schema == null) {
            schema = new VirSchemaTO();
        }

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

        schemaForm.setModel(new CompoundPropertyModel<VirSchemaTO>(schema));

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

        name.setEnabled(createFlag);

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

        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) {
                VirSchemaTO schemaTO = (VirSchemaTO) form.getDefaultModelObject();
                try {
                    if (createFlag) {
                        schemaRestClient.createVirSchema(kind, schemaTO);
                    } else {
                        schemaRestClient.updateVirSchema(kind, schemaTO);
View Full Code Here

     * Delete an already existent user virtual schema by its name.
     *
     * @param name (e.g.:surname)
     */
    public VirSchemaTO deleteVirSchema(final AttributableType type, final String name) {
        VirSchemaTO schemaTO = getService(SchemaService.class).read(type, SchemaType.VIRTUAL, name);
        getService(SchemaService.class).delete(type, SchemaType.VIRTUAL, name);
        return schemaTO;
    }
View Full Code Here

TOP

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

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.