Package org.apache.syncope.common.to

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


        assertNotNull(actual);
    }

    @Test
    public void issueSYNCOPE323() {
        ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
        assertNotNull(actual);

        try {
            createResource(actual);
            fail();
        } catch (SyncopeClientCompositeErrorException scce) {
            assertEquals(HttpStatus.CONFLICT, scce.getStatusCode());
            assertTrue(scce.hasException(SyncopeClientExceptionType.EntityExists));
        }

        actual.setName(null);
        try {
            createResource(actual);
            fail();
        } catch (SyncopeClientCompositeErrorException scce) {
            assertEquals(HttpStatus.BAD_REQUEST, scce.getStatusCode());
View Full Code Here


    @Test
    public void issueSYNCOPE360() {
        final String name = "SYNCOPE360-" + getUUIDString();
        resourceService.create(buildResourceTO(name));

        ResourceTO resource = resourceService.read(name);
        assertNotNull(resource);
        assertNotNull(resource.getUmapping());

        resource.setUmapping(new MappingTO());
        resourceService.update(name, resource);

        resource = resourceService.read(name);
        assertNotNull(resource);
        assertNull(resource.getUmapping());
    }
View Full Code Here

    @Test
    public void issueSYNCOPE368() {
        final String name = "SYNCOPE368-" + getUUIDString();

        ResourceTO resourceTO = new ResourceTO();

        resourceTO.setName(name);
        resourceTO.setConnectorId(105L);

        MappingTO mapping = new MappingTO();

        MappingItemTO item = new MappingItemTO();
        item.setIntMappingType(IntMappingType.RoleName);
        item.setPurpose(MappingPurpose.BOTH);
        mapping.setAccountIdItem(item);

        item = new MappingItemTO();
        item.setIntMappingType(IntMappingType.RoleOwnerSchema);
        item.setExtAttrName("owner");
        item.setPurpose(MappingPurpose.BOTH);
        mapping.addItem(item);

        resourceTO.setRmapping(mapping);

        resourceTO = createResource(resourceTO);
        assertNotNull(resourceTO);
        assertEquals(2, resourceTO.getRmapping().getItems().size());
    }
View Full Code Here

            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
        }
    }

    private ResourceTO buildResourceTO(final String resourceName) {
        ResourceTO resourceTO = new ResourceTO();

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

        MappingTO mapping = new MappingTO();

        MappingItemTO item = new MappingItemTO();
        item.setExtAttrName("uid");
        item.setIntAttrName("userId");
        item.setIntMappingType(IntMappingType.UserSchema);
        item.setPurpose(MappingPurpose.BOTH);
        mapping.addItem(item);

        item = new MappingItemTO();
        item.setExtAttrName("username");
        item.setIntAttrName("fullname");
        item.setIntMappingType(IntMappingType.UserId);
        item.setPurpose(MappingPurpose.BOTH);
        mapping.setAccountIdItem(item);

        item = new MappingItemTO();
        item.setExtAttrName("fullname");
        item.setIntAttrName("cn");
        item.setIntMappingType(IntMappingType.UserSchema);
        item.setAccountid(false);
        item.setPurpose(MappingPurpose.BOTH);
        mapping.addItem(item);

        resourceTO.setUmapping(mapping);
        return resourceTO;
    }
View Full Code Here

            @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) {
                        resourceTO.setUsyncToken(null);
                        resourceTO.setRsyncToken(null);
                        try {
                            resourceRestClient.update(resourceTO);
                            info(getString(Constants.OPERATION_SUCCEEDED));
                        } catch (SyncopeClientCompositeErrorException e) {
                            error(getString(Constants.ERROR) + ":" + e.getMessage());

                            LOG.error("While resetting sync token from " + resourceTO.getName(), e);
                        }

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

                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() {
                                return new ResourceModalPage(Resources.this.getPageReference(),
                                        editResourceWin, resourceTO, false);
                            }
                        });

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

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            resourceRestClient.delete(resourceTO.getName());
                            info(getString(Constants.OPERATION_SUCCEEDED));
                        } catch (SyncopeClientCompositeErrorException e) {
                            error(getString(Constants.ERROR) + ":" + e.getMessage());

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

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

                cellItem.add(panel);
            }
        });

        final AjaxDataTablePanel<ResourceTO, String> table = new AjaxDataTablePanel<ResourceTO, String>(
                "resourceDatatable",
                columns,
                (ISortableDataProvider<ResourceTO, String>) new ResourcesProvider(),
                resourcePaginatorRows,
                Arrays.asList(new ActionLink.ActionType[] { ActionLink.ActionType.DELETE }),
                resourceRestClient,
                "name",
                "Resources",
                getPageReference());

        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<Void> createResourceLink =
                new ClearIndicatingAjaxLink<Void>("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() {
                                return new ResourceModalPage(Resources.this.getPageReference(),
                                        editResourceWin, new ResourceTO(), true);
                            }
                        });

                        createResourceWin.show(target);
                    }
View Full Code Here

        List<ResourceTO> resources = resourceService.list(Long.valueOf(103));

        assertEquals(4, resources.size());

        // Retrieve a resource TO template.
        ResourceTO resourceTO = resources.get(0);

        // Make it new.
        resourceTO.setName("newAbout103");

        // Make it new.
        connInstanceTO.setId(0);
        connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
        // ----------------------------------

        // ----------------------------------
        // Create a new connector instance.
        // ----------------------------------
        Response response = connectorService.create(connInstanceTO);
        if (response.getStatus() != org.apache.http.HttpStatus.SC_CREATED) {
            throw (RuntimeException) clientExceptionMapper.fromResponse(response);
        }

        connInstanceTO = getObject(response, ConnInstanceTO.class, connectorService);

        assertNotNull(connInstanceTO);
        assertTrue(connInstanceTO.getCapabilities().isEmpty());

        long connId = connInstanceTO.getId();

        // Link resourceTO to the new connector instance.
        resourceTO.setConnectorId(connId);
        // ----------------------------------

        // ----------------------------------
        // Check for connector instance update after resource creation.
        // ----------------------------------
        response = resourceService.create(resourceTO);
        resourceTO = getObject(response, ResourceTO.class, resourceService);

        assertNotNull(resourceTO);

        resources = resourceService.list(connId);

        assertEquals(1, resources.size());
        // ----------------------------------

        // ----------------------------------
        // Check for spring bean.
        // ----------------------------------
        ConnInstanceTO connInstanceBean = connectorService.readByResource(resourceTO.getName());

        assertNotNull(connInstanceBean);
        assertTrue(connInstanceBean.getCapabilities().isEmpty());
        // ----------------------------------

        // ----------------------------------
        // Check for spring bean update after connector instance update.
        // ----------------------------------
        connInstanceTO.addCapability(ConnectorCapability.SEARCH);

        connectorService.update(connInstanceTO.getId(), connInstanceTO);
        ConnInstanceTO actual = connectorService.read(connInstanceTO.getId());

        assertNotNull(actual);
        assertFalse(connInstanceTO.getCapabilities().isEmpty());

        // check for spring bean update
        connInstanceBean = connectorService.readByResource(resourceTO.getName());

        assertFalse(connInstanceBean.getCapabilities().isEmpty());
        // ----------------------------------
    }
View Full Code Here

            // ----------------------------------------
            // create a resourceTO
            // ----------------------------------------
            String resourceName = "checkForPropOverriding";
            ResourceTO resourceTO = new ResourceTO();

            resourceTO.setName(resourceName);
            resourceTO.setConnectorId(connectorTO.getId());

            conf = new HashSet<ConnConfProperty>();
            endpoint.setValues(Collections.singletonList("http://localhost:9080/wssample/services/provisioning"));
            conf.add(endpoint);

            resourceTO.setConnectorConfigurationProperties(conf);

            MappingTO mapping = new MappingTO();
            resourceTO.setUmapping(mapping);

            MappingItemTO mapItem = new MappingItemTO();
            mapItem.setExtAttrName("uid");
            mapItem.setIntAttrName("userId");
            mapItem.setIntMappingType(IntMappingType.UserSchema);
View Full Code Here

        assertEquals("virtualupdated", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
    }

    @Test
    public void issueSYNCOPE397() {
        ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);

        for (MappingItemTO item : csv.getUmapping().getItems()) {
            if ("email".equals(item.getIntAttrName())) {
                // unset internal attribute mail and set virtual attribute virtualdata as mapped to external email
                item.setIntMappingType(IntMappingType.UserVirtualSchema);
                item.setIntAttrName("virtualdata");
                item.setPurpose(MappingPurpose.BOTH);
                item.setExtAttrName("email");
            }
        }

        resourceService.update(csv.getName(), csv);
        csv = resourceService.read(RESOURCE_NAME_CSV);
        assertNotNull(csv.getUmapping());

        boolean found = false;
        for (MappingItemTO item : csv.getUmapping().getItems()) {
            if ("email".equals(item.getExtAttrName()) && "virtualdata".equals(item.getIntAttrName())) {
                found = true;
            }
        }
View Full Code Here

        assertNotNull(userTO);
    }

    @Test
    public void testEnforceMandatoryConditionOnDerived() {
        ResourceTO resourceTO = resourceService.read(RESOURCE_NAME_CSV);
        assertNotNull(resourceTO);
        resourceTO.setName("resource-csv-enforcing");
        resourceTO.setEnforceMandatoryCondition(true);

        Response response = resourceService.create(resourceTO);
        resourceTO = getObject(response, ResourceTO.class, resourceService);
        assertNotNull(resourceTO);

        UserTO userTO = getUniqueSampleTO("syncope222@apache.org");
        userTO.addResource(resourceTO.getName());
        userTO.setPassword("newPassword");

        SyncopeClientException sce = null;
        try {
            userTO = createUser(userTO);
View Full Code Here

    }

    @Test
    public void suspendReactivateOnResource() {
        // Assert resources are present
        ResourceTO dbTable = resourceService.read(RESOURCE_NAME_TESTDB);
        assertNotNull(dbTable);
        ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
        assertNotNull(ldap);

        // Create user with reference to resources
        UserTO userTO = getUniqueSampleTO("suspreactonresource@syncope.apache.org");
        userTO.getMemberships().clear();
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.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.