Remove unused imports and catch exceptions when parsing content type
This commit is contained in:
parent
f489198551
commit
e4708412a3
@ -1,7 +1,5 @@
|
||||
package org.bigbluebutton.api.model.validator;
|
||||
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import org.apache.commons.compress.utils.Sets;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.bigbluebutton.api.model.constraint.ContentTypeConstraint;
|
||||
import org.bigbluebutton.api.model.request.Request;
|
||||
@ -11,7 +9,6 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.Set;
|
||||
|
||||
public class ContentTypeValidator implements ConstraintValidator<ContentTypeConstraint, Request> {
|
||||
|
||||
@ -32,11 +29,15 @@ public class ContentTypeValidator implements ConstraintValidator<ContentTypeCons
|
||||
if (requestBodyPresent) {
|
||||
if (contentType == null || contentTypeHeader == null) return false;
|
||||
else {
|
||||
ContentType c = ContentType.parse(contentType);
|
||||
String mimeType = c.getMimeType();
|
||||
for (Object o: request.getSupportedContentTypes()) {
|
||||
String supportedContentType = (String) o;
|
||||
if (mimeType.equalsIgnoreCase(supportedContentType)) return true;
|
||||
try {
|
||||
ContentType c = ContentType.parse(contentType);
|
||||
String mimeType = c.getMimeType();
|
||||
for (Object o: request.getSupportedContentTypes()) {
|
||||
String supportedContentType = (String) o;
|
||||
if (mimeType.equalsIgnoreCase(supportedContentType)) return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user