add micrometer @Timing annotations to Controllers+Repositories + ArchTest (#128)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: #128
Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
Michael Hoennig 2024-12-05 10:32:34 +01:00
parent 0832c90c82
commit ddba946d72
88 changed files with 461 additions and 136 deletions

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.debitor; package net.hostsharing.hsadminng.hs.booking.debitor;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -8,7 +9,9 @@ import java.util.UUID;
public interface HsBookingDebitorRepository extends Repository<HsBookingDebitorEntity, UUID> { public interface HsBookingDebitorRepository extends Repository<HsBookingDebitorEntity, UUID> {
@Timed("app.booking.debitor.repo.findByUuid")
Optional<HsBookingDebitorEntity> findByUuid(UUID id); Optional<HsBookingDebitorEntity> findByUuid(UUID id);
@Timed("app.booking.debitor.repo.findByDebitorNumber")
List<HsBookingDebitorEntity> findByDebitorNumber(int debitorNumber); List<HsBookingDebitorEntity> findByDebitorNumber(int debitorNumber);
} }

View File

@ -1,12 +1,15 @@
package net.hostsharing.hsadminng.hs.booking.item; package net.hostsharing.hsadminng.hs.booking.item;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.UUID; import java.util.UUID;
public interface BookingItemCreatedEventRepository extends Repository<BookingItemCreatedEventEntity, UUID> { public interface BookingItemCreatedEventRepository extends Repository<BookingItemCreatedEventEntity, UUID> {
@Timed("app.booking.items.repo.save")
BookingItemCreatedEventEntity save(HsBookingItemRealEntity current); BookingItemCreatedEventEntity save(HsBookingItemRealEntity current);
@Timed("app.booking.items.repo.findByBookingItem")
BookingItemCreatedEventEntity findByBookingItem(HsBookingItemRealEntity newBookingItem); BookingItemCreatedEventEntity findByBookingItem(HsBookingItemRealEntity newBookingItem);
} }

View File

@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.booking.item;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingItemsApi; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingItemsApi;
import net.hostsharing.hsadminng.hs.booking.generated.api.v1.model.HsBookingItemInsertResource; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.model.HsBookingItemInsertResource;
@ -51,7 +52,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsBookingItemResource>> listBookingItemsByProjectUuid( @Timed("app.bookingItems.api.getListOfBookingItemsByProjectUuid")
public ResponseEntity<List<HsBookingItemResource>> getListOfBookingItemsByProjectUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID projectUuid) { final UUID projectUuid) {
@ -65,7 +67,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsBookingItemResource> addBookingItem( @Timed("app.bookingItems.api.postNewBookingItem")
public ResponseEntity<HsBookingItemResource> postNewBookingItem(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsBookingItemInsertResource body) { final HsBookingItemInsertResource body) {
@ -94,7 +97,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsBookingItemResource> getBookingItemByUuid( @Timed("app.bookingItems.api.getSingleBookingItemByUuid")
public ResponseEntity<HsBookingItemResource> getSingleBookingItemByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID bookingItemUuid) { final UUID bookingItemUuid) {
@ -111,6 +115,7 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.bookingItems.api.deleteBookingIemByUuid")
public ResponseEntity<Void> deleteBookingIemByUuid( public ResponseEntity<Void> deleteBookingIemByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -125,6 +130,7 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.bookingItems.api.patchBookingItem")
public ResponseEntity<HsBookingItemResource> patchBookingItem( public ResponseEntity<HsBookingItemResource> patchBookingItem(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.item; package net.hostsharing.hsadminng.hs.booking.item;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -9,15 +10,21 @@ import java.util.UUID;
public interface HsBookingItemRbacRepository extends HsBookingItemRepository<HsBookingItemRbacEntity>, public interface HsBookingItemRbacRepository extends HsBookingItemRepository<HsBookingItemRbacEntity>,
Repository<HsBookingItemRbacEntity, UUID> { Repository<HsBookingItemRbacEntity, UUID> {
@Timed("app.bookingItems.repo.findByUuid.rbac")
Optional<HsBookingItemRbacEntity> findByUuid(final UUID bookingItemUuid); Optional<HsBookingItemRbacEntity> findByUuid(final UUID bookingItemUuid);
@Timed("app.bookingItems.repo.findByCaption.rbac")
List<HsBookingItemRbacEntity> findByCaption(String bookingItemCaption); List<HsBookingItemRbacEntity> findByCaption(String bookingItemCaption);
@Timed("app.bookingItems.repo.findAllByProjectUuid.rbac")
List<HsBookingItemRbacEntity> findAllByProjectUuid(final UUID projectItemUuid); List<HsBookingItemRbacEntity> findAllByProjectUuid(final UUID projectItemUuid);
@Timed("app.bookingItems.repo.save.rbac")
HsBookingItemRbacEntity save(HsBookingItemRbacEntity current); HsBookingItemRbacEntity save(HsBookingItemRbacEntity current);
@Timed("app.bookingItems.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.bookingItems.repo.count.rbac")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.item; package net.hostsharing.hsadminng.hs.booking.item;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -9,15 +10,21 @@ import java.util.UUID;
public interface HsBookingItemRealRepository extends HsBookingItemRepository<HsBookingItemRealEntity>, public interface HsBookingItemRealRepository extends HsBookingItemRepository<HsBookingItemRealEntity>,
Repository<HsBookingItemRealEntity, UUID> { Repository<HsBookingItemRealEntity, UUID> {
@Timed("app.bookingItems.repo.findByUuid.real")
Optional<HsBookingItemRealEntity> findByUuid(final UUID bookingItemUuid); Optional<HsBookingItemRealEntity> findByUuid(final UUID bookingItemUuid);
@Timed("app.bookingItems.repo.findByCaption.real")
List<HsBookingItemRealEntity> findByCaption(String bookingItemCaption); List<HsBookingItemRealEntity> findByCaption(String bookingItemCaption);
@Timed("app.bookingItems.repo.findAllByProjectUuid.real")
List<HsBookingItemRealEntity> findAllByProjectUuid(final UUID projectItemUuid); List<HsBookingItemRealEntity> findAllByProjectUuid(final UUID projectItemUuid);
@Timed("app.bookingItems.repo.save.real")
HsBookingItemRealEntity save(HsBookingItemRealEntity current); HsBookingItemRealEntity save(HsBookingItemRealEntity current);
@Timed("app.bookingItems.repo.deleteByUuid.real")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.bookingItems.repo.count.real")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.item; package net.hostsharing.hsadminng.hs.booking.item;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.project; package net.hostsharing.hsadminng.hs.booking.project;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorRepository; import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorRepository;
import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingProjectsApi; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingProjectsApi;
@ -35,7 +36,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsBookingProjectResource>> listBookingProjectsByDebitorUuid( @Timed("app.bookingProjects.api.getListOfBookingProjectsByDebitorUuid")
public ResponseEntity<List<HsBookingProjectResource>> getListOfBookingProjectsByDebitorUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID debitorUuid) { final UUID debitorUuid) {
@ -49,7 +51,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsBookingProjectResource> addBookingProject( @Timed("app.bookingProjects.api.postNewBookingProject")
public ResponseEntity<HsBookingProjectResource> postNewBookingProject(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsBookingProjectInsertResource body) { final HsBookingProjectInsertResource body) {
@ -71,6 +74,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.bookingProjects.api.getBookingProjectByUuid")
public ResponseEntity<HsBookingProjectResource> getBookingProjectByUuid( public ResponseEntity<HsBookingProjectResource> getBookingProjectByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -87,6 +91,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.bookingProjects.api.deleteBookingIemByUuid")
public ResponseEntity<Void> deleteBookingIemByUuid( public ResponseEntity<Void> deleteBookingIemByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -101,6 +106,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.bookingProjects.api.patchBookingProject")
public ResponseEntity<HsBookingProjectResource> patchBookingProject( public ResponseEntity<HsBookingProjectResource> patchBookingProject(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.project; package net.hostsharing.hsadminng.hs.booking.project;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -9,14 +10,21 @@ import java.util.UUID;
public interface HsBookingProjectRbacRepository extends HsBookingProjectRepository<HsBookingProjectRbacEntity>, public interface HsBookingProjectRbacRepository extends HsBookingProjectRepository<HsBookingProjectRbacEntity>,
Repository<HsBookingProjectRbacEntity, UUID> { Repository<HsBookingProjectRbacEntity, UUID> {
@Timed("app.bookingProjects.repo.findByUuid.rbac")
Optional<HsBookingProjectRbacEntity> findByUuid(final UUID bookingProjectUuid); Optional<HsBookingProjectRbacEntity> findByUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.findByCaption.rbac")
List<HsBookingProjectRbacEntity> findByCaption(final String projectCaption); List<HsBookingProjectRbacEntity> findByCaption(final String projectCaption);
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.rbac")
List<HsBookingProjectRbacEntity> findAllByDebitorUuid(final UUID bookingProjectUuid); List<HsBookingProjectRbacEntity> findAllByDebitorUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.save.rbac")
HsBookingProjectRbacEntity save(HsBookingProjectRbacEntity current); HsBookingProjectRbacEntity save(HsBookingProjectRbacEntity current);
@Timed("app.bookingProjects.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.bookingProjects.repo.count.rbac")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.project; package net.hostsharing.hsadminng.hs.booking.project;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -9,14 +10,21 @@ import java.util.UUID;
public interface HsBookingProjectRealRepository extends HsBookingProjectRepository<HsBookingProjectRealEntity>, public interface HsBookingProjectRealRepository extends HsBookingProjectRepository<HsBookingProjectRealEntity>,
Repository<HsBookingProjectRealEntity, UUID> { Repository<HsBookingProjectRealEntity, UUID> {
@Timed("app.bookingProjects.repo.findByUuid.real")
Optional<HsBookingProjectRealEntity> findByUuid(final UUID bookingProjectUuid); Optional<HsBookingProjectRealEntity> findByUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.findByCaption.real")
List<HsBookingProjectRealEntity> findByCaption(final String projectCaption); List<HsBookingProjectRealEntity> findByCaption(final String projectCaption);
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.real")
List<HsBookingProjectRealEntity> findAllByDebitorUuid(final UUID bookingProjectUuid); List<HsBookingProjectRealEntity> findAllByDebitorUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.save.real")
HsBookingProjectRealEntity save(HsBookingProjectRealEntity current); HsBookingProjectRealEntity save(HsBookingProjectRealEntity current);
@Timed("app.bookingProjects.repo.deleteByUuid.real")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.bookingProjects.repo.count.real")
long count(); long count();
} }

View File

@ -1,19 +1,28 @@
package net.hostsharing.hsadminng.hs.booking.project; package net.hostsharing.hsadminng.hs.booking.project;
import io.micrometer.core.annotation.Timed;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public interface HsBookingProjectRepository<E extends HsBookingProject> { public interface HsBookingProjectRepository<E extends HsBookingProject> {
Optional<E> findByUuid(final UUID bookingProjectUuid); @Timed("app.booking.projects.repo.findByUuid")
Optional<E> findByUuid(final UUID findByUuid);
@Timed("app.booking.projects.repo.findByCaption")
List<E> findByCaption(final String projectCaption); List<E> findByCaption(final String projectCaption);
@Timed("app.booking.projects.repo.findAllByDebitorUuid")
List<E> findAllByDebitorUuid(final UUID bookingProjectUuid); List<E> findAllByDebitorUuid(final UUID bookingProjectUuid);
@Timed("app.booking.projects.repo.save")
E save(E current); E save(E current);
@Timed("app.booking.projects.repo.deleteByUuid")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.booking.projects.repo.count")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.hosting.asset; package net.hostsharing.hsadminng.hs.hosting.asset;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRealRepository; import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRealRepository;
import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntitySaveProcessor; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntitySaveProcessor;
import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry;
@ -48,7 +49,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsHostingAssetResource>> listAssets( @Timed("app.hosting.assets.api.getListOfHostingAssets")
public ResponseEntity<List<HsHostingAssetResource>> getListOfHostingAssets(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID debitorUuid, final UUID debitorUuid,
@ -65,7 +67,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsHostingAssetResource> addAsset( @Timed("app.hosting.assets.api.postNewHostingAsset")
public ResponseEntity<HsHostingAssetResource> postNewHostingAsset(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsHostingAssetInsertResource body) { final HsHostingAssetInsertResource body) {
@ -93,7 +96,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsHostingAssetResource> getAssetByUuid( @Timed("app.hosting.assets.api.getSingleHostingAssetByUuid")
public ResponseEntity<HsHostingAssetResource> getSingleHostingAssetByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID assetUuid) { final UUID assetUuid) {
@ -109,7 +113,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<Void> deleteAssetUuid( @Timed("app.hosting.assets.api.deleteHostingAssetByUuid")
public ResponseEntity<Void> deleteHostingAssetByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID assetUuid) { final UUID assetUuid) {
@ -123,7 +128,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsHostingAssetResource> patchAsset( @Timed("app.hosting.assets.api.patchHostingAsset")
public ResponseEntity<HsHostingAssetResource> patchHostingAsset(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID assetUuid, final UUID assetUuid,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.hosting.asset; package net.hostsharing.hsadminng.hs.hosting.asset;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry;
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingAssetPropsApi; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingAssetPropsApi;
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsHostingAssetTypeResource; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsHostingAssetTypeResource;
@ -14,7 +15,8 @@ import java.util.Map;
public class HsHostingAssetPropsController implements HsHostingAssetPropsApi { public class HsHostingAssetPropsController implements HsHostingAssetPropsApi {
@Override @Override
public ResponseEntity<List<String>> listAssetTypes() { @Timed("app.hosting.assets.api.getListOfHostingAssetTypes")
public ResponseEntity<List<String>> getListOfHostingAssetTypes() {
final var resource = HostingAssetEntityValidatorRegistry.types().stream() final var resource = HostingAssetEntityValidatorRegistry.types().stream()
.map(Enum::name) .map(Enum::name)
.toList(); .toList();
@ -22,7 +24,8 @@ public class HsHostingAssetPropsController implements HsHostingAssetPropsApi {
} }
@Override @Override
public ResponseEntity<List<Object>> listAssetTypeProps( @Timed("app.hosting.assets.api.getListOfHostingAssetTypeProps")
public ResponseEntity<List<Object>> getListOfHostingAssetTypeProps(
final HsHostingAssetTypeResource assetType) { final HsHostingAssetTypeResource assetType) {
final Enum<HsHostingAssetType> type = HsHostingAssetType.of(assetType); final Enum<HsHostingAssetType> type = HsHostingAssetType.of(assetType);

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.hosting.asset; package net.hostsharing.hsadminng.hs.hosting.asset;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,8 +11,10 @@ import java.util.UUID;
public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<HsHostingAssetRbacEntity>, Repository<HsHostingAssetRbacEntity, UUID> { public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<HsHostingAssetRbacEntity>, Repository<HsHostingAssetRbacEntity, UUID> {
@Timed("app.hostingAsset.repo.findByUuid.rbac")
Optional<HsHostingAssetRbacEntity> findByUuid(final UUID serverUuid); Optional<HsHostingAssetRbacEntity> findByUuid(final UUID serverUuid);
@Timed("app.hostingAsset.repo.findByIdentifier.rbac")
List<HsHostingAssetRbacEntity> findByIdentifier(String assetIdentifier); List<HsHostingAssetRbacEntity> findByIdentifier(String assetIdentifier);
@Query(value = """ @Query(value = """
@ -32,16 +35,21 @@ public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<H
and (:parentAssetUuid is null or pha.uuid=:parentAssetUuid) and (:parentAssetUuid is null or pha.uuid=:parentAssetUuid)
and (:type is null or :type=cast(ha.type as text)) and (:type is null or :type=cast(ha.type as text))
""", nativeQuery = true) """, nativeQuery = true)
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.rbac")
// The JPQL query did not generate "left join" but just "join". // The JPQL query did not generate "left join" but just "join".
// I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv. // I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv.
List<HsHostingAssetRbacEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); List<HsHostingAssetRbacEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<HsHostingAssetRbacEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { default List<HsHostingAssetRbacEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
} }
@Timed("app.hostingAsset.repo.save.rbac")
HsHostingAssetRbacEntity save(HsHostingAsset current); HsHostingAssetRbacEntity save(HsHostingAsset current);
@Timed("app.hostingAsset.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.hostingAsset.repo.count.rbac")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.hosting.asset; package net.hostsharing.hsadminng.hs.hosting.asset;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,8 +11,10 @@ import java.util.UUID;
public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<HsHostingAssetRealEntity>, Repository<HsHostingAssetRealEntity, UUID> { public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<HsHostingAssetRealEntity>, Repository<HsHostingAssetRealEntity, UUID> {
@Timed("app.hostingAsset.repo.findByUuid.real")
Optional<HsHostingAssetRealEntity> findByUuid(final UUID serverUuid); Optional<HsHostingAssetRealEntity> findByUuid(final UUID serverUuid);
@Timed("app.hostingAsset.repo.findByIdentifier.real")
List<HsHostingAssetRealEntity> findByIdentifier(String assetIdentifier); List<HsHostingAssetRealEntity> findByIdentifier(String assetIdentifier);
default List<HsHostingAssetRealEntity> findByTypeAndIdentifier(@NotNull HsHostingAssetType type, @NotNull String identifier) { default List<HsHostingAssetRealEntity> findByTypeAndIdentifier(@NotNull HsHostingAssetType type, @NotNull String identifier) {
@ -24,6 +27,7 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<H
where cast(ha.type as String) = :type where cast(ha.type as String) = :type
and ha.identifier = :identifier and ha.identifier = :identifier
""") """)
@Timed("app.hostingAsset.repo.findByTypeAndIdentifierImpl.real")
List<HsHostingAssetRealEntity> findByTypeAndIdentifierImpl(@NotNull String type, @NotNull String identifier); List<HsHostingAssetRealEntity> findByTypeAndIdentifierImpl(@NotNull String type, @NotNull String identifier);
@Query(value = """ @Query(value = """
@ -46,14 +50,19 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<H
""", nativeQuery = true) """, nativeQuery = true)
// The JPQL query did not generate "left join" but just "join". // The JPQL query did not generate "left join" but just "join".
// I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv. // I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv.
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.real")
List<HsHostingAssetRealEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); List<HsHostingAssetRealEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<HsHostingAssetRealEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { default List<HsHostingAssetRealEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
} }
@Timed("app.hostingAsset.repo.save.real")
HsHostingAssetRealEntity save(HsHostingAssetRealEntity current); HsHostingAssetRealEntity save(HsHostingAssetRealEntity current);
@Timed("app.hostingAsset.repo.deleteByUuid.real")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.hostingAsset.repo.count.real")
long count(); long count();
} }

View File

@ -1,24 +1,32 @@
package net.hostsharing.hsadminng.hs.hosting.asset; package net.hostsharing.hsadminng.hs.hosting.asset;
import io.micrometer.core.annotation.Timed;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public interface HsHostingAssetRepository<E extends HsHostingAsset> { public interface HsHostingAssetRepository<E extends HsHostingAsset> {
@Timed("app.hosting.assets.repo.findByUuid")
Optional<E> findByUuid(final UUID serverUuid); Optional<E> findByUuid(final UUID serverUuid);
@Timed("app.hosting.assets.repo.findByIdentifier")
List<E> findByIdentifier(String assetIdentifier); List<E> findByIdentifier(String assetIdentifier);
@Timed("app.hosting.assets.repo.findAllByCriteriaImpl")
List<E> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); List<E> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<E> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { default List<E> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
} }
@Timed("app.hosting.assets.repo.save")
E save(HsHostingAsset current); E save(HsHostingAsset current);
@Timed("app.hosting.assets.repo.deleteByUuid")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.hosting.assets.repo.count")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.bankaccount; package net.hostsharing.hsadminng.hs.office.bankaccount;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeBankAccountsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeBankAccountsApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountInsertResource;
@ -31,7 +32,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficeBankAccountResource>> listBankAccounts( @Timed("app.office.bankAccounts.api.patchDebitor")
public ResponseEntity<List<HsOfficeBankAccountResource>> getListOfBankAccounts(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String holder) { final String holder) {
@ -45,7 +47,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficeBankAccountResource> addBankAccount( @Timed("app.office.bankAccounts.api.postNewBankAccount")
public ResponseEntity<HsOfficeBankAccountResource> postNewBankAccount(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficeBankAccountInsertResource body) { final HsOfficeBankAccountInsertResource body) {
@ -71,7 +74,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficeBankAccountResource> getBankAccountByUuid( @Timed("app.office.bankAccounts.api.getSingleBankAccountByUuid")
public ResponseEntity<HsOfficeBankAccountResource> getSingleBankAccountByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID bankAccountUuid) { final UUID bankAccountUuid) {
@ -87,6 +91,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.bankAccounts.api.deleteBankAccountByUuid")
public ResponseEntity<Void> deleteBankAccountByUuid( public ResponseEntity<Void> deleteBankAccountByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.bankaccount; package net.hostsharing.hsadminng.hs.office.bankaccount;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,23 +10,31 @@ import java.util.UUID;
public interface HsOfficeBankAccountRepository extends Repository<HsOfficeBankAccountEntity, UUID> { public interface HsOfficeBankAccountRepository extends Repository<HsOfficeBankAccountEntity, UUID> {
@Timed("app.office.bankAccounts.repo.findByUuid")
Optional<HsOfficeBankAccountEntity> findByUuid(UUID id); Optional<HsOfficeBankAccountEntity> findByUuid(UUID id);
@Query(""" @Query("""
SELECT c FROM HsOfficeBankAccountEntity c SELECT c FROM HsOfficeBankAccountEntity c
WHERE lower(c.holder) like lower(concat(:holder, '%')) WHERE lower(c.holder) like lower(concat(:holder, '%'))
ORDER BY c.holder ORDER BY c.holder
""") """)
@Timed("app.office.bankAccounts.repo.findByOptionalHolderLikeImpl")
List<HsOfficeBankAccountEntity> findByOptionalHolderLikeImpl(String holder); List<HsOfficeBankAccountEntity> findByOptionalHolderLikeImpl(String holder);
default List<HsOfficeBankAccountEntity> findByOptionalHolderLike(String holder) { default List<HsOfficeBankAccountEntity> findByOptionalHolderLike(String holder) {
return findByOptionalHolderLikeImpl(holder == null ? "" : holder); return findByOptionalHolderLikeImpl(holder == null ? "" : holder);
} }
@Timed("app.office.bankAccounts.repo.findByIbanOrderByIbanAsc")
List<HsOfficeBankAccountEntity> findByIbanOrderByIbanAsc(String iban); List<HsOfficeBankAccountEntity> findByIbanOrderByIbanAsc(String iban);
@Timed("app.office.bankAccounts.repo.save")
<S extends HsOfficeBankAccountEntity> S save(S entity); <S extends HsOfficeBankAccountEntity> S save(S entity);
@Timed("app.office.bankAccounts.repo.deleteByUuid")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.office.bankAccounts.repo.count")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.contact; package net.hostsharing.hsadminng.hs.office.contact;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeContactsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeContactsApi;
@ -33,7 +34,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficeContactResource>> listContacts( @Timed("app.office.contacts.api.getListOfContacts")
public ResponseEntity<List<HsOfficeContactResource>> getListOfContacts(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String caption) { final String caption) {
@ -47,7 +49,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficeContactResource> addContact( @Timed("app.office.contacts.api.postNewContact")
public ResponseEntity<HsOfficeContactResource> postNewContact(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficeContactInsertResource body) { final HsOfficeContactInsertResource body) {
@ -69,7 +72,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficeContactResource> getContactByUuid( @Timed("app.office.contacts.api.getSingleContactByUuid")
public ResponseEntity<HsOfficeContactResource> getSingleContactByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID contactUuid) { final UUID contactUuid) {
@ -85,6 +89,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.contacts.api.deleteContactByUuid")
public ResponseEntity<Void> deleteContactByUuid( public ResponseEntity<Void> deleteContactByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -101,6 +106,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.contacts.api.patchContact")
public ResponseEntity<HsOfficeContactResource> patchContact( public ResponseEntity<HsOfficeContactResource> patchContact(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.contact; package net.hostsharing.hsadminng.hs.office.contact;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,18 +10,23 @@ import java.util.UUID;
public interface HsOfficeContactRbacRepository extends Repository<HsOfficeContactRbacEntity, UUID> { public interface HsOfficeContactRbacRepository extends Repository<HsOfficeContactRbacEntity, UUID> {
@Timed("app.office.contacts.repo.findByUuid.rbac")
Optional<HsOfficeContactRbacEntity> findByUuid(UUID id); Optional<HsOfficeContactRbacEntity> findByUuid(UUID id);
@Query(""" @Query("""
SELECT c FROM HsOfficeContactRbacEntity c SELECT c FROM HsOfficeContactRbacEntity c
WHERE :caption is null WHERE :caption is null
OR c.caption like concat(cast(:caption as text), '%') OR c.caption like concat(cast(:caption as text), '%')
""") """)
@Timed("app.office.contacts.repo.findContactByOptionalCaptionLike.rbac")
List<HsOfficeContactRbacEntity> findContactByOptionalCaptionLike(String caption); List<HsOfficeContactRbacEntity> findContactByOptionalCaptionLike(String caption);
@Timed("app.office.contacts.repo.save.rbac")
HsOfficeContactRbacEntity save(final HsOfficeContactRbacEntity entity); HsOfficeContactRbacEntity save(final HsOfficeContactRbacEntity entity);
@Timed("app.office.contacts.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.office.contacts.repo.count.rbac")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.contact; package net.hostsharing.hsadminng.hs.office.contact;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,18 +10,23 @@ import java.util.UUID;
public interface HsOfficeContactRealRepository extends Repository<HsOfficeContactRealEntity, UUID> { public interface HsOfficeContactRealRepository extends Repository<HsOfficeContactRealEntity, UUID> {
@Timed("app.office.contacts.repo.findByUuid.real")
Optional<HsOfficeContactRealEntity> findByUuid(UUID id); Optional<HsOfficeContactRealEntity> findByUuid(UUID id);
@Query(""" @Query("""
SELECT c FROM HsOfficeContactRealEntity c SELECT c FROM HsOfficeContactRealEntity c
WHERE :caption is null WHERE :caption is null
OR c.caption like concat(cast(:caption as text), '%') OR c.caption like concat(cast(:caption as text), '%')
""") """)
@Timed("app.office.contacts.repo.findContactByOptionalCaptionLike.real")
List<HsOfficeContactRealEntity> findContactByOptionalCaptionLike(String caption); List<HsOfficeContactRealEntity> findContactByOptionalCaptionLike(String caption);
@Timed("app.office.contacts.repo.save.real")
HsOfficeContactRealEntity save(final HsOfficeContactRealEntity entity); HsOfficeContactRealEntity save(final HsOfficeContactRealEntity entity);
@Timed("app.office.contacts.repo.deleteByUuid.real")
int deleteByUuid(final UUID uuid); int deleteByUuid(final UUID uuid);
@Timed("app.office.contacts.repo.count.real")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.coopassets; package net.hostsharing.hsadminng.hs.office.coopassets;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.errors.MultiValidationException; import net.hostsharing.hsadminng.errors.MultiValidationException;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi;
@ -55,6 +56,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.coopAssets.api.getListOfCoopAssets")
public ResponseEntity<List<HsOfficeCoopAssetsTransactionResource>> getListOfCoopAssets( public ResponseEntity<List<HsOfficeCoopAssetsTransactionResource>> getListOfCoopAssets(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -77,6 +79,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
@Override @Override
@Transactional @Transactional
@Timed("app.office.coopAssets.api.postNewCoopAssetTransaction")
public ResponseEntity<HsOfficeCoopAssetsTransactionResource> postNewCoopAssetTransaction( public ResponseEntity<HsOfficeCoopAssetsTransactionResource> postNewCoopAssetTransaction(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -102,6 +105,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.coopAssets.api.getSingleCoopAssetTransactionByUuid")
public ResponseEntity<HsOfficeCoopAssetsTransactionResource> getSingleCoopAssetTransactionByUuid( public ResponseEntity<HsOfficeCoopAssetsTransactionResource> getSingleCoopAssetTransactionByUuid(
final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) {

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.coopassets; package net.hostsharing.hsadminng.hs.office.coopassets;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,6 +11,7 @@ import java.util.UUID;
public interface HsOfficeCoopAssetsTransactionRepository extends Repository<HsOfficeCoopAssetsTransactionEntity, UUID> { public interface HsOfficeCoopAssetsTransactionRepository extends Repository<HsOfficeCoopAssetsTransactionEntity, UUID> {
@Timed("app.office.coopAssets.repo.findByUuid")
Optional<HsOfficeCoopAssetsTransactionEntity> findByUuid(UUID id); Optional<HsOfficeCoopAssetsTransactionEntity> findByUuid(UUID id);
@Query(""" @Query("""
@ -18,11 +20,14 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository<HsOf
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (at.valueDate >= :fromValueDate)) AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (at.valueDate >= :fromValueDate))
AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (at.valueDate <= :toValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (at.valueDate <= :toValueDate))
ORDER BY at.membership.memberNumberSuffix, at.valueDate ORDER BY at.membership.memberNumberSuffix, at.valueDate
""") """)
@Timed("app.office.coopAssets.repo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange")
List<HsOfficeCoopAssetsTransactionEntity> findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( List<HsOfficeCoopAssetsTransactionEntity> findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate);
@Timed("app.office.coopAssets.repo.save")
HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity); HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity);
@Timed("app.office.coopAssets.repo.count")
long count(); long count();
} }

View File

@ -1,6 +1,8 @@
package net.hostsharing.hsadminng.hs.office.coopshares; package net.hostsharing.hsadminng.hs.office.coopshares;
import jakarta.persistence.EntityNotFoundException; import jakarta.persistence.EntityNotFoundException;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionInsertResource;
@ -38,6 +40,8 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.coopShares.api.getListOfCoopShares")
public ResponseEntity<List<HsOfficeCoopSharesTransactionResource>> getListOfCoopShares( public ResponseEntity<List<HsOfficeCoopSharesTransactionResource>> getListOfCoopShares(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -57,6 +61,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
@Override @Override
@Transactional @Transactional
@Timed("app.office.coopShares.repo.postNewCoopSharesTransaction")
public ResponseEntity<HsOfficeCoopSharesTransactionResource> postNewCoopSharesTransaction( public ResponseEntity<HsOfficeCoopSharesTransactionResource> postNewCoopSharesTransaction(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -80,6 +85,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.coopShares.repo.getSingleCoopShareTransactionByUuid")
public ResponseEntity<HsOfficeCoopSharesTransactionResource> getSingleCoopShareTransactionByUuid( public ResponseEntity<HsOfficeCoopSharesTransactionResource> getSingleCoopShareTransactionByUuid(
final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) {

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.coopshares; package net.hostsharing.hsadminng.hs.office.coopshares;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,6 +11,7 @@ import java.util.UUID;
public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOfficeCoopSharesTransactionEntity, UUID> { public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOfficeCoopSharesTransactionEntity, UUID> {
@Timed("app.office.coopShares.repo.findByUuid")
Optional<HsOfficeCoopSharesTransactionEntity> findByUuid(UUID id); Optional<HsOfficeCoopSharesTransactionEntity> findByUuid(UUID id);
@Query(""" @Query("""
@ -18,11 +20,14 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOf
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (st.valueDate >= :fromValueDate)) AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (st.valueDate >= :fromValueDate))
AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate))
ORDER BY st.membership.memberNumberSuffix, st.valueDate ORDER BY st.membership.memberNumberSuffix, st.valueDate
""") """)
@Timed("app.office.coopShares.repo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange")
List<HsOfficeCoopSharesTransactionEntity> findCoopSharesTransactionByOptionalMembershipUuidAndDateRange( List<HsOfficeCoopSharesTransactionEntity> findCoopSharesTransactionByOptionalMembershipUuidAndDateRange(
UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate);
@Timed("app.office.coopShares.repo.save")
HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity); HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity);
@Timed("app.office.coopShares.repo.count")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.debitor; package net.hostsharing.hsadminng.hs.office.debitor;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitorsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitorsApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource;
@ -51,6 +52,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.debitors.api.getListOfDebitors")
public ResponseEntity<List<HsOfficeDebitorResource>> getListOfDebitors( public ResponseEntity<List<HsOfficeDebitorResource>> getListOfDebitors(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -68,6 +70,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.debitors.api.postNewDebitor")
public ResponseEntity<HsOfficeDebitorResource> postNewDebitor( public ResponseEntity<HsOfficeDebitorResource> postNewDebitor(
String currentSubject, String currentSubject,
String assumedRoles, String assumedRoles,
@ -115,6 +118,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.debitors.api.getSingleDebitorByUuid")
public ResponseEntity<HsOfficeDebitorResource> getSingleDebitorByUuid( public ResponseEntity<HsOfficeDebitorResource> getSingleDebitorByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -131,6 +135,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.debitors.api.deleteDebitorByUuid")
public ResponseEntity<Void> deleteDebitorByUuid( public ResponseEntity<Void> deleteDebitorByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -147,6 +152,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.debitors.api.patchDebitor")
public ResponseEntity<HsOfficeDebitorResource> patchDebitor( public ResponseEntity<HsOfficeDebitorResource> patchDebitor(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.debitor; package net.hostsharing.hsadminng.hs.office.debitor;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,6 +10,7 @@ import java.util.UUID;
public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEntity, UUID> { public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEntity, UUID> {
@Timed("app.office.debitors.repo.findByUuid")
Optional<HsOfficeDebitorEntity> findByUuid(UUID id); Optional<HsOfficeDebitorEntity> findByUuid(UUID id);
@Query(""" @Query("""
@ -19,12 +21,13 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
WHERE partner.partnerNumber = :partnerNumber WHERE partner.partnerNumber = :partnerNumber
AND debitor.debitorNumberSuffix = :debitorNumberSuffix AND debitor.debitorNumberSuffix = :debitorNumberSuffix
""") """)
List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); @Timed("app.office.debitors.repo.findDebitorByPartnerNumberAndDebitorNumberSuffix")
List<HsOfficeDebitorEntity> findDebitorByPartnerNumberAndDebitorNumberSuffix(int partnerNumber, String debitorNumberSuffix);
default List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int debitorNumber) { default List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int debitorNumber) {
final var partnerNumber = debitorNumber / 100; final var partnerNumber = debitorNumber / 100;
final String suffix = String.format("%02d", debitorNumber % 100); final String suffix = String.format("%02d", debitorNumber % 100);
final var result = findDebitorByDebitorNumber(partnerNumber, suffix); final var result = findDebitorByPartnerNumberAndDebitorNumberSuffix(partnerNumber, suffix);
return result; return result;
} }
@ -46,11 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
OR person.givenName like concat(cast(:name as text), '%') OR person.givenName like concat(cast(:name as text), '%')
OR contact.caption like concat(cast(:name as text), '%') OR contact.caption like concat(cast(:name as text), '%')
""") """)
@Timed("app.office.debitors.repo.findDebitorByOptionalNameLike")
List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name); List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name);
@Timed("app.office.debitors.repo.save")
HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity); HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity);
@Timed("app.office.debitors.repo.count")
long count(); long count();
@Timed("app.office.debitors.repo.deleteByUuid")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.membership; package net.hostsharing.hsadminng.hs.office.membership;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeMembershipsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeMembershipsApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipInsertResource;
@ -33,6 +34,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.membership.api.getListOfMemberships")
public ResponseEntity<List<HsOfficeMembershipResource>> getListOfMemberships( public ResponseEntity<List<HsOfficeMembershipResource>> getListOfMemberships(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -53,6 +55,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.membership.api.postNewMembership")
public ResponseEntity<HsOfficeMembershipResource> postNewMembership( public ResponseEntity<HsOfficeMembershipResource> postNewMembership(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -76,6 +79,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Timed("app.office.membership.api.getSingleMembershipByUuid")
public ResponseEntity<HsOfficeMembershipResource> getSingleMembershipByUuid( public ResponseEntity<HsOfficeMembershipResource> getSingleMembershipByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -93,6 +97,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.membership.api.deleteMembershipByUuid")
public ResponseEntity<Void> deleteMembershipByUuid( public ResponseEntity<Void> deleteMembershipByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -109,6 +114,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.membership.api.patchMembership")
public ResponseEntity<HsOfficeMembershipResource> patchMembership( public ResponseEntity<HsOfficeMembershipResource> patchMembership(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.membership; package net.hostsharing.hsadminng.hs.office.membership;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,10 +11,13 @@ import java.util.UUID;
public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembershipEntity, UUID> { public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembershipEntity, UUID> {
@Timed("app.office.membership.repo.findByUuid")
Optional<HsOfficeMembershipEntity> findByUuid(UUID id); Optional<HsOfficeMembershipEntity> findByUuid(UUID id);
@Timed("app.office.membership.repo.save")
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity); HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
@Timed("app.office.membership.repo.findAll")
List<HsOfficeMembershipEntity> findAll(); List<HsOfficeMembershipEntity> findAll();
@Query(""" @Query("""
@ -22,6 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
OR membership.partner.uuid = :partnerUuid ) OR membership.partner.uuid = :partnerUuid )
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
""") """)
@Timed("app.office.membership.repo.findMembershipsByOptionalPartnerUuid")
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid); List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
@Query(""" @Query("""
@ -30,6 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
AND (membership.memberNumberSuffix = :suffix) AND (membership.memberNumberSuffix = :suffix)
ORDER BY membership.memberNumberSuffix ORDER BY membership.memberNumberSuffix
""") """)
@Timed("app.office.membership.repo.findMembershipByPartnerNumberAndSuffix")
HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix( HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix(
@NotNull Integer partnerNumber, @NotNull Integer partnerNumber,
@NotNull String suffix); @NotNull String suffix);
@ -41,7 +47,9 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
return result; return result;
} }
@Timed("app.office.membership.repo.count")
long count(); long count();
@Timed("app.office.membership.repo.deleteByUuid")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.partner; package net.hostsharing.hsadminng.hs.office.partner;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.errors.ReferenceNotFoundException; import net.hostsharing.hsadminng.errors.ReferenceNotFoundException;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity;
@ -50,7 +51,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficePartnerResource>> listPartners( @Timed("app.office.partners.api.getListOfPartners")
public ResponseEntity<List<HsOfficePartnerResource>> getListOfPartners(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String name) { final String name) {
@ -64,7 +66,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficePartnerResource> addPartner( @Timed("app.office.partners.api.postNewPartner")
public ResponseEntity<HsOfficePartnerResource> postNewPartner(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficePartnerInsertResource body) { final HsOfficePartnerInsertResource body) {
@ -86,7 +89,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficePartnerResource> getPartnerByUuid( @Timed("app.office.partners.api.getSinglePartnerByUuid")
public ResponseEntity<HsOfficePartnerResource> getSinglePartnerByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID partnerUuid) { final UUID partnerUuid) {
@ -102,6 +106,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.partners.api.deletePartnerByUuid")
public ResponseEntity<Void> deletePartnerByUuid( public ResponseEntity<Void> deletePartnerByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -122,6 +127,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.partners.api.patchPartner")
public ResponseEntity<HsOfficePartnerResource> patchPartner( public ResponseEntity<HsOfficePartnerResource> patchPartner(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.partner; package net.hostsharing.hsadminng.hs.office.partner;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,9 +10,11 @@ import java.util.UUID;
public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEntity, UUID> { public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEntity, UUID> {
@Timed("app.office.partners.repo.findByUuid")
Optional<HsOfficePartnerEntity> findByUuid(UUID id); Optional<HsOfficePartnerEntity> findByUuid(UUID id);
List<HsOfficePartnerEntity> findAll(); // TODO.impl: move to a repo in test sources @Timed("app.office.partners.repo.findAll")
List<HsOfficePartnerEntity> findAll(); // TODO.refa: move to a repo in test sources
@Query(""" @Query("""
SELECT partner FROM HsOfficePartnerEntity partner SELECT partner FROM HsOfficePartnerEntity partner
@ -25,12 +28,18 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
OR person.givenName like concat(cast(:name as text), '%') OR person.givenName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%') OR person.familyName like concat(cast(:name as text), '%')
""") """)
@Timed("app.office.partners.repo.findPartnerByOptionalNameLike")
List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name); List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name);
@Timed("app.office.partners.repo.findPartnerByPartnerNumber")
HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber);
@Timed("app.office.partners.repo.save")
HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); HsOfficePartnerEntity save(final HsOfficePartnerEntity entity);
@Timed("app.office.partners.repo.count")
long count(); long count();
@Timed("app.office.partners.repo.deleteByUuid")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.person; package net.hostsharing.hsadminng.hs.office.person;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficePersonsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficePersonsApi;
@ -30,7 +31,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficePersonResource>> listPersons( @Timed("app.office.persons.api.getListOfPersons")
public ResponseEntity<List<HsOfficePersonResource>> getListOfPersons(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String caption) { final String caption) {
@ -44,7 +46,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficePersonResource> addPerson( @Timed("app.office.persons.api.postNewPerson")
public ResponseEntity<HsOfficePersonResource> postNewPerson(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficePersonInsertResource body) { final HsOfficePersonInsertResource body) {
@ -66,7 +69,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficePersonResource> getPersonByUuid( @Timed("app.office.persons.api.getSinglePersonByUuid")
public ResponseEntity<HsOfficePersonResource> getSinglePersonByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID personUuid) { final UUID personUuid) {
@ -82,6 +86,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.persons.api.deletePersonByUuid")
public ResponseEntity<Void> deletePersonByUuid( public ResponseEntity<Void> deletePersonByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -98,6 +103,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.persons.api.patchPerson")
public ResponseEntity<HsOfficePersonResource> patchPerson( public ResponseEntity<HsOfficePersonResource> patchPerson(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.person; package net.hostsharing.hsadminng.hs.office.person;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,6 +10,7 @@ import java.util.UUID;
public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntity, UUID> { public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntity, UUID> {
@Timed("app.office.persons.repo.findByUuid.rbac")
Optional<HsOfficePersonEntity> findByUuid(UUID personUuid); Optional<HsOfficePersonEntity> findByUuid(UUID personUuid);
@Query(""" @Query("""
@ -17,12 +19,16 @@ public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntit
OR p.tradeName like concat(cast(:name as text), '%') OR p.tradeName like concat(cast(:name as text), '%')
OR p.givenName like concat(cast(:name as text), '%') OR p.givenName like concat(cast(:name as text), '%')
OR p.familyName like concat(cast(:name as text), '%') OR p.familyName like concat(cast(:name as text), '%')
""") """)
@Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac")
List<HsOfficePersonEntity> findPersonByOptionalNameLike(String name); List<HsOfficePersonEntity> findPersonByOptionalNameLike(String name);
@Timed("app.office.persons.repo.save.rbac")
HsOfficePersonEntity save(final HsOfficePersonEntity entity); HsOfficePersonEntity save(final HsOfficePersonEntity entity);
@Timed("app.office.persons.repo.deleteByUuid.rbac")
int deleteByUuid(final UUID personUuid); int deleteByUuid(final UUID personUuid);
@Timed("app.office.persons.repo.count.rbac")
long count(); long count();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.relation; package net.hostsharing.hsadminng.hs.office.relation;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi;
@ -21,7 +22,6 @@ import java.util.function.BiConsumer;
@RestController @RestController
public class HsOfficeRelationController implements HsOfficeRelationsApi { public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Autowired @Autowired
@ -44,7 +44,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficeRelationResource>> listRelations( @Timed("app.office.relations.api.getListOfRelations")
public ResponseEntity<List<HsOfficeRelationResource>> getListOfRelations(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID personUuid, final UUID personUuid,
@ -66,7 +67,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficeRelationResource> addRelation( @Timed("app.office.relations.api.postNewRelation")
public ResponseEntity<HsOfficeRelationResource> postNewRelation(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficeRelationInsertResource body) { final HsOfficeRelationInsertResource body) {
@ -100,7 +102,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficeRelationResource> getRelationByUuid( @Timed("app.office.relations.api.getSingleRelationByUuid")
public ResponseEntity<HsOfficeRelationResource> getSingleRelationByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID relationUuid) { final UUID relationUuid) {
@ -116,6 +119,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override @Override
@Transactional @Transactional
@Timed("apprelations.api..deleteRelationByUuid")
public ResponseEntity<Void> deleteRelationByUuid( public ResponseEntity<Void> deleteRelationByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -132,6 +136,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.relations.api.patchRelation")
public ResponseEntity<HsOfficeRelationResource> patchRelation( public ResponseEntity<HsOfficeRelationResource> patchRelation(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.relation; package net.hostsharing.hsadminng.hs.office.relation;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,12 +11,14 @@ import java.util.UUID;
public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelationRbacEntity, UUID> { public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelationRbacEntity, UUID> {
@Timed("app.office.relations.repo.findByUuid.rbac")
Optional<HsOfficeRelationRbacEntity> findByUuid(UUID id); Optional<HsOfficeRelationRbacEntity> findByUuid(UUID id);
@Query(value = """ @Query(value = """
SELECT p.* FROM hs_office.relation_rv AS p SELECT p.* FROM hs_office.relation_rv AS p
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
""", nativeQuery = true) """, nativeQuery = true)
@Timed("app.office.relations.repo.findRelationRelatedToPersonUuid.rbac")
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid); List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
/** /**
@ -51,16 +54,20 @@ public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelat
OR lower(CAST(rel.contact.emailAddresses AS String)) LIKE :contactData OR lower(CAST(rel.contact.emailAddresses AS String)) LIKE :contactData
OR lower(CAST(rel.contact.phoneNumbers AS String)) LIKE :contactData ) OR lower(CAST(rel.contact.phoneNumbers AS String)) LIKE :contactData )
""") """)
@Timed("app.office.relations.repo.findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl.rbac")
List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl( List<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl(
final UUID personUuid, final UUID personUuid,
final String relationType, final String relationType,
final String personData, final String personData,
final String contactData); final String contactData);
@Timed("app.office.relations.repo.save.rbac")
HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity); HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity);
@Timed("app.office.relations.repo.count.rbac")
long count(); long count();
@Timed("app.office.relations.repo.deleteByUuid.rbac")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
private static String toSqlLikeOperand(final String text) { private static String toSqlLikeOperand(final String text) {

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.relation; package net.hostsharing.hsadminng.hs.office.relation;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -10,6 +11,7 @@ import java.util.UUID;
public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelationRealEntity, UUID> { public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelationRealEntity, UUID> {
@Timed("app.repo.relations.findByUuid.real")
Optional<HsOfficeRelationRealEntity> findByUuid(UUID id); Optional<HsOfficeRelationRealEntity> findByUuid(UUID id);
default List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) { default List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
@ -20,6 +22,7 @@ public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelat
SELECT p.* FROM hs_office.relation AS p SELECT p.* FROM hs_office.relation AS p
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
""", nativeQuery = true) """, nativeQuery = true)
@Timed("app.repo.relations.findRelationRelatedToPersonUuid.real")
List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid); List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
@Query(value = """ @Query(value = """
@ -27,11 +30,15 @@ public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelat
WHERE (:relationType IS NULL OR p.type = cast(:relationType AS hs_office.RelationType)) WHERE (:relationType IS NULL OR p.type = cast(:relationType AS hs_office.RelationType))
AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid) AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid)
""", nativeQuery = true) """, nativeQuery = true)
@Timed("app.repo.relations.findRelationRelatedToPersonUuidAndRelationTypeString.real")
List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType); List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType);
@Timed("app.repo.relations.save.real")
HsOfficeRelationRealEntity save(final HsOfficeRelationRealEntity entity); HsOfficeRelationRealEntity save(final HsOfficeRelationRealEntity entity);
@Timed("app.repo.relations.count.real")
long count(); long count();
@Timed("app.repo.relations.deleteByUuid.real")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.sepamandate; package net.hostsharing.hsadminng.hs.office.sepamandate;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeSepaMandatesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeSepaMandatesApi;
import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandateInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandateInsertResource;
@ -38,7 +39,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<HsOfficeSepaMandateResource>> listSepaMandatesByIban( @Timed("app.office.sepaMandates.api.getListOfSepaMandates")
public ResponseEntity<List<HsOfficeSepaMandateResource>> getListOfSepaMandates(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String iban) { final String iban) {
@ -53,7 +55,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<HsOfficeSepaMandateResource> addSepaMandate( @Timed("app.office.sepaMandates.api.postNewSepaMandate")
public ResponseEntity<HsOfficeSepaMandateResource> postNewSepaMandate(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final HsOfficeSepaMandateInsertResource body) { final HsOfficeSepaMandateInsertResource body) {
@ -76,7 +79,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<HsOfficeSepaMandateResource> getSepaMandateByUuid( @Timed("app.office.sepaMandates.api.getSingleSepaMandateByUuid")
public ResponseEntity<HsOfficeSepaMandateResource> getSingleSepaMandateByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID sepaMandateUuid) { final UUID sepaMandateUuid) {
@ -93,6 +97,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.sepaMandates.api.deleteSepaMandateByUuid")
public ResponseEntity<Void> deleteSepaMandateByUuid( public ResponseEntity<Void> deleteSepaMandateByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -109,6 +114,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
@Override @Override
@Transactional @Transactional
@Timed("app.office.sepaMandates.api.patchSepaMandate")
public ResponseEntity<HsOfficeSepaMandateResource> patchSepaMandate( public ResponseEntity<HsOfficeSepaMandateResource> patchSepaMandate(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.office.sepamandate; package net.hostsharing.hsadminng.hs.office.sepamandate;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -9,6 +10,7 @@ import java.util.UUID;
public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMandateEntity, UUID> { public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMandateEntity, UUID> {
@Timed("app.office.sepaMandates.repo.findByUuid")
Optional<HsOfficeSepaMandateEntity> findByUuid(UUID id); Optional<HsOfficeSepaMandateEntity> findByUuid(UUID id);
@Query(""" @Query("""
@ -16,12 +18,16 @@ public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMa
WHERE :iban is null WHERE :iban is null
OR mandate.bankAccount.iban like concat(cast(:iban as text), '%') OR mandate.bankAccount.iban like concat(cast(:iban as text), '%')
ORDER BY mandate.bankAccount.iban ORDER BY mandate.bankAccount.iban
""") """)
@Timed("app.office.sepaMandates.repo.findSepaMandateByOptionalIban")
List<HsOfficeSepaMandateEntity> findSepaMandateByOptionalIban(String iban); List<HsOfficeSepaMandateEntity> findSepaMandateByOptionalIban(String iban);
@Timed("app.office.sepaMandates.repo.save")
HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity); HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity);
@Timed("app.office.sepaMandates.repo.count")
long count(); long count();
@Timed("app.office.sepaMandates.repo.deleteByUuid")
int deleteByUuid(UUID uuid); int deleteByUuid(UUID uuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.grant; package net.hostsharing.hsadminng.rbac.grant;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -7,9 +8,12 @@ import java.util.UUID;
public interface RawRbacGrantRepository extends Repository<RawRbacGrantEntity, UUID> { public interface RawRbacGrantRepository extends Repository<RawRbacGrantEntity, UUID> {
List<RawRbacGrantEntity> findAll(); @Timed("app.rbac.grants.repo.findAll")
List<RawRbacGrantEntity> findAll(); // TODO.refa: move to test repo
@Timed("app.rbac.grants.repo.findByAscendingUuid")
List<RawRbacGrantEntity> findByAscendingUuid(UUID ascendingUuid); List<RawRbacGrantEntity> findByAscendingUuid(UUID ascendingUuid);
@Timed("app.rbac.grants.repo.findByDescendantUuid")
List<RawRbacGrantEntity> findByDescendantUuid(UUID refUuid); List<RawRbacGrantEntity> findByDescendantUuid(UUID refUuid);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.grant; package net.hostsharing.hsadminng.rbac.grant;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacGrantsApi; import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacGrantsApi;
@ -32,7 +33,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<RbacGrantResource> getGrantById( @Timed("app.rbac.grants.api.getListOfGrantsByUuid")
public ResponseEntity<RbacGrantResource> getListOfGrantsByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID grantedRoleUuid, final UUID grantedRoleUuid,
@ -50,7 +52,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<RbacGrantResource>> listSubjectGrants( @Timed("app.rbac.grants.api.getListOfSubjectGrants")
public ResponseEntity<List<RbacGrantResource>> getListOfSubjectGrants(
final String currentSubject, final String currentSubject,
final String assumedRoles) { final String assumedRoles) {
@ -61,7 +64,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<RbacGrantResource> grantRoleToSubject( @Timed("app.rbac.grants.api.postNewRoleGrantToSubject")
public ResponseEntity<RbacGrantResource> postNewRoleGrantToSubject(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final RbacGrantResource body) { final RbacGrantResource body) {
@ -82,7 +86,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<Void> revokeRoleFromSubject( @Timed("app.rbac.grants.api.deleteRoleGrantFromSubject")
public ResponseEntity<Void> deleteRoleGrantFromSubject(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID grantedRoleUuid, final UUID grantedRoleUuid,

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.grant; package net.hostsharing.hsadminng.rbac.grant;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -13,12 +14,16 @@ public interface RbacGrantRepository extends Repository<RbacGrantEntity, RbacGra
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid} where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid} and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
""") """)
@Timed("app.rbac.grants.repo.findById")
RbacGrantEntity findById(RbacGrantId rbacGrantId); RbacGrantEntity findById(RbacGrantId rbacGrantId);
@Timed("app.rbac.grants.repo.count")
long count(); long count();
@Timed("app.rbac.grants.repo.findAll")
List<RbacGrantEntity> findAll(); List<RbacGrantEntity> findAll();
@Timed("app.rbac.grants.repo.save")
RbacGrantEntity save(final RbacGrantEntity grant); RbacGrantEntity save(final RbacGrantEntity grant);
@Modifying @Modifying
@ -27,5 +32,6 @@ public interface RbacGrantRepository extends Repository<RbacGrantEntity, RbacGra
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid} where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid} and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
""") """)
@Timed("app.rbac.grants.repo.deleteByRbacGrantId")
void deleteByRbacGrantId(RbacGrantId rbacGrantId); void deleteByRbacGrantId(RbacGrantId rbacGrantId);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.role; package net.hostsharing.hsadminng.rbac.role;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacRolesApi; import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacRolesApi;
@ -25,7 +26,8 @@ public class RbacRoleController implements RbacRolesApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<RbacRoleResource>> listRoles( @Timed("app.rbac.roles.api.getListOfRoles")
public ResponseEntity<List<RbacRoleResource>> getListOfRoles(
final String currentSubject, final String currentSubject,
final String assumedRoles) { final String assumedRoles) {

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.role; package net.hostsharing.hsadminng.rbac.role;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -10,12 +11,15 @@ public interface RbacRoleRepository extends Repository<RbacRoleEntity, UUID> {
/** /**
* @return the number of persistent RbacRoleEntity instances, mostly for testing purposes. * @return the number of persistent RbacRoleEntity instances, mostly for testing purposes.
*/ */
long count(); // TODO: move to test sources @Timed("app.rbac.roles.repo.findByUuid")
long count(); // TODO.refa: move to test sources
/** /**
* @return all persistent RbacRoleEntity instances, assigned to the current subject (user or assumed roles) * @return all persistent RbacRoleEntity instances, assigned to the current subject (user or assumed roles)
*/ */
List<RbacRoleEntity> findAll(); @Timed("app.rbac.roles.repo.findAll")
List<RbacRoleEntity> findAll(); // TODO.refa: move to test sources
@Timed("app.rbac.roles.repo.findByRoleName")
RbacRoleEntity findByRoleName(String roleName); RbacRoleEntity findByRoleName(String roleName);
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.subject; package net.hostsharing.hsadminng.rbac.subject;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.mapper.StandardMapper;
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacSubjectsApi; import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacSubjectsApi;
@ -28,7 +29,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override @Override
@Transactional @Transactional
public ResponseEntity<RbacSubjectResource> createSubject( @Timed("app.rbac.subjects.api.postNewSubject")
public ResponseEntity<RbacSubjectResource> postNewSubject(
final RbacSubjectResource body final RbacSubjectResource body
) { ) {
context.define(null); context.define(null);
@ -48,6 +50,7 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override @Override
@Transactional @Transactional
@Timed("app.rbac.subjects.api.deleteSubjectByUuid")
public ResponseEntity<Void> deleteSubjectByUuid( public ResponseEntity<Void> deleteSubjectByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
@ -62,7 +65,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<RbacSubjectResource> getSubjectById( @Timed("app.rbac.subjects.api.getSingleSubjectByUuid")
public ResponseEntity<RbacSubjectResource> getSingleSubjectByUuid(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID subjectUuid) { final UUID subjectUuid) {
@ -78,7 +82,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<RbacSubjectResource>> listSubjects( @Timed("app.rbac.subjects.api.getListOfSubjects")
public ResponseEntity<List<RbacSubjectResource>> getListOfSubjects(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final String userName final String userName
@ -90,7 +95,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<List<RbacSubjectPermissionResource>> listSubjectPermissions( @Timed("app.rbac.subjects.api.getListOfSubjectPermissions")
public ResponseEntity<List<RbacSubjectPermissionResource>> getListOfSubjectPermissions(
final String currentSubject, final String currentSubject,
final String assumedRoles, final String assumedRoles,
final UUID subjectUuid final UUID subjectUuid

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.subject; package net.hostsharing.hsadminng.rbac.subject;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
@ -14,15 +15,19 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
where :userName is null or u.name like concat(cast(:userName as text), '%') where :userName is null or u.name like concat(cast(:userName as text), '%')
order by u.name order by u.name
""") """)
@Timed("app.rbac.subjects.repo.findByOptionalNameLike")
List<RbacSubjectEntity> findByOptionalNameLike(String userName); List<RbacSubjectEntity> findByOptionalNameLike(String userName);
// bypasses the restricted view, to be able to grant rights to arbitrary user // bypasses the restricted view, to be able to grant rights to arbitrary user
@Query(value = "select * from rbac.subject where name=:userName", nativeQuery = true) @Query(value = "select * from rbac.subject where name=:userName", nativeQuery = true)
@Timed("app.rbac.subjects.repo.findByName")
RbacSubjectEntity findByName(String userName); RbacSubjectEntity findByName(String userName);
@Timed("app.rbac.subjects.repo.findByUuid")
RbacSubjectEntity findByUuid(UUID uuid); RbacSubjectEntity findByUuid(UUID uuid);
@Query(value = "select * from rbac.grantedPermissions(:subjectUuid)", nativeQuery = true) @Query(value = "select * from rbac.grantedPermissions(:subjectUuid)", nativeQuery = true)
@Timed("app.rbac.subjects.repo.findPermissionsOfUserByUuid")
List<RbacSubjectPermission> findPermissionsOfUserByUuid(UUID subjectUuid); List<RbacSubjectPermission> findPermissionsOfUserByUuid(UUID subjectUuid);
/* /*
@ -32,6 +37,7 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
*/ */
@Modifying @Modifying
@Query(value = "insert into rbac.subject_rv (uuid, name) values( :#{#newUser.uuid}, :#{#newUser.name})", nativeQuery = true) @Query(value = "insert into rbac.subject_rv (uuid, name) values( :#{#newUser.uuid}, :#{#newUser.name})", nativeQuery = true)
@Timed("app.rbac.subjects.repo.insert")
void insert(final RbacSubjectEntity newUser); void insert(final RbacSubjectEntity newUser);
default RbacSubjectEntity create(final RbacSubjectEntity rbacSubjectEntity) { default RbacSubjectEntity create(final RbacSubjectEntity rbacSubjectEntity) {
@ -42,5 +48,6 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
return rbacSubjectEntity; return rbacSubjectEntity;
} }
@Timed("app.rbac.subjects.repo.deleteByUuid")
void deleteByUuid(UUID subjectUuid); void deleteByUuid(UUID subjectUuid);
} }

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-booking-items - hs-booking-items
description: 'Fetch a single booking item its uuid, if visible for the current subject.' description: 'Fetch a single booking item its uuid, if visible for the current subject.'
operationId: getBookingItemByUuid operationId: getSingleBookingItemByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all booking items for a specified project which are visible to the current subject or any of it's assumed roles. description: Returns the list of all booking items for a specified project which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-booking-items - hs-booking-items
operationId: listBookingItemsByProjectUuid operationId: getListOfBookingItemsByProjectUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -32,7 +32,7 @@ post:
summary: Adds a new booking item. summary: Adds a new booking item.
tags: tags:
- hs-booking-items - hs-booking-items
operationId: addBookingItem operationId: postNewBookingItem
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all booking projects for a specified debitor which are visible to the current subject or any of it's assumed roles. description: Returns the list of all booking projects for a specified debitor which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-booking-projects - hs-booking-projects
operationId: listBookingProjectsByDebitorUuid operationId: getListOfBookingProjectsByDebitorUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -32,7 +32,7 @@ post:
summary: Adds a new project as a container for booking items. summary: Adds a new project as a container for booking items.
tags: tags:
- hs-booking-projects - hs-booking-projects
operationId: addBookingProject operationId: postNewBookingProject
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of available properties and their validations for a given asset type. description: Returns the list of available properties and their validations for a given asset type.
tags: tags:
- hs-hosting-asset-props - hs-hosting-asset-props
operationId: listAssetTypeProps operationId: getListOfHostingAssetTypeProps
parameters: parameters:
- name: assetType - name: assetType
in: path in: path

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of asset types to enable an adaptive UI. description: Returns the list of asset types to enable an adaptive UI.
tags: tags:
- hs-hosting-asset-props - hs-hosting-asset-props
operationId: listAssetTypes operationId: getListOfHostingAssetTypes
responses: responses:
"200": "200":
description: OK description: OK

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-hosting-assets - hs-hosting-assets
description: 'Fetch a single managed asset by its uuid, if visible for the current subject.' description: 'Fetch a single managed asset by its uuid, if visible for the current subject.'
operationId: getAssetByUuid operationId: getSingleHostingAssetByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -30,7 +30,7 @@ patch:
tags: tags:
- hs-hosting-assets - hs-hosting-assets
description: 'Updates a single hosting asset identified by its uuid, if permitted for the current subject.' description: 'Updates a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: patchAsset operationId: patchHostingAsset
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -61,7 +61,7 @@ delete:
tags: tags:
- hs-hosting-assets - hs-hosting-assets
description: 'Delete a single hosting asset identified by its uuid, if permitted for the current subject.' description: 'Delete a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: deleteAssetUuid operationId: deleteHostingAssetByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all hosting assets which match the given filters and are visible to the current subject or any of it's assumed roles. description: Returns the list of all hosting assets which match the given filters and are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-hosting-assets - hs-hosting-assets
operationId: listAssets operationId: getListOfHostingAssets
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -45,7 +45,7 @@ post:
summary: Adds a new hosting asset. summary: Adds a new hosting asset.
tags: tags:
- hs-hosting-assets - hs-hosting-assets
operationId: addAsset operationId: postNewHostingAsset
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-bank-accounts - hs-office-bank-accounts
description: 'Fetch a single bank account by its uuid, if visible for the current subject.' description: 'Fetch a single bank account by its uuid, if visible for the current subject.'
operationId: getBankAccountByUuid operationId: getSingleBankAccountByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) bankaccounts which are visible to the current subject or any of it's assumed roles. description: Returns the list of (optionally filtered) bankaccounts which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-office-bank-accounts - hs-office-bank-accounts
operationId: listBankAccounts operationId: getListOfBankAccounts
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new bank account. summary: Adds a new bank account.
tags: tags:
- hs-office-bank-accounts - hs-office-bank-accounts
operationId: addBankAccount operationId: postNewBankAccount
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-contacts - hs-office-contacts
description: 'Fetch a single business contact by its uuid, if visible for the current subject.' description: 'Fetch a single business contact by its uuid, if visible for the current subject.'
operationId: getContactByUuid operationId: getSingleContactByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) contacts which are visible to the current subject or any of it's assumed roles. description: Returns the list of (optionally filtered) contacts which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-office-contacts - hs-office-contacts
operationId: listContacts operationId: getListOfContacts
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new contact. summary: Adds a new contact.
tags: tags:
- hs-office-contacts - hs-office-contacts
operationId: addContact operationId: postNewContact
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-partners - hs-office-partners
description: 'Fetch a single business partner by its uuid, if visible for the current subject.' description: 'Fetch a single business partner by its uuid, if visible for the current subject.'
operationId: getPartnerByUuid operationId: getSinglePartnerByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) business partners which are visible to the current subject or any of it's assumed roles. description: Returns the list of (optionally filtered) business partners which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-office-partners - hs-office-partners
operationId: listPartners operationId: getListOfPartners
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new business partner. summary: Adds a new business partner.
tags: tags:
- hs-office-partners - hs-office-partners
operationId: addPartner operationId: postNewPartner
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-persons - hs-office-persons
description: 'Fetch a single business person by its uuid, if visible for the current subject.' description: 'Fetch a single business person by its uuid, if visible for the current subject.'
operationId: getPersonByUuid operationId: getSinglePersonByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) persons which are visible to the current subject or any of it's assumed roles. description: Returns the list of (optionally filtered) persons which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-office-persons - hs-office-persons
operationId: listPersons operationId: getListOfPersons
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new person. summary: Adds a new person.
tags: tags:
- hs-office-persons - hs-office-persons
operationId: addPerson operationId: postNewPerson
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-relations - hs-office-relations
description: 'Fetch a single person relation by its uuid, if visible for the current subject.' description: 'Fetch a single person relation by its uuid, if visible for the current subject.'
operationId: getRelationByUuid operationId: getSingleRelationByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -5,7 +5,7 @@ get:
To match data, all given query parameters must be fulfilled ('and' / logical conjunction). To match data, all given query parameters must be fulfilled ('and' / logical conjunction).
tags: tags:
- hs-office-relations - hs-office-relations
operationId: listRelations operationId: getListOfRelations
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -52,7 +52,7 @@ post:
summary: Adds a new person relation. summary: Adds a new person relation.
tags: tags:
- hs-office-relations - hs-office-relations
operationId: addRelation operationId: postNewRelation
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- hs-office-sepaMandates - hs-office-sepaMandates
description: 'Fetch a single SEPA Mandate by its uuid, if visible for the current subject.' description: 'Fetch a single SEPA Mandate by its uuid, if visible for the current subject.'
operationId: getSepaMandateByUuid operationId: getSingleSepaMandateByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) SEPA Mandates which are visible to the current subject or any of it's assumed roles. description: Returns the list of (optionally filtered) SEPA Mandates which are visible to the current subject or any of it's assumed roles.
tags: tags:
- hs-office-sepaMandates - hs-office-sepaMandates
operationId: listSepaMandatesByIBAN operationId: getListOfSepaMandates
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new SEPA Mandate. summary: Adds a new SEPA Mandate.
tags: tags:
- hs-office-sepaMandates - hs-office-sepaMandates
operationId: addSepaMandate operationId: postNewSepaMandate
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -1,7 +1,7 @@
get: get:
tags: tags:
- rbac-grants - rbac-grants
operationId: getGrantById operationId: getListOfGrantsByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -36,7 +36,7 @@ get:
delete: delete:
tags: tags:
- rbac-grants - rbac-grants
operationId: revokeRoleFromSubject operationId: deleteRoleGrantFromSubject
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -1,7 +1,7 @@
get: get:
tags: tags:
- rbac-grants - rbac-grants
operationId: listSubjectGrants operationId: getListOfSubjectGrants
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -18,7 +18,7 @@ get:
post: post:
tags: tags:
- rbac-grants - rbac-grants
operationId: grantRoleToSubject operationId: postNewRoleGrantToSubject
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -1,7 +1,7 @@
get: get:
tags: tags:
- rbac-roles - rbac-roles
operationId: listRoles operationId: getListOfRoles
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- rbac-subjects - rbac-subjects
description: 'List all visible permissions granted to the given subject; reduced ' description: 'List all visible permissions granted to the given subject; reduced '
operationId: listSubjectPermissions operationId: getListOfSubjectPermissions
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- rbac-subjects - rbac-subjects
description: 'Fetch a single subject by its id, if visible for the current subject.' description: 'Fetch a single subject by its id, if visible for the current subject.'
operationId: getSubjectById operationId: getSingleSubjectByUuid
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags: tags:
- rbac-subjects - rbac-subjects
description: List accessible RBAC subjects with optional filter by name. description: List accessible RBAC subjects with optional filter by name.
operationId: listSubjects operationId: getListOfSubjects
parameters: parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles' - $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -29,7 +29,7 @@ post:
tags: tags:
- rbac-subjects - rbac-subjects
description: Create a new RBAC subject (e.g. user). description: Create a new RBAC subject (e.g. user).
operationId: createSubject operationId: postNewSubject
requestBody: requestBody:
required: true required: true
content: content:

View File

@ -9,9 +9,11 @@ management:
web: web:
exposure: exposure:
include: info, health, metrics include: info, health, metrics
observations:
annotations:
enabled: true
spring: spring:
datasource: datasource:
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
password: password password: password
@ -33,3 +35,11 @@ liquibase:
hsadminng: hsadminng:
postgres: postgres:
leakproof: leakproof:
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true

View File

@ -10,6 +10,7 @@ import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ArchRule; import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.ConditionEvents; import com.tngtech.archunit.lang.ConditionEvents;
import com.tngtech.archunit.lang.SimpleConditionEvent; import com.tngtech.archunit.lang.SimpleConditionEvent;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItem; import net.hostsharing.hsadminng.hs.booking.item.HsBookingItem;
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetRbacEntity; import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetRbacEntity;
@ -20,7 +21,9 @@ import org.springframework.web.bind.annotation.RestController;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import static com.tngtech.archunit.core.domain.JavaModifier.ABSTRACT; import java.lang.annotation.Annotation;
import static com.tngtech.archunit.core.domain.JavaModifier.PUBLIC;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices; import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
import static java.lang.String.format; import static java.lang.String.format;
@ -98,7 +101,7 @@ public class ArchitectureTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static final ArchRule testClassesAreProperlyNamed = classes() public static final ArchRule testClassesAreProperlyNamed = classes()
.that().haveSimpleNameEndingWith("Test") .that().haveSimpleNameEndingWith("Test")
.and().doNotHaveModifier(ABSTRACT) .and().doNotHaveModifier(JavaModifier.ABSTRACT)
.should().haveNameMatching(".*(UnitTest|RestTest|IntegrationTest|AcceptanceTest|ScenarioTest|ArchitectureTest)$"); .should().haveNameMatching(".*(UnitTest|RestTest|IntegrationTest|AcceptanceTest|ScenarioTest|ArchitectureTest)$");
@ArchTest @ArchTest
@ -346,11 +349,25 @@ public class ArchitectureTest {
static final ArchRule restControllerNaming = static final ArchRule restControllerNaming =
classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("Controller"); classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("Controller");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule restControllerMethods = classes()
.that().areAnnotatedWith(RestController.class)
.and().resideOutsideOfPackages("net.hostsharing.hsadminng.rbac.test", "net.hostsharing.hsadminng.rbac.test.*")
.should(haveAllPublicMethodsAnnotatedWith(Timed.class));
@ArchTest @ArchTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
static final ArchRule repositoryNaming = static final ArchRule repositoryNaming =
classes().that().areAssignableTo(Repository.class).should().haveSimpleNameEndingWith("Repository"); classes().that().areAssignableTo(Repository.class).should().haveSimpleNameEndingWith("Repository");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule repositoryMethods = classes()
.that().areAssignableTo(Repository.class)
.and().resideOutsideOfPackages("net.hostsharing.hsadminng.rbac.test", "net.hostsharing.hsadminng.rbac.test.*")
.should(haveAllPublicMethodsAnnotatedWith(Timed.class));
@ArchTest @ArchTest
@SuppressWarnings("unused") @SuppressWarnings("unused")
static final ArchRule tableNamesOfRbacEntitiesShouldEndWith_rv = static final ArchRule tableNamesOfRbacEntitiesShouldEndWith_rv =
@ -389,4 +406,35 @@ public class ArchitectureTest {
} }
}; };
} }
private static ArchCondition<JavaClass> haveAllPublicMethodsAnnotatedWith(Class<? extends Annotation> annotation) {
return new ArchCondition<>("have all public methods annotated with @" + annotation.getSimpleName()) {
@Override
public void check(final JavaClass item, final ConditionEvents events) {
for (JavaMethod method : item.getMethods()) {
if (method.isAnnotatedWith(annotation)) {
continue;
}
if (isGeneratedSpringRepositoryMethod(item, method)) {
continue;
}
if (item.isAnnotatedWith(RestController.class) && !method.getModifiers().contains(PUBLIC)) {
continue;
}
final var message = String.format(
"Method %s in class %s is not annotated with @%s",
method.getName(),
item.getName(),
annotation.getSimpleName()
);
events.add(SimpleConditionEvent.violated(method, message));
}
}
};
}
private static boolean isGeneratedSpringRepositoryMethod(final JavaClass item, final JavaMethod method) {
// this is a heuristic, ideally we can determine all methods with generated database calls
return item.isAssignableTo(Repository.class) && !method.getModifiers().contains(JavaModifier.ABSTRACT);
}
} }

View File

@ -139,10 +139,10 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Nested @Nested
@Order(3) @Order(3)
class AddBookingItem { class PostNewBookingItem {
@Test @Test
void globalAdmin_canAddBookingItem() { void globalAdmin_canPostNewBookingItem() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenProject = findDefaultProjectOfDebitorNumber(1000111); final var givenProject = findDefaultProjectOfDebitorNumber(1000111);
@ -349,7 +349,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
} }
@Test @Test
void projectAgent_canAddBookingItemEvenIfHostingAssetCreationFails() { void projectAgent_canPostNewBookingItemEvenIfHostingAssetCreationFails() {
context.define("superuser-alex@hostsharing.net", "hs_booking.project#D-1000111-D-1000111defaultproject:AGENT"); context.define("superuser-alex@hostsharing.net", "hs_booking.project#D-1000111-D-1000111defaultproject:AGENT");
final var givenProject = findDefaultProjectOfDebitorNumber(1000111); final var givenProject = findDefaultProjectOfDebitorNumber(1000111);

View File

@ -84,7 +84,7 @@ class HsBookingItemControllerRestTest {
} }
@Nested @Nested
class AddBookingItem { class PostNewBookingItem {
@Test @Test
void globalAdmin_canAddValidBookingItem() throws Exception { void globalAdmin_canAddValidBookingItem() throws Exception {

View File

@ -79,10 +79,10 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
} }
@Nested @Nested
class AddBookingProject { class PostNewBookingProject {
@Test @Test
void globalAdmin_canAddBookingProject() { void globalAdmin_canPostNewBookingProject() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream() final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()

View File

@ -76,7 +76,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Nested @Nested
@Order(2) @Order(2)
class ListAssets { class GetListOfHostingAssets {
@Test @Test
void globalAdmin_canViewAllAssetsOfArbitraryDebitor() { void globalAdmin_canViewAllAssetsOfArbitraryDebitor() {
@ -146,7 +146,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Nested @Nested
@Order(3) @Order(3)
class AddAsset { class PostNewHostingAsset {
@Test @Test
void globalAdmin_canAddBookedAsset() { void globalAdmin_canAddBookedAsset() {
@ -481,7 +481,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Nested @Nested
@Order(4) @Order(4)
class PatchAsset { class PatchHostingAsset {
@Test @Test
void globalAdmin_canPatchAllUpdatablePropertiesOfAsset() { void globalAdmin_canPatchAllUpdatablePropertiesOfAsset() {

View File

@ -583,7 +583,7 @@ public class HsHostingAssetControllerRestTest {
@ParameterizedTest @ParameterizedTest
@EnumSource(HsHostingAssetControllerRestTest.ListTestCases.class) @EnumSource(HsHostingAssetControllerRestTest.ListTestCases.class)
void shouldListAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception { void shouldGetListOfHostingAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception {
// given // given
when(rbacAssetRepo.findAllByCriteria(null, null, testCase.assetType)) when(rbacAssetRepo.findAllByCriteria(null, null, testCase.assetType))
.thenReturn(testCase.givenHostingAssetsOfType); .thenReturn(testCase.givenHostingAssetsOfType);
@ -607,7 +607,7 @@ public class HsHostingAssetControllerRestTest {
} }
@Test @Test
void shouldPatchAsset() throws Exception { void shouldPatchHostingAsset() throws Exception {
// given // given
final var givenDomainSetup = HsHostingAssetRealEntity.builder() final var givenDomainSetup = HsHostingAssetRealEntity.builder()
.type(HsHostingAssetType.DOMAIN_SETUP) .type(HsHostingAssetType.DOMAIN_SETUP)

View File

@ -50,7 +50,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
EntityManager em; EntityManager em;
@Nested @Nested
class ListBankAccounts { class GetListOfBankAccounts {
@Test @Test
void globalAdmin_withoutAssumedRoles_canViewAllBankAccounts_ifNoCriteriaGiven() throws JSONException { void globalAdmin_withoutAssumedRoles_canViewAllBankAccounts_ifNoCriteriaGiven() throws JSONException {
@ -117,7 +117,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl
class CreateBankAccount { class CreateBankAccount {
@Test @Test
void globalAdmin_withoutAssumedRole_canAddBankAccount() { void globalAdmin_withoutAssumedRole_canPostNewBankAccount() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");

View File

@ -128,7 +128,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
} }
@Nested @Nested
class ListBankAccounts { class GetListOfBankAccounts {
@Test @Test
public void globalAdmin_canViewAllBankAccounts() { public void globalAdmin_canViewAllBankAccounts() {

View File

@ -58,7 +58,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
@Nested @Nested
@Transactional @Transactional
class ListPartners { class GetListOfPartners {
@Test @Test
void globalAdmin_withoutAssumedRoles_canViewAllPartners_ifNoCriteriaGiven() { void globalAdmin_withoutAssumedRoles_canViewAllPartners_ifNoCriteriaGiven() {
@ -87,10 +87,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
@Nested @Nested
@Transactional @Transactional
class AddPartner { class PostNewPartner {
@Test @Test
void globalAdmin_withoutAssumedRole_canAddPartner() { void globalAdmin_withoutAssumedRole_canPostNewPartner() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow();
@ -150,7 +150,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
void globalAdmin_canNotAddPartner_ifContactDoesNotExist() { void globalAdmin_canNotPostNewPartner_ifContactDoesNotExist() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);
@ -188,7 +188,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
} }
@Test @Test
void globalAdmin_canNotAddPartner_ifPersonDoesNotExist() { void globalAdmin_canNotPostNewPartner_ifPersonDoesNotExist() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0);

View File

@ -91,7 +91,7 @@ class HsOfficePartnerControllerRestTest {
} }
@Nested @Nested
class AddPartner { class PostNewPartner {
@Test @Test
void respondBadRequest_ifPersonUuidIsInvalid() throws Exception { void respondBadRequest_ifPersonUuidIsInvalid() throws Exception {

View File

@ -52,7 +52,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
EntityManager em; EntityManager em;
@Nested @Nested
class ListPersons { class GetListOfPersons {
@Test @Test
void globalAdmin_withoutAssumedRoles_canViewAllPersons_ifNoCriteriaGiven() { void globalAdmin_withoutAssumedRoles_canViewAllPersons_ifNoCriteriaGiven() {

View File

@ -54,7 +54,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
JpaAttempt jpaAttempt; JpaAttempt jpaAttempt;
@Nested @Nested
class ListRelations { class GetListOfRelations {
@Test @Test
void globalAdmin_withoutAssumedRoles_canViewAllRelationsOfGivenPersonAndType() { void globalAdmin_withoutAssumedRoles_canViewAllRelationsOfGivenPersonAndType() {

View File

@ -132,10 +132,10 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Nested @Nested
class AddSepaMandate { class PostNewSepaMandate {
@Test @Test
void globalAdmin_canAddSepaMandate() { void globalAdmin_canPostNewSepaMandate() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0);
@ -177,7 +177,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
// TODO.test: move validation tests to a ...WebMvcTest // TODO.test: move validation tests to a ...WebMvcTest
@Test @Test
void globalAdmin_canNotAddSepaMandateWhenDebitorUuidIsMissing() { void globalAdmin_canNotPostNewSepaMandateWhenDebitorUuidIsMissing() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0);
@ -202,7 +202,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
void globalAdmin_canNotAddSepaMandate_ifBankAccountDoesNotExist() { void globalAdmin_canNotPostNewSepaMandate_ifBankAccountDoesNotExist() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0);
@ -232,7 +232,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl
} }
@Test @Test
void globalAdmin_canNotAddSepaMandate_ifPersonDoesNotExist() { void globalAdmin_canNotPostNewSepaMandate_ifPersonDoesNotExist() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenDebitorUuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); final var givenDebitorUuid = UUID.fromString("00000000-0000-0000-0000-000000000000");

View File

@ -161,7 +161,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
} }
@Nested @Nested
class GetGrantById { class GetListOfGrantsByUuid {
@Test @Test
void customerAdmin_withAssumedPacketAdminRole_canReadPacketAdminsGrantById() { void customerAdmin_withAssumedPacketAdminRole_canReadPacketAdminsGrantById() {
@ -171,7 +171,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
// when // when
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
// then // then
@ -190,7 +190,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
// when // when
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
// then // then
@ -211,7 +211,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
// when // when
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
// then // then
@ -231,7 +231,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
"rbactest.package#xxx00:TENANT"); "rbactest.package#xxx00:TENANT");
final var givenGranteeUser = findRbacSubjectByName("pac-admin-xxx00@xxx.example.com"); final var givenGranteeUser = findRbacSubjectByName("pac-admin-xxx00@xxx.example.com");
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
// then // then
@ -360,8 +360,8 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
return new RevokeFixture(givenOwnPackageAdminRole); return new RevokeFixture(givenOwnPackageAdminRole);
} }
GetGrantByIdFixture getGrantById() { GetListOfGrantsByUuidFixture getListOfGrantsByUuid() {
return new GetGrantByIdFixture(); return new GetListOfGrantsByUuidFixture();
} }
class GrantFixture { class GrantFixture {
@ -443,12 +443,12 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
} }
} }
private class GetGrantByIdFixture { private class GetListOfGrantsByUuidFixture {
private Subject currentSubject = Subject.this; private Subject currentSubject = Subject.this;
private RbacRoleEntity grantedRole; private RbacRoleEntity grantedRole;
GetGrantByIdFixture forGrantedRole(final RbacRoleEntity grantedRole) { GetListOfGrantsByUuidFixture forGrantedRole(final RbacRoleEntity grantedRole) {
this.grantedRole = grantedRole; this.grantedRole = grantedRole;
return this; return this;
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.role; package net.hostsharing.hsadminng.rbac.role;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -7,5 +8,6 @@ import java.util.UUID;
public interface RawRbacObjectRepository extends Repository<RawRbacObjectEntity, UUID> { public interface RawRbacObjectRepository extends Repository<RawRbacObjectEntity, UUID> {
@Timed("app.rbac.objects.repo.findAll.real")
List<RawRbacObjectEntity> findAll(); List<RawRbacObjectEntity> findAll();
} }

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.role; package net.hostsharing.hsadminng.rbac.role;
import io.micrometer.core.annotation.Timed;
import org.springframework.data.repository.Repository; import org.springframework.data.repository.Repository;
import java.util.List; import java.util.List;
@ -7,5 +8,6 @@ import java.util.UUID;
public interface RawRbacRoleRepository extends Repository<RawRbacRoleEntity, UUID> { public interface RawRbacRoleRepository extends Repository<RawRbacRoleEntity, UUID> {
@Timed("app.rbac.roles.repo.findAll.real")
List<RawRbacRoleEntity> findAll(); List<RawRbacRoleEntity> findAll();
} }

View File

@ -45,7 +45,7 @@ class RbacSubjectControllerRestTest {
@Test @Test
void createSubjectUsesGivenUuid() throws Exception { void postNewSubjectUsesGivenUuid() throws Exception {
// given // given
final var givenUuid = UUID.randomUUID(); final var givenUuid = UUID.randomUUID();
@ -69,7 +69,7 @@ class RbacSubjectControllerRestTest {
} }
@Test @Test
void createSubjectGeneratesRandomUuidIfNotGiven() throws Exception { void postNewSubjectGeneratesRandomUuidIfNotGiven() throws Exception {
// when // when
mockMvc.perform(MockMvcRequestBuilders mockMvc.perform(MockMvcRequestBuilders
.post("/api/rbac/subjects") .post("/api/rbac/subjects")

View File

@ -41,7 +41,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest {
HttpServletRequest request; HttpServletRequest request;
@Nested @Nested
class CreateSubject { class PostNewSubject {
@Test @Test
@Transactional(propagation = Propagation.NEVER) @Transactional(propagation = Propagation.NEVER)
@ -178,7 +178,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest {
} }
@Nested @Nested
class ListSubjectPermissions { class GetListOfSubjectPermissions {
private static final String[] ALL_USER_PERMISSIONS = Array.of( private static final String[] ALL_USER_PERMISSIONS = Array.of(
// @formatter:off // @formatter:off