Search in sources :

Example 1 with ProjectCreationConfiguration

use of org.finos.legend.sdlc.server.project.config.ProjectCreationConfiguration in project legend-sdlc by finos.

the class GitLabProjectApi method validateProjectCreation.

private void validateProjectCreation(String name, String description, ProjectType type, String groupId, String artifactId) {
    ProjectCreationConfiguration projectCreationConfig = getProjectCreationConfiguration();
    if (projectCreationConfig != null) {
        if (projectCreationConfig.isDisallowedType(type)) {
            String message = projectCreationConfig.getDisallowedTypeMessage(type);
            if (message == null) {
                message = "Projects of type " + type + " may not be created through this server.";
            }
            throw new LegendSDLCServerException(message, Status.BAD_REQUEST);
        }
        Pattern groupIdPattern = projectCreationConfig.getGroupIdPattern();
        if ((groupIdPattern != null) && !groupIdPattern.matcher(groupId).matches()) {
            throw new LegendSDLCServerException("groupId must match \"" + groupIdPattern.pattern() + "\", got: " + groupId, Status.BAD_REQUEST);
        }
        Pattern artifactIdPattern = projectCreationConfig.getArtifactIdPattern();
        if ((artifactIdPattern != null) && !artifactIdPattern.matcher(artifactId).matches()) {
            throw new LegendSDLCServerException("artifactId must match \"" + artifactIdPattern.pattern() + "\", got: " + artifactId, Status.BAD_REQUEST);
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) LegendSDLCServerException(org.finos.legend.sdlc.server.error.LegendSDLCServerException) ProjectCreationConfiguration(org.finos.legend.sdlc.server.project.config.ProjectCreationConfiguration)

Aggregations

Pattern (java.util.regex.Pattern)1 LegendSDLCServerException (org.finos.legend.sdlc.server.error.LegendSDLCServerException)1 ProjectCreationConfiguration (org.finos.legend.sdlc.server.project.config.ProjectCreationConfiguration)1