use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class ServiceImpl method getSuggestedDeserializerForExtension.
@Override
public SDeserializerPluginConfiguration getSuggestedDeserializerForExtension(String extension, Long poid) throws ServerException, UserException {
// Token authenticated users should also be able to call this method
try {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
List<DeserializerPluginConfiguration> list = new ArrayList<>();
try {
Project project = session.get(poid, OldQuery.getDefault());
UserSettings userSettings = getUserSettings(session);
for (DeserializerPluginConfiguration deserializer : userSettings.getDeserializers()) {
Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializer.getPluginDescriptor().getIdentifier(), true);
if (plugin instanceof DeserializerPlugin) {
DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
if (deserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (deserializerPlugin.canHandleExtension(extension)) {
list.add(deserializer);
}
}
} else if (plugin instanceof StreamingDeserializerPlugin) {
StreamingDeserializerPlugin streamingDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
if (streamingDeserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (streamingDeserializerPlugin.canHandleExtension(extension)) {
list.add(deserializer);
}
}
}
}
} finally {
session.close();
}
if (list.size() == 1) {
return getBimServer().getSConverter().convertToSObject(list.get(0));
} else if (list.size() > 1) {
for (DeserializerPluginConfiguration deserializerPluginConfiguration : list) {
Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getIdentifier(), true);
// Prefer the streaming version
if (plugin instanceof StreamingDeserializerPlugin) {
return getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration);
}
}
// Just return the first one
return getBimServer().getSConverter().convertToSObject(list.get(0));
}
} catch (Exception e) {
return handleException(e);
}
return null;
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllDeserializers.
@Override
public List<SDeserializerPluginConfiguration> getAllDeserializers(Boolean onlyEnabled) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
UserSettings userSettings = getUserSettings(session);
EList<DeserializerPluginConfiguration> deserializers = userSettings.getDeserializers();
List<SDeserializerPluginConfiguration> sDeserializers = new ArrayList<SDeserializerPluginConfiguration>();
for (DeserializerPluginConfiguration deserializerPluginConfiguration : deserializers) {
if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
}
}
Collections.sort(sDeserializers, new SPluginConfigurationComparator());
return sDeserializers;
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method addDeserializer.
@Override
public Long addDeserializer(SDeserializerPluginConfiguration deserializer) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
DeserializerPluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(deserializer, session);
return session.executeAndCommitAction(new AddDeserializerDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method updateDeserializer.
@Override
public void updateDeserializer(SDeserializerPluginConfiguration deserializer) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
DeserializerPluginConfiguration convert = session.get(deserializer.getOid(), OldQuery.getDefault());
getBimServer().getSConverter().convertFromSObject(deserializer, convert, session);
session.executeAndCommitAction(new UpdateDeserializerDatabaseAction(session, getInternalAccessMethod(), convert));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.interfaces.objects.SDeserializerPluginConfiguration in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllDeserializersForProject.
@Override
public List<SDeserializerPluginConfiguration> getAllDeserializersForProject(Boolean onlyEnabled, Long poid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Project project = session.get(poid, OldQuery.getDefault());
UserSettings userSettings = getUserSettings(session);
EList<DeserializerPluginConfiguration> deserializers = userSettings.getDeserializers();
List<SDeserializerPluginConfiguration> sDeserializers = new ArrayList<SDeserializerPluginConfiguration>();
for (DeserializerPluginConfiguration deserializerPluginConfiguration : deserializers) {
DeserializerPlugin plugin = getBimServer().getPluginManager().getDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (plugin == null) {
StreamingDeserializerPlugin streamingPlugin = getBimServer().getPluginManager().getStreamingDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (streamingPlugin != null) {
if (streamingPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
}
}
}
} else {
if (plugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
}
}
}
}
Collections.sort(sDeserializers, new SPluginConfigurationComparator());
return sDeserializers;
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
Aggregations