use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method addSerializer.
@Override
public Long addSerializer(SSerializerPluginConfiguration serializer) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
SerializerPluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(serializer, session);
return session.executeAndCommitAction(new AddSerializerDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class LongDownloadOrCheckoutAction method executeAction.
protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
try {
if (action == null) {
checkoutResult = new SCheckoutResult();
checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
} else {
Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
if (revision == null) {
throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
}
// Little hack to make
revision.getProject().getGeoTag().load();
// sure this is
// lazily loaded,
// because after the
// executeAndCommitAction
// the session won't
// be usable
IfcModelInterface ifcModel = session.executeAndCommitAction(action);
// Session is closed after this
DatabaseSession newSession = getBimServer().getDatabase().createSession();
RenderEnginePlugin renderEnginePlugin = null;
try {
PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
if (serializerPluginConfiguration != null) {
if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
try {
messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
} catch (SerializerException e) {
e.printStackTrace();
}
} else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
if (renderEngine != null) {
renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
}
checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
}
}
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
newSession.close();
}
}
} finally {
done();
}
}
use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class GetSerializerByContentTypeDatabaseAction method execute.
@Override
public SerializerPluginConfiguration execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
for (SerializerPluginConfiguration serializerPluginConfiguration : getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), SerializerPluginConfiguration.class, OldQuery.getDefault())) {
PluginConfiguration pluginConfiguration = new PluginConfiguration(serializerPluginConfiguration.getSettings());
String string = pluginConfiguration.getString(SerializerPlugin.CONTENT_TYPE);
if (string != null && string.equals(contentType)) {
return serializerPluginConfiguration;
}
}
return null;
}
use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class GetSerializerByPluginClassNameDatabaseAction method execute.
@Override
public SerializerPluginConfiguration execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
PluginDescriptor pluginDescriptor = getDatabaseSession().querySingle(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(), pluginClassName);
if (pluginDescriptor == null) {
throw new UserException("No plugin found with classname " + pluginClassName);
}
User user = getUserByUoid(authorization.getUoid());
UserSettings userSettings = user.getUserSettings();
for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
if (serializerPluginConfiguration.getPluginDescriptor() == pluginDescriptor) {
return serializerPluginConfiguration;
}
}
throw new UserException("No plugin found for this user with classname " + pluginClassName);
}
use of org.bimserver.models.store.SerializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllSerializers.
@Override
public List<SSerializerPluginConfiguration> getAllSerializers(Boolean onlyEnabled) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
UserSettings userSettings = getUserSettings(session);
List<SSerializerPluginConfiguration> sSerializers = new ArrayList<SSerializerPluginConfiguration>();
for (SerializerPluginConfiguration serializerPluginConfiguration : userSettings.getSerializers()) {
if (!onlyEnabled || (serializerPluginConfiguration.getEnabled() && serializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sSerializers.add(getBimServer().getSConverter().convertToSObject(serializerPluginConfiguration));
}
}
Collections.sort(sSerializers, new SPluginConfigurationComparator());
return sSerializers;
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
Aggregations