-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,453 additions
and
625 deletions.
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
api/src/main/java/net/adamcin/oakpal/api/ApiConstants.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,62 @@ | ||
/* | ||
* Copyright 2020 Mark Adamcin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.adamcin.oakpal.api; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Hosts constants as static singleton getter methods defined by interfaces. This reduces the impact on semantic | ||
* versioning rules of adding or modifying interface constants. | ||
*/ | ||
public final class ApiConstants { | ||
private ApiConstants() { | ||
/* no construction */ | ||
} | ||
|
||
private static final ViolationKeys VIOLATION_KEYS = new ViolationKeys() { | ||
@Override | ||
public String description() { | ||
return "description"; | ||
} | ||
|
||
@Override | ||
public String severity() { | ||
return "severity"; | ||
} | ||
|
||
@Override | ||
public String packages() { | ||
return "packages"; | ||
} | ||
}; | ||
|
||
/** | ||
* Json key constant accessors for violations. | ||
*/ | ||
public interface ViolationKeys { | ||
String description(); | ||
|
||
String severity(); | ||
|
||
String packages(); | ||
} | ||
|
||
@NotNull | ||
public static ViolationKeys violationKeys() { | ||
return VIOLATION_KEYS; | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
api/src/main/java/net/adamcin/oakpal/api/ProgressCheckFactory.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2020 Mark Adamcin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.adamcin.oakpal.api; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Levels of severity for violations detected during package scans. | ||
*/ | ||
public enum Severity { | ||
/** | ||
* Unlikely to disrupt application functionality. Appropriate for reporting violations of | ||
* code or style conventions, or inconsistency between modes of installation. | ||
*/ | ||
MINOR(2), | ||
|
||
/** | ||
* Likely to be the source of component instability. Appropriate for importer errors, mistaken | ||
* assumptions about root path dependencies or namespaces, or failures related to unit testing of | ||
* application packages. | ||
*/ | ||
MAJOR(1), | ||
|
||
/** | ||
* Likely to be the source of platform instability. Appropriate for reporting cross-package filter | ||
* overlap, destructive ACL handling modes, destruction of authorable content, or security violations. | ||
*/ | ||
SEVERE(0); | ||
|
||
private final int ordinal; | ||
|
||
Severity(int ordinal) { | ||
this.ordinal = ordinal; | ||
} | ||
|
||
/** | ||
* Runtime throwing function to lookup severity codes by name. | ||
* | ||
* @param name the severity level name | ||
* @return the associated severity level | ||
*/ | ||
public static Severity byName(final @NotNull String name) { | ||
for (Severity value : values()) { | ||
if (value.name().equalsIgnoreCase(name)) { | ||
return value; | ||
} | ||
} | ||
throw new IllegalArgumentException("Unknown severity level: " + name); | ||
} | ||
|
||
public boolean isLessSevereThan(Severity other) { | ||
return this.ordinal > other.ordinal; | ||
} | ||
|
||
public Predicate<Severity> meetsMinimumSeverity() { | ||
return other -> !other.isLessSevereThan(this); | ||
} | ||
|
||
public Severity maxSeverity(final @NotNull Severity other) { | ||
return this.isLessSevereThan(other) ? other : this; | ||
} | ||
} |
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
Oops, something went wrong.