com.sun.jersey.api.client.Client Java Examples
The following examples show how to use
com.sun.jersey.api.client.Client.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public Map<String, Object> generateCSVLink(String code) throws AidrException { try { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); WebTarget webResource = client.target(persisterMainUrl + "/taggerPersister/genCSV?collectionCode=" + code + "&exportLimit=100000"); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).get(); Map<String, Object> jsonResponse = clientResponse.readEntity(Map.class); return jsonResponse; /* * if (jsonResponse != null && * "http".equals(jsonResponse.substring(0, 4))) { return * jsonResponse; } else { return ""; } */ } catch (Exception e) { logger.error("Error while generating CSV link in Persister for collection: "+code, e); throw new AidrException( "[generateCSVLink] Error while generating CSV link in Persister", e); } }
Example #2
Source File: UserRoleDelegate.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void initManaged( PurRepositoryMeta repositoryMeta, IUser userInfo ) throws JSONException { String baseUrl = repositoryMeta.getRepositoryLocation().getUrl(); String webService = baseUrl + ( baseUrl.endsWith( "/" ) ? "" : "/" ) + "api/system/authentication-provider"; HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter( userInfo.getLogin(), userInfo.getPassword() ); Client client = new Client(); client.addFilter( authFilter ); WebResource.Builder resource = client.resource( webService ).accept( MediaType.APPLICATION_JSON_TYPE ); /** * if set, _trust_user_ needs to be considered. See other places in pur-plugin's: * * @link https://github.com/pentaho/pentaho-kettle/blob/8.0.0.0-R/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/PurRepositoryConnector.java#L97-L101 * @link https://github.com/pentaho/pentaho-kettle/blob/8.0.0.0-R/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/WebServiceManager.java#L130-L133 */ if ( StringUtils.isNotBlank( System.getProperty( "pentaho.repository.client.attemptTrust" ) ) ) { resource = resource.header( TRUST_USER, userInfo.getLogin() ); } String response = resource.get( String.class ); String provider = new JSONObject( response ).getString( "authenticationType" ); managed = "jackrabbit".equals( provider ); }
Example #3
Source File: HmacClientFilterTest.java From jersey-hmac-auth with Apache License 2.0 | 6 votes |
@Test public void validateSignatureWhenThereIsNoContent() throws Exception { Connection connection = null; try { // Start the server ValidatingHttpServer server = new SignatureValidatingHttpServer(port, secretKey); connection = server.connect(); // Create a client with the filter that is under test Client client = createClient(); client.addFilter(new HmacClientFilter(apiKey, secretKey, client.getMessageBodyWorkers())); // Send a request with no content in the request body client.resource(server.getUri()).get(String.class); } finally { if (connection != null) { connection.close(); } } }
Example #4
Source File: RunnerCoordinator.java From usergrid with Apache License 2.0 | 6 votes |
/** * Starts the tests on given runners and puts them into RUNNING state, if indeed they were READY. * * @param runners Runners that are going to run the tests * @param runNumber Run number of upcoming tests, this should be get from Run storage * @return Map of resulting states of <code>runners</code>, after the operation */ public Map<Runner, State> start( Collection<Runner> runners, int runNumber ) { Map<Runner, State> states = new HashMap<Runner, State>( runners.size() ); for( Runner runner: runners ) { lastRunNumbers.put( runner, runNumber ); trustRunner( runner.getUrl() ); DefaultClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create( clientConfig ); LOG.info( "Runner to start: {}", runner.getUrl() ); WebResource resource = client.resource( runner.getUrl() ).path( Runner.START_POST ); BaseResult response = resource.type( MediaType.APPLICATION_JSON ).post( BaseResult.class ); if( ! response.getStatus() ) { LOG.warn( "Tests at runner {} could not be started.", runner.getUrl() ); LOG.warn( response.getMessage() ); states.put( runner, null ); } else { states.put( runner, response.getState() ); } } return states; }
Example #5
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public Long getLabelCount(Long collectionId) { Long labelCount = 0L; Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); Response clientResponse = null; try { WebTarget webResource = client.target(taggerMainUrl + "/label/collection/" + collectionId); clientResponse = webResource.request( MediaType.APPLICATION_JSON).get(); labelCount = clientResponse.readEntity(Long.class); if (clientResponse.getStatus() != 200) { logger.warn("Couldn't contact AIDRTaggerAPI for sending error message"); } } catch (Exception e) { logger.error("Error in contacting AIDRTaggerAPI: " + clientResponse, e); } return labelCount; }
Example #6
Source File: EmoModule.java From emodb with Apache License 2.0 | 6 votes |
/** Create an SOA QueueService client for forwarding non-partition-aware clients to the right server. */ @Provides @Singleton @PartitionAwareClient QueueServiceAuthenticator provideQueueClient(QueueService queueService, Client jerseyClient, @SelfHostAndPort HostAndPort self, @Global CuratorFramework curator, MetricRegistry metricRegistry, HealthCheckRegistry healthCheckRegistry) { MultiThreadedServiceFactory<AuthQueueService> serviceFactory = new PartitionAwareServiceFactory<>( AuthQueueService.class, QueueClientFactory.forClusterAndHttpClient(_configuration.getCluster(), jerseyClient), new TrustedQueueService(queueService), self, healthCheckRegistry, metricRegistry); AuthQueueService client = ServicePoolBuilder.create(AuthQueueService.class) .withHostDiscovery(new ZooKeeperHostDiscovery(curator, serviceFactory.getServiceName(), metricRegistry)) .withServiceFactory(serviceFactory) .withMetricRegistry(metricRegistry) .withCachingPolicy(ServiceCachingPolicyBuilder.getMultiThreadedClientPolicy()) .buildProxy(new ExponentialBackoffRetry(5, 50, 1000, TimeUnit.MILLISECONDS)); _environment.lifecycle().manage(new ManagedServicePoolProxy(client)); return QueueServiceAuthenticator.proxied(client); }
Example #7
Source File: WsClient.java From roboconf-platform with Apache License 2.0 | 6 votes |
/** * Constructor. * @param rootUrl the root URL (example: http://192.168.1.18:9007/dm/) */ public WsClient( String rootUrl ) { ClientConfig cc = new DefaultClientConfig(); cc.getClasses().add( JacksonJsonProvider.class ); cc.getClasses().add( ObjectMapperProvider.class ); this.client = Client.create( cc ); this.client.setFollowRedirects( true ); WebResource resource = this.client.resource( rootUrl ); this.applicationDelegate = new ApplicationWsDelegate( resource, this ); this.managementDelegate = new ManagementWsDelegate( resource, this ); this.debugDelegate = new DebugWsDelegate( resource, this ); this.targetWsDelegate = new TargetWsDelegate( resource, this ); this.schedulerDelegate = new SchedulerWsDelegate( resource, this ); this.preferencesWsDelegate = new PreferencesWsDelegate( resource, this ); this.authenticationWsDelegate = new AuthenticationWsDelegate( resource, this ); }
Example #8
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public Map<String, Object> generateJsonTweetIdsLink(String code, String jsonType) throws AidrException { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); try { WebTarget webResource = client.target(persisterMainUrl + "/taggerPersister/genJsonTweetIds?collectionCode=" + code + "&downloadLimited=true&" + "&jsonType=" + jsonType); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).get(); Map<String, Object> jsonResponse = clientResponse .readEntity(Map.class); logger.info("Returning from func: " + jsonResponse); return jsonResponse; } catch (Exception e) { logger.error("Error while generating JSON Tweet Ids download link in Persister for collection: "+code, e); throw new AidrException( "[generateJsonTweetIdsLink] Error while generating JSON Tweet Ids download link in Persister", e); } }
Example #9
Source File: YarnHttpClient.java From cloudbreak with Apache License 2.0 | 6 votes |
@Override public void validateApiEndpoint() throws CloudbreakOrchestratorFailedException, MalformedURLException { YarnEndpoint dashEndpoint = new YarnEndpoint( apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH ); ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString()); ClientResponse response = webResource.accept("application/json").type("application/json").get(ClientResponse.class); // Validate HTTP 200 status code if (response.getStatus() != YarnResourceConstants.HTTP_SUCCESS) { String msg = String.format("Received %d status code from url %s, reason: %s", response.getStatus(), dashEndpoint.getFullEndpointUrl().toString(), response.getEntity(String.class)); LOGGER.debug(msg); throw new CloudbreakOrchestratorFailedException(msg); } }
Example #10
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 6 votes |
public <T> ClientResponse<T> upload(String url, File f, Class<T> expectedResponse, Headers... headers) { @SuppressWarnings("resource") FormDataMultiPart form = new FormDataMultiPart(); form.bodyPart(new FileDataBodyPart("file", f, MediaType.APPLICATION_OCTET_STREAM_TYPE)); String urlCreated = createURI(url); ClientConfig cc = new DefaultClientConfig(); cc.getClasses().add(MultiPartWriter.class); WebResource webResource = Client.create(cc).resource(urlCreated); Builder builder = webResource.type(MULTIPART_MEDIA).accept(MEDIA).accept("text/plain"); for (Headers h : headers) { builder.header(h.getKey(), h.getValue()); } com.sun.jersey.api.client.ClientResponse clienteResponse = null; clienteResponse = builder.post(com.sun.jersey.api.client.ClientResponse.class, form); return new ClientResponse<T>(clienteResponse, expectedResponse); }
Example #11
Source File: YarnHttpClient.java From cloudbreak with Apache License 2.0 | 6 votes |
@Override public void validateApiEndpoint() throws YarnClientException, MalformedURLException { YarnEndpoint dashEndpoint = new YarnEndpoint(apiEndpoint, YarnResourceConstants.APPLICATIONS_PATH); ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); WebResource webResource = client.resource(dashEndpoint.getFullEndpointUrl().toString()); ClientResponse response = webResource.accept("application/json").type("application/json").get(ClientResponse.class); // Validate HTTP 200 status code if (response.getStatus() != YarnResourceConstants.HTTP_SUCCESS) { String msg = String.format("Received %d status code from url %s, reason: %s", response.getStatus(), dashEndpoint.getFullEndpointUrl().toString(), response.getEntity(String.class)); LOGGER.debug(msg); throw new YarnClientException(msg); } }
Example #12
Source File: JSONPayloadFactoryInLineTestCase.java From product-ei with Apache License 2.0 | 6 votes |
@Test(groups = {"wso2.esb"}, description = "Tests POST method with application/json content type for inline" + " payload factory") public void testHTTPPostRequestForInlinePayloadFactoryTestScenario() throws Exception { String JSON_PAYLOAD = "{\"album\":\"null\",\"singer\":\"null\"}"; Client client = Client.create(); WebResource webResource = client .resource(getProxyServiceURLHttp("PayloadFactoryInlineJSONProxy")); // sending post request ClientResponse postResponse = webResource.type("application/json") .post(ClientResponse.class, JSON_PAYLOAD); assertEquals(postResponse.getType().toString(), "application/json", "Content-Type Should be application/json"); assertEquals(postResponse.getStatus(), 201, "Response status should be 201"); // Calling the GET request to verify Added album details ClientResponse getResponse = webResource.type("application/json") .get(ClientResponse.class); assertNotNull(getResponse, "Received Null response for while getting Music album details"); assertEquals(getResponse.getEntity(String.class), "{\"album\":\"Champs\",\"singer\":\"MJ\"}", "Response mismatch for HTTP Get call"); }
Example #13
Source File: AtlasBaseClient.java From incubator-atlas with Apache License 2.0 | 5 votes |
void initializeState(Configuration configuration, String[] baseUrls, UserGroupInformation ugi, String doAsUser) { this.configuration = configuration; Client client = getClient(configuration, ugi, doAsUser); if ((!AuthenticationUtil.isKerberosAuthenticationEnabled()) && basicAuthUser != null && basicAuthPassword != null) { final HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter(basicAuthUser, basicAuthPassword); client.addFilter(authFilter); } String activeServiceUrl = determineActiveServiceURL(baseUrls, client); atlasClientContext = new AtlasClientContext(baseUrls, client, ugi, doAsUser); service = client.resource(UriBuilder.fromUri(activeServiceUrl).build()); }
Example #14
Source File: PublishRestUtil.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Used for REST Jersey calls */ private void initRestService() { ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getClasses().add( MultiPartWriter.class ); clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE ); client = Client.create( clientConfig ); client.addFilter( new HTTPBasicAuthFilter( username, password ) ); }
Example #15
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean deleteTrainingExample(Integer id) throws AidrException { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); try { /** * Rest call to Tagger */ WebTarget webResource = client.target(taggerMainUrl + "/document/removeTrainingExample/" + new Long(id)); ObjectMapper objectMapper = JacksonWrapper.getObjectMapper(); objectMapper .setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).delete(); String jsonResponse = clientResponse.readEntity(String.class); TaggerStatusResponse response = objectMapper.readValue( jsonResponse, TaggerStatusResponse.class); if (response != null && response.getStatusCode() != null) { if ("SUCCESS".equals(response.getStatusCode())) { logger.info("Document with ID " + id + " was deleted in Tagger"); return true; } else { return false; } } return false; } catch (Exception e) { logger.error("Error while deleting document", e); throw new AidrException("Error while deleting document in Tagger", e); } }
Example #16
Source File: PlatformServiceUtil.java From Insights with Apache License 2.0 | 5 votes |
public static ClientResponse publishConfigChanges(String host, int port, JsonObject requestJson) { WebResource resource = Client.create() .resource("http://" + host + ":" + port + "/PlatformEngine/refreshAggregators"); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity(requestJson.toString()).post(ClientResponse.class); return response; }
Example #17
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public TaggerCrisis updateCode(TaggerCrisis crisis) throws AidrException { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); try { /** * Rest call to Tagger */ CollectionDTO dto = crisis.toDTO(); WebTarget webResource = client.target(taggerMainUrl + "/crisis"); logger.info("Received update request for crisis = " + crisis.getCode() + ", dto = " + dto.getCode()); ObjectMapper objectMapper = JacksonWrapper.getObjectMapper(); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).put( Entity.json(objectMapper.writeValueAsString(dto)), Response.class); String jsonResponse = clientResponse.readEntity(String.class); CollectionDTO updatedDTO = objectMapper.readValue(jsonResponse, CollectionDTO.class); TaggerCrisis updatedCrisis = new TaggerCrisis(updatedDTO); logger.info("Received response: " + updatedCrisis.getCode() + ", " + updatedCrisis.getName() + "," + updatedCrisis.getCrisisType().getCrisisTypeID()); if (updatedCrisis != null) { logger.info("Crisis with id " + updatedCrisis.getCrisisID() + " was updated in Tagger"); } return crisis; } catch (Exception e) { logger.error("Error while updating crisis: "+crisis.getCode(), e); throw new AidrException( "Error while updating crisis", e); } }
Example #18
Source File: RestRequestSender.java From osiris with Apache License 2.0 | 5 votes |
public void uploadVoid(String url, File f, String formName) { FormDataMultiPart form = new FormDataMultiPart().field(formName, f, MediaType.MULTIPART_FORM_DATA_TYPE); String urlCreated = createURI(url); ClientConfig cc = new DefaultClientConfig(); cc.getClasses().add(MultiPartWriter.class); WebResource webResource = Client.create(cc).resource(urlCreated); webResource.type(MULTIPART_MEDIA).accept(MEDIA).post(form); }
Example #19
Source File: HmacClientFilterTest.java From jersey-hmac-auth with Apache License 2.0 | 5 votes |
@Test public void validateSignatureWhenContentIsPojo() throws Exception { Connection connection = null; try { // Start the server RequestConfiguration requestConfiguration = RequestConfiguration.builder().withApiKeyQueryParamName("passkey") .withSignatureHttpHeader("duck-duck-signature-header") .withTimestampHttpHeader("duck-duck-timestamp-header") .withVersionHttpHeader("duck-duck-version-header") .build(); ValidatingHttpServer server = new SignatureValidatingHttpServer(port, secretKey, requestConfiguration); connection = server.connect(); // Create a client with the filter that is under test Client client = createClient(); client.addFilter(new HmacClientFilter(apiKey, secretKey, client.getMessageBodyWorkers(), requestConfiguration)); client.addFilter(new GZIPContentEncodingFilter(true)); // Send a pizza in the request body Pizza pizza = new Pizza(); pizza.setTopping("olive"); client.resource(server.getUri()) .type(MediaType.APPLICATION_JSON_TYPE) .put(pizza); } finally { if (connection != null) { connection.close(); } } }
Example #20
Source File: BasicAuthenticationTestCase.java From eagle with Apache License 2.0 | 5 votes |
@Test public void testAdminOnlyWithoutAuth() { Client client = new Client(); client.resource(String.format("http://localhost:%d/rest/testAuth/adminOnlyWithoutAuth", RULE.getLocalPort())) .header("Authorization", ADMIN_AUTH_KEY) .get(String.class); }
Example #21
Source File: EcsSyncCtl.java From ecs-sync with Apache License 2.0 | 5 votes |
public EcsSyncCtl(String endpoint) { this.endpoint = endpoint; this.pluginResolver = new PluginResolver(); // initialize REST client ClientConfig cc = new DefaultClientConfig(); cc.getSingletons().add(pluginResolver); this.client = Client.create(cc); }
Example #22
Source File: RequestJob.java From ingestion with Apache License 2.0 | 5 votes |
/** * Initialize properties that are received in the {@code SchedulerContext}. * * @param context */ @SuppressWarnings("unchecked") public void initProperties(SchedulerContext context) { queue = (LinkedBlockingQueue<Event>) context.get("queue"); properties = (Map<String, String>) context.get("properties"); client = (Client) context.get("client"); restSourceHandler = (RestSourceHandler) context.get(HANDLER); urlHandler = (UrlHandler) context.get(URL_HANDLER); }
Example #23
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public Map<String, Object> generateTweetIdsLink(String code) throws AidrException { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); logger.info("[generateTweetIdsLink] Received request for code: " + code); try { /*System.out.println("Invoked URL: " + persisterMainUrl + "/taggerPersister/genTweetIds?collectionCode=" + code + "&downloadLimited=true");*/ WebTarget webResource = client.target(persisterMainUrl + "/taggerPersister/genTweetIds?collectionCode=" + code + "&downloadLimited=true"); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).get(); Map<String, Object> jsonResponse = clientResponse.readEntity(Map.class); logger.info("Returning from func: " + jsonResponse); return jsonResponse; /* * if (jsonResponse != null && * "http".equals(jsonResponse.substring(0, 4))) { return * jsonResponse; } else { return ""; } */ } catch (Exception e) { logger.error("Error while generating Tweet Ids link in Persister for collection: "+code, e); throw new AidrException( "[generateTweetIdsLink] Error while generating Tweet Ids link in Persister", e); } }
Example #24
Source File: RestClientFactory.java From qaf with MIT License | 5 votes |
public final Client getClient() { Client client = createClient(); client.addFilter(new ConnectionListenerFilter(getRequestListener())); client.addFilter(getRequestListener()); client.addFilter(getRequestTracker()); return client; }
Example #25
Source File: TimelineReaderFactory.java From tez with Apache License 2.0 | 5 votes |
@Override public Client getHttpClient() { ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class); HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory(connectionConf); Client httpClient = new Client(new URLConnectionClientHandler(urlFactory), config); return httpClient; }
Example #26
Source File: BaseTest.java From jerseyoauth2 with MIT License | 5 votes |
@Before public void setUp() { ClientConfig cc = new DefaultClientConfig(); restClient = Client.create(cc); authClient = new ClientManagerClient(restClient); clientEntity = registerClient(); }
Example #27
Source File: TaggerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public List<TaggerCrisis> getCrisesByUserId(Integer userId) throws AidrException { Client client = ClientBuilder.newBuilder() .register(JacksonFeature.class).build(); try { /** * Rest call to Tagger */ WebTarget webResource = client.target(taggerMainUrl + "/crisis?userID=" + userId); ObjectMapper objectMapper = JacksonWrapper.getObjectMapper(); objectMapper.configure( DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); Response clientResponse = webResource.request( MediaType.APPLICATION_JSON).get(); String jsonResponse = clientResponse.readEntity(String.class); TaggerAllCrisesResponse taggerAllCrisesResponse = objectMapper .readValue(jsonResponse, TaggerAllCrisesResponse.class); if (taggerAllCrisesResponse.getCrisises() != null) { logger.info("Tagger returned " + taggerAllCrisesResponse.getCrisises().size() + " crisis for user"); } return taggerAllCrisesResponse.getCrisises(); } catch (Exception e) { logger.error("Exception while fetching crisis by userId: "+userId, e); throw new AidrException( "No collection is enabled for Tagger. Please enable tagger for one of your collections.", e); } }
Example #28
Source File: OccurrenceWsClientIT.java From occurrence with Apache License 2.0 | 5 votes |
/** * The Annosys methods are implemented specifically to support Annosys and are not advertised or * documented in the public API. <em>They may be removed at any time without notice</em>. */ @Test public void testAnnosysXml() { Client client = Client.create(); WebResource webResource = client.resource(wsBaseUrl).path(OccurrencePaths.OCCURRENCE_PATH) .path(OccurrenceResource.ANNOSYS_PATH).path("10"); ClientResponse response = webResource.get(ClientResponse.class); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); assertTrue(response.getLength() > 0); client.destroy(); }
Example #29
Source File: KylinClient.java From ranger with Apache License 2.0 | 5 votes |
private static ClientResponse getClientResponse(String kylinUrl, String userName, String password) { ClientResponse response = null; String[] kylinUrls = kylinUrl.trim().split("[,;]"); if (ArrayUtils.isEmpty(kylinUrls)) { return null; } Client client = Client.create(); String decryptedPwd = PasswordUtils.getDecryptPassword(password); client.addFilter(new HTTPBasicAuthFilter(userName, decryptedPwd)); for (String currentUrl : kylinUrls) { if (StringUtils.isBlank(currentUrl)) { continue; } String url = currentUrl.trim() + KYLIN_LIST_API_ENDPOINT; try { response = getProjectResponse(url, client); if (response != null) { if (response.getStatus() == HttpStatus.SC_OK) { break; } else { response.close(); } } } catch (Throwable t) { String msgDesc = "Exception while getting kylin response, kylinUrl: " + url; LOG.error(msgDesc, t); } } client.destroy(); return response; }
Example #30
Source File: RestSource.java From ingestion with Apache License 2.0 | 5 votes |
private Client initClient(Context context) { final Boolean skipSsl = context.getBoolean(CONF_SKIP_SSL, Boolean.FALSE); if (skipSsl) { ClientConfig config = new DefaultClientConfig(); // SSL configuration // SSL configuration config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), getSSLContext())); return Client.create(config); } else { return new Client(); } }