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.jbpm.util.ClassLoaderUtil.java

public static Properties getProperties(String resource) {
    InputStream inStream = getStream(resource);
    if (inStream == null)
        throw new JbpmException("resource not found: " + resource);
    try {/* w w w. j  av  a  2s  . c  o m*/
        Properties properties = new Properties();
        properties.load(inStream);
        return properties;
    } catch (IOException e) {
        throw new JbpmException("could not load properties from resource: " + resource, e);
    } finally {
        try {
            inStream.close();
        } catch (IOException e) {
            Log log = LogFactory.getLog(ClassLoaderUtil.class);
            log.warn("failed to close resource: " + resource, e);
        }
    }
}

From source file:org.kuali.coeus.sys.framework.controller.interceptor.PerformanceMeasurementFilter.java

private void logSample(HttpSample sample, String outputDirectory) {
    try {//from w  w w  .j  a  v  a2  s .c  o m
        File file = new File(outputDirectory, getPerformanceLogFileName());
        if (!file.exists()) {
            createNewFile(file);
        }

        insertLine(file, sample);

    } catch (Exception e) {
        Log logger = LogFactory.getLog(PerformanceMeasurementFilter.class);
        logger.warn(e.getMessage(), e);
    }
}

From source file:org.latticesoft.util.common.LogUtil.java

public static void log(int level, Object o, Throwable t, Log log) {
    if (level == LogUtil.DEBUG)
        log.debug(o, t);/*ww w.  ja va 2 s. co m*/
    else if (level == LogUtil.ERROR)
        log.error(o, t);
    else if (level == LogUtil.FATAL)
        log.fatal(o, t);
    else if (level == LogUtil.INFO)
        log.info(o, t);
    else if (level == LogUtil.TRACE)
        log.trace(o, t);
    else if (level == LogUtil.WARNING)
        log.warn(o, t);
}

From source file:org.openmrs.module.reportingcompatibility.reporting.export.DataExportUtil.java

/**
 * @param exports/*from w ww .ja v  a 2  s  . c o  m*/
 */
public static void generateExports(List<DataExportReportObject> exports, EvaluationContext context) {

    Log log = LogFactory.getLog(DataExportUtil.class);

    for (DataExportReportObject dataExport : exports) {
        try {
            generateExport(dataExport, null, context);
        } catch (Exception e) {
            log.warn("Error while generating export: " + dataExport, e);
        }
    }

}

From source file:org.openmrs.web.Listener.java

/**
 * Copies file pointed to by <code>fromPath</code> to <code>toPath</code>
 *
 * @param fromPath//from  www  . ja v  a 2  s  .com
 * @param toPath
 * @return true/false whether the copy was a success
 */
private boolean copyFile(String fromPath, String toPath) {
    Log log = LogFactory.getLog(Listener.class);

    FileInputStream inputStream = null;
    FileOutputStream outputStream = null;
    try {
        inputStream = new FileInputStream(fromPath);
        outputStream = new FileOutputStream(toPath);
        OpenmrsUtil.copyFile(inputStream, outputStream);
    } catch (IOException io) {
        return false;
    } finally {
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException io) {
            log.warn("Unable to close input stream", io);
        }
        try {
            if (outputStream != null) {
                outputStream.close();
            }
        } catch (IOException io) {
            log.warn("Unable to close input stream", io);
        }
    }
    return true;
}

From source file:org.openmrs.web.Listener.java

public static void performWebStartOfModules(Collection<Module> startedModules, ServletContext servletContext)
        throws ModuleMustStartException, Exception {
    Log log = LogFactory.getLog(Listener.class);

    boolean someModuleNeedsARefresh = false;
    for (Module mod : startedModules) {
        try {//from  w w w  . j a v a2 s  .  c o m
            boolean thisModuleCausesRefresh = WebModuleUtil.startModule(mod, servletContext,
                    /* delayContextRefresh */true);
            someModuleNeedsARefresh = someModuleNeedsARefresh || thisModuleCausesRefresh;
        } catch (Exception e) {
            mod.setStartupErrorMessage("Unable to start module", e);
        }
    }

    if (someModuleNeedsARefresh) {
        try {
            WebModuleUtil.refreshWAC(servletContext, true, null);
        } catch (ModuleMustStartException ex) {
            // pass this up to the calling method so that openmrs loading stops
            throw ex;
        } catch (BeanCreationException ex) {
            // pass this up to the calling method so that openmrs loading stops
            throw ex;
        } catch (Exception e) {
            Throwable rootCause = getActualRootCause(e, true);
            if (rootCause != null) {
                log.fatal("Unable to refresh the spring application context.  Root Cause was:", rootCause);
            } else {
                log.fatal(
                        "Unable to refresh the spring application context. Unloading all modules,  Error was:",
                        e);
            }

            try {
                WebModuleUtil.shutdownModules(servletContext);
                for (Module mod : ModuleFactory.getLoadedModules()) {// use loadedModules to avoid a concurrentmodificationexception
                    if (!mod.isCoreModule() && !mod.isMandatory()) {
                        try {
                            ModuleFactory.stopModule(mod, true, true);
                        } catch (Exception t3) {
                            // just keep going if we get an error shutting down.  was probably caused by the module 
                            // that actually got us to this point!
                            log.trace("Unable to shutdown module:" + mod, t3);
                        }
                    }
                }
                WebModuleUtil.refreshWAC(servletContext, true, null);
            } catch (MandatoryModuleException ex) {
                // pass this up to the calling method so that openmrs loading stops
                throw new MandatoryModuleException(ex.getModuleId(),
                        "Got an error while starting a mandatory module: " + e.getMessage()
                                + ". Check the server logs for more information");
            } catch (Exception t2) {
                // a mandatory or core module is causing spring to fail to start up.  We don't want those
                // stopped so we must report this error to the higher authorities
                log.warn("caught another error: ", t2);
                throw t2;
            }
        }
    }

    // because we delayed the refresh, we need to load+start all servlets and filters now
    // (this is to protect servlets/filters that depend on their module's spring xml config being available)
    for (Module mod : ModuleFactory.getStartedModules()) {
        WebModuleUtil.loadServlets(mod, servletContext);
        WebModuleUtil.loadFilters(mod, servletContext);
    }
}

From source file:org.pentaho.reporting.platform.plugin.ReportContentUtil.java

/**
 * Apply inputs (if any) to corresponding report parameters, care is taken when
 * checking parameter types to perform any necessary casting and conversion.
 *
 * @param report The report to retrieve parameter definitions and values from.         
 * @param context a ParameterContext for which the parameters will be under
 * @param validationResult the validation result that will hold the warnings. If null, a new one will be created.
 * @return the validation result containing any parameter validation errors.
 * @throws java.io.IOException if the report of this component could not be parsed.
 * @throws ResourceException   if the report of this component could not be parsed.
 *//*from w w  w  .j a va  2  s  .co  m*/
public static ValidationResult applyInputsToReportParameters(final MasterReport report,
        final ParameterContext context, final Map<String, Object> inputs, ValidationResult validationResult)
        throws IOException, ResourceException {
    if (validationResult == null) {
        validationResult = new ValidationResult();
    }
    // apply inputs to report
    if (inputs != null) {
        final Log log = LogFactory.getLog(SimpleReportingComponent.class);
        final ParameterDefinitionEntry[] params = report.getParameterDefinition().getParameterDefinitions();
        final ReportParameterValues parameterValues = report.getParameterValues();
        for (final ParameterDefinitionEntry param : params) {
            final String paramName = param.getName();
            try {
                final Object computedParameter = ReportContentUtil.computeParameterValue(context, param,
                        inputs.get(paramName));
                parameterValues.put(param.getName(), computedParameter);
                if (log.isInfoEnabled()) {
                    log.info(Messages.getInstance().getString("ReportPlugin.infoParameterValues", //$NON-NLS-1$
                            paramName, String.valueOf(inputs.get(paramName)),
                            String.valueOf(computedParameter)));
                }
            } catch (Exception e) {
                if (log.isWarnEnabled()) {
                    log.warn(Messages.getInstance().getString("ReportPlugin.logErrorParametrization"), e); //$NON-NLS-1$
                }
                validationResult.addError(paramName, new ValidationMessage(e.getMessage()));
            }
        }
    }
    return validationResult;
}

From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public <T> void instantiationFailed(final PicoContainer container, final ComponentAdapter<T> componentAdapter,
        final Constructor<T> constructor, final Exception cause) {
    Log log = getLog(constructor);
    if (log.isWarnEnabled()) {
        log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATION_FAILED,
                ctorToString(constructor), cause.getMessage()), cause);
    }/*  ww  w  . j  a v  a 2  s  .  c om*/
    delegate.instantiationFailed(container, componentAdapter, constructor, cause);
}

From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java

/** {@inheritDoc} **/
public void lifecycleInvocationFailed(final MutablePicoContainer container,
        final ComponentAdapter<?> componentAdapter, final Method method, final Object instance,
        final RuntimeException cause) {
    Log log = getLog(method);
    if (log.isWarnEnabled()) {
        log.warn(ComponentMonitorHelper.format(ComponentMonitorHelper.LIFECYCLE_INVOCATION_FAILED,
                methodToString(method), instance, cause.getMessage()), cause);
    }/* ww  w  .j  a  v  a 2s  .c  o m*/
    delegate.lifecycleInvocationFailed(container, componentAdapter, method, instance, cause);
}

From source file:org.rhq.enterprise.server.alert.engine.model.AvailabilityDurationCacheElement.java

/**
 * Each avail duration check is performed by triggering an execution of {@link AlertAvailabilityDurationJob}.
 * Note that each of the scheduled jobs is relevant to only 1 condition evaluation.
 *   /* w  w w  .j av a 2 s.  com*/
 * @param cacheElement
 * @param resource
 */
private static void scheduleAvailabilityDurationCheck(AvailabilityDurationCacheElement cacheElement,
        Resource resource) {

    Log log = LogFactory.getLog(AvailabilityDurationCacheElement.class.getName());
    String jobName = AlertAvailabilityDurationJob.class.getName();
    String jobGroupName = AlertAvailabilityDurationJob.class.getName();
    String operator = cacheElement.getAlertConditionOperator().name();
    String triggerName = operator + "-" + resource.getId();
    String duration = (String) cacheElement.getAlertConditionOperatorOption();
    // convert from seconds to milliseconds
    Date jobTime = new Date(System.currentTimeMillis() + (Long.valueOf(duration).longValue() * 1000));

    if (log.isDebugEnabled()) {
        log.debug("Scheduling availability duration job for ["
                + DateFormat.getDateTimeInstance().format(jobTime) + "]");
    }

    JobDataMap jobDataMap = new JobDataMap();
    // the condition id is needed to ensure we limit the future avail checking to the one relevant alert condition
    jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_CONDITION_ID,
            String.valueOf(cacheElement.getAlertConditionTriggerId()));
    jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_RESOURCE_ID, String.valueOf(resource.getId()));
    jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_OPERATOR, operator);
    jobDataMap.put(AlertAvailabilityDurationJob.DATAMAP_DURATION, duration);

    Trigger trigger = new SimpleTrigger(triggerName, jobGroupName, jobTime);
    trigger.setJobName(jobName);
    trigger.setJobGroup(jobGroupName);
    trigger.setJobDataMap(jobDataMap);
    try {
        LookupUtil.getSchedulerBean().scheduleJob(trigger);
    } catch (Throwable t) {
        log.warn("Unable to schedule availability duration job for [" + resource + "] with JobData ["
                + jobDataMap.values() + "]", t);
    }
}