|
|
|
@ -35,13 +35,22 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean testConnection(WorkspaceConnectionInfo connectionInfo) throws Exception { |
|
|
|
|
LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); |
|
|
|
|
FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); |
|
|
|
|
LoginResponseInfoBean bean; |
|
|
|
|
try { |
|
|
|
|
bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
client.closePool(); |
|
|
|
|
throw e; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return StringUtils.isNotEmpty(bean.getAccessToken()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public WorkspaceClient connect(WorkspaceConnectionInfo connectionInfo) throws Exception { |
|
|
|
|
FineWorkspaceHttpClient client = FineWorkspaceHttpClient.create("Http-Client", connectionInfo); |
|
|
|
|
try { |
|
|
|
|
LoginResponseInfoBean bean = RemoteNetworkRepository.getInstance().login(createLoginBean(connectionInfo)); |
|
|
|
|
WorkspaceConnection connection = new WorkspaceConnection( |
|
|
|
|
UUID.randomUUID().toString(), |
|
|
|
@ -49,6 +58,10 @@ public class HttpWorkspaceConnector implements WorkspaceConnector {
|
|
|
|
|
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), |
|
|
|
|
InetAddress.getLocalHost().getHostAddress()); |
|
|
|
|
client.updateConnection(connection); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
client.closePool(); |
|
|
|
|
throw e; |
|
|
|
|
} |
|
|
|
|
client.startHeartBeat(); |
|
|
|
|
CompatibleRegister.registerCompatibleEnv(); |
|
|
|
|
return client; |
|
|
|
|