use of io.atlasmap.v2.StringMapEntry in project atlasmap by atlasmap.
the class AtlasService method listMappings.
@GET
@Path("/mappings")
@Produces(MediaType.APPLICATION_JSON)
public Response listMappings(@Context UriInfo uriInfo, @QueryParam("filter") final String filter) {
StringMap sMap = new StringMap();
java.nio.file.Path mappingFolder = Paths.get(baseFolder);
File[] mappings = mappingFolder.toFile().listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (filter != null && name != null && !name.toLowerCase().contains(filter.toLowerCase())) {
return false;
}
return (name != null ? name.matches("atlasmapping-[a-zA-Z0-9\\.\\-]+.xml") : false);
}
});
if (mappings == null) {
return Response.ok().entity(toJson(sMap)).build();
}
try {
for (File mapping : mappings) {
AtlasMapping map = getMappingFromFile(mapping.getAbsolutePath());
StringMapEntry mapEntry = new StringMapEntry();
mapEntry.setName(map.getName());
UriBuilder builder = uriInfo.getBaseUriBuilder().path("v2").path("atlas").path("mapping").path(map.getName());
mapEntry.setValue(builder.build().toString());
sMap.getStringMapEntry().add(mapEntry);
}
} catch (JAXBException e) {
throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR);
}
return Response.ok().entity(toJson(sMap)).build();
}
use of io.atlasmap.v2.StringMapEntry in project atlasmap by atlasmap.
the class AtlasServiceTest method testListMappings.
@Test
public void testListMappings() throws Exception {
Response resp = service.listMappings(generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mappings"), null);
StringMap sMap = Json.mapper().readValue((byte[]) resp.getEntity(), StringMap.class);
System.out.println("Found " + sMap.getStringMapEntry().size() + " objects");
for (StringMapEntry s : sMap.getStringMapEntry()) {
System.out.println("\t n: " + s.getName() + " v: " + s.getValue());
}
}
Aggregations