Example usage for org.apache.commons.collections MapUtils verbosePrint

List of usage examples for org.apache.commons.collections MapUtils verbosePrint

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils verbosePrint.

Prototype

public static void verbosePrint(final PrintStream out, final Object label, final Map map) 

Source Link

Document

Prints the given map with nice line breaks.

Usage

From source file:com.mirth.connect.model.Event.java

public String toExportString() {
    StringBuilder builder = new StringBuilder();
    builder.append(id + ", ");
    builder.append(new SimpleDateFormat(Exportable.DATE_TIME_FORMAT).format(dateTime.getTime()) + ", ");
    builder.append(level + ", ");
    builder.append(outcome + ", ");
    builder.append(name + ", ");
    builder.append(userId + ", ");
    builder.append(ipAddress + ", ");

    /*//from w  w  w  . j  a  v  a 2s.co m
     * Print out the attributes and Base64 encode them in case there are
     * newlines.
     */
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    MapUtils.verbosePrint(ps, "attributes", attributes);
    builder.append(Base64.encodeBase64URLSafeString(baos.toByteArray()));
    builder.append(System.getProperty("line.separator"));
    IOUtils.closeQuietly(ps);

    return builder.toString();
}

From source file:com.mirth.connect.model.ServerEvent.java

public String toExportString() {
    StringBuilder builder = new StringBuilder();
    builder.append(id + ", ");
    builder.append(new SimpleDateFormat(Exportable.DATE_TIME_FORMAT).format(eventTime.getTime()) + ", ");
    builder.append(level + ", ");
    builder.append(outcome + ", ");
    builder.append(name + ", ");
    builder.append(userId + ", ");
    builder.append(ipAddress + ", ");

    /*//from ww w. j av a 2  s .  c  o  m
     * Print out the attributes and Base64 encode them in case there are
     * newlines.
     */
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    MapUtils.verbosePrint(ps, "attributes", attributes);
    builder.append(Base64.encodeBase64URLSafeString(baos.toByteArray()));
    builder.append(System.getProperty("line.separator"));
    IOUtils.closeQuietly(ps);

    return builder.toString();
}

From source file:org.kuali.rice.krms.impl.ui.RuleEditorController.java

/**
 * This overridden method does extra work on refresh to populate the context and agenda
 * //from   www. j  a v  a 2  s . co  m
 * @see org.kuali.rice.krad.web.spring.controller.UifControllerBase#refresh(org.kuali.rice.krad.web.spring.form.UifFormBase, org.springframework.validation.BindingResult, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@RequestMapping(params = "methodToCall=" + "refresh")
@Override
public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    MapUtils.verbosePrint(System.out, "actionParameters", form.getActionParameters());
    MapUtils.verbosePrint(System.out, "requestParameters", request.getParameterMap());

    String agendaId = null;

    MaintenanceForm maintenanceForm = (MaintenanceForm) form;
    String conversionFields = maintenanceForm.getActionParameters().get("conversionFields");
    String refreshCaller = request.getParameter("refreshCaller");

    // handle return from agenda lookup
    // TODO: this condition is sloppy 
    if (refreshCaller != null && refreshCaller.contains("Agenda") && refreshCaller.contains("LookupView")
            && conversionFields != null &&
            // TODO: this is sloppy
            conversionFields.contains("agenda.id")) {
        AgendaEditor editorDocument = ((AgendaEditor) maintenanceForm.getDocument().getNewMaintainableObject()
                .getDataObject());
        agendaId = editorDocument.getAgenda().getId();
        AgendaBo agenda = getBusinessObjectService().findBySinglePrimaryKey(AgendaBo.class, agendaId);
        editorDocument.setAgenda(agenda);

        if (agenda.getContextId() != null) {
            ContextBo context = getBusinessObjectService().findBySinglePrimaryKey(ContextBo.class,
                    agenda.getContextId());
            editorDocument.setContext(context);
        }
    }

    return super.refresh(form, result, request, response);
}

From source file:org.nuxeo.connect.packages.dependencies.CUDFHelper.java

/**
 * @param upgrades Packages for which we'll feed the CUDF universe with the remote one if they're SNAPSHOT, in order
 *            to allow their upgrade/*ww w.  jav  a  2s  .com*/
 * @param installs
 * @param removes
 * @since 1.4.11
 */
public void initMapping(PackageDependency[] installs, PackageDependency[] removes,
        PackageDependency[] upgrades) {
    nuxeo2CUDFMap.clear();
    CUDF2NuxeoMap.clear();
    Map<String, PackageDependency> upgradesMap = new HashMap<>();
    Set<String> involvedPackages = new HashSet<>();
    List<String> installedOrRequiredSNAPSHOTPackages = new ArrayList<>();
    if (upgrades != null) {
        computeInvolvedPackages(upgrades, upgradesMap, involvedPackages, installedOrRequiredSNAPSHOTPackages);
    }
    if (installs != null) {
        computeInvolvedPackages(installs, involvedPackages, installedOrRequiredSNAPSHOTPackages);
    }
    if (removes != null) {
        computeInvolvedPackages(removes, involvedPackages, installedOrRequiredSNAPSHOTPackages);
    }

    // Build a map <pkgName,pkg>
    List<DownloadablePackage> allPackages = getAllPackages();
    Map<String, List<DownloadablePackage>> allPackagesMap = new HashMap<>();
    for (DownloadablePackage pkg : allPackages) {
        String key = pkg.getName();
        List<DownloadablePackage> list;
        if (!allPackagesMap.containsKey(key)) {
            list = new ArrayList<>();
            allPackagesMap.put(key, list);
        } else {
            list = allPackagesMap.get(key);
        }
        list.add(pkg);
        // in the mean time, add installed packages to the involved packages list
        if (keep && pkg.getPackageState().isInstalled()) {
            involvedPackages.add(pkg.getName());
        }
    }
    for (DownloadablePackage pkg : allPackages) {
        computeInvolvedReferences(involvedPackages, installedOrRequiredSNAPSHOTPackages, pkg, allPackagesMap);
    }
    installedOrRequiredSNAPSHOTPackages.addAll(getInstalledSNAPSHOTPackages());
    // for each unique "name-classifier", sort versions so we can attribute them a "CUDF posint" version populate
    // Nuxeo2CUDFMap and the reverse CUDF2NuxeoMap
    for (DownloadablePackage pkg : allPackages) {
        // ignore not involved packages
        if (!involvedPackages.contains(pkg.getName())) {
            if (installedOrRequiredSNAPSHOTPackages.contains(pkg.getName())) {
                log.error("Ignore installedOrRequiredSNAPSHOTPackage " + pkg);
            }

            // check provides
            boolean involved = false;
            PackageDependency[] provides = pkg.getProvides();
            for (PackageDependency provide : provides) {
                if (involvedPackages.contains(provide.getName())) {
                    involved = true;
                    break;
                }
            }
            if (!involved) {
                log.debug("Ignore " + pkg + " (not involved by request)");
                continue;
            }
        }

        // ignore incompatible packages when a targetPlatform is set
        if (!pkg.getPackageState().isInstalled()
                && !TargetPlatformFilterHelper.isCompatibleWithTargetPlatform(pkg, targetPlatform)) {
            log.debug("Ignore " + pkg + " (incompatible target platform)");
            continue;
        }
        // Exclude SNAPSHOT by default for non Studio packages
        if (!allowSNAPSHOT && pkg.getVersion().isSnapshot() && pkg.getType() != PackageType.STUDIO
                && !installedOrRequiredSNAPSHOTPackages.contains(pkg.getName())) {
            log.debug("Ignore " + pkg + " (excluded SNAPSHOT)");
            continue;
        }

        // SNAPSHOT upgrade requires referring the remote package
        if (pkg.getVersion().isSnapshot() && pkg.isLocal() && upgradesMap.containsKey(pkg.getName())) {
            PackageDependency upgrade = upgradesMap.get(pkg.getName());
            if (upgrade.getVersionRange().matchVersion(pkg.getVersion())) {
                DownloadablePackage remotePackage = pm.getRemotePackage(pkg.getId());
                if (remotePackage != null) {
                    log.debug(String.format("Upgrade with remote %s", remotePackage));
                    pkg = remotePackage;
                }
            }
        }
        NuxeoCUDFPackage nuxeoCUDFPackage = new NuxeoCUDFPackage(pkg);
        // if (!keep && !involvedPackages.contains(pkg.getName())) {
        // nuxeoCUDFPackage.setInstalled(false);
        // }
        Map<Version, NuxeoCUDFPackage> pkgVersions = nuxeo2CUDFMap.get(nuxeoCUDFPackage.getCUDFName());
        if (pkgVersions == null) {
            pkgVersions = new TreeMap<>();
            nuxeo2CUDFMap.put(nuxeoCUDFPackage.getCUDFName(), pkgVersions);
        }
        pkgVersions.put(nuxeoCUDFPackage.getNuxeoVersion(), nuxeoCUDFPackage);
    }
    for (String key : nuxeo2CUDFMap.keySet()) {
        Map<Version, NuxeoCUDFPackage> pkgVersions = nuxeo2CUDFMap.get(key);
        int posInt = 1;
        for (Version version : pkgVersions.keySet()) {
            NuxeoCUDFPackage pkg = pkgVersions.get(version);
            pkg.setCUDFVersion(posInt++);
            CUDF2NuxeoMap.put(pkg.getCUDFName() + "-" + pkg.getCUDFVersion(), pkg);
        }
    }

    if (log.isDebugEnabled()) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PrintStream out = new PrintStream(outputStream);
        MapUtils.verbosePrint(out, "nuxeo2CUDFMap", nuxeo2CUDFMap);
        MapUtils.verbosePrint(out, "CUDF2NuxeoMap", CUDF2NuxeoMap);
        log.debug(outputStream.toString());
        IOUtils.closeQuietly(out);
    }
}