List of usage examples for org.apache.commons.lang BooleanUtils isFalse
public static boolean isFalse(Boolean bool)
Checks if a Boolean
value is false
, handling null
by returning false
.
BooleanUtils.isFalse(Boolean.TRUE) = false BooleanUtils.isFalse(Boolean.FALSE) = true BooleanUtils.isFalse(null) = false
From source file:com.haulmont.cuba.gui.components.filter.condition.DynamicAttributesCondition.java
@Override protected void updateText() { if (operator == Op.NOT_EMPTY) { if (BooleanUtils.isTrue((Boolean) param.getValue())) { text = text.replace("not exists", "exists"); } else if (BooleanUtils.isFalse((Boolean) param.getValue()) && !text.contains("not exists")) { text = text.replace("exists ", "not exists "); }/*from w ww.ja va 2 s.co m*/ } if (!isCollection) { if (operator == Op.ENDS_WITH || operator == Op.STARTS_WITH || operator == Op.CONTAINS || operator == Op.DOES_NOT_CONTAIN) { Matcher matcher = LIKE_PATTERN.matcher(text); if (matcher.find()) { String escapeCharacter = ("\\".equals(QueryUtils.ESCAPE_CHARACTER) || "$".equals(QueryUtils.ESCAPE_CHARACTER)) ? QueryUtils.ESCAPE_CHARACTER + QueryUtils.ESCAPE_CHARACTER : QueryUtils.ESCAPE_CHARACTER; text = matcher.replaceAll("$1 ESCAPE '" + escapeCharacter + "' "); } } } else { if (operator == Op.CONTAINS) { text = text.replace("not exists", "exists"); } else if (operator == Op.DOES_NOT_CONTAIN && !text.contains("not exists")) { text = text.replace("exists ", "not exists "); } } }
From source file:com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.java
protected TextField createTextField(Datatype datatype) { TextField textField = componentsFactory.createComponent(TextField.class); textField.setDatatype(datatype);/*from w ww .j a va 2 s. c o m*/ if (!BooleanUtils.isFalse(editable)) { FilterHelper.ShortcutListener shortcutListener = new FilterHelper.ShortcutListener("add", new KeyCombination(KeyCombination.Key.ENTER)) { @Override public void handleShortcutPressed() { _addValue(textField); } }; AppBeans.get(FilterHelper.class).addShortcutListener(textField, shortcutListener); } return textField; }
From source file:com.adaptris.util.text.xml.XPath.java
/** * Create a new {@link XPath} instance.//from ww w. ja v a 2 s . c om * <p> * If the {@code DocumentBuilderFactoryBuilder} has been explicitly set to be not namespace aware and the document does in fact * contain namespaces, then Saxon can cause merry havoc in the sense that {@code //NonNamespaceXpath} doesn't work if the document * has namespaces in it. This then is a helper to mitigate against that; but of course in this situation you end up not being able * to use XPath 2.0 functions, when namespace-awareness is off as saxon 9.7+ no longer registers itself as a XPathFactory. * </p> * <p> * This leads us to a behavioural matrix that looks like this. Using Saxon means you get XPath 2.0 and its associated benefits, * Using {@code XPathFactory.newInstance()} generally means you don't, unless you have registered an alternative XPathFactory. * </p> * <table cellspacing="8"> * <tr> * <th align="left">DocumentBuilderFactoryBuilder#withNamespaceAware()</th> * <th align="left"> </th> * <th align="left">Namespace Context available</th> * <th align="left"> </th> * <th align="left">Uses Saxon</th> * <th align="left"> </th> * <th align="left">Uses XPathFactory#newInstance()</th> * </tr> * <tr> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">no</td> * <td align="left"> </td> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">false</td> * </tr> * <tr> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">false</td> * </tr> * <tr> * <td align="left">false</td> * <td align="left"> </td> * <td align="left">no</td> * <td align="left"> </td> * <td align="left">false</td> * <td align="left"> </td> * <td align="left">true</td> * </tr> * <tr> * <td align="left">false</td> * <td align="left"> </td> * <td align="left">yes</td> * <td align="left"> </td> * <td align="left">false</td> * <td align="left"> </td> * <td align="left">true</td> * </tr> * <tr> * <td align="left">not specified</td> * <td align="left"> </td> * <td align="left">yes</td> * <td align="left"> </td> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">false</td> * </tr> * <tr> * <td align="left">not specified</td> * <td align="left"> </td> * <td align="left">no</td> * <td align="left"> </td> * <td align="left">true</td> * <td align="left"> </td> * <td align="left">false</td> * </tr> * </table> * * @param builder the document builder factory * @param namespaceCtx the namespace context (might be null, but we pass it into the XPath constructor) */ public static XPath newXPathInstance(DocumentBuilderFactoryBuilder builder, NamespaceContext namespaceCtx) { // INTERLOK-2255 XPath xpathToUse = new XPath(namespaceCtx); if (builder != null && BooleanUtils.isFalse(builder.getNamespaceAware())) { xpathToUse = new XPath(namespaceCtx, XPathFactory.newInstance()); } return xpathToUse; }
From source file:com.haulmont.cuba.core.app.cache.ObjectsCache.java
@SuppressWarnings("unchecked") protected <T> List<T> copyItemsCollection(Collection<T> items) { List<T> result = Lists.newArrayList(); for (T item : items) { if (item instanceof BaseGenericIdEntity && BooleanUtils.isFalse(BaseEntityInternalAccess.isDetached((BaseGenericIdEntity) item))) item = (T) copy((BaseGenericIdEntity) item); result.add(item);// w w w. j ava 2s .c o m } return result; }
From source file:com.haulmont.cuba.security.app.LoginWorkerBean.java
@Override public UserSession loginTrusted(String login, String password, Locale locale, Map<String, Object> params) throws LoginException { RemoteClientInfo remoteClientInfo = RemoteClientInfo.get(); if (remoteClientInfo != null) { // reject request from not permitted client ip if (!trustedLoginHandler.checkAddress(remoteClientInfo.getAddress())) { log.warn("Attempt of trusted login from not permitted IP address: {} {}", login, remoteClientInfo.getAddress()); throw new LoginException(getInvalidCredentialsMessage(login, locale)); }/* w w w . ja v a2s. c o m*/ } else { log.debug("Unable to check trusted client IP when obtaining system session"); } if (!trustedLoginHandler.checkPassword(password)) throw new LoginException(getInvalidCredentialsMessage(login, locale)); Transaction tx = persistence.createTransaction(); try { User user = loadUser(login); if (user == null) { throw new LoginException( messages.formatMessage(MSG_PACK, "LoginException.InvalidUser", locale, login)); } Locale userLocale = locale; if (user.getLanguage() != null && BooleanUtils.isFalse(configuration.getConfig(GlobalConfig.class).getLocaleSelectVisible())) { userLocale = new Locale(user.getLanguage()); } UserSession session = userSessionManager.createSession(user, userLocale, false); checkPermissions(login, params, userLocale, session); log.info("Logged in: " + session); tx.commit(); userSessionManager.clearPermissionsOnUser(session); userSessionManager.storeSession(session); return session; } finally { tx.end(); } }
From source file:de.hybris.platform.b2bacceleratorfacades.order.impl.DefaultB2BCheckoutFacade.java
@Override public ScheduledCartData scheduleOrder(final TriggerData trigger) { final CartModel cartModel = getCart(); cartModel.setSite(getBaseSiteService().getCurrentBaseSite()); cartModel.setStore(getBaseStoreService().getCurrentBaseStore()); getModelService().save(cartModel);//from w w w .j a va2 s .com final AddressModel deliveryAddress = cartModel.getDeliveryAddress(); final AddressModel paymentAddress = cartModel.getPaymentAddress(); final PaymentInfoModel paymentInfo = cartModel.getPaymentInfo(); final TriggerModel triggerModel = getModelService().create(TriggerModel.class); getTriggerPopulator().populate(trigger, triggerModel); // If Trigger is not relative, reset activeDate to next expected runtime if (BooleanUtils.isFalse(triggerModel.getRelative())) { // getNextTime(relavtiveDate) will skip the date, to avoid skipping the activation date, go back 1 day to test. final Calendar priorDayCalendar = Calendar.getInstance(); priorDayCalendar.setTime(DateUtils.addDays(triggerModel.getActivationTime(), -1)); final Date nextPotentialFire = triggerService.getNextTime(triggerModel, priorDayCalendar).getTime(); if (!DateUtils.isSameDay(nextPotentialFire, triggerModel.getActivationTime())) { // Adjust activation time to next scheduled vis a vis the cron expression triggerModel.setActivationTime(nextPotentialFire); } } // schedule cart final CartToOrderCronJobModel scheduledCart = getScheduleOrderService().createOrderFromCartCronJob( cartModel, deliveryAddress, paymentAddress, paymentInfo, Collections.singletonList(triggerModel)); ScheduledCartData scheduledCartData = null; if (scheduledCart != null) { scheduledCartData = getScheduledCartConverter().convert(scheduledCart); getCartService().removeSessionCart(); // trigger an email. getEventService().publishEvent(initializeReplenishmentPlacedEvent(scheduledCart)); } return scheduledCartData; }
From source file:com.haulmont.cuba.security.app.LoginWorkerBean.java
@Override public UserSession loginByRememberMe(String login, String rememberMeToken, Locale locale, Map<String, Object> params) throws LoginException { Transaction tx = persistence.createTransaction(); try {//from w ww .j a va 2 s. co m User user = loadUser(login); if (user == null) { throw new LoginException( messages.formatMessage(MSG_PACK, "LoginException.InvalidUser", locale, login)); } RememberMeToken loginToken = loadRememberMeToken(rememberMeToken, user); if (loginToken == null) { throw new LoginException(getInvalidCredentialsMessage(login, locale)); } Locale userLocale = locale; if (user.getLanguage() != null && BooleanUtils.isFalse(configuration.getConfig(GlobalConfig.class).getLocaleSelectVisible())) { userLocale = new Locale(user.getLanguage()); } UserSession session = userSessionManager.createSession(user, userLocale, false); checkPermissions(login, params, userLocale, session); log.info("Logged in: " + session); tx.commit(); userSessionManager.clearPermissionsOnUser(session); userSessionManager.storeSession(session); return session; } finally { tx.end(); } }
From source file:mitm.common.security.smime.handler.SMIMEInfoHandlerImpl.java
private MimeMessage handleSigned(MimeMessage message, SMIMEInspector sMIMEInspector, int level) throws MessagingException { SMIMESignedInspector signedInspector = sMIMEInspector.getSignedInspector(); Collection<X509Certificate> certificates = null; try {//from ww w. j av a2 s . c o m certificates = signedInspector.getCertificates(); } catch (CryptoMessageSyntaxException e) { logger.error("Error getting certificates from signed message.", e); } Set<String> signerEmail = new HashSet<String>(); List<SignerInfo> signers; try { signers = signedInspector.getSigners(); } catch (CryptoMessageSyntaxException e) { throw new MessagingException("Error getting signers.", e); } Boolean signatureValid = null; for (int signerIndex = 0; signerIndex < signers.size(); signerIndex++) { Boolean thisSignatureValid = null; try { SignerInfo signer = signers.get(signerIndex); SignerIdentifier signerId; try { signerId = signer.getSignerId(); } catch (IOException e) { logger.error("Error getting signerId", e); /* * Continue with other signers */ continue; } addSignerIdentifierInfo(message, signerIndex, signerId, level); /* * try to get the signing certificate using a certificate selector */ CertSelector certSelector; try { certSelector = signerId.getSelector(); } catch (IOException e) { logger.error("Error getting selector for signer", e); /* * Continue with other signers */ continue; } /* first search through the certificates that are embedded in the CMS blob */ Collection<X509Certificate> signingCerts = CertificateUtils.getMatchingCertificates(certificates, certSelector); if (signingCerts.size() == 0 && securityServices.getKeyAndCertStore() != null) { /* * the certificate could not be found in the CMS blob. If the CertStore is * set we will see if the CertStore has a match. */ try { signingCerts = securityServices.getKeyAndCertStore().getCertificates(certSelector); } catch (CertStoreException e) { logger.error("Error getting certificates from the CertStore.", e); } } X509Certificate signingCertificate = null; if (signingCerts != null && signingCerts.size() > 0) { /* * there can be more than one match, although in practice this should not happen * often. Get the first one. If the sender is so stupid to send different * certificates with same issuer/serial, subjectKeyId (which is not likely) than * he/she cannot expect the signature to validate correctly. If the sender did * not add a certificate to the CMS blob but the certificate was found in the * CertStore it can happen that the wrong certificate was found. Solving this * requires that we step through all certificates found an verify until we found * the correct one. */ signingCertificate = signingCerts.iterator().next(); } if (signingCertificate != null) { if (!verifySignature(message, signerIndex, signer, signingCertificate, level)) { thisSignatureValid = false; } /* * we expect that the certificates from the CMS blob were already added to the stores * if the certificate is not in the store the path cannot be build. It is possible to * add them temporarily to the CertPathBuilder but that's not always as fast as adding * them to the global CertStore. */ if (!verifySigningCertificate(message, signerIndex, signingCertificate, certificates, level)) { thisSignatureValid = false; } if (thisSignatureValid == null) { thisSignatureValid = true; } try { signerEmail.addAll(new X509CertificateInspector(signingCertificate).getEmail()); } catch (Exception e) { logger.error("Error getting email addresses", e); } } else { String info = "Signing certificate could not be found."; logger.warn(info); setHeader(SMIMESecurityInfoHeader.SIGNER_VERIFIED + signerIndex, "False", level, message); setHeader(SMIMESecurityInfoHeader.SIGNER_VERIFICATION_INFO + signerIndex, info, level, message); } } finally { /* * Only make the overall signatureValid true if it was not already set and if the current * signature check is valid */ if (BooleanUtils.isTrue(thisSignatureValid) && signatureValid == null) { signatureValid = true; } if (BooleanUtils.isFalse(thisSignatureValid)) { signatureValid = false; } } } /* end for */ onSigned(message, sMIMEInspector, level, BooleanUtils.isTrue(signatureValid), signerEmail); return message; }
From source file:com.haulmont.cuba.gui.components.listeditor.ListEditorPopupWindow.java
protected void addValueToLayout(final Object value, String str) { final BoxLayout itemLayout = componentsFactory.createComponent(HBoxLayout.class); itemLayout.setSpacing(true);/*from w ww . j a v a 2s . co m*/ Label itemLab = componentsFactory.createComponent(Label.class); if (optionsMap != null) { str = optionsMap.entrySet().stream().filter(entry -> Objects.equals(entry.getValue(), value)) .findFirst().get().getKey(); } itemLab.setValue(str); itemLayout.add(itemLab); itemLab.setAlignment(Alignment.MIDDLE_LEFT); LinkButton delItemBtn = componentsFactory.createComponent(LinkButton.class); delItemBtn.setIcon("icons/item-remove.png"); delItemBtn.setAction(new AbstractAction("") { @Override public void actionPerform(Component component) { valuesMap.remove(value); valuesLayout.remove(itemLayout); } }); itemLayout.add(delItemBtn); if (BooleanUtils.isFalse(editable)) { delItemBtn.setEnabled(false); } valuesLayout.add(itemLayout); valuesMap.put(value, str); }
From source file:jp.primecloud.auto.process.lb.PuppetLoadBalancerProcess.java
protected Map<String, Object> createInstanceMap(Long instanceNo) { Map<String, Object> map = new HashMap<String, Object>(); // Instance/*from www . ja v a2 s . c o m*/ Instance instance = instanceDao.read(instanceNo); map.put("instance", instance); // IP List<Instance> allInstances = instanceDao.readByFarmNo(instance.getFarmNo()); Platform platform = platformDao.read(instance.getPlatformNo()); Map<String, String> accessIps = new HashMap<String, String>(); for (Instance instance2 : allInstances) { // ?????? InstanceStatus status = InstanceStatus.fromStatus(instance2.getStatus()); if (status != InstanceStatus.RUNNING) { continue; } // ?publicIp?? String accessIp = instance2.getPublicIp(); if (instance.getPlatformNo().equals(instance2.getPlatformNo())) { // ???? // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { PlatformAws platformAws = platformAwsDao.read(instance2.getPlatformNo()); if (BooleanUtils.isFalse(platformAws.getVpc())) { // VPC?????privateIp?? accessIp = instance2.getPrivateIp(); } } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { // CloudStack???getPublicIp?? accessIp = instance2.getPublicIp(); } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { // VMware???privateIp?? accessIp = instance2.getPrivateIp(); //nifty } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) { // ???privateIp?? accessIp = instance2.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { // VCloud???privateIp?? accessIp = instance2.getPrivateIp(); } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // Azure???getPublicIp?? accessIp = instance2.getPublicIp(); } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { // Openstack???getPublicIp?? accessIp = instance2.getPublicIp(); } } accessIps.put(instance2.getInstanceNo().toString(), accessIp); } map.put("accessIps", accessIps); // ???IP List<String> listenIps = new ArrayList<String>(); // TODO CLOUD BRANCHING if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) { // AWS?? listenIps.add(instance.getPrivateIp()); PlatformAws platformAws = platformAwsDao.read(instance.getPlatformNo()); if (BooleanUtils.isFalse(platform.getInternal()) && BooleanUtils.isFalse(platformAws.getVpc())) { // ?AWS?VPN??(VPC+VPN?????VPN??)?PublicIp???? listenIps.add(instance.getPublicIp()); } } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) { // CloudStack?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) { // VMware?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platform.getPlatformType())) { // Nifty?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) { // VCloud?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) { // Azure?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) { // Openstack?? listenIps.add(instance.getPublicIp()); listenIps.add(instance.getPrivateIp()); } map.put("listenIps", listenIps); return map; }