component query and remove provider alis fix

This commit is contained in:
Bill Burke 2016-12-03 11:34:48 -05:00
parent cfbd7d469f
commit 88d08c4f38
4 changed files with 14 additions and 3 deletions

View file

@ -46,6 +46,12 @@ public interface ComponentsResource {
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> query(@QueryParam("parent") String parent, @QueryParam("type") String type); public List<ComponentRepresentation> query(@QueryParam("parent") String parent, @QueryParam("type") String type);
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<ComponentRepresentation> query(@QueryParam("parent") String parent,
@QueryParam("type") String type,
@QueryParam("name") String name);
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
Response add(ComponentRepresentation rep); Response add(ComponentRepresentation rep);

View file

@ -1030,6 +1030,7 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
for (IdentityProviderEntity entity : realm.getIdentityProviders()) { for (IdentityProviderEntity entity : realm.getIdentityProviders()) {
if (entity.getAlias().equals(alias)) { if (entity.getAlias().equals(alias)) {
IdentityProviderModel model = entityToModel(entity);
em.remove(entity); em.remove(entity);
em.flush(); em.flush();
@ -1042,7 +1043,7 @@ public class RealmAdapter implements RealmModel, JpaModel<RealmEntity> {
@Override @Override
public IdentityProviderModel getRemovedIdentityProvider() { public IdentityProviderModel getRemovedIdentityProvider() {
return entityToModel(entity); return model;
} }
@Override @Override

View file

@ -840,6 +840,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
public void removeIdentityProviderByAlias(String alias) { public void removeIdentityProviderByAlias(String alias) {
for (IdentityProviderEntity entity : realm.getIdentityProviders()) { for (IdentityProviderEntity entity : realm.getIdentityProviders()) {
if (entity.getAlias().equals(alias)) { if (entity.getAlias().equals(alias)) {
IdentityProviderModel model = entityToModel(entity);
realm.getIdentityProviders().remove(entity); realm.getIdentityProviders().remove(entity);
updateRealm(); updateRealm();
@ -852,7 +853,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
@Override @Override
public IdentityProviderModel getRemovedIdentityProvider() { public IdentityProviderModel getRemovedIdentityProvider() {
return entityToModel(entity); return model;
} }
@Override @Override

View file

@ -100,7 +100,9 @@ public class ComponentResource {
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@NoCache @NoCache
public List<ComponentRepresentation> getComponents(@QueryParam("parent") String parent, @QueryParam("type") String type) { public List<ComponentRepresentation> getComponents(@QueryParam("parent") String parent,
@QueryParam("type") String type,
@QueryParam("name") String name) {
auth.requireView(); auth.requireView();
List<ComponentModel> components = Collections.EMPTY_LIST; List<ComponentModel> components = Collections.EMPTY_LIST;
if (parent == null && type == null) { if (parent == null && type == null) {
@ -115,6 +117,7 @@ public class ComponentResource {
} }
List<ComponentRepresentation> reps = new LinkedList<>(); List<ComponentRepresentation> reps = new LinkedList<>();
for (ComponentModel component : components) { for (ComponentModel component : components) {
if (name != null && !name.equals(component.getName())) continue;
ComponentRepresentation rep = ModelToRepresentation.toRepresentation(session, component, false); ComponentRepresentation rep = ModelToRepresentation.toRepresentation(session, component, false);
reps.add(rep); reps.add(rep);
} }