Search in sources :

Example 1 with ProgressHandler

use of org.bimserver.plugins.services.ProgressHandler in project BIMserver by opensourceBIM.

the class BimServerClient method checkin.

public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, long fileSize, String filename, InputStream inputStream, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
    long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
    ProgressHandler progressHandlerWrapper = new ProgressHandler() {

        @Override
        public void progress(SLongActionState state) {
            progressHandler.progress(state.getTitle(), state.getProgress());
        }
    };
    getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
    return channel.checkinSync(baseAddress, token, poid, comment, deserializerOid, false, fileSize, filename, inputStream, topicId);
}
Also used : ProgressHandler(org.bimserver.plugins.services.ProgressHandler) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) SLongActionState(org.bimserver.interfaces.objects.SLongActionState)

Example 2 with ProgressHandler

use of org.bimserver.plugins.services.ProgressHandler in project BIMserver by opensourceBIM.

the class BimServerClient method checkin.

public SLongCheckinActionState checkin(long poid, String comment, long deserializerOid, URL url, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
    long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
    ProgressHandler progressHandlerWrapper = new ProgressHandler() {

        @Override
        public void progress(SLongActionState state) {
            progressHandler.progress(state.getTitle(), state.getProgress());
        }
    };
    getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
    try {
        InputStream openStream = url.openStream();
        try {
            channel.checkinAsync(baseAddress, token, poid, comment, deserializerOid, false, -1, url.toString(), openStream, topicId);
        } finally {
            openStream.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    getNotificationsManager().unregisterProgressHandler(topicId, progressHandlerWrapper);
    return (SLongCheckinActionState) getRegistry().getProgress(topicId);
}
Also used : ProgressHandler(org.bimserver.plugins.services.ProgressHandler) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) SLongActionState(org.bimserver.interfaces.objects.SLongActionState) IOException(java.io.IOException)

Example 3 with ProgressHandler

use of org.bimserver.plugins.services.ProgressHandler in project BIMserver by opensourceBIM.

the class BimServerClient method checkinSync.

public SLongCheckinActionState checkinSync(long poid, String comment, long deserializerOid, Path file, CheckinProgressHandler progressHandler) throws ServerException, UserException, PublicInterfaceNotFoundException {
    long topicId = getServiceInterface().initiateCheckin(poid, deserializerOid);
    ProgressHandler progressHandlerWrapper = new ProgressHandler() {

        @Override
        public void progress(SLongActionState state) {
            progressHandler.progress(state.getTitle(), state.getProgress());
        }
    };
    getNotificationsManager().registerProgressHandler(topicId, progressHandlerWrapper);
    try (InputStream newInputStream = Files.newInputStream(file)) {
        SLongCheckinActionState checkinSync = channel.checkinSync(baseAddress, token, poid, comment, deserializerOid, false, Files.size(file), file.getFileName().toString(), newInputStream, topicId);
        getNotificationsManager().unregisterProgressHandler(topicId, progressHandlerWrapper);
        return checkinSync;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : ProgressHandler(org.bimserver.plugins.services.ProgressHandler) CheckinProgressHandler(org.bimserver.plugins.services.CheckinProgressHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) SLongActionState(org.bimserver.interfaces.objects.SLongActionState) IOException(java.io.IOException)

Aggregations

SLongActionState (org.bimserver.interfaces.objects.SLongActionState)3 CheckinProgressHandler (org.bimserver.plugins.services.CheckinProgressHandler)3 ProgressHandler (org.bimserver.plugins.services.ProgressHandler)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 SLongCheckinActionState (org.bimserver.interfaces.objects.SLongCheckinActionState)2