Package net.fortytwo.twitlogic.services.twitter

Examples of net.fortytwo.twitlogic.services.twitter.HandlerException


            } else {
                JSONObject obj;
                try {
                    obj = json.getJSONObject(key);
                } catch (JSONException e) {
                    throw new HandlerException(e);
                }
                if (!rdfizer.isOpen()) {
                    open = false;
                    break;
                }
View Full Code Here


                        Feature parf = pContext.persist(par);
                        parents.add(parf);
                        try {
                            submit(par, parf);
                        } catch (TwitterClientException e) {
                            throw new HandlerException(e);
                        }
                    }

                    f.setParentFeature(parents);
                }
View Full Code Here

                Feature f = persistenceContext.persist(tweet.getPlace());
                if (null != placeHelper) {
                    try {
                        placeHelper.submit(tweet.getPlace(), f);
                    } catch (TwitterClientException e) {
                        throw new HandlerException(e);
                    }
                }

                Set<SpatialThing> s = currentMicroblogPost.getLocation();
                s.add(f);
                currentMicroblogPost.setLocation(s);
            }

            // end Elmo operations

            try {
                storeConnection.commit();
            } catch (TweetStoreException e) {
                throw new HandlerException(e);
            }

            // Note: we assume that Twitter and any other services which supply these posts will not allow a cycle
            // of replies and/or retweets.
            // Note: these tweets are persisted in their own transactions.
            if (null != tweet.getInReplyToTweet()) {
                this.handle(tweet.getInReplyToTweet());
            }
            if (null != tweet.getRetweetOf()) {
                this.handle(tweet.getRetweetOf());
            }

            //System.out.println("    ...ending transaction");

            // Note: these Sail operations are performed outside of the Elmo transaction.  If they were to be
            // carried out inside the transaction, apparently Sesame would kill the thread without throwing
            // an exception or logging an error.
            if (hasAnnotations) {
                for (Triple triple : tweet.getAnnotations()) {
                    System.out.println("\t (" + triple.getWeight() + ")\t" + triple);
                    Statement st;

                    try {
                        st = toRDF(triple, uriOf(currentMicroblogPost.getEmbedsKnowledge()));
                    } catch (TwitterClientException e) {
                        throw new HandlerException(e);
                    }

                    if (null != st) {
                        // FIXME: creating a statement and then breaking it into parts is wasty
                        try {
                            //System.out.println("subject: " + st.getSubject());
                            //System.out.println("predicate: " + st.getPredicate());
                            //System.out.println("object: " + st.getObject());
                            //System.out.println("context: " + st.getContext());
                            storeConnection.getSailConnection()
                                    .addStatement(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext());
                        } catch (SailException e) {
                            throw new HandlerException(e);
                        }
                    }
                }

                try {
                    storeConnection.getSailConnection().commit();
                } catch (SailException e) {
                    throw new HandlerException(e);
                }
            }

            finished = true;
        } catch (HandlerException e) {
            throw e;
        } catch (Throwable t) {
            throw new HandlerException(t);
        } finally {
            if (!finished) {
                try {
                    LOGGER.info("rolling back failed transaction");
                    storeConnection.rollback();
                } catch (TweetStoreException e) {
                    throw new HandlerException(e);
                }
            }
        }
    }
View Full Code Here

            public void handle(Dataset dataset) throws HandlerException {
                try {
                    handleDataset(dataset);
                } catch (LocalFailure e) {
                    throw new HandlerException(e);
                }
            }
        };

        // Do this here so that the Sail is initialized before the runner thread starts.
View Full Code Here

        };

        try {
            matcher.match(tweet.getText(), tripleHandler, new SimpleTweetContext(tweet));
        } catch (MatcherException e) {
            throw new HandlerException(e);
        }

        baseHandler.handle(tweet);
    }
View Full Code Here

                        rdfizer.handle(obj);
                    }
                }
            }
        } catch (JSONException e) {
            throw new HandlerException(e);
        }
    }
View Full Code Here

                            try {
                                c.clear();
                                c.commit();
                                c.begin();
                            } catch (SailException e) {
                                throw new HandlerException(e);
                            }

                            annotator.handle(tweet);
                        }
                    };
View Full Code Here

                                    try {
                                        c.clear();
                                        c.commit();
                                        c.begin();
                                    } catch (SailException e) {
                                        throw new HandlerException(e);
                                    }

                                     annotator.handle(tweet);
                                }
                            };
View Full Code Here

                                    try {
                                        c.clear();
                                        c.commit();
                                        c.begin();
                                    } catch (SailException e) {
                                        throw new HandlerException(e);
                                    }

                                     annotator.handle(tweet);
                                }
                            };
View Full Code Here

                            try {
                                sc.clear();
                                sc.commit();
                                sc.begin();
                            } catch (SailException e) {
                                throw new HandlerException(e);
                            }
                            p.handle(tweet);
                        }
                    };
View Full Code Here

TOP

Related Classes of net.fortytwo.twitlogic.services.twitter.HandlerException

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.