public static String prefixWithAndSuffixWithoutSlash(String path) { if(Strings.isEmpty(path)){ return path; } if(path.startsWith("/")){ return suffixWithoutSlash(path); }else{ return "/" + suffixWithoutSlash(path); } }
@ConfigProperty public void setIndirectServerUrl(String indirectServerUrl) {//don't change the parameter name (used by config property) indirectServerUrl = Paths.suffixWithoutSlash(indirectServerUrl); this.authorizeUrl = indirectServerUrl + "/oauth2/authorize"; this.logoutUrl = indirectServerUrl + "/oauth2/logout"; this.indirectTokenUrl = indirectServerUrl + "/oauth2/token"; }
public void scanClasspaths(String location, Consumer<Resource> func) { for(Resource resource : Resources.scan("classpath:META-INF/jmms/core/" + Paths.suffixWithoutSlash(location))) { func.accept(resource); } }
@ConfigProperty public void setDirectServerUrl(String directServerUrl) {//don't change the parameter name (used by config property) directServerUrl = Paths.suffixWithoutSlash(directServerUrl); this.tokenUrl = directServerUrl + "/oauth2/token"; this.tokenInfoUrl = directServerUrl + "/oauth2/tokeninfo"; this.userInfoUrl = directServerUrl + "/oauth2/userinfo"; this.publicKeyUrl = directServerUrl + "/oauth2/publickey"; }
@ConfigProperty public OAuth2WebAppConfigurator setClientRedirectUri(String uri) { this.clientRedirectUri = Paths.suffixWithoutSlash(uri); return this; }
@Override @ConfigProperty public OAuth2Configurator setServerUrl(String serverUrl) {//don't change the parameter name (used by config property) serverUrl = Paths.suffixWithoutSlash(serverUrl); if(null == this.authorizeUrl) this.authorizeUrl = serverUrl + "/oauth2/authorize"; if(null == this.tokenUrl) this.tokenUrl = serverUrl + "/oauth2/token"; if(null == this.tokenInfoUrl) this.tokenInfoUrl = serverUrl + "/oauth2/tokeninfo"; if(null == this.userInfoUrl) this.userInfoUrl = serverUrl + "/oauth2/userinfo"; if(null == this.publicKeyUrl) this.publicKeyUrl = serverUrl + "/oauth2/publickey"; if(null == this.logoutUrl) this.logoutUrl = serverUrl + "/oauth2/logout"; return this; }
@ConfigProperty public OAuth2WebAppConfigurator setServerUrl(String url) { this.serverUrl = Paths.suffixWithoutSlash(url); this.serverAuthorizationEndpointUrl = this.serverUrl + "/oauth2/authorize"; this.serverTokenEndpointUrl = this.serverUrl + "/oauth2/token"; this.serverLogoutEndpointUrl = this.serverUrl + "/oauth2/logout"; return this; }
protected String fullModelPath(ApiConfigurator api, RestdModel model, String path) { String modelPath = fullModelPath(api, model); return Paths.suffixWithoutSlash(modelPath) + path; }
protected static String getExpressionValue(String expression, URI uri){ if(Strings.startsWith(expression,"/")){ return Paths.suffixWithoutSlash(uri.getPath()) + expression; } if(Strings.startsWith(expression,"~")){ return Paths.suffixWithoutSlash(uri.toString()) + expression.substring(1); } if(Strings.startsWith(expression,"^")){ return expression.substring(1); } return expression; }
public void setBasePath(String basePath) { Args.notEmpty(basePath, "basePath"); Args.assertTrue(basePath.startsWith("/"), "The base path must be leading with a slash '/'"); this.basePath = Paths.suffixWithoutSlash(basePath); }
public static String prefixAndSuffixWithoutSlash(String path){ if(Strings.isEmpty(path)){ return path; } return suffixWithoutSlash(prefixWithoutSlash(path)); }
/** * Creates a new http request of the given base url and relative path. */ default HttpRequest request(String baseUrl, String path) { return request(Paths.suffixWithoutSlash(baseUrl) + Paths.prefixWithSlash(path)); }
private void postReadApiInfo(Runtime runtime, MetaApi api) { String url = runtime.getServerUrl() + Strings.nullToEmpty(api.getBasePath()); runtime.setApiUrl(Paths.suffixWithoutSlash(url)); }
protected void processRemote(MetaApi api, MetaEntity entity) { if (entity.isRemote() && Strings.isEmpty(entity.getServicePath())) { entity.setServicePath(entity.getPath()); } if (entity.isRemote()) { if (Strings.isEmpty(entity.getServiceName())) { throw new IllegalStateException("The 'service' must not be empty for remote entity '" + entity.getName() + "'"); } MetaService service = api.getService(entity.getServiceName()); if (null == service) { throw new IllegalStateException("Service '" + entity.getServiceName() + "' not found at entity '" + entity.getName() + "'"); } entity.setServiceObject(service); entity.setServiceUrl(Paths.suffixWithoutSlash(service.getUrl())); //disable all operations for remote entity. entity.getOps().setAll(false); log.info("Found remote entity '{}', url : {}", entity.getName(), entity.getServiceUrl()); } }