Search in sources :

Example 1 with VirSchemaTO

use of org.apache.syncope.common.lib.to.VirSchemaTO in project syncope by apache.

the class VirAttrITCase method issueSYNCOPE453.

@Test
public void issueSYNCOPE453() {
    String resourceName = "issueSYNCOPE453Res" + getUUIDString();
    String groupKey = null;
    String groupName = "issueSYNCOPE453Group" + getUUIDString();
    try {
        // -------------------------------------------
        // Create a VirAttrITCase ad-hoc
        // -------------------------------------------
        VirSchemaTO rvirtualdata;
        try {
            rvirtualdata = schemaService.read(SchemaType.VIRTUAL, "rvirtualdata");
        } catch (SyncopeClientException e) {
            LOG.warn("rvirtualdata not found, re-creating", e);
            rvirtualdata = new VirSchemaTO();
            rvirtualdata.setKey("rvirtualdata");
            rvirtualdata.setExtAttrName("businessCategory");
            rvirtualdata.setResource(RESOURCE_NAME_LDAP);
            rvirtualdata.setAnyType(AnyTypeKind.GROUP.name());
            rvirtualdata = createSchema(SchemaType.VIRTUAL, rvirtualdata);
        }
        assertNotNull(rvirtualdata);
        if (!"minimal group".equals(rvirtualdata.getAnyTypeClass())) {
            LOG.warn("rvirtualdata not in minimal group, restoring");
            AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
            minimalGroup.getVirSchemas().add(rvirtualdata.getKey());
            anyTypeClassService.update(minimalGroup);
            rvirtualdata = schemaService.read(SchemaType.VIRTUAL, rvirtualdata.getKey());
            assertEquals("minimal group", rvirtualdata.getAnyTypeClass());
        }
        // -------------------------------------------
        // Create a resource ad-hoc
        // -------------------------------------------
        ResourceTO resourceTO = new ResourceTO();
        resourceTO.setKey(resourceName);
        resourceTO.setConnector("be24b061-019d-4e3e-baf0-0a6d0a45cb9c");
        ProvisionTO provisionTO = new ProvisionTO();
        provisionTO.setAnyType(AnyTypeKind.USER.name());
        provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
        resourceTO.getProvisions().add(provisionTO);
        MappingTO mapping = new MappingTO();
        provisionTO.setMapping(mapping);
        ItemTO item = new ItemTO();
        item.setIntAttrName("fullname");
        item.setExtAttrName("ID");
        item.setPurpose(MappingPurpose.PROPAGATION);
        item.setConnObjectKey(true);
        mapping.setConnObjectKeyItem(item);
        item = new ItemTO();
        item.setIntAttrName("username");
        item.setExtAttrName("USERNAME");
        item.setPurpose(MappingPurpose.PROPAGATION);
        mapping.getItems().add(item);
        item = new ItemTO();
        item.setIntAttrName("groups[" + groupName + "].rvirtualdata");
        item.setExtAttrName("EMAIL");
        item.setPurpose(MappingPurpose.PROPAGATION);
        mapping.getItems().add(item);
        assertNotNull(getObject(resourceService.create(resourceTO).getLocation(), ResourceService.class, ResourceTO.class));
        // -------------------------------------------
        GroupTO groupTO = new GroupTO();
        groupTO.setName(groupName);
        groupTO.setRealm("/");
        groupTO.getVirAttrs().add(attrTO(rvirtualdata.getKey(), "ml@group.it"));
        groupTO.getResources().add(RESOURCE_NAME_LDAP);
        groupTO = createGroup(groupTO).getEntity();
        groupKey = groupTO.getKey();
        assertEquals(1, groupTO.getVirAttrs().size());
        assertEquals("ml@group.it", groupTO.getVirAttrs().iterator().next().getValues().get(0));
        // -------------------------------------------
        // -------------------------------------------
        // Create new user
        // -------------------------------------------
        UserTO userTO = UserITCase.getUniqueSampleTO("syn453@syncope.apache.org");
        userTO.getPlainAttrs().add(attrTO("fullname", "123"));
        userTO.getResources().clear();
        userTO.getResources().add(resourceName);
        userTO.getVirAttrs().clear();
        userTO.getMemberships().clear();
        userTO.getMemberships().add(new MembershipTO.Builder().group(groupTO.getKey()).build());
        ProvisioningResult<UserTO> result = createUser(userTO);
        assertEquals(2, result.getPropagationStatuses().size());
        assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
        assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(1).getStatus());
        userTO = result.getEntity();
        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
        Map<String, Object> actuals = jdbcTemplate.queryForMap("SELECT id, surname, email FROM testpull WHERE id=?", new Object[] { userTO.getPlainAttr("fullname").get().getValues().get(0) });
        assertEquals(userTO.getPlainAttr("fullname").get().getValues().get(0), actuals.get("id").toString());
        assertEquals("ml@group.it", actuals.get("email"));
    // -------------------------------------------
    } catch (Exception e) {
        LOG.error("Unexpected error", e);
    } finally {
        // -------------------------------------------
        // Delete resource and group ad-hoc
        // -------------------------------------------
        resourceService.delete(resourceName);
        if (groupKey != null) {
            groupService.delete(groupKey);
        }
    // -------------------------------------------
    }
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) ItemTO(org.apache.syncope.common.lib.to.ItemTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) GroupTO(org.apache.syncope.common.lib.to.GroupTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) UserTO(org.apache.syncope.common.lib.to.UserTO) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 2 with VirSchemaTO

use of org.apache.syncope.common.lib.to.VirSchemaTO in project syncope by apache.

the class VirAttrITCase method issueSYNCOPE691.

@Test
public void issueSYNCOPE691() {
    ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
    try {
        ProvisionTO provision = ldap.getProvision(AnyTypeKind.USER.name()).orElse(null);
        assertNotNull(provision);
        List<ItemTO> mail = provision.getMapping().getItems().stream().filter(item -> "mail".equals(item.getExtAttrName())).collect(Collectors.toList());
        provision.getMapping().getItems().removeAll(mail);
        provision.getVirSchemas().clear();
        ldap.getProvisions().clear();
        ldap.getProvisions().add(provision);
        ldap.setKey(RESOURCE_NAME_LDAP + "691" + getUUIDString());
        resourceService.create(ldap);
        ldap = resourceService.read(ldap.getKey());
        provision = ldap.getProvision(AnyTypeKind.USER.name()).get();
        assertNotNull(provision);
        // create new virtual schema for the resource below
        VirSchemaTO virSchema = new VirSchemaTO();
        virSchema.setKey("syncope691" + getUUIDString());
        virSchema.setExtAttrName("mail");
        virSchema.setResource(ldap.getKey());
        virSchema.setAnyType(provision.getAnyType());
        virSchema = createSchema(SchemaType.VIRTUAL, virSchema);
        assertNotNull(virSchema);
        AnyTypeClassTO newClass = new AnyTypeClassTO();
        newClass.setKey("syncope691" + getUUIDString());
        newClass.getVirSchemas().add(virSchema.getKey());
        Response response = anyTypeClassService.create(newClass);
        assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
        newClass = getObject(response.getLocation(), AnyTypeClassService.class, AnyTypeClassTO.class);
        // create a new user
        UserTO userTO = UserITCase.getUniqueSampleTO("syncope691@syncope.apache.org");
        userTO.getAuxClasses().add(newClass.getKey());
        userTO.getResources().clear();
        userTO.getMemberships().clear();
        userTO.getVirAttrs().clear();
        AttrTO emailTO = new AttrTO();
        emailTO.setSchema(virSchema.getKey());
        emailTO.getValues().add("test@issue691.dom1.org");
        emailTO.getValues().add("test@issue691.dom2.org");
        userTO.getVirAttrs().add(emailTO);
        // assign resource-ldap691 to user
        userTO.getResources().add(ldap.getKey());
        // save user
        userTO = createUser(userTO).getEntity();
        // make std controls about user
        assertNotNull(userTO);
        assertTrue(ldap.getKey().equals(userTO.getResources().iterator().next()));
        assertEquals(2, userTO.getVirAttrs().iterator().next().getValues().size());
        assertTrue(userTO.getVirAttrs().iterator().next().getValues().contains("test@issue691.dom1.org"));
        assertTrue(userTO.getVirAttrs().iterator().next().getValues().contains("test@issue691.dom2.org"));
        // update user
        UserPatch userPatch = new UserPatch();
        userPatch.setKey(userTO.getKey());
        // modify virtual attribute
        userPatch.getVirAttrs().add(new AttrTO.Builder().schema(virSchema.getKey()).value("test@issue691.dom3.org").value("test@issue691.dom4.org").build());
        UserTO updated = updateUser(userPatch).getEntity();
        assertNotNull(updated);
        assertEquals(2, updated.getVirAttrs().iterator().next().getValues().size());
        assertTrue(updated.getVirAttrs().iterator().next().getValues().contains("test@issue691.dom3.org"));
        assertTrue(updated.getVirAttrs().iterator().next().getValues().contains("test@issue691.dom4.org"));
    } finally {
        try {
            resourceService.delete(ldap.getKey());
        } catch (Exception ignore) {
        // ignore
        }
    }
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) StringPatchItem(org.apache.syncope.common.lib.patch.StringPatchItem) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTypeClassService(org.apache.syncope.common.rest.api.service.AnyTypeClassService) PropagationTaskExecStatus(org.apache.syncope.common.lib.types.PropagationTaskExecStatus) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Autowired(org.springframework.beans.factory.annotation.Autowired) SerializationUtils(org.apache.commons.lang3.SerializationUtils) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) SpringJUnitConfig(org.springframework.test.context.junit.jupiter.SpringJUnitConfig) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Locale(java.util.Locale) Map(java.util.Map) DataSource(javax.sql.DataSource) ItemTO(org.apache.syncope.common.lib.to.ItemTO) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) StatusPatchType(org.apache.syncope.common.lib.types.StatusPatchType) MappingTO(org.apache.syncope.common.lib.to.MappingTO) SchemaType(org.apache.syncope.common.lib.types.SchemaType) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Collectors(java.util.stream.Collectors) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) GenericType(javax.ws.rs.core.GenericType) Test(org.junit.jupiter.api.Test) List(java.util.List) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) Response(javax.ws.rs.core.Response) MappingPurpose(org.apache.syncope.common.lib.types.MappingPurpose) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) PatchOperation(org.apache.syncope.common.lib.types.PatchOperation) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) UserTO(org.apache.syncope.common.lib.to.UserTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Response(javax.ws.rs.core.Response) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) AnyTypeClassService(org.apache.syncope.common.rest.api.service.AnyTypeClassService) UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 3 with VirSchemaTO

use of org.apache.syncope.common.lib.to.VirSchemaTO in project syncope by apache.

the class VirAttrITCase method issueSYNCOPE397.

@Test
public void issueSYNCOPE397() {
    ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);
    // change mapping of resource-csv
    MappingTO origMapping = SerializationUtils.clone(csv.getProvisions().get(0).getMapping());
    try {
        // remove this mapping
        Optional<ItemTO> email = csv.getProvisions().get(0).getMapping().getItems().stream().filter(item -> "email".equals(item.getIntAttrName())).findFirst();
        if (email.isPresent()) {
            csv.getProvisions().get(0).getMapping().getItems().remove(email.get());
        }
        resourceService.update(csv);
        csv = resourceService.read(RESOURCE_NAME_CSV);
        assertNotNull(csv.getProvisions().get(0).getMapping());
        // create new virtual schema for the resource below
        ProvisionTO provision = csv.getProvision(AnyTypeKind.USER.name()).get();
        assertNotNull(provision);
        VirSchemaTO virSchema = new VirSchemaTO();
        virSchema.setKey("syncope397" + getUUIDString());
        virSchema.setExtAttrName("email");
        virSchema.setResource(RESOURCE_NAME_CSV);
        virSchema.setAnyType(provision.getAnyType());
        virSchema = createSchema(SchemaType.VIRTUAL, virSchema);
        assertNotNull(virSchema);
        AnyTypeClassTO newClass = new AnyTypeClassTO();
        newClass.setKey("syncope397" + getUUIDString());
        newClass.getVirSchemas().add(virSchema.getKey());
        Response response = anyTypeClassService.create(newClass);
        assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
        newClass = getObject(response.getLocation(), AnyTypeClassService.class, AnyTypeClassTO.class);
        // create a new user
        UserTO userTO = UserITCase.getUniqueSampleTO("397@syncope.apache.org");
        userTO.getAuxClasses().add("csv");
        userTO.getAuxClasses().add(newClass.getKey());
        userTO.getResources().clear();
        userTO.getMemberships().clear();
        userTO.getVirAttrs().clear();
        userTO.getVirAttrs().add(attrTO(virSchema.getKey(), "test@testone.org"));
        // assign resource-csv to user
        userTO.getResources().add(RESOURCE_NAME_CSV);
        // save user
        userTO = createUser(userTO).getEntity();
        // make std controls about user
        assertNotNull(userTO);
        assertTrue(RESOURCE_NAME_CSV.equals(userTO.getResources().iterator().next()));
        assertEquals("test@testone.org", userTO.getVirAttrs().iterator().next().getValues().get(0));
        // update user
        UserTO toBeUpdated = userService.read(userTO.getKey());
        UserPatch userPatch = new UserPatch();
        userPatch.setKey(toBeUpdated.getKey());
        userPatch.setPassword(new PasswordPatch.Builder().value("password234").build());
        // assign new resource to user
        userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_WS2).build());
        // modify virtual attribute
        userPatch.getVirAttrs().add(attrTO(virSchema.getKey(), "test@testoneone.com"));
        // check Syncope change password
        userPatch.setPassword(new PasswordPatch.Builder().value("password234").onSyncope(true).resource(RESOURCE_NAME_WS2).build());
        ProvisioningResult<UserTO> result = updateUser(userPatch);
        assertNotNull(result);
        toBeUpdated = result.getEntity();
        assertTrue(toBeUpdated.getVirAttrs().iterator().next().getValues().contains("test@testoneone.com"));
        // check if propagates correctly with assertEquals on size of tasks list
        assertEquals(2, result.getPropagationStatuses().size());
    } finally {
        // restore mapping of resource-csv
        csv.getProvisions().get(0).setMapping(origMapping);
        resourceService.update(csv);
    }
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) StringPatchItem(org.apache.syncope.common.lib.patch.StringPatchItem) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTypeClassService(org.apache.syncope.common.rest.api.service.AnyTypeClassService) PropagationTaskExecStatus(org.apache.syncope.common.lib.types.PropagationTaskExecStatus) AttrTO(org.apache.syncope.common.lib.to.AttrTO) Autowired(org.springframework.beans.factory.annotation.Autowired) SerializationUtils(org.apache.commons.lang3.SerializationUtils) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) SpringJUnitConfig(org.springframework.test.context.junit.jupiter.SpringJUnitConfig) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Locale(java.util.Locale) Map(java.util.Map) DataSource(javax.sql.DataSource) ItemTO(org.apache.syncope.common.lib.to.ItemTO) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) StatusPatchType(org.apache.syncope.common.lib.types.StatusPatchType) MappingTO(org.apache.syncope.common.lib.to.MappingTO) SchemaType(org.apache.syncope.common.lib.types.SchemaType) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Collectors(java.util.stream.Collectors) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) GenericType(javax.ws.rs.core.GenericType) Test(org.junit.jupiter.api.Test) List(java.util.List) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) Response(javax.ws.rs.core.Response) MappingPurpose(org.apache.syncope.common.lib.types.MappingPurpose) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) PatchOperation(org.apache.syncope.common.lib.types.PatchOperation) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) UserTO(org.apache.syncope.common.lib.to.UserTO) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Response(javax.ws.rs.core.Response) MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) AnyTypeClassService(org.apache.syncope.common.rest.api.service.AnyTypeClassService) UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 4 with VirSchemaTO

use of org.apache.syncope.common.lib.to.VirSchemaTO in project syncope by apache.

the class NotificationWizardBuilder method getSchemas.

private List<String> getSchemas() {
    AnyTypeTO type = null;
    try {
        type = anyTypeRestClient.read(AnyTypeKind.USER.name());
    } catch (SyncopeClientException e) {
        LOG.error("While reading all any types", e);
    }
    String[] anyTypeClasses = type == null ? new String[0] : type.getClasses().toArray(new String[] {});
    List<String> result = new ArrayList<>();
    result.add("username");
    result.addAll(schemaRestClient.<PlainSchemaTO>getSchemas(SchemaType.PLAIN, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    result.addAll(schemaRestClient.<DerSchemaTO>getSchemas(SchemaType.DERIVED, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    result.addAll(schemaRestClient.<VirSchemaTO>getSchemas(SchemaType.VIRTUAL, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
    Collections.sort(result);
    return result;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO)

Example 5 with VirSchemaTO

use of org.apache.syncope.common.lib.to.VirSchemaTO in project syncope by apache.

the class SchemaLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_UPDATE + "')")
public <T extends SchemaTO> void update(final SchemaType schemaType, final T schemaTO) {
    if (!doesSchemaExist(schemaType, schemaTO.getKey())) {
        throw new NotFoundException(schemaType + "/" + schemaTO.getKey());
    }
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.find(schemaTO.getKey());
            if (virSchema == null) {
                throw new NotFoundException("Virtual Schema '" + schemaTO.getKey() + "'");
            }
            virSchemaDAO.save(binder.update((VirSchemaTO) schemaTO, virSchema));
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.find(schemaTO.getKey());
            if (derSchema == null) {
                throw new NotFoundException("Derived schema '" + schemaTO.getKey() + "'");
            }
            derSchemaDAO.save(binder.update((DerSchemaTO) schemaTO, derSchema));
            break;
        case PLAIN:
        default:
            PlainSchema plainSchema = plainSchemaDAO.find(schemaTO.getKey());
            if (plainSchema == null) {
                throw new NotFoundException("Schema '" + schemaTO.getKey() + "'");
            }
            plainSchemaDAO.save(binder.update((PlainSchemaTO) schemaTO, plainSchema));
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) DerSchema(org.apache.syncope.core.persistence.api.entity.DerSchema) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

VirSchemaTO (org.apache.syncope.common.lib.to.VirSchemaTO)12 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 Test (org.junit.jupiter.api.Test)7 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)6 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)4 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 Response (javax.ws.rs.core.Response)3 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)3 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)3 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)3 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)3 GroupTO (org.apache.syncope.common.lib.to.GroupTO)3 ItemTO (org.apache.syncope.common.lib.to.ItemTO)3 MappingTO (org.apache.syncope.common.lib.to.MappingTO)3 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)3 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)3 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)3 AnyTypeClassService (org.apache.syncope.common.rest.api.service.AnyTypeClassService)3 ResourceService (org.apache.syncope.common.rest.api.service.ResourceService)3