use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class DefaultOpenApiDescriptionGenerator method processMethod.
private void processMethod(Method method, final Class<?> pageClass, JSONObject paths, final String tagName) {
final String uri = getPath(method, pageClass);
final JSONObject path;
if (paths.containsKey(uri)) {
path = paths.getJSONObject(uri);
} else {
path = new JSONObject();
paths.put(uri, path);
}
final String httpMethod = getHttpMethod(method);
if (path.containsKey(httpMethod)) {
throw new RuntimeException(String.format("There are at least two different REST endpoints for path %s and HTTP method %s in class %s", uri, httpMethod.toUpperCase(), pageClass.getName()));
} else {
final JSONObject methodDescription = new JSONObject();
putIfNotEmpty(methodDescription, "summary", getValue(method, uri, httpMethod, "summary"));
putIfNotEmpty(methodDescription, "description", getValue(method, uri, httpMethod, "description"));
JSONArray methodTags = new JSONArray();
methodTags.add(tagName);
methodDescription.put("tags", methodTags);
processResponses(method, uri, httpMethod, methodDescription);
processParameters(method, uri, httpMethod, methodDescription);
path.put(httpMethod, methodDescription);
}
}
use of org.apache.tapestry5.annotations.Path in project tapestry-5 by apache.
the class StackAssetRequestHandler method streamStackResource.
private boolean streamStackResource(String extraPath) throws IOException {
Matcher matcher = pathPattern.matcher(extraPath);
if (!matcher.matches()) {
logger.warn("Unable to parse '{}' as an asset stack path", extraPath);
return false;
}
String checksum = matcher.group(1);
String localeName = matcher.group(2);
final String stackName = matcher.group(3);
final boolean compressed = checksum.startsWith("z");
if (compressed) {
checksum = checksum.substring(1);
}
final JavaScriptStack stack = stackSource.findStack(stackName);
if (stack == null) {
logger.warn("JavaScript stack '{}' not found.", stackName);
return false;
}
// Yes, I have a big regret that the JavaScript stack stuff relies on this global, rather than
// having it passed around properly.
localizationSetter.setNonPersistentLocaleFromLocaleName(localeName);
StreamableResource resource = tracker.perform(String.format("Assembling JavaScript asset stack '%s' (%s)", stackName, localeName), new IOOperation<StreamableResource>() {
public StreamableResource perform() throws IOException {
return javaScriptStackAssembler.assembleJavaScriptResourceForStack(stackName, compressed, stack.getJavaScriptAggregationStrategy());
}
});
if (resource == null) {
return false;
}
return resourceStreamer.streamResource(resource, checksum, ResourceStreamer.DEFAULT_OPTIONS);
}
Aggregations