private Representation resolveRepresentation(Representation representation) { String href = representation.getHref(); if (!StringUtils.hasContent(href)) { return representation; } try { Application app = application; if (!href.startsWith("#")) { ApplicationDocument applicationDocument = loadReferencedWadl(href); app = applicationDocument.getApplication(); } if (app != null) { int ix = href.lastIndexOf('#'); if (ix >= 0) { href = href.substring(ix + 1); } for (Representation m : application.getRepresentationList()) { if (m.getId().equals(href)) { return m; } } } } catch (Exception e) { e.printStackTrace(); } return representation; }
private void addRepresentationFromConfig( RestMethod restMethod, Representation representation, RestRepresentation.Type type, List<?> status) { RestRepresentation restRepresentation = restMethod.addNewRepresentation(type); restRepresentation.setMediaType(representation.getMediaType()); restRepresentation.setElement(representation.getElement()); if (status != null) { restRepresentation.setStatus(status); } restRepresentation.setId(representation.getId()); restRepresentation.setDescription(getFirstTitle(representation.getDocList(), null)); }
private void addRepresentation( Response response, RestMethod restMethod, Representation representation) { representation = resolveRepresentation(representation); List<Long> status = null; if (isWADL11) { status = response.getStatus(); } else { Node n = representation.getDomNode().getAttributes().getNamedItem("status"); if (n != null) { status = new ArrayList<Long>(); for (String s : n.getNodeValue().split(" ")) { status.add(Long.parseLong(s)); } } } boolean fault = false; if (status != null && status.size() > 0) { fault = true; for (Long s : status) { if (s < 400) { fault = false; break; } } } RestRepresentation.Type type = fault ? RestRepresentation.Type.FAULT : RestRepresentation.Type.RESPONSE; addRepresentationFromConfig(restMethod, representation, type, status); }