use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getOidByGuid.
public Long getOidByGuid(Long roid, String guid) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Long> action = new GetOidByGuidDatabaseAction(session, getInternalAccessMethod(), roid, guid);
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 validateModelChecker.
@Override
public void validateModelChecker(Long oid) throws UserException, ServerException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Void> action = new ValidateModelCheckerDatabaseAction(getBimServer(), session, getInternalAccessMethod(), oid);
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 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();
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.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllCheckoutsOfRevision.
@Override
public List<SCheckout> getAllCheckoutsOfRevision(Long roid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsOfRevisionDatabaseAction(session, getInternalAccessMethod(), roid);
List<Checkout> list = session.executeAndCommitAction(action);
Collections.sort(list, new CheckoutComparator());
return getBimServer().getSConverter().convertToSListCheckout(list);
} 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 triggerNewRevision.
@Override
public void triggerNewRevision(Long roid, Long soid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Revision revision = (Revision) session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
if (revision == null) {
throw new UserException("No revision found for roid " + roid);
}
getBimServer().getNotificationsManager().notify(new NewRevisionNotification(getBimServer(), revision.getProject().getOid(), revision.getOid(), soid));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
Aggregations