return appendIfMissing(str, suffix, false, suffixes);
return appendIfMissing(str, suffix, true, suffixes);
/** * A naive implementation of generating a jobSpec's URI within a multi-hop flow that follows the convention: * <JOB_CATALOG_SCHEME>/{@link ConfigurationKeys#JOB_GROUP_KEY}/{@link ConfigurationKeys#JOB_NAME_KEY}. */ private static URI jobSpecURIGenerator(String jobGroup, String jobName, FlowSpec flowSpec) throws URISyntaxException { return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(), StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"), "/") + jobGroup + "/" + jobName, null); } }
/** * Creates helper for archive. * @param archive absolute location of archive in underlying filesystem * @param originalBase directory for which Hadoop archive was created */ public HarPathHelper(HiveConf hconf, URI archive, URI originalBase) throws HiveException { this.originalBase = addSlash(originalBase); String parentHost = archive.getHost(); String harHost = archive.getScheme(); if (parentHost == null) { harHost += "-localhost"; } else { harHost += "-" + parentHost; } // have to make sure there's slash after .har, otherwise resolve doesn't work String path = StringUtils.appendIfMissing(archive.getPath(), "/"); if (!path.endsWith(".har/")) { throw new HiveException("HAR archive path must end with .har"); } // harUri is used to access the partition's files, which are in the archive // The format of the RI is something like: // har://underlyingfsscheme-host:port/archivepath try { base = new URI("har", archive.getUserInfo(), harHost, archive.getPort(), path, archive.getQuery(), archive.getFragment()); } catch (URISyntaxException e) { throw new HiveException("Could not create har URI from archive URI", e); } }
/** * Tests {@code appendIfMissing}. */ @Test public void testAppendIfMissing() { assertEquals("appendIfMissing(null,null)", null, StringUtils.appendIfMissing(null, null)); assertEquals("appendIfMissing(abc,null)", "abc", StringUtils.appendIfMissing("abc", null)); assertEquals("appendIfMissing(\"\",xyz)", "xyz", StringUtils.appendIfMissing("", "xyz")); assertEquals("appendIfMissing(abc,xyz)", "abcxyz", StringUtils.appendIfMissing("abc", "xyz")); assertEquals("appendIfMissing(abcxyz,xyz)", "abcxyz", StringUtils.appendIfMissing("abcxyz", "xyz")); assertEquals("appendIfMissing(aXYZ,xyz)", "aXYZxyz", StringUtils.appendIfMissing("aXYZ", "xyz")); assertEquals("appendIfMissing(null,null,null)", null, StringUtils.appendIfMissing(null, null, (CharSequence[]) null)); assertEquals("appendIfMissing(abc,null,null)", "abc", StringUtils.appendIfMissing("abc", null, (CharSequence[]) null)); assertEquals("appendIfMissing(\"\",xyz,null))", "xyz", StringUtils.appendIfMissing("", "xyz", (CharSequence[]) null)); assertEquals("appendIfMissing(abc,xyz,{null})", "abcxyz", StringUtils.appendIfMissing("abc", "xyz", new CharSequence[]{null})); assertEquals("appendIfMissing(abc,xyz,\"\")", "abc", StringUtils.appendIfMissing("abc", "xyz", "")); assertEquals("appendIfMissing(abc,xyz,mno)", "abcxyz", StringUtils.appendIfMissing("abc", "xyz", "mno")); assertEquals("appendIfMissing(abcxyz,xyz,mno)", "abcxyz", StringUtils.appendIfMissing("abcxyz", "xyz", "mno")); assertEquals("appendIfMissing(abcmno,xyz,mno)", "abcmno", StringUtils.appendIfMissing("abcmno", "xyz", "mno")); assertEquals("appendIfMissing(abcXYZ,xyz,mno)", "abcXYZxyz", StringUtils.appendIfMissing("abcXYZ", "xyz", "mno")); assertEquals("appendIfMissing(abcMNO,xyz,mno)", "abcMNOxyz", StringUtils.appendIfMissing("abcMNO", "xyz", "mno")); }
/** * A naive implementation of generating a jobSpec's URI within a multi-hop logical Flow. */ @Override public URI jobSpecURIGenerator(Object... objects) { FlowSpec flowSpec = (FlowSpec) objects[0]; ServiceNode sourceNode = (ServiceNode) objects[1]; ServiceNode targetNode = (ServiceNode) objects[2]; try { return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(), StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"),"/") + sourceNode.getNodeName() + "-" + targetNode.getNodeName(), null); } catch (URISyntaxException e) { log.error( "URI construction failed when jobSpec from " + sourceNode.getNodeName() + " to " + targetNode.getNodeName()); throw new RuntimeException(); } } }
@Override public Object apply(List<Object> strings) { String suffixed; switch (strings.size()) { case 2: suffixed = StringUtils.appendIfMissing((String) strings.get(0), (String) strings.get(1)); break; case 3: suffixed = StringUtils.appendIfMissing((String) strings.get(0), (String) strings.get(1), (String) strings.get(2)); break; default: throw new IllegalArgumentException("[APPEND_IF_MISSING] incorrect arguments. Usage: APPEND_IF_MISSING <String> <prefix> [<prefix>...]"); } return suffixed; } }
public void setSpEntityID(final String spEntityID) { this.spEntityID = StringUtils.appendIfMissing(spEntityID, "/"); }
@JsonProperty("rpt_endpoint") public String getAuthorizationRequestEndpoint() { return StringUtils.appendIfMissing(issuer, "/").concat(OAuth20Constants.UMA_AUTHORIZATION_REQUEST_URL); } }
@JsonProperty("requesting_party_claims_endpoint") public String getRequestingPartyClaimsEndpoint() { return StringUtils.appendIfMissing(issuer, "/").concat(OAuth20Constants.UMA_CLAIMS_COLLECTION_URL); }
@JsonProperty("introspection_endpoint") public String getIntrospectionEndpoint() { return StringUtils.appendIfMissing(issuer, "/").concat(OAuth20Constants.INTROSPECTION_URL); }
@JsonProperty("token_endpoint") public String getTokenEndpoint() { return StringUtils.appendIfMissing(issuer, "/").concat(OAuth20Constants.ACCESS_TOKEN_URL); }
@JsonProperty("permission_registration_endpoint") public String getPermissionRegistrationEndpoint() { return StringUtils.appendIfMissing(issuer, "/").concat(OAuth20Constants.UMA_PERMISSION_URL); }
@Override public long count() { val rest = gauth.getRest(); val countUrl = StringUtils.appendIfMissing(rest.getEndpointUrl(), "/").concat("count"); return restTemplate.getForObject(countUrl, Long.class); }
/** * A naive implementation of generating a jobSpec's URI within a multi-hop flow that follows the convention: * <JOB_CATALOG_SCHEME>/{@link ConfigurationKeys#JOB_GROUP_KEY}/{@link ConfigurationKeys#JOB_NAME_KEY}. */ private static URI jobSpecURIGenerator(String jobGroup, String jobName, FlowSpec flowSpec) throws URISyntaxException { return new URI(JobSpec.Builder.DEFAULT_JOB_CATALOG_SCHEME, flowSpec.getUri().getAuthority(), StringUtils.appendIfMissing(StringUtils.prependIfMissing(flowSpec.getUri().getPath(), "/"), "/") + jobGroup + "/" + jobName, null); } }
@Override public String getFullPath() { return getParent() == null ? SyncopeConstants.ROOT_REALM : StringUtils.appendIfMissing(getParent().getFullPath(), "/") + getName(); }
private void enableSwaggerJSON(Swagger swagger, List<String> swaggerProcessors) { final Resource.Builder builder = Resource.builder(); builder.path(basePath(originalBasePath, StringUtils.appendIfMissing(config.getSwaggerBase(), "/") + "swagger.json")) .addMethod(HttpMethod.GET) .produces(MediaType.APPLICATION_JSON) .handledBy(new SwaggerResourceController(swagger, swaggerProcessors)) .build(); registerResources(builder.build()); }
private void enableSwaggerYAML(Swagger swagger, List<String> swaggerProcessors) { final Resource.Builder builder = Resource.builder(); builder.path(basePath(originalBasePath, StringUtils.appendIfMissing(config.getSwaggerBase(), "/") + "swagger.yaml")) .addMethod(HttpMethod.GET) .produces("application/yaml") .handledBy(new SwaggerResourceController(swagger, swaggerProcessors)) .build(); registerResources(builder.build()); }
private void enableSwaggerJSON(Swagger swagger, List<String> swaggerProcessors) { final Resource.Builder builder = Resource.builder(); builder.path(basePath(originalBasePath, StringUtils.appendIfMissing(config.getSwaggerBase(), "/") + "swagger.json")) .addMethod(HttpMethod.GET) .produces(MediaType.APPLICATION_JSON) .handledBy(new SwaggerResourceController(swagger, swaggerProcessors)) .build(); registerResources(builder.build()); }
private void enableSwaggerYAML(Swagger swagger, List<String> swaggerProcessors) { final Resource.Builder builder = Resource.builder(); builder.path(basePath(originalBasePath, StringUtils.appendIfMissing(config.getSwaggerBase(), "/") + "swagger.yaml")) .addMethod(HttpMethod.GET) .produces("application/yaml") .handledBy(new SwaggerResourceController(swagger, swaggerProcessors)) .build(); registerResources(builder.build()); }