use of io.atlasmap.xml.inspect.XmlInspectionService in project atlasmap by atlasmap.
the class XmlService method inspectClass.
public Response inspectClass(XmlInspectionRequest request) {
long startTime = System.currentTimeMillis();
XmlInspectionResponse response = new XmlInspectionResponse();
XmlDocument d = null;
try {
if (request.getType() == null) {
response.setErrorMessage("Instance or Schema type must be specified in request");
} else {
XmlInspectionService s = new XmlInspectionService();
switch(request.getType()) {
case INSTANCE:
d = s.inspectXmlDocument(request.getXmlData());
break;
case SCHEMA:
d = s.inspectSchema(request.getXmlData());
break;
default:
response.setErrorMessage("Unsupported inspection type: " + request.getType());
break;
}
}
} catch (Exception e) {
LOG.error("Error inspecting xml: " + e.getMessage(), e);
response.setErrorMessage(e.getMessage());
} finally {
response.setExecutionTime(System.currentTimeMillis() - startTime);
}
response.setXmlDocument(d);
return Response.ok().entity(toJson(response)).build();
}
use of io.atlasmap.xml.inspect.XmlInspectionService in project atlasmap by atlasmap.
the class XmlService method getClass.
@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public Response getClass(@QueryParam("uri") String uri, @QueryParam("type") String type) {
XmlDocument d = null;
try {
if (type == null) {
throw new Exception("uri and type parameters must be specified");
}
InspectionType inspectType = InspectionType.valueOf(type);
XmlInspectionService s = new XmlInspectionService();
switch(inspectType) {
case INSTANCE:
d = s.inspectXmlDocument(new File(uri));
break;
case SCHEMA:
d = s.inspectSchema(new File(uri));
break;
default:
throw new Exception("Unknown type specified: " + type);
}
} catch (Exception e) {
LOG.error("Error inspecting xml: " + e.getMessage(), e);
}
return Response.ok().entity(toJson(d)).build();
}
Aggregations