id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
164,700
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", ")", "{", "return", "\"{}\"", ";", "}", "}" ]
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
164,701
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", "?", "\"\"", ":", "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", ";", "}", "}" ]
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
164,702
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", "=", "\"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", ")", ";", "}" ]
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
164,703
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", "(", "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", ";", "}" ]
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
164,704
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", ",", "@", "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", ";", "}" ]
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
164,705
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\"", ")", "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", ")", ";", "}" ]
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
164,706
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
164,707
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", "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", "(", ")", ")", ";", "/**\n * If equalsPos is not -1, then there was a '=' for the key\n * If value.size is 0, then there is no value so want to add in the '='\n * Since it will not be added later like params with keys and valued\n */", "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", ";", "}" ]
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
164,708
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", "=", "retval", ".", "substring", "(", "0", ",", "qPos", ")", ";", "}", "return", "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
164,709
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", ":", "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", ";", "}" ]
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
164,710
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", "(", "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", ";", "}" ]
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
164,711
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", "(", "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", ";", "}" ]
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
164,712
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", "(", "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", ";", "}" ]
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
164,713
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", ">", "(", ")", ";", "for", "(", "int", "groupId", ":", "groupIds", ")", "{", "methods", ".", "addAll", "(", "getMethodsFromGroupId", "(", "groupId", ",", "filters", ")", ")", ";", "}", "return", "methods", ";", "}" ]
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
164,714
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", ")", ",", "client_uuid", ",", "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
164,715
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,716
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,717
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", ">", "(", ")", ";", "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", ";", "}" ]
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
164,718
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_id", ")", ",", "client_uuid", ",", "path_id", ")", ";", "}" ]
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
164,719
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", ".", "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", ")", "{", "}", "}", "}" ]
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
164,720
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_uuid", ",", "path_id", ")", ";", "}" ]
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
164,721
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", ",", "Constants", ".", "GENERIC_ID", ",", "path_id", ",", "Constants", ".", "DB_TABLE_PATH", ")", ";", "}" ]
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
164,722
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", "=", "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", ";", "}" ]
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
164,723
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", "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", ";", "}" ]
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
164,724
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", "=", "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", ")", "{", "}", "}", "}" ]
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
164,725
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", ";", "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", ";", "}" ]
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
164,726
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", ",", "newGroups", ".", "length", "(", ")", "-", "1", ")", ".", "replaceAll", "(", "\"\\\\s\"", ",", "\"\"", ")", ";", "logger", ".", "info", "(", "\"adding groups={}, to pathId={}\"", ",", "newGroups", ",", "pathId", ")", ";", "EditService", ".", "updatePathTable", "(", "Constants", ".", "PATH_PROFILE_GROUP_IDS", ",", "newGroups", ",", "pathId", ")", ";", "}" ]
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
164,727
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", "]", "==", "numToCheck", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
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
164,728
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", ".", "DB_TABLE_GROUPS", ")", ";", "}" ]
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
164,729
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", "(", ")", ".", "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", "(", ")", ";", "}", "}" ]
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
164,730
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", ".", "DB_TABLE_GROUPS", ")", ";", "}" ]
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
164,731
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,732
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", ".", "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", ")", ";", "}" ]
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
164,733
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", "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", ")", "{", "}", "}", "}" ]
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
164,734
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 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", ")", "{", "}", "}", "}" ]
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
164,735
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", "=", "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", ";", "}" ]
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
164,736
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", "(", "Constants", ".", "PATH_PROFILE_PATH_ORDER", ",", "(", "i", "+", "1", ")", ",", "pathOrder", "[", "i", "]", ")", ";", "}", "}" ]
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
164,737
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", "=", "-", "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", ";", "}" ]
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
164,738
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_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", ";", "}" ]
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
164,739
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", "(", "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", ";", "}" ]
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
164,740
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", ";", "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", ";", "}" ]
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
164,741
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", "=", "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", ")", "{", "}", "}", "}" ]
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
164,742
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", "=", "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", ")", "{", "}", "}", "}" ]
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
164,743
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,744
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,745
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", "=", "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", ")", "{", "}", "}", "}" ]
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
164,746
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", "=", "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", ")", "{", "}", "}", "}" ]
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
164,747
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", "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", ";", "}" ]
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
164,748
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", "(", ")", ")", "{", "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", ")", "{", "}", "}", "}" ]
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
164,749
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", ",", "clientUUID", ")", ";", "OverrideService", ".", "getInstance", "(", ")", ".", "disableAllOverrides", "(", "pathId", ",", "clientUUID", ",", "Constants", ".", "OVERRIDE_TYPE_RESPONSE", ")", ";", "EditService", ".", "getInstance", "(", ")", ".", "updateRepeatNumber", "(", "Constants", ".", "OVERRIDE_TYPE_RESPONSE", ",", "pathId", ",", "clientUUID", ")", ";", "}" ]
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
164,750
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", "(", ")", ".", "disableAllOverrides", "(", "pathId", ",", "clientUUID", ",", "Constants", ".", "OVERRIDE_TYPE_REQUEST", ")", ";", "EditService", ".", "getInstance", "(", ")", ".", "updateRepeatNumber", "(", "Constants", ".", "OVERRIDE_TYPE_REQUEST", ",", "pathId", ",", "clientUUID", ")", ";", "}" ]
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
164,751
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java
PathOverrideService.getSelectedPaths
public List<EndpointOverride> getSelectedPaths(int overrideType, Client client, Profile profile, String uri, Integer requestType, boolean pathTest) throws Exception { List<EndpointOverride> selectPaths = new ArrayList<EndpointOverride>(); // get the paths for the current active client profile // this returns paths in priority order List<EndpointOverride> paths = new ArrayList<EndpointOverride>(); if (client.getIsActive()) { paths = getPaths( profile.getId(), client.getUUID(), null); } boolean foundRealPath = false; logger.info("Checking uri: {}", uri); // it should now be ordered by priority, i updated tableOverrides to // return the paths in priority order for (EndpointOverride path : paths) { // first see if the request types match.. // and if the path request type is not ALL // if they do not then skip this path // If requestType is -1 we evaluate all(probably called by the path tester) if (requestType != -1 && path.getRequestType() != requestType && path.getRequestType() != Constants.REQUEST_TYPE_ALL) { continue; } // first see if we get a match try { Pattern pattern = Pattern.compile(path.getPath()); Matcher matcher = pattern.matcher(uri); // we won't select the path if there aren't any enabled endpoints in it // this works since the paths are returned in priority order if (matcher.find()) { // now see if this path has anything enabled in it // Only go into the if: // 1. There are enabled items in this path // 2. Caller was looking for ResponseOverride and Response is enabled OR looking for RequestOverride // 3. If pathTest is true then the rest of the conditions are not evaluated. The path tester ignores enabled states so everything is returned. // and request is enabled if (pathTest || (path.getEnabledEndpoints().size() > 0 && ((overrideType == Constants.OVERRIDE_TYPE_RESPONSE && path.getResponseEnabled()) || (overrideType == Constants.OVERRIDE_TYPE_REQUEST && path.getRequestEnabled())))) { // if we haven't already seen a non global path // or if this is a global path // then add it to the list if (!foundRealPath || path.getGlobal()) { selectPaths.add(path); } } // we set this no matter what if a path matched and it was not the global path // this stops us from adding further non global matches to the list if (!path.getGlobal()) { foundRealPath = true; } } } catch (PatternSyntaxException pse) { // nothing to do but keep iterating over the list // this indicates an invalid regex } } return selectPaths; }
java
public List<EndpointOverride> getSelectedPaths(int overrideType, Client client, Profile profile, String uri, Integer requestType, boolean pathTest) throws Exception { List<EndpointOverride> selectPaths = new ArrayList<EndpointOverride>(); // get the paths for the current active client profile // this returns paths in priority order List<EndpointOverride> paths = new ArrayList<EndpointOverride>(); if (client.getIsActive()) { paths = getPaths( profile.getId(), client.getUUID(), null); } boolean foundRealPath = false; logger.info("Checking uri: {}", uri); // it should now be ordered by priority, i updated tableOverrides to // return the paths in priority order for (EndpointOverride path : paths) { // first see if the request types match.. // and if the path request type is not ALL // if they do not then skip this path // If requestType is -1 we evaluate all(probably called by the path tester) if (requestType != -1 && path.getRequestType() != requestType && path.getRequestType() != Constants.REQUEST_TYPE_ALL) { continue; } // first see if we get a match try { Pattern pattern = Pattern.compile(path.getPath()); Matcher matcher = pattern.matcher(uri); // we won't select the path if there aren't any enabled endpoints in it // this works since the paths are returned in priority order if (matcher.find()) { // now see if this path has anything enabled in it // Only go into the if: // 1. There are enabled items in this path // 2. Caller was looking for ResponseOverride and Response is enabled OR looking for RequestOverride // 3. If pathTest is true then the rest of the conditions are not evaluated. The path tester ignores enabled states so everything is returned. // and request is enabled if (pathTest || (path.getEnabledEndpoints().size() > 0 && ((overrideType == Constants.OVERRIDE_TYPE_RESPONSE && path.getResponseEnabled()) || (overrideType == Constants.OVERRIDE_TYPE_REQUEST && path.getRequestEnabled())))) { // if we haven't already seen a non global path // or if this is a global path // then add it to the list if (!foundRealPath || path.getGlobal()) { selectPaths.add(path); } } // we set this no matter what if a path matched and it was not the global path // this stops us from adding further non global matches to the list if (!path.getGlobal()) { foundRealPath = true; } } } catch (PatternSyntaxException pse) { // nothing to do but keep iterating over the list // this indicates an invalid regex } } return selectPaths; }
[ "public", "List", "<", "EndpointOverride", ">", "getSelectedPaths", "(", "int", "overrideType", ",", "Client", "client", ",", "Profile", "profile", ",", "String", "uri", ",", "Integer", "requestType", ",", "boolean", "pathTest", ")", "throws", "Exception", "{", "List", "<", "EndpointOverride", ">", "selectPaths", "=", "new", "ArrayList", "<", "EndpointOverride", ">", "(", ")", ";", "// get the paths for the current active client profile", "// this returns paths in priority order", "List", "<", "EndpointOverride", ">", "paths", "=", "new", "ArrayList", "<", "EndpointOverride", ">", "(", ")", ";", "if", "(", "client", ".", "getIsActive", "(", ")", ")", "{", "paths", "=", "getPaths", "(", "profile", ".", "getId", "(", ")", ",", "client", ".", "getUUID", "(", ")", ",", "null", ")", ";", "}", "boolean", "foundRealPath", "=", "false", ";", "logger", ".", "info", "(", "\"Checking uri: {}\"", ",", "uri", ")", ";", "// it should now be ordered by priority, i updated tableOverrides to", "// return the paths in priority order", "for", "(", "EndpointOverride", "path", ":", "paths", ")", "{", "// first see if the request types match..", "// and if the path request type is not ALL", "// if they do not then skip this path", "// If requestType is -1 we evaluate all(probably called by the path tester)", "if", "(", "requestType", "!=", "-", "1", "&&", "path", ".", "getRequestType", "(", ")", "!=", "requestType", "&&", "path", ".", "getRequestType", "(", ")", "!=", "Constants", ".", "REQUEST_TYPE_ALL", ")", "{", "continue", ";", "}", "// first see if we get a match", "try", "{", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "path", ".", "getPath", "(", ")", ")", ";", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "uri", ")", ";", "// we won't select the path if there aren't any enabled endpoints in it", "// this works since the paths are returned in priority order", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "// now see if this path has anything enabled in it", "// Only go into the if:", "// 1. There are enabled items in this path", "// 2. Caller was looking for ResponseOverride and Response is enabled OR looking for RequestOverride", "// 3. If pathTest is true then the rest of the conditions are not evaluated. The path tester ignores enabled states so everything is returned.", "// and request is enabled", "if", "(", "pathTest", "||", "(", "path", ".", "getEnabledEndpoints", "(", ")", ".", "size", "(", ")", ">", "0", "&&", "(", "(", "overrideType", "==", "Constants", ".", "OVERRIDE_TYPE_RESPONSE", "&&", "path", ".", "getResponseEnabled", "(", ")", ")", "||", "(", "overrideType", "==", "Constants", ".", "OVERRIDE_TYPE_REQUEST", "&&", "path", ".", "getRequestEnabled", "(", ")", ")", ")", ")", ")", "{", "// if we haven't already seen a non global path", "// or if this is a global path", "// then add it to the list", "if", "(", "!", "foundRealPath", "||", "path", ".", "getGlobal", "(", ")", ")", "{", "selectPaths", ".", "add", "(", "path", ")", ";", "}", "}", "// we set this no matter what if a path matched and it was not the global path", "// this stops us from adding further non global matches to the list", "if", "(", "!", "path", ".", "getGlobal", "(", ")", ")", "{", "foundRealPath", "=", "true", ";", "}", "}", "}", "catch", "(", "PatternSyntaxException", "pse", ")", "{", "// nothing to do but keep iterating over the list", "// this indicates an invalid regex", "}", "}", "return", "selectPaths", ";", "}" ]
Obtain matching paths for a request @param overrideType type of override @param client Client @param profile Profile @param uri URI @param requestType type of request @param pathTest If true this will also match disabled paths @return Collection of matching endpoints @throws Exception exception
[ "Obtain", "matching", "paths", "for", "a", "request" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/PathOverrideService.java#L1526-L1593
164,752
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.isActive
public boolean isActive(int profileId) { boolean active = false; PreparedStatement queryStatement = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT " + Constants.CLIENT_IS_ACTIVE + " FROM " + Constants.DB_TABLE_CLIENT + " WHERE " + Constants.GENERIC_CLIENT_UUID + "= '-1' " + " AND " + Constants.GENERIC_PROFILE_ID + "= ? " ); queryStatement.setInt(1, profileId); logger.info(queryStatement.toString()); ResultSet results = queryStatement.executeQuery(); if (results.next()) { active = results.getBoolean(Constants.CLIENT_IS_ACTIVE); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return active; }
java
public boolean isActive(int profileId) { boolean active = false; PreparedStatement queryStatement = null; try (Connection sqlConnection = sqlService.getConnection()) { queryStatement = sqlConnection.prepareStatement( "SELECT " + Constants.CLIENT_IS_ACTIVE + " FROM " + Constants.DB_TABLE_CLIENT + " WHERE " + Constants.GENERIC_CLIENT_UUID + "= '-1' " + " AND " + Constants.GENERIC_PROFILE_ID + "= ? " ); queryStatement.setInt(1, profileId); logger.info(queryStatement.toString()); ResultSet results = queryStatement.executeQuery(); if (results.next()) { active = results.getBoolean(Constants.CLIENT_IS_ACTIVE); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (queryStatement != null) { queryStatement.close(); } } catch (Exception e) { } } return active; }
[ "public", "boolean", "isActive", "(", "int", "profileId", ")", "{", "boolean", "active", "=", "false", ";", "PreparedStatement", "queryStatement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "queryStatement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT \"", "+", "Constants", ".", "CLIENT_IS_ACTIVE", "+", "\" FROM \"", "+", "Constants", ".", "DB_TABLE_CLIENT", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_CLIENT_UUID", "+", "\"= '-1' \"", "+", "\" AND \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\"= ? \"", ")", ";", "queryStatement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "logger", ".", "info", "(", "queryStatement", ".", "toString", "(", ")", ")", ";", "ResultSet", "results", "=", "queryStatement", ".", "executeQuery", "(", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "active", "=", "results", ".", "getBoolean", "(", "Constants", ".", "CLIENT_IS_ACTIVE", ")", ";", "}", "}", "catch", "(", "SQLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "queryStatement", "!=", "null", ")", "{", "queryStatement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "active", ";", "}" ]
Returns true if the default profile for the specified uuid is active @return true if active, otherwise false
[ "Returns", "true", "if", "the", "default", "profile", "for", "the", "specified", "uuid", "is", "active" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L61-L89
164,753
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.findAllProfiles
public List<Profile> findAllProfiles() throws Exception { ArrayList<Profile> allProfiles = new ArrayList<>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PROFILE); results = statement.executeQuery(); while (results.next()) { allProfiles.add(this.getProfileFromResultSet(results)); } } catch (Exception e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return allProfiles; }
java
public List<Profile> findAllProfiles() throws Exception { ArrayList<Profile> allProfiles = new ArrayList<>(); PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PROFILE); results = statement.executeQuery(); while (results.next()) { allProfiles.add(this.getProfileFromResultSet(results)); } } catch (Exception e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return allProfiles; }
[ "public", "List", "<", "Profile", ">", "findAllProfiles", "(", ")", "throws", "Exception", "{", "ArrayList", "<", "Profile", ">", "allProfiles", "=", "new", "ArrayList", "<>", "(", ")", ";", "PreparedStatement", "statement", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT * FROM \"", "+", "Constants", ".", "DB_TABLE_PROFILE", ")", ";", "results", "=", "statement", ".", "executeQuery", "(", ")", ";", "while", "(", "results", ".", "next", "(", ")", ")", "{", "allProfiles", ".", "add", "(", "this", ".", "getProfileFromResultSet", "(", "results", ")", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "e", ";", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "statement", "!=", "null", ")", "{", "statement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "allProfiles", ";", "}" ]
Returns a collection of all profiles @return Collection of all Profiles @throws Exception exception
[ "Returns", "a", "collection", "of", "all", "profiles" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L97-L125
164,754
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.findProfile
public Profile findProfile(int profileId) throws Exception { Profile profile = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, profileId); results = statement.executeQuery(); if (results.next()) { profile = this.getProfileFromResultSet(results); } } catch (Exception e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return profile; }
java
public Profile findProfile(int profileId) throws Exception { Profile profile = null; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement( "SELECT * FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.GENERIC_ID + " = ?" ); statement.setInt(1, profileId); results = statement.executeQuery(); if (results.next()) { profile = this.getProfileFromResultSet(results); } } catch (Exception e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return profile; }
[ "public", "Profile", "findProfile", "(", "int", "profileId", ")", "throws", "Exception", "{", "Profile", "profile", "=", "null", ";", "PreparedStatement", "statement", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT * FROM \"", "+", "Constants", ".", "DB_TABLE_PROFILE", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "results", "=", "statement", ".", "executeQuery", "(", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "profile", "=", "this", ".", "getProfileFromResultSet", "(", "results", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "e", ";", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "statement", "!=", "null", ")", "{", "statement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "profile", ";", "}" ]
Returns a specific profile @param profileId ID of profile @return Selected profile if found, null if not found @throws Exception exception
[ "Returns", "a", "specific", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L134-L166
164,755
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.getProfileFromResultSet
private Profile getProfileFromResultSet(ResultSet result) throws Exception { Profile profile = new Profile(); profile.setId(result.getInt(Constants.GENERIC_ID)); Clob clobProfileName = result.getClob(Constants.PROFILE_PROFILE_NAME); String profileName = clobProfileName.getSubString(1, (int) clobProfileName.length()); profile.setName(profileName); return profile; }
java
private Profile getProfileFromResultSet(ResultSet result) throws Exception { Profile profile = new Profile(); profile.setId(result.getInt(Constants.GENERIC_ID)); Clob clobProfileName = result.getClob(Constants.PROFILE_PROFILE_NAME); String profileName = clobProfileName.getSubString(1, (int) clobProfileName.length()); profile.setName(profileName); return profile; }
[ "private", "Profile", "getProfileFromResultSet", "(", "ResultSet", "result", ")", "throws", "Exception", "{", "Profile", "profile", "=", "new", "Profile", "(", ")", ";", "profile", ".", "setId", "(", "result", ".", "getInt", "(", "Constants", ".", "GENERIC_ID", ")", ")", ";", "Clob", "clobProfileName", "=", "result", ".", "getClob", "(", "Constants", ".", "PROFILE_PROFILE_NAME", ")", ";", "String", "profileName", "=", "clobProfileName", ".", "getSubString", "(", "1", ",", "(", "int", ")", "clobProfileName", ".", "length", "(", ")", ")", ";", "profile", ".", "setName", "(", "profileName", ")", ";", "return", "profile", ";", "}" ]
Creates a Profile object from a SQL resultset @param result resultset containing the profile @return Profile @throws Exception exception
[ "Creates", "a", "Profile", "object", "from", "a", "SQL", "resultset" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L175-L182
164,756
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.add
public Profile add(String profileName) throws Exception { Profile profile = new Profile(); int id = -1; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { Clob clobProfileName = sqlService.toClob(profileName, sqlConnection); statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_PROFILE + "(" + Constants.PROFILE_PROFILE_NAME + ") " + " VALUES (?)", PreparedStatement.RETURN_GENERATED_KEYS ); statement.setClob(1, clobProfileName); statement.executeUpdate(); results = statement.getGeneratedKeys(); if (results.next()) { id = results.getInt(1); } else { // something went wrong throw new Exception("Could not add client"); } results.close(); statement.close(); statement = sqlConnection.prepareStatement("INSERT INTO " + Constants.DB_TABLE_CLIENT + "(" + Constants.CLIENT_CLIENT_UUID + "," + Constants.CLIENT_IS_ACTIVE + "," + Constants.CLIENT_PROFILE_ID + ") " + " VALUES (?, ?, ?)"); statement.setString(1, Constants.PROFILE_CLIENT_DEFAULT_ID); statement.setBoolean(2, false); statement.setInt(3, id); statement.executeUpdate(); profile.setName(profileName); profile.setId(id); } catch (SQLException e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return profile; }
java
public Profile add(String profileName) throws Exception { Profile profile = new Profile(); int id = -1; PreparedStatement statement = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { Clob clobProfileName = sqlService.toClob(profileName, sqlConnection); statement = sqlConnection.prepareStatement( "INSERT INTO " + Constants.DB_TABLE_PROFILE + "(" + Constants.PROFILE_PROFILE_NAME + ") " + " VALUES (?)", PreparedStatement.RETURN_GENERATED_KEYS ); statement.setClob(1, clobProfileName); statement.executeUpdate(); results = statement.getGeneratedKeys(); if (results.next()) { id = results.getInt(1); } else { // something went wrong throw new Exception("Could not add client"); } results.close(); statement.close(); statement = sqlConnection.prepareStatement("INSERT INTO " + Constants.DB_TABLE_CLIENT + "(" + Constants.CLIENT_CLIENT_UUID + "," + Constants.CLIENT_IS_ACTIVE + "," + Constants.CLIENT_PROFILE_ID + ") " + " VALUES (?, ?, ?)"); statement.setString(1, Constants.PROFILE_CLIENT_DEFAULT_ID); statement.setBoolean(2, false); statement.setInt(3, id); statement.executeUpdate(); profile.setName(profileName); profile.setId(id); } catch (SQLException e) { throw e; } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (statement != null) { statement.close(); } } catch (Exception e) { } } return profile; }
[ "public", "Profile", "add", "(", "String", "profileName", ")", "throws", "Exception", "{", "Profile", "profile", "=", "new", "Profile", "(", ")", ";", "int", "id", "=", "-", "1", ";", "PreparedStatement", "statement", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "Clob", "clobProfileName", "=", "sqlService", ".", "toClob", "(", "profileName", ",", "sqlConnection", ")", ";", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"INSERT INTO \"", "+", "Constants", ".", "DB_TABLE_PROFILE", "+", "\"(\"", "+", "Constants", ".", "PROFILE_PROFILE_NAME", "+", "\") \"", "+", "\" VALUES (?)\"", ",", "PreparedStatement", ".", "RETURN_GENERATED_KEYS", ")", ";", "statement", ".", "setClob", "(", "1", ",", "clobProfileName", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "results", "=", "statement", ".", "getGeneratedKeys", "(", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "id", "=", "results", ".", "getInt", "(", "1", ")", ";", "}", "else", "{", "// something went wrong", "throw", "new", "Exception", "(", "\"Could not add client\"", ")", ";", "}", "results", ".", "close", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"INSERT INTO \"", "+", "Constants", ".", "DB_TABLE_CLIENT", "+", "\"(\"", "+", "Constants", ".", "CLIENT_CLIENT_UUID", "+", "\",\"", "+", "Constants", ".", "CLIENT_IS_ACTIVE", "+", "\",\"", "+", "Constants", ".", "CLIENT_PROFILE_ID", "+", "\") \"", "+", "\" VALUES (?, ?, ?)\"", ")", ";", "statement", ".", "setString", "(", "1", ",", "Constants", ".", "PROFILE_CLIENT_DEFAULT_ID", ")", ";", "statement", ".", "setBoolean", "(", "2", ",", "false", ")", ";", "statement", ".", "setInt", "(", "3", ",", "id", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "profile", ".", "setName", "(", "profileName", ")", ";", "profile", ".", "setId", "(", "id", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "throw", "e", ";", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "statement", "!=", "null", ")", "{", "statement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "profile", ";", "}" ]
Add a new profile with the profileName given. @param profileName name of new profile @return newly created profile @throws Exception exception
[ "Add", "a", "new", "profile", "with", "the", "profileName", "given", "." ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L191-L247
164,757
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.remove
public void remove(int profileId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.GENERIC_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //also want to delete what is in the server redirect table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_SERVERS + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //also want to delete the path_profile table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //and the enabled overrides table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //and delete all the clients associated with this profile including the default client statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_CLIENT + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
java
public void remove(int profileId) { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.GENERIC_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //also want to delete what is in the server redirect table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_SERVERS + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //also want to delete the path_profile table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_PATH + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //and the enabled overrides table statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); //and delete all the clients associated with this profile including the default client statement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_CLIENT + " WHERE " + Constants.GENERIC_PROFILE_ID + " = ?"); statement.setInt(1, profileId); statement.executeUpdate(); statement.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (statement != null) { statement.close(); } } catch (Exception e) { } } }
[ "public", "void", "remove", "(", "int", "profileId", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_PROFILE", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "//also want to delete what is in the server redirect table", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_SERVERS", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "//also want to delete the path_profile table", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_PATH", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "//and the enabled overrides table", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_ENABLED_OVERRIDE", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "//and delete all the clients associated with this profile including the default client", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_CLIENT", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\" = ?\"", ")", ";", "statement", ".", "setInt", "(", "1", ",", "profileId", ")", ";", "statement", ".", "executeUpdate", "(", ")", ";", "statement", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "statement", "!=", "null", ")", "{", "statement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}" ]
Deletes data associated with the given profile ID @param profileId ID of profile
[ "Deletes", "data", "associated", "with", "the", "given", "profile", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L256-L299
164,758
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.getNamefromId
public String getNamefromId(int id) { return (String) sqlService.getFromTable( Constants.PROFILE_PROFILE_NAME, Constants.GENERIC_ID, id, Constants.DB_TABLE_PROFILE); }
java
public String getNamefromId(int id) { return (String) sqlService.getFromTable( Constants.PROFILE_PROFILE_NAME, Constants.GENERIC_ID, id, Constants.DB_TABLE_PROFILE); }
[ "public", "String", "getNamefromId", "(", "int", "id", ")", "{", "return", "(", "String", ")", "sqlService", ".", "getFromTable", "(", "Constants", ".", "PROFILE_PROFILE_NAME", ",", "Constants", ".", "GENERIC_ID", ",", "id", ",", "Constants", ".", "DB_TABLE_PROFILE", ")", ";", "}" ]
Obtain the profile name associated with a profile ID @param id ID of profile @return Name of corresponding profile
[ "Obtain", "the", "profile", "name", "associated", "with", "a", "profile", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L307-L311
164,759
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java
ProfileService.getIdFromName
public Integer getIdFromName(String profileName) { PreparedStatement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { query = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.PROFILE_PROFILE_NAME + " = ?"); query.setString(1, profileName); results = query.executeQuery(); if (results.next()) { Object toReturn = results.getObject(Constants.GENERIC_ID); query.close(); return (Integer) toReturn; } query.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return null; }
java
public Integer getIdFromName(String profileName) { PreparedStatement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { query = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_PROFILE + " WHERE " + Constants.PROFILE_PROFILE_NAME + " = ?"); query.setString(1, profileName); results = query.executeQuery(); if (results.next()) { Object toReturn = results.getObject(Constants.GENERIC_ID); query.close(); return (Integer) toReturn; } query.close(); } catch (SQLException e) { e.printStackTrace(); } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return null; }
[ "public", "Integer", "getIdFromName", "(", "String", "profileName", ")", "{", "PreparedStatement", "query", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "query", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT * FROM \"", "+", "Constants", ".", "DB_TABLE_PROFILE", "+", "\" WHERE \"", "+", "Constants", ".", "PROFILE_PROFILE_NAME", "+", "\" = ?\"", ")", ";", "query", ".", "setString", "(", "1", ",", "profileName", ")", ";", "results", "=", "query", ".", "executeQuery", "(", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "Object", "toReturn", "=", "results", ".", "getObject", "(", "Constants", ".", "GENERIC_ID", ")", ";", "query", ".", "close", "(", ")", ";", "return", "(", "Integer", ")", "toReturn", ";", "}", "query", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "query", "!=", "null", ")", "{", "query", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "null", ";", "}" ]
Obtain the ID associated with a profile name @param profileName profile name @return ID of profile
[ "Obtain", "the", "ID", "associated", "with", "a", "profile", "name" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/ProfileService.java#L321-L353
164,760
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java
ControllerUtils.convertPathIdentifier
public static Integer convertPathIdentifier(String identifier, Integer profileId) throws Exception { Integer pathId = -1; try { pathId = Integer.parseInt(identifier); } catch (NumberFormatException ne) { // this is OK.. just means it's not a # if (profileId == null) throw new Exception("A profileId must be specified"); pathId = PathOverrideService.getInstance().getPathId(identifier, profileId); } return pathId; }
java
public static Integer convertPathIdentifier(String identifier, Integer profileId) throws Exception { Integer pathId = -1; try { pathId = Integer.parseInt(identifier); } catch (NumberFormatException ne) { // this is OK.. just means it's not a # if (profileId == null) throw new Exception("A profileId must be specified"); pathId = PathOverrideService.getInstance().getPathId(identifier, profileId); } return pathId; }
[ "public", "static", "Integer", "convertPathIdentifier", "(", "String", "identifier", ",", "Integer", "profileId", ")", "throws", "Exception", "{", "Integer", "pathId", "=", "-", "1", ";", "try", "{", "pathId", "=", "Integer", ".", "parseInt", "(", "identifier", ")", ";", "}", "catch", "(", "NumberFormatException", "ne", ")", "{", "// this is OK.. just means it's not a #", "if", "(", "profileId", "==", "null", ")", "throw", "new", "Exception", "(", "\"A profileId must be specified\"", ")", ";", "pathId", "=", "PathOverrideService", ".", "getInstance", "(", ")", ".", "getPathId", "(", "identifier", ",", "profileId", ")", ";", "}", "return", "pathId", ";", "}" ]
Obtain the path ID for a profile @param identifier Can be the path ID, or friendly name @param profileId @return @throws Exception
[ "Obtain", "the", "path", "ID", "for", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java#L36-L49
164,761
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java
ControllerUtils.convertProfileIdentifier
public static Integer convertProfileIdentifier(String profileIdentifier) throws Exception { Integer profileId = -1; if (profileIdentifier == null) { throw new Exception("A profileIdentifier must be specified"); } else { try { profileId = Integer.parseInt(profileIdentifier); } catch (NumberFormatException ne) { // this is OK.. just means it's not a # // try to get it by name instead profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } } logger.info("Profile id is {}", profileId); return profileId; }
java
public static Integer convertProfileIdentifier(String profileIdentifier) throws Exception { Integer profileId = -1; if (profileIdentifier == null) { throw new Exception("A profileIdentifier must be specified"); } else { try { profileId = Integer.parseInt(profileIdentifier); } catch (NumberFormatException ne) { // this is OK.. just means it's not a # // try to get it by name instead profileId = ProfileService.getInstance().getIdFromName(profileIdentifier); } } logger.info("Profile id is {}", profileId); return profileId; }
[ "public", "static", "Integer", "convertProfileIdentifier", "(", "String", "profileIdentifier", ")", "throws", "Exception", "{", "Integer", "profileId", "=", "-", "1", ";", "if", "(", "profileIdentifier", "==", "null", ")", "{", "throw", "new", "Exception", "(", "\"A profileIdentifier must be specified\"", ")", ";", "}", "else", "{", "try", "{", "profileId", "=", "Integer", ".", "parseInt", "(", "profileIdentifier", ")", ";", "}", "catch", "(", "NumberFormatException", "ne", ")", "{", "// this is OK.. just means it's not a #", "// try to get it by name instead", "profileId", "=", "ProfileService", ".", "getInstance", "(", ")", ".", "getIdFromName", "(", "profileIdentifier", ")", ";", "}", "}", "logger", ".", "info", "(", "\"Profile id is {}\"", ",", "profileId", ")", ";", "return", "profileId", ";", "}" ]
Obtain the profile identifier. @param profileIdentifier Can be profile ID, or friendly name @return @throws Exception
[ "Obtain", "the", "profile", "identifier", "." ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java#L58-L74
164,762
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java
ControllerUtils.convertOverrideIdentifier
public static Integer convertOverrideIdentifier(String overrideIdentifier) throws Exception { Integer overrideId = -1; try { // there is an issue with parseInt where it does not parse negative values correctly boolean isNegative = false; if (overrideIdentifier.startsWith("-")) { isNegative = true; overrideIdentifier = overrideIdentifier.substring(1); } overrideId = Integer.parseInt(overrideIdentifier); if (isNegative) { overrideId = 0 - overrideId; } } catch (NumberFormatException ne) { // this is OK.. just means it's not a # // split into two parts String className = null; String methodName = null; int lastDot = overrideIdentifier.lastIndexOf("."); className = overrideIdentifier.substring(0, lastDot); methodName = overrideIdentifier.substring(lastDot + 1); overrideId = OverrideService.getInstance().getOverrideIdForMethod(className, methodName); } return overrideId; }
java
public static Integer convertOverrideIdentifier(String overrideIdentifier) throws Exception { Integer overrideId = -1; try { // there is an issue with parseInt where it does not parse negative values correctly boolean isNegative = false; if (overrideIdentifier.startsWith("-")) { isNegative = true; overrideIdentifier = overrideIdentifier.substring(1); } overrideId = Integer.parseInt(overrideIdentifier); if (isNegative) { overrideId = 0 - overrideId; } } catch (NumberFormatException ne) { // this is OK.. just means it's not a # // split into two parts String className = null; String methodName = null; int lastDot = overrideIdentifier.lastIndexOf("."); className = overrideIdentifier.substring(0, lastDot); methodName = overrideIdentifier.substring(lastDot + 1); overrideId = OverrideService.getInstance().getOverrideIdForMethod(className, methodName); } return overrideId; }
[ "public", "static", "Integer", "convertOverrideIdentifier", "(", "String", "overrideIdentifier", ")", "throws", "Exception", "{", "Integer", "overrideId", "=", "-", "1", ";", "try", "{", "// there is an issue with parseInt where it does not parse negative values correctly", "boolean", "isNegative", "=", "false", ";", "if", "(", "overrideIdentifier", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "isNegative", "=", "true", ";", "overrideIdentifier", "=", "overrideIdentifier", ".", "substring", "(", "1", ")", ";", "}", "overrideId", "=", "Integer", ".", "parseInt", "(", "overrideIdentifier", ")", ";", "if", "(", "isNegative", ")", "{", "overrideId", "=", "0", "-", "overrideId", ";", "}", "}", "catch", "(", "NumberFormatException", "ne", ")", "{", "// this is OK.. just means it's not a #", "// split into two parts", "String", "className", "=", "null", ";", "String", "methodName", "=", "null", ";", "int", "lastDot", "=", "overrideIdentifier", ".", "lastIndexOf", "(", "\".\"", ")", ";", "className", "=", "overrideIdentifier", ".", "substring", "(", "0", ",", "lastDot", ")", ";", "methodName", "=", "overrideIdentifier", ".", "substring", "(", "lastDot", "+", "1", ")", ";", "overrideId", "=", "OverrideService", ".", "getInstance", "(", ")", ".", "getOverrideIdForMethod", "(", "className", ",", "methodName", ")", ";", "}", "return", "overrideId", ";", "}" ]
Obtain override ID @param overrideIdentifier can be the override ID or class name @return @throws Exception
[ "Obtain", "override", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java#L83-L112
164,763
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java
ControllerUtils.convertProfileAndPathIdentifier
public static Identifiers convertProfileAndPathIdentifier(String profileIdentifier, String pathIdentifier) throws Exception { Identifiers id = new Identifiers(); Integer profileId = null; try { profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); } catch (Exception e) { // this is OK for this since it isn't always needed } Integer pathId = convertPathIdentifier(pathIdentifier, profileId); id.setProfileId(profileId); id.setPathId(pathId); return id; }
java
public static Identifiers convertProfileAndPathIdentifier(String profileIdentifier, String pathIdentifier) throws Exception { Identifiers id = new Identifiers(); Integer profileId = null; try { profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); } catch (Exception e) { // this is OK for this since it isn't always needed } Integer pathId = convertPathIdentifier(pathIdentifier, profileId); id.setProfileId(profileId); id.setPathId(pathId); return id; }
[ "public", "static", "Identifiers", "convertProfileAndPathIdentifier", "(", "String", "profileIdentifier", ",", "String", "pathIdentifier", ")", "throws", "Exception", "{", "Identifiers", "id", "=", "new", "Identifiers", "(", ")", ";", "Integer", "profileId", "=", "null", ";", "try", "{", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// this is OK for this since it isn't always needed", "}", "Integer", "pathId", "=", "convertPathIdentifier", "(", "pathIdentifier", ",", "profileId", ")", ";", "id", ".", "setProfileId", "(", "profileId", ")", ";", "id", ".", "setPathId", "(", "pathId", ")", ";", "return", "id", ";", "}" ]
Obtain the IDs of profile and path as Identifiers @param profileIdentifier actual ID or friendly name of profile @param pathIdentifier actual ID or friendly name of path @return @throws Exception
[ "Obtain", "the", "IDs", "of", "profile", "and", "path", "as", "Identifiers" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ControllerUtils.java#L122-L137
164,764
groupon/odo
client/src/main/java/com/groupon/odo/client/PathValueClient.java
PathValueClient.getPathFromEndpoint
public JSONObject getPathFromEndpoint(String pathValue, String requestType) throws Exception { int type = getRequestTypeFromString(requestType); String url = BASE_PATH; JSONObject response = new JSONObject(doGet(url, null)); JSONArray paths = response.getJSONArray("paths"); for (int i = 0; i < paths.length(); i++) { JSONObject path = paths.getJSONObject(i); if (path.getString("path").equals(pathValue) && path.getInt("requestType") == type) { return path; } } return null; }
java
public JSONObject getPathFromEndpoint(String pathValue, String requestType) throws Exception { int type = getRequestTypeFromString(requestType); String url = BASE_PATH; JSONObject response = new JSONObject(doGet(url, null)); JSONArray paths = response.getJSONArray("paths"); for (int i = 0; i < paths.length(); i++) { JSONObject path = paths.getJSONObject(i); if (path.getString("path").equals(pathValue) && path.getInt("requestType") == type) { return path; } } return null; }
[ "public", "JSONObject", "getPathFromEndpoint", "(", "String", "pathValue", ",", "String", "requestType", ")", "throws", "Exception", "{", "int", "type", "=", "getRequestTypeFromString", "(", "requestType", ")", ";", "String", "url", "=", "BASE_PATH", ";", "JSONObject", "response", "=", "new", "JSONObject", "(", "doGet", "(", "url", ",", "null", ")", ")", ";", "JSONArray", "paths", "=", "response", ".", "getJSONArray", "(", "\"paths\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "paths", ".", "length", "(", ")", ";", "i", "++", ")", "{", "JSONObject", "path", "=", "paths", ".", "getJSONObject", "(", "i", ")", ";", "if", "(", "path", ".", "getString", "(", "\"path\"", ")", ".", "equals", "(", "pathValue", ")", "&&", "path", ".", "getInt", "(", "\"requestType\"", ")", "==", "type", ")", "{", "return", "path", ";", "}", "}", "return", "null", ";", "}" ]
Retrieves the path using the endpoint value @param pathValue - path (endpoint) value @param requestType - "GET", "POST", etc @return Path or null @throws Exception exception
[ "Retrieves", "the", "path", "using", "the", "endpoint", "value" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/PathValueClient.java#L43-L55
164,765
groupon/odo
client/src/main/java/com/groupon/odo/client/PathValueClient.java
PathValueClient.setDefaultCustomResponse
public static boolean setDefaultCustomResponse(String pathValue, String requestType, String customData) { try { JSONObject profile = getDefaultProfile(); String profileName = profile.getString("name"); PathValueClient client = new PathValueClient(profileName, false); return client.setCustomResponse(pathValue, requestType, customData); } catch (Exception e) { e.printStackTrace(); } return false; }
java
public static boolean setDefaultCustomResponse(String pathValue, String requestType, String customData) { try { JSONObject profile = getDefaultProfile(); String profileName = profile.getString("name"); PathValueClient client = new PathValueClient(profileName, false); return client.setCustomResponse(pathValue, requestType, customData); } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "static", "boolean", "setDefaultCustomResponse", "(", "String", "pathValue", ",", "String", "requestType", ",", "String", "customData", ")", "{", "try", "{", "JSONObject", "profile", "=", "getDefaultProfile", "(", ")", ";", "String", "profileName", "=", "profile", ".", "getString", "(", "\"name\"", ")", ";", "PathValueClient", "client", "=", "new", "PathValueClient", "(", "profileName", ",", "false", ")", ";", "return", "client", ".", "setCustomResponse", "(", "pathValue", ",", "requestType", ",", "customData", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Sets a custom response on an endpoint using default profile and client @param pathValue path (endpoint) value @param requestType path request type. "GET", "POST", etc @param customData custom response data @return true if success, false otherwise
[ "Sets", "a", "custom", "response", "on", "an", "endpoint", "using", "default", "profile", "and", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/PathValueClient.java#L65-L75
164,766
groupon/odo
client/src/main/java/com/groupon/odo/client/PathValueClient.java
PathValueClient.removeDefaultCustomResponse
public static boolean removeDefaultCustomResponse(String pathValue, String requestType) { try { JSONObject profile = getDefaultProfile(); String profileName = profile.getString("name"); PathValueClient client = new PathValueClient(profileName, false); return client.removeCustomResponse(pathValue, requestType); } catch (Exception e) { e.printStackTrace(); } return false; }
java
public static boolean removeDefaultCustomResponse(String pathValue, String requestType) { try { JSONObject profile = getDefaultProfile(); String profileName = profile.getString("name"); PathValueClient client = new PathValueClient(profileName, false); return client.removeCustomResponse(pathValue, requestType); } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "static", "boolean", "removeDefaultCustomResponse", "(", "String", "pathValue", ",", "String", "requestType", ")", "{", "try", "{", "JSONObject", "profile", "=", "getDefaultProfile", "(", ")", ";", "String", "profileName", "=", "profile", ".", "getString", "(", "\"name\"", ")", ";", "PathValueClient", "client", "=", "new", "PathValueClient", "(", "profileName", ",", "false", ")", ";", "return", "client", ".", "removeCustomResponse", "(", "pathValue", ",", "requestType", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Remove any overrides for an endpoint on the default profile, client @param pathValue path (endpoint) value @param requestType path request type. "GET", "POST", etc @return true if success, false otherwise
[ "Remove", "any", "overrides", "for", "an", "endpoint", "on", "the", "default", "profile", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/PathValueClient.java#L84-L94
164,767
groupon/odo
client/src/main/java/com/groupon/odo/client/PathValueClient.java
PathValueClient.removeCustomResponse
public boolean removeCustomResponse(String pathValue, String requestType) { try { JSONObject path = getPathFromEndpoint(pathValue, requestType); if (path == null) { return false; } String pathId = path.getString("pathId"); return resetResponseOverride(pathId); } catch (Exception e) { e.printStackTrace(); } return false; }
java
public boolean removeCustomResponse(String pathValue, String requestType) { try { JSONObject path = getPathFromEndpoint(pathValue, requestType); if (path == null) { return false; } String pathId = path.getString("pathId"); return resetResponseOverride(pathId); } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "boolean", "removeCustomResponse", "(", "String", "pathValue", ",", "String", "requestType", ")", "{", "try", "{", "JSONObject", "path", "=", "getPathFromEndpoint", "(", "pathValue", ",", "requestType", ")", ";", "if", "(", "path", "==", "null", ")", "{", "return", "false", ";", "}", "String", "pathId", "=", "path", ".", "getString", "(", "\"pathId\"", ")", ";", "return", "resetResponseOverride", "(", "pathId", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Remove any overrides for an endpoint @param pathValue path (endpoint) value @param requestType path request type. "GET", "POST", etc @return true if success, false otherwise
[ "Remove", "any", "overrides", "for", "an", "endpoint" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/PathValueClient.java#L103-L115
164,768
groupon/odo
client/src/main/java/com/groupon/odo/client/PathValueClient.java
PathValueClient.setCustomResponse
public boolean setCustomResponse(String pathValue, String requestType, String customData) { try { JSONObject path = getPathFromEndpoint(pathValue, requestType); if (path == null) { String pathName = pathValue; createPath(pathName, pathValue, requestType); path = getPathFromEndpoint(pathValue, requestType); } String pathId = path.getString("pathId"); resetResponseOverride(pathId); setCustomResponse(pathId, customData); return toggleResponseOverride(pathId, true); } catch (Exception e) { e.printStackTrace(); } return false; }
java
public boolean setCustomResponse(String pathValue, String requestType, String customData) { try { JSONObject path = getPathFromEndpoint(pathValue, requestType); if (path == null) { String pathName = pathValue; createPath(pathName, pathValue, requestType); path = getPathFromEndpoint(pathValue, requestType); } String pathId = path.getString("pathId"); resetResponseOverride(pathId); setCustomResponse(pathId, customData); return toggleResponseOverride(pathId, true); } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "boolean", "setCustomResponse", "(", "String", "pathValue", ",", "String", "requestType", ",", "String", "customData", ")", "{", "try", "{", "JSONObject", "path", "=", "getPathFromEndpoint", "(", "pathValue", ",", "requestType", ")", ";", "if", "(", "path", "==", "null", ")", "{", "String", "pathName", "=", "pathValue", ";", "createPath", "(", "pathName", ",", "pathValue", ",", "requestType", ")", ";", "path", "=", "getPathFromEndpoint", "(", "pathValue", ",", "requestType", ")", ";", "}", "String", "pathId", "=", "path", ".", "getString", "(", "\"pathId\"", ")", ";", "resetResponseOverride", "(", "pathId", ")", ";", "setCustomResponse", "(", "pathId", ",", "customData", ")", ";", "return", "toggleResponseOverride", "(", "pathId", ",", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Sets a custom response on an endpoint @param pathValue path (endpoint) value @param requestType path request type. "GET", "POST", etc @param customData custom response data @return true if success, false otherwise
[ "Sets", "a", "custom", "response", "on", "an", "endpoint" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/PathValueClient.java#L125-L141
164,769
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.getClientList
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getClientList(Model model, @PathVariable("profileIdentifier") String profileIdentifier) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); return Utils.getJQGridJSON(clientService.findAllClients(profileId), "clients"); }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getClientList(Model model, @PathVariable("profileIdentifier") String profileIdentifier) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); return Utils.getJQGridJSON(clientService.findAllClients(profileId), "clients"); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getClientList", "(", "Model", "model", ",", "@", "PathVariable", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ")", "throws", "Exception", "{", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "return", "Utils", ".", "getJQGridJSON", "(", "clientService", ".", "findAllClients", "(", "profileId", ")", ",", "\"clients\"", ")", ";", "}" ]
Returns information about all clients for a profile @param model @param profileIdentifier @return @throws Exception
[ "Returns", "information", "about", "all", "clients", "for", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L65-L73
164,770
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.getClient
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", clientService.findClient(clientUUID, profileId)); return valueHash; }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", clientService.findClient(clientUUID, profileId)); return valueHash; }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients/{clientUUID}\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getClient", "(", "Model", "model", ",", "@", "PathVariable", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ",", "@", "PathVariable", "(", "\"clientUUID\"", ")", "String", "clientUUID", ")", "throws", "Exception", "{", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "valueHash", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "valueHash", ".", "put", "(", "\"client\"", ",", "clientService", ".", "findClient", "(", "clientUUID", ",", "profileId", ")", ")", ";", "return", "valueHash", ";", "}" ]
Returns information for a specific client @param model @param profileIdentifier @param clientUUID @return @throws Exception
[ "Returns", "information", "for", "a", "specific", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L84-L94
164,771
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.addClient
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @RequestParam(required = false) String friendlyName) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); // make sure client with this name does not already exist if (null != clientService.findClientFromFriendlyName(profileId, friendlyName)) { throw new Exception("Cannot add client. Friendly name already in use."); } Client client = clientService.add(profileId); // set friendly name if it was specified if (friendlyName != null) { clientService.setFriendlyName(profileId, client.getUUID(), friendlyName); client.setFriendlyName(friendlyName); } HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", client); return valueHash; }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @RequestParam(required = false) String friendlyName) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); // make sure client with this name does not already exist if (null != clientService.findClientFromFriendlyName(profileId, friendlyName)) { throw new Exception("Cannot add client. Friendly name already in use."); } Client client = clientService.add(profileId); // set friendly name if it was specified if (friendlyName != null) { clientService.setFriendlyName(profileId, client.getUUID(), friendlyName); client.setFriendlyName(friendlyName); } HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", client); return valueHash; }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "addClient", "(", "Model", "model", ",", "@", "PathVariable", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "String", "friendlyName", ")", "throws", "Exception", "{", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "// make sure client with this name does not already exist", "if", "(", "null", "!=", "clientService", ".", "findClientFromFriendlyName", "(", "profileId", ",", "friendlyName", ")", ")", "{", "throw", "new", "Exception", "(", "\"Cannot add client. Friendly name already in use.\"", ")", ";", "}", "Client", "client", "=", "clientService", ".", "add", "(", "profileId", ")", ";", "// set friendly name if it was specified", "if", "(", "friendlyName", "!=", "null", ")", "{", "clientService", ".", "setFriendlyName", "(", "profileId", ",", "client", ".", "getUUID", "(", ")", ",", "friendlyName", ")", ";", "client", ".", "setFriendlyName", "(", "friendlyName", ")", ";", "}", "HashMap", "<", "String", ",", "Object", ">", "valueHash", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "valueHash", ".", "put", "(", "\"client\"", ",", "client", ")", ";", "return", "valueHash", ";", "}" ]
Returns a new client id for the profileIdentifier @param model @param profileIdentifier @return json with a new client_id @throws Exception
[ "Returns", "a", "new", "client", "id", "for", "the", "profileIdentifier" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L104-L128
164,772
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.updateClient
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> updateClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID, @RequestParam(required = false) Boolean active, @RequestParam(required = false) String friendlyName, @RequestParam(required = false) Boolean reset) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); if (active != null) { logger.info("Active: {}", active); clientService.updateActive(profileId, clientUUID, active); } if (friendlyName != null) { clientService.setFriendlyName(profileId, clientUUID, friendlyName); } if (reset != null && reset) { clientService.reset(profileId, clientUUID); } HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", clientService.findClient(clientUUID, profileId)); return valueHash; }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> updateClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID, @RequestParam(required = false) Boolean active, @RequestParam(required = false) String friendlyName, @RequestParam(required = false) Boolean reset) throws Exception { Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); if (active != null) { logger.info("Active: {}", active); clientService.updateActive(profileId, clientUUID, active); } if (friendlyName != null) { clientService.setFriendlyName(profileId, clientUUID, friendlyName); } if (reset != null && reset) { clientService.reset(profileId, clientUUID); } HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("client", clientService.findClient(clientUUID, profileId)); return valueHash; }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients/{clientUUID}\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "updateClient", "(", "Model", "model", ",", "@", "PathVariable", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ",", "@", "PathVariable", "(", "\"clientUUID\"", ")", "String", "clientUUID", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "Boolean", "active", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "String", "friendlyName", ",", "@", "RequestParam", "(", "required", "=", "false", ")", "Boolean", "reset", ")", "throws", "Exception", "{", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "if", "(", "active", "!=", "null", ")", "{", "logger", ".", "info", "(", "\"Active: {}\"", ",", "active", ")", ";", "clientService", ".", "updateActive", "(", "profileId", ",", "clientUUID", ",", "active", ")", ";", "}", "if", "(", "friendlyName", "!=", "null", ")", "{", "clientService", ".", "setFriendlyName", "(", "profileId", ",", "clientUUID", ",", "friendlyName", ")", ";", "}", "if", "(", "reset", "!=", "null", "&&", "reset", ")", "{", "clientService", ".", "reset", "(", "profileId", ",", "clientUUID", ")", ";", "}", "HashMap", "<", "String", ",", "Object", ">", "valueHash", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "valueHash", ".", "put", "(", "\"client\"", ",", "clientService", ".", "findClient", "(", "clientUUID", ",", "profileId", ")", ")", ";", "return", "valueHash", ";", "}" ]
Update properties for a specific client id @param model @param profileIdentifier @param clientUUID @param active - true false depending on if the client should be active @param reset - true to reset the state of a client(clears settings for all paths and disables the client) @return @throws Exception
[ "Update", "properties", "for", "a", "specific", "client", "id" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L141-L168
164,773
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.deleteClient
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.DELETE) public @ResponseBody HashMap<String, Object> deleteClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID) throws Exception { logger.info("Attempting to remove the following client: {}", clientUUID); if (clientUUID.compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) == 0) throw new Exception("Default client cannot be deleted"); Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); clientService.remove(profileId, clientUUID); HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("clients", clientService.findAllClients(profileId)); return valueHash; }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.DELETE) public @ResponseBody HashMap<String, Object> deleteClient(Model model, @PathVariable("profileIdentifier") String profileIdentifier, @PathVariable("clientUUID") String clientUUID) throws Exception { logger.info("Attempting to remove the following client: {}", clientUUID); if (clientUUID.compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) == 0) throw new Exception("Default client cannot be deleted"); Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); clientService.remove(profileId, clientUUID); HashMap<String, Object> valueHash = new HashMap<String, Object>(); valueHash.put("clients", clientService.findAllClients(profileId)); return valueHash; }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients/{clientUUID}\"", ",", "method", "=", "RequestMethod", ".", "DELETE", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "deleteClient", "(", "Model", "model", ",", "@", "PathVariable", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ",", "@", "PathVariable", "(", "\"clientUUID\"", ")", "String", "clientUUID", ")", "throws", "Exception", "{", "logger", ".", "info", "(", "\"Attempting to remove the following client: {}\"", ",", "clientUUID", ")", ";", "if", "(", "clientUUID", ".", "compareTo", "(", "Constants", ".", "PROFILE_CLIENT_DEFAULT_ID", ")", "==", "0", ")", "throw", "new", "Exception", "(", "\"Default client cannot be deleted\"", ")", ";", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "clientService", ".", "remove", "(", "profileId", ",", "clientUUID", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "valueHash", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "valueHash", ".", "put", "(", "\"clients\"", ",", "clientService", ".", "findAllClients", "(", "profileId", ")", ")", ";", "return", "valueHash", ";", "}" ]
Deletes a specific client id for a profile @param model @param profileIdentifier @param clientUUID @return returns the table of the remaining clients or an exception if deletion failed for some reason @throws Exception
[ "Deletes", "a", "specific", "client", "id", "for", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L195-L211
164,774
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java
ClientController.deleteClient
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/delete", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> deleteClient(Model model, @RequestParam("profileIdentifier") String profileIdentifier, @RequestParam("clientUUID") String[] clientUUID) throws Exception { logger.info("Attempting to remove clients from the profile: ", profileIdentifier); logger.info("Attempting to remove the following clients: {}", Arrays.toString(clientUUID)); HashMap<String, Object> valueHash = new HashMap<String, Object>(); Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); for( int i = 0; i < clientUUID.length; i++ ) { if (clientUUID[i].compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) == 0) throw new Exception("Default client cannot be deleted"); clientService.remove(profileId, clientUUID[i]); } valueHash.put("clients", clientService.findAllClients(profileId)); return valueHash; }
java
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/delete", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> deleteClient(Model model, @RequestParam("profileIdentifier") String profileIdentifier, @RequestParam("clientUUID") String[] clientUUID) throws Exception { logger.info("Attempting to remove clients from the profile: ", profileIdentifier); logger.info("Attempting to remove the following clients: {}", Arrays.toString(clientUUID)); HashMap<String, Object> valueHash = new HashMap<String, Object>(); Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier); for( int i = 0; i < clientUUID.length; i++ ) { if (clientUUID[i].compareTo(Constants.PROFILE_CLIENT_DEFAULT_ID) == 0) throw new Exception("Default client cannot be deleted"); clientService.remove(profileId, clientUUID[i]); } valueHash.put("clients", clientService.findAllClients(profileId)); return valueHash; }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile/{profileIdentifier}/clients/delete\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "deleteClient", "(", "Model", "model", ",", "@", "RequestParam", "(", "\"profileIdentifier\"", ")", "String", "profileIdentifier", ",", "@", "RequestParam", "(", "\"clientUUID\"", ")", "String", "[", "]", "clientUUID", ")", "throws", "Exception", "{", "logger", ".", "info", "(", "\"Attempting to remove clients from the profile: \"", ",", "profileIdentifier", ")", ";", "logger", ".", "info", "(", "\"Attempting to remove the following clients: {}\"", ",", "Arrays", ".", "toString", "(", "clientUUID", ")", ")", ";", "HashMap", "<", "String", ",", "Object", ">", "valueHash", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "Integer", "profileId", "=", "ControllerUtils", ".", "convertProfileIdentifier", "(", "profileIdentifier", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "clientUUID", ".", "length", ";", "i", "++", ")", "{", "if", "(", "clientUUID", "[", "i", "]", ".", "compareTo", "(", "Constants", ".", "PROFILE_CLIENT_DEFAULT_ID", ")", "==", "0", ")", "throw", "new", "Exception", "(", "\"Default client cannot be deleted\"", ")", ";", "clientService", ".", "remove", "(", "profileId", ",", "clientUUID", "[", "i", "]", ")", ";", "}", "valueHash", ".", "put", "(", "\"clients\"", ",", "clientService", ".", "findAllClients", "(", "profileId", ")", ")", ";", "return", "valueHash", ";", "}" ]
Bulk delete clients from a profile. @param model @param profileIdentifier @param clientUUID @return returns the table of the remaining clients or an exception if deletion failed for some reason @throws Exception
[ "Bulk", "delete", "clients", "from", "a", "profile", "." ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ClientController.java#L222-L245
164,775
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/PluginController.java
PluginController.getPluginInformation
@RequestMapping(value = "/api/plugins", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getPluginInformation() { return pluginInformation(); }
java
@RequestMapping(value = "/api/plugins", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getPluginInformation() { return pluginInformation(); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/plugins\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getPluginInformation", "(", ")", "{", "return", "pluginInformation", "(", ")", ";", "}" ]
Obtain plugin information @return
[ "Obtain", "plugin", "information" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/PluginController.java#L41-L46
164,776
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/PluginController.java
PluginController.addPluginPath
@RequestMapping(value = "/api/plugins", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addPluginPath(Model model, Plugin add) throws Exception { PluginManager.getInstance().addPluginPath(add.getPath()); return pluginInformation(); }
java
@RequestMapping(value = "/api/plugins", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addPluginPath(Model model, Plugin add) throws Exception { PluginManager.getInstance().addPluginPath(add.getPath()); return pluginInformation(); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/plugins\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "addPluginPath", "(", "Model", "model", ",", "Plugin", "add", ")", "throws", "Exception", "{", "PluginManager", ".", "getInstance", "(", ")", ".", "addPluginPath", "(", "add", ".", "getPath", "(", ")", ")", ";", "return", "pluginInformation", "(", ")", ";", "}" ]
Add a plugin path @param model @param add @return @throws Exception
[ "Add", "a", "plugin", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/PluginController.java#L66-L73
164,777
groupon/odo
examples/api-usage/src/main/java/com/groupon/odo/sample/SampleClient.java
SampleClient.addOverrideToPath
public static void addOverrideToPath() throws Exception { Client client = new Client("ProfileName", false); // Use the fully qualified name for a plugin override. client.addMethodToResponseOverride("Test Path", "com.groupon.odo.sample.Common.delay"); // The third argument is the ordinal - the nth instance of this override added to this path // The final arguments count and type are determined by the override. "delay" used in this sample // has a single int argument - # of milliseconds delay to simulate client.setMethodArguments("Test Path", "com.groupon.odo.sample.Common.delay", 1, "100"); }
java
public static void addOverrideToPath() throws Exception { Client client = new Client("ProfileName", false); // Use the fully qualified name for a plugin override. client.addMethodToResponseOverride("Test Path", "com.groupon.odo.sample.Common.delay"); // The third argument is the ordinal - the nth instance of this override added to this path // The final arguments count and type are determined by the override. "delay" used in this sample // has a single int argument - # of milliseconds delay to simulate client.setMethodArguments("Test Path", "com.groupon.odo.sample.Common.delay", 1, "100"); }
[ "public", "static", "void", "addOverrideToPath", "(", ")", "throws", "Exception", "{", "Client", "client", "=", "new", "Client", "(", "\"ProfileName\"", ",", "false", ")", ";", "// Use the fully qualified name for a plugin override.", "client", ".", "addMethodToResponseOverride", "(", "\"Test Path\"", ",", "\"com.groupon.odo.sample.Common.delay\"", ")", ";", "// The third argument is the ordinal - the nth instance of this override added to this path", "// The final arguments count and type are determined by the override. \"delay\" used in this sample", "// has a single int argument - # of milliseconds delay to simulate", "client", ".", "setMethodArguments", "(", "\"Test Path\"", ",", "\"com.groupon.odo.sample.Common.delay\"", ",", "1", ",", "\"100\"", ")", ";", "}" ]
Demonstrates how to add an override to an existing path
[ "Demonstrates", "how", "to", "add", "an", "override", "to", "an", "existing", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/examples/api-usage/src/main/java/com/groupon/odo/sample/SampleClient.java#L42-L52
164,778
groupon/odo
examples/api-usage/src/main/java/com/groupon/odo/sample/SampleClient.java
SampleClient.getHistory
public static void getHistory() throws Exception{ Client client = new Client("ProfileName", false); // Obtain the 100 history entries starting from offset 0 History[] history = client.refreshHistory(100, 0); client.clearHistory(); }
java
public static void getHistory() throws Exception{ Client client = new Client("ProfileName", false); // Obtain the 100 history entries starting from offset 0 History[] history = client.refreshHistory(100, 0); client.clearHistory(); }
[ "public", "static", "void", "getHistory", "(", ")", "throws", "Exception", "{", "Client", "client", "=", "new", "Client", "(", "\"ProfileName\"", ",", "false", ")", ";", "// Obtain the 100 history entries starting from offset 0", "History", "[", "]", "history", "=", "client", ".", "refreshHistory", "(", "100", ",", "0", ")", ";", "client", ".", "clearHistory", "(", ")", ";", "}" ]
Demonstrates obtaining the request history data from a test run
[ "Demonstrates", "obtaining", "the", "request", "history", "data", "from", "a", "test", "run" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/examples/api-usage/src/main/java/com/groupon/odo/sample/SampleClient.java#L99-L106
164,779
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java
ProfileController.list
@RequestMapping(value = "/profiles", method = RequestMethod.GET) public String list(Model model) { Profile profiles = new Profile(); model.addAttribute("addNewProfile", profiles); model.addAttribute("version", Constants.VERSION); logger.info("Loading initial page"); return "profiles"; }
java
@RequestMapping(value = "/profiles", method = RequestMethod.GET) public String list(Model model) { Profile profiles = new Profile(); model.addAttribute("addNewProfile", profiles); model.addAttribute("version", Constants.VERSION); logger.info("Loading initial page"); return "profiles"; }
[ "@", "RequestMapping", "(", "value", "=", "\"/profiles\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "String", "list", "(", "Model", "model", ")", "{", "Profile", "profiles", "=", "new", "Profile", "(", ")", ";", "model", ".", "addAttribute", "(", "\"addNewProfile\"", ",", "profiles", ")", ";", "model", ".", "addAttribute", "(", "\"version\"", ",", "Constants", ".", "VERSION", ")", ";", "logger", ".", "info", "(", "\"Loading initial page\"", ")", ";", "return", "\"profiles\"", ";", "}" ]
This is the profiles page. this is the 'regular' page when the url is typed in
[ "This", "is", "the", "profiles", "page", ".", "this", "is", "the", "regular", "page", "when", "the", "url", "is", "typed", "in" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java#L50-L58
164,780
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java
ProfileController.getList
@RequestMapping(value = "/api/profile", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getList(Model model) throws Exception { logger.info("Using a GET request to list profiles"); return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles"); }
java
@RequestMapping(value = "/api/profile", method = RequestMethod.GET) public @ResponseBody HashMap<String, Object> getList(Model model) throws Exception { logger.info("Using a GET request to list profiles"); return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles"); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile\"", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "getList", "(", "Model", "model", ")", "throws", "Exception", "{", "logger", ".", "info", "(", "\"Using a GET request to list profiles\"", ")", ";", "return", "Utils", ".", "getJQGridJSON", "(", "profileService", ".", "findAllProfiles", "(", ")", ",", "\"profiles\"", ")", ";", "}" ]
Obtain collection of profiles @param model @return @throws Exception
[ "Obtain", "collection", "of", "profiles" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java#L67-L73
164,781
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java
ProfileController.addProfile
@RequestMapping(value = "/api/profile", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addProfile(Model model, String name) throws Exception { logger.info("Should be adding the profile name when I hit the enter button={}", name); return Utils.getJQGridJSON(profileService.add(name), "profile"); }
java
@RequestMapping(value = "/api/profile", method = RequestMethod.POST) public @ResponseBody HashMap<String, Object> addProfile(Model model, String name) throws Exception { logger.info("Should be adding the profile name when I hit the enter button={}", name); return Utils.getJQGridJSON(profileService.add(name), "profile"); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile\"", ",", "method", "=", "RequestMethod", ".", "POST", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "addProfile", "(", "Model", "model", ",", "String", "name", ")", "throws", "Exception", "{", "logger", ".", "info", "(", "\"Should be adding the profile name when I hit the enter button={}\"", ",", "name", ")", ";", "return", "Utils", ".", "getJQGridJSON", "(", "profileService", ".", "add", "(", "name", ")", ",", "\"profile\"", ")", ";", "}" ]
Add profile to database, return collection of profile data. Called when 'enter' is hit in the UI instead of 'submit' button @param model @param name @return @throws Exception
[ "Add", "profile", "to", "database", "return", "collection", "of", "profile", "data", ".", "Called", "when", "enter", "is", "hit", "in", "the", "UI", "instead", "of", "submit", "button" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java#L84-L90
164,782
groupon/odo
proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java
ProfileController.deleteProfile
@RequestMapping(value = "/api/profile", method = RequestMethod.DELETE) public @ResponseBody HashMap<String, Object> deleteProfile(Model model, int id) throws Exception { profileService.remove(id); return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles"); }
java
@RequestMapping(value = "/api/profile", method = RequestMethod.DELETE) public @ResponseBody HashMap<String, Object> deleteProfile(Model model, int id) throws Exception { profileService.remove(id); return Utils.getJQGridJSON(profileService.findAllProfiles(), "profiles"); }
[ "@", "RequestMapping", "(", "value", "=", "\"/api/profile\"", ",", "method", "=", "RequestMethod", ".", "DELETE", ")", "public", "@", "ResponseBody", "HashMap", "<", "String", ",", "Object", ">", "deleteProfile", "(", "Model", "model", ",", "int", "id", ")", "throws", "Exception", "{", "profileService", ".", "remove", "(", "id", ")", ";", "return", "Utils", ".", "getJQGridJSON", "(", "profileService", ".", "findAllProfiles", "(", ")", ",", "\"profiles\"", ")", ";", "}" ]
Delete a profile @param model @param id @return @throws Exception
[ "Delete", "a", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxyui/src/main/java/com/groupon/odo/controllers/ProfileController.java#L100-L106
164,783
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java
HistoryService.cullHistory
public void cullHistory(final int profileId, final String clientUUID, final int limit) throws Exception { //Allow only 1 delete thread to run if (threadActive) { return; } threadActive = true; //Create a thread so proxy will continue to work during long delete Thread t1 = new Thread(new Runnable() { @Override public void run() { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is set or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " "; } if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' "; } sqlQuery += ";"; Statement query = sqlConnection.createStatement(); ResultSet results = query.executeQuery(sqlQuery); if (results.next()) { if (results.getInt("COUNT(" + Constants.GENERIC_ID + ")") < (limit + 10000)) { return; } } //Find the last item in the table statement = sqlConnection.prepareStatement("SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" + " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId + " ORDER BY " + Constants.GENERIC_ID + " ASC LIMIT 1"); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { int currentSpot = resultSet.getInt(Constants.GENERIC_ID) + 100; int finalDelete = currentSpot + 10000; //Delete 100 items at a time until 10000 are deleted //Do this so table is unlocked frequently to allow other proxy items to access it while (currentSpot < finalDelete) { PreparedStatement deleteStatement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" + " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId + " AND " + Constants.GENERIC_ID + " < " + currentSpot); deleteStatement.executeUpdate(); currentSpot += 100; } } } catch (Exception e) { e.printStackTrace(); } finally { try { threadActive = false; if (statement != null) { statement.close(); } } catch (Exception e) { } } } }); t1.start(); }
java
public void cullHistory(final int profileId, final String clientUUID, final int limit) throws Exception { //Allow only 1 delete thread to run if (threadActive) { return; } threadActive = true; //Create a thread so proxy will continue to work during long delete Thread t1 = new Thread(new Runnable() { @Override public void run() { PreparedStatement statement = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is set or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " "; } if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' "; } sqlQuery += ";"; Statement query = sqlConnection.createStatement(); ResultSet results = query.executeQuery(sqlQuery); if (results.next()) { if (results.getInt("COUNT(" + Constants.GENERIC_ID + ")") < (limit + 10000)) { return; } } //Find the last item in the table statement = sqlConnection.prepareStatement("SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" + " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId + " ORDER BY " + Constants.GENERIC_ID + " ASC LIMIT 1"); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { int currentSpot = resultSet.getInt(Constants.GENERIC_ID) + 100; int finalDelete = currentSpot + 10000; //Delete 100 items at a time until 10000 are deleted //Do this so table is unlocked frequently to allow other proxy items to access it while (currentSpot < finalDelete) { PreparedStatement deleteStatement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" + " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId + " AND " + Constants.GENERIC_ID + " < " + currentSpot); deleteStatement.executeUpdate(); currentSpot += 100; } } } catch (Exception e) { e.printStackTrace(); } finally { try { threadActive = false; if (statement != null) { statement.close(); } } catch (Exception e) { } } } }); t1.start(); }
[ "public", "void", "cullHistory", "(", "final", "int", "profileId", ",", "final", "String", "clientUUID", ",", "final", "int", "limit", ")", "throws", "Exception", "{", "//Allow only 1 delete thread to run", "if", "(", "threadActive", ")", "{", "return", ";", "}", "threadActive", "=", "true", ";", "//Create a thread so proxy will continue to work during long delete", "Thread", "t1", "=", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "PreparedStatement", "statement", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "String", "sqlQuery", "=", "\"SELECT COUNT(\"", "+", "Constants", ".", "GENERIC_ID", "+", "\") FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" \"", ";", "// see if profileId is set or not (-1)", "if", "(", "profileId", "!=", "-", "1", ")", "{", "sqlQuery", "+=", "\"WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\"=\"", "+", "profileId", "+", "\" \"", ";", "}", "if", "(", "clientUUID", "!=", "null", "&&", "clientUUID", ".", "compareTo", "(", "\"\"", ")", "!=", "0", ")", "{", "sqlQuery", "+=", "\"AND \"", "+", "Constants", ".", "GENERIC_CLIENT_UUID", "+", "\"='\"", "+", "clientUUID", "+", "\"' \"", ";", "}", "sqlQuery", "+=", "\";\"", ";", "Statement", "query", "=", "sqlConnection", ".", "createStatement", "(", ")", ";", "ResultSet", "results", "=", "query", ".", "executeQuery", "(", "sqlQuery", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "if", "(", "results", ".", "getInt", "(", "\"COUNT(\"", "+", "Constants", ".", "GENERIC_ID", "+", "\")\"", ")", "<", "(", "limit", "+", "10000", ")", ")", "{", "return", ";", "}", "}", "//Find the last item in the table", "statement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT \"", "+", "Constants", ".", "GENERIC_ID", "+", "\" FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" WHERE \"", "+", "Constants", ".", "CLIENT_CLIENT_UUID", "+", "\" = \\'\"", "+", "clientUUID", "+", "\"\\'\"", "+", "\" AND \"", "+", "Constants", ".", "CLIENT_PROFILE_ID", "+", "\" = \"", "+", "profileId", "+", "\" ORDER BY \"", "+", "Constants", ".", "GENERIC_ID", "+", "\" ASC LIMIT 1\"", ")", ";", "ResultSet", "resultSet", "=", "statement", ".", "executeQuery", "(", ")", ";", "if", "(", "resultSet", ".", "next", "(", ")", ")", "{", "int", "currentSpot", "=", "resultSet", ".", "getInt", "(", "Constants", ".", "GENERIC_ID", ")", "+", "100", ";", "int", "finalDelete", "=", "currentSpot", "+", "10000", ";", "//Delete 100 items at a time until 10000 are deleted", "//Do this so table is unlocked frequently to allow other proxy items to access it", "while", "(", "currentSpot", "<", "finalDelete", ")", "{", "PreparedStatement", "deleteStatement", "=", "sqlConnection", ".", "prepareStatement", "(", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" WHERE \"", "+", "Constants", ".", "CLIENT_CLIENT_UUID", "+", "\" = \\'\"", "+", "clientUUID", "+", "\"\\'\"", "+", "\" AND \"", "+", "Constants", ".", "CLIENT_PROFILE_ID", "+", "\" = \"", "+", "profileId", "+", "\" AND \"", "+", "Constants", ".", "GENERIC_ID", "+", "\" < \"", "+", "currentSpot", ")", ";", "deleteStatement", ".", "executeUpdate", "(", ")", ";", "currentSpot", "+=", "100", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "try", "{", "threadActive", "=", "false", ";", "if", "(", "statement", "!=", "null", ")", "{", "statement", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "}", ")", ";", "t1", ".", "start", "(", ")", ";", "}" ]
Removes old entries in the history table for the given profile and client UUID @param profileId ID of profile @param clientUUID UUID of client @param limit Maximum number of history entries to remove @throws Exception exception
[ "Removes", "old", "entries", "in", "the", "history", "table", "for", "the", "given", "profile", "and", "client", "UUID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java#L81-L151
164,784
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java
HistoryService.getHistoryCount
public int getHistoryCount(int profileId, String clientUUID, HashMap<String, String[]> searchFilter) { int count = 0; Statement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is set or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " "; } if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' "; } sqlQuery += ";"; logger.info("Query: {}", sqlQuery); query = sqlConnection.createStatement(); results = query.executeQuery(sqlQuery); if (results.next()) { count = results.getInt(1); } query.close(); } catch (Exception e) { } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return count; }
java
public int getHistoryCount(int profileId, String clientUUID, HashMap<String, String[]> searchFilter) { int count = 0; Statement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is set or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " "; } if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' "; } sqlQuery += ";"; logger.info("Query: {}", sqlQuery); query = sqlConnection.createStatement(); results = query.executeQuery(sqlQuery); if (results.next()) { count = results.getInt(1); } query.close(); } catch (Exception e) { } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return count; }
[ "public", "int", "getHistoryCount", "(", "int", "profileId", ",", "String", "clientUUID", ",", "HashMap", "<", "String", ",", "String", "[", "]", ">", "searchFilter", ")", "{", "int", "count", "=", "0", ";", "Statement", "query", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "String", "sqlQuery", "=", "\"SELECT COUNT(\"", "+", "Constants", ".", "GENERIC_ID", "+", "\") FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" \"", ";", "// see if profileId is set or not (-1)", "if", "(", "profileId", "!=", "-", "1", ")", "{", "sqlQuery", "+=", "\"WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\"=\"", "+", "profileId", "+", "\" \"", ";", "}", "if", "(", "clientUUID", "!=", "null", "&&", "clientUUID", ".", "compareTo", "(", "\"\"", ")", "!=", "0", ")", "{", "sqlQuery", "+=", "\"AND \"", "+", "Constants", ".", "GENERIC_CLIENT_UUID", "+", "\"='\"", "+", "clientUUID", "+", "\"' \"", ";", "}", "sqlQuery", "+=", "\";\"", ";", "logger", ".", "info", "(", "\"Query: {}\"", ",", "sqlQuery", ")", ";", "query", "=", "sqlConnection", ".", "createStatement", "(", ")", ";", "results", "=", "query", ".", "executeQuery", "(", "sqlQuery", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "count", "=", "results", ".", "getInt", "(", "1", ")", ";", "}", "query", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "query", "!=", "null", ")", "{", "query", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "count", ";", "}" ]
Returns the number of history entries for a client @param profileId ID of profile @param clientUUID UUID of client @param searchFilter unused @return number of history entries
[ "Returns", "the", "number", "of", "history", "entries", "for", "a", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java#L311-L357
164,785
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java
HistoryService.getHistoryForID
public History getHistoryForID(int id) { History history = null; PreparedStatement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { query = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.GENERIC_ID + "=?"); query.setInt(1, id); logger.info("Query: {}", query.toString()); results = query.executeQuery(); if (results.next()) { history = historyFromSQLResult(results, true, ScriptService.getInstance().getScripts(Constants.SCRIPT_TYPE_HISTORY)); } query.close(); } catch (Exception e) { } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return history; }
java
public History getHistoryForID(int id) { History history = null; PreparedStatement query = null; ResultSet results = null; try (Connection sqlConnection = sqlService.getConnection()) { query = sqlConnection.prepareStatement("SELECT * FROM " + Constants.DB_TABLE_HISTORY + " WHERE " + Constants.GENERIC_ID + "=?"); query.setInt(1, id); logger.info("Query: {}", query.toString()); results = query.executeQuery(); if (results.next()) { history = historyFromSQLResult(results, true, ScriptService.getInstance().getScripts(Constants.SCRIPT_TYPE_HISTORY)); } query.close(); } catch (Exception e) { } finally { try { if (results != null) { results.close(); } } catch (Exception e) { } try { if (query != null) { query.close(); } } catch (Exception e) { } } return history; }
[ "public", "History", "getHistoryForID", "(", "int", "id", ")", "{", "History", "history", "=", "null", ";", "PreparedStatement", "query", "=", "null", ";", "ResultSet", "results", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "query", "=", "sqlConnection", ".", "prepareStatement", "(", "\"SELECT * FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" WHERE \"", "+", "Constants", ".", "GENERIC_ID", "+", "\"=?\"", ")", ";", "query", ".", "setInt", "(", "1", ",", "id", ")", ";", "logger", ".", "info", "(", "\"Query: {}\"", ",", "query", ".", "toString", "(", ")", ")", ";", "results", "=", "query", ".", "executeQuery", "(", ")", ";", "if", "(", "results", ".", "next", "(", ")", ")", "{", "history", "=", "historyFromSQLResult", "(", "results", ",", "true", ",", "ScriptService", ".", "getInstance", "(", ")", ".", "getScripts", "(", "Constants", ".", "SCRIPT_TYPE_HISTORY", ")", ")", ";", "}", "query", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "finally", "{", "try", "{", "if", "(", "results", "!=", "null", ")", "{", "results", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "try", "{", "if", "(", "query", "!=", "null", ")", "{", "query", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "return", "history", ";", "}" ]
Get history for a specific database ID @param id ID of history entry @return History entry
[ "Get", "history", "for", "a", "specific", "database", "ID" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java#L478-L510
164,786
groupon/odo
proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java
HistoryService.clearHistory
public void clearHistory(int profileId, String clientUUID) { PreparedStatement query = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "DELETE FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is null or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId; } // see if clientUUID is null or not if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += " AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "'"; } sqlQuery += ";"; logger.info("Query: {}", sqlQuery); query = sqlConnection.prepareStatement(sqlQuery); query.executeUpdate(); } catch (Exception e) { } finally { try { if (query != null) { query.close(); } } catch (Exception e) { } } }
java
public void clearHistory(int profileId, String clientUUID) { PreparedStatement query = null; try (Connection sqlConnection = sqlService.getConnection()) { String sqlQuery = "DELETE FROM " + Constants.DB_TABLE_HISTORY + " "; // see if profileId is null or not (-1) if (profileId != -1) { sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId; } // see if clientUUID is null or not if (clientUUID != null && clientUUID.compareTo("") != 0) { sqlQuery += " AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "'"; } sqlQuery += ";"; logger.info("Query: {}", sqlQuery); query = sqlConnection.prepareStatement(sqlQuery); query.executeUpdate(); } catch (Exception e) { } finally { try { if (query != null) { query.close(); } } catch (Exception e) { } } }
[ "public", "void", "clearHistory", "(", "int", "profileId", ",", "String", "clientUUID", ")", "{", "PreparedStatement", "query", "=", "null", ";", "try", "(", "Connection", "sqlConnection", "=", "sqlService", ".", "getConnection", "(", ")", ")", "{", "String", "sqlQuery", "=", "\"DELETE FROM \"", "+", "Constants", ".", "DB_TABLE_HISTORY", "+", "\" \"", ";", "// see if profileId is null or not (-1)", "if", "(", "profileId", "!=", "-", "1", ")", "{", "sqlQuery", "+=", "\"WHERE \"", "+", "Constants", ".", "GENERIC_PROFILE_ID", "+", "\"=\"", "+", "profileId", ";", "}", "// see if clientUUID is null or not", "if", "(", "clientUUID", "!=", "null", "&&", "clientUUID", ".", "compareTo", "(", "\"\"", ")", "!=", "0", ")", "{", "sqlQuery", "+=", "\" AND \"", "+", "Constants", ".", "GENERIC_CLIENT_UUID", "+", "\"='\"", "+", "clientUUID", "+", "\"'\"", ";", "}", "sqlQuery", "+=", "\";\"", ";", "logger", ".", "info", "(", "\"Query: {}\"", ",", "sqlQuery", ")", ";", "query", "=", "sqlConnection", ".", "prepareStatement", "(", "sqlQuery", ")", ";", "query", ".", "executeUpdate", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "finally", "{", "try", "{", "if", "(", "query", "!=", "null", ")", "{", "query", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}" ]
Clear history for a client @param profileId ID of profile @param clientUUID UUID of client
[ "Clear", "history", "for", "a", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/proxylib/src/main/java/com/groupon/odo/proxylib/HistoryService.java#L518-L548
164,787
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.destroy
public void destroy() throws Exception { if (_clientId == null) { return; } // delete the clientId here String uri = BASE_PROFILE + uriEncode(_profileName) + "/" + BASE_CLIENTS + "/" + _clientId; try { doDelete(uri, null); } catch (Exception e) { // some sort of error throw new Exception("Could not delete a proxy client"); } }
java
public void destroy() throws Exception { if (_clientId == null) { return; } // delete the clientId here String uri = BASE_PROFILE + uriEncode(_profileName) + "/" + BASE_CLIENTS + "/" + _clientId; try { doDelete(uri, null); } catch (Exception e) { // some sort of error throw new Exception("Could not delete a proxy client"); } }
[ "public", "void", "destroy", "(", ")", "throws", "Exception", "{", "if", "(", "_clientId", "==", "null", ")", "{", "return", ";", "}", "// delete the clientId here", "String", "uri", "=", "BASE_PROFILE", "+", "uriEncode", "(", "_profileName", ")", "+", "\"/\"", "+", "BASE_CLIENTS", "+", "\"/\"", "+", "_clientId", ";", "try", "{", "doDelete", "(", "uri", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// some sort of error", "throw", "new", "Exception", "(", "\"Could not delete a proxy client\"", ")", ";", "}", "}" ]
Call when you are done with the client @throws Exception
[ "Call", "when", "you", "are", "done", "with", "the", "client" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L145-L158
164,788
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setHostName
public void setHostName(String hostName) { if (hostName == null || hostName.contains(":")) { return; } ODO_HOST = hostName; BASE_URL = "http://" + ODO_HOST + ":" + API_PORT + "/" + API_BASE + "/"; }
java
public void setHostName(String hostName) { if (hostName == null || hostName.contains(":")) { return; } ODO_HOST = hostName; BASE_URL = "http://" + ODO_HOST + ":" + API_PORT + "/" + API_BASE + "/"; }
[ "public", "void", "setHostName", "(", "String", "hostName", ")", "{", "if", "(", "hostName", "==", "null", "||", "hostName", ".", "contains", "(", "\":\"", ")", ")", "{", "return", ";", "}", "ODO_HOST", "=", "hostName", ";", "BASE_URL", "=", "\"http://\"", "+", "ODO_HOST", "+", "\":\"", "+", "API_PORT", "+", "\"/\"", "+", "API_BASE", "+", "\"/\"", ";", "}" ]
Set the host running the Odo instance to configure @param hostName name of host
[ "Set", "the", "host", "running", "the", "Odo", "instance", "to", "configure" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L195-L201
164,789
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setDefaultHostName
public static void setDefaultHostName(String hostName) { if (hostName == null || hostName.contains(":")) { return; } DEFAULT_BASE_URL = "http://" + hostName + ":" + DEFAULT_API_PORT + "/" + API_BASE + "/"; }
java
public static void setDefaultHostName(String hostName) { if (hostName == null || hostName.contains(":")) { return; } DEFAULT_BASE_URL = "http://" + hostName + ":" + DEFAULT_API_PORT + "/" + API_BASE + "/"; }
[ "public", "static", "void", "setDefaultHostName", "(", "String", "hostName", ")", "{", "if", "(", "hostName", "==", "null", "||", "hostName", ".", "contains", "(", "\":\"", ")", ")", "{", "return", ";", "}", "DEFAULT_BASE_URL", "=", "\"http://\"", "+", "hostName", "+", "\":\"", "+", "DEFAULT_API_PORT", "+", "\"/\"", "+", "API_BASE", "+", "\"/\"", ";", "}" ]
Set the default host running the Odo instance to configure. Allows default profile methods and PathValueClient to operate on remote hosts @param hostName name of host
[ "Set", "the", "default", "host", "running", "the", "Odo", "instance", "to", "configure", ".", "Allows", "default", "profile", "methods", "and", "PathValueClient", "to", "operate", "on", "remote", "hosts" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L209-L214
164,790
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.filterHistory
public History[] filterHistory(String... filters) throws Exception { BasicNameValuePair[] params; if (filters.length > 0) { params = new BasicNameValuePair[filters.length]; for (int i = 0; i < filters.length; i++) { params[i] = new BasicNameValuePair("source_uri[]", filters[i]); } } else { return refreshHistory(); } return constructHistory(params); }
java
public History[] filterHistory(String... filters) throws Exception { BasicNameValuePair[] params; if (filters.length > 0) { params = new BasicNameValuePair[filters.length]; for (int i = 0; i < filters.length; i++) { params[i] = new BasicNameValuePair("source_uri[]", filters[i]); } } else { return refreshHistory(); } return constructHistory(params); }
[ "public", "History", "[", "]", "filterHistory", "(", "String", "...", "filters", ")", "throws", "Exception", "{", "BasicNameValuePair", "[", "]", "params", ";", "if", "(", "filters", ".", "length", ">", "0", ")", "{", "params", "=", "new", "BasicNameValuePair", "[", "filters", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "filters", ".", "length", ";", "i", "++", ")", "{", "params", "[", "i", "]", "=", "new", "BasicNameValuePair", "(", "\"source_uri[]\"", ",", "filters", "[", "i", "]", ")", ";", "}", "}", "else", "{", "return", "refreshHistory", "(", ")", ";", "}", "return", "constructHistory", "(", "params", ")", ";", "}" ]
Retrieve the request History based on the specified filters. If no filter is specified, return the default size history. @param filters filters to be applied @return array of History items @throws Exception exception
[ "Retrieve", "the", "request", "History", "based", "on", "the", "specified", "filters", ".", "If", "no", "filter", "is", "specified", "return", "the", "default", "size", "history", "." ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L224-L236
164,791
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.refreshHistory
public History[] refreshHistory(int limit, int offset) throws Exception { BasicNameValuePair[] params = { new BasicNameValuePair("limit", String.valueOf(limit)), new BasicNameValuePair("offset", String.valueOf(offset)) }; return constructHistory(params); }
java
public History[] refreshHistory(int limit, int offset) throws Exception { BasicNameValuePair[] params = { new BasicNameValuePair("limit", String.valueOf(limit)), new BasicNameValuePair("offset", String.valueOf(offset)) }; return constructHistory(params); }
[ "public", "History", "[", "]", "refreshHistory", "(", "int", "limit", ",", "int", "offset", ")", "throws", "Exception", "{", "BasicNameValuePair", "[", "]", "params", "=", "{", "new", "BasicNameValuePair", "(", "\"limit\"", ",", "String", ".", "valueOf", "(", "limit", ")", ")", ",", "new", "BasicNameValuePair", "(", "\"offset\"", ",", "String", ".", "valueOf", "(", "offset", ")", ")", "}", ";", "return", "constructHistory", "(", "params", ")", ";", "}" ]
refresh the most recent history entries @param limit number of entries to populate @param offset number of most recent entries to skip @return populated history entries @throws Exception exception
[ "refresh", "the", "most", "recent", "history", "entries" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L366-L372
164,792
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.clearHistory
public void clearHistory() throws Exception { String uri; try { uri = HISTORY + uriEncode(_profileName); doDelete(uri, null); } catch (Exception e) { throw new Exception("Could not delete proxy history"); } }
java
public void clearHistory() throws Exception { String uri; try { uri = HISTORY + uriEncode(_profileName); doDelete(uri, null); } catch (Exception e) { throw new Exception("Could not delete proxy history"); } }
[ "public", "void", "clearHistory", "(", ")", "throws", "Exception", "{", "String", "uri", ";", "try", "{", "uri", "=", "HISTORY", "+", "uriEncode", "(", "_profileName", ")", ";", "doDelete", "(", "uri", ",", "null", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Exception", "(", "\"Could not delete proxy history\"", ")", ";", "}", "}" ]
Delete the proxy history for the active profile @throws Exception exception
[ "Delete", "the", "proxy", "history", "for", "the", "active", "profile" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L379-L387
164,793
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.toggleProfile
public boolean toggleProfile(Boolean enabled) { // TODO: make this return values properly BasicNameValuePair[] params = { new BasicNameValuePair("active", enabled.toString()) }; try { String uri = BASE_PROFILE + uriEncode(this._profileName) + "/" + BASE_CLIENTS + "/"; if (_clientId == null) { uri += "-1"; } else { uri += _clientId; } JSONObject response = new JSONObject(doPost(uri, params)); } catch (Exception e) { // some sort of error System.out.println(e.getMessage()); return false; } return true; }
java
public boolean toggleProfile(Boolean enabled) { // TODO: make this return values properly BasicNameValuePair[] params = { new BasicNameValuePair("active", enabled.toString()) }; try { String uri = BASE_PROFILE + uriEncode(this._profileName) + "/" + BASE_CLIENTS + "/"; if (_clientId == null) { uri += "-1"; } else { uri += _clientId; } JSONObject response = new JSONObject(doPost(uri, params)); } catch (Exception e) { // some sort of error System.out.println(e.getMessage()); return false; } return true; }
[ "public", "boolean", "toggleProfile", "(", "Boolean", "enabled", ")", "{", "// TODO: make this return values properly", "BasicNameValuePair", "[", "]", "params", "=", "{", "new", "BasicNameValuePair", "(", "\"active\"", ",", "enabled", ".", "toString", "(", ")", ")", "}", ";", "try", "{", "String", "uri", "=", "BASE_PROFILE", "+", "uriEncode", "(", "this", ".", "_profileName", ")", "+", "\"/\"", "+", "BASE_CLIENTS", "+", "\"/\"", ";", "if", "(", "_clientId", "==", "null", ")", "{", "uri", "+=", "\"-1\"", ";", "}", "else", "{", "uri", "+=", "_clientId", ";", "}", "JSONObject", "response", "=", "new", "JSONObject", "(", "doPost", "(", "uri", ",", "params", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// some sort of error", "System", ".", "out", ".", "println", "(", "e", ".", "getMessage", "(", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Turn this profile on or off @param enabled true or false @return true on success, false otherwise
[ "Turn", "this", "profile", "on", "or", "off" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L403-L422
164,794
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setCustomResponse
public boolean setCustomResponse(String pathName, String customResponse) throws Exception { // figure out the new ordinal int nextOrdinal = this.getNextOrdinalForMethodId(-1, pathName); // add override this.addMethodToResponseOverride(pathName, "-1"); // set argument return this.setMethodArguments(pathName, "-1", nextOrdinal, customResponse); }
java
public boolean setCustomResponse(String pathName, String customResponse) throws Exception { // figure out the new ordinal int nextOrdinal = this.getNextOrdinalForMethodId(-1, pathName); // add override this.addMethodToResponseOverride(pathName, "-1"); // set argument return this.setMethodArguments(pathName, "-1", nextOrdinal, customResponse); }
[ "public", "boolean", "setCustomResponse", "(", "String", "pathName", ",", "String", "customResponse", ")", "throws", "Exception", "{", "// figure out the new ordinal", "int", "nextOrdinal", "=", "this", ".", "getNextOrdinalForMethodId", "(", "-", "1", ",", "pathName", ")", ";", "// add override", "this", ".", "addMethodToResponseOverride", "(", "pathName", ",", "\"-1\"", ")", ";", "// set argument", "return", "this", ".", "setMethodArguments", "(", "pathName", ",", "\"-1\"", ",", "nextOrdinal", ",", "customResponse", ")", ";", "}" ]
Set a custom response for this path @param pathName name of path @param customResponse value of custom response @return true if success, false otherwise @throws Exception exception
[ "Set", "a", "custom", "response", "for", "this", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L568-L577
164,795
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.addMethodToResponseOverride
public boolean addMethodToResponseOverride(String pathName, String methodName) { // need to find out the ID for the method // TODO: change api for adding methods to take the name instead of ID try { Integer overrideId = getOverrideIdForMethodName(methodName); // now post to path api to add this is a selected override BasicNameValuePair[] params = { new BasicNameValuePair("addOverride", overrideId.toString()), new BasicNameValuePair("profileIdentifier", this._profileName) }; JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName), params)); // check enabled endpoints array to see if this overrideID exists JSONArray enabled = response.getJSONArray("enabledEndpoints"); for (int x = 0; x < enabled.length(); x++) { if (enabled.getJSONObject(x).getInt("overrideId") == overrideId) { return true; } } } catch (Exception e) { e.printStackTrace(); } return false; }
java
public boolean addMethodToResponseOverride(String pathName, String methodName) { // need to find out the ID for the method // TODO: change api for adding methods to take the name instead of ID try { Integer overrideId = getOverrideIdForMethodName(methodName); // now post to path api to add this is a selected override BasicNameValuePair[] params = { new BasicNameValuePair("addOverride", overrideId.toString()), new BasicNameValuePair("profileIdentifier", this._profileName) }; JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName), params)); // check enabled endpoints array to see if this overrideID exists JSONArray enabled = response.getJSONArray("enabledEndpoints"); for (int x = 0; x < enabled.length(); x++) { if (enabled.getJSONObject(x).getInt("overrideId") == overrideId) { return true; } } } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "boolean", "addMethodToResponseOverride", "(", "String", "pathName", ",", "String", "methodName", ")", "{", "// need to find out the ID for the method", "// TODO: change api for adding methods to take the name instead of ID", "try", "{", "Integer", "overrideId", "=", "getOverrideIdForMethodName", "(", "methodName", ")", ";", "// now post to path api to add this is a selected override", "BasicNameValuePair", "[", "]", "params", "=", "{", "new", "BasicNameValuePair", "(", "\"addOverride\"", ",", "overrideId", ".", "toString", "(", ")", ")", ",", "new", "BasicNameValuePair", "(", "\"profileIdentifier\"", ",", "this", ".", "_profileName", ")", "}", ";", "JSONObject", "response", "=", "new", "JSONObject", "(", "doPost", "(", "BASE_PATH", "+", "uriEncode", "(", "pathName", ")", ",", "params", ")", ")", ";", "// check enabled endpoints array to see if this overrideID exists", "JSONArray", "enabled", "=", "response", ".", "getJSONArray", "(", "\"enabledEndpoints\"", ")", ";", "for", "(", "int", "x", "=", "0", ";", "x", "<", "enabled", ".", "length", "(", ")", ";", "x", "++", ")", "{", "if", "(", "enabled", ".", "getJSONObject", "(", "x", ")", ".", "getInt", "(", "\"overrideId\"", ")", "==", "overrideId", ")", "{", "return", "true", ";", "}", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Add a method to the enabled response overrides for a path @param pathName name of path @param methodName name of method @return true if success, false otherwise
[ "Add", "a", "method", "to", "the", "enabled", "response", "overrides", "for", "a", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L617-L641
164,796
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setOverrideRepeatCount
public boolean setOverrideRepeatCount(String pathName, String methodName, Integer ordinal, Integer repeatCount) { try { String methodId = getOverrideIdForMethodName(methodName).toString(); BasicNameValuePair[] params = { new BasicNameValuePair("profileIdentifier", this._profileName), new BasicNameValuePair("ordinal", ordinal.toString()), new BasicNameValuePair("repeatNumber", repeatCount.toString()) }; JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName) + "/" + methodId, params)); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
java
public boolean setOverrideRepeatCount(String pathName, String methodName, Integer ordinal, Integer repeatCount) { try { String methodId = getOverrideIdForMethodName(methodName).toString(); BasicNameValuePair[] params = { new BasicNameValuePair("profileIdentifier", this._profileName), new BasicNameValuePair("ordinal", ordinal.toString()), new BasicNameValuePair("repeatNumber", repeatCount.toString()) }; JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName) + "/" + methodId, params)); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "boolean", "setOverrideRepeatCount", "(", "String", "pathName", ",", "String", "methodName", ",", "Integer", "ordinal", ",", "Integer", "repeatCount", ")", "{", "try", "{", "String", "methodId", "=", "getOverrideIdForMethodName", "(", "methodName", ")", ".", "toString", "(", ")", ";", "BasicNameValuePair", "[", "]", "params", "=", "{", "new", "BasicNameValuePair", "(", "\"profileIdentifier\"", ",", "this", ".", "_profileName", ")", ",", "new", "BasicNameValuePair", "(", "\"ordinal\"", ",", "ordinal", ".", "toString", "(", ")", ")", ",", "new", "BasicNameValuePair", "(", "\"repeatNumber\"", ",", "repeatCount", ".", "toString", "(", ")", ")", "}", ";", "JSONObject", "response", "=", "new", "JSONObject", "(", "doPost", "(", "BASE_PATH", "+", "uriEncode", "(", "pathName", ")", "+", "\"/\"", "+", "methodId", ",", "params", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Set the repeat count of an override at ordinal index @param pathName Path name @param methodName Fully qualified method name @param ordinal 1-based index of the override within the overrides of type methodName @param repeatCount new repeat count to set @return true if success, false otherwise
[ "Set", "the", "repeat", "count", "of", "an", "override", "at", "ordinal", "index" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L652-L667
164,797
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setMethodArguments
public boolean setMethodArguments(String pathName, String methodName, Integer ordinal, Object... arguments) { try { BasicNameValuePair[] params = new BasicNameValuePair[arguments.length + 2]; int x = 0; for (Object argument : arguments) { params[x] = new BasicNameValuePair("arguments[]", argument.toString()); x++; } params[x] = new BasicNameValuePair("profileIdentifier", this._profileName); params[x + 1] = new BasicNameValuePair("ordinal", ordinal.toString()); JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName) + "/" + methodName, params)); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
java
public boolean setMethodArguments(String pathName, String methodName, Integer ordinal, Object... arguments) { try { BasicNameValuePair[] params = new BasicNameValuePair[arguments.length + 2]; int x = 0; for (Object argument : arguments) { params[x] = new BasicNameValuePair("arguments[]", argument.toString()); x++; } params[x] = new BasicNameValuePair("profileIdentifier", this._profileName); params[x + 1] = new BasicNameValuePair("ordinal", ordinal.toString()); JSONObject response = new JSONObject(doPost(BASE_PATH + uriEncode(pathName) + "/" + methodName, params)); return true; } catch (Exception e) { e.printStackTrace(); } return false; }
[ "public", "boolean", "setMethodArguments", "(", "String", "pathName", ",", "String", "methodName", ",", "Integer", "ordinal", ",", "Object", "...", "arguments", ")", "{", "try", "{", "BasicNameValuePair", "[", "]", "params", "=", "new", "BasicNameValuePair", "[", "arguments", ".", "length", "+", "2", "]", ";", "int", "x", "=", "0", ";", "for", "(", "Object", "argument", ":", "arguments", ")", "{", "params", "[", "x", "]", "=", "new", "BasicNameValuePair", "(", "\"arguments[]\"", ",", "argument", ".", "toString", "(", ")", ")", ";", "x", "++", ";", "}", "params", "[", "x", "]", "=", "new", "BasicNameValuePair", "(", "\"profileIdentifier\"", ",", "this", ".", "_profileName", ")", ";", "params", "[", "x", "+", "1", "]", "=", "new", "BasicNameValuePair", "(", "\"ordinal\"", ",", "ordinal", ".", "toString", "(", ")", ")", ";", "JSONObject", "response", "=", "new", "JSONObject", "(", "doPost", "(", "BASE_PATH", "+", "uriEncode", "(", "pathName", ")", "+", "\"/\"", "+", "methodName", ",", "params", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
Set the method arguments for an enabled method override @param pathName Path name @param methodName Fully qualified method name @param ordinal 1-based index of the override within the overrides of type methodName @param arguments Array of arguments to set(specify all arguments) @return true if success, false otherwise
[ "Set", "the", "method", "arguments", "for", "an", "enabled", "method", "override" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L704-L723
164,798
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.createPath
public void createPath(String pathName, String pathValue, String requestType) { try { int type = getRequestTypeFromString(requestType); String url = BASE_PATH; BasicNameValuePair[] params = { new BasicNameValuePair("pathName", pathName), new BasicNameValuePair("path", pathValue), new BasicNameValuePair("requestType", String.valueOf(type)), new BasicNameValuePair("profileIdentifier", this._profileName) }; JSONObject response = new JSONObject(doPost(BASE_PATH, params)); } catch (Exception e) { e.printStackTrace(); } }
java
public void createPath(String pathName, String pathValue, String requestType) { try { int type = getRequestTypeFromString(requestType); String url = BASE_PATH; BasicNameValuePair[] params = { new BasicNameValuePair("pathName", pathName), new BasicNameValuePair("path", pathValue), new BasicNameValuePair("requestType", String.valueOf(type)), new BasicNameValuePair("profileIdentifier", this._profileName) }; JSONObject response = new JSONObject(doPost(BASE_PATH, params)); } catch (Exception e) { e.printStackTrace(); } }
[ "public", "void", "createPath", "(", "String", "pathName", ",", "String", "pathValue", ",", "String", "requestType", ")", "{", "try", "{", "int", "type", "=", "getRequestTypeFromString", "(", "requestType", ")", ";", "String", "url", "=", "BASE_PATH", ";", "BasicNameValuePair", "[", "]", "params", "=", "{", "new", "BasicNameValuePair", "(", "\"pathName\"", ",", "pathName", ")", ",", "new", "BasicNameValuePair", "(", "\"path\"", ",", "pathValue", ")", ",", "new", "BasicNameValuePair", "(", "\"requestType\"", ",", "String", ".", "valueOf", "(", "type", ")", ")", ",", "new", "BasicNameValuePair", "(", "\"profileIdentifier\"", ",", "this", ".", "_profileName", ")", "}", ";", "JSONObject", "response", "=", "new", "JSONObject", "(", "doPost", "(", "BASE_PATH", ",", "params", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Create a new path @param pathName friendly name of path @param pathValue path value or regex @param requestType path request type. "GET", "POST", etc
[ "Create", "a", "new", "path" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L767-L782
164,799
groupon/odo
client/src/main/java/com/groupon/odo/client/Client.java
Client.setCustomForDefaultClient
protected static boolean setCustomForDefaultClient(String profileName, String pathName, Boolean isResponse, String customData) { try { Client client = new Client(profileName, false); client.toggleProfile(true); client.setCustom(isResponse, pathName, customData); if (isResponse) { client.toggleResponseOverride(pathName, true); } else { client.toggleRequestOverride(pathName, true); } return true; } catch (Exception e) { e.printStackTrace(); } return false; }
java
protected static boolean setCustomForDefaultClient(String profileName, String pathName, Boolean isResponse, String customData) { try { Client client = new Client(profileName, false); client.toggleProfile(true); client.setCustom(isResponse, pathName, customData); if (isResponse) { client.toggleResponseOverride(pathName, true); } else { client.toggleRequestOverride(pathName, true); } return true; } catch (Exception e) { e.printStackTrace(); } return false; }
[ "protected", "static", "boolean", "setCustomForDefaultClient", "(", "String", "profileName", ",", "String", "pathName", ",", "Boolean", "isResponse", ",", "String", "customData", ")", "{", "try", "{", "Client", "client", "=", "new", "Client", "(", "profileName", ",", "false", ")", ";", "client", ".", "toggleProfile", "(", "true", ")", ";", "client", ".", "setCustom", "(", "isResponse", ",", "pathName", ",", "customData", ")", ";", "if", "(", "isResponse", ")", "{", "client", ".", "toggleResponseOverride", "(", "pathName", ",", "true", ")", ";", "}", "else", "{", "client", ".", "toggleRequestOverride", "(", "pathName", ",", "true", ")", ";", "}", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "return", "false", ";", "}" ]
set custom response or request for a profile's default client, ensures profile and path are enabled @param profileName profileName to modift, default client is used @param pathName friendly name of path @param isResponse true if response, false for request @param customData custom response/request data @return true if success, false otherwise
[ "set", "custom", "response", "or", "request", "for", "a", "profile", "s", "default", "client", "ensures", "profile", "and", "path", "are", "enabled" ]
3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1
https://github.com/groupon/odo/blob/3bae43d5eca8ace036775e5b2d3ed9af1a9ff9b1/client/src/main/java/com/groupon/odo/client/Client.java#L793-L808