Search in sources :

Example 11 with VirSchemaTO

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

the class SchemaRestClient method deleteVirSchema.

public VirSchemaTO deleteVirSchema(final String name) {
    VirSchemaTO schemaTO = getService(SchemaService.class).read(SchemaType.VIRTUAL, name);
    getService(SchemaService.class).delete(SchemaType.VIRTUAL, name);
    return schemaTO;
}
Also used : SchemaService(org.apache.syncope.common.rest.api.service.SchemaService) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO)

Example 12 with VirSchemaTO

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

the class SchemaLogic method create.

@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_CREATE + "')")
@SuppressWarnings("unchecked")
public <T extends SchemaTO> T create(final SchemaType schemaType, final T schemaTO) {
    if (StringUtils.isBlank(schemaTO.getKey())) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
        sce.getElements().add("Schema key");
        throw sce;
    }
    if (doesSchemaExist(schemaType, schemaTO.getKey())) {
        throw new DuplicateException(schemaType + "/" + schemaTO.getKey());
    }
    T created;
    switch(schemaType) {
        case VIRTUAL:
            VirSchema virSchema = virSchemaDAO.save(binder.create((VirSchemaTO) schemaTO));
            created = (T) binder.getVirSchemaTO(virSchema);
            break;
        case DERIVED:
            DerSchema derSchema = derSchemaDAO.save(binder.create((DerSchemaTO) schemaTO));
            created = (T) binder.getDerSchemaTO(derSchema);
            break;
        case PLAIN:
        default:
            PlainSchema plainSchema = plainSchemaDAO.save(binder.create((PlainSchemaTO) schemaTO));
            created = (T) binder.getPlainSchemaTO(plainSchema);
    }
    return created;
}
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) DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) 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