use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getNewService.
public org.bimserver.interfaces.objects.SNewService getNewService(Long soid) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
org.bimserver.models.store.NewService externalProfile = session.get(StorePackage.eINSTANCE.getNewService(), soid, OldQuery.getDefault());
return getBimServer().getSConverter().convertToSObject(externalProfile);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getGeometryInfo.
@Override
public SGeometryInfo getGeometryInfo(Long roid, Long oid) throws UserException, ServerException {
requireAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<SGeometryInfo> action = new GetGeometryInfoDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, oid, getAuthorization());
return session.executeAndCommitAction(action);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method checkinInternal.
private Long checkinInternal(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, InputStream originalInputStream, Boolean merge, Boolean sync, final DatabaseSession session, String username, String userUsername, Project project, Path file, long newServiceId) throws BimserverDatabaseException, UserException, IOException, DeserializeException, CannotBeScheduledException {
if (getBimServer().getCheckinsInProgress().containsKey(poid)) {
throw new UserException("Checkin in progress on this project, please try again later");
}
getBimServer().getCheckinsInProgress().put(poid, getAuthorization().getUoid());
DeserializerPluginConfiguration deserializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getDeserializerPluginConfiguration(), deserializerOid, OldQuery.getDefault());
if (deserializerPluginConfiguration == null) {
throw new UserException("Deserializer with oid " + deserializerOid + " not found");
} else {
PluginBundleVersion pluginBundleVersion = deserializerPluginConfiguration.getPluginDescriptor().getPluginBundleVersion();
Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (plugin != null) {
if (plugin instanceof DeserializerPlugin) {
DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
ObjectType settings = deserializerPluginConfiguration.getSettings();
Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration(settings));
OutputStream outputStream = Files.newOutputStream(file);
InputStream inputStream = new MultiplexingInputStream(originalInputStream, outputStream);
deserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
IfcModelInterface model = null;
try {
model = deserializer.read(inputStream, fileName, fileSize, null);
} finally {
inputStream.close();
}
CheckinDatabaseAction checkinDatabaseAction = new CheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), model, comment, fileName, merge, newServiceId);
LongCheckinAction longAction = new LongCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
getBimServer().getLongActionManager().start(longAction);
if (sync) {
longAction.waitForCompletion();
}
return longAction.getProgressTopic().getKey().getId();
} else if (plugin instanceof StreamingDeserializerPlugin) {
StreamingDeserializerPlugin streaminDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
ObjectType settings = deserializerPluginConfiguration.getSettings();
StreamingDeserializer streamingDeserializer = streaminDeserializerPlugin.createDeserializer(new PluginConfiguration(settings));
streamingDeserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
RestartableInputStream restartableInputStream = new RestartableInputStream(originalInputStream, file);
StreamingCheckinDatabaseAction checkinDatabaseAction = new StreamingCheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), comment, fileName, restartableInputStream, streamingDeserializer, fileSize, newServiceId, pluginBundleVersion);
LongStreamingCheckinAction longAction = new LongStreamingCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
getBimServer().getLongActionManager().start(longAction);
if (sync) {
longAction.waitForCompletion();
}
return longAction.getProgressTopic().getKey().getId();
} else {
throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
}
} else {
throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
}
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method removeServiceFromProject.
@Override
public void removeServiceFromProject(Long poid, Long serviceOid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Boolean> action = new RemoveServiceFromProjectDatabaseAction(getBimServer(), session, getInternalAccessMethod(), serviceOid, poid, getAuthorization());
session.executeAndCommitAction(action);
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class SettingsServiceImpl method setEmailSenderAddress.
@Override
public void setEmailSenderAddress(final String emailSenderAddress) throws ServerException, UserException {
if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
requireAdminAuthentication();
}
if (emailSenderAddress.trim().isEmpty()) {
throw new UserException("Email sender address cannot be empty");
}
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {
@Override
public void set(ServerSettings serverSettings) {
serverSettings.setEmailSenderAddress(emailSenderAddress);
}
});
session.executeAndCommitAction(action);
} catch (BimserverDatabaseException e) {
handleException(e);
} finally {
session.close();
}
}
Aggregations