Package net.easymodo.asagi.exception

Examples of net.easymodo.asagi.exception.ContentGetException


                    if(mediaRs != null)
                        mediaRs.close();
                } catch(SQLException e1) {
                    e.setNextException(e1);
                }
                throw new ContentGetException(e);
            }
        }

        try {
            if(mediaRs.next()) {
                media = new Media(
                    mediaRs.getInt("media_id"),
                    mediaRs.getString("media_hash"),
                    mediaRs.getString("media"),
                    mediaRs.getString("preview_op"),
                    mediaRs.getString("preview_reply"),
                    mediaRs.getInt("total"),
                    mediaRs.getInt("banned"));
            }
        } catch(SQLException e) {
            throw new ContentGetException(e);
        } finally {
            try {
                mediaRs.close();
            } catch(SQLException e) {
                System.err.println("Error closing result set" + e.getMessage());
            }
        }

        if(media == null) {
            // Somehow, we got ahead of the post insertion. Oh well, we'll get it next time.
            // Getting here means something isn't right with our transaction isolation mode
            // (Or maybe the DB we're using just sucks)
            throw new ContentGetException("Media hash " + post.getMediaHash() + " not found in media DB table");
        }

        boolean mediaUpdate = media.getMedia() == null;
        boolean previewOpUpdate = media.getPreviewOp() == null && post.isOp();
        boolean previewReplyUpdate = media.getPreviewReply() == null && !post.isOp();
View Full Code Here


        String pageText;
        try {
            pageText = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
        } catch(UnsupportedEncodingException e) {
            throw new ContentGetException("Unsupported encoding in HTTP response");
        } catch(IOException e) {
            throw new HttpGetException(e);
        } finally {
            // EntityUtils.toString should close the stream for us, but I DON'T EVEN KNOW
            EntityUtils.consumeQuietly(httpResponse.getEntity());
        }

        // we don't need to process empty content
        if(pageText == null || pageText.equals("")) {
            throw new ContentGetException("HTTP response returned empty body");
        }

        return new String[] {pageText, newLastMod};
    }
View Full Code Here

        PageJson pageJson;
        try {
            pageJson = GSON.fromJson(pageText, PageJson.class);
        } catch(JsonSyntaxException ex) {
            throw new ContentGetException("API returned invalid JSON", ex);
        }

        Page p = new Page(pageNum);
        Topic t = null;
View Full Code Here

        TopicJson topicJson;
        try {
            topicJson = GSON.fromJson(threadText, TopicJson.class);
        } catch(JsonSyntaxException ex) {
            throw new ContentGetException("API returned invalid JSON", ex);
        }

        if(topicJson == null) {
            throw new ContentParseException("API returned empty JSON in " + threadNum);
        }
View Full Code Here

        TopicListJson.Page[] topicsJson;
        try {
            topicsJson = GSON.fromJson(threadsText, TopicListJson.Page[].class);
        } catch(JsonSyntaxException ex) {
            throw new ContentGetException("API returned invalid JSON", ex);
        }

        if(topicsJson == null) {
            throw new ContentParseException("API returned empty JSON in threads.json");
        }
View Full Code Here

TOP

Related Classes of net.easymodo.asagi.exception.ContentGetException

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.