Merge branch 'develop' into stable
This commit is contained in:
commit
cf1da9b6f1
@ -2,6 +2,7 @@ package com.inteligr8.alfresco.acs;
|
||||
|
||||
import javax.ws.rs.client.Client;
|
||||
import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -26,4 +27,9 @@ public class AcsClient {
|
||||
return client;
|
||||
}
|
||||
|
||||
public WebTarget getTarget() {
|
||||
return this.getClient()
|
||||
.target(this.config.getBaseUrl());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ComponentScan
|
||||
public class AcsClientConfiguration {
|
||||
|
||||
@Value("${content.service.baseUrl}")
|
||||
@Value("${content.service.baseUrl:http://localhost:8080/alfresco}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${content.service.security.basicAuth.username}")
|
||||
@Value("${content.service.security.basicAuth.username:admin}")
|
||||
private String basicAuthUsername;
|
||||
|
||||
@Value("${content.service.security.basicAuth.password}")
|
||||
@Value("${content.service.security.basicAuth.password:admin}")
|
||||
private String basicAuthPassword;
|
||||
|
||||
@Value("${content.service.security.accessToken}")
|
||||
@ -27,10 +27,10 @@ public class AcsClientConfiguration {
|
||||
}
|
||||
|
||||
public void authorize(Client client) {
|
||||
if (this.basicAuthUsername != null) {
|
||||
client.register(new BasicAuthRequestFilter(this.basicAuthUsername, this.basicAuthPassword));
|
||||
} else if (this.accessToken != null) {
|
||||
if (this.accessToken != null) {
|
||||
client.register(new AccessTokenRequestFilter(this.accessToken));
|
||||
} else if (this.basicAuthUsername != null) {
|
||||
client.register(new BasicAuthRequestFilter(this.basicAuthUsername, this.basicAuthPassword));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,10 @@ public class ConnectionClientIT {
|
||||
@Autowired
|
||||
private AcsClient client;
|
||||
|
||||
@Autowired
|
||||
private AcsClientConfiguration config;
|
||||
|
||||
@Test
|
||||
//@EnabledIf("hostExists")
|
||||
public void testDiscovery() {
|
||||
Client client = this.client.getClient();
|
||||
WebTarget target = client.target(this.config.getBaseUrl());
|
||||
WebTarget target = this.client.getTarget();
|
||||
DiscoveryApi api = WebResourceFactory.newResource(DiscoveryApi.class, target);
|
||||
RepositoryInfo repoInfo = api.getRepositoryInformation().getEntry().getRepository();
|
||||
|
||||
@ -55,9 +51,9 @@ public class ConnectionClientIT {
|
||||
}
|
||||
|
||||
public boolean hostExists() {
|
||||
String baseUrl = this.config.getBaseUrl();
|
||||
URI uri = this.client.getTarget().getUri();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder(URI.create(baseUrl))
|
||||
HttpRequest request = HttpRequest.newBuilder(uri)
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user