public String getUri() { StringBuilder sb = new StringBuilder(); if (parentId != null) { sb.append(parentId.getUri()); } sb.append(r.getFeatures().getByClazz(this.clazz).getEndpointPath()); sb.append("/"); sb.append(id != null ? id : name); return sb.toString(); }
public static boolean isPipeSource(Repository r, Class<?> endpointClazz) { return r.getFeatures() != null && r.getEndpointFeatures(endpointClazz).getPipes().size() != 0; }
@Override public RepositoryFeatures getFeatures() { init(); return get().getFeatures(); }
@Override public String toString() { if (r == null) { return "empty id"; } StringBuilder sb = new StringBuilder(); if (parentId != null) { sb.append(parentId.toString()); } EndpointFeatures<?> clazz = r.getFeatures().getByClazz(this.clazz); sb.append(StringUtils.isEmpty(clazz.getEndpointPath()) ? "/" + clazz.getEndpointKind() : clazz.getEndpointPath()); sb.append("/"); sb.append(id != null ? id : name); return sb.toString(); }
private static Class<?> getIdRefClazz(Repository r, String endpointPath) { return r.getFeatures().getByPath(endpointPath).getClazz(); }
private Class<?> currentActionClazz() { return yawp.getFeatures().getByClazz(endpointClazz).getActionClazz(actionKey); }
private void initDatabase() { dbSynchronizer = new DatabaseSynchronizer(); dbSynchronizer.sync(r.getFeatures().getEndpointClazzes()); }
private static boolean isActionOrCollection(Repository r, HttpVerb verb, String[] parts, int i) { if (i < parts.length - 2) { return false; } if (i == parts.length - 1) { return true; } if (!isString(parts[parts.length - 1])) { return false; } String endpointPath = "/" + parts[parts.length - 2]; String possibleAction = parts[parts.length - 1]; ActionKey actionKey = new ActionKey(verb, possibleAction, true); return r.getFeatures().hasCustomAction(endpointPath, actionKey); }
@Before public void before() { r1 = Repository.r("ns1").setFeatures(yawp.getFeatures()); r2 = Repository.r("ns2").setFeatures(yawp.getFeatures()); }
@Before public void before() { yawp = Repository.r().setFeatures(new RepositoryFeaturesMock(super.yawp.getFeatures())); }
private EndpointRouter(Repository r, RequestContext ctx) { if (isWelcome(ctx.getUri())) { welcome(r); } this.ctx = ctx; this.r = r; this.verb = ctx.getHttpVerb(); this.uri = ctx.getUri(); this.requestJson = ctx.getJson(); this.params = ctx.getParams(); this.features = r.getFeatures(); try { parseAll(); } catch (EndpointNotFoundException e) { throw new HttpException(404, "Endpoint not found: " + e.getEndpointPath()); } }