Example usage for org.apache.commons.lang BooleanUtils toBooleanDefaultIfNull

List of usage examples for org.apache.commons.lang BooleanUtils toBooleanDefaultIfNull

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toBooleanDefaultIfNull.

Prototype

public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) 

Source Link

Document

Converts a Boolean to a boolean handling null.

 BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false) = true BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true) = false BooleanUtils.toBooleanDefaultIfNull(null, true)          = true 

Usage

From source file:com.redhat.rhn.frontend.action.satellite.RestartAction.java

/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) {/*from  w w w.  jav a  2 s .  com*/

    DynaActionForm form = (DynaActionForm) formIn;
    RequestContext ctx = new RequestContext(request);

    if (isSubmitted(form)) {
        Boolean restart = ((Boolean) form.get(RESTART));
        if (BooleanUtils.toBooleanDefaultIfNull(restart, false)) {
            RestartSatelliteEvent event = new RestartSatelliteEvent(ctx.getCurrentUser());
            MessageQueue.publish(event);
            createSuccessMessage(request, "restart.config.success", String.valueOf(RESTART_DELAY_IN_MINUTES));
            request.setAttribute(RESTART, Boolean.TRUE);
            request.setAttribute(RESTART_DELAY_LABEL, String.valueOf(RESTART_DELAY_IN_MINUTES * 60));
        } else {
            addMessage(request, "restart.config.norestart");
            request.setAttribute(RESTART, Boolean.FALSE);
        }
    } else {
        if (request.getParameter(RESTARTED) != null && request.getParameter(RESTARTED).equals("true")) {
            addMessage(request, "restart.config.restarted");
        }

        form.set(RESTART, Boolean.FALSE);
        request.setAttribute(RESTART, Boolean.FALSE);
    }

    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}

From source file:com.redhat.rhn.manager.satellite.ConfigureBootstrapCommand.java

/**
 * {@inheritDoc}//from   w  ww .j  a  v  a  2  s  . c o m
 */
public ValidatorError[] storeConfiguration() {
    Executor e = getExecutor();
    ValidatorError[] errors = new ValidatorError[1];
    String errorKey = "bootstrap.config.error.";

    List args = new LinkedList();
    args.add("/usr/bin/sudo");
    args.add("/usr/bin/rhn-bootstrap");
    if (BooleanUtils.toBooleanDefaultIfNull(this.allowConfigActions, false)) {
        args.add("--allow-config-actions");
    }
    if (BooleanUtils.toBooleanDefaultIfNull(this.allowRemoteCommands, false)) {
        args.add("--allow-remote-commands");
    }
    if (!BooleanUtils.toBooleanDefaultIfNull(this.enableSsl, false)) {
        args.add("--no-ssl");
    }
    if (!BooleanUtils.toBooleanDefaultIfNull(this.enableGpg, false)) {
        args.add("--no-gpg");
    }

    if (!StringUtils.isEmpty(this.hostname)) {
        args.add("--hostname=" + this.hostname);
    }
    if (!StringUtils.isEmpty(this.sslPath)) {
        args.add("--ssl-cert=" + this.sslPath);
    }
    if (!StringUtils.isEmpty(this.httpProxy)) {
        args.add("--http-proxy=" + this.httpProxy);
    }
    if (!StringUtils.isEmpty(this.httpProxyUsername)) {
        args.add("--http-proxy-username=" + this.httpProxyUsername);
    }
    if (!StringUtils.isEmpty(this.httpProxyPassword)) {
        args.add("--http-proxy-password=" + this.httpProxyPassword);
    }

    int exitcode = e.execute((String[]) args.toArray(new String[0]));
    if (exitcode != 0) {
        errorKey = errorKey + exitcode;
        if (!LocalizationService.getInstance().hasMessage(errorKey)) {
            errorKey = "bootstrap.config.error.127";
        }
        errors[0] = new ValidatorError(errorKey);
        return errors;
    }
    return null;

}

From source file:com.adaptris.core.services.transcoding.DecodingService.java

boolean isOverrideMetadata() {
    return BooleanUtils.toBooleanDefaultIfNull(getOverrideMetadata(), false);
}

From source file:com.ansorgit.plugins.bash.lang.psi.impl.BashFileImpl.java

@Override
public boolean processDeclarations(@NotNull final PsiScopeProcessor processor,
        @NotNull final ResolveState state, final PsiElement lastParent, @NotNull final PsiElement place) {
    if (!processor.execute(this, state)) {
        return false;
    }// w  w w  . j  av a2  s .c  o  m

    boolean walkDeep = BooleanUtils.toBooleanDefaultIfNull(processor.getHint(Keys.FILE_WALK_GO_DEEP), true);
    boolean moreProcessing = true;
    if (walkDeep) {
        PsiElement child = getFirstChild();

        while (child != null) {
            if (child != lastParent && !child.processDeclarations(processor, state, lastParent, place)) {
                moreProcessing = false;
            }

            child = child.getNextSibling();
        }
    } else {
        //walk the toplevel psi elements without diving into them
        //we can compute the first element to walk a bit smarter than getFirstChild().
        //It's the next toplevel element after place, i.e. starting element

        PsiElement child = getFirstChild();
        while (child != null) {
            if (!processor.execute(child, state)) {
                moreProcessing = false;
                break;
            }

            //include commands have to be visited, though
            if (child instanceof BashIncludeCommand) {
                if (!child.processDeclarations(processor, state, lastParent, place)) {
                    moreProcessing = false;
                }
            }

            child = child.getNextSibling();
        }
    }

    return moreProcessing;
}

From source file:com.adaptris.core.services.cache.RetrieveFromCacheService.java

boolean exceptionIfNotFound() {
    return BooleanUtils.toBooleanDefaultIfNull(getExceptionIfNotFound(), true);
}

From source file:com.adaptris.core.services.splitter.MessageSplitterImp.java

boolean copyMetadata() {
    return BooleanUtils.toBooleanDefaultIfNull(getCopyMetadata(), true);
}

From source file:com.gst.accounting.glaccount.domain.GLAccount.java

private GLAccount(final GLAccount parent, final String name, final String glCode, final boolean disabled,
        final boolean manualEntriesAllowed, final Integer type, final Integer usage, final String description,
        final CodeValue tagId) {
    this.name = StringUtils.defaultIfEmpty(name, null);
    this.glCode = StringUtils.defaultIfEmpty(glCode, null);
    this.disabled = BooleanUtils.toBooleanDefaultIfNull(disabled, false);
    this.manualEntriesAllowed = BooleanUtils.toBooleanDefaultIfNull(manualEntriesAllowed, true);
    this.usage = usage;
    this.type = type;
    this.description = StringUtils.defaultIfEmpty(description, null);
    this.parent = parent;
    this.tagId = tagId;
}

From source file:com.adaptris.core.services.splitter.MessageSplitterImp.java

boolean copyObjectMetadata() {
    return BooleanUtils.toBooleanDefaultIfNull(getCopyObjectMetadata(), false);
}

From source file:com.adaptris.core.services.jdbc.JdbcDataCaptureServiceImpl.java

public boolean saveReturnedKeys() {
    return BooleanUtils.toBooleanDefaultIfNull(getSaveReturnedKeys(), false);
}

From source file:com.adaptris.core.services.cache.CacheEntryEvaluator.java

boolean errorOnEmptyKey() {
    return BooleanUtils.toBooleanDefaultIfNull(getErrorOnEmptyKey(), true);
}