idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
151,700
public List < EndpointOverride > getSelectedPaths ( int overrideType , Client client , Profile profile , String uri , Integer requestType , boolean pathTest ) throws Exception { List < EndpointOverride > selectPaths = new ArrayList < EndpointOverride > ( ) ; List < EndpointOverride > paths = new ArrayList < EndpointOve...
Obtain matching paths for a request
151,701
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 + " WHE...
Returns true if the default profile for the specified uuid is active
151,702
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 " +...
Returns a collection of all profiles
151,703
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 + " ...
Returns a specific profile
151,704
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 , ( ...
Creates a Profile object from a SQL resultset
151,705
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 ) ;...
Add a new profile with the profileName given .
151,706
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 , profileI...
Deletes data associated with the given profile ID
151,707
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
151,708
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 ...
Obtain the ID associated with a profile name
151,709
public static Integer convertPathIdentifier ( String identifier , Integer profileId ) throws Exception { Integer pathId = - 1 ; try { pathId = Integer . parseInt ( identifier ) ; } catch ( NumberFormatException ne ) { if ( profileId == null ) throw new Exception ( "A profileId must be specified" ) ; pathId = PathOverri...
Obtain the path ID for a profile
151,710
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 ( NumberFormatExcept...
Obtain the profile identifier .
151,711
public static Integer convertOverrideIdentifier ( String overrideIdentifier ) throws Exception { Integer overrideId = - 1 ; try { boolean isNegative = false ; if ( overrideIdentifier . startsWith ( "-" ) ) { isNegative = true ; overrideIdentifier = overrideIdentifier . substring ( 1 ) ; } overrideId = Integer . parseIn...
Obtain override ID
151,712
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 ) { } Integer pat...
Obtain the IDs of profile and path as Identifiers
151,713
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 < ...
Retrieves the path using the endpoint value
151,714
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...
Sets a custom response on an endpoint using default profile and client
151,715
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 ,...
Remove any overrides for an endpoint on the default profile client
151,716
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 . printSt...
Remove any overrides for an endpoint
151,717
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 , requ...
Sets a custom response on an endpoint
151,718
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients" , method = RequestMethod . GET ) public HashMap < String , Object > getClientList ( Model model , @ PathVariable ( "profileIdentifier" ) String profileIdentifier ) throws Exception { Integer profileId = ControllerUtils . convertProfileIdentifier ( pr...
Returns information about all clients for a profile
151,719
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients/{clientUUID}" , method = RequestMethod . GET ) public HashMap < String , Object > getClient ( Model model , @ PathVariable ( "profileIdentifier" ) String profileIdentifier , @ PathVariable ( "clientUUID" ) String clientUUID ) throws Exception { Intege...
Returns information for a specific client
151,720
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients" , method = RequestMethod . POST ) public HashMap < String , Object > addClient ( Model model , @ PathVariable ( "profileIdentifier" ) String profileIdentifier , @ RequestParam ( required = false ) String friendlyName ) throws Exception { Integer prof...
Returns a new client id for the profileIdentifier
151,721
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients/{clientUUID}" , method = RequestMethod . POST ) public HashMap < String , Object > updateClient ( Model model , @ PathVariable ( "profileIdentifier" ) String profileIdentifier , @ PathVariable ( "clientUUID" ) String clientUUID , @ RequestParam ( requ...
Update properties for a specific client id
151,722
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients/{clientUUID}" , method = RequestMethod . DELETE ) public HashMap < String , Object > deleteClient ( Model model , @ PathVariable ( "profileIdentifier" ) String profileIdentifier , @ PathVariable ( "clientUUID" ) String clientUUID ) throws Exception { ...
Deletes a specific client id for a profile
151,723
@ RequestMapping ( value = "/api/profile/{profileIdentifier}/clients/delete" , method = RequestMethod . POST ) public HashMap < String , Object > deleteClient ( Model model , @ RequestParam ( "profileIdentifier" ) String profileIdentifier , @ RequestParam ( "clientUUID" ) String [ ] clientUUID ) throws Exception { logg...
Bulk delete clients from a profile .
151,724
@ RequestMapping ( value = "/api/plugins" , method = RequestMethod . GET ) public HashMap < String , Object > getPluginInformation ( ) { return pluginInformation ( ) ; }
Obtain plugin information
151,725
@ RequestMapping ( value = "/api/plugins" , method = RequestMethod . POST ) public HashMap < String , Object > addPluginPath ( Model model , Plugin add ) throws Exception { PluginManager . getInstance ( ) . addPluginPath ( add . getPath ( ) ) ; return pluginInformation ( ) ; }
Add a plugin path
151,726
public static void addOverrideToPath ( ) throws Exception { Client client = new Client ( "ProfileName" , false ) ; client . addMethodToResponseOverride ( "Test Path" , "com.groupon.odo.sample.Common.delay" ) ; client . setMethodArguments ( "Test Path" , "com.groupon.odo.sample.Common.delay" , 1 , "100" ) ; }
Demonstrates how to add an override to an existing path
151,727
public static void getHistory ( ) throws Exception { Client client = new Client ( "ProfileName" , false ) ; History [ ] history = client . refreshHistory ( 100 , 0 ) ; client . clearHistory ( ) ; }
Demonstrates obtaining the request history data from a test run
151,728
@ 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
151,729
@ RequestMapping ( value = "/api/profile" , method = RequestMethod . GET ) public 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
151,730
@ RequestMapping ( value = "/api/profile" , method = RequestMethod . POST ) public 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 ( n...
Add profile to database return collection of profile data . Called when enter is hit in the UI instead of submit button
151,731
@ RequestMapping ( value = "/api/profile" , method = RequestMethod . DELETE ) public HashMap < String , Object > deleteProfile ( Model model , int id ) throws Exception { profileService . remove ( id ) ; return Utils . getJQGridJSON ( profileService . findAllProfiles ( ) , "profiles" ) ; }
Delete a profile
151,732
public void cullHistory ( final int profileId , final String clientUUID , final int limit ) throws Exception { if ( threadActive ) { return ; } threadActive = true ; Thread t1 = new Thread ( new Runnable ( ) { public void run ( ) { PreparedStatement statement = null ; try ( Connection sqlConnection = sqlService . getCo...
Removes old entries in the history table for the given profile and client UUID
151,733
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 "...
Returns the number of history entries for a client
151,734
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 . GENERI...
Get history for a specific database ID
151,735
public void clearHistory ( int profileId , String clientUUID ) { PreparedStatement query = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { String sqlQuery = "DELETE FROM " + Constants . DB_TABLE_HISTORY + " " ; if ( profileId != - 1 ) { sqlQuery += "WHERE " + Constants . GENERIC_PROFILE_ID + ...
Clear history for a client
151,736
public void destroy ( ) throws Exception { if ( _clientId == null ) { return ; } String uri = BASE_PROFILE + uriEncode ( _profileName ) + "/" + BASE_CLIENTS + "/" + _clientId ; try { doDelete ( uri , null ) ; } catch ( Exception e ) { throw new Exception ( "Could not delete a proxy client" ) ; } }
Call when you are done with the client
151,737
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
151,738
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
151,739
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 ] ) ; } }...
Retrieve the request History based on the specified filters . If no filter is specified return the default size history .
151,740
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
151,741
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
151,742
public boolean toggleProfile ( Boolean enabled ) { 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 ; } JS...
Turn this profile on or off
151,743
public boolean setCustomResponse ( String pathName , String customResponse ) throws Exception { int nextOrdinal = this . getNextOrdinalForMethodId ( - 1 , pathName ) ; this . addMethodToResponseOverride ( pathName , "-1" ) ; return this . setMethodArguments ( pathName , "-1" , nextOrdinal , customResponse ) ; }
Set a custom response for this path
151,744
public boolean addMethodToResponseOverride ( String pathName , String methodName ) { try { Integer overrideId = getOverrideIdForMethodName ( methodName ) ; BasicNameValuePair [ ] params = { new BasicNameValuePair ( "addOverride" , overrideId . toString ( ) ) , new BasicNameValuePair ( "profileIdentifier" , this . _prof...
Add a method to the enabled response overrides for a path
151,745
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 BasicNam...
Set the repeat count of an override at ordinal index
151,746
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[]" , argumen...
Set the method arguments for an enabled method override
151,747
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 BasicNameValu...
Create a new path
151,748
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 . tog...
set custom response or request for a profile s default client ensures profile and path are enabled
151,749
public static boolean setCustomRequestForDefaultClient ( String profileName , String pathName , String customData ) { try { return setCustomForDefaultClient ( profileName , pathName , false , customData ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return false ; }
set custom request for profile s default client
151,750
public static boolean setCustomResponseForDefaultClient ( String profileName , String pathName , String customData ) { try { return setCustomForDefaultClient ( profileName , pathName , true , customData ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return false ; }
set custom response for profile s default client
151,751
public static boolean setCustomRequestForDefaultProfile ( String pathName , String customData ) { try { return setCustomForDefaultProfile ( pathName , false , customData ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return false ; }
set custom request for the default profile s default client
151,752
public static boolean setCustomResponseForDefaultProfile ( String pathName , String customData ) { try { return setCustomForDefaultProfile ( pathName , true , customData ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return false ; }
set custom response for the default profile s default client
151,753
protected static JSONObject getDefaultProfile ( ) throws Exception { String uri = DEFAULT_BASE_URL + BASE_PROFILE ; try { JSONObject response = new JSONObject ( doGet ( uri , 60000 ) ) ; JSONArray profiles = response . getJSONArray ( "profiles" ) ; if ( profiles . length ( ) > 0 ) { return profiles . getJSONObject ( 0 ...
get the default profile
151,754
private Integer getNextOrdinalForMethodId ( int methodId , String pathName ) throws Exception { String pathInfo = doGet ( BASE_PATH + uriEncode ( pathName ) , new BasicNameValuePair [ 0 ] ) ; JSONObject pathResponse = new JSONObject ( pathInfo ) ; JSONArray enabledEndpoints = pathResponse . getJSONArray ( "enabledEndpo...
Get the next available ordinal for a method ID
151,755
protected int getRequestTypeFromString ( String requestType ) { if ( "GET" . equals ( requestType ) ) { return REQUEST_TYPE_GET ; } if ( "POST" . equals ( requestType ) ) { return REQUEST_TYPE_POST ; } if ( "PUT" . equals ( requestType ) ) { return REQUEST_TYPE_PUT ; } if ( "DELETE" . equals ( requestType ) ) { return ...
Convert a request type string to value
151,756
public ServerRedirect addServerMapping ( String sourceHost , String destinationHost , String hostHeader ) { JSONObject response = null ; ArrayList < BasicNameValuePair > params = new ArrayList < BasicNameValuePair > ( ) ; params . add ( new BasicNameValuePair ( "srcUrl" , sourceHost ) ) ; params . add ( new BasicNameVa...
Add a new server mapping to current profile
151,757
public List < ServerRedirect > deleteServerMapping ( int serverMappingId ) { ArrayList < ServerRedirect > servers = new ArrayList < ServerRedirect > ( ) ; try { JSONArray serverArray = new JSONArray ( doDelete ( BASE_SERVER + "/" + serverMappingId , null ) ) ; for ( int i = 0 ; i < serverArray . length ( ) ; i ++ ) { J...
Remove a server mapping from current profile by ID
151,758
public List < ServerRedirect > getServerMappings ( ) { ArrayList < ServerRedirect > servers = new ArrayList < ServerRedirect > ( ) ; try { JSONObject response = new JSONObject ( doGet ( BASE_SERVER , null ) ) ; JSONArray serverArray = response . getJSONArray ( "servers" ) ; for ( int i = 0 ; i < serverArray . length ( ...
Get a list of all active server mappings defined for current profile
151,759
public ServerRedirect updateServerRedirectHost ( int serverMappingId , String hostHeader ) { ServerRedirect redirect = new ServerRedirect ( ) ; BasicNameValuePair [ ] params = { new BasicNameValuePair ( "hostHeader" , hostHeader ) , new BasicNameValuePair ( "profileIdentifier" , this . _profileName ) } ; try { JSONObje...
Update server mapping s host header
151,760
public ServerGroup addServerGroup ( String groupName ) { ServerGroup group = new ServerGroup ( ) ; BasicNameValuePair [ ] params = { new BasicNameValuePair ( "name" , groupName ) , new BasicNameValuePair ( "profileIdentifier" , this . _profileName ) } ; try { JSONObject response = new JSONObject ( doPost ( BASE_SERVERG...
Create a new server group
151,761
public List < ServerGroup > getServerGroups ( ) { ArrayList < ServerGroup > groups = new ArrayList < ServerGroup > ( ) ; try { JSONObject response = new JSONObject ( doGet ( BASE_SERVERGROUP , null ) ) ; JSONArray serverArray = response . getJSONArray ( "servergroups" ) ; for ( int i = 0 ; i < serverArray . length ( ) ...
Get the collection of the server groups
151,762
public ServerGroup updateServerGroupName ( int serverGroupId , String name ) { ServerGroup serverGroup = null ; BasicNameValuePair [ ] params = { new BasicNameValuePair ( "name" , name ) , new BasicNameValuePair ( "profileIdentifier" , this . _profileName ) } ; try { JSONObject response = new JSONObject ( doPost ( BASE...
Update the server group s name
151,763
public boolean uploadConfigurationAndProfile ( String fileName , String odoImport ) { File file = new File ( fileName ) ; MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder . create ( ) ; FileBody fileBody = new FileBody ( file , ContentType . MULTIPART_FORM_DATA ) ; multipartEntityBuilder . setMode...
Upload file and set odo overrides and configuration of odo
151,764
public JSONObject exportConfigurationAndProfile ( String oldExport ) { try { BasicNameValuePair [ ] params = { new BasicNameValuePair ( "oldExport" , oldExport ) } ; String url = BASE_BACKUP_PROFILE + "/" + uriEncode ( this . _profileName ) + "/" + this . _clientId ; return new JSONObject ( doGet ( url , new BasicNameV...
Export the odo overrides setup and odo configuration
151,765
private List < Group > getGroups ( ) throws Exception { List < Group > groups = new ArrayList < Group > ( ) ; List < Group > sourceGroups = PathOverrideService . getInstance ( ) . findAllGroups ( ) ; for ( Group sourceGroup : sourceGroups ) { Group group = new Group ( ) ; ArrayList < Method > methods = new ArrayList < ...
Get all Groups
151,766
public SingleProfileBackup getProfileBackupData ( int profileID , String clientUUID ) throws Exception { SingleProfileBackup singleProfileBackup = new SingleProfileBackup ( ) ; List < PathOverride > enabledPaths = new ArrayList < > ( ) ; List < EndpointOverride > paths = PathOverrideService . getInstance ( ) . getPaths...
Get the active overrides with parameters and the active server group for a client
151,767
public Backup getBackupData ( ) throws Exception { Backup backupData = new Backup ( ) ; backupData . setGroups ( getGroups ( ) ) ; backupData . setProfiles ( getProfiles ( ) ) ; ArrayList < Script > scripts = new ArrayList < Script > ( ) ; Collections . addAll ( scripts , ScriptService . getInstance ( ) . getScripts ( ...
Return the structured backup data
151,768
private MBeanServer getServerForName ( String name ) { try { MBeanServer mbeanServer = null ; final ObjectName objectNameQuery = new ObjectName ( name + ":type=Service,*" ) ; for ( final MBeanServer server : MBeanServerFactory . findMBeanServer ( null ) ) { if ( server . queryNames ( objectNameQuery , null ) . size ( )...
Returns an MBeanServer with the specified name
151,769
@ SuppressWarnings ( "unchecked" ) private void setProxyRequestHeaders ( HttpServletRequest httpServletRequest , HttpMethod httpMethodProxyRequest ) throws Exception { RequestInformation requestInfo = requestInformation . get ( ) ; String hostName = HttpUtilities . getHostNameFromURL ( httpServletRequest . getRequestUR...
Retrieves all of the headers from the servlet request and sets them on the proxy request
151,770
private void processRequestHeaderOverrides ( HttpMethod httpMethodProxyRequest ) throws Exception { RequestInformation requestInfo = requestInformation . get ( ) ; for ( EndpointOverride selectedPath : requestInfo . selectedRequestPaths ) { List < EnabledEndpoint > points = selectedPath . getEnabledEndpoints ( ) ; for ...
Apply any applicable header overrides to request
151,771
private String getHostHeaderForHost ( String hostName ) { List < ServerRedirect > servers = serverRedirectService . tableServers ( requestInformation . get ( ) . client . getId ( ) ) ; for ( ServerRedirect server : servers ) { if ( server . getSrcUrl ( ) . compareTo ( hostName ) == 0 ) { String hostHeader = server . ge...
Obtain host header value for a hostname
151,772
private void processClientId ( HttpServletRequest httpServletRequest , History history ) { if ( httpServletRequest . getHeader ( Constants . PROFILE_CLIENT_HEADER_NAME ) != null && ! httpServletRequest . getHeader ( Constants . PROFILE_CLIENT_HEADER_NAME ) . equals ( "" ) ) { history . setClientUUID ( httpServletReques...
Apply the matching client UUID for the request
151,773
private JSONArray getApplicablePathNames ( String requestUrl , Integer requestType ) throws Exception { RequestInformation requestInfo = requestInformation . get ( ) ; List < EndpointOverride > applicablePaths ; JSONArray pathNames = new JSONArray ( ) ; applicablePaths = PathOverrideService . getInstance ( ) . getSelec...
Get the names of the paths that would apply to the request
151,774
private String getDestinationHostName ( String hostName ) { List < ServerRedirect > servers = serverRedirectService . tableServers ( requestInformation . get ( ) . client . getId ( ) ) ; for ( ServerRedirect server : servers ) { if ( server . getSrcUrl ( ) . compareTo ( hostName ) == 0 ) { if ( server . getDestUrl ( ) ...
Obtain the destination hostname for a source host
151,775
private void processVirtualHostName ( HttpMethod httpMethodProxyRequest , HttpServletRequest httpServletRequest ) { String virtualHostName ; if ( httpMethodProxyRequest . getRequestHeader ( STRING_HOST_HEADER_NAME ) != null ) { virtualHostName = HttpUtilities . removePortFromHostHeaderString ( httpMethodProxyRequest . ...
Set virtual host so the server can direct the request . Value is the host header if it is set otherwise use the hostname from the original request .
151,776
private void cullDisabledPaths ( ) throws Exception { ArrayList < EndpointOverride > removePaths = new ArrayList < EndpointOverride > ( ) ; RequestInformation requestInfo = requestInformation . get ( ) ; for ( EndpointOverride selectedPath : requestInfo . selectedResponsePaths ) { if ( selectedPath != null && selectedP...
Remove paths with no active overrides
151,777
private ArrayList < String > getRemoveHeaders ( ) throws Exception { ArrayList < String > headersToRemove = new ArrayList < String > ( ) ; for ( EndpointOverride selectedPath : requestInformation . get ( ) . selectedResponsePaths ) { List < EnabledEndpoint > points = selectedPath . getEnabledEndpoints ( ) ; for ( Enabl...
Obtain collection of headers to remove
151,778
private void executeProxyRequest ( HttpMethod httpMethodProxyRequest , HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse , History history ) { try { RequestInformation requestInfo = requestInformation . get ( ) ; processVirtualHostName ( httpMethodProxyRequest , httpServletRequest ) ; cull...
Execute a request through Odo processing
151,779
private void executeRequest ( HttpMethod httpMethodProxyRequest , HttpServletRequest httpServletRequest , PluginResponse httpServletResponse , History history ) throws Exception { int intProxyResponseCode = 999 ; HttpClient httpClient = new HttpClient ( ) ; HttpState state = new HttpState ( ) ; try { httpMethodProxyReq...
Execute a request
151,780
private void processRedirect ( String stringStatusCode , HttpMethod httpMethodProxyRequest , HttpServletRequest httpServletRequest , HttpServletResponse httpServletResponse ) throws Exception { String stringLocation = httpMethodProxyRequest . getResponseHeader ( STRING_LOCATION_HEADER ) . getValue ( ) ; if ( stringLoca...
Execute a redirected request
151,781
private void logOriginalRequestHistory ( String requestType , HttpServletRequest request , History history ) { logger . info ( "Storing original request history" ) ; history . setRequestType ( requestType ) ; history . setOriginalRequestHeaders ( HttpUtilities . getHeaders ( request ) ) ; history . setOriginalRequestUR...
Log original incoming request
151,782
private void logOriginalResponseHistory ( PluginResponse httpServletResponse , History history ) throws URIException { RequestInformation requestInfo = requestInformation . get ( ) ; if ( requestInfo . handle && requestInfo . client . getIsActive ( ) ) { logger . info ( "Storing original response history" ) ; history ....
Log original response
151,783
private void logRequestHistory ( HttpMethod httpMethodProxyRequest , PluginResponse httpServletResponse , History history ) { try { if ( requestInformation . get ( ) . handle && requestInformation . get ( ) . client . getIsActive ( ) ) { logger . info ( "Storing history" ) ; String createdDate ; SimpleDateFormat sdf = ...
Log modified request
151,784
public void handleConnectOriginal ( String pathInContext , String pathParams , HttpRequest request , HttpResponse response ) throws HttpException , IOException { URI uri = request . getURI ( ) ; try { LOG . fine ( "CONNECT: " + uri ) ; InetAddrPort addrPort ; if ( uri . toString ( ) . endsWith ( ".selenium.doesnotexist...
Copied from original SeleniumProxyHandler Changed SslRelay to SslListener and getSslRelayOrCreateNew to getSslRelayOrCreateNewOdo No other changes to the function
151,785
protected X509Certificate wireUpSslWithCyberVilliansCAOdo ( String host , SslListener listener ) { host = requestOriginalHostName . get ( ) ; try { String escapedHost = host . replace ( '*' , '_' ) ; KeyStoreManager keyStoreManager = Utils . getKeyStoreManager ( escapedHost ) ; keyStoreManager . getKeyStore ( ) . delet...
This function wires up a SSL Listener with the cyber villians root CA and cert with the correct CNAME for the request
151,786
private void startRelayWithPortTollerance ( HttpServer server , SslListener relay , int tries ) throws Exception { if ( tries >= 5 ) { throw new BindException ( "Unable to bind to several ports, most recently " + relay . getPort ( ) + ". Giving up" ) ; } try { if ( server . isStarted ( ) ) { relay . start ( ) ; } else ...
END ODO CHANGES
151,787
private static OkHttpClient getUnsafeOkHttpClient ( ) { try { final TrustManager [ ] trustAllCerts = new TrustManager [ ] { new X509TrustManager ( ) { public void checkClientTrusted ( java . security . cert . X509Certificate [ ] chain , String authType ) throws CertificateException { } public void checkServerTrusted ( ...
Returns a OkHttpClient that ignores SSL cert errors
151,788
public void cleanup ( ) { synchronized ( _sslMap ) { for ( SslRelayOdo relay : _sslMap . values ( ) ) { if ( relay . getHttpServer ( ) != null && relay . isStarted ( ) ) { relay . getHttpServer ( ) . removeListener ( relay ) ; } } sslRelays . clear ( ) ; } }
Cleanup function to remove all allocated listeners
151,789
public void removeOverride ( int overrideId , int pathId , Integer ordinal , String clientUUID ) { PreparedStatement statement = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { int enabledId = getEnabledEndpoint ( pathId , overrideId , ordinal , clientUUID ) . getId ( ) ; statement = sqlConne...
Remove specified override id from enabled overrides for path
151,790
public void increasePriority ( int overrideId , int ordinal , int pathId , String clientUUID ) { logger . info ( "Increase priority" ) ; int origPriority = - 1 ; int newPriority = - 1 ; int origId = 0 ; int newId = 0 ; PreparedStatement statement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlS...
Increase the priority of an overrideId
151,791
private static String preparePlaceHolders ( int length ) { StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < length ; ) { builder . append ( "?" ) ; if ( ++ i < length ) { builder . append ( "," ) ; } } return builder . toString ( ) ; }
Creates a list of placeholders for use in a PreparedStatement
151,792
public void disableAllOverrides ( int pathID , String clientUUID ) { PreparedStatement statement = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { statement = sqlConnection . prepareStatement ( "DELETE FROM " + Constants . DB_TABLE_ENABLED_OVERRIDE + " WHERE " + Constants . ENABLED_OVERRIDES_...
Disable all overrides for a specified path
151,793
public void disableAllOverrides ( int pathID , String clientUUID , int overrideType ) { PreparedStatement statement = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { ArrayList < Integer > enabledOverrides = new ArrayList < Integer > ( ) ; enabledOverrides . add ( Constants . PLUGIN_REQUEST_HE...
Disable all overrides for a specified path with overrideType
151,794
public List < EnabledEndpoint > getEnabledEndpoints ( int pathId , String clientUUID , String [ ] filters ) throws Exception { ArrayList < EnabledEndpoint > enabledOverrides = new ArrayList < EnabledEndpoint > ( ) ; PreparedStatement query = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService ...
Returns an array of the enabled endpoints as Integer IDs
151,795
public int getCurrentMethodOrdinal ( int overrideId , int pathId , String clientUUID , String [ ] filters ) throws Exception { int currentOrdinal = 0 ; List < EnabledEndpoint > enabledEndpoints = getEnabledEndpoints ( pathId , clientUUID , filters ) ; for ( EnabledEndpoint enabledEndpoint : enabledEndpoints ) { if ( en...
Get the ordinal value for the last of a particular override on a path
151,796
private EnabledEndpoint getPartialEnabledEndpointFromResultset ( ResultSet result ) throws Exception { EnabledEndpoint endpoint = new EnabledEndpoint ( ) ; endpoint . setId ( result . getInt ( Constants . GENERIC_ID ) ) ; endpoint . setPathId ( result . getInt ( Constants . ENABLED_OVERRIDES_PATH_ID ) ) ; endpoint . se...
This only gets half of the EnabledEndpoint from a JDBC ResultSet Getting the method for the override id requires an additional SQL query and needs to be called after the SQL connection is released
151,797
public Integer getOverrideIdForMethod ( String className , String methodName ) { Integer overrideId = null ; PreparedStatement query = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { query = sqlConnection . prepareStatement ( "SELECT * FROM " + Constants . DB_TABLE_...
Gets an overrideID for a class name method name
151,798
public List < Client > findAllClients ( int profileId ) throws Exception { ArrayList < Client > clients = new ArrayList < Client > ( ) ; PreparedStatement query = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { query = sqlConnection . prepareStatement ( "SELECT * FR...
Return all Clients for a profile
151,799
public Client getClient ( int clientId ) throws Exception { Client client = null ; PreparedStatement statement = null ; ResultSet results = null ; try ( Connection sqlConnection = sqlService . getConnection ( ) ) { String queryString = "SELECT * FROM " + Constants . DB_TABLE_CLIENT + " WHERE " + Constants . GENERIC_ID ...
Returns a client object for a clientId