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);
}
}
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);
}
}
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;
}
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;
}
Aggregations