Search in sources :

Example 11 with BimServerClientFactory

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);
    }
}
Also used : JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) UserException(org.bimserver.shared.exceptions.UserException) SServiceDescriptor(org.bimserver.interfaces.objects.SServiceDescriptor) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 12 with BimServerClientFactory

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);
    }
}
Also used : SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) UserException(org.bimserver.shared.exceptions.UserException) OAuthServer(org.bimserver.models.store.OAuthServer) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) OAuthAuthorizationCode(org.bimserver.models.store.OAuthAuthorizationCode) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Aggregations

JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)12 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)12 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)9 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)9 ServiceException (org.bimserver.shared.exceptions.ServiceException)9 IOException (java.io.IOException)8 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)7 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)6 Path (java.nio.file.Path)5 PluginException (org.bimserver.shared.exceptions.PluginException)5 ServerException (org.bimserver.shared.exceptions.ServerException)5 UserException (org.bimserver.shared.exceptions.UserException)5 MetaDataManager (org.bimserver.emf.MetaDataManager)4 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)4 SProject (org.bimserver.interfaces.objects.SProject)4 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)3 ProtocolBuffersBimServerClientFactory (org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory)3 SoapBimServerClientFactory (org.bimserver.client.soap.SoapBimServerClientFactory)3 DatabaseSession (org.bimserver.database.DatabaseSession)3 PluginManager (org.bimserver.plugins.PluginManager)3