private void handleExistingDocRefs(List<Element> elements, String attrName, String parentDocLoc, String parentRef, Message m, UriInfo ui) { if (keepRelativeDocLinks) { return; } int index = parentDocLoc.lastIndexOf('/'); parentDocLoc = index == -1 ? parentDocLoc : parentDocLoc.substring(0, index + 1); index = parentRef.lastIndexOf('/'); parentRef = index == -1 ? "" : parentRef.substring(0, index + 1); for (Element element : elements) { String href = element.getAttribute(attrName); String originalRef = href; if (!StringUtils.isEmpty(href) && !href.startsWith("#")) { int fragmentIndex = href.lastIndexOf('#'); String fragment = null; if (fragmentIndex != -1) { fragment = href.substring(fragmentIndex + 1); href = href.substring(0, fragmentIndex); } String actualRef = parentRef + href; docLocationMap.put(actualRef, parentDocLoc + originalRef); UriBuilder ub = UriBuilder.fromUri(getBaseURI(m, ui)).path(actualRef).fragment(fragment); URI schemaURI = ub.build(); DOMUtils.setAttribute(element, attrName, schemaURI.toString()); } } }
private void handleExistingDocRefs(List<Element> elements, String attrName, String parentDocLoc, String parentRef, Message m, UriInfo ui) { int index = parentDocLoc.lastIndexOf('/'); parentDocLoc = index == -1 ? parentDocLoc : parentDocLoc.substring(0, index + 1); index = parentRef.lastIndexOf('/'); parentRef = index == -1 ? "" : parentRef.substring(0, index + 1); for (Element element : elements) { String href = element.getAttribute(attrName); String originalRef = href; if (!StringUtils.isEmpty(href) && !href.startsWith("#")) { int fragmentIndex = href.lastIndexOf("#"); String fragment = null; if (fragmentIndex != -1) { fragment = href.substring(fragmentIndex + 1); href = href.substring(0, fragmentIndex); } String actualRef = parentRef + href; docLocationMap.put(actualRef, parentDocLoc + originalRef); UriBuilder ub = UriBuilder.fromUri(getBaseURI(m, ui)).path(actualRef).fragment(fragment); URI schemaURI = ub.build(); DOMUtils.setAttribute(element, attrName, schemaURI.toString()); } } }
private void handleExistingDocRefs(List<Element> elements, String attrName, String parentDocLoc, String parentRef, Message m, UriInfo ui) { if (keepRelativeDocLinks) { return; } int index = parentDocLoc.lastIndexOf('/'); parentDocLoc = index == -1 ? parentDocLoc : parentDocLoc.substring(0, index + 1); index = parentRef.lastIndexOf('/'); parentRef = index == -1 ? "" : parentRef.substring(0, index + 1); for (Element element : elements) { String href = element.getAttribute(attrName); String originalRef = href; if (!StringUtils.isEmpty(href) && !href.startsWith("#")) { int fragmentIndex = href.lastIndexOf('#'); String fragment = null; if (fragmentIndex != -1) { fragment = href.substring(fragmentIndex + 1); href = href.substring(0, fragmentIndex); } String actualRef = parentRef + href; docLocationMap.put(actualRef, parentDocLoc + originalRef); UriBuilder ub = UriBuilder.fromUri(getBaseURI(m, ui)).path(actualRef).fragment(fragment); URI schemaURI = ub.build(); DOMUtils.setAttribute(element, attrName, schemaURI.toString()); } } }
private Response finalizeExistingWadlResponse(Document wadlDoc, Message m, UriInfo ui, MediaType mt) throws Exception { Object entity; if (stylesheetReference != null) { if (!applyStylesheetLocally) { ProcessingInstruction pi = wadlDoc.createProcessingInstruction("xml-stylesheet", getStylesheetInstructionData(getBaseURI(m, ui))); wadlDoc.insertBefore(pi, wadlDoc.getDocumentElement()); entity = copyDOMToString(wadlDoc); } else { entity = transformLocally(m, ui, new DOMSource(wadlDoc)); } } else { entity = new DOMSource(wadlDoc); } return Response.ok(entity, mt).build(); } private String copyDOMToString(Document wadlDoc) throws Exception {
private Response finalizeExistingWadlResponse(Document wadlDoc, Message m, UriInfo ui, MediaType mt) throws Exception { Object entity; if (stylesheetReference != null) { if (!applyStylesheetLocally) { ProcessingInstruction pi = wadlDoc.createProcessingInstruction("xml-stylesheet", getStylesheetInstructionData(getBaseURI(m, ui))); wadlDoc.insertBefore(pi, wadlDoc.getDocumentElement()); entity = copyDOMToString(wadlDoc); } else { entity = transformLocally(m, ui, new DOMSource(wadlDoc)); } } else { entity = new DOMSource(wadlDoc); } return Response.ok(entity, mt).build(); } private String copyDOMToString(Document wadlDoc) throws Exception {
StringBuilder sbMain = generateWADL(getBaseURI(m, ui), getResourcesList(m, resource), isJson, m, ui);
"resources"); if (resourcesEls.size() == 1) { DOMUtils.setAttribute(resourcesEls.get(0), "base", getBaseURI(m, ui));
StringBuilder sbMain = generateWADL(getBaseURI(m, ui), getResourcesList(m, ui), isJson, m, ui);
StringBuilder sbMain = generateWADL(getBaseURI(m, ui), getResourcesList(m, ui), isJson, m, ui);
"resources"); if (resourcesEls.size() == 1) { DOMUtils.setAttribute(resourcesEls.get(0), "base", getBaseURI(m, ui));
"resources"); if (resourcesEls.size() == 1) { DOMUtils.setAttribute(resourcesEls.get(0), "base", getBaseURI(m, ui));