Search in sources :

Example 1 with InspectionType

use of io.atlasmap.xml.v2.InspectionType 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();
}
Also used : InspectionType(io.atlasmap.xml.v2.InspectionType) XmlInspectionService(io.atlasmap.xml.inspect.XmlInspectionService) XmlDocument(io.atlasmap.xml.v2.XmlDocument) File(java.io.File) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 XmlInspectionService (io.atlasmap.xml.inspect.XmlInspectionService)1 InspectionType (io.atlasmap.xml.v2.InspectionType)1 XmlDocument (io.atlasmap.xml.v2.XmlDocument)1 File (java.io.File)1 IOException (java.io.IOException)1 ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1