Package sonia.scm.api.v2.resources
Class ConfigurationAdapterBase<DAO,DTO extends de.otto.edison.hal.HalRepresentation>
java.lang.Object
sonia.scm.api.v2.resources.ConfigurationAdapterBase<DAO,DTO>
- Type Parameters:
DAO- The class of the data access object used to persist the configuration.DTO- The class of the data transfer objects used in the rest api.
- All Implemented Interfaces:
HalEnricher
@Beta
public abstract class ConfigurationAdapterBase<DAO,DTO extends de.otto.edison.hal.HalRepresentation>
extends Object
implements HalEnricher
This can be used as a base class for configuration resources.
- Since:
- 2.41.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConfigurationStoreFactoryprotected final jakarta.inject.Provider<ScmPathInfoStore> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConfigurationAdapterBase(ConfigurationStoreFactory configurationStoreFactory, jakarta.inject.Provider<ScmPathInfoStore> scmPathInfoStoreProvider, Class<DAO> daoClass, Class<DTO> dtoClass) Creates the resource. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidenrich(HalEnricherContext context, HalAppender appender) Enriches the response with hal specific attributes.get(jakarta.ws.rs.core.UriInfo uriInfo) protected abstract StringgetName()protected com.github.sdorra.ssp.PermissionCheckprotected Stringprotected com.github.sdorra.ssp.PermissionCheckprotected voidvoid
-
Field Details
-
configurationStoreFactory
-
scmPathInfoStoreProvider
-
-
Constructor Details
-
ConfigurationAdapterBase
protected ConfigurationAdapterBase(ConfigurationStoreFactory configurationStoreFactory, jakarta.inject.Provider<ScmPathInfoStore> scmPathInfoStoreProvider, Class<DAO> daoClass, Class<DTO> dtoClass) Creates the resource. To do so, you have to provide theConfigurationStoreFactoryand theScmPathInfoStoreas aProviderand implementations for the DAO and the DTO.
The DAO class has to have a default constructor that creates the default (initial) configuration.
The DTO class should be created with@GenerateDtoannotation using Conveyor. If the implementation is done manually, it has to provide two methods:- A static method
DTO from(DAO, Links)creating the DTO instance for the given DAO with the provided links. - A method
DAO toEntity()creating the DAO from the DTO.
ConfigurationAdapterBase.IllegalDaoClassExceptions on your way.
The implementation may look like this:@Path("/v2/test") private static class TestConfigurationAdapter extends ConfigurationAdapterBase<TestConfiguration, TestConfigurationDto> { @Inject public TestConfigurationResource(ConfigurationStoreFactory configurationStoreFactory, Provider<ScmPathInfoStore> scmPathInfoStoreProvider) { super(configurationStoreFactory, scmPathInfoStoreProvider, TestConfiguration.class, TestConfigurationDto.class); } @Override protected String getName() { return "testConfig"; } @Override protected void postUpdateHook() { //Some logic that needs to be executed after the update } }- Parameters:
configurationStoreFactory- The configuration store factory provided from injection.scmPathInfoStoreProvider- The path info store provider provided from injection.daoClass- The DAO class instance.dtoClass- The DTO class instance.
- A static method
-
-
Method Details
-
getConfiguration
-
getName
-
getStoreName
-
get
@GET @Produces("application/json") @Path("") public DTO get(@Context jakarta.ws.rs.core.UriInfo uriInfo) -
update
-
postUpdateHook
protected void postUpdateHook() -
enrich
Description copied from interface:HalEnricherEnriches the response with hal specific attributes.- Specified by:
enrichin interfaceHalEnricher- Parameters:
context- contains the source for the json mapping and related objectsappender- can be used to append links or embedded objects to the json response
-
getReadPermission
@Nullable protected com.github.sdorra.ssp.PermissionCheck getReadPermission() -
getWritePermission
@Nullable protected com.github.sdorra.ssp.PermissionCheck getWritePermission()
-