本文整理汇总了Java中javax.ws.rs.NotSupportedException类的典型用法代码示例。如果您正苦于以下问题:Java NotSupportedException类的具体用法?Java NotSupportedException怎么用?Java NotSupportedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotSupportedException类属于javax.ws.rs包,在下文中一共展示了NotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertValue
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
public Value convertValue(Object object) {
if (object instanceof Value) {
return (Value) object;
}
ValueFactory valueFactory = SimpleValueFactory.getInstance();
if (object instanceof String) {
return valueFactory.createLiteral((String) object);
}
if (object instanceof Integer) {
return valueFactory.createLiteral((Integer) object);
}
if (object instanceof Double) {
return valueFactory.createLiteral((Double) object);
}
throw new NotSupportedException("Value is not supported: " + object.getClass());
}
示例2: toResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
public Response toResponse(Exception e) {
WrapperResponseEntity response = null;
if (e instanceof NotFoundException) {
response = new WrapperResponseEntity(ResponseCode.NOT_FOUND);
} else if (e instanceof NotAllowedException) {
response = new WrapperResponseEntity(ResponseCode.FORBIDDEN);
} else if (e instanceof JsonProcessingException) {
response = new WrapperResponseEntity(ResponseCode.ERROR_JSON);
} else if (e instanceof NotSupportedException) {
response = new WrapperResponseEntity(ResponseCode.UNSUPPORTED_MEDIA_TYPE);
} else {
response = excetionWrapper != null ? excetionWrapper.toResponse(e) : null;
if (response == null)
response = new WrapperResponseEntity(ResponseCode.INTERNAL_SERVER_ERROR);
}
return Response.status(response.httpStatus()).type(MediaType.APPLICATION_JSON)
.entity(response).build();
}
示例3: toResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
public Response toResponse(Exception e) {
WrapperResponseEntity response = null;
if (e instanceof NotFoundException) {
response = new WrapperResponseEntity(ResponseCode.NOT_FOUND);
} else if (e instanceof NotAllowedException) {
response = new WrapperResponseEntity(ResponseCode.FORBIDDEN);
} else if (e instanceof JsonProcessingException) {
response = new WrapperResponseEntity(ResponseCode.ERROR_JSON);
} else if (e instanceof NotSupportedException) {
response = new WrapperResponseEntity(ResponseCode.UNSUPPORTED_MEDIA_TYPE);
} else {
response = excetionWrapper != null ? excetionWrapper.toResponse(e) : null;
if(response == null)response = new WrapperResponseEntity(ResponseCode.INTERNAL_SERVER_ERROR);
}
return Response.status(response.httpStatus()).type(MediaType.APPLICATION_JSON).entity(response).build();
}
示例4: testCreateException
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Test
public void testCreateException() {
assertExceptionType(Response.Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class);
assertExceptionType(Response.Status.NOT_FOUND, NotFoundException.class);
assertExceptionType(Response.Status.FORBIDDEN, ForbiddenException.class);
assertExceptionType(Response.Status.BAD_REQUEST, BadRequestException.class);
assertExceptionType(Response.Status.METHOD_NOT_ALLOWED, NotAllowedException.class);
assertExceptionType(Response.Status.UNAUTHORIZED, NotAuthorizedException.class);
assertExceptionType(Response.Status.NOT_ACCEPTABLE, NotAcceptableException.class);
assertExceptionType(Response.Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class);
assertExceptionType(Response.Status.SERVICE_UNAVAILABLE, ServiceUnavailableException.class);
assertExceptionType(Response.Status.TEMPORARY_REDIRECT, RedirectionException.class);
assertExceptionType(Response.Status.LENGTH_REQUIRED, ClientErrorException.class);
assertExceptionType(Response.Status.BAD_GATEWAY, ServerErrorException.class);
assertExceptionType(Response.Status.NO_CONTENT, WebApplicationException.class);
}
示例5: loginDialog
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
public void loginDialog(String message) {
try {
if (!getTrpSets().isServerSideActivated()) {
throw new NotSupportedException("Connecting to the server not supported yet!");
}
// detachListener();
if (loginDialog != null && !loginDialog.isDisposed()) {
loginDialog.close();
}
List<String> storedUsers = TrpGuiPrefs.getUsers();
loginDialog = new TrpLoginDialog(getShell(), this, message, storedUsers.toArray(new String[0]), TrpServerConn.SERVER_URIS, TrpServerConn.DEFAULT_URI_INDEX);
loginDialog.open();
// attachListener();
} catch (Throwable e) {
onError("Error during login", "Unable to login to server", e);
ui.updateLoginInfo(false, "", "");
}
}
示例6: writeTo
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void writeTo(PMessage entity,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException, WebApplicationException {
try {
provider.getSerializer(mediaType.toString())
.serialize(entityStream, entity);
} catch (NotSupportedException e) {
throw new ProcessingException("Unknown media type: " + mediaType, e);
} catch (SerializerException se) {
throw new ProcessingException("Unable to serialize entity", se);
}
}
示例7: toResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
public Response toResponse(NotSupportedException exception) {
return ExceptionMapperUtils.buildResponse(exception, Response.Status.UNSUPPORTED_MEDIA_TYPE);
}
示例8: toResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Response toResponse(final NotSupportedException exception) {
if (L.isDebugEnabled()) {
L.debug(R.getString("D-REST-JERSEY-MAPPER#0009"));
}
ErrorMessage error = ErrorMessages.create(exception)
.code(ErrorCode.UNSUPPORTED_MEDIA_TYPE.code())
.resolve()
.get();
L.warn(error.log(), exception);
return Response.status(exception.getResponse().getStatusInfo())
.entity(error)
.type(MediaType.APPLICATION_JSON)
.build();
}
示例9: send
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
private void send(Collection<Trace> traces) {
try {
apmApi.reportTraces(traces);
} catch (NotFoundException | NotSupportedException cee) {
// 404, 415
if (apmApi instanceof ApmApi0_3) {
log.info("falling back to json");
fallbackTo0_2();
send(traces);
}
} catch (BadRequestException bre) {
log.error("{}: {}", bre.getMessage(), traces);
}
}
示例10: toResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
public Response toResponse(NotSupportedException e) {
return Response.status(Response.Status.UNSUPPORTED_MEDIA_TYPE)
.entity(new org.crunchytorch.coddy.application.data.Response(e.getMessage()))
.type(MediaType.APPLICATION_JSON)
.build();
}
示例11: handleErrorStatus
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
private static <T> T handleErrorStatus(Response response) {
final int status = response.getStatus();
switch (status) {
case 400:
throw new BadRequestException(response);
case 401:
throw new NotAuthorizedException(response);
case 404:
throw new NotFoundException(response);
case 405:
throw new NotAllowedException(response);
case 406:
throw new NotAcceptableException(response);
case 415:
throw new NotSupportedException(response);
case 500:
throw new InternalServerErrorException(response);
case 503:
throw new ServiceUnavailableException(response);
default:
break;
}
if (status >= 400 && status < 500){
throw new ClientErrorException(response);
} else if (status >= 500) {
throw new ServerErrorException(response);
}
throw new WebApplicationException(response);
}
示例12: bindExceptionhandlers
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
protected void bindExceptionhandlers(ApplicationBindingBuilder builder)
{
builder
.addProviderInstance(new GenericJsonExceptionHandler<ResourceNotFoundException>(Response.Status.NOT_FOUND) { })
.addProviderInstance(new GenericJsonExceptionHandler<StorageFileNotFoundException>(Response.Status.NOT_FOUND) { })
.addProviderInstance(new GenericJsonExceptionHandler<ResourceConflictException>(Response.Status.CONFLICT) { })
.addProviderInstance(new GenericJsonExceptionHandler<NotSupportedException>(Response.Status.BAD_REQUEST) { })
.addProviderInstance(new GenericJsonExceptionHandler<IOException>(Response.Status.BAD_REQUEST) { }) // happens if input is not gzip
.addProviderInstance(new GenericJsonExceptionHandler<ModelValidationException>(Response.Status.BAD_REQUEST) { })
.addProviderInstance(new GenericJsonExceptionHandler<ConfigException>(Response.Status.BAD_REQUEST) { })
.addProviderInstance(new GenericJsonExceptionHandler<IllegalArgumentException>(Response.Status.BAD_REQUEST) { })
.addProviderInstance(new GenericJsonExceptionHandler<ResourceLimitExceededException>(Response.Status.BAD_REQUEST) { })
;
}
示例13: create
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
/**
* POST method for creating an instance of ReservationResource
*
* @param content representation for the new resource
* @return an HTTP response with content of the created resource
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response create(String content) {
throw new NotSupportedException();
}
示例14: toApiErrorResponse
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
@Override
protected ApiErrorResponse toApiErrorResponse(NotSupportedException exception) {
return new ApiErrorResponse(
"The media type of the request body is unsupported.",
getCode(),
getLocationType(),
"Content-Type"
);
}
示例15: setValueFromResultSet
import javax.ws.rs.NotSupportedException; //导入依赖的package包/类
/**
* @see DataValueDescriptor#setValueFromResultSet
*
*/
public void setValueFromResultSet(ResultSet resultSet, int colNumber,
boolean isNullable) throws SQLException {
Array array = resultSet.getArray(colNumber);
int type = array.getBaseType();
throw new NotSupportedException("still need to implement " + array + " : " + type);
}