Java 类javax.ws.rs.NotSupportedException 实例源码

项目:dotwebstack-framework    文件:SparqlHttpStub.java   
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());
}
项目:azeroth    文件:BaseExceptionMapper.java   
@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();
}
项目:jeesuite-libs    文件:BaseExceptionMapper.java   
@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();
}
项目:microbule    文件:AbstractErrorResponseStrategyTest.java   
@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);
}
项目:TranskribusSwtGui    文件:TrpMainWidget.java   
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, "", "");
    }
}
项目:providence    文件:ProvidenceMessageBodyWriter.java   
@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);
    }
}
项目:hawkular-metrics    文件:NotSupportedExceptionMapper.java   
@Override
public Response toResponse(NotSupportedException exception) {
    return ExceptionMapperUtils.buildResponse(exception, Response.Status.UNSUPPORTED_MEDIA_TYPE);
}
项目:sinavi-jfw    文件:NotSupportedExceptionMapper.java   
/**
 * {@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();
}
项目:apm-client    文件:Writer.java   
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);
  }
}
项目:coddy    文件:NotSupportedMapper.java   
@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();
}
项目:blaze-storage    文件:ResponseObjectInvocation.java   
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);
}
项目:digdag    文件:ServerModule.java   
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) { })
        ;
}
项目:fablab-web    文件:ReservationsResource.java   
/**
 * 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();
}
项目:jee-rest    文件:NotSupportedExceptionMapper.java   
@Override
protected ApiErrorResponse toApiErrorResponse(NotSupportedException exception) {
    return new ApiErrorResponse(
        "The media type of the request body is unsupported.", 
        getCode(), 
        getLocationType(), 
        "Content-Type"
    );
}
项目:spliceengine    文件:SQLArray.java   
/**
 * @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);
}
项目:cfsummiteu2017    文件:OpenstackPlatformService.java   
@Override
public ServiceInstance updateInstance(ServiceInstance instance, Plan plan) {
    throw new NotSupportedException("Updating Service Instances is currently not supported");
}
项目:com-liferay-apio-architect    文件:NotSupportedExceptionConverter.java   
@Override
public APIError convert(NotSupportedException exception) {
    return super.convert(exception);
}
项目:hawkcd    文件:ServerService.java   
@Override
public ServiceResult delete(Server server){
    throw  new NotSupportedException("Delete Operation on Server object is not supported");
}
项目:TranskribusSwtGui    文件:TrpMainWidget.java   
public boolean login(String server, String user, String pw, boolean rememberCredentials) throws ClientVersionNotSupportedException, LoginException, Exception {
//      try {
            if (!getTrpSets().isServerSideActivated()) {
                throw new NotSupportedException("Connecting to the server not supported yet!");
            }

            storage.login(server, user, pw);
            if (rememberCredentials) { // store credentials on successful login
                logger.debug("storing credentials for user: " + user);
                TrpGuiPrefs.storeCredentials(user, pw);
            }
            TrpGuiPrefs.storeLastLogin(user);
            TrpGuiPrefs.storeLastAccountType(OAuthGuiUtil.TRANSKRIBUS_ACCOUNT_TYPE);

            storage.reloadCollections();

            userCache.add(user);

            if (sessionExpired && !lastLoginServer.equals(server)) {
                closeCurrentDocument(true);
            }

            sessionExpired = false;
            lastLoginServer = server;
            return true;
//      }
//      catch (ClientVersionNotSupportedException e) {
//          DialogUtil.showErrorMessageBox(getShell(), "Version not supported anymore!", e.getMessage());
//          logger.error(e.getMessage(), e);
//          return false;
//      }
//      catch (LoginException e) {
//          logout(true, false);
//          logger.error(e.getMessage(), e);
//          return false;
//      }
//      catch (Exception e) {
//          logout(true, false);
//          logger.error(e.getMessage(), e);
//          return false;
//      }

        // finally {
        // ui.updateLoginInfo(storage.isLoggedIn(), getCurrentUserName(),
        // storage.getCurrentServer());
        // }
    }
项目:micro-server    文件:GeneralExceptionMapperTest.java   
@Test
public void whenWebApplicationException_thenUnsupportedMediaType() {

    assertThat(mapper.toResponse(new NotSupportedException(Response.status(Status.UNSUPPORTED_MEDIA_TYPE).build()))
                            .getStatus(), is(Status.UNSUPPORTED_MEDIA_TYPE.getStatusCode()));
}
项目:providence    文件:ProvidenceMessageBodyReader.java   
@Nonnull
private PMessageDescriptor getDescriptorOrFail(Class<?> type) {
    PMessageDescriptor descriptor = getDescriptor(type);
    if (descriptor == null) throw new NotSupportedException("No providence descriptor for class " + type.getName());
    return descriptor;
}
项目:che    文件:AbstractPerspectiveActionTest.java   
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
  throw new NotSupportedException("Method isn't supported in current mode...");
}
项目:che    文件:AbstractPerspectiveActionTest.java   
@Override
public void actionPerformed(ActionEvent e) {
  throw new NotSupportedException("Method isn't supported in current mode...");
}
项目:che    文件:AbstractPerspectiveTest.java   
@Override
public void go(@NotNull AcceptsOneWidget container) {
  throw new NotSupportedException(
      "This method will be tested in the class which extends AbstractPerspective");
}
项目:nakadi    文件:FeatureToggleServiceDefault.java   
@Override
public void setFeature(final FeatureWrapper feature) {
    throw new NotSupportedException();
}
项目:carbon-uuf    文件:MicroserviceHttpRequest.java   
public MicroserviceHttpRequest(Request request, MultivaluedMap<String, ?> formParams, Object postParams) {

        this.msf4jRequest = request;
        this.method = request.getHttpMethod();
        this.isGetRequest = REQUEST_GET.equals(method);

        // process URI
        String rawUri = request.getUri();
        int uriPathEndIndex = rawUri.indexOf('?');
        String rawUriPath, rawQueryString;
        if (uriPathEndIndex == -1) {
            rawUriPath = rawUri;
            rawQueryString = null;
        } else {
            rawUriPath = rawUri.substring(0, uriPathEndIndex);
            rawQueryString = rawUri.substring(uriPathEndIndex + 1, rawUri.length());
        }
        this.uri = QueryStringDecoder.decodeComponent(rawUriPath);
        this.contextPath = HttpRequest.getContextPath(this.uri);
        this.uriWithoutContextPath = HttpRequest.getUriWithoutContextPath(this.uri);
        this.queryString = rawQueryString; // Query string is not very useful, so we don't bother to decode it.
        if (rawQueryString != null) {
            HashMap<String, Object> map = new HashMap<>();
            new QueryStringDecoder(rawQueryString, false).parameters()
                    .forEach((key, value) -> map.put(key, (value.size() == 1) ? value.get(0) : value));
            this.queryParams = map;
        } else {
            this.queryParams = Collections.emptyMap();
        }

        // process headers and cookies
        this.headers = new HashMap<>();
        request.getHeaders().getAll().forEach(header -> this.headers.put(header.getName(), header.getValue()));
        String cookieHeader = this.headers.get(HttpHeaders.COOKIE);
        this.cookies = (cookieHeader == null) ? Collections.emptyMap() :
                ServerCookieDecoder.STRICT.decode(cookieHeader).stream().collect(Collectors.toMap(Cookie::name,
                                                                                                  c -> c));

        // process POST data
        if (formParams == null) {
            // This request is not a form POST submission.
            this.files = Collections.emptyMap();
            if (postParams == null) {
                this.formParams = Collections.emptyMap();
            } else {
                if (postParams instanceof List) {
                    List<?> postParamsList = (List<?>) postParams;
                    this.formParams = new HashMap<>(postParamsList.size());
                    for (int i = 0; i < postParamsList.size(); i++) {
                        this.formParams.put(Integer.toString(i), postParamsList.get(i));
                    }
                } else if (postParams instanceof Map) {
                    this.formParams = (Map<String, Object>) postParams;
                } else {
                    throw new NotSupportedException(
                            "Unsupported JSON data type. Expected Map or List. Instead found '" +
                                    postParams.getClass().getName() + "'.");
                }
            }
        } else {
            this.formParams = new HashMap<>();
            this.files = new HashMap<>();
            for (Map.Entry<String, ? extends List<?>> entry : formParams.entrySet()) {
                List<?> values = entry.getValue();
                if (values.isEmpty()) {
                    continue;
                }
                if (values.get(0) instanceof File) {
                    this.files.put(entry.getKey(), (values.size() == 1) ? values.get(0) : values);
                } else {
                    this.formParams.put(entry.getKey(), (values.size() == 1) ? values.get(0) : values);
                }
            }
        }
    }
项目:sinavi-jfw    文件:NotSupportedExceptionResourceTest.java   
@GET
public EmptyTest exception() {
    throw new NotSupportedException();
}
项目:PANDA-DEEPLINKING    文件:ResourceCache.java   
/**
 * Traversing of subtree for requested values.
 * 
 * @param node current node
 * @param pathSegments all path segments of request URI
 * @param currentSegment index of current path segment
 * @param path path to current node
 * @param resourceType type of resource
 * @return list of values gathered from cache tree as {@code List<Value>}
 */
private List<Value> traverseCacheTree(CacheTreeNode node, LinkedList<String> pathSegments,
        int currentSegment, String path, DataResourceType resourceType) {
    List<Value> valList = new LinkedList<Value>();
    String pathSegment;
    if (currentSegment < pathSegments.size()) {
        pathSegment = pathSegments.get(currentSegment);
    } else {
        return valList;
    }

    Set<String> keys = new HashSet<String>();

    if (pathSegment.equals("*")) {
        keys = node.getKeySet();
    } else if (pathSegment.split(pandaSettings.getRangeDelimiterChar()).length == 2) {
        String[] token = pathSegment.split(pandaSettings.getRangeDelimiterChar());
        keys = node.getKeySubset(token[0], token[1]);
    } else {
        keys = node.getKeySubset(pathSegment, pathSegment);
    }

    for (String key : keys) {
        String newPath;
        Object obj = node.getChild(key);
        if (obj instanceof Value) {
            newPath = handleOutputURI(path + "/" + key, resourceType);
            Value val = (Value) obj;
            val.setSubURI(newPath);
            valList.add(val);
        } else if (obj instanceof CacheTreeNode) {
            newPath = path + "/" + key;
            valList.addAll(traverseCacheTree((CacheTreeNode) obj, pathSegments,
                    currentSegment + 1, newPath, resourceType));
        } else {
            throw new NotSupportedException("Unknown node type in CacheTree!");
        }
    }

    return valList;
}
项目:PANDA-DEEPLINKING    文件:ResourceCache.java   
/**
 * Get start node for cache tree by traversing baseURI.
 * 
 * @param pathSegments path segments of request URI
 * @param node current node
 * @param baseURI current determined baseURI
 * @param resourceType type of resource
 * @return start node for cache tree traversing as {@code CacheTreeNode}
 */
private CacheTreeNode getStartNode(LinkedList<String> pathSegments, CacheTreeNode node,
        StringBuilder baseURI, DataResourceType resourceType) {
    CacheTreeNode currentNode = node;
    baseURI.append("/");

    int minBaseUriSegments = getMinBaseUriPathSegments(resourceType);
    int startSubUri = pathSegments.size() - getMinSubUriPathSegments(resourceType);

    Iterator<String> iter = pathSegments.iterator();
    for (int count = 0; iter.hasNext(); count++) {
        String pathSegment = iter.next();

        // get next child node if:
        // - it is the first node (head of resource subtree)
        // - path segment is not a bulk request
        // - current path segment is not part spared for subURI
        // - segment shall be ignored (e.g. inserted extra segments)
        if (((!pathSegment.equals("*")
                && pathSegment.split(pandaSettings.getRangeDelimiterChar()).length < 2 && count < startSubUri))
                || count < minBaseUriSegments) {

            if (!currentNode.containsKey(pathSegment)) {
                throw new WebApplicationException(404);
            }

            Object obj = currentNode.getChild(pathSegment);
            if (obj instanceof CacheTreeNode) {
                currentNode = (CacheTreeNode) obj;
                baseURI.append(pathSegment + "/");
                iter.remove();
            } else {
                throw new NotSupportedException(
                        "Starting node for traversion of CacheTree shall not be a leaf.");
            }
        } else {
            // bulk segment found, traversing will branch here
            break;
        }
    }

    return currentNode;
}
项目:jqm    文件:ServiceClient.java   
public int enqueue(JobRequest jd)
{
    throw new NotSupportedException();
}
项目:jqm    文件:ServiceClient.java   
@Override
public int enqueue(String applicationName, String userName)
{
    throw new NotSupportedException();
}
项目:jqm    文件:ServiceClient.java   
@Override
public int getJobProgress(int jobId)
{
    throw new NotSupportedException();
}
项目:jqm    文件:ServiceClient.java   
@Override
public List<InputStream> getJobDeliverablesContent(int jobId)
{
    throw new NotSupportedException();
}
项目:usergrid    文件:UnsupportedMediaTypeMapper.java   
@Override
public Response toResponse( NotSupportedException e ) {

    logger.error( "Unsupported media type", e );

    return toResponse( UNSUPPORTED_MEDIA_TYPE, e );
}
项目:spliceengine    文件:SQLArray.java   
@Override
public void writeArray(UnsafeArrayWriter unsafeArrayWriter, int ordinal) throws StandardException {
    throw new NotSupportedException("Nested Arrays Not Supported Currently");
}
项目:spliceengine    文件:SQLArray.java   
@Override
public void read(UnsafeArrayData unsafeArrayData, int ordinal) throws StandardException {
    throw new NotSupportedException("Nested Arrays Not Supported Currently");
}