Source:
public final Response containerContents(@Context final HttpServletRequest req, @Context final HttpServletResponse res, @QueryParam("containerId") final String containerId, @QueryParam("contentInode") final String contentInode) throws DotDataException, DotSecurityException, ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException { final InitDataObject initData = webResource.init(true, req, true); final User user = initData.getUser(); Language id = WebAPILocator.getLanguageWebAPI().getLanguage(req); PageMode mode = PageMode.get(req); Container container = APILocator.getContainerAPI().find(containerId, user, mode == PageMode.ANON); org.apache.velocity.context.Context context = VelocityUtil.getWebContext(req, res); Contentlet contentlet = APILocator.getContentletAPI().find(contentInode, user, mode == PageMode.ANON); ContainerStructure cStruct = APILocator.getContainerAPI().getContainerStructures(container).stream() .filter(cs -> contentlet.getStructureInode().equals(cs.getStructureId())).findFirst().orElse(null); StringWriter in = new StringWriter(); StringWriter out = new StringWriter(); in.append("#set ($contentletList").append(container.getIdentifier()).append(" = [").append(contentlet.getIdentifier()) .append("] )").append("#set ($totalSize").append(container.getIdentifier()).append("=").append("1").append(")") .append("#parseContainer(\"").append(container.getIdentifier()).append("\")"); VelocityUtil.getEngine().evaluate(context, out, this.getClass().getName(), IOUtils.toInputStream(in.toString())); Map<String, String> response = new HashMap<>(); response.put("render", out.toString()); final Response.ResponseBuilder responseBuilder = Response.ok(response); return responseBuilder.build(); }

Target:
public final Response containerContents(@Context final HttpServletRequest req, @Context final HttpServletResponse res, @QueryParam("containerId") final String containerId, @QueryParam("contentInode") final String contentInode) throws DotDataException, DotSecurityException, ParseErrorException, MethodInvocationException, ResourceNotFoundException, IOException { final InitDataObject initData = webResource.init(true, req, true); final User user = initData.getUser(); Language id = WebAPILocator.getLanguageWebAPI() .getLanguage(req); PageMode mode = PageMode.get(req); Container container = APILocator.getContainerAPI() .find(containerId, user, !mode.isAdmin); org.apache.velocity.context.Context context = VelocityUtil.getWebContext(req, res); Contentlet contentlet = APILocator.getContentletAPI() .find(contentInode, user, !mode.isAdmin); ContainerStructure cStruct = APILocator.getContainerAPI() .getContainerStructures(container) .stream() .filter(cs -> contentlet.getStructureInode() .equals(cs.getStructureId())) .findFirst() .orElse(null); StringWriter in = new StringWriter(); StringWriter out = new StringWriter(); in.append("#set ($contentletList") .append(container.getIdentifier()) .append(" = [") .append(contentlet.getIdentifier()) .append("] )") .append("#set ($totalSize") .append(container.getIdentifier()) .append("=") .append("1") .append(")") .append("#parseContainer(\"") .append(container.getIdentifier()) .append("\")"); VelocityUtil.getEngine() .evaluate(context, out, this.getClass() .getName(), IOUtils.toInputStream(in.toString())); Map<String, String> response = new HashMap<>(); response.put("render", out.toString()); final Response.ResponseBuilder responseBuilder = Response.ok(response); return responseBuilder.build(); }