Java Code Examples for org.apache.commons.lang3.BooleanUtils#toBooleanDefaultIfNull()
The following examples show how to use
org.apache.commons.lang3.BooleanUtils#toBooleanDefaultIfNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputFile.java From ambari-logsearch with Apache License 2.0 | 6 votes |
@Override public void start() throws Exception { boolean isProcessFile = BooleanUtils.toBooleanDefaultIfNull(getInputDescriptor().getProcessFile(), true); if (isProcessFile) { for (int i = logFiles.length - 1; i >= 0; i--) { File file = logFiles[i]; if (i == 0 || !tail) { try { processFile(file, i == 0); if (isClosed() || isDrain()) { logger.info("isClosed or isDrain. Now breaking loop."); break; } } catch (Throwable t) { logger.error("Error processing file=" + file.getAbsolutePath(), t); } } } close(); } else { copyFiles(logFiles); } }
Example 2
Source File: InputFile.java From ambari-logsearch with Apache License 2.0 | 6 votes |
private void copyFiles(File[] files) { boolean isCopyFile = BooleanUtils.toBooleanDefaultIfNull(getInputDescriptor().getCopyFile(), false); if (isCopyFile && files != null) { for (File file : files) { try { InputFileMarker marker = new InputFileMarker(this, null, 0); getOutputManager().copyFile(file, marker); if (isClosed() || isDrain()) { logger.info("isClosed or isDrain. Now breaking loop."); break; } } catch (Throwable t) { logger.error("Error processing file=" + file.getAbsolutePath(), t); } } } }
Example 3
Source File: AgsBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 6 votes |
/** * Creates instance of the adaptor. * @param def broker definition * @throws InvalidDefinitionException if invalid broker definition */ public AgsBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException { super(def); this.credAdaptor =new CredentialsDefinitionAdaptor(def); this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def); if (StringUtils.trimToEmpty(def.getType()).isEmpty()) { def.setType(AgsConnector.TYPE); } else if (!AgsConnector.TYPE.equals(def.getType())) { throw new InvalidDefinitionException("Broker definition doesn't match"); } else { try { hostUrl = new URL(get(P_HOST_URL)); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } enableLayers = BooleanUtils.toBoolean(get(P_ENABLE_LAYERS)); emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false); } }
Example 4
Source File: GptBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 6 votes |
/** * Creates instance of the adaptor. * @param def broker definition */ public GptBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException { super(def); this.credAdaptor = new CredentialsDefinitionAdaptor(def); this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def); if (StringUtils.trimToEmpty(def.getType()).isEmpty()) { def.setType(GptConnector.TYPE); } else if (!GptConnector.TYPE.equals(def.getType())) { throw new InvalidDefinitionException("Broker definition doesn't match"); } else { try { String sHostUrl = get(P_HOST_URL); if (sHostUrl!=null) { sHostUrl = sHostUrl.replaceAll("/*$", "/"); } hostUrl = new URL(sHostUrl); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } index = get(P_INDEX); emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false); } }
Example 5
Source File: AgpInputBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 6 votes |
/** * Creates instance of the adaptor. * @param def broker definition * @throws IllegalArgumentException if invalid broker definition */ public AgpInputBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException { super(def); this.credAdaptor =new CredentialsDefinitionAdaptor(def); this.botsAdaptor = new BotsBrokerDefinitionAdaptor(def); if (StringUtils.trimToEmpty(def.getType()).isEmpty()) { def.setType(AgpInputConnector.TYPE); } else if (!AgpInputConnector.TYPE.equals(def.getType())) { throw new InvalidDefinitionException("Broker definition doesn't match"); } else { try { hostUrl = new URL(get(P_HOST_URL)); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } folderId = get(P_FOLDER_ID); emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false); metaFormat = MetadataFormat.parse(get(P_EMIT_XML_FMT), MetadataFormat.DEFAULT); maxRedirects = NumberUtils.toInt(get(P_MAX_REDIRECTS), DEFAULT_MAX_REDIRECTS); } }
Example 6
Source File: RestartAction.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request, HttpServletResponse response) { 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); }
Example 7
Source File: FilterDummy.java From ambari-logsearch with Apache License 2.0 | 5 votes |
@Override public void init(LogFeederProps logFeederProps) throws Exception { if (logFeederProps.isDockerContainerRegistryEnabled()) { Input input = getInput(); if (input instanceof InputFile) { dockerEnabled = BooleanUtils.toBooleanDefaultIfNull(((InputFileDescriptor) input.getInputDescriptor()).getDockerEnabled(), false); } } }
Example 8
Source File: CkanBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 5 votes |
/** * Initializes adaptor from definition. * @param def broker definition * @throws InvalidDefinitionException if definition is invalid */ protected void initialize(EntityDefinition def) throws InvalidDefinitionException { apiKey = get(P_API_KEY); emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false); try { hostUrl = new URL(get(P_HOST_URL)); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } }
Example 9
Source File: GptBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 5 votes |
/** * Creates instance of the adaptor. * @param def broker definition */ public GptBrokerDefinitionAdaptor(EntityDefinition def) throws InvalidDefinitionException { super(def); this.credAdaptor = new CredentialsDefinitionAdaptor(def); if (credAdaptor.getCredentials().isEmpty()) { throw new InvalidDefinitionException("Empty credentials"); } if (StringUtils.trimToEmpty(def.getType()).isEmpty()) { def.setType(GptConnector.TYPE); } else if (!GptConnector.TYPE.equals(def.getType())) { throw new InvalidDefinitionException("Broker definition doesn't match"); } else { try { String sHostUrl = get(P_HOST_URL); if (sHostUrl!=null) { sHostUrl = sHostUrl.replaceAll("/*$", "/"); } hostUrl = new URL(sHostUrl); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } forceAdd = Boolean.parseBoolean(get(P_FORCE_ADD)); cleanup = Boolean.parseBoolean(get(P_CLEANUP)); index = get(P_INDEX); emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_ACCEPT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_ACCEPT_JSON)), false); translatePdf = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_TRANSLATE_PDF)), true); editable = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EDITABLE)), false); } }
Example 10
Source File: DcatBrokerDefinitionAdaptor.java From geoportal-server-harvester with Apache License 2.0 | 5 votes |
/** * Initializes adaptor from definition. * @param def broker definition * @throws InvalidDefinitionException if definition is invalid */ protected void initialize(EntityDefinition def) throws InvalidDefinitionException { emitXml = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_XML)), true); emitJson = BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(get(P_EMIT_JSON)), false); try { hostUrl = new URL(get(P_HOST_URL)); } catch (MalformedURLException ex) { throw new InvalidDefinitionException(String.format("Invalid %s: %s", P_HOST_URL,get(P_HOST_URL)), ex); } }
Example 11
Source File: PropertyUtils.java From ontopia with Apache License 2.0 | 4 votes |
public static boolean isTrue(String property_value, boolean default_value) { return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(property_value), default_value); }
Example 12
Source File: ConfigureBootstrapCommand.java From uyuni with GNU General Public License v2.0 | 4 votes |
/** * {@inheritDoc} */ 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 (!BooleanUtils.toBooleanDefaultIfNull(this.saltEnabled, false)) { args.add("--traditional"); } 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; }
Example 13
Source File: BooleanUtil.java From j360-dubbo-app-all with Apache License 2.0 | 4 votes |
/** * 支持true/false,on/off, y/n, yes/no的转换, str为空或无法分析时返回defaultValue */ public static Boolean parseGeneralString(String str, Boolean defaultValue) { return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(str), defaultValue); }
Example 14
Source File: CheckerOptionsFactory.java From swagger-brake with Apache License 2.0 | 4 votes |
private boolean isDeprecatedApiDeletionAllowed(Options options) { return BooleanUtils.toBooleanDefaultIfNull(options.getDeprecatedApiDeletionAllowed(), true); }
Example 15
Source File: BooleanUtil.java From vjtools with Apache License 2.0 | 4 votes |
/** * 支持true/false,on/off, y/n, yes/no的转换, str为空或无法分析时返回defaultValue */ public static Boolean parseGeneralString(String str, Boolean defaultValue) { return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(str), defaultValue); }
Example 16
Source File: PrivacyEnforcementService.java From prebid-server-java with Apache License 2.0 | 4 votes |
public boolean isCcpaEnforced(Ccpa ccpa, Account account) { final boolean shouldEnforceCcpa = BooleanUtils.toBooleanDefaultIfNull(account.getEnforceCcpa(), ccpaEnforce); return shouldEnforceCcpa && ccpa.isEnforced(); }
Example 17
Source File: FilterGrok.java From ambari-logsearch with Apache License 2.0 | 4 votes |
@Override public void init(LogFeederProps logFeederProps) throws Exception { super.init(logFeederProps); try { messagePattern = escapePattern(((FilterGrokDescriptor)getFilterDescriptor()).getMessagePattern()); multilinePattern = escapePattern(((FilterGrokDescriptor)getFilterDescriptor()).getMultilinePattern()); sourceField = getFilterDescriptor().getSourceField(); removeSourceField = BooleanUtils.toBooleanDefaultIfNull(getFilterDescriptor().isRemoveSourceField(), removeSourceField); skipOnError = ((FilterGrokDescriptor) getFilterDescriptor()).isSkipOnError(); if (logFeederProps.isDockerContainerRegistryEnabled()) { Input input = getInput(); if (input instanceof InputFile) { dockerEnabled = BooleanUtils.toBooleanDefaultIfNull(((InputFileDescriptor) input.getInputDescriptor()).getDockerEnabled(), false); } } logger.info("init() done. grokPattern=" + messagePattern + ", multilinePattern=" + multilinePattern + ", " + getShortDescription()); if (StringUtils.isEmpty(messagePattern)) { logger.error("message_pattern is not set for filter."); return; } extractNamedParams(messagePattern, namedParamList); grokMessage = new Grok(); loadPatterns(grokMessage); grokMessage.compile(messagePattern); if (((FilterGrokDescriptor)getFilterDescriptor()).isDeepExtract()) { extractNamedParams(grokMessage.getNamedRegexCollection()); } else { extractNamedParams(messagePattern, namedParamList); } if (!StringUtils.isEmpty(multilinePattern)) { extractNamedParams(multilinePattern, multiLineamedParamList); grokMultiline = new Grok(); loadPatterns(grokMultiline); grokMultiline.compile(multilinePattern); } } catch (Throwable t) { logger.fatal("Caught exception while initializing Grok. multilinePattern=" + multilinePattern + ", messagePattern=" + messagePattern, t); grokMessage = null; grokMultiline = null; } }
Example 18
Source File: BooleanUtil.java From vjtools with Apache License 2.0 | 4 votes |
/** * 支持true/false,on/off, y/n, yes/no的转换, str为空或无法分析时返回defaultValue */ public static Boolean parseGeneralString(String str, Boolean defaultValue) { return BooleanUtils.toBooleanDefaultIfNull(BooleanUtils.toBooleanObject(str), defaultValue); }