Skip to content

Commit f5b2972

Browse files
committed
♻️ Some refactoring and javadoc
1 parent 6ba21b5 commit f5b2972

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

commons/src/main/java/org/restheart/exchange/MongoRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ public void setClientSession(ClientSessionImpl clientSession) {
10831083
}
10841084

10851085
/**
1086-
* @return the jsonMode as specified by jsonMode query paramter
1086+
* @return the jsonMode as specified by jsonMode query parameter
10871087
*/
10881088
public JsonMode getJsonMode() {
10891089
return jsonMode;
@@ -1179,7 +1179,7 @@ public long getRequestStartTime() {
11791179

11801180
/**
11811181
* @param dbName
1182-
* Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions
1182+
* See <a href="https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions">mongodb naming restrictions</a>
11831183
* @return
11841184
*/
11851185
public boolean isDbNameInvalid(String dbName) {
@@ -1192,7 +1192,7 @@ public boolean isDbNameInvalid(String dbName) {
11921192
|| dbName.contains("\"")
11931193
|| dbName.contains("$")
11941194
|| dbName.length() > 64
1195-
|| dbName.length() == 0);
1195+
|| dbName.isEmpty());
11961196
}
11971197

11981198
/**
@@ -1206,7 +1206,7 @@ public boolean isDbNameInvalidOnWindows() {
12061206

12071207
/**
12081208
* @param dbName
1209-
* Seehttps://docs.mongodb.org/v3.2/reference/limits/#naming-restrictions
1209+
* See <a href="https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions">mongodb naming restrictions</a>
12101210
* @return
12111211
*/
12121212
public boolean isDbNameInvalidOnWindows(String dbName) {
@@ -1221,7 +1221,7 @@ public boolean isDbNameInvalidOnWindows(String dbName) {
12211221
}
12221222

12231223
/**
1224-
* See https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions
1224+
* See <a href="https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions">mongodb naming restrictions</a>
12251225
*
12261226
* @return
12271227
*/
@@ -1231,7 +1231,7 @@ public boolean isCollectionNameInvalid() {
12311231

12321232
/**
12331233
* @param collectionName
1234-
* See https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions
1234+
* See <a href="https://www.mongodb.com/docs/manual/reference/limits/#naming-restrictions">mongodb naming restrictions</a>
12351235
* @return
12361236
*/
12371237
public boolean isCollectionNameInvalid(String collectionName) {

mongodb/src/main/java/org/restheart/mongodb/exchange/MongoRequestPropsInjector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public class MongoRequestPropsInjector {
6464

6565
/**
6666
*
67-
* @param exchange
67+
* @param exchange the exchange to inject the properties to
6868
*/
6969
public static void inject(HttpServerExchange exchange) {
7070
var request = MongoRequest.of(exchange);
@@ -258,7 +258,7 @@ public static void inject(HttpServerExchange exchange) {
258258
if (!_filter.isDocument()) {
259259
response.setInError(HttpStatus.SC_BAD_REQUEST, "illegal filter parameter, it is not a json object: " + f + " => " + f.getClass().getSimpleName());
260260
return true;
261-
} else if (_filter.asDocument().keySet().isEmpty()) {
261+
} else if (_filter.asDocument().isEmpty()) {
262262
response.setInError(HttpStatus.SC_BAD_REQUEST, "illegal filter parameter (empty json object)");
263263
return true;
264264
}
@@ -288,7 +288,7 @@ public static void inject(HttpServerExchange exchange) {
288288
if (avars != null) {
289289
Optional<String> _qvars = avars.stream().findFirst();
290290

291-
if (!_qvars.isPresent()) {
291+
if (_qvars.isEmpty()) {
292292
response.setInError(HttpStatus.SC_BAD_REQUEST, "Illegal avars parameter (empty)");
293293
return;
294294
}
@@ -386,7 +386,7 @@ public static void inject(HttpServerExchange exchange) {
386386
try {
387387
var _shardKeys = BsonDocument.parse(f);
388388

389-
if (_shardKeys.keySet().isEmpty()) {
389+
if (_shardKeys.isEmpty()) {
390390
response.setInError(HttpStatus.SC_BAD_REQUEST, "illegal shardkey parameter (empty json object)");
391391
return true;
392392
}

0 commit comments

Comments
 (0)