Package org.apache.syncope.client.to

Examples of org.apache.syncope.client.to.ResourceTO


            }

            @Override
            public void populateItem(final Item<ICellPopulator<ResourceTO>> cellItem, final String componentId,
                    final IModel<ResourceTO> model) {
                final ResourceTO resourceTO = model.getObject();

                final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {

                        editResourceWin.setPageCreator(new ModalWindow.PageCreator() {

                            private static final long serialVersionUID = -7834632442532690940L;

                            @Override
                            public Page createPage() {
                                ResourceModalPage form = new ResourceModalPage(Resources.this.getPageReference(),
                                        editResourceWin, resourceTO, false);
                                return form;
                            }
                        });

                        editResourceWin.show(target);
                    }
                }, ActionLink.ActionType.EDIT, "Resources", "read");

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {

                            resourceRestClient.delete(resourceTO.getName());
                            info(getString("operation_succeded"));

                        } catch (SyncopeClientCompositeErrorException e) {
                            error(getString("operation_error"));

                            LOG.error("While deleting resource " + resourceTO.getName(), e);
                        }

                        target.add(feedbackPanel);
                        target.add(resourceContainer);
                    }
                }, ActionLink.ActionType.DELETE, "Resources", "delete");

                cellItem.add(panel);
            }
        });

        final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("resourceDatatable", columns,
                new ResourcesProvider(), resourcePaginatorRows);

        resourceContainer = new WebMarkupContainer("resourceContainer");
        resourceContainer.add(table);
        resourceContainer.setOutputMarkupId(true);

        add(resourceContainer);

        setWindowClosedCallback(createResourceWin, resourceContainer);
        setWindowClosedCallback(editResourceWin, resourceContainer);

        createResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        createResourceWin.setInitialHeight(WIN_HEIGHT);
        createResourceWin.setInitialWidth(WIN_WIDTH);
        createResourceWin.setCookieName("create-res-modal");

        editResourceWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        editResourceWin.setInitialHeight(WIN_HEIGHT);
        editResourceWin.setInitialWidth(WIN_WIDTH);
        editResourceWin.setCookieName("edit-res-modal");

        AjaxLink createResourceLink = new ClearIndicatingAjaxLink("createResourceLink", getPageReference()) {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            protected void onClickInternal(final AjaxRequestTarget target) {
                createResourceWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        final ResourceModalPage windows = new ResourceModalPage(Resources.this.getPageReference(),
                                editResourceWin, new ResourceTO(), true);
                        return windows;
                    }
                });

                createResourceWin.show(target);
View Full Code Here


    public List<StatusBean> getRemoteStatuses(final UserTO userTO) {
        final List<StatusBean> statuses = new ArrayList<StatusBean>();

        for (String res : userTO.getResources()) {

            final ResourceTO resourceTO = resourceRestClient.read(res);

            final Map.Entry<IntMappingType, String> accountId = getAccountId(resourceTO);

            String objectId = null;
View Full Code Here

        UserTO userTO = getSampleTO("suspreactonresource@syncope.apache.org");

        userTO.getMemberships().clear();
        userTO.getResources().clear();

        ResourceTO dbTable = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json",
                ResourceTO.class, "resource-testdb");

        assertNotNull(dbTable);
        userTO.addResource(dbTable.getName());

        ResourceTO ldap = restTemplate.getForObject(BASE_URL + "/resource/read/{resourceName}.json", ResourceTO.class,
                "resource-ldap");

        assertNotNull(ldap);
        userTO.addResource(ldap.getName());

        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);

        assertNotNull(userTO);
        assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());

        String query = "?resourceNames=" + dbTable.getName() + "&resourceNames=" + ldap.getName()
                + "&performLocally=true"; // check also performLocally

        userTO = restTemplate.getForObject(BASE_URL + "user/suspend/" + userTO.getId() + query, UserTO.class);

        assertNotNull(userTO);
        assertEquals("suspended", userTO.getStatus());

        String dbTableUID = userTO.getUsername();
        assertNotNull(dbTableUID);

        ConnObjectTO connObjectTO = restTemplate.getForObject(BASE_URL
                + "/resource/{resourceName}/read/{objectId}.json", ConnObjectTO.class, dbTable.getName(), dbTableUID);

        assertFalse(Boolean.parseBoolean(connObjectTO.getAttributeMap().get(OperationalAttributes.ENABLE_NAME).
                getValues().
                get(0)));

        String ldapUID = userTO.getUsername();
        assertNotNull(ldapUID);

        connObjectTO = restTemplate.getForObject(BASE_URL + "/resource/{resourceName}/read/{objectId}.json",
                ConnObjectTO.class, ldap.getName(), ldapUID);

        assertNotNull(connObjectTO);

        query = "?resourceNames=" + ldap.getName() + "&performLocally=false"; // check also performLocally

        userTO = restTemplate.getForObject(BASE_URL + "user/reactivate/" + userTO.getId() + query, UserTO.class);

        assertNotNull(userTO);
        assertEquals("suspended", userTO.getStatus());
View Full Code Here

        ExternalResource resource = resourceDAO.find(resourceName);
        if (resource == null) {
            throw new NotFoundException("Resource '" + resourceName + "'");
        }
       
        ResourceTO resourceToDelete = binder.getResourceTO(resource);

        auditManager.audit(Category.resource, ResourceSubCategory.delete, Result.success,
                "Successfully deleted resource: " + resource.getName());

        resourceDAO.delete(resourceName);
View Full Code Here

        if (resource == null) {
            return null;
        }

        ResourceTO resourceTO = new ResourceTO();

        // set the resource name
        resourceTO.setName(resource.getName());

        // set the connector instance
        ConnInstance connector = resource.getConnector();

        resourceTO.setConnectorId(connector != null
                ? connector.getId()
                : null);

        // set the mappings
        resourceTO.setMappings(getSchemaMappingTOs(resource.getMappings()));

        resourceTO.setAccountLink(resource.getAccountLink());

        resourceTO.setForceMandatoryConstraint(resource.isForceMandatoryConstraint());

        resourceTO.setPropagationPrimary(resource.isPropagationPrimary());

        resourceTO.setPropagationPriority(resource.getPropagationPriority());

        resourceTO.setPropagationMode(resource.getPropagationMode());

        resourceTO.setCreateTraceLevel(resource.getCreateTraceLevel());
        resourceTO.setUpdateTraceLevel(resource.getUpdateTraceLevel());
        resourceTO.setDeleteTraceLevel(resource.getDeleteTraceLevel());
        resourceTO.setSyncTraceLevel(resource.getSyncTraceLevel());

        resourceTO.setPasswordPolicy(resource.getPasswordPolicy() != null
                ? resource.getPasswordPolicy().getId()
                : null);

        resourceTO.setAccountPolicy(resource.getAccountPolicy() != null
                ? resource.getAccountPolicy().getId()
                : null);

        resourceTO.setSyncPolicy(resource.getSyncPolicy() != null
                ? resource.getSyncPolicy().getId()
                : null);

        resourceTO.setConnectorConfigurationProperties(resource.getConfiguration());
        resourceTO.setSyncToken(resource.getSerializedSyncToken());

        return resourceTO;
    }
View Full Code Here

        schemaMappingTO.setMandatoryCondition("false");

        List<SchemaMappingTO> schemaMappingTOs = new ArrayList<SchemaMappingTO>();
        schemaMappingTOs.add(schemaMappingTO);

        ResourceTO resourceTO = new ResourceTO();
        resourceTO.setName("resource-issue42");
        resourceTO.setConnectorId(100L);
        resourceTO.setMappings(schemaMappingTOs);
        resourceTO.setPropagationMode(PropagationMode.ONE_PHASE);
        resourceTO.setForceMandatoryConstraint(true);

        ExternalResource resource = resourceDataBinder.create(resourceTO);
        resource = resourceDAO.save(resource);

        resourceDAO.flush();
View Full Code Here

public class ResourceTestITCase extends AbstractTest {

    @Test(expected = SyncopeClientCompositeErrorException.class)
    public void createExistingResource() {
        final String resourceName = "ws-target-resource-1";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(100L);

        restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);
    }
View Full Code Here

    }

    @Test
    public void create() {
        String resourceName = "ws-target-resource-create";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("uid");
        schemaMappingTO.setIntAttrName("userId");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("username");
        schemaMappingTO.setIntAttrName("fullname");
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("fullname");
        schemaMappingTO.setIntAttrName("cn");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTO.setAccountid(false);
        resourceTO.addMapping(schemaMappingTO);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);

        assertNotNull(actual);

        // check the existence
View Full Code Here

    }

    @Test
    public void createOverridingProps() {
        String resourceName = "overriding-conn-conf-target-resource-create";
        ResourceTO resourceTO = new ResourceTO();

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("uid");
        schemaMappingTO.setIntAttrName("userId");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("username");
        schemaMappingTO.setIntAttrName("fullname");
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setExtAttrName("fullname");
        schemaMappingTO.setIntAttrName("cn");
        schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
        schemaMappingTO.setAccountid(false);
        resourceTO.addMapping(schemaMappingTO);

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);

        ConnConfProperty p = new ConnConfProperty();
        ConnConfPropSchema schema = new ConnConfPropSchema();
        schema.setType("java.lang.String");
        schema.setName("endpoint");
        schema.setRequired(true);
        p.setSchema(schema);
        p.setValues(Collections.singletonList("http://invalidurl/"));

        Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<ConnConfProperty>(Arrays.asList(p));

        resourceTO.setConnectorConfigurationProperties(connectorConfigurationProperties);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);

        assertNotNull(actual);

        // check the existence
View Full Code Here

    }

    @Test
    public void createWithSingleMapping() {
        String resourceName = "ws-target-resource-create-single";
        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(resourceName);
        resourceTO.setConnectorId(102L);

        SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
        schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
        schemaMappingTO.setAccountid(true);
        resourceTO.addMapping(schemaMappingTO);

        ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/create.json", resourceTO, ResourceTO.class);

        assertNotNull(actual);
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.client.to.ResourceTO

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.