Search in sources :

Example 1 with MapScopeEntity

use of org.keycloak.models.map.authorization.entity.MapScopeEntity in project keycloak by keycloak.

the class MapScopeStore method create.

@Override
public Scope create(String id, String name, ResourceServer resourceServer) {
    LOG.tracef("create(%s, %s, %s)%s", id, name, resourceServer, getShortStackTrace());
    // @UniqueConstraint(columnNames = {"NAME", "RESOURCE_SERVER_ID"})
    DefaultModelCriteria<Scope> mcb = forResourceServer(resourceServer.getId()).compare(SearchableFields.NAME, Operator.EQ, name);
    if (tx.getCount(withCriteria(mcb)) > 0) {
        throw new ModelDuplicateException("Scope with name '" + name + "' for " + resourceServer.getId() + " already exists");
    }
    MapScopeEntity entity = new MapScopeEntityImpl();
    entity.setId(id);
    entity.setName(name);
    entity.setResourceServerId(resourceServer.getId());
    entity = tx.create(entity);
    return entityToAdapter(entity);
}
Also used : MapScopeEntity(org.keycloak.models.map.authorization.entity.MapScopeEntity) Scope(org.keycloak.authorization.model.Scope) ModelDuplicateException(org.keycloak.models.ModelDuplicateException) MapScopeEntityImpl(org.keycloak.models.map.authorization.entity.MapScopeEntityImpl)

Aggregations

Scope (org.keycloak.authorization.model.Scope)1 ModelDuplicateException (org.keycloak.models.ModelDuplicateException)1 MapScopeEntity (org.keycloak.models.map.authorization.entity.MapScopeEntity)1 MapScopeEntityImpl (org.keycloak.models.map.authorization.entity.MapScopeEntityImpl)1