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
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
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", ".", "g...
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", "t...
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/release/scm/git/GitCoordinator.java#L66-L83
train
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", ",", "Strin...
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
train
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", ...
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
train
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", ">", "...
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...
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L87-L97
train
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", ...
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...
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L107-L125
train
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", "=...
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", "a...
f5fcfff6a5a50be5374813e49d1fe3aaf6422333
https://github.com/jenkinsci/artifactory-plugin/blob/f5fcfff6a5a50be5374813e49d1fe3aaf6422333/src/main/java/org/jfrog/hudson/pipeline/common/docker/utils/DockerAgentUtils.java#L136-L162
train
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", ")", ...
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
train
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", ",", "InterruptedEx...
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
train
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", ...
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
train
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", "(", ")",...
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
train
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", "(", ")",...
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
train
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", "=", "ne...
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
train
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", "(", "...
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
train
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", ")", "{", ...
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
train
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...
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
train
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", "(", "L...
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
train
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", "=", "fromVersio...
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
train
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_STAG...
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
train
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", "(", ")", ...
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
train
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", "["...
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
train
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 ...
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
train
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", "++", ")", "{", ...
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
train
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", "....
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
train
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", "=", ...
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
train
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", "(", ")", "...
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
train
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
train
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-...
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
train
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", ...
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
train
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", ")",...
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
train
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", "(", ...
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
train
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", "++", ")", "{...
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
train
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", ...
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
train
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"...
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
train
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", "]", "^=", "(", ...
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
train
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", "/", "WO...
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
train
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", ...
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", "t...
b7ba13aea70625bb7f37c856783a29e17e354964
https://github.com/dwdyer/uncommons-maths/blob/b7ba13aea70625bb7f37c856783a29e17e354964/core/src/java/main/org/uncommons/maths/number/Rational.java#L329-L341
train
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", "Buffe...
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
train
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", ...
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
train
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
train
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",...
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
train
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", "=", ...
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
train
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", "(", ")", "...
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
train
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
train
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", ...
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
train
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_ENCOD...
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
train
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", "=", ...
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
train
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",...
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
train
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", "(", ...
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
train
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", "mappe...
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
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java
History.getJSONFromMap
private String getJSONFromMap(Map<String, Object> propMap) { try { return new JSONObject(propMap).toString(); } catch (Exception e) { return "{}"; } }
java
private String getJSONFromMap(Map<String, Object> propMap) { try { return new JSONObject(propMap).toString(); } catch (Exception e) { return "{}"; } }
[ "private", "String", "getJSONFromMap", "(", "Map", "<", "String", ",", "Object", ">", "propMap", ")", "{", "try", "{", "return", "new", "JSONObject", "(", "propMap", ")", ".", "toString", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", ...
Turn map into string @param propMap Map to be converted @return
[ "Turn", "map", "into", "string" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/models/History.java#L466-L472
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ConfigurationInterceptor.java
ConfigurationInterceptor.preHandle
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String queryString = request.getQueryString() == null ? "" : request.getQueryString(); if (ConfigurationService.getInstance().isValid() || request.getServletPath().startsWith("/configuration") || request.getServletPath().startsWith("/resources") || queryString.contains("requestFromConfiguration=true")) { return true; } else { response.sendRedirect("configuration"); return false; } }
java
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String queryString = request.getQueryString() == null ? "" : request.getQueryString(); if (ConfigurationService.getInstance().isValid() || request.getServletPath().startsWith("/configuration") || request.getServletPath().startsWith("/resources") || queryString.contains("requestFromConfiguration=true")) { return true; } else { response.sendRedirect("configuration"); return false; } }
[ "public", "boolean", "preHandle", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ",", "Object", "handler", ")", "throws", "Exception", "{", "String", "queryString", "=", "request", ".", "getQueryString", "(", ")", "==", "null", "?", ...
This will check to see if certain configuration values exist from the ConfigurationService If not then it redirects to the configuration screen
[ "This", "will", "check", "to", "see", "if", "certain", "configuration", "values", "exist", "from", "the", "ConfigurationService", "If", "not", "then", "it", "redirects", "to", "the", "configuration", "screen" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ConfigurationInterceptor.java#L38-L52
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java
ServerMappingController.addRedirectToProfile
@RequestMapping(value = "api/edit/server", method = RequestMethod.POST) public @ResponseBody ServerRedirect addRedirectToProfile(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier, @RequestParam(value = "srcUrl", required = true) String srcUrl, @RequestParam(value = "destUrl", required = true) String destUrl, @RequestParam(value = "clientUUID", required = true) String clientUUID, @RequestParam(value = "hostHeader", required = false) String hostHeader) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId(); int redirectId = ServerRedirectService.getInstance().addServerRedirectToProfile("", srcUrl, destUrl, hostHeader, profileId, clientId); return ServerRedirectService.getInstance().getRedirect(redirectId); }
java
@RequestMapping(value = "api/edit/server", method = RequestMethod.POST) public @ResponseBody ServerRedirect addRedirectToProfile(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier, @RequestParam(value = "srcUrl", required = true) String srcUrl, @RequestParam(value = "destUrl", required = true) String destUrl, @RequestParam(value = "clientUUID", required = true) String clientUUID, @RequestParam(value = "hostHeader", required = false) String hostHeader) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId(); int redirectId = ServerRedirectService.getInstance().addServerRedirectToProfile("", srcUrl, destUrl, hostHeader, profileId, clientId); return ServerRedirectService.getInstance().getRedirect(redirectId); }
[ "@", "RequestMapping", "(", "value", "=", "\"api/edit/server\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "ServerRedirect", "addRedirectToProfile", "(", "Model", "model", ",", "@", "RequestParam", "(", "value", "=", "...
Adds a redirect URL to the specified profile ID @param model @param profileId @param srcUrl @param destUrl @param hostHeader @return @throws Exception
[ "Adds", "a", "redirect", "URL", "to", "the", "specified", "profile", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java#L66-L88
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java
ServerMappingController.getjqRedirects
@RequestMapping(value = "api/edit/server", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getjqRedirects(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "clientUUID", required = true) String clientUUID, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId(); HashMap<String, Object> returnJson = Utils.getJQGridJSON(ServerRedirectService.getInstance().tableServers(clientId), "servers"); returnJson.put("hostEditor", Client.isAvailable()); return returnJson; }
java
@RequestMapping(value = "api/edit/server", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getjqRedirects(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "clientUUID", required = true) String clientUUID, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int clientId = ClientService.getInstance().findClient(clientUUID, profileId).getId(); HashMap<String, Object> returnJson = Utils.getJQGridJSON(ServerRedirectService.getInstance().tableServers(clientId), "servers"); returnJson.put("hostEditor", Client.isAvailable()); return returnJson; }
[ "@", "RequestMapping", "(", "value", "=", "\"api/edit/server\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getjqRedirects", "(", "Model", "model", ",", "@", "RequestParam...
Redirect URL to the specified profile ID @param model @param profileId @return @throws Exception
[ "Redirect", "URL", "to", "the", "specified", "profile", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java#L98-L116
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java
ServerMappingController.getServerGroups
@RequestMapping(value = "api/servergroup", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getServerGroups(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "search", required = false) String search, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } List<ServerGroup> serverGroups = ServerRedirectService.getInstance().tableServerGroups(profileId); if (search != null) { Iterator<ServerGroup> iterator = serverGroups.iterator(); while (iterator.hasNext()) { ServerGroup serverGroup = iterator.next(); if (!serverGroup.getName().toLowerCase().contains(search.toLowerCase())) { iterator.remove(); } } } HashMap<String, Object> returnJson = Utils.getJQGridJSON(serverGroups, "servergroups"); return returnJson; }
java
@RequestMapping(value = "api/servergroup", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getServerGroups(Model model, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "search", required = false) String search, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } List<ServerGroup> serverGroups = ServerRedirectService.getInstance().tableServerGroups(profileId); if (search != null) { Iterator<ServerGroup> iterator = serverGroups.iterator(); while (iterator.hasNext()) { ServerGroup serverGroup = iterator.next(); if (!serverGroup.getName().toLowerCase().contains(search.toLowerCase())) { iterator.remove(); } } } HashMap<String, Object> returnJson = Utils.getJQGridJSON(serverGroups, "servergroups"); return returnJson; }
[ "@", "RequestMapping", "(", "value", "=", "\"api/servergroup\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getServerGroups", "(", "Model", "model", ",", "@", "RequestPara...
Obtains the collection of server groups defined for a profile @param model @param profileId @return @throws Exception
[ "Obtains", "the", "collection", "of", "server", "groups", "defined", "for", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java#L126-L153
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java
ServerMappingController.createServerGroup
@RequestMapping(value = "api/servergroup", method = RequestMethod.POST) public @ResponseBody ServerGroup createServerGroup(Model model, @RequestParam(value = "name") String name, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int groupId = ServerRedirectService.getInstance().addServerGroup(name, profileId); return ServerRedirectService.getInstance().getServerGroup(groupId, profileId); }
java
@RequestMapping(value = "api/servergroup", method = RequestMethod.POST) public @ResponseBody ServerGroup createServerGroup(Model model, @RequestParam(value = "name") String name, @RequestParam(value = "profileId", required = false) Integer profileId, @RequestParam(value = "profileIdentifier", required = false) String profileIdentifier) throws Exception { if (profileId == null && profileIdentifier == null) { throw new Exception("profileId required"); } if (profileId == null) { profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } int groupId = ServerRedirectService.getInstance().addServerGroup(name, profileId); return ServerRedirectService.getInstance().getServerGroup(groupId, profileId); }
[ "@", "RequestMapping", "(", "value", "=", "\"api/servergroup\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "ServerGroup", "createServerGroup", "(", "Model", "model", ",", "@", "RequestParam", "(", "value", "=", "\"name...
Create a new server group for a profile @param model @param profileId @return @throws Exception
[ "Create", "a", "new", "server", "group", "for", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java#L188-L203
train
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java
ServerMappingController.certPage
@RequestMapping(value = "/cert", method = {RequestMethod.GET, RequestMethod.HEAD}) public String certPage() throws Exception { return "cert"; }
java
@RequestMapping(value = "/cert", method = {RequestMethod.GET, RequestMethod.HEAD}) public String certPage() throws Exception { return "cert"; }
[ "@", "RequestMapping", "(", "value", "=", "\"/cert\"", ",", "method", "=", "{", "RequestMethod", ".", "GET", ",", "RequestMethod", ".", "HEAD", "}", ")", "public", "String", "certPage", "(", ")", "throws", "Exception", "{", "return", "\"cert\"", ";", "}" ]
Returns a simple web page where certs can be downloaded. This is meant for mobile device setup. @return @throws Exception
[ "Returns", "a", "simple", "web", "page", "where", "certs", "can", "be", "downloaded", ".", "This", "is", "meant", "for", "mobile", "device", "setup", "." ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ServerMappingController.java#L385-L388
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.mapUrlEncodedParameters
public static Map<String, String[]> mapUrlEncodedParameters(byte[] dataArray) throws Exception { Map<String, String[]> mapPostParameters = new HashMap<String, String[]>(); try { ByteArrayOutputStream byteout = new ByteArrayOutputStream(); for (int x = 0; x < dataArray.length; x++) { // split the data up by & to get the parts if (dataArray[x] == '&' || x == (dataArray.length - 1)) { if (x == (dataArray.length - 1)) { byteout.write(dataArray[x]); } // find '=' and split the data up into key value pairs int equalsPos = -1; ByteArrayOutputStream key = new ByteArrayOutputStream(); ByteArrayOutputStream value = new ByteArrayOutputStream(); byte[] byteArray = byteout.toByteArray(); for (int xx = 0; xx < byteArray.length; xx++) { if (byteArray[xx] == '=') { equalsPos = xx; } else { if (equalsPos == -1) { key.write(byteArray[xx]); } else { value.write(byteArray[xx]); } } } ArrayList<String> values = new ArrayList<String>(); if (mapPostParameters.containsKey(key.toString())) { values = new ArrayList<String>(Arrays.asList(mapPostParameters.get(key.toString()))); mapPostParameters.remove(key.toString()); } values.add(value.toString()); /** * If equalsPos is not -1, then there was a '=' for the key * If value.size is 0, then there is no value so want to add in the '=' * Since it will not be added later like params with keys and valued */ if (equalsPos != -1 && value.size() == 0) { key.write((byte) '='); } mapPostParameters.put(key.toString(), values.toArray(new String[values.size()])); byteout = new ByteArrayOutputStream(); } else { byteout.write(dataArray[x]); } } } catch (Exception e) { throw new Exception("Could not parse request data: " + e.getMessage()); } return mapPostParameters; }
java
public static Map<String, String[]> mapUrlEncodedParameters(byte[] dataArray) throws Exception { Map<String, String[]> mapPostParameters = new HashMap<String, String[]>(); try { ByteArrayOutputStream byteout = new ByteArrayOutputStream(); for (int x = 0; x < dataArray.length; x++) { // split the data up by & to get the parts if (dataArray[x] == '&' || x == (dataArray.length - 1)) { if (x == (dataArray.length - 1)) { byteout.write(dataArray[x]); } // find '=' and split the data up into key value pairs int equalsPos = -1; ByteArrayOutputStream key = new ByteArrayOutputStream(); ByteArrayOutputStream value = new ByteArrayOutputStream(); byte[] byteArray = byteout.toByteArray(); for (int xx = 0; xx < byteArray.length; xx++) { if (byteArray[xx] == '=') { equalsPos = xx; } else { if (equalsPos == -1) { key.write(byteArray[xx]); } else { value.write(byteArray[xx]); } } } ArrayList<String> values = new ArrayList<String>(); if (mapPostParameters.containsKey(key.toString())) { values = new ArrayList<String>(Arrays.asList(mapPostParameters.get(key.toString()))); mapPostParameters.remove(key.toString()); } values.add(value.toString()); /** * If equalsPos is not -1, then there was a '=' for the key * If value.size is 0, then there is no value so want to add in the '=' * Since it will not be added later like params with keys and valued */ if (equalsPos != -1 && value.size() == 0) { key.write((byte) '='); } mapPostParameters.put(key.toString(), values.toArray(new String[values.size()])); byteout = new ByteArrayOutputStream(); } else { byteout.write(dataArray[x]); } } } catch (Exception e) { throw new Exception("Could not parse request data: " + e.getMessage()); } return mapPostParameters; }
[ "public", "static", "Map", "<", "String", ",", "String", "[", "]", ">", "mapUrlEncodedParameters", "(", "byte", "[", "]", "dataArray", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", "[", "]", ">", "mapPostParameters", "=", "new", "...
Obtain collection of Parameters from request @param dataArray request parameters @return Map of parameters @throws Exception exception
[ "Obtain", "collection", "of", "Parameters", "from", "request" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L151-L208
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.getURL
public static String getURL(String sourceURI) { String retval = sourceURI; int qPos = sourceURI.indexOf("?"); if (qPos != -1) { retval = retval.substring(0, qPos); } return retval; }
java
public static String getURL(String sourceURI) { String retval = sourceURI; int qPos = sourceURI.indexOf("?"); if (qPos != -1) { retval = retval.substring(0, qPos); } return retval; }
[ "public", "static", "String", "getURL", "(", "String", "sourceURI", ")", "{", "String", "retval", "=", "sourceURI", ";", "int", "qPos", "=", "sourceURI", ".", "indexOf", "(", "\"?\"", ")", ";", "if", "(", "qPos", "!=", "-", "1", ")", "{", "retval", "...
Retrieve URL without parameters @param sourceURI source URI @return URL without parameters
[ "Retrieve", "URL", "without", "parameters" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L227-L235
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.getHeaders
public static String getHeaders(HttpMethod method) { String headerString = ""; Header[] headers = method.getRequestHeaders(); for (Header header : headers) { String name = header.getName(); if (name.equals(Constants.ODO_PROXY_HEADER)) { // skip.. don't want to log this continue; } if (headerString.length() != 0) { headerString += "\n"; } headerString += header.getName() + ": " + header.getValue(); } return headerString; }
java
public static String getHeaders(HttpMethod method) { String headerString = ""; Header[] headers = method.getRequestHeaders(); for (Header header : headers) { String name = header.getName(); if (name.equals(Constants.ODO_PROXY_HEADER)) { // skip.. don't want to log this continue; } if (headerString.length() != 0) { headerString += "\n"; } headerString += header.getName() + ": " + header.getValue(); } return headerString; }
[ "public", "static", "String", "getHeaders", "(", "HttpMethod", "method", ")", "{", "String", "headerString", "=", "\"\"", ";", "Header", "[", "]", "headers", "=", "method", ".", "getRequestHeaders", "(", ")", ";", "for", "(", "Header", "header", ":", "head...
Obtain newline-delimited headers from method @param method HttpMethod to scan @return newline-delimited headers
[ "Obtain", "newline", "-", "delimited", "headers", "from", "method" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L243-L261
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.getHeaders
public static String getHeaders(HttpServletRequest request) { String headerString = ""; Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); if (name.equals(Constants.ODO_PROXY_HEADER)) { // skip.. don't want to log this continue; } if (headerString.length() != 0) { headerString += "\n"; } headerString += name + ": " + request.getHeader(name); } return headerString; }
java
public static String getHeaders(HttpServletRequest request) { String headerString = ""; Enumeration<String> headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String name = headerNames.nextElement(); if (name.equals(Constants.ODO_PROXY_HEADER)) { // skip.. don't want to log this continue; } if (headerString.length() != 0) { headerString += "\n"; } headerString += name + ": " + request.getHeader(name); } return headerString; }
[ "public", "static", "String", "getHeaders", "(", "HttpServletRequest", "request", ")", "{", "String", "headerString", "=", "\"\"", ";", "Enumeration", "<", "String", ">", "headerNames", "=", "request", ".", "getHeaderNames", "(", ")", ";", "while", "(", "heade...
Obtain newline-delimited headers from request @param request HttpServletRequest to scan @return newline-delimited headers
[ "Obtain", "newline", "-", "delimited", "headers", "from", "request" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L269-L288
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.getHeaders
public static String getHeaders(HttpServletResponse response) { String headerString = ""; Collection<String> headerNames = response.getHeaderNames(); for (String headerName : headerNames) { // there may be multiple headers per header name for (String headerValue : response.getHeaders(headerName)) { if (headerString.length() != 0) { headerString += "\n"; } headerString += headerName + ": " + headerValue; } } return headerString; }
java
public static String getHeaders(HttpServletResponse response) { String headerString = ""; Collection<String> headerNames = response.getHeaderNames(); for (String headerName : headerNames) { // there may be multiple headers per header name for (String headerValue : response.getHeaders(headerName)) { if (headerString.length() != 0) { headerString += "\n"; } headerString += headerName + ": " + headerValue; } } return headerString; }
[ "public", "static", "String", "getHeaders", "(", "HttpServletResponse", "response", ")", "{", "String", "headerString", "=", "\"\"", ";", "Collection", "<", "String", ">", "headerNames", "=", "response", ".", "getHeaderNames", "(", ")", ";", "for", "(", "Strin...
Obtain newline-delimited headers from response @param response HttpServletResponse to scan @return newline-delimited headers
[ "Obtain", "newline", "-", "delimited", "headers", "from", "response" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L296-L311
train
groupon/odo
proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java
HttpUtilities.getParameters
public static HashMap<String, String> getParameters(String query) { HashMap<String, String> params = new HashMap<String, String>(); if (query == null || query.length() == 0) { return params; } String[] splitQuery = query.split("&"); for (String splitItem : splitQuery) { String[] items = splitItem.split("="); if (items.length == 1) { params.put(items[0], ""); } else { params.put(items[0], items[1]); } } return params; }
java
public static HashMap<String, String> getParameters(String query) { HashMap<String, String> params = new HashMap<String, String>(); if (query == null || query.length() == 0) { return params; } String[] splitQuery = query.split("&"); for (String splitItem : splitQuery) { String[] items = splitItem.split("="); if (items.length == 1) { params.put(items[0], ""); } else { params.put(items[0], items[1]); } } return params; }
[ "public", "static", "HashMap", "<", "String", ",", "String", ">", "getParameters", "(", "String", "query", ")", "{", "HashMap", "<", "String", ",", "String", ">", "params", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", ...
Obtain parameters from query @param query query to scan @return Map of parameters
[ "Obtain", "parameters", "from", "query" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyserver/src/main/java/com/groupon/odo/HttpUtilities.java#L319-L337
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.getMethodsFromGroupIds
public List<Method> getMethodsFromGroupIds(int[] groupIds, String[] filters) throws Exception { ArrayList<Method> methods = new ArrayList<Method>(); for (int groupId : groupIds) { methods.addAll(getMethodsFromGroupId(groupId, filters)); } return methods; }
java
public List<Method> getMethodsFromGroupIds(int[] groupIds, String[] filters) throws Exception { ArrayList<Method> methods = new ArrayList<Method>(); for (int groupId : groupIds) { methods.addAll(getMethodsFromGroupId(groupId, filters)); } return methods; }
[ "public", "List", "<", "Method", ">", "getMethodsFromGroupIds", "(", "int", "[", "]", "groupIds", ",", "String", "[", "]", "filters", ")", "throws", "Exception", "{", "ArrayList", "<", "Method", ">", "methods", "=", "new", "ArrayList", "<", "Method", ">", ...
Return all methods for a list of groupIds @param groupIds array of group IDs @param filters array of filters to apply to method selection @return collection of Methods found @throws Exception exception
[ "Return", "all", "methods", "for", "a", "list", "of", "groupIds" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L60-L68
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.updateRepeatNumber
public void updateRepeatNumber(int newNum, int path_id, String client_uuid) throws Exception { updateRequestResponseTables("repeat_number", newNum, getProfileIdFromPathID(path_id), client_uuid, path_id); }
java
public void updateRepeatNumber(int newNum, int path_id, String client_uuid) throws Exception { updateRequestResponseTables("repeat_number", newNum, getProfileIdFromPathID(path_id), client_uuid, path_id); }
[ "public", "void", "updateRepeatNumber", "(", "int", "newNum", ",", "int", "path_id", ",", "String", "client_uuid", ")", "throws", "Exception", "{", "updateRequestResponseTables", "(", "\"repeat_number\"", ",", "newNum", ",", "getProfileIdFromPathID", "(", "path_id", ...
Update the repeat number for a client path @param newNum new repeat number of the path @param path_id ID of the path @param client_uuid UUID of the client @throws Exception exception
[ "Update", "the", "repeat", "number", "for", "a", "client", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L110-L112
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.disableAll
public void disableAll(int profileId, String client_uuid) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.CLIENT_PROFILE_ID + " = ?" + " AND " + Constants.CLIENT_CLIENT_UUID + " =? " ); statement.setInt(1, profileId); statement.setString(2, client_uuid); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void disableAll(int profileId, String client_uuid) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.CLIENT_PROFILE_ID + " = ?" + " AND " + Constants.CLIENT_CLIENT_UUID + " =? " ); statement.setInt(1, profileId); statement.setString(2, client_uuid); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "disableAll", "(", "int", "profileId", ",", "String", "client_uuid", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statem...
Delete all enabled overrides for a client @param profileId profile ID of teh client @param client_uuid UUID of teh client
[ "Delete", "all", "enabled", "overrides", "for", "a", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L120-L142
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.removePathnameFromProfile
public void removePathnameFromProfile(int path_id, int profileId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ?" ); statement.setInt(1, path_id); statement.executeUpdate(); statement.close(); statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, path_id); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void removePathnameFromProfile(int path_id, int profileId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ?" ); statement.setInt(1, path_id); statement.executeUpdate(); statement.close(); statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, path_id); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "removePathnameFromProfile", "(", "int", "path_id", ",", "int", "profileId", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", ...
Remove a path from a profile @param path_id path ID to remove @param profileId profile ID to remove path from
[ "Remove", "a", "path", "from", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L150-L177
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.getMethodsFromGroupId
public List<Method> getMethodsFromGroupId(int groupId, String[] filters) throws Exception { ArrayList<Method> methods = new ArrayList<Method>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.OVERRIDE_GROUP_ID + " = ?" ); statement.setInt(1, groupId); results = statement.executeQuery(); while (results.next()) { Method method = PathOverrideService.getInstance().getMethodForOverrideId(results.getInt("id")); if (method == null) { continue; } // decide whether or not to add this method based on the filters boolean add = true; if (filters != null) { add = false; for (String filter : filters) { if (method.getMethodType().endsWith(filter)) { add = true; break; } } } if (add && !methods.contains(method)) { methods.add(method); } } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return methods; }
java
public List<Method> getMethodsFromGroupId(int groupId, String[] filters) throws Exception { ArrayList<Method> methods = new ArrayList<Method>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.OVERRIDE_GROUP_ID + " = ?" ); statement.setInt(1, groupId); results = statement.executeQuery(); while (results.next()) { Method method = PathOverrideService.getInstance().getMethodForOverrideId(results.getInt("id")); if (method == null) { continue; } // decide whether or not to add this method based on the filters boolean add = true; if (filters != null) { add = false; for (String filter : filters) { if (method.getMethodType().endsWith(filter)) { add = true; break; } } } if (add && !methods.contains(method)) { methods.add(method); } } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return methods; }
[ "public", "List", "<", "Method", ">", "getMethodsFromGroupId", "(", "int", "groupId", ",", "String", "[", "]", "filters", ")", "throws", "Exception", "{", "ArrayList", "<", "Method", ">", "methods", "=", "new", "ArrayList", "<", "Method", ">", "(", ")", ...
Returns all methods for a specific group @param groupId group ID to remove methods from @param filters array of method types to filter by, null means no filter @return Collection of methods found @throws Exception exception
[ "Returns", "all", "methods", "for", "a", "specific", "group" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L187-L239
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.enableCustomResponse
public void enableCustomResponse(String custom, int path_id, String client_uuid) throws Exception { updateRequestResponseTables("custom_response", custom, getProfileIdFromPathID(path_id), client_uuid, path_id); }
java
public void enableCustomResponse(String custom, int path_id, String client_uuid) throws Exception { updateRequestResponseTables("custom_response", custom, getProfileIdFromPathID(path_id), client_uuid, path_id); }
[ "public", "void", "enableCustomResponse", "(", "String", "custom", ",", "int", "path_id", ",", "String", "client_uuid", ")", "throws", "Exception", "{", "updateRequestResponseTables", "(", "\"custom_response\"", ",", "custom", ",", "getProfileIdFromPathID", "(", "path...
Enable a custom response @param custom custom response @param path_id path ID of the response @param client_uuid client UUID @throws Exception exception
[ "Enable", "a", "custom", "response" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L249-L252
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.updatePathTable
public static void updatePathTable(String columnName, Object newData, int path_id) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + columnName + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setObject(1, newData); statement.setInt(2, path_id); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public static void updatePathTable(String columnName, Object newData, int path_id) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + columnName + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setObject(1, newData); statement.setInt(2, path_id); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "static", "void", "updatePathTable", "(", "String", "columnName", ",", "Object", "newData", ",", "int", "path_id", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConn...
Updates a path table value for column columnName @param columnName name of the column to update @param newData new content to set @param path_id ID of the path to update
[ "Updates", "a", "path", "table", "value", "for", "column", "columnName" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L289-L311
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.removeCustomOverride
public void removeCustomOverride(int path_id, String client_uuid) throws Exception { updateRequestResponseTables("custom_response", "", getProfileIdFromPathID(path_id), client_uuid, path_id); }
java
public void removeCustomOverride(int path_id, String client_uuid) throws Exception { updateRequestResponseTables("custom_response", "", getProfileIdFromPathID(path_id), client_uuid, path_id); }
[ "public", "void", "removeCustomOverride", "(", "int", "path_id", ",", "String", "client_uuid", ")", "throws", "Exception", "{", "updateRequestResponseTables", "(", "\"custom_response\"", ",", "\"\"", ",", "getProfileIdFromPathID", "(", "path_id", ")", ",", "client_uui...
Remove custom overrides @param path_id ID of path containing custom override @param client_uuid UUID of the client @throws Exception exception
[ "Remove", "custom", "overrides" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L320-L322
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java
EditService.getProfileIdFromPathID
public static int getProfileIdFromPathID(int path_id) throws Exception { return (Integer) SQLService.getInstance().getFromTable(Constants.GENERIC_PROFILE_ID, Constants.GENERIC_ID, path_id, Constants.DB_TABLE_PATH); }
java
public static int getProfileIdFromPathID(int path_id) throws Exception { return (Integer) SQLService.getInstance().getFromTable(Constants.GENERIC_PROFILE_ID, Constants.GENERIC_ID, path_id, Constants.DB_TABLE_PATH); }
[ "public", "static", "int", "getProfileIdFromPathID", "(", "int", "path_id", ")", "throws", "Exception", "{", "return", "(", "Integer", ")", "SQLService", ".", "getInstance", "(", ")", ".", "getFromTable", "(", "Constants", ".", "GENERIC_PROFILE_ID", ",", "Consta...
Return the profileId for a path @param path_id ID of path @return ID of profile @throws Exception exception
[ "Return", "the", "profileId", "for", "a", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/EditService.java#L331-L333
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.findAllGroups
public List<Group> findAllGroups() { ArrayList<Group> allGroups = new ArrayList<Group>(); PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_GROUPS + " ORDER BY " + Constants.GROUPS_GROUP_NAME); results = queryStatement.executeQuery(); while (results.next()) { Group group = new Group(); group.setId(results.getInt(Constants.GENERIC_ID)); group.setName(results.getString(Constants.GROUPS_GROUP_NAME)); allGroups.add(group); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return allGroups; }
java
public List<Group> findAllGroups() { ArrayList<Group> allGroups = new ArrayList<Group>(); PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_GROUPS + " ORDER BY " + Constants.GROUPS_GROUP_NAME); results = queryStatement.executeQuery(); while (results.next()) { Group group = new Group(); group.setId(results.getInt(Constants.GENERIC_ID)); group.setName(results.getString(Constants.GROUPS_GROUP_NAME)); allGroups.add(group); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return allGroups; }
[ "public", "List", "<", "Group", ">", "findAllGroups", "(", ")", "{", "ArrayList", "<", "Group", ">", "allGroups", "=", "new", "ArrayList", "<", "Group", ">", "(", ")", ";", "PreparedStatement", "queryStatement", "=", "null", ";", "ResultSet", "results", "=...
Obtain all groups @return All Groups
[ "Obtain", "all", "groups" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L70-L103
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.addPathnameToProfile
public int addPathnameToProfile(int id, String pathname, String actualPath) throws Exception { int pathOrder = getPathOrder(id).size() + 1; int pathId = -1; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_PATH + "(" + Constants.PATH_PROFILE_PATHNAME + "," + Constants.PATH_PROFILE_ACTUAL_PATH + "," + Constants.PATH_PROFILE_GROUP_IDS + "," + Constants.PATH_PROFILE_PROFILE_ID + "," + Constants.PATH_PROFILE_PATH_ORDER + "," + Constants.PATH_PROFILE_CONTENT_TYPE + "," + Constants.PATH_PROFILE_REQUEST_TYPE + "," + Constants.PATH_PROFILE_GLOBAL + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?);", PreparedStatement.RETURN_GENERATED_KEYS ); statement.setString(1, pathname); statement.setString(2, actualPath); statement.setString(3, ""); statement.setInt(4, id); statement.setInt(5, pathOrder); statement.setString(6, Constants.PATH_PROFILE_DEFAULT_CONTENT_TYPE); // should be set by UI/API statement.setInt(7, Constants.REQUEST_TYPE_GET); // should be set by UI/API statement.setBoolean(8, false); statement.executeUpdate(); // execute statement and get resultSet which will have the generated path ID as the first field results = statement.getGeneratedKeys(); if (results.next()) { pathId = results.getInt(1); } else { // something went wrong throw new Exception("Could not add path"); } } catch (SQLException e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } // need to add to request response table for all clients for (Client client : ClientService.getInstance().findAllClients(id)) { this.addPathToRequestResponseTable(id, client.getUUID(), pathId); } return pathId; }
java
public int addPathnameToProfile(int id, String pathname, String actualPath) throws Exception { int pathOrder = getPathOrder(id).size() + 1; int pathId = -1; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_PATH + "(" + Constants.PATH_PROFILE_PATHNAME + "," + Constants.PATH_PROFILE_ACTUAL_PATH + "," + Constants.PATH_PROFILE_GROUP_IDS + "," + Constants.PATH_PROFILE_PROFILE_ID + "," + Constants.PATH_PROFILE_PATH_ORDER + "," + Constants.PATH_PROFILE_CONTENT_TYPE + "," + Constants.PATH_PROFILE_REQUEST_TYPE + "," + Constants.PATH_PROFILE_GLOBAL + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?);", PreparedStatement.RETURN_GENERATED_KEYS ); statement.setString(1, pathname); statement.setString(2, actualPath); statement.setString(3, ""); statement.setInt(4, id); statement.setInt(5, pathOrder); statement.setString(6, Constants.PATH_PROFILE_DEFAULT_CONTENT_TYPE); // should be set by UI/API statement.setInt(7, Constants.REQUEST_TYPE_GET); // should be set by UI/API statement.setBoolean(8, false); statement.executeUpdate(); // execute statement and get resultSet which will have the generated path ID as the first field results = statement.getGeneratedKeys(); if (results.next()) { pathId = results.getInt(1); } else { // something went wrong throw new Exception("Could not add path"); } } catch (SQLException e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } // need to add to request response table for all clients for (Client client : ClientService.getInstance().findAllClients(id)) { this.addPathToRequestResponseTable(id, client.getUUID(), pathId); } return pathId; }
[ "public", "int", "addPathnameToProfile", "(", "int", "id", ",", "String", "pathname", ",", "String", "actualPath", ")", "throws", "Exception", "{", "int", "pathOrder", "=", "getPathOrder", "(", "id", ")", ".", "size", "(", ")", "+", "1", ";", "int", "pat...
Add a path to a profile, returns the id @param id ID of profile @param pathname name of path @param actualPath value of path @return ID of path created @throws Exception exception
[ "Add", "a", "path", "to", "a", "profile", "returns", "the", "id" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L114-L176
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.addPathToRequestResponseTable
public void addPathToRequestResponseTable(int profileId, String clientUUID, int pathId) throws Exception { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection .prepareStatement("INSERT INTO " + Constants.DB_TABLE_REQUEST_RESPONSE + "(" + Constants.REQUEST_RESPONSE_PATH_ID + "," + Constants.GENERIC_PROFILE_ID + "," + Constants.GENERIC_CLIENT_UUID + "," + Constants.REQUEST_RESPONSE_REPEAT_NUMBER + "," + Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + "," + Constants.REQUEST_RESPONSE_REQUEST_ENABLED + "," + Constants.REQUEST_RESPONSE_CUSTOM_RESPONSE + "," + Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); statement.setInt(1, pathId); statement.setInt(2, profileId); statement.setString(3, clientUUID); statement.setInt(4, -1); statement.setInt(5, 0); statement.setInt(6, 0); statement.setString(7, ""); statement.setString(8, ""); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void addPathToRequestResponseTable(int profileId, String clientUUID, int pathId) throws Exception { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection .prepareStatement("INSERT INTO " + Constants.DB_TABLE_REQUEST_RESPONSE + "(" + Constants.REQUEST_RESPONSE_PATH_ID + "," + Constants.GENERIC_PROFILE_ID + "," + Constants.GENERIC_CLIENT_UUID + "," + Constants.REQUEST_RESPONSE_REPEAT_NUMBER + "," + Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + "," + Constants.REQUEST_RESPONSE_REQUEST_ENABLED + "," + Constants.REQUEST_RESPONSE_CUSTOM_RESPONSE + "," + Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + ")" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?);"); statement.setInt(1, pathId); statement.setInt(2, profileId); statement.setString(3, clientUUID); statement.setInt(4, -1); statement.setInt(5, 0); statement.setInt(6, 0); statement.setString(7, ""); statement.setString(8, ""); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "addPathToRequestResponseTable", "(", "int", "profileId", ",", "String", "clientUUID", ",", "int", "pathId", ")", "throws", "Exception", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sql...
Adds a path to the request response table with the specified values @param profileId ID of profile @param clientUUID UUID of client @param pathId ID of path @throws Exception exception
[ "Adds", "a", "path", "to", "the", "request", "response", "table", "with", "the", "specified", "values" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L186-L219
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getPathOrder
public List<Integer> getPathOrder(int profileId) { ArrayList<Integer> pathOrder = new ArrayList<Integer>(); PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ? " + " ORDER BY " + Constants.PATH_PROFILE_PATH_ORDER + " ASC" ); queryStatement.setInt(1, profileId); results = queryStatement.executeQuery(); while (results.next()) { pathOrder.add(results.getInt(Constants.GENERIC_ID)); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } logger.info("pathOrder = {}", pathOrder); return pathOrder; }
java
public List<Integer> getPathOrder(int profileId) { ArrayList<Integer> pathOrder = new ArrayList<Integer>(); PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ? " + " ORDER BY " + Constants.PATH_PROFILE_PATH_ORDER + " ASC" ); queryStatement.setInt(1, profileId); results = queryStatement.executeQuery(); while (results.next()) { pathOrder.add(results.getInt(Constants.GENERIC_ID)); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } logger.info("pathOrder = {}", pathOrder); return pathOrder; }
[ "public", "List", "<", "Integer", ">", "getPathOrder", "(", "int", "profileId", ")", "{", "ArrayList", "<", "Integer", ">", "pathOrder", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "PreparedStatement", "queryStatement", "=", "null", ";", "...
Return collection of path Ids in priority order @param profileId ID of profile @return collection of path Ids in priority order
[ "Return", "collection", "of", "path", "Ids", "in", "priority", "order" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L227-L262
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setGroupsForPath
public void setGroupsForPath(Integer[] groups, int pathId) { String newGroups = Arrays.toString(groups); newGroups = newGroups.substring(1, newGroups.length() - 1).replaceAll("\\s", ""); logger.info("adding groups={}, to pathId={}", newGroups, pathId); EditService.updatePathTable(Constants.PATH_PROFILE_GROUP_IDS, newGroups, pathId); }
java
public void setGroupsForPath(Integer[] groups, int pathId) { String newGroups = Arrays.toString(groups); newGroups = newGroups.substring(1, newGroups.length() - 1).replaceAll("\\s", ""); logger.info("adding groups={}, to pathId={}", newGroups, pathId); EditService.updatePathTable(Constants.PATH_PROFILE_GROUP_IDS, newGroups, pathId); }
[ "public", "void", "setGroupsForPath", "(", "Integer", "[", "]", "groups", ",", "int", "pathId", ")", "{", "String", "newGroups", "=", "Arrays", ".", "toString", "(", "groups", ")", ";", "newGroups", "=", "newGroups", ".", "substring", "(", "1", ",", "new...
Set the groups assigned to a path @param groups group IDs to set @param pathId ID of path
[ "Set", "the", "groups", "assigned", "to", "a", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L295-L301
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.intArrayContains
public static boolean intArrayContains(int[] array, int numToCheck) { for (int i = 0; i < array.length; i++) { if (array[i] == numToCheck) { return true; } } return false; }
java
public static boolean intArrayContains(int[] array, int numToCheck) { for (int i = 0; i < array.length; i++) { if (array[i] == numToCheck) { return true; } } return false; }
[ "public", "static", "boolean", "intArrayContains", "(", "int", "[", "]", "array", ",", "int", "numToCheck", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", "{", "if", "(", "array", "[", "i",...
a simple contains helper method, checks if array contains a numToCheck @param array array of ints @param numToCheck value to find @return True if found, false otherwise
[ "a", "simple", "contains", "helper", "method", "checks", "if", "array", "contains", "a", "numToCheck" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L310-L317
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getGroupIdFromName
public Integer getGroupIdFromName(String groupName) { return (Integer) sqlService.getFromTable(Constants.GENERIC_ID, Constants.GROUPS_GROUP_NAME, groupName, Constants.DB_TABLE_GROUPS); }
java
public Integer getGroupIdFromName(String groupName) { return (Integer) sqlService.getFromTable(Constants.GENERIC_ID, Constants.GROUPS_GROUP_NAME, groupName, Constants.DB_TABLE_GROUPS); }
[ "public", "Integer", "getGroupIdFromName", "(", "String", "groupName", ")", "{", "return", "(", "Integer", ")", "sqlService", ".", "getFromTable", "(", "Constants", ".", "GENERIC_ID", ",", "Constants", ".", "GROUPS_GROUP_NAME", ",", "groupName", ",", "Constants", ...
given the groupName, it returns the groupId @param groupName name of group @return ID of group
[ "given", "the", "groupName", "it", "returns", "the", "groupId" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L387-L390
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.createOverride
public void createOverride(int groupId, String methodName, String className) throws Exception { // first make sure this doesn't already exist for (Method method : EditService.getInstance().getMethodsFromGroupId(groupId, null)) { if (method.getMethodName().equals(methodName) && method.getClassName().equals(className)) { // don't add if it already exists in the group return; } } try (Connection sqlConnection = sqlService.getConnection()) { PreparedStatement statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_OVERRIDE + "(" + Constants.OVERRIDE_METHOD_NAME + "," + Constants.OVERRIDE_CLASS_NAME + "," + Constants.OVERRIDE_GROUP_ID + ")" + " VALUES (?, ?, ?)" ); statement.setString(1, methodName); statement.setString(2, className); statement.setInt(3, groupId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }
java
public void createOverride(int groupId, String methodName, String className) throws Exception { // first make sure this doesn't already exist for (Method method : EditService.getInstance().getMethodsFromGroupId(groupId, null)) { if (method.getMethodName().equals(methodName) && method.getClassName().equals(className)) { // don't add if it already exists in the group return; } } try (Connection sqlConnection = sqlService.getConnection()) { PreparedStatement statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_OVERRIDE + "(" + Constants.OVERRIDE_METHOD_NAME + "," + Constants.OVERRIDE_CLASS_NAME + "," + Constants.OVERRIDE_GROUP_ID + ")" + " VALUES (?, ?, ?)" ); statement.setString(1, methodName); statement.setString(2, className); statement.setInt(3, groupId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } }
[ "public", "void", "createOverride", "(", "int", "groupId", ",", "String", "methodName", ",", "String", "className", ")", "throws", "Exception", "{", "// first make sure this doesn't already exist", "for", "(", "Method", "method", ":", "EditService", ".", "getInstance"...
given the groupId, and 2 string arrays, adds the name-responses pair to the table_override @param groupId ID of group @param methodName name of method @param className name of class @throws Exception exception
[ "given", "the", "groupId", "and", "2", "string", "arrays", "adds", "the", "name", "-", "responses", "pair", "to", "the", "table_override" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L400-L425
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getGroupNameFromId
public String getGroupNameFromId(int groupId) { return (String) sqlService.getFromTable(Constants.GROUPS_GROUP_NAME, Constants.GENERIC_ID, groupId, Constants.DB_TABLE_GROUPS); }
java
public String getGroupNameFromId(int groupId) { return (String) sqlService.getFromTable(Constants.GROUPS_GROUP_NAME, Constants.GENERIC_ID, groupId, Constants.DB_TABLE_GROUPS); }
[ "public", "String", "getGroupNameFromId", "(", "int", "groupId", ")", "{", "return", "(", "String", ")", "sqlService", ".", "getFromTable", "(", "Constants", ".", "GROUPS_GROUP_NAME", ",", "Constants", ".", "GENERIC_ID", ",", "groupId", ",", "Constants", ".", ...
given the groupId, returns the groupName @param groupId ID of group @return name of group
[ "given", "the", "groupId", "returns", "the", "groupName" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L433-L436
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.updateGroupName
public void updateGroupName(String newGroupName, int id) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_GROUPS + " SET " + Constants.GROUPS_GROUP_NAME + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, newGroupName); statement.setInt(2, id); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void updateGroupName(String newGroupName, int id) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_GROUPS + " SET " + Constants.GROUPS_GROUP_NAME + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, newGroupName); statement.setInt(2, id); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "updateGroupName", "(", "String", "newGroupName", ",", "int", "id", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "stateme...
updates the groupname in the table given the id @param newGroupName new group name @param id ID of group
[ "updates", "the", "groupname", "in", "the", "table", "given", "the", "id" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L444-L466
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.removeGroup
public void removeGroup(int groupId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_GROUPS + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, groupId); statement.executeUpdate(); statement.close(); statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.OVERRIDE_GROUP_ID + " = ?" ); statement.setInt(1, groupId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } removeGroupIdFromTablePaths(groupId); }
java
public void removeGroup(int groupId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_GROUPS + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, groupId); statement.executeUpdate(); statement.close(); statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.OVERRIDE_GROUP_ID + " = ?" ); statement.setInt(1, groupId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } removeGroupIdFromTablePaths(groupId); }
[ "public", "void", "removeGroup", "(", "int", "groupId", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "=", "sqlConnection", "."...
Remove the group and all references to it @param groupId ID of group
[ "Remove", "the", "group", "and", "all", "references", "to", "it" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L473-L503
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.removeGroupIdFromTablePaths
private void removeGroupIdFromTablePaths(int groupIdToRemove) { PreparedStatement queryStatement = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PATH); results = queryStatement.executeQuery(); // this is a hashamp from a pathId to the string of groups HashMap<Integer, String> idToGroups = new HashMap<Integer, String>(); while (results.next()) { int pathId = results.getInt(Constants.GENERIC_ID); String stringGroupIds = results.getString(Constants.PATH_PROFILE_GROUP_IDS); int[] groupIds = Utils.arrayFromStringOfIntegers(stringGroupIds); String newGroupIds = ""; for (int i = 0; i < groupIds.length; i++) { if (groupIds[i] != groupIdToRemove) { newGroupIds += (groupIds[i] + ","); } } idToGroups.put(pathId, newGroupIds); } // now i want to go though the hashmap and for each pathId, add // update the newGroupIds for (Map.Entry<Integer, String> entry : idToGroups.entrySet()) { Integer pathId = entry.getKey(); String newGroupIds = entry.getValue(); statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_GROUP_IDS + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, newGroupIds); statement.setInt(2, pathId); statement.executeUpdate(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
private void removeGroupIdFromTablePaths(int groupIdToRemove) { PreparedStatement queryStatement = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PATH); results = queryStatement.executeQuery(); // this is a hashamp from a pathId to the string of groups HashMap<Integer, String> idToGroups = new HashMap<Integer, String>(); while (results.next()) { int pathId = results.getInt(Constants.GENERIC_ID); String stringGroupIds = results.getString(Constants.PATH_PROFILE_GROUP_IDS); int[] groupIds = Utils.arrayFromStringOfIntegers(stringGroupIds); String newGroupIds = ""; for (int i = 0; i < groupIds.length; i++) { if (groupIds[i] != groupIdToRemove) { newGroupIds += (groupIds[i] + ","); } } idToGroups.put(pathId, newGroupIds); } // now i want to go though the hashmap and for each pathId, add // update the newGroupIds for (Map.Entry<Integer, String> entry : idToGroups.entrySet()) { Integer pathId = entry.getKey(); String newGroupIds = entry.getValue(); statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_GROUP_IDS + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, newGroupIds); statement.setInt(2, pathId); statement.executeUpdate(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "private", "void", "removeGroupIdFromTablePaths", "(", "int", "groupIdToRemove", ")", "{", "PreparedStatement", "queryStatement", "=", "null", ";", "PreparedStatement", "statement", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection"...
Remove all references to a groupId @param groupIdToRemove ID of group
[ "Remove", "all", "references", "to", "a", "groupId" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L510-L570
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.removePath
public void removePath(int pathId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { // remove any enabled overrides with this path statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); // remove path statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); //remove path from responseRequest statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_REQUEST_RESPONSE + " WHERE " + Constants.REQUEST_RESPONSE_PATH_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void removePath(int pathId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { // remove any enabled overrides with this path statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.ENABLED_OVERRIDES_PATH_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); // remove path statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); //remove path from responseRequest statement = sqlConnection.prepareStatement( "DELETE FROM " + Constants.DB_TABLE_REQUEST_RESPONSE + " WHERE " + Constants.REQUEST_RESPONSE_PATH_ID + " = ?" ); statement.setInt(1, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "removePath", "(", "int", "pathId", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "// remove any enabled overrides with this pat...
Remove a path @param pathId ID of path
[ "Remove", "a", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L638-L678
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getMethodForOverrideId
public com.groupon.odo.proxylib.models.Method getMethodForOverrideId(int overrideId) { com.groupon.odo.proxylib.models.Method method = null; // special case for IDs < 0 if (overrideId < 0) { method = new com.groupon.odo.proxylib.models.Method(); method.setId(overrideId); if (method.getId() == Constants.PLUGIN_RESPONSE_OVERRIDE_CUSTOM || method.getId() == Constants.PLUGIN_RESPONSE_HEADER_OVERRIDE_ADD || method.getId() == Constants.PLUGIN_RESPONSE_HEADER_OVERRIDE_REMOVE) { method.setMethodType(Constants.PLUGIN_TYPE_RESPONSE_OVERRIDE); } else { method.setMethodType(Constants.PLUGIN_TYPE_REQUEST_OVERRIDE); } } else { // get method information from the database PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.GENERIC_ID + " = ?" ); queryStatement.setInt(1, overrideId); results = queryStatement.executeQuery(); if (results.next()) { method = new com.groupon.odo.proxylib.models.Method(); method.setClassName(results.getString(Constants.OVERRIDE_CLASS_NAME)); method.setMethodName(results.getString(Constants.OVERRIDE_METHOD_NAME)); } } catch (SQLException e) { e.printStackTrace(); return null; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } // if method is still null then just return if (method == null) { return method; } // now get the rest of the data from the plugin manager // this gets all of the actual method data try { method = PluginManager.getInstance().getMethod(method.getClassName(), method.getMethodName()); method.setId(overrideId); } catch (Exception e) { // there was some problem.. return null return null; } } return method; }
java
public com.groupon.odo.proxylib.models.Method getMethodForOverrideId(int overrideId) { com.groupon.odo.proxylib.models.Method method = null; // special case for IDs < 0 if (overrideId < 0) { method = new com.groupon.odo.proxylib.models.Method(); method.setId(overrideId); if (method.getId() == Constants.PLUGIN_RESPONSE_OVERRIDE_CUSTOM || method.getId() == Constants.PLUGIN_RESPONSE_HEADER_OVERRIDE_ADD || method.getId() == Constants.PLUGIN_RESPONSE_HEADER_OVERRIDE_REMOVE) { method.setMethodType(Constants.PLUGIN_TYPE_RESPONSE_OVERRIDE); } else { method.setMethodType(Constants.PLUGIN_TYPE_REQUEST_OVERRIDE); } } else { // get method information from the database PreparedStatement queryStatement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_OVERRIDE + " WHERE " + Constants.GENERIC_ID + " = ?" ); queryStatement.setInt(1, overrideId); results = queryStatement.executeQuery(); if (results.next()) { method = new com.groupon.odo.proxylib.models.Method(); method.setClassName(results.getString(Constants.OVERRIDE_CLASS_NAME)); method.setMethodName(results.getString(Constants.OVERRIDE_METHOD_NAME)); } } catch (SQLException e) { e.printStackTrace(); return null; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } // if method is still null then just return if (method == null) { return method; } // now get the rest of the data from the plugin manager // this gets all of the actual method data try { method = PluginManager.getInstance().getMethod(method.getClassName(), method.getMethodName()); method.setId(overrideId); } catch (Exception e) { // there was some problem.. return null return null; } } return method; }
[ "public", "com", ".", "groupon", ".", "odo", ".", "proxylib", ".", "models", ".", "Method", "getMethodForOverrideId", "(", "int", "overrideId", ")", "{", "com", ".", "groupon", ".", "odo", ".", "proxylib", ".", "models", ".", "Method", "method", "=", "nu...
Gets a method based on data in the override_db table @param overrideId ID of override @return Method found
[ "Gets", "a", "method", "based", "on", "data", "in", "the", "override_db", "table" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L751-L818
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.updatePathOrder
public void updatePathOrder(int profileId, int[] pathOrder) { for (int i = 0; i < pathOrder.length; i++) { EditService.updatePathTable(Constants.PATH_PROFILE_PATH_ORDER, (i + 1), pathOrder[i]); } }
java
public void updatePathOrder(int profileId, int[] pathOrder) { for (int i = 0; i < pathOrder.length; i++) { EditService.updatePathTable(Constants.PATH_PROFILE_PATH_ORDER, (i + 1), pathOrder[i]); } }
[ "public", "void", "updatePathOrder", "(", "int", "profileId", ",", "int", "[", "]", "pathOrder", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pathOrder", ".", "length", ";", "i", "++", ")", "{", "EditService", ".", "updatePathTable", "...
Updates the path_order column in the table, loops though the pathOrder array, and changes the value to the loop index+1 for the specified pathId @param profileId ID of profile @param pathOrder array containing new order of paths
[ "Updates", "the", "path_order", "column", "in", "the", "table", "loops", "though", "the", "pathOrder", "array", "and", "changes", "the", "value", "to", "the", "loop", "index", "+", "1", "for", "the", "specified", "pathId" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L902-L906
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getPathId
public int getPathId(String pathName, int profileId) { PreparedStatement queryStatement = null; ResultSet results = null; // first get the pathId for the pathName/profileId int pathId = -1; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.PATH_PROFILE_PATHNAME + "= ? " + " AND " + Constants.GENERIC_PROFILE_ID + "= ?" ); queryStatement.setString(1, pathName); queryStatement.setInt(2, profileId); results = queryStatement.executeQuery(); if (results.next()) { pathId = results.getInt(Constants.GENERIC_ID); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return pathId; }
java
public int getPathId(String pathName, int profileId) { PreparedStatement queryStatement = null; ResultSet results = null; // first get the pathId for the pathName/profileId int pathId = -1; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.PATH_PROFILE_PATHNAME + "= ? " + " AND " + Constants.GENERIC_PROFILE_ID + "= ?" ); queryStatement.setString(1, pathName); queryStatement.setInt(2, profileId); results = queryStatement.executeQuery(); if (results.next()) { pathId = results.getInt(Constants.GENERIC_ID); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return pathId; }
[ "public", "int", "getPathId", "(", "String", "pathName", ",", "int", "profileId", ")", "{", "PreparedStatement", "queryStatement", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "// first get the pathId for the pathName/profileId", "int", "pathId", "=", ...
Get path ID for a given profileId and pathName @param pathName Name of path @param profileId ID of profile @return ID of path
[ "Get", "path", "ID", "for", "a", "given", "profileId", "and", "pathName" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L915-L950
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getPathSelectString
private String getPathSelectString() { String queryString = "SELECT " + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.GENERIC_CLIENT_UUID + "," + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "," + Constants.PATH_PROFILE_PATHNAME + "," + Constants.PATH_PROFILE_ACTUAL_PATH + "," + Constants.PATH_PROFILE_BODY_FILTER + "," + Constants.PATH_PROFILE_GROUP_IDS + "," + Constants.DB_TABLE_PATH + "." + Constants.PATH_PROFILE_PROFILE_ID + "," + Constants.PATH_PROFILE_PATH_ORDER + "," + Constants.REQUEST_RESPONSE_REPEAT_NUMBER + "," + Constants.REQUEST_RESPONSE_REQUEST_ENABLED + "," + Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + "," + Constants.PATH_PROFILE_CONTENT_TYPE + "," + Constants.PATH_PROFILE_REQUEST_TYPE + "," + Constants.PATH_PROFILE_GLOBAL + " FROM " + Constants.DB_TABLE_PATH + " JOIN " + Constants.DB_TABLE_REQUEST_RESPONSE + " ON " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "=" + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.REQUEST_RESPONSE_PATH_ID + " AND " + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.GENERIC_CLIENT_UUID + " = ?"; return queryString; }
java
private String getPathSelectString() { String queryString = "SELECT " + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.GENERIC_CLIENT_UUID + "," + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "," + Constants.PATH_PROFILE_PATHNAME + "," + Constants.PATH_PROFILE_ACTUAL_PATH + "," + Constants.PATH_PROFILE_BODY_FILTER + "," + Constants.PATH_PROFILE_GROUP_IDS + "," + Constants.DB_TABLE_PATH + "." + Constants.PATH_PROFILE_PROFILE_ID + "," + Constants.PATH_PROFILE_PATH_ORDER + "," + Constants.REQUEST_RESPONSE_REPEAT_NUMBER + "," + Constants.REQUEST_RESPONSE_REQUEST_ENABLED + "," + Constants.REQUEST_RESPONSE_RESPONSE_ENABLED + "," + Constants.PATH_PROFILE_CONTENT_TYPE + "," + Constants.PATH_PROFILE_REQUEST_TYPE + "," + Constants.PATH_PROFILE_GLOBAL + " FROM " + Constants.DB_TABLE_PATH + " JOIN " + Constants.DB_TABLE_REQUEST_RESPONSE + " ON " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "=" + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.REQUEST_RESPONSE_PATH_ID + " AND " + Constants.DB_TABLE_REQUEST_RESPONSE + "." + Constants.GENERIC_CLIENT_UUID + " = ?"; return queryString; }
[ "private", "String", "getPathSelectString", "(", ")", "{", "String", "queryString", "=", "\"SELECT \"", "+", "Constants", ".", "DB_TABLE_REQUEST_RESPONSE", "+", "\".\"", "+", "Constants", ".", "GENERIC_CLIENT_UUID", "+", "\",\"", "+", "Constants", ".", "DB_TABLE_PAT...
Generate a path select string @return Select query string
[ "Generate", "a", "path", "select", "string" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1016-L1038
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getEndpointOverrideFromResultSet
private EndpointOverride getEndpointOverrideFromResultSet(ResultSet results) throws Exception { EndpointOverride endpoint = new EndpointOverride(); endpoint.setPathId(results.getInt(Constants.GENERIC_ID)); endpoint.setPath(results.getString(Constants.PATH_PROFILE_ACTUAL_PATH)); endpoint.setBodyFilter(results.getString(Constants.PATH_PROFILE_BODY_FILTER)); endpoint.setPathName(results.getString(Constants.PATH_PROFILE_PATHNAME)); endpoint.setContentType(results.getString(Constants.PATH_PROFILE_CONTENT_TYPE)); endpoint.setRequestType(results.getInt(Constants.PATH_PROFILE_REQUEST_TYPE)); endpoint.setRepeatNumber(results.getInt(Constants.REQUEST_RESPONSE_REPEAT_NUMBER)); endpoint.setGroupIds(results.getString(Constants.PATH_PROFILE_GROUP_IDS)); endpoint.setRequestEnabled(results.getBoolean(Constants.REQUEST_RESPONSE_REQUEST_ENABLED)); endpoint.setResponseEnabled(results.getBoolean(Constants.REQUEST_RESPONSE_RESPONSE_ENABLED)); endpoint.setClientUUID(results.getString(Constants.GENERIC_CLIENT_UUID)); endpoint.setProfileId(results.getInt(Constants.GENERIC_PROFILE_ID)); endpoint.setGlobal(results.getBoolean(Constants.PATH_PROFILE_GLOBAL)); return endpoint; }
java
private EndpointOverride getEndpointOverrideFromResultSet(ResultSet results) throws Exception { EndpointOverride endpoint = new EndpointOverride(); endpoint.setPathId(results.getInt(Constants.GENERIC_ID)); endpoint.setPath(results.getString(Constants.PATH_PROFILE_ACTUAL_PATH)); endpoint.setBodyFilter(results.getString(Constants.PATH_PROFILE_BODY_FILTER)); endpoint.setPathName(results.getString(Constants.PATH_PROFILE_PATHNAME)); endpoint.setContentType(results.getString(Constants.PATH_PROFILE_CONTENT_TYPE)); endpoint.setRequestType(results.getInt(Constants.PATH_PROFILE_REQUEST_TYPE)); endpoint.setRepeatNumber(results.getInt(Constants.REQUEST_RESPONSE_REPEAT_NUMBER)); endpoint.setGroupIds(results.getString(Constants.PATH_PROFILE_GROUP_IDS)); endpoint.setRequestEnabled(results.getBoolean(Constants.REQUEST_RESPONSE_REQUEST_ENABLED)); endpoint.setResponseEnabled(results.getBoolean(Constants.REQUEST_RESPONSE_RESPONSE_ENABLED)); endpoint.setClientUUID(results.getString(Constants.GENERIC_CLIENT_UUID)); endpoint.setProfileId(results.getInt(Constants.GENERIC_PROFILE_ID)); endpoint.setGlobal(results.getBoolean(Constants.PATH_PROFILE_GLOBAL)); return endpoint; }
[ "private", "EndpointOverride", "getEndpointOverrideFromResultSet", "(", "ResultSet", "results", ")", "throws", "Exception", "{", "EndpointOverride", "endpoint", "=", "new", "EndpointOverride", "(", ")", ";", "endpoint", ".", "setPathId", "(", "results", ".", "getInt",...
Turn a resultset into EndpointOverride @param results results containing relevant information @return EndpointOverride @throws Exception exception
[ "Turn", "a", "resultset", "into", "EndpointOverride" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1047-L1063
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getPath
public EndpointOverride getPath(int pathId, String clientUUID, String[] filters) throws Exception { EndpointOverride endpoint = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String queryString = this.getPathSelectString(); queryString += " AND " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "=" + pathId + ";"; statement = sqlConnection.prepareStatement(queryString); statement.setString(1, clientUUID); results = statement.executeQuery(); if (results.next()) { endpoint = this.getEndpointOverrideFromResultSet(results); endpoint.setFilters(filters); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return endpoint; }
java
public EndpointOverride getPath(int pathId, String clientUUID, String[] filters) throws Exception { EndpointOverride endpoint = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String queryString = this.getPathSelectString(); queryString += " AND " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_ID + "=" + pathId + ";"; statement = sqlConnection.prepareStatement(queryString); statement.setString(1, clientUUID); results = statement.executeQuery(); if (results.next()) { endpoint = this.getEndpointOverrideFromResultSet(results); endpoint.setFilters(filters); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return endpoint; }
[ "public", "EndpointOverride", "getPath", "(", "int", "pathId", ",", "String", "clientUUID", ",", "String", "[", "]", "filters", ")", "throws", "Exception", "{", "EndpointOverride", "endpoint", "=", "null", ";", "PreparedStatement", "statement", "=", "null", ";",...
Returns information for a specific path id @param pathId ID of path @param clientUUID client UUID @param filters filters to set on endpoint @return EndpointOverride @throws Exception exception
[ "Returns", "information", "for", "a", "specific", "path", "id" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1074-L1109
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setName
public void setName(int pathId, String pathName) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_PATHNAME + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, pathName); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setName(int pathId, String pathName) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_PATHNAME + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, pathName); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setName", "(", "int", "pathId", ",", "String", "pathName", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "...
Sets the path name for this ID @param pathId ID of path @param pathName Name of path
[ "Sets", "the", "path", "name", "for", "this", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1117-L1139
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setPath
public void setPath(int pathId, String path) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_ACTUAL_PATH + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, path); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setPath(int pathId, String path) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_ACTUAL_PATH + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, path); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setPath", "(", "int", "pathId", ",", "String", "path", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "=", ...
Sets the actual path for this ID @param pathId ID of path @param path value of path
[ "Sets", "the", "actual", "path", "for", "this", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1147-L1169
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setBodyFilter
public void setBodyFilter(int pathId, String bodyFilter) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_BODY_FILTER + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, bodyFilter); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setBodyFilter(int pathId, String bodyFilter) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_BODY_FILTER + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, bodyFilter); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setBodyFilter", "(", "int", "pathId", ",", "String", "bodyFilter", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "stateme...
Sets the body filter for this ID @param pathId ID of path @param bodyFilter Body filter to set
[ "Sets", "the", "body", "filter", "for", "this", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1177-L1199
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setContentType
public void setContentType(int pathId, String contentType) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_CONTENT_TYPE + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, contentType); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setContentType(int pathId, String contentType) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_CONTENT_TYPE + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setString(1, contentType); statement.setInt(2, pathId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setContentType", "(", "int", "pathId", ",", "String", "contentType", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "state...
Sets the content type for this ID @param pathId ID of path @param contentType content type value
[ "Sets", "the", "content", "type", "for", "this", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1207-L1229
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setRequestType
public void setRequestType(int pathId, Integer requestType) { if (requestType == null) { requestType = Constants.REQUEST_TYPE_GET; } PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_REQUEST_TYPE + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, requestType); statement.setInt(2, pathId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setRequestType(int pathId, Integer requestType) { if (requestType == null) { requestType = Constants.REQUEST_TYPE_GET; } PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_REQUEST_TYPE + " = ?" + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, requestType); statement.setInt(2, pathId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setRequestType", "(", "int", "pathId", ",", "Integer", "requestType", ")", "{", "if", "(", "requestType", "==", "null", ")", "{", "requestType", "=", "Constants", ".", "REQUEST_TYPE_GET", ";", "}", "PreparedStatement", "statement", "=", "nul...
Sets the request type for this ID. Defaults to GET @param pathId ID of path @param requestType type of request to service
[ "Sets", "the", "request", "type", "for", "this", "ID", ".", "Defaults", "to", "GET" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1237-L1262
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setGlobal
public void setGlobal(int pathId, Boolean global) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_GLOBAL + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setBoolean(1, global); statement.setInt(2, pathId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setGlobal(int pathId, Boolean global) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_PATH + " SET " + Constants.PATH_PROFILE_GLOBAL + " = ? " + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setBoolean(1, global); statement.setInt(2, pathId); statement.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setGlobal", "(", "int", "pathId", ",", "Boolean", "global", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", ...
Sets the global setting for this ID @param pathId ID of path @param global True if global, False otherwise
[ "Sets", "the", "global", "setting", "for", "this", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1270-L1292
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getPaths
public List<EndpointOverride> getPaths(int profileId, String clientUUID, String[] filters) throws Exception { ArrayList<EndpointOverride> properties = new ArrayList<EndpointOverride>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String queryString = this.getPathSelectString(); queryString += " AND " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_PROFILE_ID + "=? " + " ORDER BY " + Constants.PATH_PROFILE_PATH_ORDER + " ASC"; statement = sqlConnection.prepareStatement(queryString); statement.setString(1, clientUUID); statement.setInt(2, profileId); results = statement.executeQuery(); while (results.next()) { EndpointOverride endpoint = this.getEndpointOverrideFromResultSet(results); endpoint.setFilters(filters); properties.add(endpoint); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return properties; }
java
public List<EndpointOverride> getPaths(int profileId, String clientUUID, String[] filters) throws Exception { ArrayList<EndpointOverride> properties = new ArrayList<EndpointOverride>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String queryString = this.getPathSelectString(); queryString += " AND " + Constants.DB_TABLE_PATH + "." + Constants.GENERIC_PROFILE_ID + "=? " + " ORDER BY " + Constants.PATH_PROFILE_PATH_ORDER + " ASC"; statement = sqlConnection.prepareStatement(queryString); statement.setString(1, clientUUID); statement.setInt(2, profileId); results = statement.executeQuery(); while (results.next()) { EndpointOverride endpoint = this.getEndpointOverrideFromResultSet(results); endpoint.setFilters(filters); properties.add(endpoint); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return properties; }
[ "public", "List", "<", "EndpointOverride", ">", "getPaths", "(", "int", "profileId", ",", "String", "clientUUID", ",", "String", "[", "]", "filters", ")", "throws", "Exception", "{", "ArrayList", "<", "EndpointOverride", ">", "properties", "=", "new", "ArrayLi...
Returns an array of all endpoints @param profileId ID of profile @param clientUUID UUID of client @param filters filters to apply to endpoints @return Collection of endpoints @throws Exception exception
[ "Returns", "an", "array", "of", "all", "endpoints" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1303-L1341
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.setCustomRequest
public void setCustomRequest(int pathId, String customRequest, String clientUUID) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { int profileId = EditService.getProfileIdFromPathID(pathId); statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_REQUEST_RESPONSE + " SET " + Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + "= ?" + " WHERE " + Constants.GENERIC_PROFILE_ID + "= ?" + " AND " + Constants.GENERIC_CLIENT_UUID + "= ?" + " AND " + Constants.REQUEST_RESPONSE_PATH_ID + "= ?" ); statement.setString(1, customRequest); statement.setInt(2, profileId); statement.setString(3, clientUUID); statement.setInt(4, pathId); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void setCustomRequest(int pathId, String customRequest, String clientUUID) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { int profileId = EditService.getProfileIdFromPathID(pathId); statement = sqlConnection.prepareStatement( "UPDATE " + Constants.DB_TABLE_REQUEST_RESPONSE + " SET " + Constants.REQUEST_RESPONSE_CUSTOM_REQUEST + "= ?" + " WHERE " + Constants.GENERIC_PROFILE_ID + "= ?" + " AND " + Constants.GENERIC_CLIENT_UUID + "= ?" + " AND " + Constants.REQUEST_RESPONSE_PATH_ID + "= ?" ); statement.setString(1, customRequest); statement.setInt(2, profileId); statement.setString(3, clientUUID); statement.setInt(4, pathId); statement.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "setCustomRequest", "(", "int", "pathId", ",", "String", "customRequest", ",", "String", "clientUUID", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection...
Set the value for a custom request @param pathId ID of path @param customRequest value of custom request @param clientUUID UUID of client
[ "Set", "the", "value", "for", "a", "custom", "request" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1458-L1485
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.clearResponseSettings
public void clearResponseSettings(int pathId, String clientUUID) throws Exception { logger.info("clearing response settings"); this.setResponseEnabled(pathId, false, clientUUID); OverrideService.getInstance().disableAllOverrides(pathId, clientUUID, Constants.OVERRIDE_TYPE_RESPONSE); EditService.getInstance().updateRepeatNumber(Constants.OVERRIDE_TYPE_RESPONSE, pathId, clientUUID); }
java
public void clearResponseSettings(int pathId, String clientUUID) throws Exception { logger.info("clearing response settings"); this.setResponseEnabled(pathId, false, clientUUID); OverrideService.getInstance().disableAllOverrides(pathId, clientUUID, Constants.OVERRIDE_TYPE_RESPONSE); EditService.getInstance().updateRepeatNumber(Constants.OVERRIDE_TYPE_RESPONSE, pathId, clientUUID); }
[ "public", "void", "clearResponseSettings", "(", "int", "pathId", ",", "String", "clientUUID", ")", "throws", "Exception", "{", "logger", ".", "info", "(", "\"clearing response settings\"", ")", ";", "this", ".", "setResponseEnabled", "(", "pathId", ",", "false", ...
Clear all overrides, reset repeat counts for a response path @param pathId ID of path @param clientUUID UUID of client @throws Exception exception
[ "Clear", "all", "overrides", "reset", "repeat", "counts", "for", "a", "response", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1494-L1499
train
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.clearRequestSettings
public void clearRequestSettings(int pathId, String clientUUID) throws Exception { this.setRequestEnabled(pathId, false, clientUUID); OverrideService.getInstance().disableAllOverrides(pathId, clientUUID, Constants.OVERRIDE_TYPE_REQUEST); EditService.getInstance().updateRepeatNumber(Constants.OVERRIDE_TYPE_REQUEST, pathId, clientUUID); }
java
public void clearRequestSettings(int pathId, String clientUUID) throws Exception { this.setRequestEnabled(pathId, false, clientUUID); OverrideService.getInstance().disableAllOverrides(pathId, clientUUID, Constants.OVERRIDE_TYPE_REQUEST); EditService.getInstance().updateRepeatNumber(Constants.OVERRIDE_TYPE_REQUEST, pathId, clientUUID); }
[ "public", "void", "clearRequestSettings", "(", "int", "pathId", ",", "String", "clientUUID", ")", "throws", "Exception", "{", "this", ".", "setRequestEnabled", "(", "pathId", ",", "false", ",", "clientUUID", ")", ";", "OverrideService", ".", "getInstance", "(", ...
Clear all overrides, reset repeat counts for a request path @param pathId ID of path @param clientUUID UUID of client @throws Exception exception
[ "Clear", "all", "overrides", "reset", "repeat", "counts", "for", "a", "request", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1508-L1512
train