List of usage examples for org.apache.commons.lang StringUtils endsWith
public static boolean endsWith(String str, String suffix)
Check if a String ends with a specified suffix.
From source file:org.sonar.java.checks.CommentedOutCodeLineCheck.java
/** * From GWT documentation:/*from ww w . java2s .c o m*/ * JSNI methods are declared native and contain JavaScript code in a specially formatted comment block * between the end of the parameter list and the trailing semicolon. * A JSNI comment block begins with the exact token {@link #START_JSNI} and ends with the exact token {@link #END_JSNI}. */ private static boolean isJSNI(String comment) { return StringUtils.startsWith(comment, START_JSNI) && StringUtils.endsWith(comment, END_JSNI); }
From source file:org.sonar.plugins.checkstyle.CheckstyleExecutorTest.java
private BaseMatcher<AuditEvent> newErrorMatcher(final String filename, final String rule) { return new BaseMatcher<AuditEvent>() { public boolean matches(Object o) { AuditEvent event = (AuditEvent) o; return StringUtils.endsWith(event.getFileName(), filename) && StringUtils.equals(event.getSourceName(), rule); }//from w ww . j a v a 2s .c om public void describeTo(Description description) { } }; }
From source file:org.sonar.plugins.checkstyle.CheckstyleExecutorTest.java
private BaseMatcher<AuditEvent> newFilenameMatcher(final String filename) { return new BaseMatcher<AuditEvent>() { public boolean matches(Object o) { AuditEvent event = (AuditEvent) o; return StringUtils.endsWith(event.getFileName(), filename); }/*from www.j av a 2 s . c o m*/ public void describeTo(Description description) { } }; }
From source file:org.sonar.plugins.flex.core.FlexResourceBridge.java
private String computeLogicalKey(org.sonar.api.resources.File file) { String logicalName = file.getKey(); if (StringUtils.endsWith(file.getKey(), ".as")) { // For ".as" files, the extension should be removed. logicalName = StringUtils.substringBeforeLast(logicalName, "."); }/* w w w . java2s . c o m*/ // and all the '/' should be replaced by a package-separator '.' return logicalName.replace('/', '.'); }
From source file:org.sonar.plugins.github.oauth.providers.GithubClient.java
@Override public Request createAuthenticationRequest() { String authorizationUrl = settings.getString(Settings.AUTHORIZATION_URL); String clientId = settings.getString(Settings.CLIENT_ID); String scope = settings.getString(Settings.SCOPE); Preconditions.checkArgument(StringUtils.isNotBlank(authorizationUrl), "Property is missing : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(!authorizationUrl.contains("?"), "Property must not contain the character ? : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(!StringUtils.endsWith(authorizationUrl, "/"), "Property must not end with with slash / : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(StringUtils.isNotBlank(clientId), "Property is missing : " + Settings.CLIENT_ID); return new Request(authorizationUrl, new OAuthQueryParams.Builder().withClientId(clientId).withScope(scope).build()); }
From source file:org.sonar.plugins.github.oauth.providers.GithubClient.java
@Override public Request createAccessTokenRequest() { String clientId = settings.getString(Settings.CLIENT_ID); String clientSecret = settings.getString(Settings.CLIENT_SECRET); String accessTokenUrl = settings.getString(Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(StringUtils.isNotBlank(accessTokenUrl), "Property is missing : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(!accessTokenUrl.contains("?"), "Property must not contain the character ? : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(!StringUtils.endsWith(accessTokenUrl, "/"), "Property must not end with with slash / : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(StringUtils.isNotBlank(clientId), "Property is missing : " + Settings.CLIENT_ID); Preconditions.checkArgument(StringUtils.isNotBlank(clientSecret), "Property is missing : " + Settings.CLIENT_SECRET); return new Request(accessTokenUrl, new OAuthQueryParams.Builder().withClientId(clientId).withClientSecret(clientSecret).build()); }
From source file:org.sonar.plugins.oauth.providers.GoogleClient.java
@Override public Request createAuthenticationRequest() { String authorizationUrl = settings.getString(Settings.AUTHORIZATION_URL); String clientId = settings.getString(Settings.CLIENT_ID); String scope = settings.getString(Settings.SCOPE); Preconditions.checkArgument(StringUtils.isNotBlank(authorizationUrl), "Property is missing : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(!authorizationUrl.contains("?"), "Property must not contain the character ? : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(!StringUtils.endsWith(authorizationUrl, "/"), "Property must not end with with slash / : " + Settings.AUTHORIZATION_URL); Preconditions.checkArgument(StringUtils.isNotBlank(clientId), "Property is missing : " + Settings.CLIENT_ID); return new Request(authorizationUrl, new OAuthQueryParams.Builder().withClientId(clientId).withScope("email").withResponseType("code") .withRedirectUri(getSonarServerUrl() + "/oauth/validate").withScope(scope).build()); }
From source file:org.sonar.plugins.oauth.providers.GoogleClient.java
@Override public Request createAccessTokenRequest() { String clientId = settings.getString(Settings.CLIENT_ID); String clientSecret = settings.getString(Settings.CLIENT_SECRET); String accessTokenUrl = settings.getString(Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(StringUtils.isNotBlank(accessTokenUrl), "Property is missing : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(!accessTokenUrl.contains("?"), "Property must not contain the character ? : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(!StringUtils.endsWith(accessTokenUrl, "/"), "Property must not end with with slash / : " + Settings.ACCESS_TOKEN_URL); Preconditions.checkArgument(StringUtils.isNotBlank(clientId), "Property is missing : " + Settings.CLIENT_ID); Preconditions.checkArgument(StringUtils.isNotBlank(clientSecret), "Property is missing : " + Settings.CLIENT_SECRET); return new Request(accessTokenUrl, new OAuthQueryParams.Builder().withClientId(clientId).withClientSecret(clientSecret) .withRedirectUri(getSonarServerUrl() + "/oauth/validate") .withGrantType("authorization_code").build()); }
From source file:org.sonar.plugins.openid.OpenIdClient.java
@VisibleForTesting void initReturnToUrl() { String sonarUrl = settings.getString(PROPERTY_SONAR_URL); Preconditions.checkArgument(StringUtils.isNotBlank(sonarUrl), "Property sonar.openid.sonarServerUrl is missing"); Preconditions.checkArgument(!sonarUrl.contains("?"), "Property sonar.openid.sonarServerUrl must not contain the character ?"); Preconditions.checkArgument(!StringUtils.endsWith(sonarUrl, "/"), "Property sonar.openid.sonarServerUrl must not end with with slash /"); returnToUrl = sonarUrl + "/openid/validate"; }
From source file:org.sonar.scanner.scan.report.HtmlReport.java
private File getReportFileDir() { String reportFileDirStr = settings.getString(HTML_REPORT_LOCATION_KEY); File reportFileDir = new File(reportFileDirStr); if (!reportFileDir.isAbsolute()) { reportFileDir = new File(fs.workDir(), reportFileDirStr); }/*from ww w . j av a 2 s .c o m*/ if (StringUtils.endsWith(reportFileDirStr, ".html")) { LOG.warn("{} should indicate a directory. Using parent folder.", HTML_REPORT_LOCATION_KEY); reportFileDir = reportFileDir.getParentFile(); } try { FileUtils.forceMkdir(reportFileDir); } catch (IOException e) { throw new IllegalStateException("Fail to create the directory " + reportFileDirStr, e); } return reportFileDir; }