Examples of PingTargetManager


Examples of org.apache.roller.business.pings.PingTargetManager

     * Display the common ping targets with page
     */
    public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
        ActionForward forward = mapping.findForward(PING_SETUP_PAGE);
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        WebsiteData website = rreq.getWebsite();
        try {
            if (!isAuthorized(rreq, website)) {
                return mapping.findForward("access-denied");
            }

            BasePageModel pageModel = new BasePageModel("pings.title", req, res, mapping);
            req.setAttribute("model", pageModel);

            List commonPingTargets = pingTargetMgr.getCommonPingTargets();
            req.setAttribute("commonPingTargets", commonPingTargets);

            Boolean allowCustomTargets = new Boolean(!PingConfig.getDisallowCustomTargets());
            req.setAttribute("allowCustomTargets", allowCustomTargets);

            List customPingTargets = allowCustomTargets.booleanValue() ? pingTargetMgr.getCustomPingTargets(website) : Collections.EMPTY_LIST;
            req.setAttribute("customPingTargets", customPingTargets);

            // Build isEnabled map (keyed by ping target id and values Boolean.TRUE/Boolean.FALSE)
            Map isEnabled = buildIsEnabledMap(rreq, commonPingTargets, customPingTargets);
            req.setAttribute("isEnabled", isEnabled);
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

        while(it.hasNext()) {
            this.strategy.remove((AutoPingData) it.next());
        }
       
        // Remove the website's custom ping targets
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        List pingtargets = pingTargetMgr.getCustomPingTargets(website);
        it = pingtargets.iterator();
        while(it.hasNext()) {
            this.strategy.remove((PingTargetData) it.next());
        }
       
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

        if (configuredVal == null || configuredVal.trim().length() == 0)
        {
            if (logger.isDebugEnabled()) logger.debug("No (or empty) value of " + PINGS_INITIAL_COMMON_TARGETS_PROP + " present in the configuration.  Skipping initialization of commmon targets.");
            return;
        }
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        if (!pingTargetMgr.getCommonPingTargets().isEmpty())
        {
            if (logger.isDebugEnabled()) logger.debug("Some common ping targets are present in the database already.  Skipping initialization.");
            return;
        }

        String[] configuredTargets = configuredVal.trim().split(",");
        for (int i = 0; i < configuredTargets.length; i++)
        {
            // Trim space around the target spec
            String thisTarget = configuredTargets[i].trim();
            // skip empty ones
            if (thisTarget.length() == 0) continue;
            // parse the ith target and store it
            Matcher m = PING_TARGET_SPEC.matcher(configuredTargets[i].trim());
            if (m.matches() && m.groupCount() == 2)
            {
                String name = m.group(1);
                String url = m.group(2);
                logger.info("Creating common ping target '" + name + "' from configuration properties.");
                PingTargetData pingTarget = new PingTargetData(null, name, url, null);
                pingTargetMgr.savePingTarget(pingTarget);
            }
            else
            {
                logger.error("Unable to parse configured initial ping target '" + configuredTargets[i] +
                    "'. Skipping this target. Check your setting of the property " + PINGS_INITIAL_COMMON_TARGETS_PROP);
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

        PingTargetData testPing = new PingTargetData();
        testPing.setName("testCommonPing");
        testPing.setPingUrl("http://localhost/testCommonPing");
       
        // store ping
        PingTargetManager pingMgr = RollerFactory.getRoller().getPingTargetManager();
        pingMgr.savePingTarget(testPing);
       
        // query for it
        PingTargetData ping = pingMgr.getPingTarget(testPing.getId());
       
        if(ping == null)
            throw new RollerException("error setting up ping target");
       
        return ping;
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

     * Convenience method for removing a ping target.
     */
    public static void teardownPingTarget(String id) throws Exception {
       
        // query for it
        PingTargetManager pingMgr = RollerFactory.getRoller().getPingTargetManager();
        PingTargetData ping = pingMgr.getPingTarget(id);
       
        // remove the ping
        pingMgr.removePingTarget(ping);
    }
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

    public ActionForward save(ActionMapping mapping, ActionForm form,
                              HttpServletRequest req, HttpServletResponse res)
        throws Exception
    {
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        PingTargetManager pingTargetMgr =
                RollerFactory.getRoller().getPingTargetManager();
        PingTargetForm pingTargetForm = (PingTargetForm) form;
        try
        {
            BasePageModel pageModel =
                new BasePageModel(getPingTargetEditTitle(), req, res, mapping);
            req.setAttribute("model",pageModel);           
            if (!hasRequiredRights(rreq, rreq.getWebsite()))
            {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }

            PingTargetData pingTarget = null;
            String pingTargetId = pingTargetForm.getId();
            if (pingTargetId != null && pingTargetId.length() > 0)
            {
                pingTarget = pingTargetMgr.getPingTarget(
                        pingTargetForm.getId());
                if (pingTarget == null)
                    throw new RollerException(
                            "No such ping target id: " + pingTargetId);
                pingTargetForm.copyTo(pingTarget, req.getLocale());
            }
            else
            {
                pingTarget = createPingTarget(rreq, pingTargetForm);
            }

            // Call private helper to validate ping target
            // If there are errors, go back to the target edit page.
            ActionMessages errors = validate(rreq, pingTarget);
            if (!errors.isEmpty()) {
                saveErrors(rreq.getRequest(), errors);
                return mapping.findForward(PING_TARGET_EDIT_PAGE);
            }

            // Appears to be ok. 
            // Save it, commit and return refreshed view of target list.
            pingTargetMgr.savePingTarget(pingTarget);
            RollerFactory.getRoller().flush();
           
            ActionMessages msgs = new ActionMessages();
            msgs.add(ActionMessages.GLOBAL_MESSAGE,
                    new ActionMessage("pingTarget.saved"));
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

                                         HttpServletRequest req, HttpServletResponse res)
        throws Exception
    {
        RollerRequest rreq = RollerRequest.getRollerRequest(req);
        PingTargetForm pingTargetForm = (PingTargetForm) form;
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        try
        {
            if (!hasRequiredRights(rreq, rreq.getWebsite()))
            {
                return mapping.findForward(ACCESS_DENIED_PAGE);
            }
            String pingTargetId = pingTargetForm.getId();
            if (pingTargetId == null || pingTargetId.length() == 0)
            {
                throw new RollerException("Missing ping target id.");
            }
            PingTargetData ping = pingTargetMgr.getPingTarget(pingTargetId);
            pingTargetMgr.removePingTarget(ping);
            RollerFactory.getRoller().flush();
            return view(mapping, form, req, res);
        }
        catch (Exception e)
        {
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

     * @throws RollerException
     */
    private PingTargetData select(RollerRequest rreq) throws RollerException
    {
        String pingTargetId = rreq.getRequest().getParameter(RollerRequest.PINGTARGETID_KEY);
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        if (pingTargetId == null || pingTargetId.length() == 0)
        {
            throw new RollerException("Missing ping target id: " + pingTargetId);
        }

        PingTargetData pingTarget = pingTargetMgr.getPingTarget(pingTargetId);
        if (pingTarget == null)
        {
            throw new RollerException("No such ping target id: " + pingTargetId);
        }
        return pingTarget;
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

    private ActionMessages validate(
        RollerRequest rreq, PingTargetData pingTarget) throws RollerException
    {
        ActionMessages errors = new ActionMessages();

        PingTargetManager pingTargetMgr =
                RollerFactory.getRoller().getPingTargetManager();
        if (!pingTargetMgr.isNameUnique(pingTarget))
        {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                new ActionMessage("pingTarget.nameNotUnique"));
        }
        if (!pingTargetMgr.isUrlWellFormed(pingTarget))
        {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                new ActionMessage("pingTarget.malformedUrl"));
        } else if (!pingTargetMgr.isHostnameKnown(pingTarget))
        {
            errors.add(ActionMessages.GLOBAL_MESSAGE,
                new ActionMessage("pingTarget.unknownHost"));
        }
        return errors;
View Full Code Here

Examples of org.apache.roller.model.PingTargetManager

     * Get the ping targets for the view.  Here we return the common ping targets for the
     * entire site.
     */
    protected List getPingTargets(RollerRequest rreq) throws RollerException
    {
        PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
        return pingTargetMgr.getCommonPingTargets();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.