public WeblogTrackbackRequest()

in app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogTrackbackRequest.java [55:145]


    public WeblogTrackbackRequest(HttpServletRequest request) 
            throws InvalidRequestException {
        
        // let our parent take care of their business first
        // parent determines weblog handle and locale if specified
        super(request);
        
        String servlet = request.getServletPath();
        
        // we only want the path info left over from after our parents parsing
        String pathInfo = this.getPathInfo();
        
        // was this request bound for the comment servlet?
        if(servlet == null || !TRACKBACK_SERVLET.equals(servlet)) {
            throw new InvalidRequestException("not a weblog trackback request, "+
                    request.getRequestURL());
        }
        
        
        /*
         * parse path info.  we expect ...
         *
         * /entry/<anchor> - permalink
         */
        if(pathInfo != null && !pathInfo.isBlank()) {
            
            // we should only ever get 2 path elements
            String[] pathElements = pathInfo.split("/");
            if(pathElements.length == 2) {
                
                String context = pathElements[0];
                if("entry".equals(context)) {
                    this.weblogAnchor = URLDecoder.decode(pathElements[1], StandardCharsets.UTF_8);
                } else {
                    throw new InvalidRequestException("bad path info, "+
                            request.getRequestURL());
                }
                
            } else {
                throw new InvalidRequestException("bad path info, "+
                        request.getRequestURL());
            }
            
        } else {
            // bad request
            throw new InvalidRequestException("bad path info, "+
                    request.getRequestURL());
        }
        
        
        /*
         * parse request parameters
         *
         * the only params we currently care about are:
         *   blog_name - comment author
         *   url - comment referring url
         *   excerpt - comment contents
         *   title - comment title
         */
        if(request.getParameter("blog_name") != null) {
            this.blogName = request.getParameter("blog_name");
        }
        
        if(request.getParameter("url") != null) {
            this.url = request.getParameter("url");
        }
        
        if(request.getParameter("excerpt") != null) {
            this.excerpt = request.getParameter("excerpt");
        }
        
        if(request.getParameter("title") != null) {
            this.title = request.getParameter("title");
        }
        
        // a little bit of validation, trackbacks enforce that all params
        // must have a value, so any nulls equals a bad request
        if(this.blogName == null || this.url == null || 
                this.excerpt == null || this.title == null) {
            throw new InvalidRequestException("bad request data.  did not "+
                    "receive values for all trackback params (blog_name, url, excerpt, title)");
        }
        
        if(log.isDebugEnabled()) {
            log.debug("name = "+this.blogName);
            log.debug("url = "+this.url);
            log.debug("excerpt = "+this.excerpt);
            log.debug("title = "+this.title);
            log.debug("weblogAnchor = "+this.weblogAnchor);
        }
    }