Search in sources :

Example 11 with EndPoint

use of org.bimserver.endpoints.EndPoint in project BIMserver by opensourceBIM.

the class NotificationRegistryServiceImpl method unregisterChangeProgressOnRevision.

@Override
public void unregisterChangeProgressOnRevision(Long endPointId, Long poid, Long roid) throws ServerException, UserException {
    ChangeProgressTopicOnRevisionTopic changeProgressOnProjectTopic = getBimServer().getNotificationsManager().getChangeProgressOnRevisionTopic(poid, roid);
    EndPoint endPoint = getEndPoint(endPointId);
    try {
        changeProgressOnProjectTopic.unregister(endPoint);
    } catch (TopicRegisterException e) {
        handleException(e);
    }
}
Also used : TopicRegisterException(org.bimserver.notifications.TopicRegisterException) ChangeProgressTopicOnRevisionTopic(org.bimserver.notifications.ChangeProgressTopicOnRevisionTopic) EndPoint(org.bimserver.endpoints.EndPoint)

Example 12 with EndPoint

use of org.bimserver.endpoints.EndPoint in project BIMserver by opensourceBIM.

the class ProgressTopic method updateProgress.

protected synchronized void updateProgress(final LongActionState state) {
    try {
        // Actually we should be keeping track of when we last sent a message to A SPECIFIC ENDPOINT, this way, new endpoints won't receive the message rights away
        boolean sendMessage = lastSent == -1L || (System.nanoTime() - lastSent > RATE_LIMIT_NANO_SECONDS && state.getProgress().intValue() != lastProgress.getProgress().intValue());
        sendMessage |= state.getProgress() == 100;
        sendMessage |= state.getState() == ActionState.FINISHED;
        sendMessage |= state.getState() == ActionState.AS_ERROR;
        sendMessage |= lastProgress != null && lastProgress.getStage() != state.getStage();
        sendMessage |= lastProgress != null && ((lastProgress.getTitle() == null && state.getTitle() != null) || !lastProgress.getTitle().equals(state.getTitle()));
        if (sendMessage) {
            try {
                // System.out.println("Sending " + state.getProgress() + ", " + state.getState() + ", " + state.getTitle() + " to " + getEndPoints().size());
                map(new Mapper() {

                    @Override
                    public void map(EndPoint endPoint) throws UserException, ServerException, BimserverDatabaseException {
                        try {
                            endPoint.getNotificationInterface().progress(key.getId(), new SConverter().convertToSObject(state));
                        } catch (Exception e) {
                            LOGGER.error("", e);
                        }
                    }
                });
            } catch (Exception e) {
                LOGGER.error("", e);
            }
            lastProgress = state;
            lastSent = System.nanoTime();
        } else {
        // System.out.println("Skipping " + state.getProgress() + ", " + state.getState() + ", " + state.getTitle());
        }
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) ServerException(org.bimserver.shared.exceptions.ServerException) SConverter(org.bimserver.interfaces.SConverter) EndPoint(org.bimserver.endpoints.EndPoint) UserException(org.bimserver.shared.exceptions.UserException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Aggregations

EndPoint (org.bimserver.endpoints.EndPoint)12 TopicRegisterException (org.bimserver.notifications.TopicRegisterException)11 UserException (org.bimserver.shared.exceptions.UserException)4 ChangeProgressTopicOnProjectTopic (org.bimserver.notifications.ChangeProgressTopicOnProjectTopic)2 ChangeProgressTopicOnRevisionTopic (org.bimserver.notifications.ChangeProgressTopicOnRevisionTopic)2 ChangeProgressTopicOnServerTopic (org.bimserver.notifications.ChangeProgressTopicOnServerTopic)2 ProgressTopic (org.bimserver.notifications.ProgressTopic)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 SConverter (org.bimserver.interfaces.SConverter)1 SLongActionState (org.bimserver.interfaces.objects.SLongActionState)1 LongActionState (org.bimserver.models.store.LongActionState)1 NewExtendedDataOnRevisionTopic (org.bimserver.notifications.NewExtendedDataOnRevisionTopic)1 NewExtendedDataOnRevisionTopicKey (org.bimserver.notifications.NewExtendedDataOnRevisionTopicKey)1 NewRevisionOnSpecificProjectTopic (org.bimserver.notifications.NewRevisionOnSpecificProjectTopic)1 NewRevisionOnSpecificProjectTopicKey (org.bimserver.notifications.NewRevisionOnSpecificProjectTopicKey)1 NewRevisionTopic (org.bimserver.notifications.NewRevisionTopic)1 ServerException (org.bimserver.shared.exceptions.ServerException)1 NotificationRegistryInterface (org.bimserver.shared.interfaces.NotificationRegistryInterface)1