Java 类org.codehaus.jackson.map.exc.UnrecognizedPropertyException 实例源码

项目:personium-core    文件:BarFileReadRunner.java   
/**
 * manifest.jsonのバリデート.
 * @param jp Jsonパーサー
 * @param mapper ObjectMapper
 * @return JSONManifestオブジェクト
 * @throws IOException データの読み込みに失敗した場合
 */
protected JSONManifest manifestJsonValidate(JsonParser jp, ObjectMapper mapper) throws IOException {
    // TODO BARファイルのバージョンチェック
    JSONManifest manifest = null;
    try {
        manifest = mapper.readValue(jp, JSONManifest.class);
    } catch (UnrecognizedPropertyException ex) {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(
                "manifest.json unrecognized property");
    }
    if (manifest.getBarVersion() == null) {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params("manifest.json#barVersion");
    }
    if (manifest.getBoxVersion() == null) {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params("manifest.json#boxVersion");
    }
    if (manifest.getDefaultPath() == null) {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params("manifest.json#DefaultPath");
    }
    return manifest;
}
项目:personium-core    文件:BarFileUtils.java   
/**
 * barファイルエントリからJSONファイルを読み込む.
 * @param <T> JSONMappedObject
 * @param inStream barファイルエントリのInputStream
 * @param entryName entryName
 * @param clazz clazz
 * @return JSONファイルから読み込んだオブジェクト
 * @throws IOException JSONファイル読み込みエラー
 */
public static <T> T readJsonEntry(
        InputStream inStream, String entryName, Class<T> clazz) throws IOException {
    JsonParser jp = null;
    ObjectMapper mapper = new ObjectMapper();
    JsonFactory f = new JsonFactory();
    jp = f.createJsonParser(inStream);
    JsonToken token = jp.nextToken(); // JSONルート要素("{")
    Pattern formatPattern = Pattern.compile(".*/+(.*)");
    Matcher formatMatcher = formatPattern.matcher(entryName);
    String jsonName = formatMatcher.replaceAll("$1");
    T json = null;
    if (token == JsonToken.START_OBJECT) {
        try {
            json = mapper.readValue(jp, clazz);
        } catch (UnrecognizedPropertyException ex) {
            throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
        }
    } else {
        throw PersoniumCoreException.BarInstall.JSON_FILE_FORMAT_ERROR.params(jsonName);
    }
    return json;
}
项目:BulkScanDownloader    文件:Authentication.java   
public void signIn(String username, String password) throws Exception {
    Entity payload = Entity.json("{ \"ClientType\": 6,  \"Password\": \"" + password + "\", \"UserName\": \"" + username + "\"}");
    Response response = client.target(endpoint.toString()).request(MediaType.APPLICATION_JSON_TYPE).post(payload);

    String res = response.readEntity(String.class);

    try {
        JSONAuthSession jsonSession = new ObjectMapper().readValue(res, JSONAuthSession.class);
        this.session = jsonSession.getSession();
        ((Stub) this.downloadService).clearHeaders();
        ((Stub) this.downloadService).setHeader(this.getSoapSessionHeader());
    } catch (UnrecognizedPropertyException e) {
        JSONAuthFault fault = new ObjectMapper().readValue(res, JSONAuthFault.class);
        logger.error("Could not sign in user `" + username + "`, reason:");
        logger.error(fault.getMessage());
        throw new Exception("Unable to sign in");
    }
}
项目:archived-net-virt-platform    文件:JSONMsgHandler.java   
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
    throws Exception {
    if (e.getCause() instanceof IllegalStateException) {
        // hiding exception logging - expected because of the way we do
        // JSON message decoding
        // logger.debug("Illegal State exception ", 
        //        e.getCause().toString());
    } else if (e.getCause() instanceof UnrecognizedPropertyException) {
        logger.error("Jackson unrecognized property error {}", 
                e.getCause());
    } else if (e.getCause() instanceof JsonMappingException) {
        logger.error("Jackson mapping error {}", 
                e.getCause());
    } else if (e.getCause() instanceof JsonParseException) {
        logger.error("Jackson parsing error {}", 
                e.getCause());
    } else if (e.getCause() instanceof ClosedChannelException) {
        logger.error("Netty closed channel error", e.getCause());
    } else if (e.getCause() instanceof ConnectException) {
        logger.error("Connection refused", e.getCause());
    } else if (e.getCause() instanceof IOException) {
        logger.error("IO problem", e.getCause());
    } else {
        super.exceptionCaught(ctx, e);
    }
}
项目:jee-rest    文件:UnrecognizedPropertyExceptionMapper.java   
@Override
protected ApiErrorResponse toApiErrorResponse(UnrecognizedPropertyException upe) {
    return new ApiErrorResponse(
        buildMessage(upe), 
        getCode(),
        getLocationType(),
        upe.getUnrecognizedPropertyName()
    );
}
项目:homePi    文件:GeneralExceptionMapper.java   
public Response toResponse(Exception exception) {
    String msg = "General Exception at CXF layer:" +exception.toString();
    log.debug(msg,exception);
    if(exception instanceof NullPointerException){
        return new NullPointerExceptionMapper().toResponse((NullPointerException)exception);
    } else if(exception instanceof HomePiAppException){
        return new HomePiAppExceptionMapper().toResponse((HomePiAppException)exception);
    } else if(exception instanceof JsonProcessingException){
        return new JsonProcessingExceptionMapper().toResponse((JsonProcessingException)exception);
    } else if(exception instanceof UnrecognizedPropertyException){
        return new UnrecognizedPropertyExceptionMapper().toResponse((UnrecognizedPropertyException)exception);
    } else if(exception instanceof WebApplicationException){
        WebApplicationException wae = (WebApplicationException)exception;
        Status status = Status.fromStatusCode(wae.getResponse().getStatus());
        String cause = (wae.getCause()!= null)?wae.getCause().toString():"";
        if(status == null && wae.getResponse().getStatus() == 405){
            msg += (" [Unmapped Status:" + wae.getResponse().getStatus()+"] " + wae.getResponse().getMetadata());
            if(cause == null) cause = "Method Not Allowed";
        }   
        return Response
            .status(status)
               .entity(new HomePiAppException(status, msg, cause,0).toResponse())
               .type(MediaType.APPLICATION_JSON)
               .build();
    }

    return Response
        .status(Status.BAD_REQUEST)
           .entity(new HomePiAppException(Status.BAD_REQUEST, msg, "",0).toResponse())
           .type(MediaType.APPLICATION_JSON)
           .build();
}
项目:homePi    文件:UnrecognizedPropertyExceptionMapper.java   
public Response toResponse(UnrecognizedPropertyException exception)
{
    String message = "Invalid JSON field: '"+exception.getUnrecognizedPropertyName()+"'";
    return Response
            .status(Status.BAD_REQUEST)
            .entity(new HomePiAppException(Status.BAD_REQUEST, message, "Invalid JSON, Unrecognized Property.",0).toResponse())
            .type( MediaType.APPLICATION_JSON)
            .build();
}
项目:12306-android-Decompile    文件:StdDeserializationContext.java   
public JsonMappingException unknownFieldException(Object paramObject, String paramString)
{
  return UnrecognizedPropertyException.from(this._parser, paramObject, paramString);
}
项目:12306-android-Decompile    文件:StdDeserializationContext.java   
public JsonMappingException unknownFieldException(Object paramObject, String paramString)
{
  return UnrecognizedPropertyException.from(this._parser, paramObject, paramString);
}
项目:ingress-indonesia-dev    文件:StdDeserializationContext.java   
public JsonMappingException unknownFieldException(Object paramObject, String paramString)
{
  return UnrecognizedPropertyException.from(this._parser, paramObject, paramString);
}
项目:jee-rest    文件:UnrecognizedPropertyExceptionMapper.java   
/**
 * Builds an error message indicating which property is unknown.
 *
 * @param upe the cause
 * @return a message indicating the position (line and column) of the unknown property in the
 * JSON document
 */
private String buildMessage(UnrecognizedPropertyException upe) {
    return "JSON parsing error due to unknown JSON object property "
            + upe.getUnrecognizedPropertyName() + getLocationDetails(upe) + ".";
}