if (segments.length < 2) {
throw new IllegalArgumentException("No name provided");
}
String name = segments[3];
IDiagramStencilSet stencilset = _pluginService.findStencilSet(req, name);
if (stencilset == null) {
throw new IllegalArgumentException("No stencilset by the name of " + name);
}
InputStream input = null;
if (segments.length > 4) { //looking for a resource under the stencilset.
String path = requestURI.substring(requestURI.indexOf(segments[3]) + segments[3].length() + 1);
input = stencilset.getResourceContents(path);
} else {
input = stencilset.getContents();
resp.setContentType("application/json");
}
try {
byte[] buffer = new byte[4096];