org.apache.hadoop.fs.swift.exceptions.SwiftJsonMarshallingException#org.codehaus.jackson.JsonGenerationException源码实例Demo

下面列出了org.apache.hadoop.fs.swift.exceptions.SwiftJsonMarshallingException#org.codehaus.jackson.JsonGenerationException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response findById(@PathParam("id") Long id) throws JsonGenerationException, JsonMappingException, IOException {
	
	Podcast podcastById = podcastDao.getPodcastById(id);
	
	if (podcastById != null) {
		return Response
				.status(200)
				.entity(podcastById)
				.header("Access-Control-Allow-Headers", "X-extra-header")
				.allow("OPTIONS")
				.build();
	} else {
		return Response
				.status(404)
				.entity("The podcast with the id " + id + " does not exist")					
				.build();
	}
}
 

private void addVertexToPolygon(double lat, double lon, double hae)
		throws JsonGenerationException, IOException {
	try {
		if (firstVertex) {
			firstVertex = false;
			cachedLat = lat;
			cachedLon = lon;
			cachedHae = hae;
			firstVertex = false;
		}

		generator.writeStartArray();
		generator.writeNumber(lon);
		generator.writeNumber(lat);
		// generator.writeNumber(hae);
		generator.writeEndArray();
	} catch (Exception e) {
		log.error(e);
		log.error(e.getStackTrace());
	}
}
 

private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException
{
	if( firstVertex )
	{
		firstVertex = false;
		cachedLat = lat;
		cachedLon = lon;
		cachedHae = hae;
		firstVertex = false;
	}

	generator.writeStartArray();
	generator.writeNumber(lon);
	generator.writeNumber(lat);
	//generator.writeNumber(hae);
	generator.writeEndArray();
}
 

private void addVertexToPolygon(double lat, double lon, double hae)
		throws JsonGenerationException, IOException {
	try {
		if (firstVertex) {
			firstVertex = false;
			cachedLat = lat;
			cachedLon = lon;
			cachedHae = hae;
			firstVertex = false;
		}

		generator.writeStartArray();
		generator.writeNumber(lon);
		generator.writeNumber(lat);
		// generator.writeNumber(hae);
		generator.writeEndArray();
	} catch (Exception e) {
		log.error(e);
		log.error(e.getStackTrace());
	}
}
 

private void addVertexToPolygon(double lat, double lon, double hae) throws JsonGenerationException, IOException
{
	if( firstVertex )
	{
		firstVertex = false;
		cachedLat = lat;
		cachedLon = lon;
		cachedHae = hae;
		firstVertex = false;
	}

	generator.writeStartArray();
	generator.writeNumber(lon);
	generator.writeNumber(lat);
	//generator.writeNumber(hae);
	generator.writeEndArray();
}
 

@Test
public void testGetLegacyPodcast() throws JsonGenerationException,
		JsonMappingException, IOException {

	ClientConfig clientConfig = new ClientConfig();
	clientConfig.register(JacksonFeature.class);

	Client client = ClientBuilder.newClient(clientConfig);

	WebTarget webTarget = client
			.target("http://localhost:8888/demo-rest-spring-jersey-jpa2-hibernate-0.0.1-SNAPSHOT/podcasts/2");

	Builder request = webTarget.request(MediaType.APPLICATION_JSON);

	Response response = request.get();
	Assert.assertTrue(response.getStatus() == 200);

	Podcast podcast = response.readEntity(Podcast.class);

	ObjectMapper mapper = new ObjectMapper();
	System.out
			.print("Received podcast from database *************************** "
					+ mapper.writerWithDefaultPrettyPrinter()
							.writeValueAsString(podcast));

}
 
源代码7 项目: SI   文件: OpenApiService.java

public HashMap<String, Object> execute(String operation, String content) 
		throws JsonGenerationException, JsonMappingException, IOException, UserSysException
{	
	HashMap<String, Object> res = callOpenAPI(operation, content);
	
	
	//try {
		//int status = (Integer)res.get("status");
		String body = (String)res.get("body");
		ObjectMapper mapper = new ObjectMapper();
		Object json = mapper.readValue(body, Object.class);
		res.put("json", json);
	//} catch (JsonGenerationException ex) {
	//	res.put("exception", ex);
	//} catch (JsonMappingException ex) {
	//	res.put("exception", ex);
	//} catch (IOException ex) {
	//	res.put("exception", ex);
	//} catch (UserSysException ex) {
		
	//}
	
	return res;
}
 
源代码8 项目: helix   文件: InstanceResource.java

StringRepresentation getInstanceRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
  String instanceName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.INSTANCE_NAME);
  Builder keyBuilder = new PropertyKey.Builder(clusterName);
  ZkClient zkclient =
      ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.RAW_ZKCLIENT);

  String instanceCfgStr =
      ResourceUtil.readZkAsBytes(zkclient, keyBuilder.instanceConfig(instanceName));
  StringRepresentation representation =
      new StringRepresentation(instanceCfgStr, MediaType.APPLICATION_JSON);

  return representation;
}
 
源代码9 项目: helix   文件: MockController.java

void sendMessage(String msgId, String instanceName, String fromState, String toState,
    String partitionKey, int partitionId) throws InterruptedException, JsonGenerationException,
    JsonMappingException, IOException {
  Message message = new Message(MessageType.STATE_TRANSITION, msgId);
  message.setMsgId(msgId);
  message.setSrcName(srcName);
  message.setTgtName(instanceName);
  message.setMsgState(MessageState.NEW);
  message.setFromState(fromState);
  message.setToState(toState);
  // message.setPartitionId(partitionId);
  message.setPartitionName(partitionKey);

  String path = PropertyPathBuilder.instanceMessage(clusterName, instanceName, message.getId());
  ObjectMapper mapper = new ObjectMapper();
  StringWriter sw = new StringWriter();
  mapper.writeValueUsingView(sw, message, Message.class);
  System.out.println(sw.toString());
  client.delete(path);

  Thread.sleep(10000);
  ZNRecord record = client.readData(PropertyPathBuilder.liveInstance(clusterName, instanceName));
  message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString())
      .toString());
  client.createPersistent(path, message);
}
 
源代码10 项目: jetstream-esper   文件: EPLUtils.java

public static String toJsonString(Object obj, boolean bStripJsReservedWords) throws JsonGenerationException, JsonMappingException, IOException {
	String strResult = null;
	if (obj != null) {
		
		if (bStripJsReservedWords && obj instanceof JetstreamEvent)
			obj = ((JetstreamEvent)obj).getFilteredEvent();
		
		try {
			ObjectMapper mapper = new ObjectMapper();
			Writer writer = new StringWriter();
			mapper.writeValue(writer, obj);
			strResult = writer.toString();
		}
		catch (Throwable t) {
			if (m_nErrorCount++ % 10000 == 0 && LOGGER.isErrorEnabled())
				LOGGER.error( "", t); 
		}
	}
	return strResult;
}
 
源代码11 项目: helix   文件: StatusUpdateResource.java

StringRepresentation getInstanceStatusUpdateRepresentation(String clusterName,
    String instanceName, String resourceGroup) throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);

  Builder keyBuilder = new PropertyKey.Builder(clusterName);
  String message =
      ClusterRepresentationUtil.getInstancePropertiesAsString(zkClient, clusterName,
          keyBuilder.stateTransitionStatus(instanceName, instanceSessionId, resourceGroup),
          // instanceSessionId
          // + "__"
          // + resourceGroup,
          MediaType.APPLICATION_JSON);
  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);
  return representation;
}
 
源代码12 项目: realtime-analytics   文件: Simulator.java

private static void sendMessage() throws IOException, JsonProcessingException, JsonGenerationException,
            JsonMappingException, UnsupportedEncodingException, HttpException {
        ObjectMapper mapper = new ObjectMapper();

        Map<String, Object> m = new HashMap<String, Object>();

        m.put("si", "12345");
        m.put("ct", System.currentTimeMillis());
        
        String payload = mapper.writeValueAsString(m);
        HttpClient client = new HttpClient();
        PostMethod method = new PostMethod("http://localhost:8080/tracking/ingest/PulsarRawEvent");
//      method.addRequestHeader("Accept-Encoding", "gzip,deflate,sdch");
        method.setRequestEntity(new StringRequestEntity(payload, "application/json", "UTF-8"));
        int status = client.executeMethod(method);
        System.out.println(Arrays.toString(method.getResponseHeaders()));
        System.out.println("Status code: " + status + ", Body: " +  method.getResponseBodyAsString());
    }
 
源代码13 项目: SI   文件: OpenApiService.java

public HashMap<String, Object> execute(String operation, String content) 
		throws JsonGenerationException, JsonMappingException, IOException, UserSysException
{	
	HashMap<String, Object> res = callOpenAPI(operation, content);
	
	
	//try {
		//int status = (Integer)res.get("status");
		String body = (String)res.get("body");
		ObjectMapper mapper = new ObjectMapper();
		Object json = mapper.readValue(body, Object.class);
		res.put("json", json);
	//} catch (JsonGenerationException ex) {
	//	res.put("exception", ex);
	//} catch (JsonMappingException ex) {
	//	res.put("exception", ex);
	//} catch (IOException ex) {
	//	res.put("exception", ex);
	//} catch (UserSysException ex) {
		
	//}
	
	return res;
}
 
源代码14 项目: helix   文件: ErrorsResource.java

StringRepresentation getInstanceErrorsRepresentation(String clusterName, String instanceName)
    throws JsonGenerationException, JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ;

  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);

  String message =
      ClusterRepresentationUtil
          .getInstancePropertyNameListAsString(zkClient, clusterName, instanceName,
              PropertyType.CURRENTSTATES, instanceSessionId, MediaType.APPLICATION_JSON);

  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);

  return representation;
}
 
源代码15 项目: helix   文件: StateModelsResource.java

StringRepresentation getStateModelsRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);

  List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);

  ZNRecord modelDefinitions = new ZNRecord("modelDefinitions");
  modelDefinitions.setListField("models", models);

  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions),
          MediaType.APPLICATION_JSON);

  return representation;
}
 
源代码16 项目: Cubert   文件: TestOLAPCubeCountDistinct.java

@Test
void testThreeDimsTeam() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    Object[][] rows =
            { { 1, (int) 1, (int) 2, (int) 1 }, { 2, (int) 1, (int) 2, (int) 2 },
                    { 3, (int) 1, (int) 1, (int) 1 },
                    { 4, (int) 1, (int) 1, (int) 2 },
                    { 5, (int) 2, (int) 2, (int) 2 } };
    String[] expected =
            new String[] { "(1,2,1,1)", "(1,2,2,1)", "(1,1,1,1)", "(1,1,2,1)",
                    "(2,2,2,1)", "(1,,,4)", "(2,,,1)", "(,1,,2)", "(,2,,3)",
                    "(,,1,2)", "(,,2,3)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)",
                    "(,1,1,1)", "(,1,2,1)", "(,2,1,1)", "(,2,2,2)", "(1,,1,2)",
                    "(1,,2,2)", "(2,,2,1)", "(,,,5)" };
    validate(rows, expected);
}
 
源代码17 项目: Cubert   文件: TestOLAPCubeCountDistinct.java

@Test
void testLongType() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    // members: srinivas, maneesh, krishna, saurabh, rui
    // dimensions: country code, number of monitors, vegetarian
    Object[][] rows =
            { { 1, (long) 1, (long) 2, (long) 1 },
                    { 2, (long) 1, (long) 2, (long) 2 },
                    { 3, (long) 1, (long) 1, (long) 1 },
                    { 4, (long) 1, (long) 1, (long) 2 },
                    { 5, (long) 2, (long) 2, (long) 2 } };
    String[] expected =
            new String[] { "(1,2,1,1)", "(1,2,2,1)", "(1,1,1,1)", "(1,1,2,1)",
                    "(2,2,2,1)", "(1,,,4)", "(2,,,1)", "(,1,,2)", "(,2,,3)",
                    "(,,1,2)", "(,,2,3)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)",
                    "(,1,1,1)", "(,1,2,1)", "(,2,1,1)", "(,2,2,2)", "(1,,1,2)",
                    "(1,,2,2)", "(2,,2,1)", "(,,,5)" };
    validate(rows, expected);
}
 
源代码18 项目: Cubert   文件: TestOLAPCubeCountDistinct.java

@Test
void testMixedTypes() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    // members: srinivas, maneesh, krishna, saurabh, rui
    // dimensions: country code, number of monitors, vegetarian
    Object[][] rows =
            { { 1, 1, (long) 22222222222222L, 1 },
                    { 2, 1, (long) 22222222222222L, 2 },
                    { 3, 1, (long) 11111111111111L, 1 },
                    { 4, 1, (long) 11111111111111L, 2 },
                    { 5, 2, (long) 22222222222222L, 2 } };
    String[] expected =
            new String[] { "(1,22222222222222,1,1)", "(1,22222222222222,2,1)",
                    "(1,11111111111111,1,1)", "(1,11111111111111,2,1)",
                    "(2,22222222222222,2,1)", "(1,,,4)", "(2,,,1)",
                    "(,11111111111111,,2)", "(,22222222222222,,3)", "(,,1,2)",
                    "(,,2,3)", "(1,11111111111111,,2)", "(1,22222222222222,,2)",
                    "(2,22222222222222,,1)", "(,11111111111111,1,1)",
                    "(,11111111111111,2,1)", "(,22222222222222,1,1)",
                    "(,22222222222222,2,2)", "(1,,1,2)", "(1,,2,2)", "(2,,2,1)",
                    "(,,,5)" };
    validate(rows, expected);
}
 
源代码19 项目: Cubert   文件: TestOLAPCubeCountDistinct.java

@Test
void testThreeDimsTeamGroupingSets() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    // members: srinivas, maneesh, krishna, saurabh, rui
    // dimensions: country code, number of monitors, vegetarian
    Object[][] rows =
            { { 1, (int) 1, (int) 2, (int) 1 }, { 2, (int) 1, (int) 2, (int) 2 },
                    { 3, (int) 1, (int) 1, (int) 1 },
                    { 4, (int) 1, (int) 1, (int) 2 },
                    { 5, (int) 2, (int) 2, (int) 2 } };
    String[] expected =
            new String[] { "(1,,,4)", "(2,,,1)", "(1,1,,2)", "(1,2,,2)", "(2,2,,1)" };
    validateGroupingSets(rows, expected, new String[] { "Dim0,Dim1", "Dim0" });
}
 
源代码20 项目: helix   文件: CurrentStateResource.java

StringRepresentation getInstanceCurrentStateRepresentation(String clusterName,
    String instanceName, String resourceGroup) throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient = (ZkClient) getRequest().getAttributes().get(RestAdminApplication.ZKCLIENT);
  String instanceSessionId =
      ClusterRepresentationUtil.getInstanceSessionId(zkClient, clusterName, instanceName);
  Builder keyBuilder = new PropertyKey.Builder(clusterName);

  String message =
      ClusterRepresentationUtil.getInstancePropertyAsString(zkClient, clusterName,
          keyBuilder.currentState(instanceName, instanceSessionId, resourceGroup),
          MediaType.APPLICATION_JSON);
  StringRepresentation representation =
      new StringRepresentation(message, MediaType.APPLICATION_JSON);
  return representation;
}
 
源代码21 项目: Cubert   文件: TestOLAPCube.java

@Test
void testGroupingSetsSum() throws JsonGenerationException,
        JsonMappingException,
        IOException,
        InterruptedException
{
    // clickCount
    // dimensions: country code, number of monitors, vegetarian
    Object[][] rows =
            { { 1, (int) 1, (int) 1, (int) 1 }, { 1, (int) 1, (int) 1, (int) 2 },
                    { 2, (int) 1, (int) 2, (int) 1 },
                    { 3, (int) 1, (int) 2, (int) 2 },
                    { 2, (int) 2, (int) 2, (int) 2 } };

    String[] expected =
            new String[] { "(1,,,7)", "(2,,,2)", "(1,1,,2)", "(1,2,,5)", "(2,2,,2)" };

    validateGroupingSets(rows, expected, new String[] { "Dim0,Dim1", "Dim0" });
}
 
源代码22 项目: helix   文件: SchedulerTasksResource.java

StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  String instanceName = (String) getRequest().getAttributes().get("instanceName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);
  List<String> instances =
      setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);

  HelixDataAccessor accessor =
      ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
  LiveInstance liveInstance =
      accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName));
  String sessionId = liveInstance.getEphemeralOwner();

  StringRepresentation representation = new StringRepresentation("");// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs),
                                                                     // MediaType.APPLICATION_JSON);

  return representation;
}
 

/**
 * TODO If we could get the nasty pre-serialization stuff into the serialization policy, that'd be great.
 */
public static String getRequestString(final String method, final Object... parameters) throws JsonGenerationException, JsonMappingException, IOException {
  final ArrayList<Object> parameterLst = new ArrayList<>();

  for (Object parameter : parameters) {
    // Just check if this parameter is a number, if it is, make it an explicit
    // number
    if (parameter instanceof String) {
      if (((String) parameter).toLowerCase().equals("true")) {
        parameter = true;
      } else if (((String) parameter).toLowerCase().equals("false")) {
        parameter = false;
      } else if (parameter instanceof String) {
        try {
          parameter = Integer.parseInt((String) parameter);
        } catch (final NumberFormatException e) {
          // eat
        }
      }
    }

    parameterLst.add(parameter);
  }

  return getRequestStringWithParameters(method, parameterLst);
}
 

@Test
public void testGetLegacyPodcast() throws JsonGenerationException,
		JsonMappingException, IOException {

	ClientConfig clientConfig = new ClientConfig();
	clientConfig.register(JacksonFeature.class);

	Client client = ClientBuilder.newClient(clientConfig);

	WebTarget webTarget = client
			.target("http://localhost:8888/demo-rest-jersey-spring/legacy/podcasts/2");

	Builder request = webTarget.request(MediaType.APPLICATION_JSON);

	Response response = request.get();
	Assert.assertTrue(response.getStatus() == 200);

	Podcast podcast = response.readEntity(Podcast.class);

	ObjectMapper mapper = new ObjectMapper();
	System.out
			.print("Received podcast from LEGACY database *************************** "
					+ mapper.writerWithDefaultPrettyPrinter()
							.writeValueAsString(podcast));

}
 
源代码25 项目: openmrs-module-initializer   文件: Utils.java

/**
 * Convenience method to serialize a JSON object that also handles the simple string case.
 */
public static String asString(Object jsonObj) throws JsonGenerationException, JsonMappingException, IOException {
	if (jsonObj == null) {
		return "";
	}
	if (jsonObj instanceof String) {
		return (String) jsonObj;
	} else {
		return (new ObjectMapper()).writeValueAsString(jsonObj);
	}
}
 
源代码26 项目: ranger   文件: JSONUtil.java

public File writeJsonToFile(ViewBaseBean viewBean, String fileName)
		throws JsonGenerationException, JsonMappingException, IOException {

	if (fileName.length() < 3) {
		fileName = "file_" + fileName;
	}

	File file = File.createTempFile(fileName, ".json");
	JsonUtilsV2.getMapper().defaultPrettyPrintingWriter().writeValue(file, viewBean);

	return file;
}
 
源代码27 项目: helix   文件: ClusterResource.java

StringRepresentation getClusterRepresentation(String clusterName) throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient =
      ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);
  List<String> instances =
      setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);

  ZNRecord clusterSummayRecord = new ZNRecord("Cluster Summary");
  clusterSummayRecord.setListField("participants", instances);

  List<String> resources =
      setupTool.getClusterManagementTool().getResourcesInCluster(clusterName);
  clusterSummayRecord.setListField("resources", resources);

  List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);
  clusterSummayRecord.setListField("stateModelDefs", models);

  HelixDataAccessor accessor =
      ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
  Builder keyBuilder = accessor.keyBuilder();

  LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
  if (leader != null) {
    clusterSummayRecord.setSimpleField("LEADER", leader.getInstanceName());
  } else {
    clusterSummayRecord.setSimpleField("LEADER", "");
  }
  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clusterSummayRecord),
          MediaType.APPLICATION_JSON);

  return representation;
}
 
源代码28 项目: fountain   文件: JsonUtils.java

public byte[] writeValueAsBytes(Object value,
        JsonSerialize.Inclusion inc) throws IOException,
        JsonGenerationException, JsonMappingException {
    if (inc == null) {
        return super.writeValueAsBytes(value);
    }
    // alas, we have to pull the recycler directly here...
    ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
    writeValueWithConf(_jsonFactory.createJsonGenerator(bb, JsonEncoding.UTF8), value,inc);
    byte[] result = bb.toByteArray();
    bb.release();
    return result;
}
 
源代码29 项目: fountain   文件: JsonUtils.java

private void writeValueWithConf(JsonGenerator jgen, Object value,
		JsonSerialize.Inclusion inc) throws IOException,
		JsonGenerationException, JsonMappingException {
	
	SerializationConfig cfg = copySerializationConfig();
	cfg = cfg.withSerializationInclusion(inc);
	
	// [JACKSON-96]: allow enabling pretty printing for ObjectMapper
	// directly
	if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) {
		jgen.useDefaultPrettyPrinter();
	}
	// [JACKSON-282]: consider Closeable
	if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE)
			&& (value instanceof Closeable)) {
		configAndWriteCloseable(jgen, value, cfg);
		return;
	}
	boolean closed = false;
	try {
		_serializerProvider.serializeValue(cfg, jgen, value,
				_serializerFactory);
		closed = true;
		jgen.close();
	} finally {
		/*
		 * won't try to close twice; also, must catch exception (so it
		 * will not mask exception that is pending)
		 */
		if (!closed) {
			try {
				jgen.close();
			} catch (IOException ioe) {
			}
		}
	}
}
 
源代码30 项目: helix   文件: ClusterRepresentationUtil.java

public static String getInstancePropertyNameListAsString(ZkClient zkClient, String clusterName,
    String instanceName, PropertyType instanceProperty, String key, MediaType mediaType)
    throws JsonGenerationException, JsonMappingException, IOException {
  String path = PropertyPathBuilder.instanceProperty(clusterName, instanceName, instanceProperty, key);
  if (zkClient.exists(path)) {
    List<String> recordNames = zkClient.getChildren(path);
    return ObjectToJson(recordNames);
  }

  return ObjectToJson(new ArrayList<String>());
}