|
15 | 15 | */
|
16 | 16 | package com.redhat.exhort;
|
17 | 17 |
|
| 18 | +import com.redhat.exhort.api.AnalysisReport; |
| 19 | +import com.redhat.exhort.image.ImageRef; |
18 | 20 | import java.io.IOException;
|
19 | 21 | import java.util.Arrays;
|
20 | 22 | import java.util.Map;
|
21 | 23 | import java.util.Objects;
|
22 | 24 | import java.util.Set;
|
23 | 25 | import java.util.concurrent.CompletableFuture;
|
24 | 26 |
|
25 |
| -import com.redhat.exhort.api.AnalysisReport; |
26 |
| -import com.redhat.exhort.image.ImageRef; |
27 |
| - |
28 | 27 | /** The Api interface is used for contracting API implementations. **/
|
29 | 28 | public interface Api {
|
30 | 29 |
|
31 |
| - public static final String CYCLONEDX_MEDIA_TYPE = "application/vnd.cyclonedx+json"; |
| 30 | + public static final String CYCLONEDX_MEDIA_TYPE = "application/vnd.cyclonedx+json"; |
32 | 31 |
|
33 |
| - enum MediaType { |
34 |
| - APPLICATION_JSON, |
35 |
| - TEXT_HTML, |
36 |
| - MULTIPART_MIXED; |
| 32 | + enum MediaType { |
| 33 | + APPLICATION_JSON, |
| 34 | + TEXT_HTML, |
| 35 | + MULTIPART_MIXED; |
37 | 36 |
|
38 |
| - @Override |
39 |
| - public String toString() { |
40 |
| - return this.name().toLowerCase().replace("_", "/"); |
| 37 | + @Override |
| 38 | + public String toString() { |
| 39 | + return this.name().toLowerCase().replace("_", "/"); |
| 40 | + } |
41 | 41 | }
|
42 |
| - } |
43 | 42 |
|
44 |
| - /** POJO class used for aggregating multipart/mixed analysis requests. */ |
45 |
| - class MixedReport { |
46 |
| - final public byte[] html; |
47 |
| - final public AnalysisReport json; |
48 |
| - |
49 |
| - public MixedReport(final byte[] html, final AnalysisReport json) { |
50 |
| - this.html = html; |
51 |
| - this.json = json; |
52 |
| - } |
53 |
| - public MixedReport() |
54 |
| - { |
55 |
| - this.html = new byte[0]; |
56 |
| - this.json = new AnalysisReport(); |
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); |
| 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 | + } |
64 | 70 | }
|
65 | 71 |
|
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) 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; |
| 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; |
114 | 114 | }
|
0 commit comments