String pagePath = requestInfo.getPagePath(); String r = pagePath.substring(pagePath.lastIndexOf('/') + 1);
public void marshal( Object source, HierarchicalStreamWriter writer, MarshallingContext context) { String ref; // Special case for layer list, to handle the non-workspace-specific // endpoint for layers if (clazz.equals(LayerInfo.class) && OwsUtils.getter(clazz, "prefixedName", String.class) != null && RequestInfo.get() != null && !RequestInfo.get().getPagePath().contains("/workspaces/")) { ref = (String) OwsUtils.get(source, "prefixedName"); } else if (OwsUtils.getter(clazz, "name", String.class) != null) { ref = (String) OwsUtils.get(source, "name"); } else if (OwsUtils.getter(clazz, "id", String.class) != null) { ref = (String) OwsUtils.get(source, "id"); } else if (OwsUtils.getter(clazz, "id", Long.class) != null) { // For some reason Importer objects have Long ids so this catches that // case ref = OwsUtils.get(source, "id").toString(); } else { throw new RuntimeException( "Could not determine identifier for: " + clazz.getName()); } writer.startNode("name"); writer.setValue(ref); writer.endNode(); encodeLink(encode(ref), writer); }