|
|
|
@ -17,7 +17,9 @@ import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response; |
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.ResourceBundle; |
|
|
|
|
|
|
|
|
|
@Path("/") |
|
|
|
|
@Produces(MediaType.TEXT_HTML) |
|
|
|
@ -25,16 +27,31 @@ public class ApiResource {
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ApiResource.class); |
|
|
|
|
|
|
|
|
|
@GET |
|
|
|
|
@Path("/info") |
|
|
|
|
@Produces(MediaType.APPLICATION_JSON) |
|
|
|
|
public Response info() { |
|
|
|
|
Map<String, String> result = new HashMap<String, String>(); |
|
|
|
|
try { |
|
|
|
|
ResourceBundle resource = ResourceBundle.getBundle("build-info"); |
|
|
|
|
result.put("version", resource.getString("version")); |
|
|
|
|
result.put("timestamp", resource.getString("timestamp")); |
|
|
|
|
} catch (Exception e){ |
|
|
|
|
result.put("version", "LOCAL"); |
|
|
|
|
result.put("timestamp", "NOW"); |
|
|
|
|
} |
|
|
|
|
return Response.ok(result).build(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@GET |
|
|
|
|
@Path("/validate") |
|
|
|
|
@Produces(MediaType.APPLICATION_JSON) |
|
|
|
|
public Response validate(@QueryParam("path") String path){ |
|
|
|
|
public Response validate(@QueryParam("path") String path) { |
|
|
|
|
int result = -1; |
|
|
|
|
try { |
|
|
|
|
JsonPath compiled = JsonPath.compile(path); |
|
|
|
|
result = compiled.isDefinite()?0:1; |
|
|
|
|
} catch (Exception e){ |
|
|
|
|
result = compiled.isDefinite() ? 0 : 1; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
} |
|
|
|
|
return Response.ok(Collections.singletonMap("result", result)).build(); |
|
|
|
|
} |
|
|
|
@ -47,10 +64,10 @@ public class ApiResource {
|
|
|
|
|
public Response getTemplate(@FormParam("json") String json, |
|
|
|
|
@FormParam("path") String path, |
|
|
|
|
@FormParam("type") String type, |
|
|
|
|
@FormParam("flagWrap") boolean flagWrap, |
|
|
|
|
@FormParam("flagNullLeaf") boolean flagNullLeaf, |
|
|
|
|
@FormParam("flagSuppress") boolean flagSuppress, |
|
|
|
|
@FormParam("flagRequireProps") boolean flagRequireProps){ |
|
|
|
|
@FormParam("flagWrap") boolean flagWrap, |
|
|
|
|
@FormParam("flagNullLeaf") boolean flagNullLeaf, |
|
|
|
|
@FormParam("flagSuppress") boolean flagSuppress, |
|
|
|
|
@FormParam("flagRequireProps") boolean flagRequireProps) { |
|
|
|
|
|
|
|
|
|
boolean value = "VALUE".equalsIgnoreCase(type); |
|
|
|
|
|
|
|
|
@ -60,5 +77,4 @@ public class ApiResource {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|