idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
28,000
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 " + Consta...
Sets the path name for this ID
28,001
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 " + Consta...
Sets the actual path for this ID
28,002
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 + " = ? " + " WHER...
Sets the body filter for this ID
28,003
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 + " = ? " + " W...
Sets the content type for this ID
28,004
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...
Sets the request type for this ID . Defaults to GET
28,005
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 " + Consta...
Sets the global setting for this ID
28,006
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 . getCo...
Returns an array of all endpoints
28,007
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 " + C...
Set the value for a custom request
28,008
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 ) ; Edit...
Clear all overrides reset repeat counts for a response path
28,009
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 ( Con...
Clear all overrides reset repeat counts for a request path
28,010
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
28,011
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
28,012
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
28,013
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
28,014
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
28,015
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 .
28,016
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
28,017
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
28,018
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
28,019
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
28,020
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 .
28,021
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
28,022
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
28,023
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
28,024
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
28,025
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
28,026
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
28,027
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
28,028
@ 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
28,029
@ 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
28,030
@ 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
28,031
@ 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
28,032
@ 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
28,033
@ 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 .
28,034
@ RequestMapping ( value = "/api/plugins" , method = RequestMethod . GET ) public HashMap < String , Object > getPluginInformation ( ) { return pluginInformation ( ) ; }
Obtain plugin information
28,035
@ 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
28,036
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
28,037
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
28,038
@ 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
28,039
@ 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
28,040
@ 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
28,041
@ 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
28,042
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
28,043
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
28,044
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
28,045
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
28,046
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
28,047
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
28,048
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
28,049
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 .
28,050
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
28,051
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
28,052
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
28,053
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
28,054
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
28,055
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
28,056
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
28,057
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
28,058
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
28,059
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
28,060
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
28,061
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
28,062
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
28,063
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
28,064
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
28,065
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
28,066
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
28,067
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
28,068
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
28,069
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
28,070
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
28,071
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
28,072
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
28,073
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
28,074
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
28,075
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
28,076
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
28,077
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
28,078
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
28,079
@ 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
28,080
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
28,081
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
28,082
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
28,083
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
28,084
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
28,085
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 .
28,086
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
28,087
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
28,088
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
28,089
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
28,090
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
28,091
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
28,092
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
28,093
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
28,094
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
28,095
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
28,096
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
28,097
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
28,098
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
28,099
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