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

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

Introduction

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

Prototype

void debug(Object message);

Source Link

Document

Logs a message with debug log level.

Usage

From source file:org.rhq.enterprise.gui.legacy.action.resource.common.monitor.alerts.RemoveAction.java

/**
 * removes alerts/*w ww.ja  v  a  2s .c  om*/
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Log log = LogFactory.getLog(RemoveAction.class);
    log.debug("entering removeAlertsAction");

    RemoveForm nwForm = (RemoveForm) form;

    Integer resourceId = nwForm.getId();

    Map<String, Integer> params = new HashMap<String, Integer>();
    params.put(ParamConstants.RESOURCE_ID_PARAM, resourceId);

    ActionForward forward = checkSubmit(request, mapping, form, params);

    // if the remove button was clicked, we are coming from
    // the alerts list page and just want to continue
    // processing ...
    if ((forward != null) && !forward.getName().equals(RetCodeConstants.REMOVE_URL)) {
        log.trace("returning " + forward);

        // if there is no resourceId -- go to dashboard on cancel
        if (forward.getName().equals(RetCodeConstants.CANCEL_URL) && (resourceId == null)) {
            return returnNoResource(request, mapping);
        }

        return forward;
    }

    Integer[] alertIds = nwForm.getAlerts();
    if (log.isDebugEnabled()) {
        log.debug("removing: " + Arrays.asList(alertIds));
    }

    if ((alertIds == null) || (alertIds.length == 0)) {
        return returnSuccess(request, mapping, params);
    }

    if (resourceId == null)
        return returnNoResource(request, mapping);

    AlertManagerLocal alertManager = LookupUtil.getAlertManager();
    alertManager.deleteAlerts(WebUtility.getSubject(request), ArrayUtils.unwrapArray(alertIds));

    if (log.isDebugEnabled())
        log.debug("!!!!!!!!!!!!!!!! removing alerts!!!!!!!!!!!!");

    return returnSuccess(request, mapping, params);
}

From source file:org.rhq.enterprise.gui.legacy.action.resource.group.monitor.config.GroupConfigMetricsFormPrepareAction.java

/**
 * Retrieve different resource metrics and store them in various request attributes.
 *//*from w w  w  . j av  a 2 s . c om*/
public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    Log log = LogFactory.getLog(GroupConfigMetricsFormPrepareAction.class.getName());
    log.trace("Preparing group resource metrics action.");

    ActionForward fwd = super.execute(context, mapping, form, request, response);

    if (fwd != null) {
        return null;
    }

    // XXX group specific prepare actions here

    log.debug("Successfully completed preparing Group Config Metrics");

    return null;
}

From source file:org.rhq.enterprise.gui.legacy.portlet.addresource.AddResourcesPrepareAction.java

@Override
@SuppressWarnings({ "unchecked", "deprecation" })
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    Log log = LogFactory.getLog(AddResourcesPrepareAction.class);
    AddResourcesForm addForm = (AddResourcesForm) form;
    HttpSession session = request.getSession();
    WebUser user = RequestUtils.getWebUser(request);
    Subject subject = user.getSubject();
    ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();

    PageControl pcAvail = WebUtility.getPageControl(request, "a");
    PageControl pcPending = WebUtility.getPageControl(request, "p");
    log.trace("available page control: " + pcAvail);
    log.trace("pending page control: " + pcPending);

    // first, get the pending resources (those that have been added to the RHS
    // pending resources are those on the right side of the "add to list" widget that are awaiting association with the group when the form's "ok" button is clicked. */
    log.debug("check session if there are pending resources");
    List<String> pendingResourceList = new ArrayList<String>();

    if (session.getAttribute(Constants.PENDING_RESOURCES_SES_ATTR) == null) {
        // if hitting the page for the first time, load resources already associated with user via preferences
        log.debug("get pending resources from user preferences");
        WebUserPreferences preferences = user.getWebPreferences();
        pendingResourceList = preferences.getPreferenceAsList(addForm.getKey(),
                DashboardUtils.DASHBOARD_DELIMITER);

        if (pendingResourceList != null) {
            // otherwise, we've been here for a while but the user paged, performed changed LHS<->RHS, etc
            log.debug("put entire list of pending resources in session");
            session.setAttribute(Constants.PENDING_RESOURCES_SES_ATTR, pendingResourceList);
        }// w  ww.  j ava 2 s  . c o  m
    } else {
        pendingResourceList = SessionUtils.getListAsList(session, Constants.PENDING_RESOURCES_SES_ATTR);
    }

    // get the resources, so we can display name & description in the UI
    log.debug("get page of pending resources selected by user");
    int[] pendingResourceArray = StringUtility.getIntArray(pendingResourceList);
    PageList<Resource> pendingResources = resourceManager.findResourceByIds(subject, pendingResourceArray,
            false, pcPending);

    PageList<DisambiguationReport<Resource>> disambiguatedPendingResources = DisambiguatedResourceListUtil
            .disambiguate(resourceManager, pendingResources, RESOURCE_ID_EXTRACTOR);

    // give 'em to the jsp page
    log.debug("put selected page of pending resources in request");
    request.setAttribute(Constants.PENDING_RESOURCES_ATTR, disambiguatedPendingResources);
    request.setAttribute(Constants.NUM_PENDING_RESOURCES_ATTR, disambiguatedPendingResources.getTotalSize());

    // available resources are all resources in the system that are not associated with the user and are not pending
    log.debug("determine if user wants to filter available resources");
    Integer typeIdFilter = ((addForm.getType() == null) || (addForm.getType() == DEFAULT_RESOURCE_TYPE)) ? null
            : addForm.getType();
    ResourceCategory categoryFilter = (addForm.getCategory() != null)
            ? ResourceCategory.valueOf(addForm.getCategory().toUpperCase())
            : ResourceCategory.PLATFORM;

    int[] excludeIds = StringUtility.getIntArray(pendingResourceList);
    PageList<Resource> availableResources = null;

    availableResources = resourceManager.findAvailableResourcesForDashboardPortlet(subject, typeIdFilter,
            categoryFilter, excludeIds, pcAvail);

    PageList<DisambiguationReport<Resource>> disambiguatedAvailableResources = DisambiguatedResourceListUtil
            .disambiguate(resourceManager, availableResources, RESOURCE_ID_EXTRACTOR);

    log.debug("put selected page of available resources in request");
    request.setAttribute(Constants.AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources);
    request.setAttribute(Constants.NUM_AVAIL_RESOURCES_ATTR, disambiguatedAvailableResources.getTotalSize());

    log.debug("get the available resources user can filter by");
    setDropDowns(addForm, request, subject, categoryFilter);

    return null;
}

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.
 *   /*from   w ww .ja va2 s  .  c  o  m*/
 * @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);
    }
}

From source file:org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil.java

/**
 * Loads a plugin descriptor from the given plugin jar and returns it. If the given jar does not
 * have a server plugin descriptor, <code>null</code> will be returned, meaning this is not
 * a server plugin jar.//w  w  w  .j  a  v a  2s  . co m
 *  
 * @param pluginJarFileUrl URL to a plugin jar file
 * @return the plugin descriptor found in the given plugin jar file, or <code>null</code> if there
 *         is no plugin descriptor in the jar file
 * @throws Exception if failed to parse the descriptor file found in the plugin jar
 */
public static ServerPluginDescriptorType loadPluginDescriptorFromUrl(URL pluginJarFileUrl) throws Exception {

    final Log logger = LogFactory.getLog(ServerPluginDescriptorUtil.class);

    if (pluginJarFileUrl == null) {
        throw new Exception("A valid plugin JAR URL must be supplied.");
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Loading plugin descriptor from plugin jar at [" + pluginJarFileUrl + "]...");
    }

    testPluginJarIsReadable(pluginJarFileUrl);

    JarInputStream jis = null;
    JarEntry descriptorEntry = null;

    try {
        jis = new JarInputStream(pluginJarFileUrl.openStream());
        JarEntry nextEntry = jis.getNextJarEntry();
        while (nextEntry != null && descriptorEntry == null) {
            if (PLUGIN_DESCRIPTOR_PATH.equals(nextEntry.getName())) {
                descriptorEntry = nextEntry;
            } else {
                jis.closeEntry();
                nextEntry = jis.getNextJarEntry();
            }
        }

        ServerPluginDescriptorType pluginDescriptor = null;

        if (descriptorEntry != null) {
            Unmarshaller unmarshaller = null;
            try {
                unmarshaller = getServerPluginDescriptorUnmarshaller();
                Object jaxbElement = unmarshaller.unmarshal(jis);
                pluginDescriptor = ((JAXBElement<? extends ServerPluginDescriptorType>) jaxbElement).getValue();
            } finally {
                if (unmarshaller != null) {
                    ValidationEventCollector validationEventCollector = (ValidationEventCollector) unmarshaller
                            .getEventHandler();
                    logValidationEvents(pluginJarFileUrl, validationEventCollector);
                }
            }
        }

        return pluginDescriptor;

    } catch (Exception e) {
        throw new Exception("Could not successfully parse the plugin descriptor [" + PLUGIN_DESCRIPTOR_PATH
                + "] found in plugin jar at [" + pluginJarFileUrl + "]", e);
    } finally {
        if (jis != null) {
            try {
                jis.close();
            } catch (Exception e) {
                logger.warn("Cannot close jar stream [" + pluginJarFileUrl + "]. Cause: " + e);
            }
        }
    }
}

From source file:org.rhq.plugins.platform.content.RpmPackageDiscoveryDelegate.java

public static Set<ResourcePackageDetails> discoverPackages(PackageType type) throws IOException {
    Log log = LogFactory.getLog(RpmPackageDiscoveryDelegate.class);

    Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();

    if (rpmExecutable == null) {
        return packages;
    }//from  w  ww  . j av  a2 s  . c  o m

    /* Sample output from: rpm -qa
     * xorg-x11-fonts-ethiopic-7.2-3.fc8 bitmap-fonts-0.3-5.1.2.fc7 bluez-utils-cups-3.20-4.fc8
     *
     * In short, it's a list of installed packages.
     */
    ProcessExecution listRpmsProcess = new ProcessExecution(rpmExecutable);
    listRpmsProcess.setArguments(new String[] { "-qa" });
    listRpmsProcess.setCaptureOutput(true);

    ProcessExecutionResults executionResults = systemInfo.executeProcess(listRpmsProcess);
    String capturedOutput = executionResults.getCapturedOutput();

    // Process the resulting output
    if (capturedOutput == null) {
        return packages;
    }

    BufferedReader rpmNameReader = new BufferedReader(new StringReader(capturedOutput));

    String rpmName;

    while ((rpmName = rpmNameReader.readLine()) != null) {
        String name = null;
        String version = null;
        String architectureName = null;

        try {

            // Execute RPM query for each RPM
            ProcessExecution rpmQuery = new ProcessExecution(rpmExecutable);
            rpmQuery.setArguments(new String[] { "-q", "--qf",
                    "%{NAME}\\n%{VERSION}.%{RELEASE}\\n%{ARCH}\\n%{INSTALLTIME}\\n%{FILEMD5S}\\n%{GROUP}\\n%{FILENAMES}\\n%{SIZE}\\n%{LICENSE}\\n%{DESCRIPTION}",
                    rpmName });
            rpmQuery.setCaptureOutput(true);

            ProcessExecutionResults rpmDataResults = systemInfo.executeProcess(rpmQuery);
            String rpmData = rpmDataResults.getCapturedOutput();

            BufferedReader rpmDataReader = new BufferedReader(new StringReader(rpmData));

            name = rpmDataReader.readLine();
            version = rpmDataReader.readLine();
            architectureName = rpmDataReader.readLine();
            String installTimeString = rpmDataReader.readLine();
            String md5 = rpmDataReader.readLine();
            String category = rpmDataReader.readLine();
            String fileName = rpmDataReader.readLine();
            String sizeString = rpmDataReader.readLine();
            String license = rpmDataReader.readLine();

            StringBuffer description = new StringBuffer();
            String descriptionTemp;
            while ((descriptionTemp = rpmDataReader.readLine()) != null) {
                description.append(descriptionTemp);
            }

            Long fileSize = null;
            if (sizeString != null) {
                try {
                    fileSize = Long.parseLong(sizeString);
                } catch (NumberFormatException e) {
                    log.warn("Could not parse file size: " + sizeString);
                }
            }

            Long installTime = null;
            if (installTimeString != null) {
                try {
                    installTime = Long.parseLong(installTimeString);
                    installTime *= 1000L; // RPM returns epoch seconds, we need epoch millis
                } catch (NumberFormatException e) {
                    log.debug("Could not parse package install time");
                }
            }

            // There may be multiple file names. For now, just ignore the package (I'll find a better way
            // to deal with this going forward). There will be a blank space in the fileName attribute, so
            // just abort if we see that
            if ((fileName == null) || fileName.equals("")) {
                continue;
            }

            PackageDetailsKey key = new PackageDetailsKey(name, version, "rpm", architectureName);
            ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
            packageDetails.setClassification(category);
            packageDetails.setDisplayName(name);
            packageDetails.setFileName(fileName);
            if (!md5.startsWith("00000000000000000000000000000000")) {
                if (md5.length() <= 32) {
                    packageDetails.setMD5(md5);
                } else {
                    packageDetails.setSHA256(md5); // md5's can only be 32 chars, anything more and we assume its a SHA256
                }
            }
            packageDetails.setFileSize(fileSize);
            packageDetails.setLicenseName(license);
            packageDetails.setLongDescription(description.toString());
            packageDetails.setInstallationTimestamp(installTime);
            packages.add(packageDetails);
        } catch (Exception e) {
            log.error("Error creating resource package. RPM Name: " + rpmName + " Version: " + version
                    + " Architecture: " + architectureName);
        }

    }

    return packages;

}

From source file:org.romaframework.aspect.logging.loggers.FileLogger.java

public void print(int level, String category, String message) {
    Log logger = LogFactory.getLog(category);
    if (level == LoggingConstants.LEVEL_DEBUG) {
        logger.debug(message);
    } else if (level == LoggingConstants.LEVEL_WARNING) {
        logger.warn(message);//w  ww .j av a  2  s  .c  o  m
    } else if (level == LoggingConstants.LEVEL_ERROR) {
        logger.error(message);
    } else if (level == LoggingConstants.LEVEL_FATAL) {
        logger.fatal(message);
    } else if (level == LoggingConstants.LEVEL_INFO) {
        logger.info(message);
    }

}

From source file:org.sakaiproject.tool.assessment.business.entity.FileNamer.java

/**
 * unit test for use with jUnit etc.//from   w  ww  . j ava2 s  .c  om
 */
public static void unitTest() {
    Log log = LogFactory.getLog(RecordingData.class);

    String s;
    s = make("Ed Smiley", "esmiley", "Intro to Wombats 101");
    log.debug("esmiley file: " + s);

    s = make("Rachel Gollub", "rgollub", "Intro to Wolverines and Aardvarks 221B");
    log.debug("rgollub file: " + s);

    s = make("Ed Smiley", "esmiley", "Intro to Wombats 101");
    log.debug("esmiley file: " + s);

    s = make("Rachel Gollub", "rgollub", "Intro to Wolverines and Aardvarks 221B");
    log.debug("rgollub file: " + s);

    s = make(null, null, null);
    log.debug("NULL file: " + s);
    s = make(null, null, null);
    log.debug("NULL file: " + s);
}

From source file:org.sakaiproject.tool.assessment.business.entity.RecordingData.java

/**
 * unit test for use with jUnit etc. this only tests the file name
 * computation, the other methods are pretty trivial
 *
 * @param none//  ww  w  .ja v a 2  s .  c  o  m
 * @return none
 */
public static void unitTest() {
    Log log = LogFactory.getLog(RecordingData.class);

    RecordingData rd = new RecordingData("Ed Smiley", "esmiley", "Intro to Wombats 101", "10", "30");
    log.debug("esmiley file:" + rd.getFileName() + "." + rd.getFileExtension());
    log.debug("limit =" + rd.getLimit());
    log.debug("seconds=" + rd.getSeconds());

    rd = new RecordingData("Rachel Gollub", "rgollub", "Rachel's Intro to Wolverines and Aardvarks 221B", "10",
            "25");
    log.debug("rgollub file:" + rd.getFileName() + "." + rd.getFileExtension());
    log.debug("limit =" + rd.getLimit());
    log.debug("seconds=" + rd.getSeconds());

    rd = new RecordingData("Rachel Gollub", "rgollub", "Intro to Wolverines and Aardvarks 221B", "10", "25");
    log.debug("rgollub file:" + rd.getFileName() + "." + rd.getFileExtension());
    log.debug("limit =" + rd.getLimit());
    log.debug("seconds=" + rd.getSeconds());

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Source xmlSource = new DOMSource(rd.getXMLDataModel());
    Result outputTarget = new StreamResult(out);
    Transformer tf;
    try {
        tf = TransformerFactory.newInstance().newTransformer();
        tf.transform(xmlSource, outputTarget);
    } catch (TransformerException e) {
        log.debug("cannot serialize" + e);
    }

    rd = new RecordingData(null, null, null, null, null);
    log.debug("NULL file: " + rd.getFileName() + "." + rd.getFileExtension());
    log.debug("limit =" + rd.getLimit());
    log.debug("seconds=" + rd.getSeconds());

    rd = new RecordingData(null, null, null, null, null);
    log.debug("NULL file: " + rd.getFileName() + "." + rd.getFileExtension());
    log.debug("limit =" + rd.getLimit());
    log.debug("seconds=" + rd.getSeconds());
}

From source file:org.sakaiproject.tool.assessment.integration.context.IntegrationContextFactory.java

/**
 * Static method returning an implementation instance of this factory.
 * @return the factory singleton//from w  w w  . ja v  a2s. c o  m
 */
public static IntegrationContextFactory getInstance() {
    Log log = LogFactory.getLog(IntegrationContextFactory.class);
    log.debug("IntegrationContextFactory.getInstance()");
    if (instance == null) {
        try {
            FactoryUtil.setUseLocator(true);
            instance = FactoryUtil.lookup();
        } catch (Exception ex) {
            log.error("Unable to read integration context: " + ex);
        }
    }
    log.debug("instance=" + instance);
    return instance;
}