|
24 | 24 | import java.util.Set;
|
25 | 25 | import java.util.concurrent.CompletableFuture;
|
26 | 26 |
|
27 |
| -/** The Api interface is used for contracting API implementations. **/ |
| 27 | +/** The Api interface is used for contracting API implementations. * */ |
28 | 28 | public interface Api {
|
29 | 29 |
|
30 |
| - public static final String CYCLONEDX_MEDIA_TYPE = "application/vnd.cyclonedx+json"; |
| 30 | + public static final String CYCLONEDX_MEDIA_TYPE = "application/vnd.cyclonedx+json"; |
31 | 31 |
|
32 |
| - enum MediaType { |
33 |
| - APPLICATION_JSON, |
34 |
| - TEXT_HTML, |
35 |
| - MULTIPART_MIXED; |
| 32 | + enum MediaType { |
| 33 | + APPLICATION_JSON, |
| 34 | + TEXT_HTML, |
| 35 | + MULTIPART_MIXED; |
36 | 36 |
|
37 |
| - @Override |
38 |
| - public String toString() { |
39 |
| - return this.name().toLowerCase().replace("_", "/"); |
40 |
| - } |
| 37 | + @Override |
| 38 | + public String toString() { |
| 39 | + return this.name().toLowerCase().replace("_", "/"); |
41 | 40 | }
|
| 41 | + } |
42 | 42 |
|
43 |
| - /** POJO class used for aggregating multipart/mixed analysis requests. */ |
44 |
| - class MixedReport { |
45 |
| - public final byte[] html; |
46 |
| - public final AnalysisReport json; |
47 |
| - |
48 |
| - public MixedReport(final byte[] html, final AnalysisReport json) { |
49 |
| - this.html = html; |
50 |
| - this.json = json; |
51 |
| - } |
52 |
| - |
53 |
| - public MixedReport() { |
54 |
| - this.html = new byte[0]; |
55 |
| - this.json = new AnalysisReport(); |
56 |
| - } |
57 |
| - |
58 |
| - @Override |
59 |
| - public boolean equals(final Object o) { |
60 |
| - if (this == o) return true; |
61 |
| - if (o == null || this.getClass() != o.getClass()) return false; |
62 |
| - var that = (MixedReport) o; |
63 |
| - return Arrays.equals(this.html, that.html) && Objects.equals(this.json, that.json); |
64 |
| - } |
65 |
| - |
66 |
| - @Override |
67 |
| - public int hashCode() { |
68 |
| - return 31 * Objects.hash(json) + Arrays.hashCode(html); |
69 |
| - } |
| 43 | + /** POJO class used for aggregating multipart/mixed analysis requests. */ |
| 44 | + class MixedReport { |
| 45 | + public final byte[] html; |
| 46 | + public final AnalysisReport json; |
| 47 | + |
| 48 | + public MixedReport(final byte[] html, final AnalysisReport json) { |
| 49 | + this.html = html; |
| 50 | + this.json = json; |
| 51 | + } |
| 52 | + |
| 53 | + public MixedReport() { |
| 54 | + this.html = new byte[0]; |
| 55 | + this.json = new AnalysisReport(); |
70 | 56 | }
|
71 | 57 |
|
72 |
| - /** |
73 |
| - * Use for creating a stack analysis HTML report for a given manifest file. |
74 |
| - * |
75 |
| - * @param manifestFile the path for the manifest file |
76 |
| - * @return a mixed reports for both HTML and JSON wrapped in a CompletableFuture |
77 |
| - * @throws IOException when failed to load the manifest file |
78 |
| - */ |
79 |
| - CompletableFuture<MixedReport> stackAnalysisMixed(String manifestFile) throws IOException; |
80 |
| - |
81 |
| - /** |
82 |
| - * Use for creating a stack analysis HTML report for a given manifest file. |
83 |
| - * |
84 |
| - * @param manifestFile the path for the manifest file |
85 |
| - * @return the HTML report as a String wrapped in a CompletableFuture |
86 |
| - * @throws IOException when failed to load the manifest file |
87 |
| - */ |
88 |
| - CompletableFuture<byte[]> stackAnalysisHtml(String manifestFile) throws IOException; |
89 |
| - |
90 |
| - /** |
91 |
| - * Use for creating a stack analysis deserialized Json report for a given manifest file. |
92 |
| - * |
93 |
| - * @param manifestFile the path for the manifest file |
94 |
| - * @return the deserialized Json report as an AnalysisReport wrapped in a CompletableFuture |
95 |
| - * @throws IOException when failed to load the manifest file |
96 |
| - */ |
97 |
| - CompletableFuture<AnalysisReport> stackAnalysis(String manifestFile) throws IOException; |
98 |
| - |
99 |
| - /** |
100 |
| - * Use for creating a component analysis deserialized Json report for a given type and content. |
101 |
| - * |
102 |
| - * @param manifestType the type of the manifest, i.e. {@code pom.xml} |
103 |
| - * @param manifestContent a byte array of the manifest's content |
104 |
| - * @return the deserialized Json report as an AnalysisReport wrapped in a CompletableFuture |
105 |
| - * @throws IOException when failed to load the manifest content |
106 |
| - */ |
107 |
| - CompletableFuture<AnalysisReport> componentAnalysis(String manifestType, byte[] manifestContent) throws IOException; |
108 |
| - |
109 |
| - CompletableFuture<AnalysisReport> componentAnalysis(String manifestFile) throws IOException; |
110 |
| - |
111 |
| - CompletableFuture<Map<ImageRef, AnalysisReport>> imageAnalysis(Set<ImageRef> imageRefs) throws IOException; |
112 |
| - |
113 |
| - CompletableFuture<byte[]> imageAnalysisHtml(Set<ImageRef> imageRefs) throws IOException; |
| 58 | + @Override |
| 59 | + public boolean equals(final Object o) { |
| 60 | + if (this == o) return true; |
| 61 | + if (o == null || this.getClass() != o.getClass()) return false; |
| 62 | + var that = (MixedReport) o; |
| 63 | + return Arrays.equals(this.html, that.html) && Objects.equals(this.json, that.json); |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public int hashCode() { |
| 68 | + return 31 * Objects.hash(json) + Arrays.hashCode(html); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Use for creating a stack analysis HTML report for a given manifest file. |
| 74 | + * |
| 75 | + * @param manifestFile the path for the manifest file |
| 76 | + * @return a mixed reports for both HTML and JSON wrapped in a CompletableFuture |
| 77 | + * @throws IOException when failed to load the manifest file |
| 78 | + */ |
| 79 | + CompletableFuture<MixedReport> stackAnalysisMixed(String manifestFile) throws IOException; |
| 80 | + |
| 81 | + /** |
| 82 | + * Use for creating a stack analysis HTML report for a given manifest file. |
| 83 | + * |
| 84 | + * @param manifestFile the path for the manifest file |
| 85 | + * @return the HTML report as a String wrapped in a CompletableFuture |
| 86 | + * @throws IOException when failed to load the manifest file |
| 87 | + */ |
| 88 | + CompletableFuture<byte[]> stackAnalysisHtml(String manifestFile) throws IOException; |
| 89 | + |
| 90 | + /** |
| 91 | + * Use for creating a stack analysis deserialized Json report for a given manifest file. |
| 92 | + * |
| 93 | + * @param manifestFile the path for the manifest file |
| 94 | + * @return the deserialized Json report as an AnalysisReport wrapped in a CompletableFuture |
| 95 | + * @throws IOException when failed to load the manifest file |
| 96 | + */ |
| 97 | + CompletableFuture<AnalysisReport> stackAnalysis(String manifestFile) throws IOException; |
| 98 | + |
| 99 | + /** |
| 100 | + * Use for creating a component analysis deserialized Json report for a given type and content. |
| 101 | + * |
| 102 | + * @param manifestType the type of the manifest, i.e. {@code pom.xml} |
| 103 | + * @param manifestContent a byte array of the manifest's content |
| 104 | + * @return the deserialized Json report as an AnalysisReport wrapped in a CompletableFuture |
| 105 | + * @throws IOException when failed to load the manifest content |
| 106 | + */ |
| 107 | + CompletableFuture<AnalysisReport> componentAnalysis(String manifestType, byte[] manifestContent) |
| 108 | + throws IOException; |
| 109 | + |
| 110 | + CompletableFuture<AnalysisReport> componentAnalysis(String manifestFile) throws IOException; |
| 111 | + |
| 112 | + CompletableFuture<Map<ImageRef, AnalysisReport>> imageAnalysis(Set<ImageRef> imageRefs) |
| 113 | + throws IOException; |
| 114 | + |
| 115 | + CompletableFuture<byte[]> imageAnalysisHtml(Set<ImageRef> imageRefs) throws IOException; |
114 | 116 | }
|
0 commit comments