use of org.bimserver.shared.BimServerClientFactory in project BIMserver by opensourceBIM.
the class ServiceImpl method getServiceDescriptor.
@Override
public SServiceDescriptor getServiceDescriptor(String baseUrl, String serviceIdentifier) throws ServerException, UserException {
requireRealUserAuthentication();
try {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(baseUrl, getBimServer().getServicesMap(), getBimServer().getJsonSocketReflectorFactory(), getBimServer().getReflectorFactory(), getBimServer().getMetaDataManager())) {
try (BimServerClientInterface client = factory.create()) {
SServiceDescriptor service = client.getRemoteServiceInterface().getService(serviceIdentifier);
if (service == null) {
throw new UserException("No service found with identifier " + serviceIdentifier);
}
service.setUrl(baseUrl);
return service;
}
}
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.shared.BimServerClientFactory in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllPrivateProfiles.
@Override
public List<SProfileDescriptor> getAllPrivateProfiles(String notificationsUrl, String serviceIdentifier) throws ServerException, UserException {
if (notificationsUrl == null) {
throw new UserException("Missing notificationsUrl");
}
requireRealUserAuthentication();
try (DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY)) {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(notificationsUrl, getBimServer().getServicesMap(), getBimServer().getJsonSocketReflectorFactory(), getBimServer().getReflectorFactory(), getBimServer().getMetaDataManager())) {
BimServerClientInterface client = factory.create();
OAuthServer oAuthServer = session.querySingle(StorePackage.eINSTANCE.getOAuthServer_ApiUrl(), notificationsUrl);
User user = session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
for (OAuthAuthorizationCode oAuthAuthorizationCode : user.getOAuthAuthorizationCodes()) {
if (oAuthAuthorizationCode.getOauthServer() == oAuthServer) {
return client.getRemoteServiceInterface().getPrivateProfiles(serviceIdentifier, oAuthAuthorizationCode.getCode());
}
}
return null;
}
} catch (Exception e) {
return handleException(e);
}
}
Aggregations