Package javax.ws.rs

Examples of javax.ws.rs.WebApplicationException


                    BroadcasterFactory bp = (BroadcasterFactory)
                            req.getAttribute(AtmosphereServlet.BROADCASTER_FACTORY);

                    broadcaster = bp.lookup(r.getBroadcaster().getClass(), topic, true);
                } catch (Throwable ex) {
                    throw new WebApplicationException(ex);
                }
                req.setAttribute(AtmosphereFilter.INJECTED_BROADCASTER, broadcaster);
                return broadcaster;
            }
View Full Code Here


                                 @FormParam("name") String name) {

        UserStateData usd = us.create(name,(TwitterBroadcaster)bc);
        // User already exists, client error
        if (usd == null)
            throw new WebApplicationException(400);

        if (name == null) {
            logger.error("Name cannot be null");
            throw new WebApplicationException(400);
        }

        bc.setID(name);
        String m = BEGIN_SCRIPT_TAG + toJsonp("Welcome back", name) + END_SCRIPT_TAG;
        Broadcastable b = new Broadcastable(m, bc);
View Full Code Here

                                  @FormParam("name") String name,
                                  @FormParam("followee") String followee) {

        if (followee == null) {
            logger.error("Message cannot be null");
            throw new WebApplicationException(400);
        }

        if (name == null) {
            logger.error("Name cannot be null");
            throw new WebApplicationException(400);
        }

        UserStateData followeeData = us.get(followee);
        TwitterBroadcaster outsiderBroadcaster = followeeData.bc;
        if (outsiderBroadcaster == null) {
View Full Code Here

                                @FormParam("message") String message,
                                @FormParam("callback") String callback){
       
        if (message == null) {
            logger.error("Message cannot be null");
            throw new WebApplicationException(400);
        }

        if (callback == null) {
            callback = "alert";
        }
View Full Code Here

    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public void follow(@FormParam("follower") String follower) {
        UserStateData followerState = us.get(follower);
        // User does not exist
        if (followerState == null) {
            throw new WebApplicationException(404);
        }

        followerState.bc.addAtmosphereResource(us.get(user).bc.getUserAtmosphereEvent().getResource());
        followerState.bc.broadcast(user + " is now follow you ",
                followerState.bc.getUserAtmosphereEvent().getResource());
View Full Code Here

        if ("login".equals(action)) {
            return ("System Message" + "__" + name + " has joined.");
        } else if ("post".equals(action)) {
            return name + "__" + form.getFirst("message");
        } else {
            throw new WebApplicationException(422);
        }
    }
View Full Code Here

                            InjectorProvider.getInjector().inject(el);
                            if (r instanceof AtmosphereEventLifecycle) {
                                ((AtmosphereEventLifecycle) r).addEventListener(el);
                            }
                        } catch (Throwable t) {
                            throw new WebApplicationException(
                                    new IllegalStateException("Invalid AtmosphereResourceEventListener " + listener, t));
                        }
                    }
                    suspend(sessionSupported, resumeOnBroadcast, outputJunk, suspendTimeout, request, response, (
                            Broadcaster) servletReq.getAttribute(INJECTED_BROADCASTER), r);
                    break;
                case RESUME:
                    if (response.getEntity() != null) {
                        try {
                            response.write();
                        } catch (IOException ex) {
                            throw new WebApplicationException(ex);
                        }
                    }

                    if (sessionSupported) {
                        r = (AtmosphereResource) servletReq.getSession().getAttribute(SUSPENDED_RESOURCE);
                    } else {
                        String path = response.getContainerRequest().getPath();
                        r = resumeCandidates.remove(path.substring(path.lastIndexOf("/") + 1));
                    }

                    if (r != null) {
                        resume(r);
                    } else {
                        throw new WebApplicationException(
                                new IllegalStateException("Unable to retrieve suspended Response. " +
                                        "Either session-support is not enabled in atmosphere.xml or the" +
                                        "path used to resume is invalid."));

                    }
                    break;
                case BROADCAST:
                case RESUME_ON_BROADCAST:
                    AtmosphereResource ar = (AtmosphereResource) servletReq.getAttribute(SUSPENDED_RESOURCE);
                    if (ar != null) {
                        r = ar;
                    }
                    broadcast(response, r, suspendTimeout);
                    break;
                case SCHEDULE:
                case SCHEDULE_RESUME:
                    Object o = response.getEntity();
                    Broadcaster b = r.getBroadcaster();
                    if (response.getEntity() instanceof Broadcastable) {
                        b = ((Broadcastable) response.getEntity()).getBroadcaster();
                        o = ((Broadcastable) response.getEntity()).getMessage();
                        response.setEntity(((Broadcastable) response.getEntity()).getResponseMessage());
                    }

                    if (response.getEntity() != null) {
                        try {
                            response.write();
                        } catch (IOException ex) {
                            throw new WebApplicationException(ex);
                        }
                    }

                    if (action == Action.SCHEDULE_RESUME) {
                        configureResumeOnBroadcast(b);
View Full Code Here

            }
        }


        void configureFilter(Broadcaster bc) {
            if (bc == null) throw new WebApplicationException(new IllegalStateException("Broadcaster cannot be null"));

            /**
             * Here we can't predict if it's the same set of filter shared across all Broadcaster as
             * Broadcaster can have their own BroadcasterConfig instance.
             */
 
View Full Code Here

                r.suspend(timeout, comments && !resumeOnBroadcast);
                if (response.getEntity() != null) {
                    response.write();
                }
            } catch (IOException ex) {
                throw new WebApplicationException(ex);
            }
        }
View Full Code Here

                    }
                    loadClasses(url.openStream());
                }
            }
        } catch (IOException e) {
            throw new WebApplicationException(e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.WebApplicationException

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.