com.bimface.sdk.client.ApiClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bimface-java-sdk Show documentation
Show all versions of bimface-java-sdk Show documentation
Bimface provide the required call java sdk.
The newest version!
package com.bimface.sdk.client;
import com.bimface.api.bean.compatible.response.BatchDeleteResultBean;
import com.bimface.api.bean.compatible.response.ShareLinkBean;
import com.bimface.api.bean.request.extraction.ExtractionQueryRequest;
import com.bimface.api.bean.request.extraction.ExtractionRequest;
import com.bimface.api.bean.request.integrate.FileIntegrateRequest;
import com.bimface.api.bean.request.integrate.IntegrateQueryRequest;
import com.bimface.api.bean.request.modelCompare.CompareRequest;
import com.bimface.api.bean.request.modelCompare.ModelCompareQueryRequest;
import com.bimface.api.bean.request.modelCompare.ModelCompareRequest;
import com.bimface.api.bean.request.scene.AutoUpdateSceneLayerRequest;
import com.bimface.api.bean.request.translate.FileTranslateRequest;
import com.bimface.api.bean.request.translate.TranslateQueryRequest;
import com.bimface.api.bean.request.v1.FileTranslateRequestV1;
import com.bimface.api.bean.response.*;
import com.bimface.api.bean.response.databagDerivative.IntegrateDatabagDerivativeBean;
import com.bimface.api.bean.response.databagDerivative.ModelCompareDatabagDerivativeBean;
import com.bimface.api.bean.response.databagDerivative.TranslateDatabagDerivativeBean;
import com.bimface.api.bean.request.clashDetective.ClashDetectiveRequest;
import com.bimface.api.bean.response.clashDetective.ClashDetectiveList;
import com.bimface.api.bean.response.clashDetective.ClashDetectiveResponse;
import com.bimface.api.bean.response.extraction.ExtractionInfoBean;
import com.bimface.api.bean.response.extraction.ExtractionResponse;
import com.bimface.api.bean.response.scene.AutoUpdateSceneLayerResponse;
import com.bimface.api.bean.response.v1.FileTranslateResponseV1;
import com.bimface.api.enums.TranslatePolicy;
import com.bimface.bean.GeneralResponse;
import com.bimface.exception.BimfaceException;
import com.bimface.http.BimfaceResponseChecker;
import com.bimface.page.PagedList;
import com.bimface.scene.bean.CreateSceneRequest;
import com.bimface.scene.bean.CreateSceneResp;
import com.bimface.scene.bean.response.SceneInfoResponse;
import com.bimface.sdk.bean.request.DatabagDerivativeRequest;
import com.bimface.sdk.bean.response.AccessTokenBean;
import com.bimface.sdk.config.Config;
import com.bimface.sdk.config.authorization.Credential;
import com.bimface.sdk.interfaces.ApiInterface;
import com.bimface.sdk.utils.AssertUtils;
import com.bimface.sdk.utils.StringUtils;
import com.glodon.paas.foundation.restclient.RESTClientBuilder;
import com.glodon.paas.foundation.restclient.RESTResponse;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Call;
import retrofit2.http.*;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;
public class ApiClient extends AbstractClient {
private static final Logger logger = LoggerFactory.getLogger(ApiClient.class);
private ApiInterface apiClient;
private static ApiClient instance;
public static synchronized ApiClient getApiClient(String apiBaseUrl) {
return getApiClient(apiBaseUrl, null);
}
public static synchronized ApiClient getApiClient(String apiBaseUrl, Config config) {
return instance != null ? instance : new ApiClient(apiBaseUrl, config);
}
private ApiClient(String apiBaseUrl, Config config) {
RESTClientBuilder builder = new RESTClientBuilder()
.serviceBaseUrl(apiBaseUrl);
// 如果没设置config,则使用rest client的默认配置
if (config != null) {
builder.timeoutMilli(config.getConnectTimeout(), config.getWriteTimeout(), config.getReadTimeout());
}
if (logger.isDebugEnabled()) {
builder.enableHttpLoggingInterceptor();
}
this.apiClient = builder.responseChecker(new BimfaceResponseChecker())
.build(ApiInterface.class);
}
public AccessTokenBean applyOAuthToken(@NotNull Credential credential) throws BimfaceException {
String basicOAuth = generateBasicOAuth(credential);
return executeCall(apiClient.applyOAuthToken(basicOAuth));
}
public String getViewToken(Long fileId, Long integrateId, Long compareId, Long sceneId, Long clashDetectiveId, @NotNull String accessToken) throws BimfaceException {
// fileId、integrateId、compareId、sceneId和clashDetectiveId中有且只有一个可以非null
int count = countNoNullArgs(fileId, integrateId, compareId, sceneId, clashDetectiveId);
if (count != 1) {
throw new IllegalArgumentException("one and only one argument can be not null in (fileId, integrateId, compareId, sceneId, clashDetectiveId)");
}
accessToken = validToken(accessToken);
return executeCall(apiClient.getViewToken(fileId, integrateId, compareId, sceneId, clashDetectiveId, accessToken));
}
public FileTranslateBean translate(@NotNull FileTranslateRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.translate(request, accessToken));
}
public FileTranslateBean getTranslation(@NotNull Long fileId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslation(fileId, accessToken));
}
public PagedList getTranslations(@NotNull TranslateQueryRequest translateQueryRequest, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslates(translateQueryRequest, accessToken));
}
public FileTranslateBean translate2Bimtiles(FileTranslateRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.translate2Bimtiles(request, accessToken));
}
//获取转换资源列表
public com.bimface.page.es.PagedList fileTranslateList(Long projectId, FileTranslateRequestV1 request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.fileTranslateList(projectId, request, accessToken));
}
public ShareLinkBean createShare(Long fileId, Long integrateId, Long sceneId, Integer activeDurationInHours, String expireDate, Boolean needPassword, @NotNull String accessToken) throws BimfaceException {
int count = countNoNullArgs(fileId, integrateId, sceneId);
if (count != 1) {
throw new IllegalArgumentException("one and only one argument can be not null in (fileId, integrateId)");
}
if (activeDurationInHours != null && !StringUtils.isNullOrEmpty(expireDate)) {
throw new IllegalArgumentException("only one argument can be not null in (activeDurationInHours, expireDate)");
}
if (activeDurationInHours != null && activeDurationInHours < 0) {
throw new IllegalArgumentException("activeDurationInHours can not be negative");
}
if (!StringUtils.isNullOrEmpty(expireDate) && !AssertUtils.isEffectiveDate(expireDate)) {
throw new IllegalArgumentException("expireDate is not effective data");
}
accessToken = validToken(accessToken);
return executeCall(apiClient.createShare(fileId, integrateId, sceneId, activeDurationInHours, expireDate, needPassword, accessToken));
}
public String deleteShare(Long fileId, Long integrateId, Long sceneId, @NotNull String accessToken) throws BimfaceException {
int argNum = countNoNullArgs(fileId, integrateId, sceneId);
if (argNum != 1) {
throw new IllegalArgumentException("one and only one argument can be not null in (fileId, integrateId)");
}
accessToken = validToken(accessToken);
return executeCall(apiClient.deleteShare(fileId, integrateId, sceneId, accessToken));
}
public BatchDeleteResultBean batchDeteleShare(List sourceIds, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.batchDeteleShare(sourceIds, accessToken));
}
public ShareLinkBean getShareLink(String token, Long fileId, Long integrateId, Long sceneId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getShareLink(token, fileId, integrateId, sceneId, accessToken));
}
public PagedList shareList(@NotNull String accessToken, Integer pageNo, Integer pageSize) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.shareList(accessToken, pageNo, pageSize));
}
public TranslateDatabagDerivativeBean createTranslateOfflineDatabag(@NotNull Long fileId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createTranslateOfflineDatabag(fileId, callback, request, accessToken));
}
public IntegrateDatabagDerivativeBean createIntegateOfflineDatabag(@NotNull Long integrateId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createIntegateOfflineDatabag(integrateId, callback, request, accessToken));
}
public ModelCompareDatabagDerivativeBean createCompareOfflineDatabag(@NotNull Long compareId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createCompareOfflineDatabag(compareId, callback, request, accessToken));
}
public List getTranslateOfflineDatabag(@NotNull Long fileId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslateOfflineDatabag(fileId, accessToken));
}
public List getIntegrateOfflineDatabag(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrateOfflineDatabag(integrateId, accessToken));
}
public List getCompareOfflineDatabag(@NotNull Long compareId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getCompareOfflineDatabag(compareId, accessToken));
}
public TranslateDatabagDerivativeBean exportTranslateGltfDatabag(Long fileId, String callback, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.exportTranslateGltfDatabag(fileId, callback, accessToken));
}
public List getTranslateGltfDatabag(Long fileId, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslateGltfDatabag(fileId, accessToken));
}
public FileIntegrateBean integrate(@NotNull FileIntegrateRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.integrate(request, accessToken));
}
public FileIntegrateBean getIntegrate(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrate(integrateId, accessToken));
}
public PagedList getIntegrates(@NotNull IntegrateQueryRequest integrateQueryRequest, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrates(integrateQueryRequest, accessToken));
}
public FileIntegrateBean integrate2Bimtiles(FileIntegrateRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.integrate2Bimtiles(request, accessToken));
}
public void deleteIntegrate(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
executeCall(apiClient.deleteIntegrate(integrateId, accessToken));
}
public FileIntegrateBean modify(@NotNull Long integrateId, String name, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.modify(integrateId, name, accessToken));
}
public ModelCompareBean invokeModelCompare(@NotNull ModelCompareRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.invokeModelCompare(request, accessToken));
}
public ModelCompareBean invokeModelComparev2(@NotNull CompareRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.invokeModelCompareV2(request, accessToken));
}
public ModelCompareBean getModelCompare(@NotNull Long compareId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getModelCompareV2(compareId, accessToken));
}
public PagedList getModelCompares(@NotNull ModelCompareQueryRequest modelCompareQueryRequest, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getModelCompares(modelCompareQueryRequest, accessToken));
}
public void deleteModelCompare(@NotNull Long compareId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
executeCall(apiClient.deleteModelCompareV2(compareId, accessToken));
}
public TranslateDatabagDerivativeBean createDrawingSplit(@NotNull Long fileId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createDrawingSplit(fileId, callback, request, accessToken));
}
public TranslateDatabagDerivativeBean getDrawingSplit(@NotNull Long fileId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getDrawingSplit(fileId, accessToken));
}
public IntegrateDatabagDerivativeBean exportIntegrateGltfDatabag(@NotNull Long integrateId, String callback,
@NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.exportIntegrateGltfDatabag(integrateId, callback, accessToken));
}
public List getIntegrateGltfDatabags(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrateGltfDatabags(integrateId, accessToken));
}
public TranslateDatabagDerivativeBean exportTranslate3DTilesDatabag(@NotNull Long fileId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.exportTranslate3DTilesDatabag(fileId, callback, request, accessToken));
}
public List getTranslate3DTilesDatabags(@NotNull Long fileId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslate3DTilesDatabags(fileId, accessToken));
}
public IntegrateDatabagDerivativeBean exportIntegrate3DTilesDatabag(@NotNull Long integrateId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.exportIntegrate3DTilesDatabag(integrateId, callback, request, accessToken));
}
public List getIntegrate3DTilesDatabags(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrate3DTilesDatabags(integrateId, accessToken));
}
public TranslateDatabagDerivativeBean createTranslateBakeDatabag(@NotNull Long fileId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createTranslateBakeDatabag(fileId, callback, request, accessToken));
}
public List getTranslateBakeDatabags(@NotNull Long fileId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getTranslateBakeDatabags(fileId, accessToken));
}
public IntegrateDatabagDerivativeBean createIntegrateBakeDatabag(@NotNull Long integrateId, String callback,
DatabagDerivativeRequest request, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createIntegrateBakeDatabag(integrateId, callback, request, accessToken));
}
public List getIntegrateBakeDatabags(@NotNull Long integrateId, @NotNull String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getIntegrateBakeDatabags(integrateId, accessToken));
}
public CreateSceneResp createScene(CreateSceneRequest sceneInfo, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createScene(sceneInfo, accessToken));
}
public String updateScene(Long sceneId, CreateSceneRequest sceneInfo, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.updateScene(sceneId, sceneInfo, accessToken));
}
public SceneInfoResponse getScene(Long sceneId, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.getScene(sceneId, accessToken));
}
public ClashDetectiveResponse createClashDetective(ClashDetectiveRequest request, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createClashDetective(request, accessToken));
}
public ClashDetectiveResponse queryClashDetective(Long clashDetectiveId, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.queryClashDetective(clashDetectiveId, accessToken));
}
public ClashDetectiveList queryClashDetectiveByModelId(Long fileId, Long integrateId, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.queryClashDetectiveByModelId(fileId, integrateId, accessToken));
}
public ExtractionResponse createExtraction(ExtractionRequest request, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.createExtraction(request, accessToken));
}
public PagedList queryExtraction(ExtractionQueryRequest queryRequest, Integer pageNo, Integer pageSize, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.queryExtraction(queryRequest, pageNo, pageSize, accessToken));
}
public Void deleteExtraction(Long fileId, Long integrateId, String extractType, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.deleteExtraction(fileId, integrateId, extractType, accessToken));
}
// sdk中的很多方法都是传多个参数,但是保证有且仅有一个不为null的时候才有效
private int countNoNullArgs(Long... args) {
int count = 0;
for (Long arg : args) {
count = arg != null ? ++count : count;
}
return count;
}
public AutoUpdateSceneLayerResponse autoUpdateSceneLayers(Long sceneId, AutoUpdateSceneLayerRequest autoUpdateSceneLayerRequest, String accessToken) throws BimfaceException {
accessToken = validToken(accessToken);
return executeCall(apiClient.autoUpdateSceneLayers(sceneId, autoUpdateSceneLayerRequest, accessToken));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy