use of org.bimserver.shared.interfaces.async.AsyncRemoteServiceInterface.NewExtendedDataOnRevisionCallback in project BIMserver by opensourceBIM.
the class NewExtendedDataOnRevisionNotification method triggerNewExtendedData.
public void triggerNewExtendedData(DatabaseSession session, NotificationsManager notificationsManager, final BimServer bimServer, String siteAddress, Project project, final long roid, Trigger trigger, final Service service) throws UserException, ServerException {
if (service.getTrigger() == trigger) {
Channel channel = null;
try {
channel = notificationsManager.getChannel(service);
final RemoteServiceInterface remoteServiceInterface = channel.get(RemoteServiceInterface.class);
long writeProjectPoid = service.getWriteRevision() == null ? -1 : service.getWriteRevision().getOid();
long writeExtendedDataRoid = service.getWriteExtendedData() != null ? roid : -1;
long readRevisionRoid = service.isReadRevision() ? roid : -1;
long readExtendedDataRoid = service.getReadExtendedData() != null ? roid : -1;
final ExplicitRightsAuthorization authorization = new ExplicitRightsAuthorization(bimServer, service.getUser().getOid(), service.getOid(), new long[] { readRevisionRoid }, writeProjectPoid, readExtendedDataRoid, writeExtendedDataRoid);
ServiceInterface newService = bimServer.getServiceFactory().get(authorization, AccessMethod.INTERNAL).get(ServiceInterface.class);
// TODO redundant?
((org.bimserver.webservices.impl.ServiceImpl) newService).setAuthorization(authorization);
AsyncRemoteServiceInterface asyncRemoteServiceInterface = new AsyncRemoteServiceInterface(remoteServiceInterface, bimServer.getExecutorService());
asyncRemoteServiceInterface.newExtendedDataOnRevision(poid, roid, edid, soid, service.getServiceIdentifier(), service.getProfileIdentifier(), service.getToken(), authorization.asHexToken(bimServer.getEncryptionKey()), bimServer.getServerSettingsCache().getServerSettings().getSiteAddress(), new NewExtendedDataOnRevisionCallback() {
@Override
public void success() {
}
@Override
public void error(Throwable e) {
LOGGER.error("", e);
}
});
asyncRemoteServiceInterface.newRevision(poid, roid, service.getOid(), service.getServiceIdentifier(), service.getProfileIdentifier(), service.getToken(), authorization.asHexToken(bimServer.getEncryptionKey()), bimServer.getServerSettingsCache().getServerSettings().getSiteAddress(), new NewRevisionCallback() {
@Override
public void success() {
}
@Override
public void error(Throwable e) {
LOGGER.error("", e);
}
});
} catch (ChannelConnectionException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
} finally {
if (channel != null) {
// TODO This is interesting, when sending async, is this not going to break?
channel.disconnect();
}
}
}
}
Aggregations