Package de.fu_berlin.inf.dpp.net

Examples of de.fu_berlin.inf.dpp.net.IncomingTransferObject


                     */
                    progress = SubMonitor.convert(new NullProgressMonitor());
                    progress.beginTask("receive", 100);

                    try {
                        IncomingTransferObject transferObject = channel
                            .receiveIncomingTransferObject(progress.newChild(1));

                        listener.addIncomingTransferObject(transferObject);

                    } catch (LocalCancellationException e) {
View Full Code Here


        final String type) {

        return new AndFilter(extProv.getPacketFilter(), new PacketFilter() {

            public boolean accept(Packet packet) {
                IncomingTransferObject payload = extProv.getPayload(packet);

                if (payload == null) {
                    log.error("Invalid payload in packet: " + packet);
                    return false;
                }

                TransferDescription transferDescription = payload
                    .getTransferDescription();
                if (!Utils.equals(transferDescription.sessionID,
                    sessionID.getValue()))
                    return false;
View Full Code Here

        final IncomingTransferObjectExtensionProvider extProv,
        final String sessionID, final String processID, final JID peer) {
        return new AndFilter(extProv.getPacketFilter(), new PacketFilter() {

            public boolean accept(Packet packet) {
                IncomingTransferObject payload = extProv.getPayload(packet);

                if (payload == null) {
                    log.error("Invalid payload in packet: " + packet);
                    return false;
                }
                TransferDescription transferDescription = payload
                    .getTransferDescription();
                if (!Utils.equals(transferDescription.sender, peer)) {
                    return false;
                }
                if (!Utils.equals(transferDescription.sessionID, sessionID)) {
View Full Code Here

        receiver.addPacketListener(new PacketListener() {

            public void processPacket(Packet packet) {

                IncomingTransferObject ito = incomingTransferObjectExtensionProvider
                    .getPayload(packet);

                ConnectionTestResponse result = new ConnectionTestResponse();
                result.transferMode = ito.getTransferMode();

                try {
                    byte[] data = ito.accept(SubMonitor
                        .convert(new NullProgressMonitor()));

                    result.dataHash = Arrays.hashCode(data);

                    log.info(Utils.prefix(new JID(packet.getFrom()))
                        + "Connection Test Data received: " + data.length
                        + " bytes, hashCode==" + result.dataHash);
                } catch (SarosCancellationException e) {
                    log.error(
                        "Connection Test failed because of an CancelationException",
                        e);
                    result.errorMessage = "SarosCancellationException: "
                        + Utils.getMessage(e);
                } catch (IOException e) {
                    log.error(
                        "Connection Test failed because of an IOException", e);
                    result.errorMessage = "IOException: " + Utils.getMessage(e);
                }

                try {
                    IQ iqResponse = responseProvider.createIQ(result);
                    iqResponse.setTo(packet.getFrom());
                    iqResponse.setPacketID(ito.getTransferDescription().testID);

                    sarosNet.getConnection().sendPacket(iqResponse);
                } catch (Exception e) {
                    log.error(
                        "Could not send test results to "
                            + Utils.prefix(new JID(packet.getFrom())), e);
                }
            }
        }, new PacketFilter() {

            public boolean accept(Packet packet) {
                IncomingTransferObject payload = incomingTransferObjectExtensionProvider
                    .getPayload(packet);

                if (payload == null)
                    return false;

                return FileTransferType.CONNECTION_TEST.equals(payload
                    .getTransferDescription().type);
            }
        });

    }
View Full Code Here

    }

    class StreamPacketListener implements PacketListener {

        public void processPacket(Packet packet) {
            IncomingTransferObject ito = incomingTransferObjectExtensionProvider
                .getPayload(packet);
            try {
                if (receiver != null)
                    receiver.offerPacket(new StreamPacket(ito));
            } catch (IllegalArgumentException e) {
View Full Code Here

    }

    class StreamPacketFilter implements PacketFilter {

        public boolean accept(Packet packet) {
            IncomingTransferObject payload = incomingTransferObjectExtensionProvider
                .getPayload(packet);

            if (payload == null) {
                return false;
            }

            TransferDescription transferDescription = payload
                .getTransferDescription();
            if (!Utils.equals(transferDescription.sessionID,
                sarosSessionID.getValue()))
                return false;
View Full Code Here

        SubMonitor monitor, boolean forceWait)
        throws SarosCancellationException, IOException {

        log.trace("Waiting for FileList from ");

        IncomingTransferObject result = incomingExtProv.getPayload(receive(
            monitor, collector, 500, true));

        if (monitor.isCanceled()) {
            result.reject();
            throw new LocalCancellationException();
        }

        byte[] data = result.accept(monitor);
        String fileListAsString;
        try {
            fileListAsString = new String(data, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            fileListAsString = new String(data);
View Full Code Here

        PacketFilter filter = PacketExtensionUtils.getIncomingFileListFilter(
            incomingExtProv, sessionID.getValue(), processID, peer);
        SarosPacketCollector collector = installReceiver(filter);

        IncomingTransferObject result = incomingExtProv.getPayload(receive(
            monitor, collector, 500, true));

        if (monitor.isCanceled()) {
            result.reject();
            throw new LocalCancellationException();
        }

        byte[] data = result.accept(monitor);
        String fileListAsString;
        try {
            fileListAsString = new String(data, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            fileListAsString = new String(data);
View Full Code Here

            }
        }

        monitor.subTask("Receiving archive...");
        try {
            IncomingTransferObject result = incomingExtProv.getPayload(receive(
                monitor.newChild(packetListenerIBB == null ? 10 : 1),
                collector, 10000, forceWait));

            if (monitor.isCanceled()) {
                result.reject();
                throw new LocalCancellationException();
            }
            byte[] data = result.accept(monitor
                .newChild(packetListenerIBB == null ? 90 : 9));

            return new ByteArrayInputStream(data);
        } finally {
            monitor.done();
View Full Code Here

        final IncomingTransferObject transferObjectDescription) {

        final TransferDescription description = transferObjectDescription
            .getTransferDescription();

        final IncomingTransferObject transferObjectData = new LoggingTransferObject(
            transferObjectDescription);

        // ask upper layer to accept
        dispatchThreadContext.executeAsDispatch(new Runnable() {
            public void run() {
View Full Code Here

TOP

Related Classes of de.fu_berlin.inf.dpp.net.IncomingTransferObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.