Package com.linkedin.restli.server

Examples of com.linkedin.restli.server.RoutingException


    {
      return DataMapUtils.read(request, recordClass);
    }
    catch (IOException e)
    {
      throw new RoutingException("Error parsing entity body: " + e.getMessage(),
                                 HttpStatus.S_400_BAD_REQUEST.getCode());
    }
  }
View Full Code Here


    for (Map.Entry<String, R> entry : batchRequest.getEntities().entrySet())
    {
      Object key = parsedKeyMap.get(entry.getKey());
      if (key == null)
      {
        throw new RoutingException(
          String.format("Batch request mismatch, URI keys: '%s'  Entity keys: '%s'",
                        ids.toString(),
                        batchRequest.getEntities().keySet().toString()),
          HttpStatus.S_400_BAD_REQUEST.getCode());
      }
      R value = DataTemplateUtil.wrap(entry.getValue().data(), valueClass);
      result.put(key, value);
    }
    if (!ids.equals(result.keySet()))
    {
      throw new RoutingException(
        String.format("Batch request mismatch, URI keys: '%s'  Entity keys: '%s'",
                      ids.toString(),
                      result.keySet().toString()),
        HttpStatus.S_400_BAD_REQUEST.getCode());
    }
View Full Code Here

        {
          value = null;
        }
        else
        {
          throw new RoutingException("Parameter '" + param.getName() + "' of method '"
              + resourceMethodDescriptor.getActionName() + "' is required", HttpStatus.S_400_BAD_REQUEST.getCode());
        }
      }
      else
      {
        try
        {
          value = template.getValue(param);
        }
        catch (TemplateOutputCastException e)
        {
          throw new RoutingException("Parameter '" + param.getName() + "' of method '"
                                         + resourceMethodDescriptor.getActionName() + "' must be of type '"
                                         + param.getType().getName() + "'",
                                     HttpStatus.S_400_BAD_REQUEST.getCode());
        }
      }
View Full Code Here

    ValidationResult result =
        ValidateDataAgainstSchema.validate(data, template.schema(), new ValidationOptions(RequiredMode.IGNORE,
                                                                                          CoercionMode.NORMAL));
    if (!result.isValid())
    {
      throw new RoutingException("Parameters of method '" + resourceMethodDescriptor.getActionName()
          + "' failed validation with error '" + result.getMessages() + "'", HttpStatus.S_400_BAD_REQUEST.getCode());
    }
    return new RestLiRequestDataImpl.Builder().entity(template).build();
  }
View Full Code Here

      int count =
          countString == null || StringUtils.isEmpty(countString.trim()) ?
              defaultCount : Integer.parseInt(countString);
      if (count < 0 || start < 0)
      {
        throw new RoutingException("start/count parameters must be non-negative", 400);
      }
      return new PagingContext(start, count, startString != null, countString != null);
    }
    catch (NumberFormatException e)
    {
      throw new RoutingException("Invalid (non-integer) start/count parameters", 400);
    }
  }
View Full Code Here

    {
      restLiServiceException = (RestLiServiceException) e;
    }
    else if (e instanceof RoutingException)
    {
      RoutingException routingException = (RoutingException) e;

      restLiServiceException =
          new RestLiServiceException(HttpStatus.fromCode(routingException.getStatus()),
                                     routingException.getMessage(),
                                     routingException);
    }
    else
    {
      restLiServiceException = new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, e.getMessage(), e);
View Full Code Here

  @DataProvider(name = "provideExceptions")
  private Object[][] provideExceptions()
  {
    return new Object[][] { { new RuntimeException("Test runtime exception") },
        { new RoutingException("Test routing exception", 404) } };
  }
View Full Code Here

    {
      contentType = new ContentType(header);
    }
    catch (ParseException e)
    {
      throw new RoutingException("Unable to parse Content-Type: " + header, HttpStatus.S_400_BAD_REQUEST.getCode(), e);
    }

    if (contentType.getBaseType().equalsIgnoreCase(RestConstants.HEADER_VALUE_APPLICATION_JSON))
    {
      return CODEC.readMap(message.getEntity().asInputStream());
    }
    else if (contentType.getBaseType().equalsIgnoreCase(RestConstants.HEADER_VALUE_APPLICATION_PSON))
    {
      return PSON_DATA_CODEC.readMap(message.getEntity().asInputStream());
    }
    else
    {
      throw new RoutingException("Unknown Content-Type: " + contentType.toString(), HttpStatus.S_415_UNSUPPORTED_MEDIA_TYPE.getCode());
    }
  }
View Full Code Here

  /** @see com.linkedin.restli.server.resources.CollectionResource#getAll(com.linkedin.restli.server.PagingContext) */
  @Override
  public List<V> getAll(PagingContext pagingContext)
  {
    throw new RoutingException("'getAll(PagingContext)' not implemented", 400);
  }
View Full Code Here

   * @see com.linkedin.restli.server.resources.CollectionResource#create(com.linkedin.data.template.RecordTemplate)
   */
  @Override
  public CreateResponse create(final V entity)
  {
    throw new RoutingException("'create' not implemented", 400);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.server.RoutingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.