|
|
@ -46,17 +46,7 @@ public class HttpWorkspaceConnector implements WorkspaceConnector { |
|
|
|
LoginResponseInfoBean bean; |
|
|
|
LoginResponseInfoBean bean; |
|
|
|
try { |
|
|
|
try { |
|
|
|
bean = RemoteAuthorityRepository.getInstance().login(createLoginBean(connectionInfo)); |
|
|
|
bean = RemoteAuthorityRepository.getInstance().login(createLoginBean(connectionInfo)); |
|
|
|
WorkspaceConnection connection = new WorkspaceConnection( |
|
|
|
checkValidAndUpdateInfo(client, connectionInfo, bean); |
|
|
|
UUID.randomUUID().toString(), |
|
|
|
|
|
|
|
connectionInfo.getUserName(), |
|
|
|
|
|
|
|
HttpConstants.AUTHORIZATION_PREFIX + bean.getAccessToken(), |
|
|
|
|
|
|
|
InetAddress.getLocalHost().getHostAddress()); |
|
|
|
|
|
|
|
client.updateConnection(connection); |
|
|
|
|
|
|
|
// 检查远程权限
|
|
|
|
|
|
|
|
if (!checkRemoteAuthority(connection)) { |
|
|
|
|
|
|
|
// 无权限则抛出无权限的错
|
|
|
|
|
|
|
|
throw new RemoteDesignPermissionDeniedException(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
client.closePool(); |
|
|
|
client.closePool(); |
|
|
|
} |
|
|
|
} |
|
|
@ -78,6 +68,18 @@ public class HttpWorkspaceConnector implements WorkspaceConnector { |
|
|
|
throw new RuntimeException("Empty token, try connect again and check server"); |
|
|
|
throw new RuntimeException("Empty token, try connect again and check server"); |
|
|
|
} |
|
|
|
} |
|
|
|
FineLoggerFactory.getLogger().info("[connector] infos:{}", bean.getAccessToken()); |
|
|
|
FineLoggerFactory.getLogger().info("[connector] infos:{}", bean.getAccessToken()); |
|
|
|
|
|
|
|
checkValidAndUpdateInfo(client, connectionInfo, bean); |
|
|
|
|
|
|
|
client.startHeartBeat(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
client.closePool(); |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CompatibleRegister.registerCompatibleEnv(); |
|
|
|
|
|
|
|
RepositoryManager.getInstance().clearLastPool(); |
|
|
|
|
|
|
|
return client; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void checkValidAndUpdateInfo(FineWorkspaceHttpClient client, WorkspaceConnectionInfo connectionInfo, LoginResponseInfoBean bean) throws Exception { |
|
|
|
WorkspaceConnection connection = new WorkspaceConnection( |
|
|
|
WorkspaceConnection connection = new WorkspaceConnection( |
|
|
|
UUID.randomUUID().toString(), |
|
|
|
UUID.randomUUID().toString(), |
|
|
|
connectionInfo.getUserName(), |
|
|
|
connectionInfo.getUserName(), |
|
|
@ -89,14 +91,6 @@ public class HttpWorkspaceConnector implements WorkspaceConnector { |
|
|
|
// 无权限则抛出无权限的错
|
|
|
|
// 无权限则抛出无权限的错
|
|
|
|
throw new RemoteDesignPermissionDeniedException(); |
|
|
|
throw new RemoteDesignPermissionDeniedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
client.startHeartBeat(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
client.closePool(); |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CompatibleRegister.registerCompatibleEnv(); |
|
|
|
|
|
|
|
RepositoryManager.getInstance().clearLastPool(); |
|
|
|
|
|
|
|
return client; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean checkRemoteAuthority(WorkspaceConnection connection) { |
|
|
|
private boolean checkRemoteAuthority(WorkspaceConnection connection) { |
|
|
|