use of com.fasterxml.jackson.core.JsonParseException in project hadoop by apache.
the class DomainLogInfo method parseForStore.
public long parseForStore(TimelineDataManager tdm, Path appDirPath, boolean appCompleted, JsonFactory jsonFactory, ObjectMapper objMapper, FileSystem fs) throws IOException {
LOG.debug("Parsing for log dir {} on attempt {}", appDirPath, attemptDirName);
Path logPath = getPath(appDirPath);
FileStatus status = fs.getFileStatus(logPath);
long numParsed = 0;
if (status != null) {
long startTime = Time.monotonicNow();
try {
LOG.debug("Parsing {} at offset {}", logPath, offset);
long count = parsePath(tdm, logPath, appCompleted, jsonFactory, objMapper, fs);
LOG.info("Parsed {} entities from {} in {} msec", count, logPath, Time.monotonicNow() - startTime);
numParsed += count;
} catch (RuntimeException e) {
// If AppLogs cannot parse this log, it may be corrupted or just empty
if (e.getCause() instanceof JsonParseException && (status.getLen() > 0 || offset > 0)) {
// log on parse problems if the file as been read in the past or
// is visibly non-empty
LOG.info("Log {} appears to be corrupted. Skip. ", logPath);
}
}
} else {
LOG.warn("{} no longer exists. Skip for scanning. ", logPath);
}
return numParsed;
}
use of com.fasterxml.jackson.core.JsonParseException in project hadoop by apache.
the class RemoteSASKeyGenerationResponse method makeRemoteRequest.
/**
* Helper method to make a remote request.
* @param uri - Uri to use for the remote request
* @return RemoteSASKeyGenerationResponse
*/
private RemoteSASKeyGenerationResponse makeRemoteRequest(URI uri) throws SASKeyGenerationException {
try {
String responseBody = remoteCallHelper.makeRemoteGetRequest(new HttpGet(uri));
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(responseBody, RemoteSASKeyGenerationResponse.class);
} catch (WasbRemoteCallException remoteCallEx) {
throw new SASKeyGenerationException("Encountered RemoteCallException" + " while retrieving SAS key from remote service", remoteCallEx);
} catch (JsonParseException jsonParserEx) {
throw new SASKeyGenerationException("Encountered JsonParseException " + "while parsing the response from remote" + " service into RemoteSASKeyGenerationResponse object", jsonParserEx);
} catch (JsonMappingException jsonMappingEx) {
throw new SASKeyGenerationException("Encountered JsonMappingException" + " while mapping the response from remote service into " + "RemoteSASKeyGenerationResponse object", jsonMappingEx);
} catch (IOException ioEx) {
throw new SASKeyGenerationException("Encountered IOException while " + "accessing remote service to retrieve SAS Key", ioEx);
}
}
use of com.fasterxml.jackson.core.JsonParseException in project midpoint by Evolveum.
the class ItemPathDeserializer method deserialize.
@Override
public ItemPath deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
// TODO : implement..this is only for test
if (jp.getCurrentToken() != JsonToken.VALUE_STRING) {
throw new JsonParseException("Cannot parse path value. Expected that the value will be string but it is: " + jp.getCurrentTokenId(), jp.getCurrentLocation());
}
String path = jp.getText();
if (StringUtils.isBlank(path)) {
throw new IllegalStateException("Error while deserializing path. No path specified.");
}
//System.out.println("path: " + path);
// if (path.startsWith("declare.*")){
XPathHolder holder = new XPathHolder(path);
return holder.toItemPath();
// }
// else {
// String[] segments = path.split("/");
// if (segments.length == 1){
// String[] pathItems = segments[0].split(":");
// if (pathItems.length == 1){
// return new ItemPath(QNameUtil.nullNamespace(pathItems[0]));
// }
//
// } else
// }
// return new ItemPath(new QName("http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd", "name"));
}
use of com.fasterxml.jackson.core.JsonParseException in project midpoint by Evolveum.
the class ItemPathTypeDeserializer method deserialize.
@Override
public ItemPathType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
if (jp.getCurrentToken() != JsonToken.VALUE_STRING) {
throw new JsonParseException("Cannot parse path value. Expected that the value will be string but it is: " + jp.getCurrentTokenId(), jp.getCurrentLocation());
}
String path = jp.getText();
if (StringUtils.isBlank(path)) {
throw new IllegalStateException("Error while deserializing path. No path specified.");
}
//System.out.println("path: " + path);
// if (path.startsWith("declare.*")){
XPathHolder holder = new XPathHolder(path);
ItemPath itemPath = holder.toItemPath();
ItemPathType itemPathType = new ItemPathType(itemPath);
return itemPathType;
// ItemPathType itemPathType = new ItemPathType();
// itemPathType.getContent().add(jp.getText());
//
// return itemPathType;
}
use of com.fasterxml.jackson.core.JsonParseException in project OpenClinica by OpenClinica.
the class XformMetaDataService method executeIndividualCrf.
public void executeIndividualCrf(ExecuteIndividualCrfObject eicObject) {
for (OCodmComplexTypeDefinitionFormLayoutDef formLayoutDef : eicObject.formLayoutDefs) {
List<String> fileLinks = null;
String vForm = "";
RestTemplate rest = new RestTemplate();
if (eicObject.form != null) {
List<FormVersion> versions = eicObject.form.getVersions();
for (FormVersion version : versions) {
if (version.getName().equals(formLayoutDef.getOID())) {
fileLinks = version.getFileLinks();
for (String fileLink : fileLinks) {
if (fileLink.endsWith(VERSION)) {
vForm = rest.getForObject(fileLink, String.class);
break;
}
}
if (!eicObject.errors.hasErrors()) {
ObjectMapper mapper = new ObjectMapper();
TypeReference<List<XformGroup>> mapType = new TypeReference<List<XformGroup>>() {
};
List<XformGroup> jsonList = null;
try {
jsonList = mapper.readValue(vForm, mapType);
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XformContainer xformContainer = new XformContainer();
xformContainer.setGroups(jsonList);
eicObject.setContainer(xformContainer);
if (eicObject.errors.hasErrors()) {
return;
}
// Save meta-data in database
saveFormMetadata(eicObject, version, eicObject.container, formLayoutDef, fileLinks);
}
}
}
}
}
}
Aggregations