Skip to content

Commit

Permalink
SHIBUI-2394
Browse files Browse the repository at this point in the history
Changes for 2440 odd behavior in fetch lists for action required screens
  • Loading branch information
chasegawa committed Oct 28, 2022
1 parent 79fd272 commit cbb44e9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public ResponseEntity<?> getAllVersions(@PathVariable String resourceId) throws
@Secured("ROLE_ADMIN")
@Transactional
@GetMapping(value = "/EntityDescriptor/disabledNonAdmin")
public Iterable<EntityDescriptorRepresentation> getDisabledAndNotOwnedByAdmin() throws ForbiddenException {
return entityDescriptorService.getAllDisabledAndNotOwnedByAdmin();
public ResponseEntity<?> getDisabledAndNotOwnedByAdmin() throws ForbiddenException {
return ResponseEntity.ok(entityDescriptorService.getAllDisabledAndNotOwnedByAdmin());
}

@GetMapping("/EntityDescriptor/{resourceId}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package edu.internet2.tier.shibboleth.admin.ui.repository;

import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor;
import edu.internet2.tier.shibboleth.admin.ui.security.model.Group;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
Expand Down Expand Up @@ -35,9 +36,12 @@ public interface EntityDescriptorRepository extends JpaRepository<EntityDescript

Stream<EntityDescriptor> findAllStreamByIdOfOwner(String ownerId);

@Query("select e from EntityDescriptor e, User u join u.roles r " +
"where e.createdBy = u.username and e.serviceEnabled = false and r.name in ('ROLE_USER', 'ROLE_NONE')")
Stream<EntityDescriptor> findAllDisabledAndNotOwnedByAdmin();
@Query(value = "select new edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorProjection(e.entityID, e.resourceId, e.serviceProviderName, e.createdBy, " +
"e.createdDate, e.serviceEnabled, e.idOfOwner, e.protocol, e.approved) " +
" from EntityDescriptor e " +
" where e.serviceEnabled = false"
)
List<EntityDescriptorProjection> getEntityDescriptorsNeedingEnabling();

/**
* SHIBUI-1740 This is here to aid in migration of systems using the SHIBUI prior to group functionality being added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EntityDescriptorRepresentation createNew(EntityDescriptorRepresentation edRepres
* "admin"
* @throws ForbiddenException - If user is not an ADMIN
*/
Iterable<EntityDescriptorRepresentation> getAllDisabledAndNotOwnedByAdmin() throws ForbiddenException;
Iterable<EntityDescriptorProjection> getAllDisabledAndNotOwnedByAdmin() throws ForbiddenException;

/**
* @return a list of EntityDescriptorProjections that a user has the rights to access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ public boolean entityExists(String entityID) {
}

@Override
public Iterable<EntityDescriptorRepresentation> getAllDisabledAndNotOwnedByAdmin() throws ForbiddenException {
public Iterable<EntityDescriptorProjection> getAllDisabledAndNotOwnedByAdmin() throws ForbiddenException {
if (!userService.currentUserIsAdmin()) {
throw new ForbiddenException();
}
return entityDescriptorRepository.findAllDisabledAndNotOwnedByAdmin().map(ed -> createRepresentationFromDescriptor(ed)).collect(Collectors.toList());
return entityDescriptorRepository.getEntityDescriptorsNeedingEnabling();
}

/**
Expand Down

0 comments on commit cbb44e9

Please sign in to comment.