@Override public Map<String, URL> getLinks() { Map<String, URL> links = super.getLinks(); links.remove(UrlBuilder.SELF); return links; } }
@Override public String getBaseType() { return getType(); }
@Override protected Resource createResource(Object obj, IdFormatter idFormatter, ApiRequest apiRequest) { Resource r = super.createResource(obj, idFormatter, apiRequest); if (r instanceof ResourceImpl) { ((ResourceImpl) r).setType("setting"); Object id = r.getFields().get("name"); if (id != null) { ((ResourceImpl) r).setId(id.toString()); } r.getLinks().remove(UrlBuilder.SELF); // Recreate the SELF url r.getLinks(); ((ResourceImpl) r).setType("activeSetting"); ((ResourceImpl) r).getFields().put("baseType", "setting"); } return r; }
protected Resource getHaConfig() { Map<String, Object> data = new HashMap<>(); String host = DB_HOST.get(); data.put("dbHost", host); data.put("enabled", HA_ENABLED.get()); data.put("clusterSize", HA_CLUSTER_SIZE.get()); if ("localhost".equals(host) || "127.0.0.1".equals(host)) { try { data.put("dbSize", dbSize()); } catch (NumberFormatException | IOException e) { data.put("dbSize", -1); } } ResourceImpl resource = new ResourceImpl("haConfig", "haConfig", data); UrlBuilder builder = ApiContext.getUrlBuilder(); resource.getLinks().put("dbdump", builder.resourceLink(resource, "dbdump")); resource.getActions().put("createscript", builder.actionLink(resource, "createscript")); return resource; }
protected void mapStack(ApiRequest apiRequest, Object original, Resource converted) { if (converted instanceof ResourceImpl) { if ("stack".equals(converted.getType())) { IdFormatter idF = ApiContext.getContext().getIdFormatter(); ((ResourceImpl)converted).setId(idF.formatId("environment", ObjectUtils.getId(original)).toString()); ((ResourceImpl)converted).setType("environment"); } } if ("stack".equals(converted.getFields().get("kind"))) { converted.getFields().put("kind", "environment"); } convertURLs(converted, "/stacks/", "/environments/", converted.getLinks()); convertURLs(converted, "/stacks/", "/environments/", converted.getActions()); }
@Override public String getType() { String type = super.getType(); return type == null ? schema.getId() : type; }