Renames globalConfig to config.

From an SCMM point of view there is only one config, so no "global" necessary.
The others configs are provided by plugins.
This commit is contained in:
Johannes Schnatterer
2018-07-31 14:47:15 +02:00
parent 1db45a7892
commit 865929b328
13 changed files with 87 additions and 89 deletions

View File

@@ -11,7 +11,7 @@ import java.util.Set;
@NoArgsConstructor
@Getter
@Setter
public class GlobalConfigDto extends HalRepresentation {
public class ConfigDto extends HalRepresentation {
private String proxyPassword;
private int proxyPort;

View File

@@ -6,7 +6,7 @@ import sonia.scm.config.ScmConfiguration;
// Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
@SuppressWarnings("squid:S3306")
@Mapper
public abstract class GlobalConfigDtoToScmConfigurationMapper {
public abstract class ConfigDtoToScmConfigurationMapper {
public abstract ScmConfiguration map(GlobalConfigDto dto);
public abstract ScmConfiguration map(ConfigDto dto);
}

View File

@@ -18,16 +18,16 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@Path(GlobalConfigResource.GLOBAL_CONFIG_PATH_V2)
public class GlobalConfigResource {
@Path(ConfigResource.CONFIG_PATH_V2)
public class ConfigResource {
static final String GLOBAL_CONFIG_PATH_V2 = "v2/config/global";
private final GlobalConfigDtoToScmConfigurationMapper dtoToConfigMapper;
private final ScmConfigurationToGlobalConfigDtoMapper configToDtoMapper;
static final String CONFIG_PATH_V2 = "v2/config";
private final ConfigDtoToScmConfigurationMapper dtoToConfigMapper;
private final ScmConfigurationToConfigDtoMapper configToDtoMapper;
private final ScmConfiguration configuration;
@Inject
public GlobalConfigResource(GlobalConfigDtoToScmConfigurationMapper dtoToConfigMapper, ScmConfigurationToGlobalConfigDtoMapper configToDtoMapper, ScmConfiguration configuration) {
public ConfigResource(ConfigDtoToScmConfigurationMapper dtoToConfigMapper, ScmConfigurationToConfigDtoMapper configToDtoMapper, ScmConfiguration configuration) {
this.dtoToConfigMapper = dtoToConfigMapper;
this.configToDtoMapper = configToDtoMapper;
this.configuration = configuration;
@@ -38,7 +38,7 @@ public class GlobalConfigResource {
*/
@GET
@Path("")
@Produces(VndMediaType.GLOBAL_CONFIG)
@Produces(VndMediaType.CONFIG)
@TypeHint(UserDto.class)
@StatusCodes({
@ResponseCode(code = 200, condition = "success"),
@@ -62,7 +62,7 @@ public class GlobalConfigResource {
*/
@PUT
@Path("")
@Consumes(VndMediaType.GLOBAL_CONFIG)
@Consumes(VndMediaType.CONFIG)
@StatusCodes({
@ResponseCode(code = 201, condition = "update success"),
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
@@ -70,7 +70,7 @@ public class GlobalConfigResource {
@ResponseCode(code = 500, condition = "internal server error")
})
@TypeHint(TypeHint.NO_CONTENT.class)
public Response update(GlobalConfigDto configDto, @Context UriInfo uriInfo) {
public Response update(ConfigDto configDto, @Context UriInfo uriInfo) {
// This *could* be moved to ScmConfiguration or ScmConfigurationUtil classes.
// But to where to check? load() or store()? Leave it for now, SCMv1 legacy that can be cleaned up later.

View File

@@ -15,8 +15,8 @@ public class MapperModule extends AbstractModule {
bind(GroupToGroupDtoMapper.class).to(Mappers.getMapper(GroupToGroupDtoMapper.class).getClass());
bind(GroupCollectionToDtoMapper.class);
bind(ScmConfigurationToGlobalConfigDtoMapper.class).to(Mappers.getMapper(ScmConfigurationToGlobalConfigDtoMapper.class).getClass());
bind(GlobalConfigDtoToScmConfigurationMapper.class).to(Mappers.getMapper(GlobalConfigDtoToScmConfigurationMapper.class).getClass());
bind(ScmConfigurationToConfigDtoMapper.class).to(Mappers.getMapper(ScmConfigurationToConfigDtoMapper.class).getClass());
bind(ConfigDtoToScmConfigurationMapper.class).to(Mappers.getMapper(ConfigDtoToScmConfigurationMapper.class).getClass());
bind(RepositoryToRepositoryDtoMapper.class).to(Mappers.getMapper(RepositoryToRepositoryDtoMapper.class).getClass());
bind(RepositoryDtoToRepositoryMapper.class).to(Mappers.getMapper(RepositoryDtoToRepositoryMapper.class).getClass());

View File

@@ -101,23 +101,23 @@ class ResourceLinks {
}
}
GlobalConfigLinks globalConfig() {
return new GlobalConfigLinks(uriInfoStore.get());
ConfigLinks config() {
return new ConfigLinks(uriInfoStore.get());
}
static class GlobalConfigLinks {
private final LinkBuilder globalConfigLinkBuilder;
static class ConfigLinks {
private final LinkBuilder configLinkBuilder;
GlobalConfigLinks(UriInfo uriInfo) {
globalConfigLinkBuilder = new LinkBuilder(uriInfo, GlobalConfigResource.class);
ConfigLinks(UriInfo uriInfo) {
configLinkBuilder = new LinkBuilder(uriInfo, ConfigResource.class);
}
String self() {
return globalConfigLinkBuilder.method("get").parameters().href();
return configLinkBuilder.method("get").parameters().href();
}
String update() {
return globalConfigLinkBuilder.method("update").parameters().href();
return configLinkBuilder.method("update").parameters().href();
}
}

View File

@@ -15,18 +15,18 @@ import static de.otto.edison.hal.Links.linkingTo;
// Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
@SuppressWarnings("squid:S3306")
@Mapper
public abstract class ScmConfigurationToGlobalConfigDtoMapper {
public abstract class ScmConfigurationToConfigDtoMapper {
@Inject
private ResourceLinks resourceLinks;
public abstract GlobalConfigDto map(ScmConfiguration config);
public abstract ConfigDto map(ScmConfiguration config);
@AfterMapping
void appendLinks(ScmConfiguration config, @MappingTarget GlobalConfigDto target) {
Links.Builder linksBuilder = linkingTo().self(resourceLinks.globalConfig().self());
void appendLinks(ScmConfiguration config, @MappingTarget ConfigDto target) {
Links.Builder linksBuilder = linkingTo().self(resourceLinks.config().self());
if (ConfigurationPermissions.write(config).isPermitted()) {
linksBuilder.single(link("update", resourceLinks.globalConfig().update()));
linksBuilder.single(link("update", resourceLinks.config().update()));
}
target.add(linksBuilder.build());
}