use of org.bimserver.plugins.serializers.MessagingSerializerPlugin in project BIMserver by opensourceBIM.
the class SerializerFactory method createMessagingSerializer.
public MessagingSerializer createMessagingSerializer(String username, IfcModelInterface model, DownloadParameters downloadParameters) throws SerializerException {
DatabaseSession session = bimDatabase.createSession();
try {
MessagingSerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getMessagingSerializerPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
if (serializerPluginConfiguration != null) {
MessagingSerializerPlugin serializerPlugin = (MessagingSerializerPlugin) pluginManager.getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (serializerPlugin != null) {
ObjectType settings = serializerPluginConfiguration.getSettings();
MessagingSerializer serializer = serializerPlugin.createSerializer(new PluginConfiguration(settings));
if (serializer != null) {
try {
serializer.init(model, null, pluginManager, model.getPackageMetaData(), true);
return serializer;
} catch (NullPointerException e) {
LOGGER.error("", e);
}
}
}
}
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
session.close();
}
return null;
}
use of org.bimserver.plugins.serializers.MessagingSerializerPlugin in project BIMserver by opensourceBIM.
the class ServiceImpl method download.
@Override
public Long download(Set<Long> roids, String jsonQuery, Long serializerOid, Boolean sync) throws ServerException, UserException {
try {
User user = null;
DatabaseSession session = getBimServer().getDatabase().createSession();
Plugin plugin = null;
try {
SerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), serializerOid, OldQuery.getDefault());
plugin = getBimServer().getPluginManager().getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
} catch (BimserverDatabaseException e) {
throw new UserException(e);
} finally {
session.close();
}
if (plugin instanceof StreamingSerializerPlugin || plugin instanceof MessagingStreamingSerializerPlugin) {
LongStreamingDownloadAction longDownloadAction = new LongStreamingDownloadAction(getBimServer(), user == null ? "Unknown" : user.getName(), user == null ? "Unknown" : user.getUsername(), getAuthorization(), serializerOid, jsonQuery, roids);
try {
getBimServer().getLongActionManager().start(longDownloadAction);
} catch (Exception e) {
LOGGER.error("", e);
}
if (sync) {
longDownloadAction.waitForCompletion();
}
return longDownloadAction.getProgressTopic().getKey().getId();
} else if (plugin instanceof MessagingSerializerPlugin) {
requireAuthenticationAndRunningServer();
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
downloadParameters.setRoids(roids);
downloadParameters.setJsonQuery(jsonQuery);
downloadParameters.setSerializerOid(serializerOid);
return download(downloadParameters, sync);
} else if (plugin instanceof SerializerPlugin) {
requireAuthenticationAndRunningServer();
DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_BY_NEW_JSON_QUERY);
downloadParameters.setRoids(roids);
downloadParameters.setJsonQuery(jsonQuery);
downloadParameters.setSerializerOid(serializerOid);
return download(downloadParameters, sync);
} else {
throw new UserException("Unimplemented");
}
} catch (Exception e) {
return handleException(e);
}
}
Aggregations