Package net.easymodo.asagi.exception

Examples of net.easymodo.asagi.exception.ContentParseException


        int mediaSize;
        try {
            timeStamp = DateUtils.adjustTimestampEpoch(dateUtc, DateUtils.NYC_TIMEZONE);
            mediaSize = this.parseFilesize(filesize);
        } catch(IllegalArgumentException e) {
            throw new ContentParseException("Could not create post " + num , e);
        }

        String exif = this.cleanSimple(this.parseMeta(comment));

        Post post = new Post();
View Full Code Here


        // Software like FindBugs will complain we're pointlessly calling the
        // String constructor, but in this case, we know exactly what we're doing.

        Matcher mat = numPattern.matcher(text);
        if(!mat.find()) {
            throw new ContentParseException("Could not parse thread (post num regex failed)");
        }
        int num = Integer.parseInt(mat.group(1));

        mat = titlePattern.matcher(text);
        if(!mat.find()) {
            throw new ContentParseException("Could not parse thread (post title regex failed)");
        }
        String title = new String(mat.group(1));

        String email = null;
        mat = emailPattern.matcher(text);
        if(mat.find()) {
            email = new String(mat.group(1));
        }

        mat = postParsePattern1.matcher(text);
        if(!mat.find()) {
            throw new ContentParseException("Could not parse thread (post info block regex failed)");
        }
        String name    = new String(mat.group(1));
        String trip    = (mat.group(2) != null) ? new String(mat.group(2)) : null;
        String capcode = (mat.group(3) != null) ? new String(mat.group(3)) : null;
        String uid     = mat.group(4);
        String country = (mat.group(5) != null) ? new String(mat.group(5)) : null;

        mat = datePattern.matcher(text);
        if(!mat.find()) {
            throw new ContentParseException("Could not parse thread (post timestamp regex failed)");
        }
        long dateUtc = Long.parseLong(mat.group(1));

        mat = postParsePattern2.matcher(text);
        String link = null;
        boolean spoiler = false;
        String fileSize = null;
        int width = 0;
        int height = 0;
        String fileName = null;
        String md5b64 = null;
        int tHeight = 0;
        int tWidth = 0;
        if(mat.find()) {
            link     = (mat.group(2) != null) ? new String(mat.group(2)) : null;
            spoiler  = (mat.group(3) != null);
            fileSize = (mat.group(4) != null) ? new String(mat.group(4)) : null;
            width    = (mat.group(5) != null) ? Integer.parseInt(mat.group(5)) : 0;
            height   = (mat.group(6) != null) ? Integer.parseInt(mat.group(6)) : 0;
            fileName = (mat.group(7) == null) ?
                          ((mat.group(1) != null) ? new String(mat.group(1)) : null) :
                          new String(mat.group(7));
            md5b64   = (mat.group(8) != null) ? new String(mat.group(8)) : null;
            tHeight  = (mat.group(9) != null) ? Integer.parseInt(mat.group(9)) : 0;
            tWidth   = (mat.group(10) != null) ? Integer.parseInt(mat.group(10)) : 0;
        }

        mat = commentPattern.matcher(text);
        if(!mat.find()) {
            throw new ContentParseException("Could not parse thread (post comment regex failed)");
        }
        String comment  = new String(mat.group(1));

        boolean sticky = false;
        mat = stickyPattern.matcher(text);
View Full Code Here

            if(type.equals("opContainer")) {
                if(t == null) {
                    t = this.parseThread(text);
                    t.setLastMod(newLastMod);
                } else {
                    throw new ContentParseException("Two OP posts in thread in " + threadNum);
                }
            } else {
                if(t != null) {
                    t.addPost(this.parsePost(text, t.getNum()));
                } else {
                    throw new ContentParseException("Thread without OP post in " + threadNum);
                }
            }
        }

        return t;
View Full Code Here

        } catch(JsonSyntaxException ex) {
            throw new ContentGetException("API returned invalid JSON", ex);
        }

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

        for(PostJson pj : topicJson.getPosts()) {
            if(pj.getResto() == 0) {
                if(t == null) {
                    t = this.makeThreadFromJson(pj);
                    t.setLastMod(newLastMod);
                } else {
                    throw new ContentParseException("Two OP posts in thread in " + threadNum);
                }
            } else {
                if(t != null) {
                    t.addPost(this.makePostFromJson(pj));
                } else {
                    throw new ContentParseException("Thread without OP post in " + threadNum);
                }
            }
        }

        return t;
View Full Code Here

        } catch(JsonSyntaxException ex) {
            throw new ContentGetException("API returned invalid JSON", ex);
        }

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

        for(TopicListJson.Page page : topicsJson) {
            for(TopicListJson.Topic topic : page.getThreads()) {
                Topic t = new Topic(topic.getNo(), 0, 0);
View Full Code Here

        return threadList;
    }

    private Post makePostFromJson(PostJson pj) throws ContentParseException {
        if(pj.getNo() == 0) {
            throw new ContentParseException("Could not parse post (post num missing and could not be zero)");
        }
        if(pj.getTime() == 0) {
            throw new ContentParseException("Could not parse post (post timestamp missing and could not be zero)");
        }

        Post p = new Post();

        if(pj.getFilename() != null) {
View Full Code Here

        return p;
    }

    private Topic makeThreadFromJson(PostJson pj) throws ContentParseException {
        if(pj.getNo() == 0) {
            throw new ContentParseException("Could not parse thread (thread post num missing and could not be zero)");
        }

        Topic t = new Topic(pj.getNo(), pj.getOmittedPosts(), pj.getOmittedImages());

        t.addPost(this.makePostFromJson(pj));
View Full Code Here

TOP

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

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.