use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getModelBounds.
@Override
public SBounds getModelBounds(Long roid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
Revision revision = session.get(roid, OldQuery.getDefault());
ConcreteRevision lastConcreteRevision = revision.getLastConcreteRevision();
Bounds bounds = lastConcreteRevision.getBounds();
Vector3f min = bounds.getMin();
Vector3f max = bounds.getMax();
if (lastConcreteRevision.getMultiplierToMm() != 1f) {
min.setX(min.getX() * lastConcreteRevision.getMultiplierToMm());
min.setY(min.getY() * lastConcreteRevision.getMultiplierToMm());
min.setZ(min.getZ() * lastConcreteRevision.getMultiplierToMm());
max.setX(max.getX() * lastConcreteRevision.getMultiplierToMm());
max.setY(max.getY() * lastConcreteRevision.getMultiplierToMm());
max.setZ(max.getZ() * lastConcreteRevision.getMultiplierToMm());
}
return getBimServer().getSConverter().convertToSObject(bounds);
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method sendCompareEmail.
@Override
public void sendCompareEmail(SCompareType sCompareType, Long mcid, Long poid, Long roid1, Long roid2, String address) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
SUser currentUser = getCurrentUser(session);
Revision revision1 = session.get(StorePackage.eINSTANCE.getRevision(), roid1, OldQuery.getDefault());
Revision revision2 = session.get(StorePackage.eINSTANCE.getRevision(), roid2, OldQuery.getDefault());
String senderName = currentUser.getName();
String senderAddress = currentUser.getUsername();
if (!senderAddress.contains("@") || !senderAddress.contains(".")) {
senderAddress = getBimServer().getServerSettingsCache().getServerSettings().getEmailSenderAddress();
}
EmailMessage message = getBimServer().getMailSystem().createMessage();
try {
InternetAddress addressFrom = new InternetAddress(senderAddress);
addressFrom.setPersonal(senderName);
message.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[1];
addressTo[0] = new InternetAddress(address);
message.setRecipients(Message.RecipientType.TO, addressTo);
message.setSubject("BIMserver Model Comparator");
SCompareResult compareResult = compare(roid1, roid2, sCompareType, mcid);
String html = CompareWriter.writeCompareResult(compareResult, revision1.getId(), revision2.getId(), sCompareType, getServiceMap().getServiceInterface().getProjectByPoid(poid), false);
message.setContent(html, "text/html");
message.send();
} catch (AddressException e) {
throw new UserException(e);
} catch (UnsupportedEncodingException e) {
throw new UserException(e);
} catch (MessagingException e) {
throw new UserException(e);
}
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllAuthorizedUsersOfProject.
@Override
public List<SUser> getAllAuthorizedUsersOfProject(Long poid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
BimDatabaseAction<Set<User>> action = new GetAllAuthorizedUsersOfProjectDatabaseAction(session, getInternalAccessMethod(), poid);
return new ArrayList<SUser>(getBimServer().getSConverter().convertToSSetUser(session.executeAndCommitAction(action)));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method getSerializerByName.
@Override
public SSerializerPluginConfiguration getSerializerByName(String serializerName) throws ServerException, UserException {
requireAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
try {
return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetSerializerByNameDatabaseAction(session, getInternalAccessMethod(), serializerName)));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.
the class ServiceImpl method addExtendedDataToRevision.
@Override
public void addExtendedDataToRevision(Long roid, SExtendedData extendedData) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
try {
ExtendedData convert = getBimServer().getSConverter().convertFromSObject(extendedData, session.create(ExtendedData.class), session);
session.executeAndCommitAction(new AddExtendedDataToRevisionDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, getAuthorization(), convert));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
Aggregations