custom validation annotation

This commit is contained in:
Jake Potrebic 2021-02-05 14:54:07 -08:00
parent 2298bc1869
commit c6287f7483
No known key found for this signature in database
GPG Key ID: 7C58557EC9C421F8
149 changed files with 499 additions and 231 deletions

View File

@ -216,7 +216,14 @@
<div v-if="!projectError" class="text-h5 mt-2">{{ $t('project.new.step5.text') }}</div>
<template v-else>
<div class="text-h5 mt-2">{{ $t('project.new.error') }}</div>
<v-btn @click="step = 1">Retry</v-btn>
<v-btn
@click="
step = 1;
projectLoading = true;
projectError = false;
"
>Retry</v-btn
>
</template>
</v-card-text>
</v-card>

View File

@ -10,8 +10,11 @@ import io.papermc.hangar.controller.extras.converters.StringToEnumConverterFacto
import io.papermc.hangar.securityold.UserLockExceptionResolver;
import no.api.freemarker.java8.Java8ObjectWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.expression.BeanFactoryResolver;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.CacheControl;
import org.springframework.http.converter.HttpMessageConverter;
@ -163,4 +166,11 @@ public class WebConfig extends WebMvcConfigurationSupport {
public UserLockExceptionResolver userLockExceptionResolver() {
return new UserLockExceptionResolver();
}
@Bean
public StandardEvaluationContext standardEvaluationContext(ApplicationContext applicationContext) {
StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext));
return evaluationContext;
}
}

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.config.hangar;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
public class ChannelsConfig {
private int maxNameLen = 15;
private String nameRegex = "^[a-zA-Z0-9]+$";
@Value("#{T(io.papermc.hangar.model.Color).getById(${hangar.channels.color-default})}")
@Value("#{T(io.papermc.hangar.model.common.Color).getById(${hangar.channels.color-default})}")
private Color colorDefault = Color.getById(7);
private String nameDefault = "Release";

View File

@ -3,10 +3,10 @@ package io.papermc.hangar.controller.api.v1;
import io.papermc.hangar.controller.HangarController;
import io.papermc.hangar.controller.api.v1.interfaces.IPermissionsController;
import io.papermc.hangar.exceptions.HangarApiException;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.PermissionType;
import io.papermc.hangar.model.api.permissions.PermissionCheck;
import io.papermc.hangar.model.api.permissions.UserPermissions;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.common.PermissionType;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.service.PermissionService;
import org.apache.commons.lang3.tuple.ImmutablePair;

View File

@ -2,11 +2,11 @@ package io.papermc.hangar.controller.api.v1;
import io.papermc.hangar.controller.HangarController;
import io.papermc.hangar.controller.api.v1.interfaces.IProjectsController;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.api.PaginatedResult;
import io.papermc.hangar.model.api.project.Project;
import io.papermc.hangar.model.api.project.ProjectMember;
import io.papermc.hangar.model.api.requests.RequestPagination;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.modelold.generated.ProjectSortingStrategy;
import io.papermc.hangar.service.api.ProjectsApiService;
import org.jetbrains.annotations.NotNull;

View File

@ -1,10 +1,10 @@
package io.papermc.hangar.controller.api.v1.interfaces;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.api.PaginatedResult;
import io.papermc.hangar.model.api.project.Project;
import io.papermc.hangar.model.api.project.ProjectMember;
import io.papermc.hangar.model.api.requests.RequestPagination;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.modelold.generated.ProjectSortingStrategy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -41,7 +41,7 @@ public interface IProjectsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping( "/projects/{author}/{slug}")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
ResponseEntity<Project> getProject(@ApiParam("The author of the project to return") @PathVariable String author,
@ApiParam("The slug of the project to return") @PathVariable String slug);
@ -58,7 +58,7 @@ public interface IProjectsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping("/projects/{author}/{slug}/members")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
ResponseEntity<PaginatedResult<ProjectMember>> getProjectMembers(
@ApiParam("The author of the project to return members for") @PathVariable("author") String author,
@ApiParam("The slug of the project to return") @PathVariable("slug") String slug,
@ -78,7 +78,7 @@ public interface IProjectsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping("/projects")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
ResponseEntity<PaginatedResult<Project>> getProjects(
@ApiParam("The query to use when searching") @RequestParam(required = false) String q,
@ApiParam("Restrict your search to a list of categories") @RequestParam(required = false) List<Category> categories,

View File

@ -27,6 +27,6 @@ public interface ISessionsController {
@ApiResponse(code = 401, message = "Api session missing, invalid or expired"),
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")})
@DeleteMapping("/sessions/current")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).None, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).None, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
ResponseEntity<Void> deleteSession();
}

View File

@ -55,7 +55,7 @@ public interface IVersionsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping(value = "/projects/{author}/{slug}/versions/{name:.*}")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
ResponseEntity<Version> getVersion(@ApiParam("The author of the project to return the version for") @PathVariable String author,
@ApiParam("The slug of the project to return") @PathVariable String slug,
@ApiParam("The name of the version to return") @PathVariable String name
@ -74,7 +74,7 @@ public interface IVersionsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping("/projects/{author}/{slug}/versions")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
ResponseEntity<PaginatedResult<Version>> getVersions(@ApiParam("The author of the project to return versions for") @PathVariable String author,
@ApiParam("The slug of the project to return versions for") @PathVariable String slug,
@ApiParam("A list of tags all the returned versions should have. Should be formatted either as `tagname` or `tagname:tagdata`.") @RequestParam(required = false) List<String> tags,
@ -95,7 +95,7 @@ public interface IVersionsController {
@ApiResponse(code = 403, message = "Not enough permissions to use this endpoint")
})
@GetMapping(value = "/projects/{author}/{slug}/versions/{version}/stats", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).IsProjectMember, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).IsProjectMember, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
ResponseEntity<Map<String, VersionStats>> getVersionStats(@ApiParam("The author of the version to return the stats for") @PathVariable String author,
@ApiParam("The slug of the project to return stats for") @PathVariable String slug,
@ApiParam("The version to return the stats for") @PathVariable String version,

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.controller.extras;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.UserTable;
import io.papermc.hangar.model.db.auth.ApiKeyTable;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.controller.extras;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.UserTable;
public class HangarRequest {

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.controller.extras.converters;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.convert.converter.Converter;

View File

@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.security.annotations.Anyone;
import org.apache.commons.lang3.NotImplementedException;

View File

@ -4,10 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.papermc.hangar.controller.HangarController;
import io.papermc.hangar.exceptions.HangarApiException;
import io.papermc.hangar.model.common.roles.Role;
import io.papermc.hangar.model.db.roles.ExtendedRoleTable;
import io.papermc.hangar.model.internal.user.HangarUser;
import io.papermc.hangar.model.internal.user.notifications.HangarNotification;
import io.papermc.hangar.model.roles.Role;
import io.papermc.hangar.security.HangarAuthenticationToken;
import io.papermc.hangar.service.api.UsersApiService;
import io.papermc.hangar.service.internal.InviteService;

View File

@ -1,9 +1,10 @@
package io.papermc.hangar.controller.internal;
import io.papermc.hangar.controller.HangarController;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.internal.api.requests.projects.NewProject;
import io.papermc.hangar.model.internal.api.responses.PossibleProjectOwner;
import io.papermc.hangar.security.annotations.unlocked.Unlocked;
import io.papermc.hangar.service.internal.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@ -48,6 +49,7 @@ public class ProjectController extends HangarController {
return ResponseEntity.ok(possibleProjectOwners);
}
@Unlocked
@PostMapping(value = "/create", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> createProject(@RequestBody @Valid NewProject newProject) {
System.out.println(newProject);

View File

@ -0,0 +1,57 @@
package io.papermc.hangar.controller.validations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Constraint(validatedBy = Validate.ValidateValueMatchValidator.class)
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Validate.List.class)
public @interface Validate {
String SpEL() default "";
String message() default "Invalid field";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
class ValidateValueMatchValidator implements ConstraintValidator<Validate, Object> {
@Autowired
StandardEvaluationContext evaluationContext;
private Expression expression;
@Override
public void initialize(Validate constraintAnnotation) {
ExpressionParser expressionParser = new SpelExpressionParser();
expression = expressionParser.parseExpression(constraintAnnotation.SpEL());
}
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
if (value == null) return false;
Boolean bool = expression.getValue(evaluationContext, value, boolean.class);
return bool != null && bool;
}
}
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@interface List {
Validate[] value();
}
}

View File

@ -47,7 +47,7 @@ public class Apiv1Controller extends HangarController {
this.projectsTable = projectsTable;
}
@PreAuthorize("@authenticationService.authV1ApiRequest(T(io.papermc.hangar.model.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.authV1ApiRequest(T(io.papermc.hangar.model.common.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@UserLock
@Secured("ROLE_USER")
@PostMapping("/v1/projects/{author}/{slug}/keys/new") // USED IN project settings (deployment key)
@ -67,7 +67,7 @@ public class Apiv1Controller extends HangarController {
return ResponseEntity.ok(apiKeyObj);
}
@PreAuthorize("@authenticationService.authV1ApiRequest(T(io.papermc.hangar.model.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.authV1ApiRequest(T(io.papermc.hangar.model.common.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@UserLock
@Secured("ROLE_USER")
@PostMapping("/v1/projects/{author}/{slug}/keys/revoke") // USED in project settings (deployment key)

View File

@ -17,9 +17,9 @@ import io.papermc.hangar.db.modelold.RoleTable;
import io.papermc.hangar.db.modelold.Stats;
import io.papermc.hangar.db.modelold.UserOrganizationRolesTable;
import io.papermc.hangar.db.modelold.UserProjectRolesTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.Platform;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.common.Platform;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.Role;
import io.papermc.hangar.modelold.viewhelpers.Activity;

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.papermc.hangar.db.modelold.ProjectsTable;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.viewhelpers.ProjectData;
import io.papermc.hangar.securityold.annotations.ProjectPermission;

View File

@ -22,10 +22,10 @@ import io.papermc.hangar.db.modelold.ProjectsTable;
import io.papermc.hangar.db.modelold.UserProjectRolesTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.exceptions.HangarException;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.FlagReason;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.FlagReason;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.model.internal.user.notifications.NotificationType;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.generated.Note;

View File

@ -6,8 +6,8 @@ import io.papermc.hangar.db.customtypes.LoggedActionType.VersionContext;
import io.papermc.hangar.db.modelold.ProjectVersionReviewsTable;
import io.papermc.hangar.db.modelold.ProjectVersionsTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.internal.user.notifications.NotificationType;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.viewhelpers.VersionData;

View File

@ -17,8 +17,8 @@ import io.papermc.hangar.db.modelold.ProjectVersionsTable;
import io.papermc.hangar.db.modelold.ProjectsTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.exceptions.HangarException;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.modelold.DownloadType;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.viewhelpers.ProjectData;

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.controllerold.api;
import io.papermc.hangar.db.customtypes.LoggedActionType;
import io.papermc.hangar.db.customtypes.LoggedActionType.UserContext;
import io.papermc.hangar.exceptions.HangarApiException;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.modelold.ApiAuthInfo;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.modelold.generated.ApiKeyRequest;
@ -39,7 +39,7 @@ public class KeysApiController implements KeysApi {
}
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
public ResponseEntity<ApiKeyResponse> createKey(ApiKeyRequest body) {
List<NamedPermission> perms;
try {
@ -72,7 +72,7 @@ public class KeysApiController implements KeysApi {
}
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).EditApiKeys, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
public ResponseEntity<Void> deleteKey(String name) {
if (apiAuthInfo.getUser() == null) {
throw new HangarApiException(HttpStatus.BAD_REQUEST, "Public keys can't be used to delete");

View File

@ -2,7 +2,7 @@ package io.papermc.hangar.controllerold.api;
import io.papermc.hangar.config.hangar.HangarConfig;
import io.papermc.hangar.exceptions.HangarApiException;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.modelold.ApiAuthInfo;
import io.papermc.hangar.modelold.generated.Project;
import io.papermc.hangar.modelold.generated.ProjectStatsDay;
@ -38,7 +38,7 @@ public class ProjectsApiController implements ProjectsApi {
}
// @Override
// @PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
// @PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
// public ResponseEntity<List<ProjectMember>> showMembers(String author, String slug, Long inLimit, Long inOffset) {
// long limit = ApiUtil.limitOrDefault(inLimit, hangarConfig.getProjects().getInitLoad());
// long offset = ApiUtil.offsetOrZero(inOffset);
@ -51,7 +51,7 @@ public class ProjectsApiController implements ProjectsApi {
// }
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#id))")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#id))")
public ResponseEntity<Project> showProject(long id) {
boolean seeHidden = apiAuthInfo.getGlobalPerms().has(Permission.SeeHidden);
Project project = projectApiService.getProject(id, seeHidden, apiAuthInfo.getUserId());
@ -63,7 +63,7 @@ public class ProjectsApiController implements ProjectsApi {
}
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).IsProjectMember, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).IsProjectMember, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
public ResponseEntity<Map<String, ProjectStatsDay>> showProjectStats(String author, String slug, @NotNull @Valid String fromDate, @NotNull @Valid String toDate) {
LocalDate from = ApiUtil.parseDate(fromDate);
LocalDate to = ApiUtil.parseDate(toDate);

View File

@ -53,7 +53,7 @@ public class VersionsApiController implements VersionsApi {
}
@Override
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.Permission).None, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
@PreAuthorize("@authenticationService.handleApiRequest(T(io.papermc.hangar.model.common.Permission).None, T(io.papermc.hangar.controller.extras.ApiScope).ofGlobal())")
public ResponseEntity<List<PlatformInfo>> showPlatforms() {
List<PlatformInfo> platformInfoList = new ArrayList<>();
for (Platform platform : Platform.getValues()) {
@ -69,7 +69,7 @@ public class VersionsApiController implements VersionsApi {
// moved from versions controller
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
public Object download(String author, String slug, String name, String token) {
// ProjectsTable project = projectsTable.get();
// ProjectVersionsTable pvt = projectVersionsTable.get();
@ -86,7 +86,7 @@ public class VersionsApiController implements VersionsApi {
}
@Override
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
@PreAuthorize("@authenticationService.authApiRequest(T(io.papermc.hangar.model.common.Permission).ViewPublicInfo, T(io.papermc.hangar.controller.extras.ApiScope).ofProject(#author, #slug))")
public Object downloadRecommended(String author, String slug, String token) {
// ProjectsTable project = projectsTable.get();
// ProjectVersionsTable recommendedVersion = versionService.getRecommendedVersion(project);

View File

@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonCreator.Mode;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.controllerold.forms.objects.License;
import io.papermc.hangar.controllerold.forms.objects.ProjectLinks;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.common.projects.Category;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.controllerold.forms.objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.db.dao;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.db.dao.internal.table;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.OrganizationTable;
import org.jdbi.v3.sqlobject.config.RegisterConstructorMapper;
import org.jdbi.v3.sqlobject.customizer.BindBean;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.dao.internal.table.roles;
import io.papermc.hangar.model.common.roles.Role;
import io.papermc.hangar.model.db.roles.RoleTable;
import io.papermc.hangar.model.roles.Role;
public interface RoleDAO<T extends RoleTable<? extends Role<T>>> {

View File

@ -1,10 +1,10 @@
package io.papermc.hangar.db.dao.v1;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.api.color.TagColor;
import io.papermc.hangar.model.api.project.version.Tag;
import io.papermc.hangar.model.api.project.version.Version;
import io.papermc.hangar.model.api.project.version.VersionStats;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.util.StringUtils;
import org.jdbi.v3.core.result.LinkedHashMapRowReducer;
import org.jdbi.v3.core.result.RowView;
@ -138,7 +138,7 @@ public interface VersionsApiDAO {
List<Tag> tags = new ArrayList<>();
for (int i = 0; i < tagNames.length; i++) {
TagColor apiTagColor;
io.papermc.hangar.model.TagColor tagColor = io.papermc.hangar.model.TagColor.getByName(tagNames[i]);
io.papermc.hangar.model.common.TagColor tagColor = io.papermc.hangar.model.common.TagColor.getByName(tagNames[i]);
if (tagColor == null) {
Color color = Color.VALUES[tagColors[i]];
apiTagColor = new TagColor(null, color.getHex());

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.db.daoold;
import io.papermc.hangar.db.modelold.OrganizationsTable;
import io.papermc.hangar.db.modelold.UserOrganizationRolesTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;
import org.jdbi.v3.sqlobject.customizer.BindBean;
import org.jdbi.v3.sqlobject.customizer.Timestamped;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.daoold;
import io.papermc.hangar.db.modelold.PlatformVersionsTable;
import io.papermc.hangar.model.Platform;
import io.papermc.hangar.model.common.Platform;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.enums.EnumStrategy;
import org.jdbi.v3.sqlobject.config.KeyColumn;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.daoold;
import io.papermc.hangar.db.modelold.ProjectChannelsTable;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.serviceold.project.ChannelService;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.db.daoold;
import io.papermc.hangar.db.modelold.ProjectsTable;
import io.papermc.hangar.db.modelold.UserProjectRolesTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.modelold.generated.ProjectStatsAll;
import io.papermc.hangar.modelold.viewhelpers.ProjectApprovalData;
import io.papermc.hangar.modelold.viewhelpers.ProjectMissingFile;

View File

@ -4,7 +4,7 @@ import io.papermc.hangar.db.mappers.PlatformDependencyMapper;
import io.papermc.hangar.db.mappers.VersionDependenciesMapper;
import io.papermc.hangar.db.modelold.ProjectVersionTagsTable;
import io.papermc.hangar.db.modelold.ProjectVersionsTable;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.modelold.viewhelpers.ReviewQueueEntry;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.db.daoold.api.mappers;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.modelold.generated.FileInfo;
import io.papermc.hangar.modelold.generated.Tag;
import io.papermc.hangar.modelold.generated.TagColor;
@ -38,7 +38,7 @@ public class VersionMapper implements RowMapper<Version> {
List<Tag> tags = new ArrayList<>();
for (int i = 0; i < tagNames.length; i++) {
io.papermc.hangar.model.TagColor tagColor = io.papermc.hangar.model.TagColor.getByName(tagNames[i]);
io.papermc.hangar.model.common.TagColor tagColor = io.papermc.hangar.model.common.TagColor.getByName(tagNames[i]);
Tag newTag = new Tag().name(tagNames[i]);
if (tagData[i] != null) {
newTag.data(StringUtils.formatVersionNumbers(Arrays.asList(tagData[i].split(", "))));

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.db.mappers;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import org.jdbi.v3.core.mapper.ColumnMapper;
import org.jdbi.v3.core.statement.StatementContext;

View File

@ -6,9 +6,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.NullNode;
import io.papermc.hangar.db.customtypes.JSONB;
import io.papermc.hangar.model.TagColor;
import io.papermc.hangar.model.api.project.version.PromotedVersion;
import io.papermc.hangar.model.api.project.version.PromotedVersionTag;
import io.papermc.hangar.model.common.TagColor;
import io.papermc.hangar.util.StringUtils;
import org.jdbi.v3.core.mapper.ColumnMapper;
import org.jdbi.v3.core.statement.StatementContext;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.mappers;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.roles.Role;
import io.papermc.hangar.model.common.roles.GlobalRole;
import io.papermc.hangar.model.common.roles.Role;
import org.jdbi.v3.core.config.ConfigRegistry;
import org.jdbi.v3.core.mapper.ColumnMapper;
import org.jdbi.v3.core.mapper.ColumnMapperFactory;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import org.jdbi.v3.core.mapper.Nested;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.Platform;
import io.papermc.hangar.model.common.Platform;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import java.time.OffsetDateTime;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.common.Color;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import java.time.OffsetDateTime;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.FlagReason;
import io.papermc.hangar.model.common.projects.FlagReason;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.TagColor;
import io.papermc.hangar.model.common.TagColor;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import java.util.List;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import java.time.OffsetDateTime;

View File

@ -1,9 +1,9 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.annotation.Unmappable;
import org.jdbi.v3.core.enums.EnumByOrdinal;

View File

@ -1,12 +1,11 @@
package io.papermc.hangar.db.modelold;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.springframework.lang.Nullable;
import java.time.OffsetDateTime;
import io.papermc.hangar.model.Visibility;
public class ProjectVisibilityChangesTable {
private long id;

View File

@ -3,10 +3,10 @@ package io.papermc.hangar.db.modelold;
import io.papermc.hangar.controllerold.forms.NewProjectForm;
import io.papermc.hangar.db.customtypes.JSONB;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.Visitable;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.util.StringUtils;
import org.jdbi.v3.core.annotation.Unmappable;
import org.jdbi.v3.core.enums.EnumByOrdinal;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
public interface Visible {

View File

@ -2,7 +2,7 @@ package io.papermc.hangar.model.api;
import io.papermc.hangar.model.Model;
import io.papermc.hangar.model.Named;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.common.roles.GlobalRole;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.api.permissions;
import io.papermc.hangar.model.PermissionType;
import io.papermc.hangar.model.common.PermissionType;
public class PermissionCheck {

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.api.permissions;
import io.papermc.hangar.model.PermissionType;
import io.papermc.hangar.model.common.PermissionType;
import io.papermc.hangar.modelold.NamedPermission;
import java.util.List;

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.model.api.project;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.api.project.version.PromotedVersion;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;

View File

@ -1,11 +1,11 @@
package io.papermc.hangar.model.api.project;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.Model;
import io.papermc.hangar.model.Named;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.api.project.version.PromotedVersion;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.api.project;
import io.papermc.hangar.model.roles.ProjectRole;
import io.papermc.hangar.model.common.roles.ProjectRole;
import java.util.List;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.api.project.version;
import io.papermc.hangar.model.TagColor;
import io.papermc.hangar.model.common.TagColor;
public class PromotedVersionTag extends Tag {

View File

@ -2,10 +2,10 @@ package io.papermc.hangar.model.api.project.version;
import io.papermc.hangar.model.Model;
import io.papermc.hangar.model.Named;
import io.papermc.hangar.model.Platform;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.common.Platform;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;
import org.jdbi.v3.core.mapper.reflect.ColumnName;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common;
import com.fasterxml.jackson.annotation.JsonValue;
import io.papermc.hangar.modelold.NamedPermission;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common.projects;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common.projects;
public enum FlagReason {

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common.projects;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -1,4 +1,4 @@
package io.papermc.hangar.model;
package io.papermc.hangar.model.common.projects;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -1,9 +1,9 @@
package io.papermc.hangar.model.roles;
package io.papermc.hangar.model.common.roles;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.roles.GlobalRoleTable;
import org.jdbi.v3.core.statement.StatementContext;
import org.jetbrains.annotations.NotNull;

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.model.roles;
package io.papermc.hangar.model.common.roles;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.roles.OrganizationRoleTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.model.roles;
package io.papermc.hangar.model.common.roles;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.roles.ProjectRoleTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.model.roles;
package io.papermc.hangar.model.common.roles;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.roles.RoleTable;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.statement.StatementContext;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.model.db.auth;
import io.papermc.hangar.model.Named;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.db.Table;
import org.jdbi.v3.core.mapper.PropagateNull;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.projects;
import io.papermc.hangar.model.FlagReason;
import io.papermc.hangar.model.common.projects.FlagReason;
import io.papermc.hangar.model.db.Table;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;

View File

@ -2,10 +2,10 @@ package io.papermc.hangar.model.db.projects;
import io.papermc.hangar.controllerold.forms.NewProjectForm;
import io.papermc.hangar.db.customtypes.JSONB;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.Visitable;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.model.db.Table;
import io.papermc.hangar.util.StringUtils;
import org.jdbi.v3.core.enums.EnumByOrdinal;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.projects;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.model.db.Table;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.model.db.roles;
import io.papermc.hangar.model.common.roles.Role;
import io.papermc.hangar.model.db.Table;
import io.papermc.hangar.model.roles.Role;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.roles;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.common.roles.GlobalRole;
import org.jdbi.v3.core.mapper.reflect.ColumnName;
public class GlobalRoleTable implements RoleTable<GlobalRole> {

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.model.db.roles;
import io.papermc.hangar.model.roles.OrganizationRole;
import io.papermc.hangar.model.common.roles.OrganizationRole;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.roles;
import io.papermc.hangar.model.roles.ProjectRole;
import io.papermc.hangar.model.common.roles.ProjectRole;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;
import java.time.OffsetDateTime;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.roles;
import io.papermc.hangar.model.roles.Role;
import io.papermc.hangar.model.common.roles.Role;
public interface RoleTable<R extends Role<? extends RoleTable<R>>> {

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.db.versions;
import io.papermc.hangar.model.Platform;
import io.papermc.hangar.model.common.Platform;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.reflect.JdbiConstructor;

View File

@ -1,9 +1,9 @@
package io.papermc.hangar.model.db.versions;
import io.papermc.hangar.model.Named;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.Visible;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.model.db.Table;
import io.papermc.hangar.modelold.generated.PlatformDependency;
import io.papermc.hangar.modelold.viewhelpers.VersionDependencies;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.model.internal;
import io.papermc.hangar.model.FlagReason;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.FlagReason;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.model.db.projects.ProjectFlagTable;
import org.jdbi.v3.core.enums.EnumByOrdinal;

View File

@ -1,21 +1,56 @@
package io.papermc.hangar.model.internal.api.requests.projects;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.controller.validations.Validate;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.util.StringUtils;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
public class NewProject {
private final long ownerId;
@Size(min = 7, message = "Name has to be at least 7 characters")
@NotNull
@Validate(SpEL = "#root.length le @hangarConfig.projects.maxNameLen", message = "Project name too long") // TODO i18n
@Validate(SpEL = "#root matches @hangarConfig.projects.nameRegex", message = "Invalid project name") // TODO i18n
private final String name;
@NotNull
@Validate(SpEL = "#root.length le @hangarConfig.projects.maxDescLen", message = "Project description too long") // TODO i18n
private final String description;
@NotNull
private final Category category;
private final String pageContent;
private final String homepageUrl;
private final String issuesUrl;
private final String sourceUrl;
private final String supportUrl;
private final String licenseName;
private final String licenseUrl;
@NotNull
@Validate(SpEL = "#root.length le @hangarConfig.projects.maxKeywords", message = "Too many keywords") // TODO i18n
private final List<String> keywords;
@JsonCreator
public NewProject(long ownerId, String name, String description) {
public NewProject(long ownerId, @NotNull String name, @NotNull String description, @NotNull Category category, String pageContent, @JsonProperty("links") Map<String, String> linkMap, @JsonProperty("license") Map<String, String> licenseMap, @NotNull List<String> keywords) {
this.ownerId = ownerId;
this.name = name;
this.name = StringUtils.compact(name);
this.description = description;
this.category = category;
this.pageContent = pageContent;
this.homepageUrl = linkMap.get("homepage");
this.issuesUrl = linkMap.get("issues");
this.sourceUrl = linkMap.get("source");
this.supportUrl = linkMap.get("support");
String licenseName = StringUtils.stringOrNull(licenseMap.get("customName"));
if (licenseName == null) {
licenseName = licenseMap.get("type");
}
this.licenseName = licenseName;
this.licenseUrl = licenseMap.get("url");
this.keywords = keywords;
}
public long getOwnerId() {
@ -30,12 +65,57 @@ public class NewProject {
return description;
}
public Category getCategory() {
return category;
}
public String getPageContent() {
return pageContent;
}
public String getHomepageUrl() {
return homepageUrl;
}
public String getIssuesUrl() {
return issuesUrl;
}
public String getSourceUrl() {
return sourceUrl;
}
public String getSupportUrl() {
return supportUrl;
}
public String getLicenseName() {
return licenseName;
}
public String getLicenseUrl() {
return licenseUrl;
}
public List<String> getKeywords() {
return keywords;
}
@Override
public String toString() {
return "NewProject{" +
"ownerId=" + ownerId +
", name='" + name + '\'' +
", description='" + description + '\'' +
", category=" + category +
", pageContent='" + pageContent + '\'' +
", homepageUrl='" + homepageUrl + '\'' +
", issuesUrl='" + issuesUrl + '\'' +
", sourceUrl='" + sourceUrl + '\'' +
", supportUrl='" + supportUrl + '\'' +
", licenseName='" + licenseName + '\'' +
", licenseUrl='" + licenseUrl + '\'' +
", keywords=" + keywords +
'}';
}
}

View File

@ -1,8 +1,8 @@
package io.papermc.hangar.model.internal.sso;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.roles.Role;
import io.papermc.hangar.model.common.roles.GlobalRole;
import io.papermc.hangar.model.common.roles.Role;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.model.internal.sso;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.common.roles.GlobalRole;
import io.papermc.hangar.util.SsoUtil;
import java.util.List;

View File

@ -1,9 +1,9 @@
package io.papermc.hangar.model.internal.user;
import io.papermc.hangar.model.Identified;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.api.User;
import io.papermc.hangar.model.roles.GlobalRole;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.model.common.roles.GlobalRole;
import java.time.OffsetDateTime;
import java.util.List;

View File

@ -1,9 +1,9 @@
package io.papermc.hangar.model.internal.user.notifications;
import io.papermc.hangar.model.common.roles.OrganizationRole;
import io.papermc.hangar.model.common.roles.ProjectRole;
import io.papermc.hangar.model.common.roles.Role;
import io.papermc.hangar.model.db.roles.RoleTable;
import io.papermc.hangar.model.roles.OrganizationRole;
import io.papermc.hangar.model.roles.ProjectRole;
import io.papermc.hangar.model.roles.Role;
public abstract class HangarInvite<R extends Role<? extends RoleTable<R>>> {

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.modelold;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.modelold.generated.ApiKey;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.modelold;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
import io.papermc.hangar.db.dao.HangarDao;
import io.papermc.hangar.db.daoold.PlatformVersionsDao;
import io.papermc.hangar.db.modelold.ProjectVersionTagsTable;
import io.papermc.hangar.model.TagColor;
import io.papermc.hangar.model.common.TagColor;
import io.papermc.hangar.modelold.generated.PlatformDependency;
import io.papermc.hangar.serviceold.VersionService;
import org.apache.commons.lang3.tuple.ImmutablePair;

View File

@ -7,8 +7,8 @@ import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.model.Color;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Color;
import io.papermc.hangar.model.common.Permission;
@JsonFormat(shape = Shape.OBJECT)
public enum Role {

View File

@ -1,6 +1,6 @@
package io.papermc.hangar.modelold.generated;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import org.jdbi.v3.core.annotation.Unmappable;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -2,8 +2,8 @@ package io.papermc.hangar.modelold.generated;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Category;
import io.papermc.hangar.model.common.projects.Visibility;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;
import org.springframework.validation.annotation.Validated;

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.modelold.generated;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.papermc.hangar.model.Category;
import io.papermc.hangar.model.common.projects.Category;
import io.swagger.annotations.ApiModelProperty;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -3,8 +3,8 @@ package io.papermc.hangar.modelold.generated;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.papermc.hangar.model.ReviewState;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.ReviewState;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.modelold.Platform;
import io.swagger.annotations.ApiModelProperty;
import org.jdbi.v3.core.enums.EnumByOrdinal;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.modelold.viewhelpers;
import io.papermc.hangar.model.common.Permission;
import io.papermc.hangar.modelold.NamedPermission;
import io.papermc.hangar.model.Permission;
import org.jdbi.v3.core.mapper.Nested;
import java.util.Collection;

View File

@ -1,7 +1,7 @@
package io.papermc.hangar.modelold.viewhelpers;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
public class HeaderData {

View File

@ -3,7 +3,7 @@ package io.papermc.hangar.modelold.viewhelpers;
import io.papermc.hangar.db.customtypes.RoleCategory;
import io.papermc.hangar.db.modelold.RoleTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Permission;
import io.papermc.hangar.model.common.Permission;
import java.util.Map;
import java.util.Map.Entry;

View File

@ -1,8 +1,7 @@
package io.papermc.hangar.modelold.viewhelpers;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.modelold.generated.ProjectNamespace;
import org.jdbi.v3.core.enums.EnumByOrdinal;
import org.jdbi.v3.core.mapper.Nested;

View File

@ -6,7 +6,7 @@ import io.papermc.hangar.db.modelold.ProjectVisibilityChangesTable;
import io.papermc.hangar.db.modelold.ProjectsTable;
import io.papermc.hangar.db.modelold.UserProjectRolesTable;
import io.papermc.hangar.db.modelold.UsersTable;
import io.papermc.hangar.model.Visibility;
import io.papermc.hangar.model.common.projects.Visibility;
import io.papermc.hangar.serviceold.MarkdownService;
import java.util.List;

Some files were not shown because too many files have changed in this diff Show More