Package java.net

Examples of java.net.ProtocolException


  public InputStream getInputStream() throws IOException {
    LOG.info("getInputStream(" + url.toExternalForm() + ")");
    if (!getDoInput()) {
      LOG.error("Input not allowed");
      throw new ProtocolException("Input not allowed on this connection");
    }
    connect();
    return fHttpRequestMethod.getResponseBodyAsStream();
  }
View Full Code Here


  public OutputStream getOutputStream() throws IOException {
    LOG.info("getOutputStream(" + url.toExternalForm() + ")");
    // TODO: return fOutputStream if fOutputStream != null ??
    if (!getDoOutput()) {
      LOG.error("Output not allowed");
      throw new ProtocolException("Output not allowed on this connection");
    }
    if (fHttpRequestMethod instanceof GetMethod) {
      setRequestMethod("POST");
    }
    if (!(fHttpRequestMethod instanceof EntityEnclosingMethod)) {
View Full Code Here

    return Collections.unmodifiableMap(hf);
  }

  public void setRequestMethod(final String method) throws ProtocolException {
    if (connected) {
      throw new ProtocolException("Can't reset method: already connected");
    }
    if (fOutputStream != null) {
      // TODO: or just clear the output stream?
      // TODO: or allow change between Post and Put?
      throw new ProtocolException("Can't reset method: output stream already allocated");
    }
    LOG.info("setRequestMethod(" + method + ")");
    if ("GET".equals(method)) {
      setHttpRequestMethod(new GetMethod(url.toExternalForm()));
    } else if ("POST".equals(method)) {
      setHttpRequestMethod(new PostMethod(url.toExternalForm()));
    } else {
      throw new ProtocolException("Not implemented/Invalid HTTP method: " + method);
    }
  }
View Full Code Here

            String t_name = name.substring("/topic/".length(), name.length());
            return ActiveMQDestination.createDestination(ActiveMQDestination.ACTIVEMQ_TOPIC, t_name);
        }
        else
        {
            throw new ProtocolException("Illegal destination name: [" + name + "] -- ActiveMQ TTMP destinations " +
                                        "must begine with /queue/ or /topic/");
        }

    }
View Full Code Here

        Properties headers = parser.parse(in);
        while (in.readByte() != 0) {}

        if (!format.isInTransaction())
        {
            throw new ProtocolException("Cannot COMMIT when not in a transaction");
        }
        TransactionInfo tx = new TransactionInfo();
        tx.setTransactionId(format.getTransactionId());
        tx.setType(TransactionType.COMMIT);
        format.clearTransactionId();
View Full Code Here

                String value = line.substring(seperator_index + 1, line.length()).trim();
                props.setProperty(name, value);
            }
            catch (Exception e)
            {
                throw new ProtocolException("Unable to parser header line [" + line + "]");
            }
        }
        return props;
    }
View Full Code Here

        Properties headers = parser.parse(in);
        while (in.readByte() != 0) {}

        if (!format.isInTransaction())
        {
            throw new ProtocolException("Cannot ABORT when not in a transaction");
        }
        TransactionInfo tx = new TransactionInfo();
        tx.setTransactionId(format.getTransactionId());
        tx.setType(TransactionType.ROLLBACK);
        format.clearTransactionId();
View Full Code Here

        if (line.startsWith(Stomp.Commands.UNSUBSCRIBE)) command = new Unsubscribe(format);

        if (command == null)
        {
            while (in.readByte() == 0) {}
            throw new ProtocolException("Unknown command [" + line + "]");
        }

        PacketEnvelope envelope = command.build(line, in);
        if (envelope.getHeaders().containsKey(Stomp.Headers.RECEIPT_REQUESTED))
        {
View Full Code Here

      if (service != null) {
        // TODO: message should already be a String?
        service.sendAsync(senderUri, receiverUrl, message.toString(),
            tag);
      } else {
        throw new ProtocolException(
            "No transport service configured for protocol '"
                + protocol + "'.");
      }
    }
  }
View Full Code Here

                        conn.receiveResponseEntity(response);
                    }
                    int status = response.getStatusLine().getStatusCode();
                    if (status < 200) {
                        if (status != HttpStatus.SC_CONTINUE) {
                            throw new ProtocolException(
                                    "Unexpected response: " + response.getStatusLine());
                        }
                        // discard 100-continue
                        response = null;
                    } else {
View Full Code Here

TOP

Related Classes of java.net.ProtocolException

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.