id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
164,600
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java
SubversionManager.createTag
public void createTag(final String tagUrl, final String commitMessage) throws IOException, InterruptedException { build.getWorkspace() .act(new SVNCreateTagCallable(tagUrl, commitMessage, getLocation(), getSvnAuthenticationProvider(build), buildListener)); }
java
public void createTag(final String tagUrl, final String commitMessage) throws IOException, InterruptedException { build.getWorkspace() .act(new SVNCreateTagCallable(tagUrl, commitMessage, getLocation(), getSvnAuthenticationProvider(build), buildListener)); }
[ "public", "void", "createTag", "(", "final", "String", "tagUrl", ",", "final", "String", "commitMessage", ")", "throws", "IOException", ",", "InterruptedException", "{", "build", ".", "getWorkspace", "(", ")", ".", "act", "(", "new", "SVNCreateTagCallable", "(", "tagUrl", ",", "commitMessage", ",", "getLocation", "(", ")", ",", "getSvnAuthenticationProvider", "(", "build", ")", ",", "buildListener", ")", ")", ";", "}" ]
Creates a tag directly from the working copy. @param tagUrl The URL of the tag to create. @param commitMessage Commit message @return The commit info upon successful operation. @throws IOException On IO of SVN failure
[ "Creates", "a", "tag", "directly", "from", "the", "working", "copy", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java#L71-L76
164,601
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java
SubversionManager.revertWorkingCopy
public void revertWorkingCopy() throws IOException, InterruptedException { build.getWorkspace() .act(new RevertWorkingCopyCallable(getLocation(), getSvnAuthenticationProvider(build), buildListener)); }
java
public void revertWorkingCopy() throws IOException, InterruptedException { build.getWorkspace() .act(new RevertWorkingCopyCallable(getLocation(), getSvnAuthenticationProvider(build), buildListener)); }
[ "public", "void", "revertWorkingCopy", "(", ")", "throws", "IOException", ",", "InterruptedException", "{", "build", ".", "getWorkspace", "(", ")", ".", "act", "(", "new", "RevertWorkingCopyCallable", "(", "getLocation", "(", ")", ",", "getSvnAuthenticationProvider", "(", "build", ")", ",", "buildListener", ")", ")", ";", "}" ]
Revert all the working copy changes.
[ "Revert", "all", "the", "working", "copy", "changes", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java#L81-L84
164,602
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java
SubversionManager.safeRevertWorkingCopy
public void safeRevertWorkingCopy() { try { revertWorkingCopy(); } catch (Exception e) { debuggingLogger.log(Level.FINE, "Failed to revert working copy", e); log("Failed to revert working copy: " + e.getLocalizedMessage()); Throwable cause = e.getCause(); if (!(cause instanceof SVNException)) { return; } SVNException svnException = (SVNException) cause; if (svnException.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LOCKED) { // work space locked attempt cleanup and try to revert again try { cleanupWorkingCopy(); } catch (Exception unlockException) { debuggingLogger.log(Level.FINE, "Failed to cleanup working copy", e); log("Failed to cleanup working copy: " + e.getLocalizedMessage()); return; } try { revertWorkingCopy(); } catch (Exception revertException) { log("Failed to revert working copy on the 2nd attempt: " + e.getLocalizedMessage()); } } } }
java
public void safeRevertWorkingCopy() { try { revertWorkingCopy(); } catch (Exception e) { debuggingLogger.log(Level.FINE, "Failed to revert working copy", e); log("Failed to revert working copy: " + e.getLocalizedMessage()); Throwable cause = e.getCause(); if (!(cause instanceof SVNException)) { return; } SVNException svnException = (SVNException) cause; if (svnException.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LOCKED) { // work space locked attempt cleanup and try to revert again try { cleanupWorkingCopy(); } catch (Exception unlockException) { debuggingLogger.log(Level.FINE, "Failed to cleanup working copy", e); log("Failed to cleanup working copy: " + e.getLocalizedMessage()); return; } try { revertWorkingCopy(); } catch (Exception revertException) { log("Failed to revert working copy on the 2nd attempt: " + e.getLocalizedMessage()); } } } }
[ "public", "void", "safeRevertWorkingCopy", "(", ")", "{", "try", "{", "revertWorkingCopy", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "debuggingLogger", ".", "log", "(", "Level", ".", "FINE", ",", "\"Failed to revert working copy\"", ",", "e", ")", ";", "log", "(", "\"Failed to revert working copy: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "Throwable", "cause", "=", "e", ".", "getCause", "(", ")", ";", "if", "(", "!", "(", "cause", "instanceof", "SVNException", ")", ")", "{", "return", ";", "}", "SVNException", "svnException", "=", "(", "SVNException", ")", "cause", ";", "if", "(", "svnException", ".", "getErrorMessage", "(", ")", ".", "getErrorCode", "(", ")", "==", "SVNErrorCode", ".", "WC_LOCKED", ")", "{", "// work space locked attempt cleanup and try to revert again", "try", "{", "cleanupWorkingCopy", "(", ")", ";", "}", "catch", "(", "Exception", "unlockException", ")", "{", "debuggingLogger", ".", "log", "(", "Level", ".", "FINE", ",", "\"Failed to cleanup working copy\"", ",", "e", ")", ";", "log", "(", "\"Failed to cleanup working copy: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "return", ";", "}", "try", "{", "revertWorkingCopy", "(", ")", ";", "}", "catch", "(", "Exception", "revertException", ")", "{", "log", "(", "\"Failed to revert working copy on the 2nd attempt: \"", "+", "e", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "}", "}", "}" ]
Attempts to revert the working copy. In case of failure it just logs the error.
[ "Attempts", "to", "revert", "the", "working", "copy", ".", "In", "case", "of", "failure", "it", "just", "logs", "the", "error", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/svn/SubversionManager.java#L89-L117
164,603
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/IssuesTrackerHelper.java
IssuesTrackerHelper.setIssueTrackerInfo
public void setIssueTrackerInfo(BuildInfoBuilder builder) { Issues issues = new Issues(); issues.setAggregateBuildIssues(aggregateBuildIssues); issues.setAggregationBuildStatus(aggregationBuildStatus); issues.setTracker(new IssueTracker("JIRA", issueTrackerVersion)); Set<Issue> affectedIssuesSet = IssuesTrackerUtils.getAffectedIssuesSet(affectedIssues); if (!affectedIssuesSet.isEmpty()) { issues.setAffectedIssues(affectedIssuesSet); } builder.issues(issues); }
java
public void setIssueTrackerInfo(BuildInfoBuilder builder) { Issues issues = new Issues(); issues.setAggregateBuildIssues(aggregateBuildIssues); issues.setAggregationBuildStatus(aggregationBuildStatus); issues.setTracker(new IssueTracker("JIRA", issueTrackerVersion)); Set<Issue> affectedIssuesSet = IssuesTrackerUtils.getAffectedIssuesSet(affectedIssues); if (!affectedIssuesSet.isEmpty()) { issues.setAffectedIssues(affectedIssuesSet); } builder.issues(issues); }
[ "public", "void", "setIssueTrackerInfo", "(", "BuildInfoBuilder", "builder", ")", "{", "Issues", "issues", "=", "new", "Issues", "(", ")", ";", "issues", ".", "setAggregateBuildIssues", "(", "aggregateBuildIssues", ")", ";", "issues", ".", "setAggregationBuildStatus", "(", "aggregationBuildStatus", ")", ";", "issues", ".", "setTracker", "(", "new", "IssueTracker", "(", "\"JIRA\"", ",", "issueTrackerVersion", ")", ")", ";", "Set", "<", "Issue", ">", "affectedIssuesSet", "=", "IssuesTrackerUtils", ".", "getAffectedIssuesSet", "(", "affectedIssues", ")", ";", "if", "(", "!", "affectedIssuesSet", ".", "isEmpty", "(", ")", ")", "{", "issues", ".", "setAffectedIssues", "(", "affectedIssuesSet", ")", ";", "}", "builder", ".", "issues", "(", "issues", ")", ";", "}" ]
Apply issues tracker info to a build info builder (used by generic tasks and maven2 which doesn't use the extractor
[ "Apply", "issues", "tracker", "info", "to", "a", "build", "info", "builder", "(", "used", "by", "generic", "tasks", "and", "maven2", "which", "doesn", "t", "use", "the", "extractor" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/IssuesTrackerHelper.java#L103-L113
164,604
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/BuildRetentionFactory.java
BuildRetentionFactory.createBuildRetention
public static BuildRetention createBuildRetention(Run build, boolean discardOldArtifacts) { BuildRetention buildRetention = new BuildRetention(discardOldArtifacts); LogRotator rotator = null; BuildDiscarder buildDiscarder = build.getParent().getBuildDiscarder(); if (buildDiscarder != null && buildDiscarder instanceof LogRotator) { rotator = (LogRotator) buildDiscarder; } if (rotator == null) { return buildRetention; } if (rotator.getNumToKeep() > -1) { buildRetention.setCount(rotator.getNumToKeep()); } if (rotator.getDaysToKeep() > -1) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, -rotator.getDaysToKeep()); buildRetention.setMinimumBuildDate(new Date(calendar.getTimeInMillis())); } List<String> notToBeDeleted = ExtractorUtils.getBuildNumbersNotToBeDeleted(build); buildRetention.setBuildNumbersNotToBeDiscarded(notToBeDeleted); return buildRetention; }
java
public static BuildRetention createBuildRetention(Run build, boolean discardOldArtifacts) { BuildRetention buildRetention = new BuildRetention(discardOldArtifacts); LogRotator rotator = null; BuildDiscarder buildDiscarder = build.getParent().getBuildDiscarder(); if (buildDiscarder != null && buildDiscarder instanceof LogRotator) { rotator = (LogRotator) buildDiscarder; } if (rotator == null) { return buildRetention; } if (rotator.getNumToKeep() > -1) { buildRetention.setCount(rotator.getNumToKeep()); } if (rotator.getDaysToKeep() > -1) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, -rotator.getDaysToKeep()); buildRetention.setMinimumBuildDate(new Date(calendar.getTimeInMillis())); } List<String> notToBeDeleted = ExtractorUtils.getBuildNumbersNotToBeDeleted(build); buildRetention.setBuildNumbersNotToBeDiscarded(notToBeDeleted); return buildRetention; }
[ "public", "static", "BuildRetention", "createBuildRetention", "(", "Run", "build", ",", "boolean", "discardOldArtifacts", ")", "{", "BuildRetention", "buildRetention", "=", "new", "BuildRetention", "(", "discardOldArtifacts", ")", ";", "LogRotator", "rotator", "=", "null", ";", "BuildDiscarder", "buildDiscarder", "=", "build", ".", "getParent", "(", ")", ".", "getBuildDiscarder", "(", ")", ";", "if", "(", "buildDiscarder", "!=", "null", "&&", "buildDiscarder", "instanceof", "LogRotator", ")", "{", "rotator", "=", "(", "LogRotator", ")", "buildDiscarder", ";", "}", "if", "(", "rotator", "==", "null", ")", "{", "return", "buildRetention", ";", "}", "if", "(", "rotator", ".", "getNumToKeep", "(", ")", ">", "-", "1", ")", "{", "buildRetention", ".", "setCount", "(", "rotator", ".", "getNumToKeep", "(", ")", ")", ";", "}", "if", "(", "rotator", ".", "getDaysToKeep", "(", ")", ">", "-", "1", ")", "{", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "calendar", ".", "add", "(", "Calendar", ".", "DAY_OF_YEAR", ",", "-", "rotator", ".", "getDaysToKeep", "(", ")", ")", ";", "buildRetention", ".", "setMinimumBuildDate", "(", "new", "Date", "(", "calendar", ".", "getTimeInMillis", "(", ")", ")", ")", ";", "}", "List", "<", "String", ">", "notToBeDeleted", "=", "ExtractorUtils", ".", "getBuildNumbersNotToBeDeleted", "(", "build", ")", ";", "buildRetention", ".", "setBuildNumbersNotToBeDiscarded", "(", "notToBeDeleted", ")", ";", "return", "buildRetention", ";", "}" ]
Create a Build retention object out of the build @param build The build to create the build retention out of @param discardOldArtifacts Flag whether to discard artifacts of those builds that are to be discarded. @return a new Build retention
[ "Create", "a", "Build", "retention", "object", "out", "of", "the", "build" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/BuildRetentionFactory.java#L24-L45
164,605
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.getImageIdFromTag
public static String getImageIdFromTag(String imageTag, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(imageTag).exec().getId(); } finally { closeQuietly(dockerClient); } }
java
public static String getImageIdFromTag(String imageTag, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(imageTag).exec().getId(); } finally { closeQuietly(dockerClient); } }
[ "public", "static", "String", "getImageIdFromTag", "(", "String", "imageTag", ",", "String", "host", ")", "throws", "IOException", "{", "DockerClient", "dockerClient", "=", "null", ";", "try", "{", "dockerClient", "=", "getDockerClient", "(", "host", ")", ";", "return", "dockerClient", ".", "inspectImageCmd", "(", "imageTag", ")", ".", "exec", "(", ")", ".", "getId", "(", ")", ";", "}", "finally", "{", "closeQuietly", "(", "dockerClient", ")", ";", "}", "}" ]
Get image Id from imageTag using DockerBuildInfoHelper client. @param imageTag @param host @return
[ "Get", "image", "Id", "from", "imageTag", "using", "DockerBuildInfoHelper", "client", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L34-L42
164,606
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.pushImage
public static void pushImage(String imageTag, String username, String password, String host) throws IOException { final AuthConfig authConfig = new AuthConfig(); authConfig.withUsername(username); authConfig.withPassword(password); DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); dockerClient.pushImageCmd(imageTag).withAuthConfig(authConfig).exec(new PushImageResultCallback()).awaitSuccess(); } finally { closeQuietly(dockerClient); } }
java
public static void pushImage(String imageTag, String username, String password, String host) throws IOException { final AuthConfig authConfig = new AuthConfig(); authConfig.withUsername(username); authConfig.withPassword(password); DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); dockerClient.pushImageCmd(imageTag).withAuthConfig(authConfig).exec(new PushImageResultCallback()).awaitSuccess(); } finally { closeQuietly(dockerClient); } }
[ "public", "static", "void", "pushImage", "(", "String", "imageTag", ",", "String", "username", ",", "String", "password", ",", "String", "host", ")", "throws", "IOException", "{", "final", "AuthConfig", "authConfig", "=", "new", "AuthConfig", "(", ")", ";", "authConfig", ".", "withUsername", "(", "username", ")", ";", "authConfig", ".", "withPassword", "(", "password", ")", ";", "DockerClient", "dockerClient", "=", "null", ";", "try", "{", "dockerClient", "=", "getDockerClient", "(", "host", ")", ";", "dockerClient", ".", "pushImageCmd", "(", "imageTag", ")", ".", "withAuthConfig", "(", "authConfig", ")", ".", "exec", "(", "new", "PushImageResultCallback", "(", ")", ")", ".", "awaitSuccess", "(", ")", ";", "}", "finally", "{", "closeQuietly", "(", "dockerClient", ")", ";", "}", "}" ]
Push docker image using the docker java client. @param imageTag @param username @param password @param host
[ "Push", "docker", "image", "using", "the", "docker", "java", "client", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L52-L64
164,607
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.pullImage
public static void pullImage(String imageTag, String username, String password, String host) throws IOException { final AuthConfig authConfig = new AuthConfig(); authConfig.withUsername(username); authConfig.withPassword(password); DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); dockerClient.pullImageCmd(imageTag).withAuthConfig(authConfig).exec(new PullImageResultCallback()).awaitSuccess(); } finally { closeQuietly(dockerClient); } }
java
public static void pullImage(String imageTag, String username, String password, String host) throws IOException { final AuthConfig authConfig = new AuthConfig(); authConfig.withUsername(username); authConfig.withPassword(password); DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); dockerClient.pullImageCmd(imageTag).withAuthConfig(authConfig).exec(new PullImageResultCallback()).awaitSuccess(); } finally { closeQuietly(dockerClient); } }
[ "public", "static", "void", "pullImage", "(", "String", "imageTag", ",", "String", "username", ",", "String", "password", ",", "String", "host", ")", "throws", "IOException", "{", "final", "AuthConfig", "authConfig", "=", "new", "AuthConfig", "(", ")", ";", "authConfig", ".", "withUsername", "(", "username", ")", ";", "authConfig", ".", "withPassword", "(", "password", ")", ";", "DockerClient", "dockerClient", "=", "null", ";", "try", "{", "dockerClient", "=", "getDockerClient", "(", "host", ")", ";", "dockerClient", ".", "pullImageCmd", "(", "imageTag", ")", ".", "withAuthConfig", "(", "authConfig", ")", ".", "exec", "(", "new", "PullImageResultCallback", "(", ")", ")", ".", "awaitSuccess", "(", ")", ";", "}", "finally", "{", "closeQuietly", "(", "dockerClient", ")", ";", "}", "}" ]
Pull docker image using the docker java client. @param imageTag @param username @param password @param host
[ "Pull", "docker", "image", "using", "the", "docker", "java", "client", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L74-L86
164,608
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.getParentId
public static String getParentId(String digest, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(digest).exec().getParent(); } finally { closeQuietly(dockerClient); } }
java
public static String getParentId(String digest, String host) throws IOException { DockerClient dockerClient = null; try { dockerClient = getDockerClient(host); return dockerClient.inspectImageCmd(digest).exec().getParent(); } finally { closeQuietly(dockerClient); } }
[ "public", "static", "String", "getParentId", "(", "String", "digest", ",", "String", "host", ")", "throws", "IOException", "{", "DockerClient", "dockerClient", "=", "null", ";", "try", "{", "dockerClient", "=", "getDockerClient", "(", "host", ")", ";", "return", "dockerClient", ".", "inspectImageCmd", "(", "digest", ")", ".", "exec", "(", ")", ".", "getParent", "(", ")", ";", "}", "finally", "{", "closeQuietly", "(", "dockerClient", ")", ";", "}", "}" ]
Get parent digest of an image. @param digest @param host @return
[ "Get", "parent", "digest", "of", "an", "image", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L95-L103
164,609
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.getLayersDigests
public static List<String> getLayersDigests(String manifestContent) throws IOException { List<String> dockerLayersDependencies = new ArrayList<String>(); JsonNode manifest = Utils.mapper().readTree(manifestContent); JsonNode schemaVersion = manifest.get("schemaVersion"); if (schemaVersion == null) { throw new IllegalStateException("Could not find 'schemaVersion' in manifest"); } boolean isSchemeVersion1 = schemaVersion.asInt() == 1; JsonNode fsLayers = getFsLayers(manifest, isSchemeVersion1); for (JsonNode fsLayer : fsLayers) { JsonNode blobSum = getBlobSum(isSchemeVersion1, fsLayer); dockerLayersDependencies.add(blobSum.asText()); } dockerLayersDependencies.add(getConfigDigest(manifestContent)); //Add manifest sha1 String manifestSha1 = Hashing.sha1().hashString(manifestContent, Charsets.UTF_8).toString(); dockerLayersDependencies.add("sha1:" + manifestSha1); return dockerLayersDependencies; }
java
public static List<String> getLayersDigests(String manifestContent) throws IOException { List<String> dockerLayersDependencies = new ArrayList<String>(); JsonNode manifest = Utils.mapper().readTree(manifestContent); JsonNode schemaVersion = manifest.get("schemaVersion"); if (schemaVersion == null) { throw new IllegalStateException("Could not find 'schemaVersion' in manifest"); } boolean isSchemeVersion1 = schemaVersion.asInt() == 1; JsonNode fsLayers = getFsLayers(manifest, isSchemeVersion1); for (JsonNode fsLayer : fsLayers) { JsonNode blobSum = getBlobSum(isSchemeVersion1, fsLayer); dockerLayersDependencies.add(blobSum.asText()); } dockerLayersDependencies.add(getConfigDigest(manifestContent)); //Add manifest sha1 String manifestSha1 = Hashing.sha1().hashString(manifestContent, Charsets.UTF_8).toString(); dockerLayersDependencies.add("sha1:" + manifestSha1); return dockerLayersDependencies; }
[ "public", "static", "List", "<", "String", ">", "getLayersDigests", "(", "String", "manifestContent", ")", "throws", "IOException", "{", "List", "<", "String", ">", "dockerLayersDependencies", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "JsonNode", "manifest", "=", "Utils", ".", "mapper", "(", ")", ".", "readTree", "(", "manifestContent", ")", ";", "JsonNode", "schemaVersion", "=", "manifest", ".", "get", "(", "\"schemaVersion\"", ")", ";", "if", "(", "schemaVersion", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Could not find 'schemaVersion' in manifest\"", ")", ";", "}", "boolean", "isSchemeVersion1", "=", "schemaVersion", ".", "asInt", "(", ")", "==", "1", ";", "JsonNode", "fsLayers", "=", "getFsLayers", "(", "manifest", ",", "isSchemeVersion1", ")", ";", "for", "(", "JsonNode", "fsLayer", ":", "fsLayers", ")", "{", "JsonNode", "blobSum", "=", "getBlobSum", "(", "isSchemeVersion1", ",", "fsLayer", ")", ";", "dockerLayersDependencies", ".", "add", "(", "blobSum", ".", "asText", "(", ")", ")", ";", "}", "dockerLayersDependencies", ".", "add", "(", "getConfigDigest", "(", "manifestContent", ")", ")", ";", "//Add manifest sha1", "String", "manifestSha1", "=", "Hashing", ".", "sha1", "(", ")", ".", "hashString", "(", "manifestContent", ",", "Charsets", ".", "UTF_8", ")", ".", "toString", "(", ")", ";", "dockerLayersDependencies", ".", "add", "(", "\"sha1:\"", "+", "manifestSha1", ")", ";", "return", "dockerLayersDependencies", ";", "}" ]
Get a list of layer digests from docker manifest. @param manifestContent @return @throws IOException
[ "Get", "a", "list", "of", "layer", "digests", "from", "docker", "manifest", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L142-L164
164,610
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.digestToFileName
public static String digestToFileName(String digest) { if (StringUtils.startsWith(digest, "sha1")) { return "manifest.json"; } return getShaVersion(digest) + "__" + getShaValue(digest); }
java
public static String digestToFileName(String digest) { if (StringUtils.startsWith(digest, "sha1")) { return "manifest.json"; } return getShaVersion(digest) + "__" + getShaValue(digest); }
[ "public", "static", "String", "digestToFileName", "(", "String", "digest", ")", "{", "if", "(", "StringUtils", ".", "startsWith", "(", "digest", ",", "\"sha1\"", ")", ")", "{", "return", "\"manifest.json\"", ";", "}", "return", "getShaVersion", "(", "digest", ")", "+", "\"__\"", "+", "getShaValue", "(", "digest", ")", ";", "}" ]
Digest format to layer file name. @param digest @return
[ "Digest", "format", "to", "layer", "file", "name", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L276-L281
164,611
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java
DockerUtils.getNumberOfDependentLayers
public static int getNumberOfDependentLayers(String imageContent) throws IOException { JsonNode history = Utils.mapper().readTree(imageContent).get("history"); if (history == null) { throw new IllegalStateException("Could not find 'history' tag"); } int layersNum = history.size(); boolean newImageLayers = true; for (int i = history.size() - 1; i >= 0; i--) { if (newImageLayers) { layersNum--; } JsonNode layer = history.get(i); JsonNode emptyLayer = layer.get("empty_layer"); if (!newImageLayers && emptyLayer != null) { layersNum--; } if (layer.get("created_by") == null) { continue; } String createdBy = layer.get("created_by").textValue(); if (createdBy.contains("ENTRYPOINT") || createdBy.contains("MAINTAINER")) { newImageLayers = false; } } return layersNum; }
java
public static int getNumberOfDependentLayers(String imageContent) throws IOException { JsonNode history = Utils.mapper().readTree(imageContent).get("history"); if (history == null) { throw new IllegalStateException("Could not find 'history' tag"); } int layersNum = history.size(); boolean newImageLayers = true; for (int i = history.size() - 1; i >= 0; i--) { if (newImageLayers) { layersNum--; } JsonNode layer = history.get(i); JsonNode emptyLayer = layer.get("empty_layer"); if (!newImageLayers && emptyLayer != null) { layersNum--; } if (layer.get("created_by") == null) { continue; } String createdBy = layer.get("created_by").textValue(); if (createdBy.contains("ENTRYPOINT") || createdBy.contains("MAINTAINER")) { newImageLayers = false; } } return layersNum; }
[ "public", "static", "int", "getNumberOfDependentLayers", "(", "String", "imageContent", ")", "throws", "IOException", "{", "JsonNode", "history", "=", "Utils", ".", "mapper", "(", ")", ".", "readTree", "(", "imageContent", ")", ".", "get", "(", "\"history\"", ")", ";", "if", "(", "history", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Could not find 'history' tag\"", ")", ";", "}", "int", "layersNum", "=", "history", ".", "size", "(", ")", ";", "boolean", "newImageLayers", "=", "true", ";", "for", "(", "int", "i", "=", "history", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "newImageLayers", ")", "{", "layersNum", "--", ";", "}", "JsonNode", "layer", "=", "history", ".", "get", "(", "i", ")", ";", "JsonNode", "emptyLayer", "=", "layer", ".", "get", "(", "\"empty_layer\"", ")", ";", "if", "(", "!", "newImageLayers", "&&", "emptyLayer", "!=", "null", ")", "{", "layersNum", "--", ";", "}", "if", "(", "layer", ".", "get", "(", "\"created_by\"", ")", "==", "null", ")", "{", "continue", ";", "}", "String", "createdBy", "=", "layer", ".", "get", "(", "\"created_by\"", ")", ".", "textValue", "(", ")", ";", "if", "(", "createdBy", ".", "contains", "(", "\"ENTRYPOINT\"", ")", "||", "createdBy", ".", "contains", "(", "\"MAINTAINER\"", ")", ")", "{", "newImageLayers", "=", "false", ";", "}", "}", "return", "layersNum", ";", "}" ]
Returns number of dependencies layers in the image. @param imageContent @return @throws IOException
[ "Returns", "number", "of", "dependencies", "layers", "in", "the", "image", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerUtils.java#L290-L319
164,612
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java
MavenReleaseWrapper.getMavenModules
private List<String> getMavenModules(MavenModuleSetBuild mavenBuild) throws IOException, InterruptedException { FilePath pathToModuleRoot = mavenBuild.getModuleRoot(); FilePath pathToPom = new FilePath(pathToModuleRoot, mavenBuild.getProject().getRootPOM(null)); return pathToPom.act(new MavenModulesExtractor()); }
java
private List<String> getMavenModules(MavenModuleSetBuild mavenBuild) throws IOException, InterruptedException { FilePath pathToModuleRoot = mavenBuild.getModuleRoot(); FilePath pathToPom = new FilePath(pathToModuleRoot, mavenBuild.getProject().getRootPOM(null)); return pathToPom.act(new MavenModulesExtractor()); }
[ "private", "List", "<", "String", ">", "getMavenModules", "(", "MavenModuleSetBuild", "mavenBuild", ")", "throws", "IOException", ",", "InterruptedException", "{", "FilePath", "pathToModuleRoot", "=", "mavenBuild", ".", "getModuleRoot", "(", ")", ";", "FilePath", "pathToPom", "=", "new", "FilePath", "(", "pathToModuleRoot", ",", "mavenBuild", ".", "getProject", "(", ")", ".", "getRootPOM", "(", "null", ")", ")", ";", "return", "pathToPom", ".", "act", "(", "new", "MavenModulesExtractor", "(", ")", ")", ";", "}" ]
Retrieve from the parent pom the path to the modules of the project
[ "Retrieve", "from", "the", "parent", "pom", "the", "path", "to", "the", "modules", "of", "the", "project" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java#L238-L242
164,613
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java
MavenReleaseWrapper.getRelativePomPath
private String getRelativePomPath(MavenModule mavenModule, MavenModuleSetBuild mavenBuild) { String relativePath = mavenModule.getRelativePath(); if (StringUtils.isBlank(relativePath)) { return POM_NAME; } // If this is the root module, return the root pom path. if (mavenModule.getModuleName().toString(). equals(mavenBuild.getProject().getRootModule().getModuleName().toString())) { return mavenBuild.getProject().getRootPOM(null); } // to remove the project folder name if exists // keeps only the name of the module String modulePath = relativePath.substring(relativePath.indexOf("/") + 1); for (String moduleName : mavenModules) { if (moduleName.contains(modulePath)) { return createPomPath(relativePath, moduleName); } } // In case this module is not in the parent pom return relativePath + "/" + POM_NAME; }
java
private String getRelativePomPath(MavenModule mavenModule, MavenModuleSetBuild mavenBuild) { String relativePath = mavenModule.getRelativePath(); if (StringUtils.isBlank(relativePath)) { return POM_NAME; } // If this is the root module, return the root pom path. if (mavenModule.getModuleName().toString(). equals(mavenBuild.getProject().getRootModule().getModuleName().toString())) { return mavenBuild.getProject().getRootPOM(null); } // to remove the project folder name if exists // keeps only the name of the module String modulePath = relativePath.substring(relativePath.indexOf("/") + 1); for (String moduleName : mavenModules) { if (moduleName.contains(modulePath)) { return createPomPath(relativePath, moduleName); } } // In case this module is not in the parent pom return relativePath + "/" + POM_NAME; }
[ "private", "String", "getRelativePomPath", "(", "MavenModule", "mavenModule", ",", "MavenModuleSetBuild", "mavenBuild", ")", "{", "String", "relativePath", "=", "mavenModule", ".", "getRelativePath", "(", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "relativePath", ")", ")", "{", "return", "POM_NAME", ";", "}", "// If this is the root module, return the root pom path.", "if", "(", "mavenModule", ".", "getModuleName", "(", ")", ".", "toString", "(", ")", ".", "equals", "(", "mavenBuild", ".", "getProject", "(", ")", ".", "getRootModule", "(", ")", ".", "getModuleName", "(", ")", ".", "toString", "(", ")", ")", ")", "{", "return", "mavenBuild", ".", "getProject", "(", ")", ".", "getRootPOM", "(", "null", ")", ";", "}", "// to remove the project folder name if exists", "// keeps only the name of the module", "String", "modulePath", "=", "relativePath", ".", "substring", "(", "relativePath", ".", "indexOf", "(", "\"/\"", ")", "+", "1", ")", ";", "for", "(", "String", "moduleName", ":", "mavenModules", ")", "{", "if", "(", "moduleName", ".", "contains", "(", "modulePath", ")", ")", "{", "return", "createPomPath", "(", "relativePath", ",", "moduleName", ")", ";", "}", "}", "// In case this module is not in the parent pom", "return", "relativePath", "+", "\"/\"", "+", "POM_NAME", ";", "}" ]
Retrieve the relative path to the pom of the module
[ "Retrieve", "the", "relative", "path", "to", "the", "pom", "of", "the", "module" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java#L271-L294
164,614
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java
MavenReleaseWrapper.createPomPath
private String createPomPath(String relativePath, String moduleName) { if (!moduleName.contains(".xml")) { // Inside the parent pom, the reference is to the pom.xml file return relativePath + "/" + POM_NAME; } // There is a reference to another xml file, which is not the pom. String dirName = relativePath.substring(0, relativePath.indexOf("/")); return dirName + "/" + moduleName; }
java
private String createPomPath(String relativePath, String moduleName) { if (!moduleName.contains(".xml")) { // Inside the parent pom, the reference is to the pom.xml file return relativePath + "/" + POM_NAME; } // There is a reference to another xml file, which is not the pom. String dirName = relativePath.substring(0, relativePath.indexOf("/")); return dirName + "/" + moduleName; }
[ "private", "String", "createPomPath", "(", "String", "relativePath", ",", "String", "moduleName", ")", "{", "if", "(", "!", "moduleName", ".", "contains", "(", "\".xml\"", ")", ")", "{", "// Inside the parent pom, the reference is to the pom.xml file", "return", "relativePath", "+", "\"/\"", "+", "POM_NAME", ";", "}", "// There is a reference to another xml file, which is not the pom.", "String", "dirName", "=", "relativePath", ".", "substring", "(", "0", ",", "relativePath", ".", "indexOf", "(", "\"/\"", ")", ")", ";", "return", "dirName", "+", "\"/\"", "+", "moduleName", ";", "}" ]
Creates the actual path to the xml file of the module.
[ "Creates", "the", "actual", "path", "to", "the", "xml", "file", "of", "the", "module", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/maven/MavenReleaseWrapper.java#L299-L307
164,615
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/maven/MavenModulesExtractor.java
MavenModulesExtractor.invoke
public List<String> invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { MavenProject mavenProject = getMavenProject(f.getAbsolutePath()); return mavenProject.getModel().getModules(); }
java
public List<String> invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { MavenProject mavenProject = getMavenProject(f.getAbsolutePath()); return mavenProject.getModel().getModules(); }
[ "public", "List", "<", "String", ">", "invoke", "(", "File", "f", ",", "VirtualChannel", "channel", ")", "throws", "IOException", ",", "InterruptedException", "{", "MavenProject", "mavenProject", "=", "getMavenProject", "(", "f", ".", "getAbsolutePath", "(", ")", ")", ";", "return", "mavenProject", ".", "getModel", "(", ")", ".", "getModules", "(", ")", ";", "}" ]
This is needed when running on slaves.
[ "This", "is", "needed", "when", "running", "on", "slaves", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/maven/MavenModulesExtractor.java#L21-L24
164,616
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.getVcsRevision
public static String getVcsRevision(Map<String, String> env) { String revision = env.get("SVN_REVISION"); if (StringUtils.isBlank(revision)) { revision = env.get(GIT_COMMIT); } if (StringUtils.isBlank(revision)) { revision = env.get("P4_CHANGELIST"); } return revision; }
java
public static String getVcsRevision(Map<String, String> env) { String revision = env.get("SVN_REVISION"); if (StringUtils.isBlank(revision)) { revision = env.get(GIT_COMMIT); } if (StringUtils.isBlank(revision)) { revision = env.get("P4_CHANGELIST"); } return revision; }
[ "public", "static", "String", "getVcsRevision", "(", "Map", "<", "String", ",", "String", ">", "env", ")", "{", "String", "revision", "=", "env", ".", "get", "(", "\"SVN_REVISION\"", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "revision", ")", ")", "{", "revision", "=", "env", ".", "get", "(", "GIT_COMMIT", ")", ";", "}", "if", "(", "StringUtils", ".", "isBlank", "(", "revision", ")", ")", "{", "revision", "=", "env", ".", "get", "(", "\"P4_CHANGELIST\"", ")", ";", "}", "return", "revision", ";", "}" ]
Get the VCS revision from the Jenkins build environment. The search will one of "SVN_REVISION", "GIT_COMMIT", "P4_CHANGELIST" in the environment. @param env Th Jenkins build environment. @return The vcs revision for supported VCS
[ "Get", "the", "VCS", "revision", "from", "the", "Jenkins", "build", "environment", ".", "The", "search", "will", "one", "of", "SVN_REVISION", "GIT_COMMIT", "P4_CHANGELIST", "in", "the", "environment", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L81-L90
164,617
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.getVcsUrl
public static String getVcsUrl(Map<String, String> env) { String url = env.get("SVN_URL"); if (StringUtils.isBlank(url)) { url = publicGitUrl(env.get("GIT_URL")); } if (StringUtils.isBlank(url)) { url = env.get("P4PORT"); } return url; }
java
public static String getVcsUrl(Map<String, String> env) { String url = env.get("SVN_URL"); if (StringUtils.isBlank(url)) { url = publicGitUrl(env.get("GIT_URL")); } if (StringUtils.isBlank(url)) { url = env.get("P4PORT"); } return url; }
[ "public", "static", "String", "getVcsUrl", "(", "Map", "<", "String", ",", "String", ">", "env", ")", "{", "String", "url", "=", "env", ".", "get", "(", "\"SVN_URL\"", ")", ";", "if", "(", "StringUtils", ".", "isBlank", "(", "url", ")", ")", "{", "url", "=", "publicGitUrl", "(", "env", ".", "get", "(", "\"GIT_URL\"", ")", ")", ";", "}", "if", "(", "StringUtils", ".", "isBlank", "(", "url", ")", ")", "{", "url", "=", "env", ".", "get", "(", "\"P4PORT\"", ")", ";", "}", "return", "url", ";", "}" ]
Get the VCS url from the Jenkins build environment. The search will one of "SVN_REVISION", "GIT_COMMIT", "P4_CHANGELIST" in the environment. @param env Th Jenkins build environment. @return The vcs url for supported VCS
[ "Get", "the", "VCS", "url", "from", "the", "Jenkins", "build", "environment", ".", "The", "search", "will", "one", "of", "SVN_REVISION", "GIT_COMMIT", "P4_CHANGELIST", "in", "the", "environment", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L99-L108
164,618
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.daysBetween
private static long daysBetween(Date date1, Date date2) { long diff; if (date2.after(date1)) { diff = date2.getTime() - date1.getTime(); } else { diff = date1.getTime() - date2.getTime(); } return diff / (24 * 60 * 60 * 1000); }
java
private static long daysBetween(Date date1, Date date2) { long diff; if (date2.after(date1)) { diff = date2.getTime() - date1.getTime(); } else { diff = date1.getTime() - date2.getTime(); } return diff / (24 * 60 * 60 * 1000); }
[ "private", "static", "long", "daysBetween", "(", "Date", "date1", ",", "Date", "date2", ")", "{", "long", "diff", ";", "if", "(", "date2", ".", "after", "(", "date1", ")", ")", "{", "diff", "=", "date2", ".", "getTime", "(", ")", "-", "date1", ".", "getTime", "(", ")", ";", "}", "else", "{", "diff", "=", "date1", ".", "getTime", "(", ")", "-", "date2", ".", "getTime", "(", ")", ";", "}", "return", "diff", "/", "(", "24", "*", "60", "*", "60", "*", "1000", ")", ";", "}" ]
Naive implementation of the difference in days between two dates
[ "Naive", "implementation", "of", "the", "difference", "in", "days", "between", "two", "dates" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L394-L402
164,619
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.getBuildNumbersNotToBeDeleted
public static List<String> getBuildNumbersNotToBeDeleted(Run build) { List<String> notToDelete = Lists.newArrayList(); List<? extends Run<?, ?>> builds = build.getParent().getBuilds(); for (Run<?, ?> run : builds) { if (run.isKeepLog()) { notToDelete.add(String.valueOf(run.getNumber())); } } return notToDelete; }
java
public static List<String> getBuildNumbersNotToBeDeleted(Run build) { List<String> notToDelete = Lists.newArrayList(); List<? extends Run<?, ?>> builds = build.getParent().getBuilds(); for (Run<?, ?> run : builds) { if (run.isKeepLog()) { notToDelete.add(String.valueOf(run.getNumber())); } } return notToDelete; }
[ "public", "static", "List", "<", "String", ">", "getBuildNumbersNotToBeDeleted", "(", "Run", "build", ")", "{", "List", "<", "String", ">", "notToDelete", "=", "Lists", ".", "newArrayList", "(", ")", ";", "List", "<", "?", "extends", "Run", "<", "?", ",", "?", ">", ">", "builds", "=", "build", ".", "getParent", "(", ")", ".", "getBuilds", "(", ")", ";", "for", "(", "Run", "<", "?", ",", "?", ">", "run", ":", "builds", ")", "{", "if", "(", "run", ".", "isKeepLog", "(", ")", ")", "{", "notToDelete", ".", "add", "(", "String", ".", "valueOf", "(", "run", ".", "getNumber", "(", ")", ")", ")", ";", "}", "}", "return", "notToDelete", ";", "}" ]
Get the list of build numbers that are to be kept forever.
[ "Get", "the", "list", "of", "build", "numbers", "that", "are", "to", "be", "kept", "forever", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L415-L424
164,620
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.entityToString
public static String entityToString(HttpEntity entity) throws IOException { if (entity != null) { InputStream is = entity.getContent(); return IOUtils.toString(is, "UTF-8"); } return ""; }
java
public static String entityToString(HttpEntity entity) throws IOException { if (entity != null) { InputStream is = entity.getContent(); return IOUtils.toString(is, "UTF-8"); } return ""; }
[ "public", "static", "String", "entityToString", "(", "HttpEntity", "entity", ")", "throws", "IOException", "{", "if", "(", "entity", "!=", "null", ")", "{", "InputStream", "is", "=", "entity", ".", "getContent", "(", ")", ";", "return", "IOUtils", ".", "toString", "(", "is", ",", "\"UTF-8\"", ")", ";", "}", "return", "\"\"", ";", "}" ]
Converts the http entity to string. If entity is null, returns empty string. @param entity @return @throws IOException
[ "Converts", "the", "http", "entity", "to", "string", ".", "If", "entity", "is", "null", "returns", "empty", "string", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L555-L561
164,621
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/ExtractorUtils.java
ExtractorUtils.createAndGetTempDir
public static FilePath createAndGetTempDir(final FilePath ws) throws IOException, InterruptedException { // The token that combines the project name and unique number to create unique workspace directory. String workspaceList = System.getProperty("hudson.slaves.WorkspaceList"); return ws.act(new MasterToSlaveCallable<FilePath, IOException>() { @Override public FilePath call() { final FilePath tempDir = ws.sibling(ws.getName() + Objects.toString(workspaceList, "@") + "tmp").child("artifactory"); File tempDirFile = new File(tempDir.getRemote()); tempDirFile.mkdirs(); tempDirFile.deleteOnExit(); return tempDir; } }); }
java
public static FilePath createAndGetTempDir(final FilePath ws) throws IOException, InterruptedException { // The token that combines the project name and unique number to create unique workspace directory. String workspaceList = System.getProperty("hudson.slaves.WorkspaceList"); return ws.act(new MasterToSlaveCallable<FilePath, IOException>() { @Override public FilePath call() { final FilePath tempDir = ws.sibling(ws.getName() + Objects.toString(workspaceList, "@") + "tmp").child("artifactory"); File tempDirFile = new File(tempDir.getRemote()); tempDirFile.mkdirs(); tempDirFile.deleteOnExit(); return tempDir; } }); }
[ "public", "static", "FilePath", "createAndGetTempDir", "(", "final", "FilePath", "ws", ")", "throws", "IOException", ",", "InterruptedException", "{", "// The token that combines the project name and unique number to create unique workspace directory.", "String", "workspaceList", "=", "System", ".", "getProperty", "(", "\"hudson.slaves.WorkspaceList\"", ")", ";", "return", "ws", ".", "act", "(", "new", "MasterToSlaveCallable", "<", "FilePath", ",", "IOException", ">", "(", ")", "{", "@", "Override", "public", "FilePath", "call", "(", ")", "{", "final", "FilePath", "tempDir", "=", "ws", ".", "sibling", "(", "ws", ".", "getName", "(", ")", "+", "Objects", ".", "toString", "(", "workspaceList", ",", "\"@\"", ")", "+", "\"tmp\"", ")", ".", "child", "(", "\"artifactory\"", ")", ";", "File", "tempDirFile", "=", "new", "File", "(", "tempDir", ".", "getRemote", "(", ")", ")", ";", "tempDirFile", ".", "mkdirs", "(", ")", ";", "tempDirFile", ".", "deleteOnExit", "(", ")", ";", "return", "tempDir", ";", "}", "}", ")", ";", "}" ]
Create a temporary directory under a given workspace
[ "Create", "a", "temporary", "directory", "under", "a", "given", "workspace" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/ExtractorUtils.java#L586-L599
164,622
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/maven2/MavenDependenciesRecorder.java
MavenDependenciesRecorder.postExecute
@Override public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) { //listener.getLogger().println("[MavenDependenciesRecorder] mojo: " + mojo.getClass() + ":" + mojo.getGoal()); //listener.getLogger().println("[MavenDependenciesRecorder] dependencies: " + pom.getArtifacts()); recordMavenDependencies(pom.getArtifacts()); return true; }
java
@Override public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) { //listener.getLogger().println("[MavenDependenciesRecorder] mojo: " + mojo.getClass() + ":" + mojo.getGoal()); //listener.getLogger().println("[MavenDependenciesRecorder] dependencies: " + pom.getArtifacts()); recordMavenDependencies(pom.getArtifacts()); return true; }
[ "@", "Override", "public", "boolean", "postExecute", "(", "MavenBuildProxy", "build", ",", "MavenProject", "pom", ",", "MojoInfo", "mojo", ",", "BuildListener", "listener", ",", "Throwable", "error", ")", "{", "//listener.getLogger().println(\"[MavenDependenciesRecorder] mojo: \" + mojo.getClass() + \":\" + mojo.getGoal());", "//listener.getLogger().println(\"[MavenDependenciesRecorder] dependencies: \" + pom.getArtifacts());", "recordMavenDependencies", "(", "pom", ".", "getArtifacts", "(", ")", ")", ";", "return", "true", ";", "}" ]
Mojos perform different dependency resolution, so we add dependencies for each mojo.
[ "Mojos", "perform", "different", "dependency", "resolution", "so", "we", "add", "dependencies", "for", "each", "mojo", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven2/MavenDependenciesRecorder.java#L54-L61
164,623
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/maven2/MavenDependenciesRecorder.java
MavenDependenciesRecorder.postBuild
@Override public boolean postBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException, IOException { build.executeAsync(new BuildCallable<Void, IOException>() { // record is transient, so needs to make a copy first private final Set<MavenDependency> d = dependencies; public Void call(MavenBuild build) throws IOException, InterruptedException { // add the action //TODO: [by yl] These actions are persisted into the build.xml of each build run - we need another //context to store these actions build.getActions().add(new MavenDependenciesRecord(build, d)); return null; } }); return true; }
java
@Override public boolean postBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException, IOException { build.executeAsync(new BuildCallable<Void, IOException>() { // record is transient, so needs to make a copy first private final Set<MavenDependency> d = dependencies; public Void call(MavenBuild build) throws IOException, InterruptedException { // add the action //TODO: [by yl] These actions are persisted into the build.xml of each build run - we need another //context to store these actions build.getActions().add(new MavenDependenciesRecord(build, d)); return null; } }); return true; }
[ "@", "Override", "public", "boolean", "postBuild", "(", "MavenBuildProxy", "build", ",", "MavenProject", "pom", ",", "BuildListener", "listener", ")", "throws", "InterruptedException", ",", "IOException", "{", "build", ".", "executeAsync", "(", "new", "BuildCallable", "<", "Void", ",", "IOException", ">", "(", ")", "{", "// record is transient, so needs to make a copy first", "private", "final", "Set", "<", "MavenDependency", ">", "d", "=", "dependencies", ";", "public", "Void", "call", "(", "MavenBuild", "build", ")", "throws", "IOException", ",", "InterruptedException", "{", "// add the action", "//TODO: [by yl] These actions are persisted into the build.xml of each build run - we need another", "//context to store these actions", "build", ".", "getActions", "(", ")", ".", "add", "(", "new", "MavenDependenciesRecord", "(", "build", ",", "d", ")", ")", ";", "return", "null", ";", "}", "}", ")", ";", "return", "true", ";", "}" ]
Sends the collected dependencies over to the master and record them.
[ "Sends", "the", "collected", "dependencies", "over", "to", "the", "master", "and", "record", "them", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven2/MavenDependenciesRecorder.java#L66-L82
164,624
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/CredentialManager.java
CredentialManager.getPreferredDeployer
public static CredentialsConfig getPreferredDeployer(DeployerOverrider deployerOverrider, ArtifactoryServer server) { if (deployerOverrider.isOverridingDefaultDeployer()) { CredentialsConfig deployerCredentialsConfig = deployerOverrider.getDeployerCredentialsConfig(); if (deployerCredentialsConfig != null) { return deployerCredentialsConfig; } } if (server != null) { CredentialsConfig deployerCredentials = server.getDeployerCredentialsConfig(); if (deployerCredentials != null) { return deployerCredentials; } } return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG; }
java
public static CredentialsConfig getPreferredDeployer(DeployerOverrider deployerOverrider, ArtifactoryServer server) { if (deployerOverrider.isOverridingDefaultDeployer()) { CredentialsConfig deployerCredentialsConfig = deployerOverrider.getDeployerCredentialsConfig(); if (deployerCredentialsConfig != null) { return deployerCredentialsConfig; } } if (server != null) { CredentialsConfig deployerCredentials = server.getDeployerCredentialsConfig(); if (deployerCredentials != null) { return deployerCredentials; } } return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG; }
[ "public", "static", "CredentialsConfig", "getPreferredDeployer", "(", "DeployerOverrider", "deployerOverrider", ",", "ArtifactoryServer", "server", ")", "{", "if", "(", "deployerOverrider", ".", "isOverridingDefaultDeployer", "(", ")", ")", "{", "CredentialsConfig", "deployerCredentialsConfig", "=", "deployerOverrider", ".", "getDeployerCredentialsConfig", "(", ")", ";", "if", "(", "deployerCredentialsConfig", "!=", "null", ")", "{", "return", "deployerCredentialsConfig", ";", "}", "}", "if", "(", "server", "!=", "null", ")", "{", "CredentialsConfig", "deployerCredentials", "=", "server", ".", "getDeployerCredentialsConfig", "(", ")", ";", "if", "(", "deployerCredentials", "!=", "null", ")", "{", "return", "deployerCredentials", ";", "}", "}", "return", "CredentialsConfig", ".", "EMPTY_CREDENTIALS_CONFIG", ";", "}" ]
Decides and returns the preferred deployment credentials to use from this builder settings and selected server @param deployerOverrider Deploy-overriding capable builder @param server Selected Artifactory server @return Preferred deployment credentials
[ "Decides", "and", "returns", "the", "preferred", "deployment", "credentials", "to", "use", "from", "this", "builder", "settings", "and", "selected", "server" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/CredentialManager.java#L41-L57
164,625
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java
Maven3Builder.perform
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion()); EnvVars env = build.getEnvironment(listener); FilePath workDir = build.getModuleRoot(); FilePath ws = build.getWorkspace(); FilePath mavenHome = getMavenHome(listener, env, launcher); if (!mavenHome.exists()) { listener.error("Couldn't find Maven home: " + mavenHome.getRemote()); throw new Run.RunnerAbortedException(); } ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, ws, ws); String[] cmds = cmdLine.toCommandArray(); return RunMaven(build, launcher, listener, env, workDir, cmds); }
java
@Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion()); EnvVars env = build.getEnvironment(listener); FilePath workDir = build.getModuleRoot(); FilePath ws = build.getWorkspace(); FilePath mavenHome = getMavenHome(listener, env, launcher); if (!mavenHome.exists()) { listener.error("Couldn't find Maven home: " + mavenHome.getRemote()); throw new Run.RunnerAbortedException(); } ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, ws, ws); String[] cmds = cmdLine.toCommandArray(); return RunMaven(build, launcher, listener, env, workDir, cmds); }
[ "@", "Override", "public", "boolean", "perform", "(", "AbstractBuild", "<", "?", ",", "?", ">", "build", ",", "Launcher", "launcher", ",", "BuildListener", "listener", ")", "throws", "InterruptedException", ",", "IOException", "{", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Jenkins Artifactory Plugin version: \"", "+", "ActionableHelper", ".", "getArtifactoryPluginVersion", "(", ")", ")", ";", "EnvVars", "env", "=", "build", ".", "getEnvironment", "(", "listener", ")", ";", "FilePath", "workDir", "=", "build", ".", "getModuleRoot", "(", ")", ";", "FilePath", "ws", "=", "build", ".", "getWorkspace", "(", ")", ";", "FilePath", "mavenHome", "=", "getMavenHome", "(", "listener", ",", "env", ",", "launcher", ")", ";", "if", "(", "!", "mavenHome", ".", "exists", "(", ")", ")", "{", "listener", ".", "error", "(", "\"Couldn't find Maven home: \"", "+", "mavenHome", ".", "getRemote", "(", ")", ")", ";", "throw", "new", "Run", ".", "RunnerAbortedException", "(", ")", ";", "}", "ArgumentListBuilder", "cmdLine", "=", "buildMavenCmdLine", "(", "build", ",", "listener", ",", "env", ",", "launcher", ",", "mavenHome", ",", "ws", ",", "ws", ")", ";", "String", "[", "]", "cmds", "=", "cmdLine", ".", "toCommandArray", "(", ")", ";", "return", "RunMaven", "(", "build", ",", "launcher", ",", "listener", ",", "env", ",", "workDir", ",", "cmds", ")", ";", "}" ]
Used by FreeStyle Maven jobs only
[ "Used", "by", "FreeStyle", "Maven", "jobs", "only" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java#L81-L97
164,626
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java
Maven3Builder.perform
public boolean perform(Run<?, ?> build, Launcher launcher, TaskListener listener, EnvVars env, FilePath workDir, FilePath tempDir) throws InterruptedException, IOException { listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion()); FilePath mavenHome = getMavenHome(listener, env, launcher); if (!mavenHome.exists()) { listener.getLogger().println("Couldn't find Maven home at " + mavenHome.getRemote() + " on agent " + Utils.getAgentName(workDir) + ". This could be because this build is running inside a Docker container."); } ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, workDir, tempDir); String[] cmds = cmdLine.toCommandArray(); return RunMaven(build, launcher, listener, env, workDir, cmds); }
java
public boolean perform(Run<?, ?> build, Launcher launcher, TaskListener listener, EnvVars env, FilePath workDir, FilePath tempDir) throws InterruptedException, IOException { listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion()); FilePath mavenHome = getMavenHome(listener, env, launcher); if (!mavenHome.exists()) { listener.getLogger().println("Couldn't find Maven home at " + mavenHome.getRemote() + " on agent " + Utils.getAgentName(workDir) + ". This could be because this build is running inside a Docker container."); } ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, workDir, tempDir); String[] cmds = cmdLine.toCommandArray(); return RunMaven(build, launcher, listener, env, workDir, cmds); }
[ "public", "boolean", "perform", "(", "Run", "<", "?", ",", "?", ">", "build", ",", "Launcher", "launcher", ",", "TaskListener", "listener", ",", "EnvVars", "env", ",", "FilePath", "workDir", ",", "FilePath", "tempDir", ")", "throws", "InterruptedException", ",", "IOException", "{", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Jenkins Artifactory Plugin version: \"", "+", "ActionableHelper", ".", "getArtifactoryPluginVersion", "(", ")", ")", ";", "FilePath", "mavenHome", "=", "getMavenHome", "(", "listener", ",", "env", ",", "launcher", ")", ";", "if", "(", "!", "mavenHome", ".", "exists", "(", ")", ")", "{", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Couldn't find Maven home at \"", "+", "mavenHome", ".", "getRemote", "(", ")", "+", "\" on agent \"", "+", "Utils", ".", "getAgentName", "(", "workDir", ")", "+", "\". This could be because this build is running inside a Docker container.\"", ")", ";", "}", "ArgumentListBuilder", "cmdLine", "=", "buildMavenCmdLine", "(", "build", ",", "listener", ",", "env", ",", "launcher", ",", "mavenHome", ",", "workDir", ",", "tempDir", ")", ";", "String", "[", "]", "cmds", "=", "cmdLine", ".", "toCommandArray", "(", ")", ";", "return", "RunMaven", "(", "build", ",", "launcher", ",", "listener", ",", "env", ",", "workDir", ",", "cmds", ")", ";", "}" ]
Used by Pipeline jobs only
[ "Used", "by", "Pipeline", "jobs", "only" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java#L100-L112
164,627
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java
Maven3Builder.copyClassWorldsFile
private FilePath copyClassWorldsFile(FilePath ws, URL resource) { try { FilePath remoteClassworlds = ws.createTextTempFile("classworlds", "conf", ""); remoteClassworlds.copyFrom(resource); return remoteClassworlds; } catch (Exception e) { throw new RuntimeException(e); } }
java
private FilePath copyClassWorldsFile(FilePath ws, URL resource) { try { FilePath remoteClassworlds = ws.createTextTempFile("classworlds", "conf", ""); remoteClassworlds.copyFrom(resource); return remoteClassworlds; } catch (Exception e) { throw new RuntimeException(e); } }
[ "private", "FilePath", "copyClassWorldsFile", "(", "FilePath", "ws", ",", "URL", "resource", ")", "{", "try", "{", "FilePath", "remoteClassworlds", "=", "ws", ".", "createTextTempFile", "(", "\"classworlds\"", ",", "\"conf\"", ",", "\"\"", ")", ";", "remoteClassworlds", ".", "copyFrom", "(", "resource", ")", ";", "return", "remoteClassworlds", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Copies a classworlds file to a temporary location either on the local filesystem or on a slave depending on the node type. @return The path of the classworlds.conf file
[ "Copies", "a", "classworlds", "file", "to", "a", "temporary", "location", "either", "on", "the", "local", "filesystem", "or", "on", "a", "slave", "depending", "on", "the", "node", "type", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/maven3/Maven3Builder.java#L284-L293
164,628
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/action/ActionableHelper.java
ActionableHelper.getPublisher
public static <T extends Publisher> T getPublisher(AbstractProject<?, ?> project, Class<T> type) { // Search for a publisher of the given type in the project and return it if found: T publisher = new PublisherFindImpl<T>().find(project, type); if (publisher != null) { return publisher; } // If not found, the publisher might be wrapped by a "Flexible Publish" publisher. The below searches for it inside the // Flexible Publisher: publisher = new PublisherFlexible<T>().find(project, type); return publisher; }
java
public static <T extends Publisher> T getPublisher(AbstractProject<?, ?> project, Class<T> type) { // Search for a publisher of the given type in the project and return it if found: T publisher = new PublisherFindImpl<T>().find(project, type); if (publisher != null) { return publisher; } // If not found, the publisher might be wrapped by a "Flexible Publish" publisher. The below searches for it inside the // Flexible Publisher: publisher = new PublisherFlexible<T>().find(project, type); return publisher; }
[ "public", "static", "<", "T", "extends", "Publisher", ">", "T", "getPublisher", "(", "AbstractProject", "<", "?", ",", "?", ">", "project", ",", "Class", "<", "T", ">", "type", ")", "{", "// Search for a publisher of the given type in the project and return it if found:", "T", "publisher", "=", "new", "PublisherFindImpl", "<", "T", ">", "(", ")", ".", "find", "(", "project", ",", "type", ")", ";", "if", "(", "publisher", "!=", "null", ")", "{", "return", "publisher", ";", "}", "// If not found, the publisher might be wrapped by a \"Flexible Publish\" publisher. The below searches for it inside the", "// Flexible Publisher:", "publisher", "=", "new", "PublisherFlexible", "<", "T", ">", "(", ")", ".", "find", "(", "project", ",", "type", ")", ";", "return", "publisher", ";", "}" ]
Search for a publisher of the given type in a project and return it, or null if it is not found. @return The publisher
[ "Search", "for", "a", "publisher", "of", "the", "given", "type", "in", "a", "project", "and", "return", "it", "or", "null", "if", "it", "is", "not", "found", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/action/ActionableHelper.java#L80-L90
164,629
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/action/ActionableHelper.java
ActionableHelper.getArtifactoryPluginVersion
public static String getArtifactoryPluginVersion() { String pluginsSortName = "artifactory"; //Validates Jenkins existence because in some jobs the Jenkins instance is unreachable if (Jenkins.getInstance() != null && Jenkins.getInstance().getPlugin(pluginsSortName) != null && Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper() != null) { return Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper().getVersion(); } return ""; }
java
public static String getArtifactoryPluginVersion() { String pluginsSortName = "artifactory"; //Validates Jenkins existence because in some jobs the Jenkins instance is unreachable if (Jenkins.getInstance() != null && Jenkins.getInstance().getPlugin(pluginsSortName) != null && Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper() != null) { return Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper().getVersion(); } return ""; }
[ "public", "static", "String", "getArtifactoryPluginVersion", "(", ")", "{", "String", "pluginsSortName", "=", "\"artifactory\"", ";", "//Validates Jenkins existence because in some jobs the Jenkins instance is unreachable", "if", "(", "Jenkins", ".", "getInstance", "(", ")", "!=", "null", "&&", "Jenkins", ".", "getInstance", "(", ")", ".", "getPlugin", "(", "pluginsSortName", ")", "!=", "null", "&&", "Jenkins", ".", "getInstance", "(", ")", ".", "getPlugin", "(", "pluginsSortName", ")", ".", "getWrapper", "(", ")", "!=", "null", ")", "{", "return", "Jenkins", ".", "getInstance", "(", ")", ".", "getPlugin", "(", "pluginsSortName", ")", ".", "getWrapper", "(", ")", ".", "getVersion", "(", ")", ";", "}", "return", "\"\"", ";", "}" ]
Returns the version of Jenkins Artifactory Plugin or empty string if not found @return the version of Jenkins Artifactory Plugin or empty string if not found
[ "Returns", "the", "version", "of", "Jenkins", "Artifactory", "Plugin", "or", "empty", "string", "if", "not", "found" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/action/ActionableHelper.java#L250-L259
164,630
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/action/ActionableHelper.java
ActionableHelper.deleteFilePath
public static void deleteFilePath(FilePath workspace, String path) throws IOException { if (StringUtils.isNotBlank(path)) { try { FilePath propertiesFile = new FilePath(workspace, path); propertiesFile.delete(); } catch (Exception e) { throw new IOException("Could not delete temp file: " + path); } } }
java
public static void deleteFilePath(FilePath workspace, String path) throws IOException { if (StringUtils.isNotBlank(path)) { try { FilePath propertiesFile = new FilePath(workspace, path); propertiesFile.delete(); } catch (Exception e) { throw new IOException("Could not delete temp file: " + path); } } }
[ "public", "static", "void", "deleteFilePath", "(", "FilePath", "workspace", ",", "String", "path", ")", "throws", "IOException", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "path", ")", ")", "{", "try", "{", "FilePath", "propertiesFile", "=", "new", "FilePath", "(", "workspace", ",", "path", ")", ";", "propertiesFile", ".", "delete", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IOException", "(", "\"Could not delete temp file: \"", "+", "path", ")", ";", "}", "}", "}" ]
Deletes a FilePath file. @param workspace The build workspace. @param path The path in the workspace. @throws IOException In case of missing file.
[ "Deletes", "a", "FilePath", "file", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/action/ActionableHelper.java#L277-L286
164,631
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/git/GitManager.java
GitManager.getRemoteUrl
public String getRemoteUrl(String defaultRemoteUrl) { if (StringUtils.isBlank(defaultRemoteUrl)) { RemoteConfig remoteConfig = getJenkinsScm().getRepositories().get(0); URIish uri = remoteConfig.getURIs().get(0); return uri.toPrivateString(); } return defaultRemoteUrl; }
java
public String getRemoteUrl(String defaultRemoteUrl) { if (StringUtils.isBlank(defaultRemoteUrl)) { RemoteConfig remoteConfig = getJenkinsScm().getRepositories().get(0); URIish uri = remoteConfig.getURIs().get(0); return uri.toPrivateString(); } return defaultRemoteUrl; }
[ "public", "String", "getRemoteUrl", "(", "String", "defaultRemoteUrl", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "defaultRemoteUrl", ")", ")", "{", "RemoteConfig", "remoteConfig", "=", "getJenkinsScm", "(", ")", ".", "getRepositories", "(", ")", ".", "get", "(", "0", ")", ";", "URIish", "uri", "=", "remoteConfig", ".", "getURIs", "(", ")", ".", "get", "(", "0", ")", ";", "return", "uri", ".", "toPrivateString", "(", ")", ";", "}", "return", "defaultRemoteUrl", ";", "}" ]
This method is currently in use only by the SvnCoordinator
[ "This", "method", "is", "currently", "in", "use", "only", "by", "the", "SvnCoordinator" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/git/GitManager.java#L185-L193
164,632
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/RepositoryConf.java
RepositoryConf.getRepoKey
public String getRepoKey() { String repoKey; if (isDynamicMode()) { repoKey = keyFromText; } else { repoKey = keyFromSelect; } return repoKey; }
java
public String getRepoKey() { String repoKey; if (isDynamicMode()) { repoKey = keyFromText; } else { repoKey = keyFromSelect; } return repoKey; }
[ "public", "String", "getRepoKey", "(", ")", "{", "String", "repoKey", ";", "if", "(", "isDynamicMode", "(", ")", ")", "{", "repoKey", "=", "keyFromText", ";", "}", "else", "{", "repoKey", "=", "keyFromSelect", ";", "}", "return", "repoKey", ";", "}" ]
Used to get the current repository key @return keyFromText or keyFromSelect reflected by the dynamicMode flag
[ "Used", "to", "get", "the", "current", "repository", "key" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/RepositoryConf.java#L34-L42
164,633
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java
Env.collectVariables
public void collectVariables(EnvVars env, Run build, TaskListener listener) { EnvVars buildParameters = Utils.extractBuildParameters(build, listener); if (buildParameters != null) { env.putAll(buildParameters); } addAllWithFilter(envVars, env, filter.getPatternFilter()); Map<String, String> sysEnv = new HashMap<>(); Properties systemProperties = System.getProperties(); Enumeration<?> enumeration = systemProperties.propertyNames(); while (enumeration.hasMoreElements()) { String propertyKey = (String) enumeration.nextElement(); sysEnv.put(propertyKey, systemProperties.getProperty(propertyKey)); } addAllWithFilter(sysVars, sysEnv, filter.getPatternFilter()); }
java
public void collectVariables(EnvVars env, Run build, TaskListener listener) { EnvVars buildParameters = Utils.extractBuildParameters(build, listener); if (buildParameters != null) { env.putAll(buildParameters); } addAllWithFilter(envVars, env, filter.getPatternFilter()); Map<String, String> sysEnv = new HashMap<>(); Properties systemProperties = System.getProperties(); Enumeration<?> enumeration = systemProperties.propertyNames(); while (enumeration.hasMoreElements()) { String propertyKey = (String) enumeration.nextElement(); sysEnv.put(propertyKey, systemProperties.getProperty(propertyKey)); } addAllWithFilter(sysVars, sysEnv, filter.getPatternFilter()); }
[ "public", "void", "collectVariables", "(", "EnvVars", "env", ",", "Run", "build", ",", "TaskListener", "listener", ")", "{", "EnvVars", "buildParameters", "=", "Utils", ".", "extractBuildParameters", "(", "build", ",", "listener", ")", ";", "if", "(", "buildParameters", "!=", "null", ")", "{", "env", ".", "putAll", "(", "buildParameters", ")", ";", "}", "addAllWithFilter", "(", "envVars", ",", "env", ",", "filter", ".", "getPatternFilter", "(", ")", ")", ";", "Map", "<", "String", ",", "String", ">", "sysEnv", "=", "new", "HashMap", "<>", "(", ")", ";", "Properties", "systemProperties", "=", "System", ".", "getProperties", "(", ")", ";", "Enumeration", "<", "?", ">", "enumeration", "=", "systemProperties", ".", "propertyNames", "(", ")", ";", "while", "(", "enumeration", ".", "hasMoreElements", "(", ")", ")", "{", "String", "propertyKey", "=", "(", "String", ")", "enumeration", ".", "nextElement", "(", ")", ";", "sysEnv", ".", "put", "(", "propertyKey", ",", "systemProperties", ".", "getProperty", "(", "propertyKey", ")", ")", ";", "}", "addAllWithFilter", "(", "sysVars", ",", "sysEnv", ",", "filter", ".", "getPatternFilter", "(", ")", ")", ";", "}" ]
Collect environment variables and system properties under with filter constrains
[ "Collect", "environment", "variables", "and", "system", "properties", "under", "with", "filter", "constrains" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java#L36-L50
164,634
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java
Env.append
protected void append(Env env) { addAllWithFilter(this.envVars, env.envVars, filter.getPatternFilter()); addAllWithFilter(this.sysVars, env.sysVars, filter.getPatternFilter()); }
java
protected void append(Env env) { addAllWithFilter(this.envVars, env.envVars, filter.getPatternFilter()); addAllWithFilter(this.sysVars, env.sysVars, filter.getPatternFilter()); }
[ "protected", "void", "append", "(", "Env", "env", ")", "{", "addAllWithFilter", "(", "this", ".", "envVars", ",", "env", ".", "envVars", ",", "filter", ".", "getPatternFilter", "(", ")", ")", ";", "addAllWithFilter", "(", "this", ".", "sysVars", ",", "env", ".", "sysVars", ",", "filter", ".", "getPatternFilter", "(", ")", ")", ";", "}" ]
Append environment variables and system properties from othre PipelineEvn object
[ "Append", "environment", "variables", "and", "system", "properties", "from", "othre", "PipelineEvn", "object" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java#L55-L58
164,635
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java
Env.addAllWithFilter
private void addAllWithFilter(Map<String, String> toMap, Map<String, String> fromMap, IncludeExcludePatterns pattern) { for (Object o : fromMap.entrySet()) { Map.Entry entry = (Map.Entry) o; String key = (String) entry.getKey(); if (PatternMatcher.pathConflicts(key, pattern)) { continue; } toMap.put(key, (String) entry.getValue()); } }
java
private void addAllWithFilter(Map<String, String> toMap, Map<String, String> fromMap, IncludeExcludePatterns pattern) { for (Object o : fromMap.entrySet()) { Map.Entry entry = (Map.Entry) o; String key = (String) entry.getKey(); if (PatternMatcher.pathConflicts(key, pattern)) { continue; } toMap.put(key, (String) entry.getValue()); } }
[ "private", "void", "addAllWithFilter", "(", "Map", "<", "String", ",", "String", ">", "toMap", ",", "Map", "<", "String", ",", "String", ">", "fromMap", ",", "IncludeExcludePatterns", "pattern", ")", "{", "for", "(", "Object", "o", ":", "fromMap", ".", "entrySet", "(", ")", ")", "{", "Map", ".", "Entry", "entry", "=", "(", "Map", ".", "Entry", ")", "o", ";", "String", "key", "=", "(", "String", ")", "entry", ".", "getKey", "(", ")", ";", "if", "(", "PatternMatcher", ".", "pathConflicts", "(", "key", ",", "pattern", ")", ")", "{", "continue", ";", "}", "toMap", ".", "put", "(", "key", ",", "(", "String", ")", "entry", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Adds all pairs from 'fromMap' to 'toMap' excluding once that matching the pattern
[ "Adds", "all", "pairs", "from", "fromMap", "to", "toMap", "excluding", "once", "that", "matching", "the", "pattern" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/Env.java#L63-L72
164,636
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java
DeployerResolverOverriderConverter.credentialsMigration
public void credentialsMigration(T overrider, Class overriderClass) { try { deployerMigration(overrider, overriderClass); resolverMigration(overrider, overriderClass); } catch (NoSuchFieldException | IllegalAccessException | IOException e) { converterErrors.add(getConversionErrorMessage(overrider, e)); } }
java
public void credentialsMigration(T overrider, Class overriderClass) { try { deployerMigration(overrider, overriderClass); resolverMigration(overrider, overriderClass); } catch (NoSuchFieldException | IllegalAccessException | IOException e) { converterErrors.add(getConversionErrorMessage(overrider, e)); } }
[ "public", "void", "credentialsMigration", "(", "T", "overrider", ",", "Class", "overriderClass", ")", "{", "try", "{", "deployerMigration", "(", "overrider", ",", "overriderClass", ")", ";", "resolverMigration", "(", "overrider", ",", "overriderClass", ")", ";", "}", "catch", "(", "NoSuchFieldException", "|", "IllegalAccessException", "|", "IOException", "e", ")", "{", "converterErrors", ".", "add", "(", "getConversionErrorMessage", "(", "overrider", ",", "e", ")", ")", ";", "}", "}" ]
Migrate to Jenkins "Credentials" plugin from the old credential implementation
[ "Migrate", "to", "Jenkins", "Credentials", "plugin", "from", "the", "old", "credential", "implementation" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java#L72-L79
164,637
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java
DeployerResolverOverriderConverter.createInitialResolveDetailsFromDeployDetails
private ServerDetails createInitialResolveDetailsFromDeployDetails(ServerDetails deployerDetails) { RepositoryConf oldResolveRepositoryConfig = deployerDetails.getResolveReleaseRepository(); RepositoryConf oldSnapshotResolveRepositoryConfig = deployerDetails.getResolveSnapshotRepository(); RepositoryConf resolverReleaseRepos = oldResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldResolveRepositoryConfig; RepositoryConf resolveSnapshotRepos = oldSnapshotResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotResolveRepositoryConfig; return new ServerDetails(deployerDetails.getArtifactoryName(), deployerDetails.getArtifactoryUrl(), null, null, resolverReleaseRepos, resolveSnapshotRepos, null, null); }
java
private ServerDetails createInitialResolveDetailsFromDeployDetails(ServerDetails deployerDetails) { RepositoryConf oldResolveRepositoryConfig = deployerDetails.getResolveReleaseRepository(); RepositoryConf oldSnapshotResolveRepositoryConfig = deployerDetails.getResolveSnapshotRepository(); RepositoryConf resolverReleaseRepos = oldResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldResolveRepositoryConfig; RepositoryConf resolveSnapshotRepos = oldSnapshotResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotResolveRepositoryConfig; return new ServerDetails(deployerDetails.getArtifactoryName(), deployerDetails.getArtifactoryUrl(), null, null, resolverReleaseRepos, resolveSnapshotRepos, null, null); }
[ "private", "ServerDetails", "createInitialResolveDetailsFromDeployDetails", "(", "ServerDetails", "deployerDetails", ")", "{", "RepositoryConf", "oldResolveRepositoryConfig", "=", "deployerDetails", ".", "getResolveReleaseRepository", "(", ")", ";", "RepositoryConf", "oldSnapshotResolveRepositoryConfig", "=", "deployerDetails", ".", "getResolveSnapshotRepository", "(", ")", ";", "RepositoryConf", "resolverReleaseRepos", "=", "oldResolveRepositoryConfig", "==", "null", "?", "RepositoryConf", ".", "emptyRepositoryConfig", ":", "oldResolveRepositoryConfig", ";", "RepositoryConf", "resolveSnapshotRepos", "=", "oldSnapshotResolveRepositoryConfig", "==", "null", "?", "RepositoryConf", ".", "emptyRepositoryConfig", ":", "oldSnapshotResolveRepositoryConfig", ";", "return", "new", "ServerDetails", "(", "deployerDetails", ".", "getArtifactoryName", "(", ")", ",", "deployerDetails", ".", "getArtifactoryUrl", "(", ")", ",", "null", ",", "null", ",", "resolverReleaseRepos", ",", "resolveSnapshotRepos", ",", "null", ",", "null", ")", ";", "}" ]
Creates a new ServerDetails object for resolver, this will take URL and name from the deployer ServerDetails as a default behaviour
[ "Creates", "a", "new", "ServerDetails", "object", "for", "resolver", "this", "will", "take", "URL", "and", "name", "from", "the", "deployer", "ServerDetails", "as", "a", "default", "behaviour" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java#L181-L188
164,638
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java
DeployerResolverOverriderConverter.createInitialDeployDetailsFromOldDeployDetails
private ServerDetails createInitialDeployDetailsFromOldDeployDetails(ServerDetails oldDeployerDetails) { RepositoryConf oldDeployRepositoryConfig = oldDeployerDetails.getDeployReleaseRepository(); RepositoryConf oldSnapshotDeployRepositoryConfig = oldDeployerDetails.getDeploySnapshotRepository(); RepositoryConf deployReleaseRepos = oldDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldDeployRepositoryConfig; RepositoryConf deploySnapshotRepos = oldSnapshotDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotDeployRepositoryConfig; return new ServerDetails(oldDeployerDetails.getArtifactoryName(), oldDeployerDetails.getArtifactoryUrl(), deployReleaseRepos, deploySnapshotRepos, null, null, null, null); }
java
private ServerDetails createInitialDeployDetailsFromOldDeployDetails(ServerDetails oldDeployerDetails) { RepositoryConf oldDeployRepositoryConfig = oldDeployerDetails.getDeployReleaseRepository(); RepositoryConf oldSnapshotDeployRepositoryConfig = oldDeployerDetails.getDeploySnapshotRepository(); RepositoryConf deployReleaseRepos = oldDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldDeployRepositoryConfig; RepositoryConf deploySnapshotRepos = oldSnapshotDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotDeployRepositoryConfig; return new ServerDetails(oldDeployerDetails.getArtifactoryName(), oldDeployerDetails.getArtifactoryUrl(), deployReleaseRepos, deploySnapshotRepos, null, null, null, null); }
[ "private", "ServerDetails", "createInitialDeployDetailsFromOldDeployDetails", "(", "ServerDetails", "oldDeployerDetails", ")", "{", "RepositoryConf", "oldDeployRepositoryConfig", "=", "oldDeployerDetails", ".", "getDeployReleaseRepository", "(", ")", ";", "RepositoryConf", "oldSnapshotDeployRepositoryConfig", "=", "oldDeployerDetails", ".", "getDeploySnapshotRepository", "(", ")", ";", "RepositoryConf", "deployReleaseRepos", "=", "oldDeployRepositoryConfig", "==", "null", "?", "RepositoryConf", ".", "emptyRepositoryConfig", ":", "oldDeployRepositoryConfig", ";", "RepositoryConf", "deploySnapshotRepos", "=", "oldSnapshotDeployRepositoryConfig", "==", "null", "?", "RepositoryConf", ".", "emptyRepositoryConfig", ":", "oldSnapshotDeployRepositoryConfig", ";", "return", "new", "ServerDetails", "(", "oldDeployerDetails", ".", "getArtifactoryName", "(", ")", ",", "oldDeployerDetails", ".", "getArtifactoryUrl", "(", ")", ",", "deployReleaseRepos", ",", "deploySnapshotRepos", ",", "null", ",", "null", ",", "null", ",", "null", ")", ";", "}" ]
Creates a new ServerDetails object for deployer, this will take URL and name from the oldDeployer ServerDetails
[ "Creates", "a", "new", "ServerDetails", "object", "for", "deployer", "this", "will", "take", "URL", "and", "name", "from", "the", "oldDeployer", "ServerDetails" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/converters/DeployerResolverOverriderConverter.java#L193-L200
164,639
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/PropertyUtils.java
PropertyUtils.loadGradleProperties
private static Properties loadGradleProperties(FilePath gradlePropertiesFilePath) throws IOException, InterruptedException { return gradlePropertiesFilePath.act(new MasterToSlaveFileCallable<Properties>() { public Properties invoke(File gradlePropertiesFile, VirtualChannel channel) throws IOException, InterruptedException { Properties gradleProps = new Properties(); if (gradlePropertiesFile.exists()) { debuggingLogger.fine("Gradle properties file exists at: " + gradlePropertiesFile.getAbsolutePath()); FileInputStream stream = null; try { stream = new FileInputStream(gradlePropertiesFile); gradleProps.load(stream); } catch (IOException e) { debuggingLogger.fine("IO exception occurred while trying to read properties file from: " + gradlePropertiesFile.getAbsolutePath()); throw new RuntimeException(e); } finally { IOUtils.closeQuietly(stream); } } return gradleProps; } }); }
java
private static Properties loadGradleProperties(FilePath gradlePropertiesFilePath) throws IOException, InterruptedException { return gradlePropertiesFilePath.act(new MasterToSlaveFileCallable<Properties>() { public Properties invoke(File gradlePropertiesFile, VirtualChannel channel) throws IOException, InterruptedException { Properties gradleProps = new Properties(); if (gradlePropertiesFile.exists()) { debuggingLogger.fine("Gradle properties file exists at: " + gradlePropertiesFile.getAbsolutePath()); FileInputStream stream = null; try { stream = new FileInputStream(gradlePropertiesFile); gradleProps.load(stream); } catch (IOException e) { debuggingLogger.fine("IO exception occurred while trying to read properties file from: " + gradlePropertiesFile.getAbsolutePath()); throw new RuntimeException(e); } finally { IOUtils.closeQuietly(stream); } } return gradleProps; } }); }
[ "private", "static", "Properties", "loadGradleProperties", "(", "FilePath", "gradlePropertiesFilePath", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "gradlePropertiesFilePath", ".", "act", "(", "new", "MasterToSlaveFileCallable", "<", "Properties", ">", "(", ")", "{", "public", "Properties", "invoke", "(", "File", "gradlePropertiesFile", ",", "VirtualChannel", "channel", ")", "throws", "IOException", ",", "InterruptedException", "{", "Properties", "gradleProps", "=", "new", "Properties", "(", ")", ";", "if", "(", "gradlePropertiesFile", ".", "exists", "(", ")", ")", "{", "debuggingLogger", ".", "fine", "(", "\"Gradle properties file exists at: \"", "+", "gradlePropertiesFile", ".", "getAbsolutePath", "(", ")", ")", ";", "FileInputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "new", "FileInputStream", "(", "gradlePropertiesFile", ")", ";", "gradleProps", ".", "load", "(", "stream", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "debuggingLogger", ".", "fine", "(", "\"IO exception occurred while trying to read properties file from: \"", "+", "gradlePropertiesFile", ".", "getAbsolutePath", "(", ")", ")", ";", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "stream", ")", ";", "}", "}", "return", "gradleProps", ";", "}", "}", ")", ";", "}" ]
Load a properties file from a file path @param gradlePropertiesFilePath The file path where the gradle.properties is located. @return The loaded properties. @throws IOException In case an error occurs while reading the properties file, this exception is thrown.
[ "Load", "a", "properties", "file", "from", "a", "file", "path" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/PropertyUtils.java#L81-L104
164,640
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java
DockerImage.generateBuildInfoModule
public Module generateBuildInfoModule(Run build, TaskListener listener, ArtifactoryConfigurator config, String buildName, String buildNumber, String timestamp) throws IOException { if (artifactsProps == null) { artifactsProps = ArrayListMultimap.create(); } artifactsProps.put("build.name", buildName); artifactsProps.put("build.number", buildNumber); artifactsProps.put("build.timestamp", timestamp); String artifactsPropsStr = ExtractorUtils.buildPropertiesString(artifactsProps); Properties buildInfoItemsProps = new Properties(); buildInfoItemsProps.setProperty("build.name", buildName); buildInfoItemsProps.setProperty("build.number", buildNumber); buildInfoItemsProps.setProperty("build.timestamp", timestamp); ArtifactoryServer server = config.getArtifactoryServer(); CredentialsConfig preferredResolver = server.getDeployerCredentialsConfig(); ArtifactoryDependenciesClient dependenciesClient = null; ArtifactoryBuildInfoClient propertyChangeClient = null; try { dependenciesClient = server.createArtifactoryDependenciesClient( preferredResolver.provideUsername(build.getParent()), preferredResolver.providePassword(build.getParent()), server.createProxyConfiguration(Jenkins.getInstance().proxy), listener); CredentialsConfig preferredDeployer = CredentialManager.getPreferredDeployer(config, server); propertyChangeClient = server.createArtifactoryClient( preferredDeployer.provideUsername(build.getParent()), preferredDeployer.providePassword(build.getParent()), server.createProxyConfiguration(Jenkins.getInstance().proxy)); Module buildInfoModule = new Module(); buildInfoModule.setId(imageTag.substring(imageTag.indexOf("/") + 1)); // If manifest and imagePath not found, return. if ((StringUtils.isEmpty(manifest) || StringUtils.isEmpty(imagePath)) && !findAndSetManifestFromArtifactory(server, dependenciesClient, listener)) { return buildInfoModule; } listener.getLogger().println("Fetching details of published docker layers from Artifactory..."); boolean includeVirtualReposSupported = propertyChangeClient.getArtifactoryVersion().isAtLeast(VIRTUAL_REPOS_SUPPORTED_VERSION); DockerLayers layers = createLayers(dependenciesClient, includeVirtualReposSupported); listener.getLogger().println("Tagging published docker layers with build properties in Artifactory..."); setDependenciesAndArtifacts(buildInfoModule, layers, artifactsPropsStr, buildInfoItemsProps, dependenciesClient, propertyChangeClient, server); setBuildInfoModuleProps(buildInfoModule); return buildInfoModule; } finally { if (dependenciesClient != null) { dependenciesClient.close(); } if (propertyChangeClient != null) { propertyChangeClient.close(); } } }
java
public Module generateBuildInfoModule(Run build, TaskListener listener, ArtifactoryConfigurator config, String buildName, String buildNumber, String timestamp) throws IOException { if (artifactsProps == null) { artifactsProps = ArrayListMultimap.create(); } artifactsProps.put("build.name", buildName); artifactsProps.put("build.number", buildNumber); artifactsProps.put("build.timestamp", timestamp); String artifactsPropsStr = ExtractorUtils.buildPropertiesString(artifactsProps); Properties buildInfoItemsProps = new Properties(); buildInfoItemsProps.setProperty("build.name", buildName); buildInfoItemsProps.setProperty("build.number", buildNumber); buildInfoItemsProps.setProperty("build.timestamp", timestamp); ArtifactoryServer server = config.getArtifactoryServer(); CredentialsConfig preferredResolver = server.getDeployerCredentialsConfig(); ArtifactoryDependenciesClient dependenciesClient = null; ArtifactoryBuildInfoClient propertyChangeClient = null; try { dependenciesClient = server.createArtifactoryDependenciesClient( preferredResolver.provideUsername(build.getParent()), preferredResolver.providePassword(build.getParent()), server.createProxyConfiguration(Jenkins.getInstance().proxy), listener); CredentialsConfig preferredDeployer = CredentialManager.getPreferredDeployer(config, server); propertyChangeClient = server.createArtifactoryClient( preferredDeployer.provideUsername(build.getParent()), preferredDeployer.providePassword(build.getParent()), server.createProxyConfiguration(Jenkins.getInstance().proxy)); Module buildInfoModule = new Module(); buildInfoModule.setId(imageTag.substring(imageTag.indexOf("/") + 1)); // If manifest and imagePath not found, return. if ((StringUtils.isEmpty(manifest) || StringUtils.isEmpty(imagePath)) && !findAndSetManifestFromArtifactory(server, dependenciesClient, listener)) { return buildInfoModule; } listener.getLogger().println("Fetching details of published docker layers from Artifactory..."); boolean includeVirtualReposSupported = propertyChangeClient.getArtifactoryVersion().isAtLeast(VIRTUAL_REPOS_SUPPORTED_VERSION); DockerLayers layers = createLayers(dependenciesClient, includeVirtualReposSupported); listener.getLogger().println("Tagging published docker layers with build properties in Artifactory..."); setDependenciesAndArtifacts(buildInfoModule, layers, artifactsPropsStr, buildInfoItemsProps, dependenciesClient, propertyChangeClient, server); setBuildInfoModuleProps(buildInfoModule); return buildInfoModule; } finally { if (dependenciesClient != null) { dependenciesClient.close(); } if (propertyChangeClient != null) { propertyChangeClient.close(); } } }
[ "public", "Module", "generateBuildInfoModule", "(", "Run", "build", ",", "TaskListener", "listener", ",", "ArtifactoryConfigurator", "config", ",", "String", "buildName", ",", "String", "buildNumber", ",", "String", "timestamp", ")", "throws", "IOException", "{", "if", "(", "artifactsProps", "==", "null", ")", "{", "artifactsProps", "=", "ArrayListMultimap", ".", "create", "(", ")", ";", "}", "artifactsProps", ".", "put", "(", "\"build.name\"", ",", "buildName", ")", ";", "artifactsProps", ".", "put", "(", "\"build.number\"", ",", "buildNumber", ")", ";", "artifactsProps", ".", "put", "(", "\"build.timestamp\"", ",", "timestamp", ")", ";", "String", "artifactsPropsStr", "=", "ExtractorUtils", ".", "buildPropertiesString", "(", "artifactsProps", ")", ";", "Properties", "buildInfoItemsProps", "=", "new", "Properties", "(", ")", ";", "buildInfoItemsProps", ".", "setProperty", "(", "\"build.name\"", ",", "buildName", ")", ";", "buildInfoItemsProps", ".", "setProperty", "(", "\"build.number\"", ",", "buildNumber", ")", ";", "buildInfoItemsProps", ".", "setProperty", "(", "\"build.timestamp\"", ",", "timestamp", ")", ";", "ArtifactoryServer", "server", "=", "config", ".", "getArtifactoryServer", "(", ")", ";", "CredentialsConfig", "preferredResolver", "=", "server", ".", "getDeployerCredentialsConfig", "(", ")", ";", "ArtifactoryDependenciesClient", "dependenciesClient", "=", "null", ";", "ArtifactoryBuildInfoClient", "propertyChangeClient", "=", "null", ";", "try", "{", "dependenciesClient", "=", "server", ".", "createArtifactoryDependenciesClient", "(", "preferredResolver", ".", "provideUsername", "(", "build", ".", "getParent", "(", ")", ")", ",", "preferredResolver", ".", "providePassword", "(", "build", ".", "getParent", "(", ")", ")", ",", "server", ".", "createProxyConfiguration", "(", "Jenkins", ".", "getInstance", "(", ")", ".", "proxy", ")", ",", "listener", ")", ";", "CredentialsConfig", "preferredDeployer", "=", "CredentialManager", ".", "getPreferredDeployer", "(", "config", ",", "server", ")", ";", "propertyChangeClient", "=", "server", ".", "createArtifactoryClient", "(", "preferredDeployer", ".", "provideUsername", "(", "build", ".", "getParent", "(", ")", ")", ",", "preferredDeployer", ".", "providePassword", "(", "build", ".", "getParent", "(", ")", ")", ",", "server", ".", "createProxyConfiguration", "(", "Jenkins", ".", "getInstance", "(", ")", ".", "proxy", ")", ")", ";", "Module", "buildInfoModule", "=", "new", "Module", "(", ")", ";", "buildInfoModule", ".", "setId", "(", "imageTag", ".", "substring", "(", "imageTag", ".", "indexOf", "(", "\"/\"", ")", "+", "1", ")", ")", ";", "// If manifest and imagePath not found, return.", "if", "(", "(", "StringUtils", ".", "isEmpty", "(", "manifest", ")", "||", "StringUtils", ".", "isEmpty", "(", "imagePath", ")", ")", "&&", "!", "findAndSetManifestFromArtifactory", "(", "server", ",", "dependenciesClient", ",", "listener", ")", ")", "{", "return", "buildInfoModule", ";", "}", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Fetching details of published docker layers from Artifactory...\"", ")", ";", "boolean", "includeVirtualReposSupported", "=", "propertyChangeClient", ".", "getArtifactoryVersion", "(", ")", ".", "isAtLeast", "(", "VIRTUAL_REPOS_SUPPORTED_VERSION", ")", ";", "DockerLayers", "layers", "=", "createLayers", "(", "dependenciesClient", ",", "includeVirtualReposSupported", ")", ";", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Tagging published docker layers with build properties in Artifactory...\"", ")", ";", "setDependenciesAndArtifacts", "(", "buildInfoModule", ",", "layers", ",", "artifactsPropsStr", ",", "buildInfoItemsProps", ",", "dependenciesClient", ",", "propertyChangeClient", ",", "server", ")", ";", "setBuildInfoModuleProps", "(", "buildInfoModule", ")", ";", "return", "buildInfoModule", ";", "}", "finally", "{", "if", "(", "dependenciesClient", "!=", "null", ")", "{", "dependenciesClient", ".", "close", "(", ")", ";", "}", "if", "(", "propertyChangeClient", "!=", "null", ")", "{", "propertyChangeClient", ".", "close", "(", ")", ";", "}", "}", "}" ]
Generates the build-info module for this docker image. Additionally. this method tags the deployed docker layers with properties, such as build.name, build.number and custom properties defined in the Jenkins build. @param build @param listener @param config @param buildName @param buildNumber @param timestamp @return @throws IOException
[ "Generates", "the", "build", "-", "info", "module", "for", "this", "docker", "image", ".", "Additionally", ".", "this", "method", "tags", "the", "deployed", "docker", "layers", "with", "properties", "such", "as", "build", ".", "name", "build", ".", "number", "and", "custom", "properties", "defined", "in", "the", "Jenkins", "build", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java#L115-L169
164,641
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java
DockerImage.findAndSetManifestFromArtifactory
private boolean findAndSetManifestFromArtifactory(ArtifactoryServer server, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException { String candidateImagePath = DockerUtils.getImagePath(imageTag); String manifestPath; // Try to get manifest, assuming reverse proxy manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/"); if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) { return true; } // Try to get manifest, assuming proxy-less candidateImagePath = candidateImagePath.substring(candidateImagePath.indexOf("/") + 1); manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/"); if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) { return true; } // Couldn't find correct manifest listener.getLogger().println("Could not find corresponding manifest.json file in Artifactory."); return false; }
java
private boolean findAndSetManifestFromArtifactory(ArtifactoryServer server, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException { String candidateImagePath = DockerUtils.getImagePath(imageTag); String manifestPath; // Try to get manifest, assuming reverse proxy manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/"); if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) { return true; } // Try to get manifest, assuming proxy-less candidateImagePath = candidateImagePath.substring(candidateImagePath.indexOf("/") + 1); manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/"); if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) { return true; } // Couldn't find correct manifest listener.getLogger().println("Could not find corresponding manifest.json file in Artifactory."); return false; }
[ "private", "boolean", "findAndSetManifestFromArtifactory", "(", "ArtifactoryServer", "server", ",", "ArtifactoryDependenciesClient", "dependenciesClient", ",", "TaskListener", "listener", ")", "throws", "IOException", "{", "String", "candidateImagePath", "=", "DockerUtils", ".", "getImagePath", "(", "imageTag", ")", ";", "String", "manifestPath", ";", "// Try to get manifest, assuming reverse proxy", "manifestPath", "=", "StringUtils", ".", "join", "(", "new", "String", "[", "]", "{", "server", ".", "getUrl", "(", ")", ",", "targetRepo", ",", "candidateImagePath", ",", "\"manifest.json\"", "}", ",", "\"/\"", ")", ";", "if", "(", "checkAndSetManifestAndImagePathCandidates", "(", "manifestPath", ",", "candidateImagePath", ",", "dependenciesClient", ",", "listener", ")", ")", "{", "return", "true", ";", "}", "// Try to get manifest, assuming proxy-less", "candidateImagePath", "=", "candidateImagePath", ".", "substring", "(", "candidateImagePath", ".", "indexOf", "(", "\"/\"", ")", "+", "1", ")", ";", "manifestPath", "=", "StringUtils", ".", "join", "(", "new", "String", "[", "]", "{", "server", ".", "getUrl", "(", ")", ",", "targetRepo", ",", "candidateImagePath", ",", "\"manifest.json\"", "}", ",", "\"/\"", ")", ";", "if", "(", "checkAndSetManifestAndImagePathCandidates", "(", "manifestPath", ",", "candidateImagePath", ",", "dependenciesClient", ",", "listener", ")", ")", "{", "return", "true", ";", "}", "// Couldn't find correct manifest", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Could not find corresponding manifest.json file in Artifactory.\"", ")", ";", "return", "false", ";", "}" ]
Find and validate manifest.json file in Artifactory for the current image. Since provided imageTag differs between reverse-proxy and proxy-less configuration, try to build the correct manifest path. @param server @param dependenciesClient @param listener @return @throws IOException
[ "Find", "and", "validate", "manifest", ".", "json", "file", "in", "Artifactory", "for", "the", "current", "image", ".", "Since", "provided", "imageTag", "differs", "between", "reverse", "-", "proxy", "and", "proxy", "-", "less", "configuration", "try", "to", "build", "the", "correct", "manifest", "path", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java#L180-L200
164,642
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java
DockerImage.checkAndSetManifestAndImagePathCandidates
private boolean checkAndSetManifestAndImagePathCandidates(String manifestPath, String candidateImagePath, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException { String candidateManifest = getManifestFromArtifactory(dependenciesClient, manifestPath); if (candidateManifest == null) { return false; } String imageDigest = DockerUtils.getConfigDigest(candidateManifest); if (imageDigest.equals(imageId)) { manifest = candidateManifest; imagePath = candidateImagePath; return true; } listener.getLogger().println(String.format("Found incorrect manifest.json file in Artifactory in the following path: %s\nExpecting: %s got: %s", manifestPath, imageId, imageDigest)); return false; }
java
private boolean checkAndSetManifestAndImagePathCandidates(String manifestPath, String candidateImagePath, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException { String candidateManifest = getManifestFromArtifactory(dependenciesClient, manifestPath); if (candidateManifest == null) { return false; } String imageDigest = DockerUtils.getConfigDigest(candidateManifest); if (imageDigest.equals(imageId)) { manifest = candidateManifest; imagePath = candidateImagePath; return true; } listener.getLogger().println(String.format("Found incorrect manifest.json file in Artifactory in the following path: %s\nExpecting: %s got: %s", manifestPath, imageId, imageDigest)); return false; }
[ "private", "boolean", "checkAndSetManifestAndImagePathCandidates", "(", "String", "manifestPath", ",", "String", "candidateImagePath", ",", "ArtifactoryDependenciesClient", "dependenciesClient", ",", "TaskListener", "listener", ")", "throws", "IOException", "{", "String", "candidateManifest", "=", "getManifestFromArtifactory", "(", "dependenciesClient", ",", "manifestPath", ")", ";", "if", "(", "candidateManifest", "==", "null", ")", "{", "return", "false", ";", "}", "String", "imageDigest", "=", "DockerUtils", ".", "getConfigDigest", "(", "candidateManifest", ")", ";", "if", "(", "imageDigest", ".", "equals", "(", "imageId", ")", ")", "{", "manifest", "=", "candidateManifest", ";", "imagePath", "=", "candidateImagePath", ";", "return", "true", ";", "}", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "String", ".", "format", "(", "\"Found incorrect manifest.json file in Artifactory in the following path: %s\\nExpecting: %s got: %s\"", ",", "manifestPath", ",", "imageId", ",", "imageDigest", ")", ")", ";", "return", "false", ";", "}" ]
Check if the provided manifestPath is correct. Set the manifest and imagePath in case of the correct manifest. @param manifestPath @param candidateImagePath @param dependenciesClient @param listener @return true if found the correct manifest @throws IOException
[ "Check", "if", "the", "provided", "manifestPath", "is", "correct", ".", "Set", "the", "manifest", "and", "imagePath", "in", "case", "of", "the", "correct", "manifest", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/DockerImage.java#L212-L227
164,643
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/BuildInfo.java
BuildInfo.getBuildFilesList
private List<org.jfrog.hudson.pipeline.types.File> getBuildFilesList(Stream<? extends BaseBuildFileBean> buildFilesStream) { return buildFilesStream .filter(buildFile -> StringUtils.isNotBlank(buildFile.getLocalPath())) .filter(buildFile -> StringUtils.isNotBlank(buildFile.getRemotePath())) .map(org.jfrog.hudson.pipeline.types.File::new) .distinct() .collect(Collectors.toList()); }
java
private List<org.jfrog.hudson.pipeline.types.File> getBuildFilesList(Stream<? extends BaseBuildFileBean> buildFilesStream) { return buildFilesStream .filter(buildFile -> StringUtils.isNotBlank(buildFile.getLocalPath())) .filter(buildFile -> StringUtils.isNotBlank(buildFile.getRemotePath())) .map(org.jfrog.hudson.pipeline.types.File::new) .distinct() .collect(Collectors.toList()); }
[ "private", "List", "<", "org", ".", "jfrog", ".", "hudson", ".", "pipeline", ".", "types", ".", "File", ">", "getBuildFilesList", "(", "Stream", "<", "?", "extends", "BaseBuildFileBean", ">", "buildFilesStream", ")", "{", "return", "buildFilesStream", ".", "filter", "(", "buildFile", "->", "StringUtils", ".", "isNotBlank", "(", "buildFile", ".", "getLocalPath", "(", ")", ")", ")", ".", "filter", "(", "buildFile", "->", "StringUtils", ".", "isNotBlank", "(", "buildFile", ".", "getRemotePath", "(", ")", ")", ")", ".", "map", "(", "org", ".", "jfrog", ".", "hudson", ".", "pipeline", ".", "types", ".", "File", "::", "new", ")", ".", "distinct", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Return a list of 'Files' of downloaded or uploaded files. Filters build files without local and remote paths. @param buildFilesStream - Stream of build Artifacts or Dependencies. @return - List of build files.
[ "Return", "a", "list", "of", "Files", "of", "downloaded", "or", "uploaded", "files", ".", "Filters", "build", "files", "without", "local", "and", "remote", "paths", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/types/buildInfo/BuildInfo.java#L126-L133
164,644
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/ArtifactoryServer.java
ArtifactoryServer.getConnectionRetries
public List<Integer> getConnectionRetries() { List<Integer> items = new ArrayList<Integer>(); for (int i = 0; i < 10; i++) { items.add(i); } return items; }
java
public List<Integer> getConnectionRetries() { List<Integer> items = new ArrayList<Integer>(); for (int i = 0; i < 10; i++) { items.add(i); } return items; }
[ "public", "List", "<", "Integer", ">", "getConnectionRetries", "(", ")", "{", "List", "<", "Integer", ">", "items", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10", ";", "i", "++", ")", "{", "items", ".", "add", "(", "i", ")", ";", "}", "return", "items", ";", "}" ]
To populate the dropdown list from the jelly
[ "To", "populate", "the", "dropdown", "list", "from", "the", "jelly" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/ArtifactoryServer.java#L127-L133
164,645
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/ArtifactoryServer.java
ArtifactoryServer.getResolvingCredentialsConfig
public CredentialsConfig getResolvingCredentialsConfig() { if (resolverCredentialsConfig != null && resolverCredentialsConfig.isCredentialsProvided()) { return getResolverCredentialsConfig(); } if (deployerCredentialsConfig != null) { return getDeployerCredentialsConfig(); } return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG; }
java
public CredentialsConfig getResolvingCredentialsConfig() { if (resolverCredentialsConfig != null && resolverCredentialsConfig.isCredentialsProvided()) { return getResolverCredentialsConfig(); } if (deployerCredentialsConfig != null) { return getDeployerCredentialsConfig(); } return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG; }
[ "public", "CredentialsConfig", "getResolvingCredentialsConfig", "(", ")", "{", "if", "(", "resolverCredentialsConfig", "!=", "null", "&&", "resolverCredentialsConfig", ".", "isCredentialsProvided", "(", ")", ")", "{", "return", "getResolverCredentialsConfig", "(", ")", ";", "}", "if", "(", "deployerCredentialsConfig", "!=", "null", ")", "{", "return", "getDeployerCredentialsConfig", "(", ")", ";", "}", "return", "CredentialsConfig", ".", "EMPTY_CREDENTIALS_CONFIG", ";", "}" ]
Decides what are the preferred credentials to use for resolving the repo keys of the server @return Preferred credentials for repo resolving. Never null.
[ "Decides", "what", "are", "the", "preferred", "credentials", "to", "use", "for", "resolving", "the", "repo", "keys", "of", "the", "server" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/ArtifactoryServer.java#L351-L360
164,646
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/maven/PomTransformer.java
PomTransformer.invoke
public Boolean invoke(File pomFile, VirtualChannel channel) throws IOException, InterruptedException { org.jfrog.build.extractor.maven.reader.ModuleName current = new org.jfrog.build.extractor.maven.reader.ModuleName( currentModule.groupId, currentModule.artifactId); Map<org.jfrog.build.extractor.maven.reader.ModuleName, String> modules = Maps.newLinkedHashMap(); for (Map.Entry<ModuleName, String> entry : versionsByModule.entrySet()) { modules.put(new org.jfrog.build.extractor.maven.reader.ModuleName( entry.getKey().groupId, entry.getKey().artifactId), entry.getValue()); } org.jfrog.build.extractor.maven.transformer.PomTransformer transformer = new org.jfrog.build.extractor.maven.transformer.PomTransformer(current, modules, scmUrl, failOnSnapshot); return transformer.transform(pomFile); }
java
public Boolean invoke(File pomFile, VirtualChannel channel) throws IOException, InterruptedException { org.jfrog.build.extractor.maven.reader.ModuleName current = new org.jfrog.build.extractor.maven.reader.ModuleName( currentModule.groupId, currentModule.artifactId); Map<org.jfrog.build.extractor.maven.reader.ModuleName, String> modules = Maps.newLinkedHashMap(); for (Map.Entry<ModuleName, String> entry : versionsByModule.entrySet()) { modules.put(new org.jfrog.build.extractor.maven.reader.ModuleName( entry.getKey().groupId, entry.getKey().artifactId), entry.getValue()); } org.jfrog.build.extractor.maven.transformer.PomTransformer transformer = new org.jfrog.build.extractor.maven.transformer.PomTransformer(current, modules, scmUrl, failOnSnapshot); return transformer.transform(pomFile); }
[ "public", "Boolean", "invoke", "(", "File", "pomFile", ",", "VirtualChannel", "channel", ")", "throws", "IOException", ",", "InterruptedException", "{", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "reader", ".", "ModuleName", "current", "=", "new", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "reader", ".", "ModuleName", "(", "currentModule", ".", "groupId", ",", "currentModule", ".", "artifactId", ")", ";", "Map", "<", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "reader", ".", "ModuleName", ",", "String", ">", "modules", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "ModuleName", ",", "String", ">", "entry", ":", "versionsByModule", ".", "entrySet", "(", ")", ")", "{", "modules", ".", "put", "(", "new", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "reader", ".", "ModuleName", "(", "entry", ".", "getKey", "(", ")", ".", "groupId", ",", "entry", ".", "getKey", "(", ")", ".", "artifactId", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "transformer", ".", "PomTransformer", "transformer", "=", "new", "org", ".", "jfrog", ".", "build", ".", "extractor", ".", "maven", ".", "transformer", ".", "PomTransformer", "(", "current", ",", "modules", ",", "scmUrl", ",", "failOnSnapshot", ")", ";", "return", "transformer", ".", "transform", "(", "pomFile", ")", ";", "}" ]
Performs the transformation. @return True if the file was modified.
[ "Performs", "the", "transformation", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/maven/PomTransformer.java#L61-L77
164,647
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/perforce/AbstractPerforceManager.java
AbstractPerforceManager.edit
public void edit(int currentChangeListId, FilePath filePath) throws Exception { establishConnection().editFile(currentChangeListId, new File(filePath.getRemote())); }
java
public void edit(int currentChangeListId, FilePath filePath) throws Exception { establishConnection().editFile(currentChangeListId, new File(filePath.getRemote())); }
[ "public", "void", "edit", "(", "int", "currentChangeListId", ",", "FilePath", "filePath", ")", "throws", "Exception", "{", "establishConnection", "(", ")", ".", "editFile", "(", "currentChangeListId", ",", "new", "File", "(", "filePath", ".", "getRemote", "(", ")", ")", ")", ";", "}" ]
Opens file for editing. @param currentChangeListId The current change list id to open the file for editing at @param filePath The filePath which contains the file we need to edit @throws IOException Thrown in case of perforce communication errors @throws InterruptedException
[ "Opens", "file", "for", "editing", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/perforce/AbstractPerforceManager.java#L98-L100
164,648
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/executors/MavenExecutor.java
MavenExecutor.convertJdkPath
private void convertJdkPath(Launcher launcher, EnvVars extendedEnv) { String separator = launcher.isUnix() ? "/" : "\\"; String java_home = extendedEnv.get("JAVA_HOME"); if (StringUtils.isNotEmpty(java_home)) { if (!StringUtils.endsWith(java_home, separator)) { java_home += separator; } extendedEnv.put("PATH+JDK", java_home + "bin"); } }
java
private void convertJdkPath(Launcher launcher, EnvVars extendedEnv) { String separator = launcher.isUnix() ? "/" : "\\"; String java_home = extendedEnv.get("JAVA_HOME"); if (StringUtils.isNotEmpty(java_home)) { if (!StringUtils.endsWith(java_home, separator)) { java_home += separator; } extendedEnv.put("PATH+JDK", java_home + "bin"); } }
[ "private", "void", "convertJdkPath", "(", "Launcher", "launcher", ",", "EnvVars", "extendedEnv", ")", "{", "String", "separator", "=", "launcher", ".", "isUnix", "(", ")", "?", "\"/\"", ":", "\"\\\\\"", ";", "String", "java_home", "=", "extendedEnv", ".", "get", "(", "\"JAVA_HOME\"", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "java_home", ")", ")", "{", "if", "(", "!", "StringUtils", ".", "endsWith", "(", "java_home", ",", "separator", ")", ")", "{", "java_home", "+=", "separator", ";", "}", "extendedEnv", ".", "put", "(", "\"PATH+JDK\"", ",", "java_home", "+", "\"bin\"", ")", ";", "}", "}" ]
The Maven3Builder class is looking for the PATH+JDK environment variable due to legacy code. In The pipeline flow we need to convert the JAVA_HOME to PATH+JDK in order to reuse the code.
[ "The", "Maven3Builder", "class", "is", "looking", "for", "the", "PATH", "+", "JDK", "environment", "variable", "due", "to", "legacy", "code", ".", "In", "The", "pipeline", "flow", "we", "need", "to", "convert", "the", "JAVA_HOME", "to", "PATH", "+", "JDK", "in", "order", "to", "reuse", "the", "code", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/executors/MavenExecutor.java#L84-L93
164,649
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/BuildUniqueIdentifierHelper.java
BuildUniqueIdentifierHelper.getRootBuild
public static AbstractBuild<?, ?> getRootBuild(AbstractBuild<?, ?> currentBuild) { AbstractBuild<?, ?> rootBuild = null; AbstractBuild<?, ?> parentBuild = getUpstreamBuild(currentBuild); while (parentBuild != null) { if (isPassIdentifiedDownstream(parentBuild)) { rootBuild = parentBuild; } parentBuild = getUpstreamBuild(parentBuild); } if (rootBuild == null && isPassIdentifiedDownstream(currentBuild)) { return currentBuild; } return rootBuild; }
java
public static AbstractBuild<?, ?> getRootBuild(AbstractBuild<?, ?> currentBuild) { AbstractBuild<?, ?> rootBuild = null; AbstractBuild<?, ?> parentBuild = getUpstreamBuild(currentBuild); while (parentBuild != null) { if (isPassIdentifiedDownstream(parentBuild)) { rootBuild = parentBuild; } parentBuild = getUpstreamBuild(parentBuild); } if (rootBuild == null && isPassIdentifiedDownstream(currentBuild)) { return currentBuild; } return rootBuild; }
[ "public", "static", "AbstractBuild", "<", "?", ",", "?", ">", "getRootBuild", "(", "AbstractBuild", "<", "?", ",", "?", ">", "currentBuild", ")", "{", "AbstractBuild", "<", "?", ",", "?", ">", "rootBuild", "=", "null", ";", "AbstractBuild", "<", "?", ",", "?", ">", "parentBuild", "=", "getUpstreamBuild", "(", "currentBuild", ")", ";", "while", "(", "parentBuild", "!=", "null", ")", "{", "if", "(", "isPassIdentifiedDownstream", "(", "parentBuild", ")", ")", "{", "rootBuild", "=", "parentBuild", ";", "}", "parentBuild", "=", "getUpstreamBuild", "(", "parentBuild", ")", ";", "}", "if", "(", "rootBuild", "==", "null", "&&", "isPassIdentifiedDownstream", "(", "currentBuild", ")", ")", "{", "return", "currentBuild", ";", "}", "return", "rootBuild", ";", "}" ]
Get the root build which triggered the current build. The build root is considered to be the one furthest one away from the current build which has the isPassIdentifiedDownstream active, if no parent build exists, check that the current build needs an upstream identifier, if it does return it. @param currentBuild The current build. @return The root build with isPassIdentifiedDownstream active. Null if no upstream or non is found.
[ "Get", "the", "root", "build", "which", "triggered", "the", "current", "build", ".", "The", "build", "root", "is", "considered", "to", "be", "the", "one", "furthest", "one", "away", "from", "the", "current", "build", "which", "has", "the", "isPassIdentifiedDownstream", "active", "if", "no", "parent", "build", "exists", "check", "that", "the", "current", "build", "needs", "an", "upstream", "identifier", "if", "it", "does", "return", "it", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/BuildUniqueIdentifierHelper.java#L35-L48
164,650
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/util/BuildUniqueIdentifierHelper.java
BuildUniqueIdentifierHelper.getProject
private static AbstractProject<?, ?> getProject(String fullName) { Item item = Hudson.getInstance().getItemByFullName(fullName); if (item != null && item instanceof AbstractProject) { return (AbstractProject<?, ?>) item; } return null; }
java
private static AbstractProject<?, ?> getProject(String fullName) { Item item = Hudson.getInstance().getItemByFullName(fullName); if (item != null && item instanceof AbstractProject) { return (AbstractProject<?, ?>) item; } return null; }
[ "private", "static", "AbstractProject", "<", "?", ",", "?", ">", "getProject", "(", "String", "fullName", ")", "{", "Item", "item", "=", "Hudson", ".", "getInstance", "(", ")", ".", "getItemByFullName", "(", "fullName", ")", ";", "if", "(", "item", "!=", "null", "&&", "item", "instanceof", "AbstractProject", ")", "{", "return", "(", "AbstractProject", "<", "?", ",", "?", ">", ")", "item", ";", "}", "return", "null", ";", "}" ]
Get a project according to its full name. @param fullName The full name of the project. @return The project which answers the full name.
[ "Get", "a", "project", "according", "to", "its", "full", "name", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/util/BuildUniqueIdentifierHelper.java#L75-L81
164,651
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/scm/git/GitCoordinator.java
GitCoordinator.pushDryRun
public void pushDryRun() throws Exception { if (releaseAction.isCreateVcsTag()) { if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), releaseAction.getTagUrl())) { throw new Exception(String.format("Tag with name '%s' already exists", releaseAction.getTagUrl())); } } String testTagName = releaseAction.getTagUrl() + "_test"; try { scmManager.testPush(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName); } catch (Exception e) { throw new Exception(String.format("Failed while attempting push dry-run: %s", e.getMessage()), e); } finally { if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName)) { scmManager.deleteLocalTag(testTagName); } } }
java
public void pushDryRun() throws Exception { if (releaseAction.isCreateVcsTag()) { if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), releaseAction.getTagUrl())) { throw new Exception(String.format("Tag with name '%s' already exists", releaseAction.getTagUrl())); } } String testTagName = releaseAction.getTagUrl() + "_test"; try { scmManager.testPush(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName); } catch (Exception e) { throw new Exception(String.format("Failed while attempting push dry-run: %s", e.getMessage()), e); } finally { if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName)) { scmManager.deleteLocalTag(testTagName); } } }
[ "public", "void", "pushDryRun", "(", ")", "throws", "Exception", "{", "if", "(", "releaseAction", ".", "isCreateVcsTag", "(", ")", ")", "{", "if", "(", "scmManager", ".", "isTagExists", "(", "scmManager", ".", "getRemoteConfig", "(", "releaseAction", ".", "getTargetRemoteName", "(", ")", ")", ",", "releaseAction", ".", "getTagUrl", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "String", ".", "format", "(", "\"Tag with name '%s' already exists\"", ",", "releaseAction", ".", "getTagUrl", "(", ")", ")", ")", ";", "}", "}", "String", "testTagName", "=", "releaseAction", ".", "getTagUrl", "(", ")", "+", "\"_test\"", ";", "try", "{", "scmManager", ".", "testPush", "(", "scmManager", ".", "getRemoteConfig", "(", "releaseAction", ".", "getTargetRemoteName", "(", ")", ")", ",", "testTagName", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Exception", "(", "String", ".", "format", "(", "\"Failed while attempting push dry-run: %s\"", ",", "e", ".", "getMessage", "(", ")", ")", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "scmManager", ".", "isTagExists", "(", "scmManager", ".", "getRemoteConfig", "(", "releaseAction", ".", "getTargetRemoteName", "(", ")", ")", ",", "testTagName", ")", ")", "{", "scmManager", ".", "deleteLocalTag", "(", "testTagName", ")", ";", "}", "}", "}" ]
This method uses the configured git credentials and repo, to test its validity. In addition, in case the user requested creation of a new tag, it checks that another tag with the same name doesn't exist
[ "This", "method", "uses", "the", "configured", "git", "credentials", "and", "repo", "to", "test", "its", "validity", ".", "In", "addition", "in", "case", "the", "user", "requested", "creation", "of", "a", "new", "tag", "it", "checks", "that", "another", "tag", "with", "the", "same", "name", "doesn", "t", "exist" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/git/GitCoordinator.java#L66-L83
164,652
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.registerImagOnAgents
public synchronized static void registerImagOnAgents(Launcher launcher, final String imageTag, final String host, final String targetRepo, final ArrayListMultimap<String, String> artifactsProps, final int buildInfoId) throws IOException, InterruptedException { // Master final String imageId = getImageIdFromAgent(launcher, imageTag, host); registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId); // Agents List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } try { node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId); return true; } }); } catch (Exception e) { launcher.getListener().getLogger().println("Could not register docker image " + imageTag + " on Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage() + " This could be because this node is now offline." ); } } }
java
public synchronized static void registerImagOnAgents(Launcher launcher, final String imageTag, final String host, final String targetRepo, final ArrayListMultimap<String, String> artifactsProps, final int buildInfoId) throws IOException, InterruptedException { // Master final String imageId = getImageIdFromAgent(launcher, imageTag, host); registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId); // Agents List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } try { node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId); return true; } }); } catch (Exception e) { launcher.getListener().getLogger().println("Could not register docker image " + imageTag + " on Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage() + " This could be because this node is now offline." ); } } }
[ "public", "synchronized", "static", "void", "registerImagOnAgents", "(", "Launcher", "launcher", ",", "final", "String", "imageTag", ",", "final", "String", "host", ",", "final", "String", "targetRepo", ",", "final", "ArrayListMultimap", "<", "String", ",", "String", ">", "artifactsProps", ",", "final", "int", "buildInfoId", ")", "throws", "IOException", ",", "InterruptedException", "{", "// Master", "final", "String", "imageId", "=", "getImageIdFromAgent", "(", "launcher", ",", "imageTag", ",", "host", ")", ";", "registerImage", "(", "imageId", ",", "imageTag", ",", "targetRepo", ",", "artifactsProps", ",", "buildInfoId", ")", ";", "// Agents", "List", "<", "Node", ">", "nodes", "=", "Jenkins", ".", "getInstance", "(", ")", ".", "getNodes", "(", ")", ";", "for", "(", "Node", "node", ":", "nodes", ")", "{", "if", "(", "node", "==", "null", "||", "node", ".", "getChannel", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "try", "{", "node", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "Boolean", ",", "IOException", ">", "(", ")", "{", "public", "Boolean", "call", "(", ")", "throws", "IOException", "{", "registerImage", "(", "imageId", ",", "imageTag", ",", "targetRepo", ",", "artifactsProps", ",", "buildInfoId", ")", ";", "return", "true", ";", "}", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "launcher", ".", "getListener", "(", ")", ".", "getLogger", "(", ")", ".", "println", "(", "\"Could not register docker image \"", "+", "imageTag", "+", "\" on Jenkins node '\"", "+", "node", ".", "getDisplayName", "(", ")", "+", "\"' due to: \"", "+", "e", ".", "getMessage", "(", ")", "+", "\" This could be because this node is now offline.\"", ")", ";", "}", "}", "}" ]
Registers an image to be captured by the build-info proxy. @param imageTag @param host @param targetRepo @param buildInfoId @throws IOException @throws InterruptedException
[ "Registers", "an", "image", "to", "be", "captured", "by", "the", "build", "-", "info", "proxy", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L36-L63
164,653
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.registerImage
private static void registerImage(String imageId, String imageTag, String targetRepo, ArrayListMultimap<String, String> artifactsProps, int buildInfoId) throws IOException { DockerImage image = new DockerImage(imageId, imageTag, targetRepo, buildInfoId, artifactsProps); images.add(image); }
java
private static void registerImage(String imageId, String imageTag, String targetRepo, ArrayListMultimap<String, String> artifactsProps, int buildInfoId) throws IOException { DockerImage image = new DockerImage(imageId, imageTag, targetRepo, buildInfoId, artifactsProps); images.add(image); }
[ "private", "static", "void", "registerImage", "(", "String", "imageId", ",", "String", "imageTag", ",", "String", "targetRepo", ",", "ArrayListMultimap", "<", "String", ",", "String", ">", "artifactsProps", ",", "int", "buildInfoId", ")", "throws", "IOException", "{", "DockerImage", "image", "=", "new", "DockerImage", "(", "imageId", ",", "imageTag", ",", "targetRepo", ",", "buildInfoId", ",", "artifactsProps", ")", ";", "images", ".", "add", "(", "image", ")", ";", "}" ]
Registers an image to the images cache, so that it can be captured by the build-info proxy. @param imageId @param imageTag @param targetRepo @param buildInfoId @throws IOException
[ "Registers", "an", "image", "to", "the", "images", "cache", "so", "that", "it", "can", "be", "captured", "by", "the", "build", "-", "info", "proxy", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L74-L78
164,654
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.getImagesByBuildId
public static List<DockerImage> getImagesByBuildId(int buildInfoId) { List<DockerImage> list = new ArrayList<DockerImage>(); Iterator<DockerImage> it = images.iterator(); while (it.hasNext()) { DockerImage image = it.next(); if (image.getBuildInfoId() == buildInfoId && image.hasManifest()) { list.add(image); } } return list; }
java
public static List<DockerImage> getImagesByBuildId(int buildInfoId) { List<DockerImage> list = new ArrayList<DockerImage>(); Iterator<DockerImage> it = images.iterator(); while (it.hasNext()) { DockerImage image = it.next(); if (image.getBuildInfoId() == buildInfoId && image.hasManifest()) { list.add(image); } } return list; }
[ "public", "static", "List", "<", "DockerImage", ">", "getImagesByBuildId", "(", "int", "buildInfoId", ")", "{", "List", "<", "DockerImage", ">", "list", "=", "new", "ArrayList", "<", "DockerImage", ">", "(", ")", ";", "Iterator", "<", "DockerImage", ">", "it", "=", "images", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "DockerImage", "image", "=", "it", ".", "next", "(", ")", ";", "if", "(", "image", ".", "getBuildInfoId", "(", ")", "==", "buildInfoId", "&&", "image", ".", "hasManifest", "(", ")", ")", "{", "list", ".", "add", "(", "image", ")", ";", "}", "}", "return", "list", ";", "}" ]
Gets a list of registered docker images from the images cache, if it has been registered to the cache for a specific build-info ID and if a docker manifest has been captured for it by the build-info proxy. @param buildInfoId @return
[ "Gets", "a", "list", "of", "registered", "docker", "images", "from", "the", "images", "cache", "if", "it", "has", "been", "registered", "to", "the", "cache", "for", "a", "specific", "build", "-", "info", "ID", "and", "if", "a", "docker", "manifest", "has", "been", "captured", "for", "it", "by", "the", "build", "-", "info", "proxy", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L87-L97
164,655
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.getAndDiscardImagesByBuildId
public static List<DockerImage> getAndDiscardImagesByBuildId(int buildInfoId) { List<DockerImage> list = new ArrayList<DockerImage>(); synchronized(images) { Iterator<DockerImage> it = images.iterator(); while (it.hasNext()) { DockerImage image = it.next(); if (image.getBuildInfoId() == buildInfoId) { if (image.hasManifest()) { list.add(image); } it.remove(); } else // Remove old images from the cache, for which build-info hasn't been published to Artifactory: if (image.isExpired()) { it.remove(); } } } return list; }
java
public static List<DockerImage> getAndDiscardImagesByBuildId(int buildInfoId) { List<DockerImage> list = new ArrayList<DockerImage>(); synchronized(images) { Iterator<DockerImage> it = images.iterator(); while (it.hasNext()) { DockerImage image = it.next(); if (image.getBuildInfoId() == buildInfoId) { if (image.hasManifest()) { list.add(image); } it.remove(); } else // Remove old images from the cache, for which build-info hasn't been published to Artifactory: if (image.isExpired()) { it.remove(); } } } return list; }
[ "public", "static", "List", "<", "DockerImage", ">", "getAndDiscardImagesByBuildId", "(", "int", "buildInfoId", ")", "{", "List", "<", "DockerImage", ">", "list", "=", "new", "ArrayList", "<", "DockerImage", ">", "(", ")", ";", "synchronized", "(", "images", ")", "{", "Iterator", "<", "DockerImage", ">", "it", "=", "images", ".", "iterator", "(", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "DockerImage", "image", "=", "it", ".", "next", "(", ")", ";", "if", "(", "image", ".", "getBuildInfoId", "(", ")", "==", "buildInfoId", ")", "{", "if", "(", "image", ".", "hasManifest", "(", ")", ")", "{", "list", ".", "add", "(", "image", ")", ";", "}", "it", ".", "remove", "(", ")", ";", "}", "else", "// Remove old images from the cache, for which build-info hasn't been published to Artifactory:", "if", "(", "image", ".", "isExpired", "(", ")", ")", "{", "it", ".", "remove", "(", ")", ";", "}", "}", "}", "return", "list", ";", "}" ]
Gets a list of registered docker images from the images cache, if it has been registered to the cache for a specific build-info ID and if a docker manifest has been captured for it by the build-info proxy. Additionally, the methods also removes the returned images from the cache. @param buildInfoId @return
[ "Gets", "a", "list", "of", "registered", "docker", "images", "from", "the", "images", "cache", "if", "it", "has", "been", "registered", "to", "the", "cache", "for", "a", "specific", "build", "-", "info", "ID", "and", "if", "a", "docker", "manifest", "has", "been", "captured", "for", "it", "by", "the", "build", "-", "info", "proxy", ".", "Additionally", "the", "methods", "also", "removes", "the", "returned", "images", "from", "the", "cache", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L107-L125
164,656
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.getDockerImagesFromAgents
public static List<DockerImage> getDockerImagesFromAgents(final int buildInfoId, TaskListener listener) throws IOException, InterruptedException { List<DockerImage> dockerImages = new ArrayList<DockerImage>(); // Collect images from the master: dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId)); // Collect images from all the agents: List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } try { List<DockerImage> partialDockerImages = node.getChannel().call(new MasterToSlaveCallable<List<DockerImage>, IOException>() { public List<DockerImage> call() throws IOException { List<DockerImage> dockerImages = new ArrayList<DockerImage>(); dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId)); return dockerImages; } }); dockerImages.addAll(partialDockerImages); } catch (Exception e) { listener.getLogger().println("Could not collect docker images from Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage()); } } return dockerImages; }
java
public static List<DockerImage> getDockerImagesFromAgents(final int buildInfoId, TaskListener listener) throws IOException, InterruptedException { List<DockerImage> dockerImages = new ArrayList<DockerImage>(); // Collect images from the master: dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId)); // Collect images from all the agents: List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } try { List<DockerImage> partialDockerImages = node.getChannel().call(new MasterToSlaveCallable<List<DockerImage>, IOException>() { public List<DockerImage> call() throws IOException { List<DockerImage> dockerImages = new ArrayList<DockerImage>(); dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId)); return dockerImages; } }); dockerImages.addAll(partialDockerImages); } catch (Exception e) { listener.getLogger().println("Could not collect docker images from Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage()); } } return dockerImages; }
[ "public", "static", "List", "<", "DockerImage", ">", "getDockerImagesFromAgents", "(", "final", "int", "buildInfoId", ",", "TaskListener", "listener", ")", "throws", "IOException", ",", "InterruptedException", "{", "List", "<", "DockerImage", ">", "dockerImages", "=", "new", "ArrayList", "<", "DockerImage", ">", "(", ")", ";", "// Collect images from the master:", "dockerImages", ".", "addAll", "(", "getAndDiscardImagesByBuildId", "(", "buildInfoId", ")", ")", ";", "// Collect images from all the agents:", "List", "<", "Node", ">", "nodes", "=", "Jenkins", ".", "getInstance", "(", ")", ".", "getNodes", "(", ")", ";", "for", "(", "Node", "node", ":", "nodes", ")", "{", "if", "(", "node", "==", "null", "||", "node", ".", "getChannel", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "try", "{", "List", "<", "DockerImage", ">", "partialDockerImages", "=", "node", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "List", "<", "DockerImage", ">", ",", "IOException", ">", "(", ")", "{", "public", "List", "<", "DockerImage", ">", "call", "(", ")", "throws", "IOException", "{", "List", "<", "DockerImage", ">", "dockerImages", "=", "new", "ArrayList", "<", "DockerImage", ">", "(", ")", ";", "dockerImages", ".", "addAll", "(", "getAndDiscardImagesByBuildId", "(", "buildInfoId", ")", ")", ";", "return", "dockerImages", ";", "}", "}", ")", ";", "dockerImages", ".", "addAll", "(", "partialDockerImages", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "listener", ".", "getLogger", "(", ")", ".", "println", "(", "\"Could not collect docker images from Jenkins node '\"", "+", "node", ".", "getDisplayName", "(", ")", "+", "\"' due to: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "return", "dockerImages", ";", "}" ]
Retrieves from all the Jenkins agents all the docker images, which have been registered for a specific build-info ID Only images for which manifests have been captured are returned. @param buildInfoId @return @throws IOException @throws InterruptedException
[ "Retrieves", "from", "all", "the", "Jenkins", "agents", "all", "the", "docker", "images", "which", "have", "been", "registered", "for", "a", "specific", "build", "-", "info", "ID", "Only", "images", "for", "which", "manifests", "have", "been", "captured", "are", "returned", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L136-L162
164,657
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.pushImage
public static boolean pushImage(Launcher launcher, final JenkinsBuildInfoLog log, final String imageTag, final String username, final String password, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { String message = "Pushing image: " + imageTag; if (StringUtils.isNotEmpty(host)) { message += " using docker daemon host: " + host; } log.info(message); DockerUtils.pushImage(imageTag, username, password, host); return true; } }); }
java
public static boolean pushImage(Launcher launcher, final JenkinsBuildInfoLog log, final String imageTag, final String username, final String password, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { String message = "Pushing image: " + imageTag; if (StringUtils.isNotEmpty(host)) { message += " using docker daemon host: " + host; } log.info(message); DockerUtils.pushImage(imageTag, username, password, host); return true; } }); }
[ "public", "static", "boolean", "pushImage", "(", "Launcher", "launcher", ",", "final", "JenkinsBuildInfoLog", "log", ",", "final", "String", "imageTag", ",", "final", "String", "username", ",", "final", "String", "password", ",", "final", "String", "host", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "launcher", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "Boolean", ",", "IOException", ">", "(", ")", "{", "public", "Boolean", "call", "(", ")", "throws", "IOException", "{", "String", "message", "=", "\"Pushing image: \"", "+", "imageTag", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "host", ")", ")", "{", "message", "+=", "\" using docker daemon host: \"", "+", "host", ";", "}", "log", ".", "info", "(", "message", ")", ";", "DockerUtils", ".", "pushImage", "(", "imageTag", ",", "username", ",", "password", ",", "host", ")", ";", "return", "true", ";", "}", "}", ")", ";", "}" ]
Execute push docker image on agent @param launcher @param log @param imageTag @param username @param password @param host @return @throws IOException @throws InterruptedException
[ "Execute", "push", "docker", "image", "on", "agent" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L176-L191
164,658
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.pullImage
public static boolean pullImage(Launcher launcher, final String imageTag, final String username, final String password, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { DockerUtils.pullImage(imageTag, username, password, host); return true; } }); }
java
public static boolean pullImage(Launcher launcher, final String imageTag, final String username, final String password, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { DockerUtils.pullImage(imageTag, username, password, host); return true; } }); }
[ "public", "static", "boolean", "pullImage", "(", "Launcher", "launcher", ",", "final", "String", "imageTag", ",", "final", "String", "username", ",", "final", "String", "password", ",", "final", "String", "host", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "launcher", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "Boolean", ",", "IOException", ">", "(", ")", "{", "public", "Boolean", "call", "(", ")", "throws", "IOException", "{", "DockerUtils", ".", "pullImage", "(", "imageTag", ",", "username", ",", "password", ",", "host", ")", ";", "return", "true", ";", "}", "}", ")", ";", "}" ]
Execute pull docker image on agent @param launcher @param imageTag @param username @param password @param host @return @throws IOException @throws InterruptedException
[ "Execute", "pull", "docker", "image", "on", "agent" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L205-L214
164,659
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.updateImageParentOnAgents
public static boolean updateImageParentOnAgents(final JenkinsBuildInfoLog log, final String imageTag, final String host, final int buildInfoId) throws IOException, InterruptedException { boolean parentUpdated = updateImageParent(log, imageTag, host, buildInfoId); List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } boolean parentNodeUpdated = node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { return updateImageParent(log, imageTag, host, buildInfoId); } }); parentUpdated = parentUpdated ? parentUpdated : parentNodeUpdated; } return parentUpdated; }
java
public static boolean updateImageParentOnAgents(final JenkinsBuildInfoLog log, final String imageTag, final String host, final int buildInfoId) throws IOException, InterruptedException { boolean parentUpdated = updateImageParent(log, imageTag, host, buildInfoId); List<Node> nodes = Jenkins.getInstance().getNodes(); for (Node node : nodes) { if (node == null || node.getChannel() == null) { continue; } boolean parentNodeUpdated = node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() { public Boolean call() throws IOException { return updateImageParent(log, imageTag, host, buildInfoId); } }); parentUpdated = parentUpdated ? parentUpdated : parentNodeUpdated; } return parentUpdated; }
[ "public", "static", "boolean", "updateImageParentOnAgents", "(", "final", "JenkinsBuildInfoLog", "log", ",", "final", "String", "imageTag", ",", "final", "String", "host", ",", "final", "int", "buildInfoId", ")", "throws", "IOException", ",", "InterruptedException", "{", "boolean", "parentUpdated", "=", "updateImageParent", "(", "log", ",", "imageTag", ",", "host", ",", "buildInfoId", ")", ";", "List", "<", "Node", ">", "nodes", "=", "Jenkins", ".", "getInstance", "(", ")", ".", "getNodes", "(", ")", ";", "for", "(", "Node", "node", ":", "nodes", ")", "{", "if", "(", "node", "==", "null", "||", "node", ".", "getChannel", "(", ")", "==", "null", ")", "{", "continue", ";", "}", "boolean", "parentNodeUpdated", "=", "node", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "Boolean", ",", "IOException", ">", "(", ")", "{", "public", "Boolean", "call", "(", ")", "throws", "IOException", "{", "return", "updateImageParent", "(", "log", ",", "imageTag", ",", "host", ",", "buildInfoId", ")", ";", "}", "}", ")", ";", "parentUpdated", "=", "parentUpdated", "?", "parentUpdated", ":", "parentNodeUpdated", ";", "}", "return", "parentUpdated", ";", "}" ]
Updates property of parent id for the image provided. Returns false if image was not captured true otherwise. @param log @param imageTag @param host @param buildInfoId @return @throws IOException @throws InterruptedException
[ "Updates", "property", "of", "parent", "id", "for", "the", "image", "provided", ".", "Returns", "false", "if", "image", "was", "not", "captured", "true", "otherwise", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L228-L243
164,660
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.getImageIdFromAgent
public static String getImageIdFromAgent(Launcher launcher, final String imageTag, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() { public String call() throws IOException { return DockerUtils.getImageIdFromTag(imageTag, host); } }); }
java
public static String getImageIdFromAgent(Launcher launcher, final String imageTag, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() { public String call() throws IOException { return DockerUtils.getImageIdFromTag(imageTag, host); } }); }
[ "public", "static", "String", "getImageIdFromAgent", "(", "Launcher", "launcher", ",", "final", "String", "imageTag", ",", "final", "String", "host", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "launcher", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "String", ",", "IOException", ">", "(", ")", "{", "public", "String", "call", "(", ")", "throws", "IOException", "{", "return", "DockerUtils", ".", "getImageIdFromTag", "(", "imageTag", ",", "host", ")", ";", "}", "}", ")", ";", "}" ]
Get image ID from imageTag on the current agent. @param imageTag @return
[ "Get", "image", "ID", "from", "imageTag", "on", "the", "current", "agent", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L278-L284
164,661
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java
DockerAgentUtils.getParentIdFromAgent
public static String getParentIdFromAgent(Launcher launcher, final String imageID, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() { public String call() throws IOException { return DockerUtils.getParentId(imageID, host); } }); }
java
public static String getParentIdFromAgent(Launcher launcher, final String imageID, final String host) throws IOException, InterruptedException { return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() { public String call() throws IOException { return DockerUtils.getParentId(imageID, host); } }); }
[ "public", "static", "String", "getParentIdFromAgent", "(", "Launcher", "launcher", ",", "final", "String", "imageID", ",", "final", "String", "host", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "launcher", ".", "getChannel", "(", ")", ".", "call", "(", "new", "MasterToSlaveCallable", "<", "String", ",", "IOException", ">", "(", ")", "{", "public", "String", "call", "(", ")", "throws", "IOException", "{", "return", "DockerUtils", ".", "getParentId", "(", "imageID", ",", "host", ")", ";", "}", "}", ")", ";", "}" ]
Get image parent ID from imageID on the current agent. @param imageID @return
[ "Get", "image", "parent", "ID", "from", "imageID", "on", "the", "current", "agent", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L292-L298
164,662
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java
BaseGradleReleaseAction.initBuilderSpecific
@Override protected void initBuilderSpecific() throws Exception { reset(); FilePath workspace = getModuleRoot(EnvVars.masterEnvVars); FilePath gradlePropertiesPath = new FilePath(workspace, "gradle.properties"); if (releaseProps == null) { releaseProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getReleaseProperties()); } if (nextIntegProps == null) { nextIntegProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getNextIntegProperties()); } }
java
@Override protected void initBuilderSpecific() throws Exception { reset(); FilePath workspace = getModuleRoot(EnvVars.masterEnvVars); FilePath gradlePropertiesPath = new FilePath(workspace, "gradle.properties"); if (releaseProps == null) { releaseProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getReleaseProperties()); } if (nextIntegProps == null) { nextIntegProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getNextIntegProperties()); } }
[ "@", "Override", "protected", "void", "initBuilderSpecific", "(", ")", "throws", "Exception", "{", "reset", "(", ")", ";", "FilePath", "workspace", "=", "getModuleRoot", "(", "EnvVars", ".", "masterEnvVars", ")", ";", "FilePath", "gradlePropertiesPath", "=", "new", "FilePath", "(", "workspace", ",", "\"gradle.properties\"", ")", ";", "if", "(", "releaseProps", "==", "null", ")", "{", "releaseProps", "=", "PropertyUtils", ".", "getModulesPropertiesFromPropFile", "(", "gradlePropertiesPath", ",", "getReleaseProperties", "(", ")", ")", ";", "}", "if", "(", "nextIntegProps", "==", "null", ")", "{", "nextIntegProps", "=", "PropertyUtils", ".", "getModulesPropertiesFromPropFile", "(", "gradlePropertiesPath", ",", "getNextIntegProperties", "(", ")", ")", ";", "}", "}" ]
Initialize the version properties map from the gradle.properties file, and the additional properties from the gradle.properties file.
[ "Initialize", "the", "version", "properties", "map", "from", "the", "gradle", ".", "properties", "file", "and", "the", "additional", "properties", "from", "the", "gradle", ".", "properties", "file", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java#L76-L88
164,663
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java
BaseGradleReleaseAction.getModuleRoot
public FilePath getModuleRoot(Map<String, String> globalEnv) throws IOException, InterruptedException { FilePath someWorkspace = project.getSomeWorkspace(); if (someWorkspace == null) { throw new IllegalStateException("Couldn't find workspace"); } Map<String, String> workspaceEnv = Maps.newHashMap(); workspaceEnv.put("WORKSPACE", someWorkspace.getRemote()); for (Builder builder : getBuilders()) { if (builder instanceof Gradle) { Gradle gradleBuilder = (Gradle) builder; String rootBuildScriptDir = gradleBuilder.getRootBuildScriptDir(); if (rootBuildScriptDir != null && rootBuildScriptDir.trim().length() != 0) { String rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptDir.trim(), workspaceEnv); rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptNormalized, globalEnv); return new FilePath(someWorkspace, rootBuildScriptNormalized); } else { return someWorkspace; } } } throw new IllegalArgumentException("Couldn't find Gradle builder in the current builders list"); }
java
public FilePath getModuleRoot(Map<String, String> globalEnv) throws IOException, InterruptedException { FilePath someWorkspace = project.getSomeWorkspace(); if (someWorkspace == null) { throw new IllegalStateException("Couldn't find workspace"); } Map<String, String> workspaceEnv = Maps.newHashMap(); workspaceEnv.put("WORKSPACE", someWorkspace.getRemote()); for (Builder builder : getBuilders()) { if (builder instanceof Gradle) { Gradle gradleBuilder = (Gradle) builder; String rootBuildScriptDir = gradleBuilder.getRootBuildScriptDir(); if (rootBuildScriptDir != null && rootBuildScriptDir.trim().length() != 0) { String rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptDir.trim(), workspaceEnv); rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptNormalized, globalEnv); return new FilePath(someWorkspace, rootBuildScriptNormalized); } else { return someWorkspace; } } } throw new IllegalArgumentException("Couldn't find Gradle builder in the current builders list"); }
[ "public", "FilePath", "getModuleRoot", "(", "Map", "<", "String", ",", "String", ">", "globalEnv", ")", "throws", "IOException", ",", "InterruptedException", "{", "FilePath", "someWorkspace", "=", "project", ".", "getSomeWorkspace", "(", ")", ";", "if", "(", "someWorkspace", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Couldn't find workspace\"", ")", ";", "}", "Map", "<", "String", ",", "String", ">", "workspaceEnv", "=", "Maps", ".", "newHashMap", "(", ")", ";", "workspaceEnv", ".", "put", "(", "\"WORKSPACE\"", ",", "someWorkspace", ".", "getRemote", "(", ")", ")", ";", "for", "(", "Builder", "builder", ":", "getBuilders", "(", ")", ")", "{", "if", "(", "builder", "instanceof", "Gradle", ")", "{", "Gradle", "gradleBuilder", "=", "(", "Gradle", ")", "builder", ";", "String", "rootBuildScriptDir", "=", "gradleBuilder", ".", "getRootBuildScriptDir", "(", ")", ";", "if", "(", "rootBuildScriptDir", "!=", "null", "&&", "rootBuildScriptDir", ".", "trim", "(", ")", ".", "length", "(", ")", "!=", "0", ")", "{", "String", "rootBuildScriptNormalized", "=", "Util", ".", "replaceMacro", "(", "rootBuildScriptDir", ".", "trim", "(", ")", ",", "workspaceEnv", ")", ";", "rootBuildScriptNormalized", "=", "Util", ".", "replaceMacro", "(", "rootBuildScriptNormalized", ",", "globalEnv", ")", ";", "return", "new", "FilePath", "(", "someWorkspace", ",", "rootBuildScriptNormalized", ")", ";", "}", "else", "{", "return", "someWorkspace", ";", "}", "}", "}", "throw", "new", "IllegalArgumentException", "(", "\"Couldn't find Gradle builder in the current builders list\"", ")", ";", "}" ]
Get the root path where the build is located, the project may be checked out to a sub-directory from the root workspace location. @param globalEnv EnvVars to take the workspace from, if workspace is not found then it is take from project.getSomeWorkspace() @return The location of the root of the Gradle build. @throws IOException @throws InterruptedException
[ "Get", "the", "root", "path", "where", "the", "build", "is", "located", "the", "project", "may", "be", "checked", "out", "to", "a", "sub", "-", "directory", "from", "the", "root", "workspace", "location", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java#L100-L124
164,664
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java
BaseGradleReleaseAction.extractNumericVersion
private String extractNumericVersion(Collection<String> versionStrings) { if (versionStrings == null) { return ""; } for (String value : versionStrings) { String releaseValue = calculateReleaseVersion(value); if (!releaseValue.equals(value)) { return releaseValue; } } return ""; }
java
private String extractNumericVersion(Collection<String> versionStrings) { if (versionStrings == null) { return ""; } for (String value : versionStrings) { String releaseValue = calculateReleaseVersion(value); if (!releaseValue.equals(value)) { return releaseValue; } } return ""; }
[ "private", "String", "extractNumericVersion", "(", "Collection", "<", "String", ">", "versionStrings", ")", "{", "if", "(", "versionStrings", "==", "null", ")", "{", "return", "\"\"", ";", "}", "for", "(", "String", "value", ":", "versionStrings", ")", "{", "String", "releaseValue", "=", "calculateReleaseVersion", "(", "value", ")", ";", "if", "(", "!", "releaseValue", ".", "equals", "(", "value", ")", ")", "{", "return", "releaseValue", ";", "}", "}", "return", "\"\"", ";", "}" ]
Try to extract a numeric version from a collection of strings. @param versionStrings Collection of string properties. @return The version string if exists in the collection.
[ "Try", "to", "extract", "a", "numeric", "version", "from", "a", "collection", "of", "strings", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/gradle/BaseGradleReleaseAction.java#L341-L352
164,665
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/ReleaseAction.java
ReleaseAction.init
@SuppressWarnings("UnusedDeclaration") public void init() throws Exception { initBuilderSpecific(); resetFields(); if (!UserPluginInfo.NO_PLUGIN_KEY.equals(getSelectedStagingPluginName())) { PluginSettings selectedStagingPluginSettings = getSelectedStagingPlugin(); try { stagingStrategy = getArtifactoryServer().getStagingStrategy(selectedStagingPluginSettings, Util.rawEncode(project.getName()), project); } catch (Exception e) { log.log(Level.WARNING, "Failed to obtain staging strategy: " + e.getMessage(), e); strategyRequestFailed = true; strategyRequestErrorMessage = "Failed to obtain staging strategy '" + selectedStagingPluginSettings.getPluginName() + "': " + e.getMessage() + ".\nPlease review the log for further information."; stagingStrategy = null; } strategyPluginExists = (stagingStrategy != null) && !stagingStrategy.isEmpty(); } prepareDefaultVersioning(); prepareDefaultGlobalModule(); prepareDefaultModules(); prepareDefaultVcsSettings(); prepareDefaultPromotionConfig(); }
java
@SuppressWarnings("UnusedDeclaration") public void init() throws Exception { initBuilderSpecific(); resetFields(); if (!UserPluginInfo.NO_PLUGIN_KEY.equals(getSelectedStagingPluginName())) { PluginSettings selectedStagingPluginSettings = getSelectedStagingPlugin(); try { stagingStrategy = getArtifactoryServer().getStagingStrategy(selectedStagingPluginSettings, Util.rawEncode(project.getName()), project); } catch (Exception e) { log.log(Level.WARNING, "Failed to obtain staging strategy: " + e.getMessage(), e); strategyRequestFailed = true; strategyRequestErrorMessage = "Failed to obtain staging strategy '" + selectedStagingPluginSettings.getPluginName() + "': " + e.getMessage() + ".\nPlease review the log for further information."; stagingStrategy = null; } strategyPluginExists = (stagingStrategy != null) && !stagingStrategy.isEmpty(); } prepareDefaultVersioning(); prepareDefaultGlobalModule(); prepareDefaultModules(); prepareDefaultVcsSettings(); prepareDefaultPromotionConfig(); }
[ "@", "SuppressWarnings", "(", "\"UnusedDeclaration\"", ")", "public", "void", "init", "(", ")", "throws", "Exception", "{", "initBuilderSpecific", "(", ")", ";", "resetFields", "(", ")", ";", "if", "(", "!", "UserPluginInfo", ".", "NO_PLUGIN_KEY", ".", "equals", "(", "getSelectedStagingPluginName", "(", ")", ")", ")", "{", "PluginSettings", "selectedStagingPluginSettings", "=", "getSelectedStagingPlugin", "(", ")", ";", "try", "{", "stagingStrategy", "=", "getArtifactoryServer", "(", ")", ".", "getStagingStrategy", "(", "selectedStagingPluginSettings", ",", "Util", ".", "rawEncode", "(", "project", ".", "getName", "(", ")", ")", ",", "project", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Failed to obtain staging strategy: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "strategyRequestFailed", "=", "true", ";", "strategyRequestErrorMessage", "=", "\"Failed to obtain staging strategy '\"", "+", "selectedStagingPluginSettings", ".", "getPluginName", "(", ")", "+", "\"': \"", "+", "e", ".", "getMessage", "(", ")", "+", "\".\\nPlease review the log for further information.\"", ";", "stagingStrategy", "=", "null", ";", "}", "strategyPluginExists", "=", "(", "stagingStrategy", "!=", "null", ")", "&&", "!", "stagingStrategy", ".", "isEmpty", "(", ")", ";", "}", "prepareDefaultVersioning", "(", ")", ";", "prepareDefaultGlobalModule", "(", ")", ";", "prepareDefaultModules", "(", ")", ";", "prepareDefaultVcsSettings", "(", ")", ";", "prepareDefaultPromotionConfig", "(", ")", ";", "}" ]
invoked from the jelly file @throws Exception Any exception
[ "invoked", "from", "the", "jelly", "file" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/ReleaseAction.java#L106-L130
164,666
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/ReleaseAction.java
ReleaseAction.doApi
@SuppressWarnings({"UnusedDeclaration"}) protected void doApi(StaplerRequest req, StaplerResponse resp) throws IOException, ServletException { try { log.log(Level.INFO, "Initiating Artifactory Release Staging using API"); // Enforce release permissions project.checkPermission(ArtifactoryPlugin.RELEASE); // In case a staging user plugin is configured, the init() method invoke it: init(); // Read the values provided by the staging user plugin and assign them to data members in this class. // Those values can be overriden by URL arguments sent with the API: readStagingPluginValues(); // Read values from the request and override the staging plugin values: overrideStagingPluginParams(req); // Schedule the release build: Queue.WaitingItem item = Jenkins.getInstance().getQueue().schedule( project, 0, new Action[]{this, new CauseAction(new Cause.UserIdCause())} ); if (item == null) { log.log(Level.SEVERE, "Failed to schedule a release build following a Release API invocation"); resp.setStatus(StaplerResponse.SC_INTERNAL_SERVER_ERROR); } else { String url = req.getContextPath() + '/' + item.getUrl(); JSONObject json = new JSONObject(); json.element("queueItem", item.getId()); json.element("releaseVersion", getReleaseVersion()); json.element("nextVersion", getNextVersion()); json.element("releaseBranch", getReleaseBranch()); // Must use getOutputStream as sendRedirect uses getOutputStream (and closes it) resp.getOutputStream().print(json.toString()); resp.sendRedirect(201, url); } } catch (Exception e) { log.log(Level.SEVERE, "Artifactory Release Staging API invocation failed: " + e.getMessage(), e); resp.setStatus(StaplerResponse.SC_INTERNAL_SERVER_ERROR); ErrorResponse errorResponse = new ErrorResponse(StaplerResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); resp.getWriter().write(mapper.writeValueAsString(errorResponse)); } }
java
@SuppressWarnings({"UnusedDeclaration"}) protected void doApi(StaplerRequest req, StaplerResponse resp) throws IOException, ServletException { try { log.log(Level.INFO, "Initiating Artifactory Release Staging using API"); // Enforce release permissions project.checkPermission(ArtifactoryPlugin.RELEASE); // In case a staging user plugin is configured, the init() method invoke it: init(); // Read the values provided by the staging user plugin and assign them to data members in this class. // Those values can be overriden by URL arguments sent with the API: readStagingPluginValues(); // Read values from the request and override the staging plugin values: overrideStagingPluginParams(req); // Schedule the release build: Queue.WaitingItem item = Jenkins.getInstance().getQueue().schedule( project, 0, new Action[]{this, new CauseAction(new Cause.UserIdCause())} ); if (item == null) { log.log(Level.SEVERE, "Failed to schedule a release build following a Release API invocation"); resp.setStatus(StaplerResponse.SC_INTERNAL_SERVER_ERROR); } else { String url = req.getContextPath() + '/' + item.getUrl(); JSONObject json = new JSONObject(); json.element("queueItem", item.getId()); json.element("releaseVersion", getReleaseVersion()); json.element("nextVersion", getNextVersion()); json.element("releaseBranch", getReleaseBranch()); // Must use getOutputStream as sendRedirect uses getOutputStream (and closes it) resp.getOutputStream().print(json.toString()); resp.sendRedirect(201, url); } } catch (Exception e) { log.log(Level.SEVERE, "Artifactory Release Staging API invocation failed: " + e.getMessage(), e); resp.setStatus(StaplerResponse.SC_INTERNAL_SERVER_ERROR); ErrorResponse errorResponse = new ErrorResponse(StaplerResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); resp.getWriter().write(mapper.writeValueAsString(errorResponse)); } }
[ "@", "SuppressWarnings", "(", "{", "\"UnusedDeclaration\"", "}", ")", "protected", "void", "doApi", "(", "StaplerRequest", "req", ",", "StaplerResponse", "resp", ")", "throws", "IOException", ",", "ServletException", "{", "try", "{", "log", ".", "log", "(", "Level", ".", "INFO", ",", "\"Initiating Artifactory Release Staging using API\"", ")", ";", "// Enforce release permissions", "project", ".", "checkPermission", "(", "ArtifactoryPlugin", ".", "RELEASE", ")", ";", "// In case a staging user plugin is configured, the init() method invoke it:", "init", "(", ")", ";", "// Read the values provided by the staging user plugin and assign them to data members in this class.", "// Those values can be overriden by URL arguments sent with the API:", "readStagingPluginValues", "(", ")", ";", "// Read values from the request and override the staging plugin values:", "overrideStagingPluginParams", "(", "req", ")", ";", "// Schedule the release build:", "Queue", ".", "WaitingItem", "item", "=", "Jenkins", ".", "getInstance", "(", ")", ".", "getQueue", "(", ")", ".", "schedule", "(", "project", ",", "0", ",", "new", "Action", "[", "]", "{", "this", ",", "new", "CauseAction", "(", "new", "Cause", ".", "UserIdCause", "(", ")", ")", "}", ")", ";", "if", "(", "item", "==", "null", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Failed to schedule a release build following a Release API invocation\"", ")", ";", "resp", ".", "setStatus", "(", "StaplerResponse", ".", "SC_INTERNAL_SERVER_ERROR", ")", ";", "}", "else", "{", "String", "url", "=", "req", ".", "getContextPath", "(", ")", "+", "'", "'", "+", "item", ".", "getUrl", "(", ")", ";", "JSONObject", "json", "=", "new", "JSONObject", "(", ")", ";", "json", ".", "element", "(", "\"queueItem\"", ",", "item", ".", "getId", "(", ")", ")", ";", "json", ".", "element", "(", "\"releaseVersion\"", ",", "getReleaseVersion", "(", ")", ")", ";", "json", ".", "element", "(", "\"nextVersion\"", ",", "getNextVersion", "(", ")", ")", ";", "json", ".", "element", "(", "\"releaseBranch\"", ",", "getReleaseBranch", "(", ")", ")", ";", "// Must use getOutputStream as sendRedirect uses getOutputStream (and closes it)", "resp", ".", "getOutputStream", "(", ")", ".", "print", "(", "json", ".", "toString", "(", ")", ")", ";", "resp", ".", "sendRedirect", "(", "201", ",", "url", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Artifactory Release Staging API invocation failed: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "resp", ".", "setStatus", "(", "StaplerResponse", ".", "SC_INTERNAL_SERVER_ERROR", ")", ";", "ErrorResponse", "errorResponse", "=", "new", "ErrorResponse", "(", "StaplerResponse", ".", "SC_INTERNAL_SERVER_ERROR", ",", "e", ".", "getMessage", "(", ")", ")", ";", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "mapper", ".", "enable", "(", "SerializationFeature", ".", "INDENT_OUTPUT", ")", ";", "resp", ".", "getWriter", "(", ")", ".", "write", "(", "mapper", ".", "writeValueAsString", "(", "errorResponse", ")", ")", ";", "}", "}" ]
This method is used to initiate a release staging process using the Artifactory Release Staging API.
[ "This", "method", "is", "used", "to", "initiate", "a", "release", "staging", "process", "using", "the", "Artifactory", "Release", "Staging", "API", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/ReleaseAction.java#L273-L313
164,667
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/ReleaseAction.java
ReleaseAction.calculateNextVersion
protected String calculateNextVersion(String fromVersion) { // first turn it to release version fromVersion = calculateReleaseVersion(fromVersion); String nextVersion; int lastDotIndex = fromVersion.lastIndexOf('.'); try { if (lastDotIndex != -1) { // probably a major minor version e.g., 2.1.1 String minorVersionToken = fromVersion.substring(lastDotIndex + 1); String nextMinorVersion; int lastDashIndex = minorVersionToken.lastIndexOf('-'); if (lastDashIndex != -1) { // probably a minor-buildNum e.g., 2.1.1-4 (should change to 2.1.1-5) String buildNumber = minorVersionToken.substring(lastDashIndex + 1); int nextBuildNumber = Integer.parseInt(buildNumber) + 1; nextMinorVersion = minorVersionToken.substring(0, lastDashIndex + 1) + nextBuildNumber; } else { nextMinorVersion = Integer.parseInt(minorVersionToken) + 1 + ""; } nextVersion = fromVersion.substring(0, lastDotIndex + 1) + nextMinorVersion; } else { // maybe it's just a major version; try to parse as an int int nextMajorVersion = Integer.parseInt(fromVersion) + 1; nextVersion = nextMajorVersion + ""; } } catch (NumberFormatException e) { return fromVersion; } return nextVersion + "-SNAPSHOT"; }
java
protected String calculateNextVersion(String fromVersion) { // first turn it to release version fromVersion = calculateReleaseVersion(fromVersion); String nextVersion; int lastDotIndex = fromVersion.lastIndexOf('.'); try { if (lastDotIndex != -1) { // probably a major minor version e.g., 2.1.1 String minorVersionToken = fromVersion.substring(lastDotIndex + 1); String nextMinorVersion; int lastDashIndex = minorVersionToken.lastIndexOf('-'); if (lastDashIndex != -1) { // probably a minor-buildNum e.g., 2.1.1-4 (should change to 2.1.1-5) String buildNumber = minorVersionToken.substring(lastDashIndex + 1); int nextBuildNumber = Integer.parseInt(buildNumber) + 1; nextMinorVersion = minorVersionToken.substring(0, lastDashIndex + 1) + nextBuildNumber; } else { nextMinorVersion = Integer.parseInt(minorVersionToken) + 1 + ""; } nextVersion = fromVersion.substring(0, lastDotIndex + 1) + nextMinorVersion; } else { // maybe it's just a major version; try to parse as an int int nextMajorVersion = Integer.parseInt(fromVersion) + 1; nextVersion = nextMajorVersion + ""; } } catch (NumberFormatException e) { return fromVersion; } return nextVersion + "-SNAPSHOT"; }
[ "protected", "String", "calculateNextVersion", "(", "String", "fromVersion", ")", "{", "// first turn it to release version", "fromVersion", "=", "calculateReleaseVersion", "(", "fromVersion", ")", ";", "String", "nextVersion", ";", "int", "lastDotIndex", "=", "fromVersion", ".", "lastIndexOf", "(", "'", "'", ")", ";", "try", "{", "if", "(", "lastDotIndex", "!=", "-", "1", ")", "{", "// probably a major minor version e.g., 2.1.1", "String", "minorVersionToken", "=", "fromVersion", ".", "substring", "(", "lastDotIndex", "+", "1", ")", ";", "String", "nextMinorVersion", ";", "int", "lastDashIndex", "=", "minorVersionToken", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "lastDashIndex", "!=", "-", "1", ")", "{", "// probably a minor-buildNum e.g., 2.1.1-4 (should change to 2.1.1-5)", "String", "buildNumber", "=", "minorVersionToken", ".", "substring", "(", "lastDashIndex", "+", "1", ")", ";", "int", "nextBuildNumber", "=", "Integer", ".", "parseInt", "(", "buildNumber", ")", "+", "1", ";", "nextMinorVersion", "=", "minorVersionToken", ".", "substring", "(", "0", ",", "lastDashIndex", "+", "1", ")", "+", "nextBuildNumber", ";", "}", "else", "{", "nextMinorVersion", "=", "Integer", ".", "parseInt", "(", "minorVersionToken", ")", "+", "1", "+", "\"\"", ";", "}", "nextVersion", "=", "fromVersion", ".", "substring", "(", "0", ",", "lastDotIndex", "+", "1", ")", "+", "nextMinorVersion", ";", "}", "else", "{", "// maybe it's just a major version; try to parse as an int", "int", "nextMajorVersion", "=", "Integer", ".", "parseInt", "(", "fromVersion", ")", "+", "1", ";", "nextVersion", "=", "nextMajorVersion", "+", "\"\"", ";", "}", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "fromVersion", ";", "}", "return", "nextVersion", "+", "\"-SNAPSHOT\"", ";", "}" ]
Calculates the next snapshot version based on the current release version @param fromVersion The version to bump to next development version @return The next calculated development (snapshot) version
[ "Calculates", "the", "next", "snapshot", "version", "based", "on", "the", "current", "release", "version" ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/ReleaseAction.java#L470-L499
164,668
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/release/ReleaseAction.java
ReleaseAction.addVars
public void addVars(Map<String, String> env) { if (tagUrl != null) { env.put("RELEASE_SCM_TAG", tagUrl); env.put(RT_RELEASE_STAGING + "SCM_TAG", tagUrl); } if (releaseBranch != null) { env.put("RELEASE_SCM_BRANCH", releaseBranch); env.put(RT_RELEASE_STAGING + "SCM_BRANCH", releaseBranch); } if (releaseVersion != null) { env.put(RT_RELEASE_STAGING + "VERSION", releaseVersion); } if (nextVersion != null) { env.put(RT_RELEASE_STAGING + "NEXT_VERSION", nextVersion); } }
java
public void addVars(Map<String, String> env) { if (tagUrl != null) { env.put("RELEASE_SCM_TAG", tagUrl); env.put(RT_RELEASE_STAGING + "SCM_TAG", tagUrl); } if (releaseBranch != null) { env.put("RELEASE_SCM_BRANCH", releaseBranch); env.put(RT_RELEASE_STAGING + "SCM_BRANCH", releaseBranch); } if (releaseVersion != null) { env.put(RT_RELEASE_STAGING + "VERSION", releaseVersion); } if (nextVersion != null) { env.put(RT_RELEASE_STAGING + "NEXT_VERSION", nextVersion); } }
[ "public", "void", "addVars", "(", "Map", "<", "String", ",", "String", ">", "env", ")", "{", "if", "(", "tagUrl", "!=", "null", ")", "{", "env", ".", "put", "(", "\"RELEASE_SCM_TAG\"", ",", "tagUrl", ")", ";", "env", ".", "put", "(", "RT_RELEASE_STAGING", "+", "\"SCM_TAG\"", ",", "tagUrl", ")", ";", "}", "if", "(", "releaseBranch", "!=", "null", ")", "{", "env", ".", "put", "(", "\"RELEASE_SCM_BRANCH\"", ",", "releaseBranch", ")", ";", "env", ".", "put", "(", "RT_RELEASE_STAGING", "+", "\"SCM_BRANCH\"", ",", "releaseBranch", ")", ";", "}", "if", "(", "releaseVersion", "!=", "null", ")", "{", "env", ".", "put", "(", "RT_RELEASE_STAGING", "+", "\"VERSION\"", ",", "releaseVersion", ")", ";", "}", "if", "(", "nextVersion", "!=", "null", ")", "{", "env", ".", "put", "(", "RT_RELEASE_STAGING", "+", "\"NEXT_VERSION\"", ",", "nextVersion", ")", ";", "}", "}" ]
Add some of the release build properties to a map.
[ "Add", "some", "of", "the", "release", "build", "properties", "to", "a", "map", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/ReleaseAction.java#L678-L693
164,669
jenkinsci/artifactory-plugin
src/main/java/org/jfrog/hudson/gradle/GradleInitScriptWriter.java
GradleInitScriptWriter.generateInitScript
public String generateInitScript(EnvVars env) throws IOException, InterruptedException { StringBuilder initScript = new StringBuilder(); InputStream templateStream = getClass().getResourceAsStream("/initscripttemplate.gradle"); String templateAsString = IOUtils.toString(templateStream, Charsets.UTF_8.name()); File extractorJar = PluginDependencyHelper.getExtractorJar(env); FilePath dependencyDir = PluginDependencyHelper.getActualDependencyDirectory(extractorJar, rootPath); String absoluteDependencyDirPath = dependencyDir.getRemote(); absoluteDependencyDirPath = absoluteDependencyDirPath.replace("\\", "/"); String str = templateAsString.replace("${pluginLibDir}", absoluteDependencyDirPath); initScript.append(str); return initScript.toString(); }
java
public String generateInitScript(EnvVars env) throws IOException, InterruptedException { StringBuilder initScript = new StringBuilder(); InputStream templateStream = getClass().getResourceAsStream("/initscripttemplate.gradle"); String templateAsString = IOUtils.toString(templateStream, Charsets.UTF_8.name()); File extractorJar = PluginDependencyHelper.getExtractorJar(env); FilePath dependencyDir = PluginDependencyHelper.getActualDependencyDirectory(extractorJar, rootPath); String absoluteDependencyDirPath = dependencyDir.getRemote(); absoluteDependencyDirPath = absoluteDependencyDirPath.replace("\\", "/"); String str = templateAsString.replace("${pluginLibDir}", absoluteDependencyDirPath); initScript.append(str); return initScript.toString(); }
[ "public", "String", "generateInitScript", "(", "EnvVars", "env", ")", "throws", "IOException", ",", "InterruptedException", "{", "StringBuilder", "initScript", "=", "new", "StringBuilder", "(", ")", ";", "InputStream", "templateStream", "=", "getClass", "(", ")", ".", "getResourceAsStream", "(", "\"/initscripttemplate.gradle\"", ")", ";", "String", "templateAsString", "=", "IOUtils", ".", "toString", "(", "templateStream", ",", "Charsets", ".", "UTF_8", ".", "name", "(", ")", ")", ";", "File", "extractorJar", "=", "PluginDependencyHelper", ".", "getExtractorJar", "(", "env", ")", ";", "FilePath", "dependencyDir", "=", "PluginDependencyHelper", ".", "getActualDependencyDirectory", "(", "extractorJar", ",", "rootPath", ")", ";", "String", "absoluteDependencyDirPath", "=", "dependencyDir", ".", "getRemote", "(", ")", ";", "absoluteDependencyDirPath", "=", "absoluteDependencyDirPath", ".", "replace", "(", "\"\\\\\"", ",", "\"/\"", ")", ";", "String", "str", "=", "templateAsString", ".", "replace", "(", "\"${pluginLibDir}\"", ",", "absoluteDependencyDirPath", ")", ";", "initScript", ".", "append", "(", "str", ")", ";", "return", "initScript", ".", "toString", "(", ")", ";", "}" ]
Generate the init script from the Artifactory URL. @return The generated script.
[ "Generate", "the", "init", "script", "from", "the", "Artifactory", "URL", "." ]
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/gradle/GradleInitScriptWriter.java#L50-L61
164,670
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java
BinaryUtils.convertBytesToInt
public static int convertBytesToInt(byte[] bytes, int offset) { return (BITWISE_BYTE_TO_INT & bytes[offset + 3]) | ((BITWISE_BYTE_TO_INT & bytes[offset + 2]) << 8) | ((BITWISE_BYTE_TO_INT & bytes[offset + 1]) << 16) | ((BITWISE_BYTE_TO_INT & bytes[offset]) << 24); }
java
public static int convertBytesToInt(byte[] bytes, int offset) { return (BITWISE_BYTE_TO_INT & bytes[offset + 3]) | ((BITWISE_BYTE_TO_INT & bytes[offset + 2]) << 8) | ((BITWISE_BYTE_TO_INT & bytes[offset + 1]) << 16) | ((BITWISE_BYTE_TO_INT & bytes[offset]) << 24); }
[ "public", "static", "int", "convertBytesToInt", "(", "byte", "[", "]", "bytes", ",", "int", "offset", ")", "{", "return", "(", "BITWISE_BYTE_TO_INT", "&", "bytes", "[", "offset", "+", "3", "]", ")", "|", "(", "(", "BITWISE_BYTE_TO_INT", "&", "bytes", "[", "offset", "+", "2", "]", ")", "<<", "8", ")", "|", "(", "(", "BITWISE_BYTE_TO_INT", "&", "bytes", "[", "offset", "+", "1", "]", ")", "<<", "16", ")", "|", "(", "(", "BITWISE_BYTE_TO_INT", "&", "bytes", "[", "offset", "]", ")", "<<", "24", ")", ";", "}" ]
Take four bytes from the specified position in the specified block and convert them into a 32-bit int, using the big-endian convention. @param bytes The data to read from. @param offset The position to start reading the 4-byte int from. @return The 32-bit integer represented by the four bytes.
[ "Take", "four", "bytes", "from", "the", "specified", "position", "in", "the", "specified", "block", "and", "convert", "them", "into", "a", "32", "-", "bit", "int", "using", "the", "big", "-", "endian", "convention", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java#L85-L91
164,671
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java
BinaryUtils.convertBytesToInts
public static int[] convertBytesToInts(byte[] bytes) { if (bytes.length % 4 != 0) { throw new IllegalArgumentException("Number of input bytes must be a multiple of 4."); } int[] ints = new int[bytes.length / 4]; for (int i = 0; i < ints.length; i++) { ints[i] = convertBytesToInt(bytes, i * 4); } return ints; }
java
public static int[] convertBytesToInts(byte[] bytes) { if (bytes.length % 4 != 0) { throw new IllegalArgumentException("Number of input bytes must be a multiple of 4."); } int[] ints = new int[bytes.length / 4]; for (int i = 0; i < ints.length; i++) { ints[i] = convertBytesToInt(bytes, i * 4); } return ints; }
[ "public", "static", "int", "[", "]", "convertBytesToInts", "(", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", ".", "length", "%", "4", "!=", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Number of input bytes must be a multiple of 4.\"", ")", ";", "}", "int", "[", "]", "ints", "=", "new", "int", "[", "bytes", ".", "length", "/", "4", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ints", ".", "length", ";", "i", "++", ")", "{", "ints", "[", "i", "]", "=", "convertBytesToInt", "(", "bytes", ",", "i", "*", "4", ")", ";", "}", "return", "ints", ";", "}" ]
Convert an array of bytes into an array of ints. 4 bytes from the input data map to a single int in the output data. @param bytes The data to read from. @return An array of 32-bit integers constructed from the data. @since 1.1
[ "Convert", "an", "array", "of", "bytes", "into", "an", "array", "of", "ints", ".", "4", "bytes", "from", "the", "input", "data", "map", "to", "a", "single", "int", "in", "the", "output", "data", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java#L101-L113
164,672
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java
BinaryUtils.convertBytesToLong
public static long convertBytesToLong(byte[] bytes, int offset) { long value = 0; for (int i = offset; i < offset + 8; i++) { byte b = bytes[i]; value <<= 8; value |= b; } return value; }
java
public static long convertBytesToLong(byte[] bytes, int offset) { long value = 0; for (int i = offset; i < offset + 8; i++) { byte b = bytes[i]; value <<= 8; value |= b; } return value; }
[ "public", "static", "long", "convertBytesToLong", "(", "byte", "[", "]", "bytes", ",", "int", "offset", ")", "{", "long", "value", "=", "0", ";", "for", "(", "int", "i", "=", "offset", ";", "i", "<", "offset", "+", "8", ";", "i", "++", ")", "{", "byte", "b", "=", "bytes", "[", "i", "]", ";", "value", "<<=", "8", ";", "value", "|=", "b", ";", "}", "return", "value", ";", "}" ]
Utility method to convert an array of bytes into a long. Byte ordered is assumed to be big-endian. @param bytes The data to read from. @param offset The position to start reading the 8-byte long from. @return The 64-bit integer represented by the eight bytes. @since 1.1
[ "Utility", "method", "to", "convert", "an", "array", "of", "bytes", "into", "a", "long", ".", "Byte", "ordered", "is", "assumed", "to", "be", "big", "-", "endian", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BinaryUtils.java#L124-L135
164,673
dwdyer/uncommons-maths
demo/src/java/main/org/uncommons/maths/demo/GaussianDistribution.java
GaussianDistribution.getExpectedProbability
private double getExpectedProbability(double x) { double y = 1 / (standardDeviation * Math.sqrt(Math.PI * 2)); double z = -(Math.pow(x - mean, 2) / (2 * Math.pow(standardDeviation, 2))); return y * Math.exp(z); }
java
private double getExpectedProbability(double x) { double y = 1 / (standardDeviation * Math.sqrt(Math.PI * 2)); double z = -(Math.pow(x - mean, 2) / (2 * Math.pow(standardDeviation, 2))); return y * Math.exp(z); }
[ "private", "double", "getExpectedProbability", "(", "double", "x", ")", "{", "double", "y", "=", "1", "/", "(", "standardDeviation", "*", "Math", ".", "sqrt", "(", "Math", ".", "PI", "*", "2", ")", ")", ";", "double", "z", "=", "-", "(", "Math", ".", "pow", "(", "x", "-", "mean", ",", "2", ")", "/", "(", "2", "*", "Math", ".", "pow", "(", "standardDeviation", ",", "2", ")", ")", ")", ";", "return", "y", "*", "Math", ".", "exp", "(", "z", ")", ";", "}" ]
This is the probability density function for the Gaussian distribution.
[ "This", "is", "the", "probability", "density", "function", "for", "the", "Gaussian", "distribution", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/demo/src/java/main/org/uncommons/maths/demo/GaussianDistribution.java#L65-L70
164,674
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java
PermutationGenerator.reset
public final void reset() { for (int i = 0; i < permutationIndices.length; i++) { permutationIndices[i] = i; } remainingPermutations = totalPermutations; }
java
public final void reset() { for (int i = 0; i < permutationIndices.length; i++) { permutationIndices[i] = i; } remainingPermutations = totalPermutations; }
[ "public", "final", "void", "reset", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "permutationIndices", ".", "length", ";", "i", "++", ")", "{", "permutationIndices", "[", "i", "]", "=", "i", ";", "}", "remainingPermutations", "=", "totalPermutations", ";", "}" ]
Resets the generator state.
[ "Resets", "the", "generator", "state", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java#L83-L90
164,675
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java
PermutationGenerator.nextPermutationAsArray
@SuppressWarnings("unchecked") public T[] nextPermutationAsArray() { T[] permutation = (T[]) Array.newInstance(elements.getClass().getComponentType(), permutationIndices.length); return nextPermutationAsArray(permutation); }
java
@SuppressWarnings("unchecked") public T[] nextPermutationAsArray() { T[] permutation = (T[]) Array.newInstance(elements.getClass().getComponentType(), permutationIndices.length); return nextPermutationAsArray(permutation); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "[", "]", "nextPermutationAsArray", "(", ")", "{", "T", "[", "]", "permutation", "=", "(", "T", "[", "]", ")", "Array", ".", "newInstance", "(", "elements", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ",", "permutationIndices", ".", "length", ")", ";", "return", "nextPermutationAsArray", "(", "permutation", ")", ";", "}" ]
Generate the next permutation and return an array containing the elements in the appropriate order. @see #nextPermutationAsArray(Object[]) @see #nextPermutationAsList() @return The next permutation as an array.
[ "Generate", "the", "next", "permutation", "and", "return", "an", "array", "containing", "the", "elements", "in", "the", "appropriate", "order", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java#L131-L137
164,676
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java
PermutationGenerator.nextPermutationAsList
public List<T> nextPermutationAsList() { List<T> permutation = new ArrayList<T>(elements.length); return nextPermutationAsList(permutation); }
java
public List<T> nextPermutationAsList() { List<T> permutation = new ArrayList<T>(elements.length); return nextPermutationAsList(permutation); }
[ "public", "List", "<", "T", ">", "nextPermutationAsList", "(", ")", "{", "List", "<", "T", ">", "permutation", "=", "new", "ArrayList", "<", "T", ">", "(", "elements", ".", "length", ")", ";", "return", "nextPermutationAsList", "(", "permutation", ")", ";", "}" ]
Generate the next permutation and return a list containing the elements in the appropriate order. @see #nextPermutationAsList(java.util.List) @see #nextPermutationAsArray() @return The next permutation as a list.
[ "Generate", "the", "next", "permutation", "and", "return", "a", "list", "containing", "the", "elements", "in", "the", "appropriate", "order", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/combinatorics/PermutationGenerator.java#L179-L183
164,677
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/random/JavaRNG.java
JavaRNG.createLongSeed
private static long createLongSeed(byte[] seed) { if (seed == null || seed.length != SEED_SIZE_BYTES) { throw new IllegalArgumentException("Java RNG requires a 64-bit (8-byte) seed."); } return BinaryUtils.convertBytesToLong(seed, 0); }
java
private static long createLongSeed(byte[] seed) { if (seed == null || seed.length != SEED_SIZE_BYTES) { throw new IllegalArgumentException("Java RNG requires a 64-bit (8-byte) seed."); } return BinaryUtils.convertBytesToLong(seed, 0); }
[ "private", "static", "long", "createLongSeed", "(", "byte", "[", "]", "seed", ")", "{", "if", "(", "seed", "==", "null", "||", "seed", ".", "length", "!=", "SEED_SIZE_BYTES", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Java RNG requires a 64-bit (8-byte) seed.\"", ")", ";", "}", "return", "BinaryUtils", ".", "convertBytesToLong", "(", "seed", ",", "0", ")", ";", "}" ]
Helper method to convert seed bytes into the long value required by the super class.
[ "Helper", "method", "to", "convert", "seed", "bytes", "into", "the", "long", "value", "required", "by", "the", "super", "class", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/random/JavaRNG.java#L79-L86
164,678
dwdyer/uncommons-maths
demo/src/java/main/org/uncommons/swing/SwingBackgroundTask.java
SwingBackgroundTask.execute
public void execute() { Runnable task = new Runnable() { public void run() { final V result = performTask(); SwingUtilities.invokeLater(new Runnable() { public void run() { postProcessing(result); latch.countDown(); } }); } }; new Thread(task, "SwingBackgroundTask-" + id).start(); }
java
public void execute() { Runnable task = new Runnable() { public void run() { final V result = performTask(); SwingUtilities.invokeLater(new Runnable() { public void run() { postProcessing(result); latch.countDown(); } }); } }; new Thread(task, "SwingBackgroundTask-" + id).start(); }
[ "public", "void", "execute", "(", ")", "{", "Runnable", "task", "=", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "final", "V", "result", "=", "performTask", "(", ")", ";", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "postProcessing", "(", "result", ")", ";", "latch", ".", "countDown", "(", ")", ";", "}", "}", ")", ";", "}", "}", ";", "new", "Thread", "(", "task", ",", "\"SwingBackgroundTask-\"", "+", "id", ")", ".", "start", "(", ")", ";", "}" ]
Asynchronous call that begins execution of the task and returns immediately.
[ "Asynchronous", "call", "that", "begins", "execution", "of", "the", "task", "and", "returns", "immediately", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/demo/src/java/main/org/uncommons/swing/SwingBackgroundTask.java#L49-L67
164,679
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/statistics/DataSet.java
DataSet.addValue
public void addValue(double value) { if (dataSetSize == dataSet.length) { // Increase the capacity of the array. int newLength = (int) (GROWTH_RATE * dataSetSize); double[] newDataSet = new double[newLength]; System.arraycopy(dataSet, 0, newDataSet, 0, dataSetSize); dataSet = newDataSet; } dataSet[dataSetSize] = value; updateStatsWithNewValue(value); ++dataSetSize; }
java
public void addValue(double value) { if (dataSetSize == dataSet.length) { // Increase the capacity of the array. int newLength = (int) (GROWTH_RATE * dataSetSize); double[] newDataSet = new double[newLength]; System.arraycopy(dataSet, 0, newDataSet, 0, dataSetSize); dataSet = newDataSet; } dataSet[dataSetSize] = value; updateStatsWithNewValue(value); ++dataSetSize; }
[ "public", "void", "addValue", "(", "double", "value", ")", "{", "if", "(", "dataSetSize", "==", "dataSet", ".", "length", ")", "{", "// Increase the capacity of the array.", "int", "newLength", "=", "(", "int", ")", "(", "GROWTH_RATE", "*", "dataSetSize", ")", ";", "double", "[", "]", "newDataSet", "=", "new", "double", "[", "newLength", "]", ";", "System", ".", "arraycopy", "(", "dataSet", ",", "0", ",", "newDataSet", ",", "0", ",", "dataSetSize", ")", ";", "dataSet", "=", "newDataSet", ";", "}", "dataSet", "[", "dataSetSize", "]", "=", "value", ";", "updateStatsWithNewValue", "(", "value", ")", ";", "++", "dataSetSize", ";", "}" ]
Adds a single value to the data set and updates any statistics that are calculated cumulatively. @param value The value to add.
[ "Adds", "a", "single", "value", "to", "the", "data", "set", "and", "updates", "any", "statistics", "that", "are", "calculated", "cumulatively", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/statistics/DataSet.java#L83-L96
164,680
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/statistics/DataSet.java
DataSet.getMedian
public final double getMedian() { assertNotEmpty(); // Sort the data (take a copy to do this). double[] dataCopy = new double[getSize()]; System.arraycopy(dataSet, 0, dataCopy, 0, dataCopy.length); Arrays.sort(dataCopy); int midPoint = dataCopy.length / 2; if (dataCopy.length % 2 != 0) { return dataCopy[midPoint]; } else { return dataCopy[midPoint - 1] + (dataCopy[midPoint] - dataCopy[midPoint - 1]) / 2; } }
java
public final double getMedian() { assertNotEmpty(); // Sort the data (take a copy to do this). double[] dataCopy = new double[getSize()]; System.arraycopy(dataSet, 0, dataCopy, 0, dataCopy.length); Arrays.sort(dataCopy); int midPoint = dataCopy.length / 2; if (dataCopy.length % 2 != 0) { return dataCopy[midPoint]; } else { return dataCopy[midPoint - 1] + (dataCopy[midPoint] - dataCopy[midPoint - 1]) / 2; } }
[ "public", "final", "double", "getMedian", "(", ")", "{", "assertNotEmpty", "(", ")", ";", "// Sort the data (take a copy to do this).", "double", "[", "]", "dataCopy", "=", "new", "double", "[", "getSize", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "dataSet", ",", "0", ",", "dataCopy", ",", "0", ",", "dataCopy", ".", "length", ")", ";", "Arrays", ".", "sort", "(", "dataCopy", ")", ";", "int", "midPoint", "=", "dataCopy", ".", "length", "/", "2", ";", "if", "(", "dataCopy", ".", "length", "%", "2", "!=", "0", ")", "{", "return", "dataCopy", "[", "midPoint", "]", ";", "}", "else", "{", "return", "dataCopy", "[", "midPoint", "-", "1", "]", "+", "(", "dataCopy", "[", "midPoint", "]", "-", "dataCopy", "[", "midPoint", "-", "1", "]", ")", "/", "2", ";", "}", "}" ]
Determines the median value of the data set. @return If the number of elements is odd, returns the middle element. If the number of elements is even, returns the midpoint of the two middle elements. @since 1.0.1
[ "Determines", "the", "median", "value", "of", "the", "data", "set", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/statistics/DataSet.java#L159-L175
164,681
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/statistics/DataSet.java
DataSet.sumSquaredDiffs
private double sumSquaredDiffs() { double mean = getArithmeticMean(); double squaredDiffs = 0; for (int i = 0; i < getSize(); i++) { double diff = mean - dataSet[i]; squaredDiffs += (diff * diff); } return squaredDiffs; }
java
private double sumSquaredDiffs() { double mean = getArithmeticMean(); double squaredDiffs = 0; for (int i = 0; i < getSize(); i++) { double diff = mean - dataSet[i]; squaredDiffs += (diff * diff); } return squaredDiffs; }
[ "private", "double", "sumSquaredDiffs", "(", ")", "{", "double", "mean", "=", "getArithmeticMean", "(", ")", ";", "double", "squaredDiffs", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getSize", "(", ")", ";", "i", "++", ")", "{", "double", "diff", "=", "mean", "-", "dataSet", "[", "i", "]", ";", "squaredDiffs", "+=", "(", "diff", "*", "diff", ")", ";", "}", "return", "squaredDiffs", ";", "}" ]
Helper method for variance calculations. @return The sum of the squares of the differences between each value and the arithmetic mean. @throws EmptyDataSetException If the data set is empty.
[ "Helper", "method", "for", "variance", "calculations", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/statistics/DataSet.java#L298-L308
164,682
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BitString.java
BitString.getBit
public boolean getBit(int index) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; return (data[word] & (1 << offset)) != 0; }
java
public boolean getBit(int index) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; return (data[word] & (1 << offset)) != 0; }
[ "public", "boolean", "getBit", "(", "int", "index", ")", "{", "assertValidIndex", "(", "index", ")", ";", "int", "word", "=", "index", "/", "WORD_LENGTH", ";", "int", "offset", "=", "index", "%", "WORD_LENGTH", ";", "return", "(", "data", "[", "word", "]", "&", "(", "1", "<<", "offset", ")", ")", "!=", "0", ";", "}" ]
Returns the bit at the specified index. @param index The index of the bit to look-up (0 is the least-significant bit). @return A boolean indicating whether the bit is set or not. @throws IndexOutOfBoundsException If the specified index is not a bit position in this bit string.
[ "Returns", "the", "bit", "at", "the", "specified", "index", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BitString.java#L129-L135
164,683
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BitString.java
BitString.setBit
public void setBit(int index, boolean set) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; if (set) { data[word] |= (1 << offset); } else // Unset the bit. { data[word] &= ~(1 << offset); } }
java
public void setBit(int index, boolean set) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; if (set) { data[word] |= (1 << offset); } else // Unset the bit. { data[word] &= ~(1 << offset); } }
[ "public", "void", "setBit", "(", "int", "index", ",", "boolean", "set", ")", "{", "assertValidIndex", "(", "index", ")", ";", "int", "word", "=", "index", "/", "WORD_LENGTH", ";", "int", "offset", "=", "index", "%", "WORD_LENGTH", ";", "if", "(", "set", ")", "{", "data", "[", "word", "]", "|=", "(", "1", "<<", "offset", ")", ";", "}", "else", "// Unset the bit.", "{", "data", "[", "word", "]", "&=", "~", "(", "1", "<<", "offset", ")", ";", "}", "}" ]
Sets the bit at the specified index. @param index The index of the bit to set (0 is the least-significant bit). @param set A boolean indicating whether the bit should be set or not. @throws IndexOutOfBoundsException If the specified index is not a bit position in this bit string.
[ "Sets", "the", "bit", "at", "the", "specified", "index", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BitString.java#L145-L158
164,684
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BitString.java
BitString.flipBit
public void flipBit(int index) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; data[word] ^= (1 << offset); }
java
public void flipBit(int index) { assertValidIndex(index); int word = index / WORD_LENGTH; int offset = index % WORD_LENGTH; data[word] ^= (1 << offset); }
[ "public", "void", "flipBit", "(", "int", "index", ")", "{", "assertValidIndex", "(", "index", ")", ";", "int", "word", "=", "index", "/", "WORD_LENGTH", ";", "int", "offset", "=", "index", "%", "WORD_LENGTH", ";", "data", "[", "word", "]", "^=", "(", "1", "<<", "offset", ")", ";", "}" ]
Inverts the value of the bit at the specified index. @param index The bit to flip (0 is the least-significant bit). @throws IndexOutOfBoundsException If the specified index is not a bit position in this bit string.
[ "Inverts", "the", "value", "of", "the", "bit", "at", "the", "specified", "index", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BitString.java#L167-L173
164,685
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/binary/BitString.java
BitString.swapSubstring
public void swapSubstring(BitString other, int start, int length) { assertValidIndex(start); other.assertValidIndex(start); int word = start / WORD_LENGTH; int partialWordSize = (WORD_LENGTH - start) % WORD_LENGTH; if (partialWordSize > 0) { swapBits(other, word, 0xFFFFFFFF << (WORD_LENGTH - partialWordSize)); ++word; } int remainingBits = length - partialWordSize; int stop = remainingBits / WORD_LENGTH; for (int i = word; i < stop; i++) { int temp = data[i]; data[i] = other.data[i]; other.data[i] = temp; } remainingBits %= WORD_LENGTH; if (remainingBits > 0) { swapBits(other, word, 0xFFFFFFFF >>> (WORD_LENGTH - remainingBits)); } }
java
public void swapSubstring(BitString other, int start, int length) { assertValidIndex(start); other.assertValidIndex(start); int word = start / WORD_LENGTH; int partialWordSize = (WORD_LENGTH - start) % WORD_LENGTH; if (partialWordSize > 0) { swapBits(other, word, 0xFFFFFFFF << (WORD_LENGTH - partialWordSize)); ++word; } int remainingBits = length - partialWordSize; int stop = remainingBits / WORD_LENGTH; for (int i = word; i < stop; i++) { int temp = data[i]; data[i] = other.data[i]; other.data[i] = temp; } remainingBits %= WORD_LENGTH; if (remainingBits > 0) { swapBits(other, word, 0xFFFFFFFF >>> (WORD_LENGTH - remainingBits)); } }
[ "public", "void", "swapSubstring", "(", "BitString", "other", ",", "int", "start", ",", "int", "length", ")", "{", "assertValidIndex", "(", "start", ")", ";", "other", ".", "assertValidIndex", "(", "start", ")", ";", "int", "word", "=", "start", "/", "WORD_LENGTH", ";", "int", "partialWordSize", "=", "(", "WORD_LENGTH", "-", "start", ")", "%", "WORD_LENGTH", ";", "if", "(", "partialWordSize", ">", "0", ")", "{", "swapBits", "(", "other", ",", "word", ",", "0xFFFFFFFF", "<<", "(", "WORD_LENGTH", "-", "partialWordSize", ")", ")", ";", "++", "word", ";", "}", "int", "remainingBits", "=", "length", "-", "partialWordSize", ";", "int", "stop", "=", "remainingBits", "/", "WORD_LENGTH", ";", "for", "(", "int", "i", "=", "word", ";", "i", "<", "stop", ";", "i", "++", ")", "{", "int", "temp", "=", "data", "[", "i", "]", ";", "data", "[", "i", "]", "=", "other", ".", "data", "[", "i", "]", ";", "other", ".", "data", "[", "i", "]", "=", "temp", ";", "}", "remainingBits", "%=", "WORD_LENGTH", ";", "if", "(", "remainingBits", ">", "0", ")", "{", "swapBits", "(", "other", ",", "word", ",", "0xFFFFFFFF", ">>>", "(", "WORD_LENGTH", "-", "remainingBits", ")", ")", ";", "}", "}" ]
An efficient method for exchanging data between two bit strings. Both bit strings must be long enough that they contain the full length of the specified substring. @param other The bitstring with which this bitstring should swap bits. @param start The start position for the substrings to be exchanged. All bit indices are big-endian, which means position 0 is the rightmost bit. @param length The number of contiguous bits to swap.
[ "An", "efficient", "method", "for", "exchanging", "data", "between", "two", "bit", "strings", ".", "Both", "bit", "strings", "must", "be", "long", "enough", "that", "they", "contain", "the", "full", "length", "of", "the", "specified", "substring", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/binary/BitString.java#L237-L265
164,686
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/number/Rational.java
Rational.compareTo
public int compareTo(Rational other) { if (denominator == other.getDenominator()) { return ((Long) numerator).compareTo(other.getNumerator()); } else { Long adjustedNumerator = numerator * other.getDenominator(); Long otherAdjustedNumerator = other.getNumerator() * denominator; return adjustedNumerator.compareTo(otherAdjustedNumerator); } }
java
public int compareTo(Rational other) { if (denominator == other.getDenominator()) { return ((Long) numerator).compareTo(other.getNumerator()); } else { Long adjustedNumerator = numerator * other.getDenominator(); Long otherAdjustedNumerator = other.getNumerator() * denominator; return adjustedNumerator.compareTo(otherAdjustedNumerator); } }
[ "public", "int", "compareTo", "(", "Rational", "other", ")", "{", "if", "(", "denominator", "==", "other", ".", "getDenominator", "(", ")", ")", "{", "return", "(", "(", "Long", ")", "numerator", ")", ".", "compareTo", "(", "other", ".", "getNumerator", "(", ")", ")", ";", "}", "else", "{", "Long", "adjustedNumerator", "=", "numerator", "*", "other", ".", "getDenominator", "(", ")", ";", "Long", "otherAdjustedNumerator", "=", "other", ".", "getNumerator", "(", ")", "*", "denominator", ";", "return", "adjustedNumerator", ".", "compareTo", "(", "otherAdjustedNumerator", ")", ";", "}", "}" ]
Compares this value with the specified object for order. Returns a negative integer, zero, or a positive integer as this value is less than, equal to, or greater than the specified value. @param other Another Rational value. @return A negative integer, zero, or a positive integer as this value is less than, equal to, or greater than the specified value.
[ "Compares", "this", "value", "with", "the", "specified", "object", "for", "order", ".", "Returns", "a", "negative", "integer", "zero", "or", "a", "positive", "integer", "as", "this", "value", "is", "less", "than", "equal", "to", "or", "greater", "than", "the", "specified", "value", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/number/Rational.java#L329-L341
164,687
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/random/DiehardInputGenerator.java
DiehardInputGenerator.generateOutputFile
public static void generateOutputFile(Random rng, File outputFile) throws IOException { DataOutputStream dataOutput = null; try { dataOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile))); for (int i = 0; i < INT_COUNT; i++) { dataOutput.writeInt(rng.nextInt()); } dataOutput.flush(); } finally { if (dataOutput != null) { dataOutput.close(); } } }
java
public static void generateOutputFile(Random rng, File outputFile) throws IOException { DataOutputStream dataOutput = null; try { dataOutput = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile))); for (int i = 0; i < INT_COUNT; i++) { dataOutput.writeInt(rng.nextInt()); } dataOutput.flush(); } finally { if (dataOutput != null) { dataOutput.close(); } } }
[ "public", "static", "void", "generateOutputFile", "(", "Random", "rng", ",", "File", "outputFile", ")", "throws", "IOException", "{", "DataOutputStream", "dataOutput", "=", "null", ";", "try", "{", "dataOutput", "=", "new", "DataOutputStream", "(", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "outputFile", ")", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "INT_COUNT", ";", "i", "++", ")", "{", "dataOutput", ".", "writeInt", "(", "rng", ".", "nextInt", "(", ")", ")", ";", "}", "dataOutput", ".", "flush", "(", ")", ";", "}", "finally", "{", "if", "(", "dataOutput", "!=", "null", ")", "{", "dataOutput", ".", "close", "(", ")", ";", "}", "}", "}" ]
Generates a file of random data in a format suitable for the DIEHARD test. DIEHARD requires 3 million 32-bit integers. @param rng The random number generator to use to generate the data. @param outputFile The file that the random data is written to. @throws IOException If there is a problem writing to the file.
[ "Generates", "a", "file", "of", "random", "data", "in", "a", "format", "suitable", "for", "the", "DIEHARD", "test", ".", "DIEHARD", "requires", "3", "million", "32", "-", "bit", "integers", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/random/DiehardInputGenerator.java#L70-L90
164,688
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/Maths.java
Maths.raiseToPower
public static long raiseToPower(int value, int power) { if (power < 0) { throw new IllegalArgumentException("This method does not support negative powers."); } long result = 1; for (int i = 0; i < power; i++) { result *= value; } return result; }
java
public static long raiseToPower(int value, int power) { if (power < 0) { throw new IllegalArgumentException("This method does not support negative powers."); } long result = 1; for (int i = 0; i < power; i++) { result *= value; } return result; }
[ "public", "static", "long", "raiseToPower", "(", "int", "value", ",", "int", "power", ")", "{", "if", "(", "power", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"This method does not support negative powers.\"", ")", ";", "}", "long", "result", "=", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "power", ";", "i", "++", ")", "{", "result", "*=", "value", ";", "}", "return", "result", ";", "}" ]
Calculate the first argument raised to the power of the second. This method only supports non-negative powers. @param value The number to be raised. @param power The exponent (must be positive). @return {@code value} raised to {@code power}.
[ "Calculate", "the", "first", "argument", "raised", "to", "the", "power", "of", "the", "second", ".", "This", "method", "only", "supports", "non", "-", "negative", "powers", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/Maths.java#L111-L123
164,689
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/Maths.java
Maths.restrictRange
public static int restrictRange(int value, int min, int max) { return Math.min((Math.max(value, min)), max); }
java
public static int restrictRange(int value, int min, int max) { return Math.min((Math.max(value, min)), max); }
[ "public", "static", "int", "restrictRange", "(", "int", "value", ",", "int", "min", ",", "int", "max", ")", "{", "return", "Math", ".", "min", "(", "(", "Math", ".", "max", "(", "value", ",", "min", ")", ")", ",", "max", ")", ";", "}" ]
If the specified value is not greater than or equal to the specified minimum and less than or equal to the specified maximum, adjust it so that it is. @param value The value to check. @param min The minimum permitted value. @param max The maximum permitted value. @return {@code value} if it is between the specified limits, {@code min} if the value is too low, or {@code max} if the value is too high. @since 1.2
[ "If", "the", "specified", "value", "is", "not", "greater", "than", "or", "equal", "to", "the", "specified", "minimum", "and", "less", "than", "or", "equal", "to", "the", "specified", "maximum", "adjust", "it", "so", "that", "it", "is", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/Maths.java#L170-L173
164,690
dwdyer/uncommons-maths
demo/src/java/main/org/uncommons/maths/demo/ProbabilityDistribution.java
ProbabilityDistribution.doQuantization
protected static Map<Double, Double> doQuantization(double max, double min, double[] values) { double range = max - min; int noIntervals = 20; double intervalSize = range / noIntervals; int[] intervals = new int[noIntervals]; for (double value : values) { int interval = Math.min(noIntervals - 1, (int) Math.floor((value - min) / intervalSize)); assert interval >= 0 && interval < noIntervals : "Invalid interval: " + interval; ++intervals[interval]; } Map<Double, Double> discretisedValues = new HashMap<Double, Double>(); for (int i = 0; i < intervals.length; i++) { // Correct the value to take into account the size of the interval. double value = (1 / intervalSize) * (double) intervals[i]; discretisedValues.put(min + ((i + 0.5) * intervalSize), value); } return discretisedValues; }
java
protected static Map<Double, Double> doQuantization(double max, double min, double[] values) { double range = max - min; int noIntervals = 20; double intervalSize = range / noIntervals; int[] intervals = new int[noIntervals]; for (double value : values) { int interval = Math.min(noIntervals - 1, (int) Math.floor((value - min) / intervalSize)); assert interval >= 0 && interval < noIntervals : "Invalid interval: " + interval; ++intervals[interval]; } Map<Double, Double> discretisedValues = new HashMap<Double, Double>(); for (int i = 0; i < intervals.length; i++) { // Correct the value to take into account the size of the interval. double value = (1 / intervalSize) * (double) intervals[i]; discretisedValues.put(min + ((i + 0.5) * intervalSize), value); } return discretisedValues; }
[ "protected", "static", "Map", "<", "Double", ",", "Double", ">", "doQuantization", "(", "double", "max", ",", "double", "min", ",", "double", "[", "]", "values", ")", "{", "double", "range", "=", "max", "-", "min", ";", "int", "noIntervals", "=", "20", ";", "double", "intervalSize", "=", "range", "/", "noIntervals", ";", "int", "[", "]", "intervals", "=", "new", "int", "[", "noIntervals", "]", ";", "for", "(", "double", "value", ":", "values", ")", "{", "int", "interval", "=", "Math", ".", "min", "(", "noIntervals", "-", "1", ",", "(", "int", ")", "Math", ".", "floor", "(", "(", "value", "-", "min", ")", "/", "intervalSize", ")", ")", ";", "assert", "interval", ">=", "0", "&&", "interval", "<", "noIntervals", ":", "\"Invalid interval: \"", "+", "interval", ";", "++", "intervals", "[", "interval", "]", ";", "}", "Map", "<", "Double", ",", "Double", ">", "discretisedValues", "=", "new", "HashMap", "<", "Double", ",", "Double", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "intervals", ".", "length", ";", "i", "++", ")", "{", "// Correct the value to take into account the size of the interval.", "double", "value", "=", "(", "1", "/", "intervalSize", ")", "*", "(", "double", ")", "intervals", "[", "i", "]", ";", "discretisedValues", ".", "put", "(", "min", "+", "(", "(", "i", "+", "0.5", ")", "*", "intervalSize", ")", ",", "value", ")", ";", "}", "return", "discretisedValues", ";", "}" ]
Convert the continuous values into discrete values by chopping up the distribution into several equally-sized intervals.
[ "Convert", "the", "continuous", "values", "into", "discrete", "values", "by", "chopping", "up", "the", "distribution", "into", "several", "equally", "-", "sized", "intervals", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/demo/src/java/main/org/uncommons/maths/demo/ProbabilityDistribution.java#L90-L113
164,691
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/combinatorics/CombinationGenerator.java
CombinationGenerator.reset
public final void reset() { for (int i = 0; i < combinationIndices.length; i++) { combinationIndices[i] = i; } remainingCombinations = totalCombinations; }
java
public final void reset() { for (int i = 0; i < combinationIndices.length; i++) { combinationIndices[i] = i; } remainingCombinations = totalCombinations; }
[ "public", "final", "void", "reset", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "combinationIndices", ".", "length", ";", "i", "++", ")", "{", "combinationIndices", "[", "i", "]", "=", "i", ";", "}", "remainingCombinations", "=", "totalCombinations", ";", "}" ]
Reset the combination generator.
[ "Reset", "the", "combination", "generator", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/combinatorics/CombinationGenerator.java#L94-L101
164,692
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/combinatorics/CombinationGenerator.java
CombinationGenerator.nextCombinationAsArray
@SuppressWarnings("unchecked") public T[] nextCombinationAsArray() { T[] combination = (T[]) Array.newInstance(elements.getClass().getComponentType(), combinationIndices.length); return nextCombinationAsArray(combination); }
java
@SuppressWarnings("unchecked") public T[] nextCombinationAsArray() { T[] combination = (T[]) Array.newInstance(elements.getClass().getComponentType(), combinationIndices.length); return nextCombinationAsArray(combination); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "T", "[", "]", "nextCombinationAsArray", "(", ")", "{", "T", "[", "]", "combination", "=", "(", "T", "[", "]", ")", "Array", ".", "newInstance", "(", "elements", ".", "getClass", "(", ")", ".", "getComponentType", "(", ")", ",", "combinationIndices", ".", "length", ")", ";", "return", "nextCombinationAsArray", "(", "combination", ")", ";", "}" ]
Generate the next combination and return an array containing the appropriate elements. @see #nextCombinationAsArray(Object[]) @see #nextCombinationAsList() @return An array containing the elements that make up the next combination.
[ "Generate", "the", "next", "combination", "and", "return", "an", "array", "containing", "the", "appropriate", "elements", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/combinatorics/CombinationGenerator.java#L139-L145
164,693
dwdyer/uncommons-maths
core/src/java/main/org/uncommons/maths/number/AdjustableNumberGenerator.java
AdjustableNumberGenerator.setValue
public void setValue(T value) { try { lock.writeLock().lock(); this.value = value; } finally { lock.writeLock().unlock(); } }
java
public void setValue(T value) { try { lock.writeLock().lock(); this.value = value; } finally { lock.writeLock().unlock(); } }
[ "public", "void", "setValue", "(", "T", "value", ")", "{", "try", "{", "lock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "this", ".", "value", "=", "value", ";", "}", "finally", "{", "lock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}", "}" ]
Change the value that is returned by this generator. @param value The new value to return.
[ "Change", "the", "value", "that", "is", "returned", "by", "this", "generator", "." ]
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/number/AdjustableNumberGenerator.java#L52-L63
164,694
aliyun/fc-java-sdk
src/main/java/com/aliyuncs/fc/auth/AcsURLEncoder.java
AcsURLEncoder.urlEncode
public static String urlEncode(String path) throws URISyntaxException { if (isNullOrEmpty(path)) return path; return UrlEscapers.urlFragmentEscaper().escape(path); }
java
public static String urlEncode(String path) throws URISyntaxException { if (isNullOrEmpty(path)) return path; return UrlEscapers.urlFragmentEscaper().escape(path); }
[ "public", "static", "String", "urlEncode", "(", "String", "path", ")", "throws", "URISyntaxException", "{", "if", "(", "isNullOrEmpty", "(", "path", ")", ")", "return", "path", ";", "return", "UrlEscapers", ".", "urlFragmentEscaper", "(", ")", ".", "escape", "(", "path", ")", ";", "}" ]
used for encoding url path segment
[ "used", "for", "encoding", "url", "path", "segment" ]
45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe
https://github.com/aliyun/fc-java-sdk/blob/45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe/src/main/java/com/aliyuncs/fc/auth/AcsURLEncoder.java#L42-L46
164,695
aliyun/fc-java-sdk
src/main/java/com/aliyuncs/fc/auth/AcsURLEncoder.java
AcsURLEncoder.encode
public static String encode(String value) throws UnsupportedEncodingException { if (isNullOrEmpty(value)) return value; return URLEncoder.encode(value, URL_ENCODING); }
java
public static String encode(String value) throws UnsupportedEncodingException { if (isNullOrEmpty(value)) return value; return URLEncoder.encode(value, URL_ENCODING); }
[ "public", "static", "String", "encode", "(", "String", "value", ")", "throws", "UnsupportedEncodingException", "{", "if", "(", "isNullOrEmpty", "(", "value", ")", ")", "return", "value", ";", "return", "URLEncoder", ".", "encode", "(", "value", ",", "URL_ENCODING", ")", ";", "}" ]
used for encoding queries or form data
[ "used", "for", "encoding", "queries", "or", "form", "data" ]
45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe
https://github.com/aliyun/fc-java-sdk/blob/45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe/src/main/java/com/aliyuncs/fc/auth/AcsURLEncoder.java#L52-L55
164,696
aliyun/fc-java-sdk
src/main/java/com/aliyuncs/fc/http/HttpResponse.java
HttpResponse.getResponse
public static HttpResponse getResponse(String urls, HttpRequest request, HttpMethod method, int connectTimeoutMillis, int readTimeoutMillis) throws IOException { OutputStream out = null; InputStream content = null; HttpResponse response = null; HttpURLConnection httpConn = request .getHttpConnection(urls, method.name()); httpConn.setConnectTimeout(connectTimeoutMillis); httpConn.setReadTimeout(readTimeoutMillis); try { httpConn.connect(); if (null != request.getPayload() && request.getPayload().length > 0) { out = httpConn.getOutputStream(); out.write(request.getPayload()); } content = httpConn.getInputStream(); response = new HttpResponse(); parseHttpConn(response, httpConn, content); return response; } catch (SocketTimeoutException e) { throw e; } catch (IOException e) { content = httpConn.getErrorStream(); response = new HttpResponse(); parseHttpConn(response, httpConn, content); return response; } finally { if (content != null) { content.close(); } httpConn.disconnect(); } }
java
public static HttpResponse getResponse(String urls, HttpRequest request, HttpMethod method, int connectTimeoutMillis, int readTimeoutMillis) throws IOException { OutputStream out = null; InputStream content = null; HttpResponse response = null; HttpURLConnection httpConn = request .getHttpConnection(urls, method.name()); httpConn.setConnectTimeout(connectTimeoutMillis); httpConn.setReadTimeout(readTimeoutMillis); try { httpConn.connect(); if (null != request.getPayload() && request.getPayload().length > 0) { out = httpConn.getOutputStream(); out.write(request.getPayload()); } content = httpConn.getInputStream(); response = new HttpResponse(); parseHttpConn(response, httpConn, content); return response; } catch (SocketTimeoutException e) { throw e; } catch (IOException e) { content = httpConn.getErrorStream(); response = new HttpResponse(); parseHttpConn(response, httpConn, content); return response; } finally { if (content != null) { content.close(); } httpConn.disconnect(); } }
[ "public", "static", "HttpResponse", "getResponse", "(", "String", "urls", ",", "HttpRequest", "request", ",", "HttpMethod", "method", ",", "int", "connectTimeoutMillis", ",", "int", "readTimeoutMillis", ")", "throws", "IOException", "{", "OutputStream", "out", "=", "null", ";", "InputStream", "content", "=", "null", ";", "HttpResponse", "response", "=", "null", ";", "HttpURLConnection", "httpConn", "=", "request", ".", "getHttpConnection", "(", "urls", ",", "method", ".", "name", "(", ")", ")", ";", "httpConn", ".", "setConnectTimeout", "(", "connectTimeoutMillis", ")", ";", "httpConn", ".", "setReadTimeout", "(", "readTimeoutMillis", ")", ";", "try", "{", "httpConn", ".", "connect", "(", ")", ";", "if", "(", "null", "!=", "request", ".", "getPayload", "(", ")", "&&", "request", ".", "getPayload", "(", ")", ".", "length", ">", "0", ")", "{", "out", "=", "httpConn", ".", "getOutputStream", "(", ")", ";", "out", ".", "write", "(", "request", ".", "getPayload", "(", ")", ")", ";", "}", "content", "=", "httpConn", ".", "getInputStream", "(", ")", ";", "response", "=", "new", "HttpResponse", "(", ")", ";", "parseHttpConn", "(", "response", ",", "httpConn", ",", "content", ")", ";", "return", "response", ";", "}", "catch", "(", "SocketTimeoutException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "IOException", "e", ")", "{", "content", "=", "httpConn", ".", "getErrorStream", "(", ")", ";", "response", "=", "new", "HttpResponse", "(", ")", ";", "parseHttpConn", "(", "response", ",", "httpConn", ",", "content", ")", ";", "return", "response", ";", "}", "finally", "{", "if", "(", "content", "!=", "null", ")", "{", "content", ".", "close", "(", ")", ";", "}", "httpConn", ".", "disconnect", "(", ")", ";", "}", "}" ]
Get http response
[ "Get", "http", "response" ]
45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe
https://github.com/aliyun/fc-java-sdk/blob/45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe/src/main/java/com/aliyuncs/fc/http/HttpResponse.java#L116-L149
164,697
aliyun/fc-java-sdk
src/main/java/com/aliyuncs/fc/config/Config.java
Config.refreshCredentials
public void refreshCredentials() { if (this.credsProvider == null) return; try { AlibabaCloudCredentials creds = this.credsProvider.getCredentials(); this.accessKeyID = creds.getAccessKeyId(); this.accessKeySecret = creds.getAccessKeySecret(); if (creds instanceof BasicSessionCredentials) { this.securityToken = ((BasicSessionCredentials) creds).getSessionToken(); } } catch (Exception e) { e.printStackTrace(); } }
java
public void refreshCredentials() { if (this.credsProvider == null) return; try { AlibabaCloudCredentials creds = this.credsProvider.getCredentials(); this.accessKeyID = creds.getAccessKeyId(); this.accessKeySecret = creds.getAccessKeySecret(); if (creds instanceof BasicSessionCredentials) { this.securityToken = ((BasicSessionCredentials) creds).getSessionToken(); } } catch (Exception e) { e.printStackTrace(); } }
[ "public", "void", "refreshCredentials", "(", ")", "{", "if", "(", "this", ".", "credsProvider", "==", "null", ")", "return", ";", "try", "{", "AlibabaCloudCredentials", "creds", "=", "this", ".", "credsProvider", ".", "getCredentials", "(", ")", ";", "this", ".", "accessKeyID", "=", "creds", ".", "getAccessKeyId", "(", ")", ";", "this", ".", "accessKeySecret", "=", "creds", ".", "getAccessKeySecret", "(", ")", ";", "if", "(", "creds", "instanceof", "BasicSessionCredentials", ")", "{", "this", ".", "securityToken", "=", "(", "(", "BasicSessionCredentials", ")", "creds", ")", ".", "getSessionToken", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
refresh credentials if CredentialProvider set
[ "refresh", "credentials", "if", "CredentialProvider", "set" ]
45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe
https://github.com/aliyun/fc-java-sdk/blob/45ee0cbff93d4ea7eaa87fc08fd18ac176df2dfe/src/main/java/com/aliyuncs/fc/config/Config.java#L218-L234
164,698
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java
History.addExtraInfo
public void addExtraInfo(String key, Object value) { // Turn extraInfo into map Map<String, Object> infoMap = (HashMap<String, Object>)getMapFromJSON(extraInfo); // Add value infoMap.put(key, value); // Turn back into string extraInfo = getJSONFromMap(infoMap); }
java
public void addExtraInfo(String key, Object value) { // Turn extraInfo into map Map<String, Object> infoMap = (HashMap<String, Object>)getMapFromJSON(extraInfo); // Add value infoMap.put(key, value); // Turn back into string extraInfo = getJSONFromMap(infoMap); }
[ "public", "void", "addExtraInfo", "(", "String", "key", ",", "Object", "value", ")", "{", "// Turn extraInfo into map", "Map", "<", "String", ",", "Object", ">", "infoMap", "=", "(", "HashMap", "<", "String", ",", "Object", ">", ")", "getMapFromJSON", "(", "extraInfo", ")", ";", "// Add value", "infoMap", ".", "put", "(", "key", ",", "value", ")", ";", "// Turn back into string", "extraInfo", "=", "getJSONFromMap", "(", "infoMap", ")", ";", "}" ]
Add key value pair to extra info @param key Key of new item @param value New value to add
[ "Add", "key", "value", "pair", "to", "extra", "info" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java#L409-L417
164,699
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java
History.getMapFromJSON
private Map<String, Object> getMapFromJSON(String json) { Map<String, Object> propMap = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); // Initialize string if empty if (json == null || json.length() == 0) { json = "{}"; } try { // Convert string propMap = mapper.readValue(json, new TypeReference<HashMap<String, Object>>(){}); } catch (Exception e) { ; } return propMap; }
java
private Map<String, Object> getMapFromJSON(String json) { Map<String, Object> propMap = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); // Initialize string if empty if (json == null || json.length() == 0) { json = "{}"; } try { // Convert string propMap = mapper.readValue(json, new TypeReference<HashMap<String, Object>>(){}); } catch (Exception e) { ; } return propMap; }
[ "private", "Map", "<", "String", ",", "Object", ">", "getMapFromJSON", "(", "String", "json", ")", "{", "Map", "<", "String", ",", "Object", ">", "propMap", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "ObjectMapper", "mapper", "=", "new", "ObjectMapper", "(", ")", ";", "// Initialize string if empty", "if", "(", "json", "==", "null", "||", "json", ".", "length", "(", ")", "==", "0", ")", "{", "json", "=", "\"{}\"", ";", "}", "try", "{", "// Convert string", "propMap", "=", "mapper", ".", "readValue", "(", "json", ",", "new", "TypeReference", "<", "HashMap", "<", "String", ",", "Object", ">", ">", "(", ")", "{", "}", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", ";", "}", "return", "propMap", ";", "}" ]
Turn json string into map @param json @return
[ "Turn", "json", "string", "into", "map" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java#L442-L458