com.bimface.sdk.service.DatabagService 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.service;
import com.bimface.exception.BimfaceException;
import com.bimface.sdk.client.DataClient;
import com.bimface.sdk.config.Config;
import com.bimface.sdk.config.Endpoint;
import com.bimface.sdk.utils.AssertUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class DatabagService {
private DataClient dataClient;
private AccessTokenService accessTokenService;
public DatabagService(Endpoint endpoint, AccessTokenService accessTokenService) {
this(endpoint, null, accessTokenService);
}
public DatabagService(Endpoint endpoint, Config config, AccessTokenService accessTokenService) {
this.dataClient = DataClient.getDataClient(endpoint.getApiHost() + "/data/", config);
this.accessTokenService = accessTokenService;
}
public InputStream getFileDatabagContent(Long fileId) throws BimfaceException {
String dataBagUrl = getFileDatabagUrl(fileId);
try {
return new URL(dataBagUrl).openStream();
} catch (IOException e) {
throw new BimfaceException("download by url error, url: " + dataBagUrl, e);
}
}
public String getFileDatabagUrl(Long fileId) throws BimfaceException{
AssertUtils.assertParameterNotNull(fileId, "fileId");
String accessToken = accessTokenService.getAccessToken();
return dataClient.getDatabagDownloadUrl(fileId, null, null, null, null, accessToken);
}
public Long getFileDatabagSize(Long fileId) throws BimfaceException{
AssertUtils.assertParameterNotNull(fileId, "fileId");
return dataClient.getDatabagSize(fileId, accessTokenService.getAccessToken());
}
public String getFileDataBagRootUrl(Long fileId) throws BimfaceException {
return dataClient.getFileDatabagRootUrl(fileId, accessTokenService.getAccessToken());
}
public String getIntegrateDatabagRootUrl(Long integrateId) throws BimfaceException {
return dataClient.getIntegrateDatabagRootUrl(integrateId, accessTokenService.getAccessToken());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy