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