Examples of HttpError


Examples of org.apache.tomcat.bayeux.HttpError

     *
     * @return HttpError This method returns null if no errors were found
     */
    public HttpError validate() {
        if(clientId==null|| (!this.getTomcatBayeux().hasClient(clientId)))
            return new HttpError(400,"Client Id not valid.", null);
        if (subscription==null||subscription.length()==0)
            return new HttpError(400,"Subscription missing.",null);
        return null;//no error
    }
View Full Code Here

Examples of org.apache.tomcat.bayeux.HttpError

     */
    public int process(int prevops) throws BayeuxException {
        super.process(prevops);
        response = (HashMap<String, Object>)this.responseTemplate.clone();
        ClientImpl client = (ClientImpl)getTomcatBayeux().getClient(clientId);
        HttpError error = validate();
        if (error == null) {
            boolean wildcard = subscription.indexOf('*')!=-1;
            boolean subscribed = false;
            if (wildcard) {
                List<Channel> channels = getTomcatBayeux().getChannels();
                Iterator<Channel> it = channels.iterator();
                while (it.hasNext()) {
                    ChannelImpl ch = (ChannelImpl)it.next();
                    if (ch.matches(subscription)) {
                        ch.subscribe(client);
                        subscribed = true;
                    }
                }
            }else {
                ChannelImpl ch = (ChannelImpl)getTomcatBayeux().getChannel(subscription,true);
                ch.subscribe(client);
                subscribed = true;
            }
            response.put(Bayeux.SUCCESSFUL_FIELD, Boolean.valueOf(subscribed));
            response.put(Bayeux.SUBSCRIPTION_FIELD,subscription);
            ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put("reconnect", "retry");
            ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put("interval", getReconnectInterval());
        }else {
            response.put(Bayeux.SUCCESSFUL_FIELD,Boolean.FALSE);
            response.put(Bayeux.ERROR_FIELD, error.toString());
            ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put("reconnect", "handshake");
            if (client==null) client = TomcatBayeux.getErrorClient();
        }
        response.put(Bayeux.CLIENT_FIELD, client.getId());
        response.put(Bayeux.TIMESTAMP_FIELD,getTimeStamp());
View Full Code Here

Examples of org.apache.tomcat.bayeux.HttpError

     * @return HttpError This method returns null if no errors were found
     */
    @Override
    public HttpError validate() {
        if(channel==null|| (!this.getTomcatBayeux().hasChannel(channel)))
            return new HttpError(400,"Channel Id not valid.", null);
        if(data==null || data.length()==0)
            return new HttpError(400,"Message data missing.", null);
        try {
            this.msgData = new JSONObject(data);
        }catch (JSONException x) {
            return new HttpError(400,"Invalid JSON object in data attribute.",x);
        }
        if(clientId==null|| (!this.getTomcatBayeux().hasClient(clientId)))
            return new HttpError(400,"Client Id not valid.", null);
        return null;//no error
    }
View Full Code Here

Examples of org.apache.tomcat.bayeux.HttpError

        super.process(prevops);
        response = (HashMap<String, Object>)responseTemplate.clone();
        ClientImpl client = clientId!=null?(ClientImpl)getTomcatBayeux().getClient(clientId):
                                           (ClientImpl)event.getHttpServletRequest().getAttribute("client");
        boolean success = false;
        HttpError error = validate();
        if (error == null) {
            ChannelImpl chimpl = (ChannelImpl)getTomcatBayeux().getChannel(channel,false);
            MessageImpl mimpl = (MessageImpl)getTomcatBayeux().newMessage(client);

            try {
                String[] keys = JSONObject.getNames(msgData);
                for (int i = 0; i < keys.length; i++) {
                    mimpl.put(keys[i], msgData.get(keys[i]));
                }
                success = true;
                ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.RECONNECT_FIELD, Bayeux.RETRY_RESPONSE);
                ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.INTERVAL_FIELD, getReconnectInterval());
            }catch (JSONException x) {
                if (log.isErrorEnabled()) log.error("Unable to parse:"+msgData,x);
                throw new BayeuxException(x);
            }
            chimpl.publish(mimpl);
        }
        if(!success) {
            response.put(Bayeux.SUCCESSFUL_FIELD,Boolean.FALSE);
            response.put(Bayeux.ERROR_FIELD, error.toString());
            ((HashMap) response.get(Bayeux.ADVICE_FIELD)).put(Bayeux.RECONNECT_FIELD, Bayeux.HANDSHAKE_RESPONSE);
            if (client==null) client = TomcatBayeux.getErrorClient();
        }
        response.put(Bayeux.CHANNEL_FIELD,channel);
        response.put(Bayeux.CLIENT_FIELD, client.getId());
View Full Code Here

Examples of org.apache.tomcat.bayeux.HttpError

        suppConnTypesFlag = ClientImpl.SUPPORT_CALLBACK_POLL | ClientImpl.SUPPORT_LONG_POLL;

    }

    public HttpError validate() {
        HttpError result = null;
//        if (clientId == null) {
//            result = new HttpError(401,"No Client ID.", null);
//        }
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.