Example usage for org.apache.commons.logging Log warn

List of usage examples for org.apache.commons.logging Log warn

Introduction

In this page you can find the example usage for org.apache.commons.logging Log warn.

Prototype

void warn(Object message, Throwable t);

Source Link

Document

Logs an error with warn log level.

Usage

From source file:org.sakaiproject.site.tool.AdminSitesAction.java

/**
 * Handle a request to save the edit from either page or tools list mode - no form to read in.
 *///from   w  ww  . j av a2  s  . c o m
public void doSave_edit(RunData data, Context context) {
    SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());

    if (!"POST".equals(data.getRequest().getMethod())) {
        return;
    }

    // commit the change
    Site site = (Site) state.getAttribute("site");
    if (site != null) {
        String url_alias = StringUtil.trimToNull(data.getParameters().getString("url_alias"));
        // set an alias for the site
        if (url_alias != null) {
            state.setAttribute(STATE_SITE_INSTANCE_ID, site.getId());
            setSiteAlias(url_alias, site.getReference(), state);
        }

        // bring the mail archive service's channel for this site in sync with the site's setting
        // syncWithMailArchive(site);

        try {
            //Remove the new property if it exists on the site
            site.getPropertiesEdit().removeProperty("new");
            //Remove the new property on all pages and tools in this site
            List<SitePage> pages = site.getPages();
            for (SitePage page : pages) {
                //Clear new from page
                page.getPropertiesEdit().removeProperty("new");
                List<ToolConfiguration> tools = page.getTools();
                for (ToolConfiguration tool : tools) {
                    //Clear new from tool
                    tool.getPlacementConfig().remove("new");
                }
            }

            SiteService.save(site);
        } catch (PermissionException e) {
            Log.warn("chef", "SitesAction.doSave_edit: " + e);
        } catch (IdUnusedException e) {
            Log.warn("chef", "SitesAction.doSave_edit: " + e);
        }

        // save the realm, too
        // RealmEdit realm = (RealmEdit) state.getAttribute("realm");
        // authzGroupService.commitEdit(realm);
    }

    // cleanup
    cleanState(state);

    // return to main mode
    state.removeAttribute("mode");

    // make sure auto-updates are enabled
    enableObserver(state);

    // TODO: hard coding this frame id is fragile, portal dependent, and needs to be fixed -ggolden
    schedulePeerFrameRefresh("sitenav");

}

From source file:org.sakaiproject.site.tool.AdminSitesAction.java

/**
 * Read the page form and update the site in state.
 * /*from w ww. j a  v a  2 s . c  o  m*/
 * @return true if the form is accepted, false if there's a validation error (an alertMessage will be set)
 */
private boolean readPageForm(RunData data, SessionState state) {
    // get the page - it's there
    SitePage page = (SitePage) state.getAttribute("page");

    // read the form
    String title = StringUtil.trimToNull(data.getParameters().getString("title"));
    page.setTitle(title);

    try {
        // this comes in 1 based, convert to 0 based
        int layout = Integer.parseInt(data.getParameters().getString("layout")) - 1;
        page.setLayout(layout);
    } catch (Exception e) {
        Log.warn("chef", this + ".readPageForm(): reading layout: " + e);
    }

    boolean popup = data.getParameters().getBoolean("popup");
    page.setPopup(popup);

    boolean custom = data.getParameters().getBoolean("custom");
    page.setTitleCustom(custom);

    if (title == null) {
        addAlert(state, rb.getString("sitact.plespe"));
        return false;
    } else {
        return true;
    }

}

From source file:org.sakaiproject.site.tool.SiteAction.java

/**
 * Handle the eventSubmit_doUnjoin command to have the user un-join this site.
 *//*  w  w w  .ja v  a2 s  .co m*/
public void doUnjoin(RunData data) {

    SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
    final ParameterParser params = data.getParameters();

    final String id = params.get("itemReference");
    String siteTitle = null;

    if (id != null) {
        try {
            siteTitle = SiteService.getSite(id).getTitle();
            SiteService.unjoin(id);
            String msg = rb.getString("sitinfimp.youhave") + " " + siteTitle;
            addAlert(state, msg);

        } catch (IdUnusedException ignore) {

        } catch (PermissionException e) {
            // This could occur if the user's role is the maintain role for the site, and we don't let the user
            // unjoin sites they are maintainers of
            Log.warn("chef", this + ".doUnjoin(): " + e);
            //TODO can't access site so redirect to portal

        } catch (InUseException e) {
            addAlert(state, siteTitle + " " + rb.getString("sitinfimp.sitebeing") + " ");
        }
    }

    // refresh the whole page
    scheduleTopRefresh();

}

From source file:org.sakaiproject.site.tool.SiteBrowserAction.java

/**
 * build the context/*  www  . j a va  2s .c o  m*/
 */
public String buildMainPanelContext(VelocityPortlet portlet, Context context, RunData rundata,
        SessionState state) {
    context.put("tlang", rb);
    String template = null;

    // check mode and dispatch
    String mode = (String) state.getAttribute(MODE);
    if ((mode == null) || mode.equals(SIMPLE_SEARCH_VIEW)) {
        template = buildSimpleSearchContext(state, context);
    } else if (mode.equals(LIST_VIEW)) {
        template = buildListContext(state, context);
    } else if ("visit".equals(mode)) {
        template = buildVisitContext(state, context);
    }

    // bjones86 - SAK-24423 - joinable site settings - join from site browser
    else if (JoinableSiteSettings.SITE_BROWSER_JOIN_MODE.equalsIgnoreCase(mode)) {
        if (JoinableSiteSettings.isJoinFromSiteBrowserEnabled()) {
            template = JoinableSiteSettings.buildJoinContextForSiteBrowser(state, context, rb);
        } else {
            Log.warn("chef",
                    "SiteBrowserAction: mode = " + mode + ", but site browser join is disabled globally");
            template = buildListContext(state, context);
        }
    }

    else {
        Log.warn("chef", "SiteBrowserAction: mode: " + mode);
        template = buildListContext(state, context);
    }

    return (String) getContext(rundata).get("template") + template;

}

From source file:org.sakaiproject.site.tool.SiteBrowserAction.java

/**
 * Handle a request to visit a site./* ww w. j  ava2  s. c  o m*/
 */
public void doVisit(RunData data, Context context) {
    SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());
    String id = data.getParameters().getString("id");

    // get the site
    try {
        Site site = SiteService.getSite(id);
        state.setAttribute("siteId", id);
        state.setAttribute(MODE, "visit");

        // disable auto-updates while in view mode
        // ((EventObservingCourier) state.getAttribute(STATE_OBSERVER)).disable();
    } catch (IdUnusedException e) {
        Log.warn("chef", "SiteBrowserAction.doEdit: site not found: " + id);

        addAlert(state, rb.getFormattedMessage("notfound", new Object[] { id }));
        state.removeAttribute(MODE);

        // make sure auto-updates are enabled
        // enableObserver(state);
    }

}

From source file:org.sakaiproject.tool.assessment.services.assessment.AssessmentService.java

/**
 * Return a string based on id that is valid according to Resource name validity rules.
 * /*from w  w  w.j  av a  2s  . c  o m*/
 * @param id
 *        The string to escape.
 * @return id fully escaped using Resource name validity rules.
 */
public static String escapeResourceName(String id) {
    if (id == null)
        return "";
    id = id.trim();
    try {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < id.length(); i++) {
            char c = id.charAt(i);
            if (MAP_TO_A.indexOf(c) >= 0) {
                buf.append('a');
            } else if (MAP_TO_E.indexOf(c) >= 0) {
                buf.append('e');
            } else if (MAP_TO_I.indexOf(c) >= 0) {
                buf.append('i');
            } else if (MAP_TO_O.indexOf(c) >= 0) {
                buf.append('o');
            } else if (MAP_TO_U.indexOf(c) >= 0) {
                buf.append('u');
            } else if (MAP_TO_Y.indexOf(c) >= 0) {
                buf.append('y');
            } else if (MAP_TO_N.indexOf(c) >= 0) {
                buf.append('n');
            } else if (MAP_TO_B.indexOf(c) >= 0) {
                buf.append('b');
            } else if (MAP_TO_C.indexOf(c) >= 0) {
                buf.append('c');
            } else if (MAP_TO_L.indexOf(c) >= 0) {
                buf.append('l');
            } else if (MAP_TO_X.indexOf(c) >= 0) {
                buf.append('x');
            } else if (c < '\040') // Remove any ascii control characters
            {
                buf.append('_');
            } else if (INVALID_CHARS_IN_RESOURCE_ID.indexOf(c) >= 0
                    || ESCAPE_CHARS_IN_RESOURCE_ID.indexOf(c) >= 0) {
                buf.append('_');
            } else {
                buf.append(c);
            }
        }

        String rv = buf.toString();
        return rv;
    } catch (Exception e) {
        Log log = LogFactory.getLog(AssessmentService.class);
        log.warn("escapeResourceName: ", e);
        return id;
    }

}

From source file:org.sakaiproject.tool.assessment.util.TextFormat.java

public static String convertPlaintextToFormattedTextNoHighUnicode(Log log, String value) {
    if (value == null)
        return "";

    try {/*from  ww w.  j  av  a 2s .  c  o  m*/
        StringBuilder buf = new StringBuilder();
        final int len = value.length();
        for (int i = 0; i < len; i++) {
            char c = value.charAt(i);
            switch (c) {
            case '<': {
                if (buf == null)
                    buf = new StringBuilder(value.substring(0, i));
                buf.append("&lt;");
            }
                break;

            case '>': {
                if (buf == null)
                    buf = new StringBuilder(value.substring(0, i));
                buf.append("&gt;");
            }
                break;

            case '&': {
                if (buf == null)
                    buf = new StringBuilder(value.substring(0, i));
                buf.append("&amp;");
            }
                break;

            case '"': {
                if (buf == null)
                    buf = new StringBuilder(value.substring(0, i));
                buf.append("&quot;");
            }
                break;
            case '\n': {
                if (buf == null)
                    buf = new StringBuilder(value.substring(0, i));
                buf.append("<br />\n");
            }
                break;
            default: {
                if (buf != null)
                    buf.append(c);
            }
                break;
            }
        } // for

        return (buf == null) ? value : buf.toString();
    } catch (Exception e) {
        log.warn("convertPlaintextToFormattedTextNoHighUnicode: ", e);
        return "";
    }

}

From source file:org.seasar.mayaa.impl.util.xml.XMLHandler.java

public void warning(SAXParseException e) {
    Log log = getLog();
    if (log != null && log.isWarnEnabled()) {
        log.warn(e.getMessage(), e);
    }//  ww w.jav a 2  s.c  o  m
}

From source file:org.springframework.boot.SpringApplicationBannerPrinter.java

public Banner print(Environment environment, Class<?> sourceClass, Log logger) {
    Banner banner = getBanner(environment, this.fallbackBanner);
    try {//from w w  w  .j av a 2  s  . c  o m
        logger.info(createStringFromBanner(banner, environment, sourceClass));
    } catch (UnsupportedEncodingException ex) {
        logger.warn("Failed to create String for banner", ex);
    }
    return new PrintedBanner(banner, sourceClass);
}

From source file:org.springframework.flex.core.CommonsLoggingTarget.java

public void logEvent(LogEvent logevent) {
    String category = logevent.logger.getCategory();
    if (this.categoryPrefix != null) {
        category = this.categoryPrefix + "." + category;
    }//from  w w w .  j a  v  a2s.  c  om
    Log log = LogFactory.getLog(category);
    switch (logevent.level) {
    case LogEvent.FATAL:
        if (log.isFatalEnabled()) {
            log.fatal(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ERROR:
        if (log.isErrorEnabled()) {
            log.error(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.WARN:
        if (log.isWarnEnabled()) {
            log.warn(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.INFO:
        if (log.isInfoEnabled()) {
            log.info(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.DEBUG:
        if (log.isDebugEnabled()) {
            log.debug(logevent.message, logevent.throwable);
        }
        break;
    case LogEvent.ALL:
        if (log.isTraceEnabled()) {
            log.trace(logevent.message, logevent.throwable);
        }
        break;
    default:
        break;
    }
}