Skip to content

Commit 34c9ede

Browse files
committed
Merge branch 'SentryMan-roles-again'
2 parents a324af1 + 86e9aec commit 34c9ede

File tree

8 files changed

+25
-19
lines changed

8 files changed

+25
-19
lines changed

http-generator-core/src/main/java/io/avaje/http/generator/core/Util.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import javax.lang.model.type.TypeKind;
99
import javax.lang.model.type.TypeMirror;
1010
import javax.lang.model.util.SimpleAnnotationValueVisitor8;
11-
import java.util.*;
11+
import java.util.ArrayList;
12+
import java.util.Collections;
13+
import java.util.List;
1214

1315
public class Util {
1416

@@ -38,7 +40,7 @@ public static String typeDef(TypeMirror typeMirror) {
3840
}
3941
}
4042

41-
public static String trimAnnotations(String type) {
43+
public static String trimAnnotations(String type) {
4244
int pos = type.indexOf("@");
4345
if (pos == -1) {
4446
return type;
@@ -72,10 +74,14 @@ static String combinePath(String beanPath, String webMethodPath) {
7274
}
7375

7476
public static String shortName(String fullType) {
77+
return shortName(fullType, false);
78+
}
79+
80+
public static String shortName(String fullType, boolean role) {
7581
int p = fullType.lastIndexOf('.');
7682
if (p == -1) {
7783
return fullType;
78-
} else if (fullType.startsWith("java")) {
84+
} else if (fullType.startsWith("java") || role) {
7985
return fullType.substring(p + 1);
8086
} else {
8187
var result = "";

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/ControllerMethodWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void write(boolean requestScoped) {
7878
if (i > 0) {
7979
writer.append(", ");
8080
}
81-
writer.append(Util.shortName(roles.get(i)));
81+
writer.append(Util.shortName(roles.get(i), true));
8282
}
8383
}
8484
writer.append(");").eol().eol();

http-generator-jex/src/main/java/io/avaje/http/generator/jex/ControllerMethodWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void write(boolean requestScoped) {
8181
if (i > 0) {
8282
writer.append(", ");
8383
}
84-
writer.append(Util.shortName(roles.get(i)));
84+
writer.append(Util.shortName(roles.get(i), true));
8585
}
8686
}
8787
writer.append(");").eol().eol();

tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<assertj.version>3.24.1</assertj.version>
2020
<jackson.version>2.14.1</jackson.version>
2121
<jex.version>2.5</jex.version>
22-
<avaje-inject.version>8.12-RC1</avaje-inject.version>
22+
<avaje-inject.version>8.12-RC3</avaje-inject.version>
2323
</properties>
2424

2525
<modules>

tests/test-javalin-jsonb/src/main/java/org/example/myapp/web/test/OpenAPIController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,18 @@ Person testPost(Person b) {
7575
description = "Some other Error",
7676
type = ErrorResponse.class)
7777
})
78-
Person testPostl(List<Person> m) {
79-
78+
Person testPostList(List<Person> m) {
8079
return new Person(0, "baby");
8180
}
8281

8382
@Put("/put")
8483
@Produces(value = MediaType.TEXT_PLAIN, defaultStatus = 203)
8584
@OpenAPIResponse(responseCode = "204", type = String.class)
8685
String testDefaultStatus(Context ctx) {
87-
8886
if (ctx.contentType().equals(MediaType.APPLICATION_PDF)) {
8987
ctx.status(204);
9088
return "";
9189
}
92-
9390
return "only partial info";
9491
}
9592
}

tests/test-javalin-jsonb/src/main/java/org/example/myapp/web/test/TestController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
import java.util.Map;
55
import java.util.Set;
66

7+
import org.example.myapp.web.AppRoles;
8+
import org.example.myapp.web.Roles;
9+
710
import io.avaje.http.api.Controller;
811
import io.avaje.http.api.Form;
912
import io.avaje.http.api.Get;
1013
import io.avaje.http.api.Header;
14+
import io.avaje.http.api.MatrixParam;
1115
import io.avaje.http.api.MediaType;
1216
import io.avaje.http.api.Path;
1317
import io.avaje.http.api.Post;
1418
import io.avaje.http.api.Produces;
1519
import io.avaje.http.api.Put;
16-
import io.avaje.http.api.MatrixParam;
1720
import io.javalin.http.Context;
1821

1922
@Path("test/")
2023
@Controller
24+
@Roles(AppRoles.ANYONE)
2125
public class TestController {
2226

2327
@Get
@@ -40,7 +44,6 @@ byte[] testBytes() {
4044

4145
@Get("/ctx")
4246
void testVoid(Context ctx) {
43-
4447
ctx.result("success path:" + ctx.path());
4548
}
4649

@@ -107,7 +110,8 @@ String testForm(String name, String email, String url) {
107110
String testFormBean(MyForm form) {
108111
return form.name + "|" + form.email + "|" + form.url;
109112
}
110-
113+
114+
@Roles(AppRoles.ADMIN)
111115
@Get("/withMatrixParam/{type-1;category;vendor-34}/{range;style}")
112116
void neo(
113117
@MatrixParam("type-1") String type,
@@ -116,6 +120,6 @@ void neo(
116120
String range,
117121
String style) {
118122

119-
System.out.println("Ever have that feeling where you're not sure if you're awake or dreaming?");
123+
System.out.println("Ever have that feeling where you're not sure if you're awake or dreaming?");
120124
}
121125
}

tests/test-nima-jsonb/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
<dependency>
3737
<groupId>io.helidon.nima.webserver</groupId>
3838
<artifactId>helidon-nima-webserver</artifactId>
39-
<version>4.0.0-ALPHA2</version>
39+
<version>4.0.0-ALPHA4</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>io.helidon.nima.http.media</groupId>
4343
<artifactId>helidon-nima-http-media-jsonb</artifactId>
44-
<version>4.0.0-ALPHA2</version>
44+
<version>4.0.0-ALPHA4</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>io.avaje</groupId>

tests/test-nima/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919

20-
2120
<dependencies>
2221
<dependency>
2322
<groupId>io.avaje</groupId>
@@ -33,12 +32,12 @@
3332
<dependency>
3433
<groupId>io.helidon.nima.webserver</groupId>
3534
<artifactId>helidon-nima-webserver</artifactId>
36-
<version>4.0.0-ALPHA2</version>
35+
<version>4.0.0-ALPHA4</version>
3736
</dependency>
3837
<dependency>
3938
<groupId>io.helidon.nima.http.media</groupId>
4039
<artifactId>helidon-nima-http-media-jsonb</artifactId>
41-
<version>4.0.0-ALPHA2</version>
40+
<version>4.0.0-ALPHA4</version>
4241
</dependency>
4342

4443
<!-- <dependency>-->

0 commit comments

Comments
 (0)