Search in sources :

Example 11 with DerSchemaTO

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

the class DerSchemaITCase method update.

@Test
public void update() {
    DerSchemaTO schema = schemaService.read(SchemaType.DERIVED, "mderiveddata");
    assertNotNull(schema);
    assertEquals("mderived_sx + '-' + mderived_dx", schema.getExpression());
    try {
        schema.setExpression("mderived_sx + '.' + mderived_dx");
        schemaService.update(SchemaType.DERIVED, schema);
        schema = schemaService.read(SchemaType.DERIVED, "mderiveddata");
        assertNotNull(schema);
        assertEquals("mderived_sx + '.' + mderived_dx", schema.getExpression());
    } finally {
        // Set updated back to make test re-runnable
        schema.setExpression("mderived_sx + '-' + mderived_dx");
        schemaService.update(SchemaType.DERIVED, schema);
    }
}
Also used : DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) Test(org.junit.jupiter.api.Test)

Example 12 with DerSchemaTO

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

the class DerSchemaITCase method delete.

@Test
public void delete() {
    DerSchemaTO schema = schemaService.read(SchemaType.DERIVED, "rderiveddata");
    assertNotNull(schema);
    schemaService.delete(SchemaType.DERIVED, schema.getKey());
    try {
        schemaService.read(SchemaType.DERIVED, "rderiveddata");
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.NotFound, e.getType());
    } finally {
        // Recreate schema to make test re-runnable
        schema = createSchema(SchemaType.DERIVED, schema);
        assertNotNull(schema);
    }
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) Test(org.junit.jupiter.api.Test)

Example 13 with DerSchemaTO

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

the class SchemaRestClient method deleteDerSchema.

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

Example 14 with DerSchemaTO

use of org.apache.syncope.common.lib.to.DerSchemaTO 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

DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)14 Test (org.junit.jupiter.api.Test)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)4 VirSchemaTO (org.apache.syncope.common.lib.to.VirSchemaTO)3 ArrayList (java.util.ArrayList)2 DerSchema (org.apache.syncope.core.persistence.api.entity.DerSchema)2 PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)2 VirSchema (org.apache.syncope.core.persistence.api.entity.VirSchema)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 AccessControlException (java.security.AccessControlException)1 NamingException (javax.naming.NamingException)1 DirContext (javax.naming.directory.DirContext)1 SearchControls (javax.naming.directory.SearchControls)1 SearchResult (javax.naming.directory.SearchResult)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 Response (javax.ws.rs.core.Response)1 GroupPatch (org.apache.syncope.common.lib.patch.GroupPatch)1 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)1 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)1