-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
manual url for internal forms and override support #2673
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e9a90ad
adds ManualConfig to set manual configs for internal forms or overrid…
thoniTUB 37c1644
Update AutoDoc
github-actions[bot] 1008817
cleans up class structure and adds docu
thoniTUB 3afec64
Update AutoDoc
github-actions[bot] 1f9ed37
fixes tests
thoniTUB dad01f8
Update backend/src/main/java/com/bakdata/conquery/models/forms/fronte…
thoniTUB 9042aad
throw exception on wrong manualUrl-node type
thoniTUB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
backend/src/main/java/com/bakdata/conquery/models/config/ManualConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.bakdata.conquery.models.config; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
import com.bakdata.conquery.io.cps.CPSType; | ||
import com.bakdata.conquery.util.validation.ManualURI; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Configuration of manual links for {@link org.checkerframework.checker.signature.qual.InternalForm} and | ||
* overriding of other {@link com.bakdata.conquery.apiv1.forms.Form}s. | ||
*/ | ||
@CPSType(id = "MANUAL", base = PluginConfig.class) | ||
@Getter | ||
@Setter | ||
public class ManualConfig implements PluginConfig { | ||
|
||
|
||
/** | ||
* Maps a {@link CPSType} of a {@link com.bakdata.conquery.apiv1.forms.Form} to a manual URL. | ||
* E.g.: | ||
* <ul> | ||
* <li>EXPORT_FORM -> https://example.org/export-form</li> | ||
* <li>FULL_EXPORT_FORM -> ./full-export-form</li> | ||
* </ul> | ||
*/ | ||
private Map<String, @ManualURI URI> forms = Collections.emptyMap(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/com/bakdata/conquery/util/validation/ManualURI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.bakdata.conquery.util.validation; | ||
|
||
import static java.lang.annotation.ElementType.*; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.validation.Constraint; | ||
import javax.validation.Payload; | ||
|
||
@Target({ANNOTATION_TYPE, FIELD, TYPE_USE}) | ||
@Retention(RUNTIME) | ||
@Constraint(validatedBy = ManualURIValidator.class) | ||
@Documented | ||
public @interface ManualURI { | ||
String message() default ""; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
@SuppressWarnings("UnusedDeclaration") Class<? extends Payload>[] payload() default {}; | ||
} |
54 changes: 54 additions & 0 deletions
54
backend/src/main/java/com/bakdata/conquery/util/validation/ManualURIValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.bakdata.conquery.util.validation; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.util.List; | ||
|
||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
public class ManualURIValidator implements ConstraintValidator<ManualURI, URI> { | ||
|
||
@Override | ||
public boolean isValid(URI value, ConstraintValidatorContext context) { | ||
|
||
if (value == null) { | ||
return true; | ||
} | ||
|
||
context.disableDefaultConstraintViolation(); | ||
|
||
boolean isValid = true; | ||
|
||
if (value.isOpaque()) { | ||
isValid = false; | ||
context.buildConstraintViolationWithTemplate("The URI was opaque") | ||
.addConstraintViolation(); | ||
} | ||
|
||
if (value.isAbsolute()) { | ||
try { | ||
var unused = value.toURL(); | ||
} | ||
catch (MalformedURLException e) { | ||
isValid = false; | ||
context.buildConstraintViolationWithTemplate("Absolute URI is not a valid URL (" + e.getMessage() + ")") | ||
.addConstraintViolation(); | ||
} | ||
if (!List.of("http", "https").contains(value.getScheme())) { | ||
isValid = false; | ||
context.buildConstraintViolationWithTemplate("The URI has an unsupported Scheme: " + value.getScheme()) | ||
.addConstraintViolation(); | ||
} | ||
} | ||
else { | ||
if (value.getAuthority() != null) { | ||
isValid = false; | ||
context.buildConstraintViolationWithTemplate("The URI is not absolute but has an authority: " + value.getAuthority()) | ||
.addConstraintViolation(); | ||
} | ||
} | ||
|
||
return isValid; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macht es was, wenn du hier eine exception wirfst? Das ist mMn sinnvoller