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 ConfigurationStoreFactory
protected final jakarta.inject.Provider<ScmPathInfoStore>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ConfigurationAdapterBase
(ConfigurationStoreFactory configurationStoreFactory, jakarta.inject.Provider<ScmPathInfoStore> scmPathInfoStoreProvider, Class<DAO> daoClass, Class<DTO> dtoClass) Creates the resource. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
enrich
(HalEnricherContext context, HalAppender appender) Enriches the response with hal specific attributes.get
(jakarta.ws.rs.core.UriInfo uriInfo) protected abstract String
getName()
protected com.github.sdorra.ssp.PermissionCheck
protected String
protected com.github.sdorra.ssp.PermissionCheck
void
-
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 theConfigurationStoreFactory
and theScmPathInfoStore
as aProvider
and 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@GenerateDto
annotation 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.IllegalDaoClassException
s on your way.
The implementation may look like this:- 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
-
enrich
Description copied from interface:HalEnricher
Enriches the response with hal specific attributes.- Specified by:
enrich
in 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()
-