split PersonEntity/Repo into Rbac and Real Entity/Repo and use in Relation for faster lazy loading #130
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.debitor;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -8,7 +9,9 @@ import java.util.UUID;
|
||||
|
||||
public interface HsBookingDebitorRepository extends Repository<HsBookingDebitorEntity, UUID> {
|
||||
|
||||
@Timed("app.bookingDebitor.repo.findByUuid")
|
||||
Optional<HsBookingDebitorEntity> findByUuid(UUID id);
|
||||
|
||||
@Timed("app.bookingDebitor.repo.findByDebitorNumber")
|
||||
List<HsBookingDebitorEntity> findByDebitorNumber(int debitorNumber);
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.item;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface BookingItemCreatedEventRepository extends Repository<BookingItemCreatedEventEntity, UUID> {
|
||||
|
||||
@Timed("app.booking.items.repo.save")
|
||||
BookingItemCreatedEventEntity save(HsBookingItemRealEntity current);
|
||||
|
||||
@Timed("app.booking.items.repo.findByBookingItem")
|
||||
BookingItemCreatedEventEntity findByBookingItem(HsBookingItemRealEntity newBookingItem);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.booking.item;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
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.model.HsBookingItemInsertResource;
|
||||
@ -51,7 +52,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<HsBookingItemResource>> listBookingItemsByProjectUuid(
|
||||
@Timed("app.bookingItems.api.getListOfBookingItemsByProjectUuid")
|
||||
public ResponseEntity<List<HsBookingItemResource>> getListOfBookingItemsByProjectUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID projectUuid) {
|
||||
@ -65,7 +67,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsBookingItemResource> addBookingItem(
|
||||
@Timed("app.bookingItems.api.postNewBookingItem")
|
||||
public ResponseEntity<HsBookingItemResource> postNewBookingItem(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final HsBookingItemInsertResource body) {
|
||||
@ -94,7 +97,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<HsBookingItemResource> getBookingItemByUuid(
|
||||
@Timed("app.bookingItems.api.getSingleBookingItemByUuid")
|
||||
public ResponseEntity<HsBookingItemResource> getSingleBookingItemByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID bookingItemUuid) {
|
||||
@ -111,6 +115,7 @@ public class HsBookingItemController implements HsBookingItemsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.bookingItems.api.deleteBookingIemByUuid")
|
||||
public ResponseEntity<Void> deleteBookingIemByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -125,6 +130,7 @@ public class HsBookingItemController implements HsBookingItemsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.bookingItems.api.patchBookingItem")
|
||||
public ResponseEntity<HsBookingItemResource> patchBookingItem(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.item;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,15 +10,21 @@ import java.util.UUID;
|
||||
public interface HsBookingItemRbacRepository extends HsBookingItemRepository<HsBookingItemRbacEntity>,
|
||||
Repository<HsBookingItemRbacEntity, UUID> {
|
||||
|
||||
@Timed("app.bookingItems.repo.findByUuid.rbac")
|
||||
Optional<HsBookingItemRbacEntity> findByUuid(final UUID bookingItemUuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.findByCaption.rbac")
|
||||
List<HsBookingItemRbacEntity> findByCaption(String bookingItemCaption);
|
||||
|
||||
@Timed("app.bookingItems.repo.findAllByProjectUuid.rbac")
|
||||
List<HsBookingItemRbacEntity> findAllByProjectUuid(final UUID projectItemUuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.save.rbac")
|
||||
HsBookingItemRbacEntity save(HsBookingItemRbacEntity current);
|
||||
|
||||
@Timed("app.bookingItems.repo.deleteByUuid.rbac")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.count.rbac")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.item;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,15 +10,21 @@ import java.util.UUID;
|
||||
public interface HsBookingItemRealRepository extends HsBookingItemRepository<HsBookingItemRealEntity>,
|
||||
Repository<HsBookingItemRealEntity, UUID> {
|
||||
|
||||
@Timed("app.bookingItems.repo.findByUuid.real")
|
||||
Optional<HsBookingItemRealEntity> findByUuid(final UUID bookingItemUuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.findByCaption.real")
|
||||
List<HsBookingItemRealEntity> findByCaption(String bookingItemCaption);
|
||||
|
||||
@Timed("app.bookingItems.repo.findAllByProjectUuid.real")
|
||||
List<HsBookingItemRealEntity> findAllByProjectUuid(final UUID projectItemUuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.save.real")
|
||||
HsBookingItemRealEntity save(HsBookingItemRealEntity current);
|
||||
|
||||
@Timed("app.bookingItems.repo.deleteByUuid.real")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.bookingItems.repo.count.real")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.item;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.project;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorRepository;
|
||||
import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingProjectsApi;
|
||||
@ -35,7 +36,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<HsBookingProjectResource>> listBookingProjectsByDebitorUuid(
|
||||
@Timed("app.bookingProjects.api.getListOfBookingProjectsByDebitorUuid")
|
||||
public ResponseEntity<List<HsBookingProjectResource>> getListOfBookingProjectsByDebitorUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID debitorUuid) {
|
||||
@ -49,7 +51,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsBookingProjectResource> addBookingProject(
|
||||
@Timed("app.bookingProjects.api.postNewBookingProject")
|
||||
public ResponseEntity<HsBookingProjectResource> postNewBookingProject(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final HsBookingProjectInsertResource body) {
|
||||
@ -71,6 +74,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
@Timed("app.bookingProjects.api.getBookingProjectByUuid")
|
||||
public ResponseEntity<HsBookingProjectResource> getBookingProjectByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -87,6 +91,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.bookingProjects.api.deleteBookingIemByUuid")
|
||||
public ResponseEntity<Void> deleteBookingIemByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -101,6 +106,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.bookingProjects.api.patchBookingProject")
|
||||
public ResponseEntity<HsBookingProjectResource> patchBookingProject(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.project;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,14 +10,21 @@ import java.util.UUID;
|
||||
public interface HsBookingProjectRbacRepository extends HsBookingProjectRepository<HsBookingProjectRbacEntity>,
|
||||
Repository<HsBookingProjectRbacEntity, UUID> {
|
||||
|
||||
@Timed("app.bookingProjects.repo.findByUuid.rbac")
|
||||
Optional<HsBookingProjectRbacEntity> findByUuid(final UUID bookingProjectUuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.findByCaption.rbac")
|
||||
List<HsBookingProjectRbacEntity> findByCaption(final String projectCaption);
|
||||
|
||||
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.rbac")
|
||||
List<HsBookingProjectRbacEntity> findAllByDebitorUuid(final UUID bookingProjectUuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.save.rbac")
|
||||
HsBookingProjectRbacEntity save(HsBookingProjectRbacEntity current);
|
||||
|
||||
@Timed("app.bookingProjects.repo.deleteByUuid.rbac")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.count.rbac")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.project;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -9,14 +10,21 @@ import java.util.UUID;
|
||||
public interface HsBookingProjectRealRepository extends HsBookingProjectRepository<HsBookingProjectRealEntity>,
|
||||
Repository<HsBookingProjectRealEntity, UUID> {
|
||||
|
||||
@Timed("app.bookingProjects.repo.findByUuid.real")
|
||||
Optional<HsBookingProjectRealEntity> findByUuid(final UUID bookingProjectUuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.findByCaption.real")
|
||||
List<HsBookingProjectRealEntity> findByCaption(final String projectCaption);
|
||||
|
||||
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.real")
|
||||
List<HsBookingProjectRealEntity> findAllByDebitorUuid(final UUID bookingProjectUuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.save.real")
|
||||
HsBookingProjectRealEntity save(HsBookingProjectRealEntity current);
|
||||
|
||||
@Timed("app.bookingProjects.repo.deleteByUuid.real")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.bookingProjects.repo.count.real")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,19 +1,28 @@
|
||||
package net.hostsharing.hsadminng.hs.booking.project;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
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);
|
||||
|
||||
@Timed("app.booking.projects.repo.findAllByDebitorUuid")
|
||||
List<E> findAllByDebitorUuid(final UUID bookingProjectUuid);
|
||||
|
||||
@Timed("app.booking.projects.repo.save")
|
||||
E save(E current);
|
||||
|
||||
@Timed("app.booking.projects.repo.deleteByUuid")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.booking.projects.repo.count")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.hosting.asset.validators.HostingAssetEntitySaveProcessor;
|
||||
import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry;
|
||||
@ -48,7 +49,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<HsHostingAssetResource>> listAssets(
|
||||
@Timed("app.hosting.assets.api.getListOfHostingAssets")
|
||||
public ResponseEntity<List<HsHostingAssetResource>> getListOfHostingAssets(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID debitorUuid,
|
||||
@ -65,7 +67,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsHostingAssetResource> addAsset(
|
||||
@Timed("app.hosting.assets.api.postNewHostingAsset")
|
||||
public ResponseEntity<HsHostingAssetResource> postNewHostingAsset(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final HsHostingAssetInsertResource body) {
|
||||
@ -93,7 +96,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<HsHostingAssetResource> getAssetByUuid(
|
||||
@Timed("app.hosting.assets.api.getSingleHostingAssetByUuid")
|
||||
public ResponseEntity<HsHostingAssetResource> getSingleHostingAssetByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID assetUuid) {
|
||||
@ -109,7 +113,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<Void> deleteAssetUuid(
|
||||
@Timed("app.hosting.assets.api.deleteHostingAssetByUuid")
|
||||
public ResponseEntity<Void> deleteHostingAssetByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID assetUuid) {
|
||||
@ -123,7 +128,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsHostingAssetResource> patchAsset(
|
||||
@Timed("app.hosting.assets.api.patchHostingAsset")
|
||||
public ResponseEntity<HsHostingAssetResource> patchHostingAsset(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID assetUuid,
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.generated.api.v1.api.HsHostingAssetPropsApi;
|
||||
import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsHostingAssetTypeResource;
|
||||
@ -14,7 +15,8 @@ import java.util.Map;
|
||||
public class HsHostingAssetPropsController implements HsHostingAssetPropsApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<String>> listAssetTypes() {
|
||||
@Timed("app.hosting.assets.api.getListOfHostingAssetTypes")
|
||||
public ResponseEntity<List<String>> getListOfHostingAssetTypes() {
|
||||
final var resource = HostingAssetEntityValidatorRegistry.types().stream()
|
||||
.map(Enum::name)
|
||||
.toList();
|
||||
@ -22,7 +24,8 @@ public class HsHostingAssetPropsController implements HsHostingAssetPropsApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<List<Object>> listAssetTypeProps(
|
||||
@Timed("app.hosting.assets.api.getListOfHostingAssetTypeProps")
|
||||
public ResponseEntity<List<Object>> getListOfHostingAssetTypeProps(
|
||||
final HsHostingAssetTypeResource assetType) {
|
||||
|
||||
final Enum<HsHostingAssetType> type = HsHostingAssetType.of(assetType);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.hosting.asset;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
@ -10,8 +11,10 @@ import java.util.UUID;
|
||||
|
||||
public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<HsHostingAssetRbacEntity>, Repository<HsHostingAssetRbacEntity, UUID> {
|
||||
|
||||
@Timed("app.hostingAsset.repo.findByUuid.rbac")
|
||||
Optional<HsHostingAssetRbacEntity> findByUuid(final UUID serverUuid);
|
||||
|
||||
@Timed("app.hostingAsset.repo.findByIdentifier.rbac")
|
||||
List<HsHostingAssetRbacEntity> findByIdentifier(String assetIdentifier);
|
||||
|
||||
@Query(value = """
|
||||
@ -32,16 +35,21 @@ public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<H
|
||||
and (:parentAssetUuid is null or pha.uuid=:parentAssetUuid)
|
||||
and (:type is null or :type=cast(ha.type as text))
|
||||
""", nativeQuery = true)
|
||||
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.rbac")
|
||||
// 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.
|
||||
List<HsHostingAssetRbacEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
|
||||
|
||||
default List<HsHostingAssetRbacEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
|
||||
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
|
||||
}
|
||||
|
||||
@Timed("app.hostingAsset.repo.save.rbac")
|
||||
HsHostingAssetRbacEntity save(HsHostingAsset current);
|
||||
|
||||
@Timed("app.hostingAsset.repo.deleteByUuid.rbac")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.hostingAsset.repo.count.rbac")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.hs.hosting.asset;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
@ -10,8 +11,10 @@ import java.util.UUID;
|
||||
|
||||
public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<HsHostingAssetRealEntity>, Repository<HsHostingAssetRealEntity, UUID> {
|
||||
|
||||
@Timed("app.hostingAsset.repo.findByUuid.real")
|
||||
Optional<HsHostingAssetRealEntity> findByUuid(final UUID serverUuid);
|
||||
|
||||
@Timed("app.hostingAsset.repo.findByIdentifier.real")
|
||||
List<HsHostingAssetRealEntity> findByIdentifier(String assetIdentifier);
|
||||
|
||||
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
|
||||
and ha.identifier = :identifier
|
||||
""")
|
||||
@Timed("app.hostingAsset.repo.findByTypeAndIdentifierImpl.real")
|
||||
List<HsHostingAssetRealEntity> findByTypeAndIdentifierImpl(@NotNull String type, @NotNull String identifier);
|
||||
|
||||
@Query(value = """
|
||||
@ -46,14 +50,19 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<H
|
||||
""", nativeQuery = true)
|
||||
// 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.
|
||||
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.real")
|
||||
List<HsHostingAssetRealEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
|
||||
|
||||
default List<HsHostingAssetRealEntity> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
|
||||
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
|
||||
}
|
||||
|
||||
@Timed("app.hostingAsset.repo.save.real")
|
||||
HsHostingAssetRealEntity save(HsHostingAssetRealEntity current);
|
||||
|
||||
@Timed("app.hostingAsset.repo.deleteByUuid.real")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.hostingAsset.repo.count.real")
|
||||
long count();
|
||||
}
|
||||
|
@ -1,24 +1,32 @@
|
||||
package net.hostsharing.hsadminng.hs.hosting.asset;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface HsHostingAssetRepository<E extends HsHostingAsset> {
|
||||
|
||||
@Timed("app.hosting.assets.repo.findByUuid")
|
||||
Optional<E> findByUuid(final UUID serverUuid);
|
||||
|
||||
@Timed("app.hosting.assets.repo.findByIdentifier")
|
||||
List<E> findByIdentifier(String assetIdentifier);
|
||||
|
||||
@Timed("app.hosting.assets.repo.findAllByCriteriaImpl")
|
||||
List<E> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
|
||||
|
||||
default List<E> findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) {
|
||||
return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type));
|
||||
}
|
||||
|
||||
@Timed("app.hosting.assets.repo.save")
|
||||
E save(HsHostingAsset current);
|
||||
|
||||
@Timed("app.hosting.assets.repo.deleteByUuid")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.hosting.assets.repo.count")
|
||||
long count();
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public interface HsOfficeBankAccountRepository extends Repository<HsOfficeBankAc
|
||||
""")
|
||||
@Timed("app.bankAccounts.repo.findByOptionalHolderLikeImpl")
|
||||
List<HsOfficeBankAccountEntity> findByOptionalHolderLikeImpl(String holder);
|
||||
|
||||
default List<HsOfficeBankAccountEntity> findByOptionalHolderLike(String holder) {
|
||||
return findByOptionalHolderLikeImpl(holder == null ? "" : holder);
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
||||
WHERE partner.partnerNumber = :partnerNumber
|
||||
AND debitor.debitorNumberSuffix = :debitorNumberSuffix
|
||||
""")
|
||||
@Timed("app.debitors.repo.findDebitorByDebitorNumber")
|
||||
List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix);
|
||||
@Timed("app.debitors.repo.findDebitorByPartnerNumberAndDebitorNumberSuffix")
|
||||
List<HsOfficeDebitorEntity> findDebitorByPartnerNumberAndDebitorNumberSuffix(int partnerNumber, String debitorNumberSuffix);
|
||||
|
||||
default List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int debitorNumber) {
|
||||
final var partnerNumber = debitorNumber / 100;
|
||||
final String suffix = String.format("%02d", debitorNumber % 100);
|
||||
final var result = findDebitorByDebitorNumber(partnerNumber, suffix);
|
||||
final var result = findDebitorByPartnerNumberAndDebitorNumberSuffix(partnerNumber, suffix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
@Timed("app.membership.api.getListOfMemberships")
|
||||
@Timed("app.office.membership.api.getListOfMemberships")
|
||||
public ResponseEntity<List<HsOfficeMembershipResource>> getListOfMemberships(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -55,7 +55,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.membership.api.postNewMembership")
|
||||
@Timed("app.office.membership.api.postNewMembership")
|
||||
public ResponseEntity<HsOfficeMembershipResource> postNewMembership(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -79,7 +79,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
@Timed("app.membership.api.getSingleMembershipByUuid")
|
||||
@Timed("app.office.membership.api.getSingleMembershipByUuid")
|
||||
public ResponseEntity<HsOfficeMembershipResource> getSingleMembershipByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -97,7 +97,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.membership.api.deleteMembershipByUuid")
|
||||
@Timed("app.office.membership.api.deleteMembershipByUuid")
|
||||
public ResponseEntity<Void> deleteMembershipByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -114,7 +114,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.membership.api.patchMembership")
|
||||
@Timed("app.office.membership.api.patchMembership")
|
||||
public ResponseEntity<HsOfficeMembershipResource> patchMembership(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -11,13 +11,13 @@ import java.util.UUID;
|
||||
|
||||
public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembershipEntity, UUID> {
|
||||
|
||||
@Timed("app.membership.repo.findByUuid")
|
||||
@Timed("app.office.membership.repo.findByUuid")
|
||||
Optional<HsOfficeMembershipEntity> findByUuid(UUID id);
|
||||
|
||||
@Timed("app.membership.repo.save")
|
||||
@Timed("app.office.membership.repo.save")
|
||||
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
|
||||
|
||||
@Timed("app.membership.repo.findAll")
|
||||
@Timed("app.office.membership.repo.findAll")
|
||||
List<HsOfficeMembershipEntity> findAll();
|
||||
|
||||
@Query("""
|
||||
@ -26,7 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
||||
OR membership.partner.uuid = :partnerUuid )
|
||||
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
|
||||
""")
|
||||
@Timed("app.membership.repo.findMembershipsByOptionalPartnerUuid")
|
||||
@Timed("app.office.membership.repo.findMembershipsByOptionalPartnerUuid")
|
||||
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
|
||||
|
||||
@Query("""
|
||||
@ -35,7 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
||||
AND (membership.memberNumberSuffix = :suffix)
|
||||
ORDER BY membership.memberNumberSuffix
|
||||
""")
|
||||
@Timed("app.membership.repo.findMembershipByPartnerNumberAndSuffix")
|
||||
@Timed("app.office.membership.repo.findMembershipByPartnerNumberAndSuffix")
|
||||
HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix(
|
||||
@NotNull Integer partnerNumber,
|
||||
@NotNull String suffix);
|
||||
@ -47,9 +47,9 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
|
||||
return result;
|
||||
}
|
||||
|
||||
@Timed("app.membership.repo.count")
|
||||
@Timed("app.office.membership.repo.count")
|
||||
long count();
|
||||
|
||||
@Timed("app.membership.repo.deleteByUuid")
|
||||
@Timed("app.office.membership.repo.deleteByUuid")
|
||||
int deleteByUuid(UUID uuid);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.grant;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -7,9 +8,12 @@ import java.util.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);
|
||||
|
||||
@Timed("app.rbac.grants.repo.findByDescendantUuid")
|
||||
List<RawRbacGrantEntity> findByDescendantUuid(UUID refUuid);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.grant;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacGrantsApi;
|
||||
@ -32,7 +33,8 @@ public class RbacGrantController implements RbacGrantsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<RbacGrantResource> getGrantById(
|
||||
@Timed("app.rbac.grants.api.getListOfGrantsByUuid")
|
||||
public ResponseEntity<RbacGrantResource> getListOfGrantsByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID grantedRoleUuid,
|
||||
@ -50,7 +52,8 @@ public class RbacGrantController implements RbacGrantsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<RbacGrantResource>> listSubjectGrants(
|
||||
@Timed("app.rbac.grants.api.getListOfSubjectGrants")
|
||||
public ResponseEntity<List<RbacGrantResource>> getListOfSubjectGrants(
|
||||
final String currentSubject,
|
||||
final String assumedRoles) {
|
||||
|
||||
@ -61,7 +64,8 @@ public class RbacGrantController implements RbacGrantsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<RbacGrantResource> grantRoleToSubject(
|
||||
@Timed("app.rbac.grants.api.postNewRoleGrantToSubject")
|
||||
public ResponseEntity<RbacGrantResource> postNewRoleGrantToSubject(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final RbacGrantResource body) {
|
||||
@ -82,7 +86,8 @@ public class RbacGrantController implements RbacGrantsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<Void> revokeRoleFromSubject(
|
||||
@Timed("app.rbac.grants.api.deleteRoleGrantFromSubject")
|
||||
public ResponseEntity<Void> deleteRoleGrantFromSubject(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID grantedRoleUuid,
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.Query;
|
||||
import org.springframework.data.repository.Repository;
|
||||
@ -13,12 +14,16 @@ public interface RbacGrantRepository extends Repository<RbacGrantEntity, RbacGra
|
||||
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
|
||||
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
|
||||
""")
|
||||
@Timed("app.rbac.grants.repo.findById")
|
||||
RbacGrantEntity findById(RbacGrantId rbacGrantId);
|
||||
|
||||
@Timed("app.rbac.grants.repo.count")
|
||||
long count();
|
||||
|
||||
@Timed("app.rbac.grants.repo.findAll")
|
||||
List<RbacGrantEntity> findAll();
|
||||
|
||||
@Timed("app.rbac.grants.repo.save")
|
||||
RbacGrantEntity save(final RbacGrantEntity grant);
|
||||
|
||||
@Modifying
|
||||
@ -27,5 +32,6 @@ public interface RbacGrantRepository extends Repository<RbacGrantEntity, RbacGra
|
||||
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
|
||||
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
|
||||
""")
|
||||
@Timed("app.rbac.grants.repo.deleteByRbacGrantId")
|
||||
void deleteByRbacGrantId(RbacGrantId rbacGrantId);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.role;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacRolesApi;
|
||||
@ -25,7 +26,8 @@ public class RbacRoleController implements RbacRolesApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<RbacRoleResource>> listRoles(
|
||||
@Timed("app.rbac.roles.api.getListOfRoles")
|
||||
public ResponseEntity<List<RbacRoleResource>> getListOfRoles(
|
||||
final String currentSubject,
|
||||
final String assumedRoles) {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.role;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
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.
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.subject;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import net.hostsharing.hsadminng.mapper.StandardMapper;
|
||||
import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacSubjectsApi;
|
||||
@ -28,7 +29,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<RbacSubjectResource> createSubject(
|
||||
@Timed("app.rbac.subjects.api.postNewSubject")
|
||||
public ResponseEntity<RbacSubjectResource> postNewSubject(
|
||||
final RbacSubjectResource body
|
||||
) {
|
||||
context.define(null);
|
||||
@ -48,6 +50,7 @@ public class RbacSubjectController implements RbacSubjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Timed("app.rbac.subjects.api.deleteSubjectByUuid")
|
||||
public ResponseEntity<Void> deleteSubjectByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
@ -62,7 +65,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<RbacSubjectResource> getSubjectById(
|
||||
@Timed("app.rbac.subjects.api.getSingleSubjectByUuid")
|
||||
public ResponseEntity<RbacSubjectResource> getSingleSubjectByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID subjectUuid) {
|
||||
@ -78,7 +82,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<RbacSubjectResource>> listSubjects(
|
||||
@Timed("app.rbac.subjects.api.getListOfSubjects")
|
||||
public ResponseEntity<List<RbacSubjectResource>> getListOfSubjects(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final String userName
|
||||
@ -90,7 +95,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<List<RbacSubjectPermissionResource>> listSubjectPermissions(
|
||||
@Timed("app.rbac.subjects.api.getListOfSubjectPermissions")
|
||||
public ResponseEntity<List<RbacSubjectPermissionResource>> getListOfSubjectPermissions(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final UUID subjectUuid
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.Query;
|
||||
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), '%')
|
||||
order by u.name
|
||||
""")
|
||||
@Timed("app.rbac.subjects.repo.findByOptionalNameLike")
|
||||
List<RbacSubjectEntity> findByOptionalNameLike(String userName);
|
||||
|
||||
// bypasses the restricted view, to be able to grant rights to arbitrary user
|
||||
@Query(value = "select * from rbac.subject where name=:userName", nativeQuery = true)
|
||||
@Timed("app.rbac.subjects.repo.findByName")
|
||||
RbacSubjectEntity findByName(String userName);
|
||||
|
||||
@Timed("app.rbac.subjects.repo.findByUuid")
|
||||
RbacSubjectEntity findByUuid(UUID uuid);
|
||||
|
||||
@Query(value = "select * from rbac.grantedPermissions(:subjectUuid)", nativeQuery = true)
|
||||
@Timed("app.rbac.subjects.repo.findPermissionsOfUserByUuid")
|
||||
List<RbacSubjectPermission> findPermissionsOfUserByUuid(UUID subjectUuid);
|
||||
|
||||
/*
|
||||
@ -32,6 +37,7 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
|
||||
*/
|
||||
@Modifying
|
||||
@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);
|
||||
|
||||
default RbacSubjectEntity create(final RbacSubjectEntity rbacSubjectEntity) {
|
||||
@ -42,5 +48,6 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
|
||||
return rbacSubjectEntity;
|
||||
}
|
||||
|
||||
@Timed("app.rbac.subjects.repo.deleteByUuid")
|
||||
void deleteByUuid(UUID subjectUuid);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ get:
|
||||
tags:
|
||||
- hs-booking-items
|
||||
description: 'Fetch a single booking item its uuid, if visible for the current subject.'
|
||||
operationId: getBookingItemByUuid
|
||||
operationId: getSingleBookingItemByUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -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.
|
||||
tags:
|
||||
- hs-booking-items
|
||||
operationId: listBookingItemsByProjectUuid
|
||||
operationId: getListOfBookingItemsByProjectUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -32,7 +32,7 @@ post:
|
||||
summary: Adds a new booking item.
|
||||
tags:
|
||||
- hs-booking-items
|
||||
operationId: addBookingItem
|
||||
operationId: postNewBookingItem
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -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.
|
||||
tags:
|
||||
- hs-booking-projects
|
||||
operationId: listBookingProjectsByDebitorUuid
|
||||
operationId: getListOfBookingProjectsByDebitorUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -32,7 +32,7 @@ post:
|
||||
summary: Adds a new project as a container for booking items.
|
||||
tags:
|
||||
- hs-booking-projects
|
||||
operationId: addBookingProject
|
||||
operationId: postNewBookingProject
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -3,7 +3,7 @@ get:
|
||||
description: Returns the list of available properties and their validations for a given asset type.
|
||||
tags:
|
||||
- hs-hosting-asset-props
|
||||
operationId: listAssetTypeProps
|
||||
operationId: getListOfHostingAssetTypeProps
|
||||
parameters:
|
||||
- name: assetType
|
||||
in: path
|
||||
|
@ -3,7 +3,7 @@ get:
|
||||
description: Returns the list of asset types to enable an adaptive UI.
|
||||
tags:
|
||||
- hs-hosting-asset-props
|
||||
operationId: listAssetTypes
|
||||
operationId: getListOfHostingAssetTypes
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
|
@ -2,7 +2,7 @@ get:
|
||||
tags:
|
||||
- hs-hosting-assets
|
||||
description: 'Fetch a single managed asset by its uuid, if visible for the current subject.'
|
||||
operationId: getAssetByUuid
|
||||
operationId: getSingleHostingAssetByUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -30,7 +30,7 @@ patch:
|
||||
tags:
|
||||
- hs-hosting-assets
|
||||
description: 'Updates a single hosting asset identified by its uuid, if permitted for the current subject.'
|
||||
operationId: patchAsset
|
||||
operationId: patchHostingAsset
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -61,7 +61,7 @@ delete:
|
||||
tags:
|
||||
- hs-hosting-assets
|
||||
description: 'Delete a single hosting asset identified by its uuid, if permitted for the current subject.'
|
||||
operationId: deleteAssetUuid
|
||||
operationId: deleteHostingAssetByUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -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.
|
||||
tags:
|
||||
- hs-hosting-assets
|
||||
operationId: listAssets
|
||||
operationId: getListOfHostingAssets
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -45,7 +45,7 @@ post:
|
||||
summary: Adds a new hosting asset.
|
||||
tags:
|
||||
- hs-hosting-assets
|
||||
operationId: addAsset
|
||||
operationId: postNewHostingAsset
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -1,7 +1,7 @@
|
||||
get:
|
||||
tags:
|
||||
- rbac-grants
|
||||
operationId: getGrantById
|
||||
operationId: getListOfGrantsByUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -36,7 +36,7 @@ get:
|
||||
delete:
|
||||
tags:
|
||||
- rbac-grants
|
||||
operationId: revokeRoleFromSubject
|
||||
operationId: deleteRoleGrantFromSubject
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -1,7 +1,7 @@
|
||||
get:
|
||||
tags:
|
||||
- rbac-grants
|
||||
operationId: listSubjectGrants
|
||||
operationId: getListOfSubjectGrants
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -18,7 +18,7 @@ get:
|
||||
post:
|
||||
tags:
|
||||
- rbac-grants
|
||||
operationId: grantRoleToSubject
|
||||
operationId: postNewRoleGrantToSubject
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -1,7 +1,7 @@
|
||||
get:
|
||||
tags:
|
||||
- rbac-roles
|
||||
operationId: listRoles
|
||||
operationId: getListOfRoles
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -2,7 +2,7 @@ get:
|
||||
tags:
|
||||
- rbac-subjects
|
||||
description: 'List all visible permissions granted to the given subject; reduced '
|
||||
operationId: listSubjectPermissions
|
||||
operationId: getListOfSubjectPermissions
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -2,7 +2,7 @@ get:
|
||||
tags:
|
||||
- rbac-subjects
|
||||
description: 'Fetch a single subject by its id, if visible for the current subject.'
|
||||
operationId: getSubjectById
|
||||
operationId: getSingleSubjectByUuid
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
|
@ -2,7 +2,7 @@ get:
|
||||
tags:
|
||||
- rbac-subjects
|
||||
description: List accessible RBAC subjects with optional filter by name.
|
||||
operationId: listSubjects
|
||||
operationId: getListOfSubjects
|
||||
parameters:
|
||||
- $ref: 'auth.yaml#/components/parameters/currentSubject'
|
||||
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
|
||||
@ -29,7 +29,7 @@ post:
|
||||
tags:
|
||||
- rbac-subjects
|
||||
description: Create a new RBAC subject (e.g. user).
|
||||
operationId: createSubject
|
||||
operationId: postNewSubject
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
|
@ -10,6 +10,7 @@ import com.tngtech.archunit.lang.ArchCondition;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
import com.tngtech.archunit.lang.ConditionEvents;
|
||||
import com.tngtech.archunit.lang.SimpleConditionEvent;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItem;
|
||||
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetRbacEntity;
|
||||
@ -20,7 +21,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
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.library.dependencies.SlicesRuleDefinition.slices;
|
||||
import static java.lang.String.format;
|
||||
@ -98,7 +101,7 @@ public class ArchitectureTest {
|
||||
@SuppressWarnings("unused")
|
||||
public static final ArchRule testClassesAreProperlyNamed = classes()
|
||||
.that().haveSimpleNameEndingWith("Test")
|
||||
.and().doNotHaveModifier(ABSTRACT)
|
||||
.and().doNotHaveModifier(JavaModifier.ABSTRACT)
|
||||
.should().haveNameMatching(".*(UnitTest|RestTest|IntegrationTest|AcceptanceTest|ScenarioTest|ArchitectureTest)$");
|
||||
|
||||
@ArchTest
|
||||
@ -346,11 +349,25 @@ public class ArchitectureTest {
|
||||
static final ArchRule restControllerNaming =
|
||||
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
|
||||
@SuppressWarnings("unused")
|
||||
static final ArchRule repositoryNaming =
|
||||
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
|
||||
@SuppressWarnings("unused")
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -139,10 +139,10 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
@Nested
|
||||
@Order(3)
|
||||
class AddBookingItem {
|
||||
class PostNewBookingItem {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canAddBookingItem() {
|
||||
void globalAdmin_canPostNewBookingItem() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenProject = findDefaultProjectOfDebitorNumber(1000111);
|
||||
@ -349,7 +349,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectAgent_canAddBookingItemEvenIfHostingAssetCreationFails() {
|
||||
void projectAgent_canPostNewBookingItemEvenIfHostingAssetCreationFails() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net", "hs_booking.project#D-1000111-D-1000111defaultproject:AGENT");
|
||||
final var givenProject = findDefaultProjectOfDebitorNumber(1000111);
|
||||
|
@ -84,7 +84,7 @@ class HsBookingItemControllerRestTest {
|
||||
}
|
||||
|
||||
@Nested
|
||||
class AddBookingItem {
|
||||
class PostNewBookingItem {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canAddValidBookingItem() throws Exception {
|
||||
|
@ -79,10 +79,10 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
}
|
||||
|
||||
@Nested
|
||||
class AddBookingProject {
|
||||
class PostNewBookingProject {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canAddBookingProject() {
|
||||
void globalAdmin_canPostNewBookingProject() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||
|
@ -76,7 +76,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
@Nested
|
||||
@Order(2)
|
||||
class ListAssets {
|
||||
class GetListOfHostingAssets {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canViewAllAssetsOfArbitraryDebitor() {
|
||||
@ -146,7 +146,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
@Nested
|
||||
@Order(3)
|
||||
class AddAsset {
|
||||
class PostNewHostingAsset {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canAddBookedAsset() {
|
||||
@ -481,7 +481,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
||||
|
||||
@Nested
|
||||
@Order(4)
|
||||
class PatchAsset {
|
||||
class PatchHostingAsset {
|
||||
|
||||
@Test
|
||||
void globalAdmin_canPatchAllUpdatablePropertiesOfAsset() {
|
||||
|
@ -583,7 +583,7 @@ public class HsHostingAssetControllerRestTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(HsHostingAssetControllerRestTest.ListTestCases.class)
|
||||
void shouldListAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception {
|
||||
void shouldGetListOfHostingAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception {
|
||||
// given
|
||||
when(rbacAssetRepo.findAllByCriteria(null, null, testCase.assetType))
|
||||
.thenReturn(testCase.givenHostingAssetsOfType);
|
||||
@ -607,7 +607,7 @@ public class HsHostingAssetControllerRestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPatchAsset() throws Exception {
|
||||
void shouldPatchHostingAsset() throws Exception {
|
||||
// given
|
||||
final var givenDomainSetup = HsHostingAssetRealEntity.builder()
|
||||
.type(HsHostingAssetType.DOMAIN_SETUP)
|
||||
|
@ -161,7 +161,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Nested
|
||||
class GetGrantById {
|
||||
class GetListOfGrantsByUuid {
|
||||
|
||||
@Test
|
||||
void customerAdmin_withAssumedPacketAdminRole_canReadPacketAdminsGrantById() {
|
||||
@ -171,7 +171,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
|
||||
|
||||
// when
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById()
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
|
||||
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
|
||||
|
||||
// then
|
||||
@ -190,7 +190,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
|
||||
|
||||
// when
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById()
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
|
||||
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
|
||||
|
||||
// then
|
||||
@ -211,7 +211,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
|
||||
|
||||
// when
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById()
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
|
||||
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
|
||||
|
||||
// then
|
||||
@ -231,7 +231,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
"rbactest.package#xxx00:TENANT");
|
||||
final var givenGranteeUser = findRbacSubjectByName("pac-admin-xxx00@xxx.example.com");
|
||||
final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN");
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getGrantById()
|
||||
final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid()
|
||||
.forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser);
|
||||
|
||||
// then
|
||||
@ -360,8 +360,8 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
return new RevokeFixture(givenOwnPackageAdminRole);
|
||||
}
|
||||
|
||||
GetGrantByIdFixture getGrantById() {
|
||||
return new GetGrantByIdFixture();
|
||||
GetListOfGrantsByUuidFixture getListOfGrantsByUuid() {
|
||||
return new GetListOfGrantsByUuidFixture();
|
||||
}
|
||||
|
||||
class GrantFixture {
|
||||
@ -443,12 +443,12 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest {
|
||||
}
|
||||
}
|
||||
|
||||
private class GetGrantByIdFixture {
|
||||
private class GetListOfGrantsByUuidFixture {
|
||||
|
||||
private Subject currentSubject = Subject.this;
|
||||
private RbacRoleEntity grantedRole;
|
||||
|
||||
GetGrantByIdFixture forGrantedRole(final RbacRoleEntity grantedRole) {
|
||||
GetListOfGrantsByUuidFixture forGrantedRole(final RbacRoleEntity grantedRole) {
|
||||
this.grantedRole = grantedRole;
|
||||
return this;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.role;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -7,5 +8,6 @@ import java.util.UUID;
|
||||
|
||||
public interface RawRbacObjectRepository extends Repository<RawRbacObjectEntity, UUID> {
|
||||
|
||||
@Timed("app.rbac.objects.repo.findAll.real")
|
||||
List<RawRbacObjectEntity> findAll();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.rbac.role;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -7,5 +8,6 @@ import java.util.UUID;
|
||||
|
||||
public interface RawRbacRoleRepository extends Repository<RawRbacRoleEntity, UUID> {
|
||||
|
||||
@Timed("app.rbac.roles.repo.findAll.real")
|
||||
List<RawRbacRoleEntity> findAll();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class RbacSubjectControllerRestTest {
|
||||
|
||||
|
||||
@Test
|
||||
void createSubjectUsesGivenUuid() throws Exception {
|
||||
void postNewSubjectUsesGivenUuid() throws Exception {
|
||||
// given
|
||||
final var givenUuid = UUID.randomUUID();
|
||||
|
||||
@ -69,7 +69,7 @@ class RbacSubjectControllerRestTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void createSubjectGeneratesRandomUuidIfNotGiven() throws Exception {
|
||||
void postNewSubjectGeneratesRandomUuidIfNotGiven() throws Exception {
|
||||
// when
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/api/rbac/subjects")
|
||||
|
@ -41,7 +41,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest {
|
||||
HttpServletRequest request;
|
||||
|
||||
@Nested
|
||||
class CreateSubject {
|
||||
class PostNewSubject {
|
||||
|
||||
@Test
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
@ -178,7 +178,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest {
|
||||
}
|
||||
|
||||
@Nested
|
||||
class ListSubjectPermissions {
|
||||
class GetListOfSubjectPermissions {
|
||||
|
||||
private static final String[] ALL_USER_PERMISSIONS = Array.of(
|
||||
// @formatter:off
|
||||
|
Loading…
Reference in New Issue
Block a user