List of usage examples for org.apache.commons.lang3 BooleanUtils isNotFalse
public static boolean isNotFalse(final Boolean bool)
Checks if a Boolean value is not false , handling null by returning true .
BooleanUtils.isNotFalse(Boolean.TRUE) = true BooleanUtils.isNotFalse(Boolean.FALSE) = false BooleanUtils.isNotFalse(null) = true
From source file:com.joyent.manta.config.AuthAwareConfigContext.java
/** * Internal method for updating authentication parameters and derived objects. * * @param paramsFingerprint identifier for the new AuthContext * @return the new {@link AuthContext}//from w w w . ja va2 s . com */ private AuthContext doLoad(final int paramsFingerprint) { if (BooleanUtils.isNotFalse(noAuth())) { return null; } final KeyPair keyPair = new KeyPairFactory(this).createKeyPair(); final Signer.Builder builder = new Signer.Builder(keyPair); if (BooleanUtils.isTrue(disableNativeSignatures())) { // DefaultConfigContext#DEFAULT_DISABLE_NATIVE_SIGNATURES is false builder.providerCode("stdlib"); } final ThreadLocalSigner signer = new ThreadLocalSigner(builder); return new AuthContext(paramsFingerprint, keyPair, signer, new UsernamePasswordCredentials(getMantaUser(), null), new HttpSignatureAuthScheme(keyPair, signer)); }
From source file:com.epam.ta.reportportal.core.project.impl.UpdateProjectHandler.java
@Override public OperationCompletionRS updateProjectEmailConfig(String projectName, String user, UpdateProjectEmailRQ updateProjectEmailRQ) { Project project = projectRepository.findOne(projectName); Project beforeUpdate = SerializationUtils.clone(project); expect(project, notNull()).verify(PROJECT_NOT_FOUND, projectName); if (null != updateProjectEmailRQ.getConfiguration()) { ProjectEmailConfig config = updateProjectEmailRQ.getConfiguration(); if (null != config.getFrom()) { expect(isEmailValid(config.getFrom()), equalTo(true)).verify(BAD_REQUEST_ERROR, formattedSupplier("Provided FROM value '{}' is invalid", config.getFrom())); project.getConfiguration().getEmailConfig().setFrom(config.getFrom()); }/*from ww w . java 2s . c o m*/ List<EmailSenderCase> cases = config.getEmailCases(); if (BooleanUtils.isNotFalse(config.getEmailEnabled())) { expect(cases, Preconditions.NOT_EMPTY_COLLECTION).verify(BAD_REQUEST_ERROR, "At least one rule should be present."); cases.forEach(sendCase -> { expect(findByName(sendCase.getSendCase()).isPresent(), equalTo(true)).verify(BAD_REQUEST_ERROR, sendCase.getSendCase()); expect(sendCase.getRecipients(), notNull()).verify(BAD_REQUEST_ERROR, "Recipients list should not be null"); expect(sendCase.getRecipients().isEmpty(), equalTo(false)).verify(BAD_REQUEST_ERROR, formattedSupplier("Empty recipients list for email case '{}' ", sendCase)); sendCase.setRecipients(sendCase.getRecipients().stream().map(it -> { validateRecipient(project, it); return it.trim(); }).distinct().collect(toList())); if (null != sendCase.getLaunchNames()) { sendCase.setLaunchNames(sendCase.getLaunchNames().stream().map(name -> { validateLaunchName(name); return name.trim(); }).distinct().collect(toList())); } if (null != sendCase.getTags()) { sendCase.setTags(sendCase.getTags().stream().map(tag -> { expect(isNullOrEmpty(tag), equalTo(false)).verify(BAD_REQUEST_ERROR, "Tags values cannot be empty. Please specify it or not include in request."); return tag.trim(); }).distinct().collect(toList())); } }); /* If project email settings */ List<EmailSenderCase> withoutDuplicateCases = cases.stream().distinct().collect(toList()); if (cases.size() != withoutDuplicateCases.size()) fail().withError(BAD_REQUEST_ERROR, "Project email settings contain duplicate cases"); project.getConfiguration().getEmailConfig().setEmailCases(cases); } /* If enable parameter is FALSE, previous settings be dropped */ if (!config.getEmailEnabled()) setDefaultEmailCofiguration(project); else project.getConfiguration().getEmailConfig().setEmailEnabled(true); } else { /* Something wrong with input RQ but we don't care about */ } try { projectRepository.save(project); } catch (Exception e) { throw new ReportPortalException("Error during updating Project", e); } publisher.publishEvent(new EmailConfigUpdatedEvent(beforeUpdate, updateProjectEmailRQ, user)); return new OperationCompletionRS( "EMail configuration of project with name = '" + projectName + "' is successfully updated."); }
From source file:org.finra.herd.dao.impl.S3DaoImpl.java
@Override public void validateGlacierS3FilesRestored(S3FileTransferRequestParamsDto params) throws RuntimeException { LOGGER.info(//ww w .j a v a 2 s . com "Checking for already restored Glacier storage class objects... s3KeyPrefix=\"{}\" s3BucketName=\"{}\" s3KeyCount={}", params.getS3KeyPrefix(), params.getS3BucketName(), params.getFiles().size()); if (!CollectionUtils.isEmpty(params.getFiles())) { // Initialize a key value pair for the error message in the catch block. String key = params.getFiles().get(0).getPath().replaceAll("\\\\", "/"); try { // Create an S3 client. AmazonS3Client s3Client = getAmazonS3(params); try { for (File file : params.getFiles()) { key = file.getPath().replaceAll("\\\\", "/"); ObjectMetadata objectMetadata = s3Operations.getObjectMetadata(params.getS3BucketName(), key, s3Client); // Fail if a not already restored object is detected. if (BooleanUtils.isNotFalse(objectMetadata.getOngoingRestore())) { throw new IllegalArgumentException(String.format( "Archived Glacier S3 file \"%s\" is not restored. StorageClass {%s}, OngoingRestore flag {%s}, S3 bucket name {%s}", key, objectMetadata.getStorageClass(), objectMetadata.getOngoingRestore(), params.getS3BucketName())); } } } finally { s3Client.shutdown(); } } catch (AmazonServiceException e) { throw new IllegalStateException( String.format("Fail to check restore status for \"%s\" key in \"%s\" bucket. Reason: %s", key, params.getS3BucketName(), e.getMessage()), e); } } }
From source file:org.libreplan.business.common.Configuration.java
public static boolean isExampleUsersDisabled() { return BooleanUtils.isNotFalse(singleton.getExampleUsersDisabled()); }
From source file:org.libreplan.business.common.Configuration.java
public static boolean isEmailSendingEnabled() { return BooleanUtils.isNotFalse(singleton.getEmailSendingEnabled()); }
From source file:org.opendaylight.controller.sal.rest.doc.impl.ModelGenerator.java
private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models, final Boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException { if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) { Preconditions.checkArgument(dataNode instanceof SchemaNode, "Data node should be also schema node"); Iterable<DataSchemaNode> containerChildren = dataNode.getChildNodes(); JSONObject properties = processChildren(containerChildren, ((SchemaNode) dataNode).getQName(), moduleName, models, isConfig, schemaContext); String nodeName = (BooleanUtils.isNotFalse(isConfig) ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL) + ((SchemaNode) dataNode).getQName().getLocalName(); JSONObject childSchema = getSchemaTemplate(); childSchema.put(TYPE_KEY, OBJECT_TYPE); childSchema.put(PROPERTIES_KEY, properties); childSchema.put("id", nodeName); models.put(nodeName, childSchema); if (BooleanUtils.isNotFalse(isConfig)) { createConcreteModelForPost(models, ((SchemaNode) dataNode).getQName().getLocalName(), createPropertiesForPost(dataNode)); }/*from w ww .j a v a2 s .c o m*/ JSONObject items = new JSONObject(); items.put(REF_KEY, nodeName); JSONObject dataNodeProperties = new JSONObject(); dataNodeProperties.put(TYPE_KEY, dataNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE); dataNodeProperties.put(ITEMS_KEY, items); return dataNodeProperties; } return null; }
From source file:org.sigmah.server.handler.util.ProjectMapper.java
/** * <p>//from w w w .ja v a2 s. c o m * Map a project into a project light DTO. * </p> * <p> * Populates the following fields of the returned {@link ProjectDTO} instance: * <ul> * <li>{@link EntityDTO#ID}</li> * <li>{@link ProjectDTO#NAME}</li> * <li>{@link ProjectDTO#FULL_NAME}</li> * <li>{@link ProjectDTO#START_DATE}</li> * <li>{@link ProjectDTO#END_DATE}</li> * <li>{@link ProjectDTO#CLOSE_DATE}</li> * <li>{@link ProjectDTO#ACTIVITY_ADVANCEMENT}</li> * <li>{@link ProjectDTO#COUNTRY}</li> * <li>{@link ProjectDTO#CURRENT_PHASE_NAME}</li> * <li>{@link ProjectDTO#VISIBILITIES}</li> * <li>{@link ProjectDTO#ORG_UNIT_NAME}</li> * <li>{@link ProjectDTO#CATEGORY_ELEMENTS}</li> * <li>{@link ProjectDTO#RATIO_DIVIDEND_LABEL}</li> * <li>{@link ProjectDTO#RATIO_DIVIDEND_TYPE}</li> * <li>{@link ProjectDTO#RATIO_DIVIDEND_VALUE}</li> * <li>{@link ProjectDTO#RATIO_DIVISOR_LABEL}</li> * <li>{@link ProjectDTO#RATIO_DIVISOR_TYPE}</li> * <li>{@link ProjectDTO#RATIO_DIVISOR_VALUE}</li> * <li>{@link ProjectDTO#PLANNED_BUDGET}</li> * <li>{@link ProjectDTO#RECEIVED_BUDGET}</li> * <li>{@link ProjectDTO#SPEND_BUDGET}</li> * <li>{@link ProjectDTO#CHILDREN_PROJECTS}</li> * <li>{@link ProjectDTO#FAVORITE_USERS}</li> * </ul> * </p> * * @param project * The project. * @param mapChildren * If the children projects must be retrieved. * @return The light DTO. */ public ProjectDTO map(final Project project, final boolean mapChildren) { final StringBuilder sb = new StringBuilder(); sb.append("Project mapping:\n"); final ProjectDTO projectDTO = new ProjectDTO(); // --------------- // -- SIMPLE FIELDS // --------------- long start = new Date().getTime(); projectDTO.setId(project.getId()); projectDTO.setName(project.getName()); projectDTO.setFullName(project.getFullName()); projectDTO.setStartDate(project.getStartDate()); projectDTO.setEndDate(project.getEndDate()); projectDTO.setCloseDate(project.getCloseDate()); projectDTO.setActivityAdvancement(project.getActivityAdvancement()); projectDTO.setCountry(mapper.map(project.getCountry(), new CountryDTO())); sb.append("- SIMPLE FIELDS: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); // --------------- // -- CURRENT PHASE // --------------- start = new Date().getTime(); final Phase currentPhase = project.getCurrentPhase(); if (currentPhase != null) { projectDTO.setCurrentPhaseName(currentPhase.getPhaseModel().getName()); } sb.append("- CURRENT PHASE: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); // --------------- // -- VISIBILITIES // --------------- start = new Date().getTime(); final ArrayList<ProjectModelVisibilityDTO> visibilities = new ArrayList<ProjectModelVisibilityDTO>(); for (final ProjectModelVisibility v : project.getProjectModel().getVisibilities()) { final ProjectModelVisibilityDTO vDTO = new ProjectModelVisibilityDTO(); vDTO.setId(v.getId()); vDTO.setType(v.getType()); vDTO.setOrganizationId(v.getOrganization().getId()); visibilities.add(vDTO); } projectDTO.setVisibilities(visibilities); sb.append("- VISIBILITIES: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); // --------------- // -- ORG UNIT // --------------- start = new Date().getTime(); // Fill the org unit. final TypedQuery<OrgUnit> orgUnitQuery = em() .createQuery("SELECT o FROM OrgUnit o WHERE :project MEMBER OF o.databases", OrgUnit.class); orgUnitQuery.setParameter("project", project); for (final OrgUnit orgUnit : orgUnitQuery.getResultList()) { projectDTO.setOrgUnitName(orgUnit.getName() + " - " + orgUnit.getFullName()); break; } sb.append("- ORG UNIT: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); // --------------- // -- CATEGORIES // --------------- start = new Date().getTime(); final TypedQuery<Value> categoriesQuery = em().createQuery( "SELECT v FROM Value v JOIN v.element e WHERE v.containerId = :projectId AND " + "e.id IN (SELECT q.id FROM QuestionElement q WHERE q.categoryType IS NOT NULL)", Value.class); categoriesQuery.setParameter("projectId", project.getId()); final HashSet<CategoryElementDTO> elements = new HashSet<CategoryElementDTO>(); for (final Value value : categoriesQuery.getResultList()) { List<Integer> values = ValueResultUtils.splitValuesAsInteger(value.getValue()); if (!values.isEmpty()) { final TypedQuery<QuestionChoiceElement> choicesQuery = em().createQuery( "SELECT c FROM QuestionChoiceElement c WHERE c.id IN (:ids)", QuestionChoiceElement.class); choicesQuery.setParameter("ids", ValueResultUtils.splitValuesAsInteger(value.getValue())); for (final QuestionChoiceElement choice : choicesQuery.getResultList()) { final CategoryType parent = choice.getCategoryElement().getParentType(); final CategoryTypeDTO parentDTO = new CategoryTypeDTO(); parentDTO.setId(parent.getId()); parentDTO.setLabel(parent.getLabel()); parentDTO.setIcon(parent.getIcon()); final CategoryElement element = choice.getCategoryElement(); final CategoryElementDTO elementDTO = new CategoryElementDTO(); elementDTO.setId(element.getId()); elementDTO.setLabel(element.getLabel()); elementDTO.setColor(element.getColor()); elementDTO.setParentCategoryDTO(parentDTO); elements.add(elementDTO); } } } projectDTO.setCategoryElements(elements); fillBudget(project, projectDTO); sb.append("- CATEGORIES: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); // --------------- // -- CHILDREN // --------------- start = new Date().getTime(); final ArrayList<ProjectDTO> children = new ArrayList<ProjectDTO>(); // Maps the funding projects. if (mapChildren && project.getFunding() != null) { for (final ProjectFunding funding : project.getFunding()) { final Project pFunding = funding.getFunding(); if (pFunding != null) { // Recursive call to retrieve the child (without its children). children.add(map(pFunding, false)); } } } // Maps the funded projects. if (mapChildren && project.getFunded() != null) { for (final ProjectFunding funded : project.getFunded()) { final Project pFunded = funded.getFunded(); if (pFunded != null) { // Recursive call to retrieve the child (without its children). children.add(map(pFunded, false)); } } } projectDTO.setChildrenProjects(children); // ------------------ // -- FAVORITE USERS // ------------------ if (project.getFavoriteUsers() != null) { final Set<UserDTO> favoriteUsesSet = new HashSet<UserDTO>(); for (final User u : project.getFavoriteUsers()) { // favoriteUsesSet.add(dozermapper.map(u, new UserDTO())); UserDTO uDTO = new UserDTO(); uDTO.setId(u.getId()); uDTO.setChangePasswordKey(u.getChangePasswordKey()); uDTO.setDateChangePasswordKeyIssued(u.getDateChangePasswordKeyIssued()); uDTO.setEmail(u.getEmail()); uDTO.setFirstName(u.getFirstName()); uDTO.setLocale(u.getLocale()); uDTO.setActive(BooleanUtils.isNotFalse(u.getActive())); favoriteUsesSet.add(uDTO); } projectDTO.setFavoriteUsers(favoriteUsesSet); } else { projectDTO.setFavoriteUsers(null); } // ---END---- sb.append("- CHILDREN: "); sb.append(new Date().getTime() - start); sb.append("ms.\n"); if (LOG.isDebugEnabled()) { LOG.debug(sb.toString()); } return projectDTO; }
From source file:yoyo.framework.standard.shared.commons.lang.BooleanUtilsTest.java
@Test public void test() { assertThat(BooleanUtils.and(new boolean[] { true }), is(true)); assertThat(BooleanUtils.and(new boolean[] { true, false }), is(false)); assertThat(BooleanUtils.isFalse(false), is(true)); assertThat(BooleanUtils.isNotFalse(false), is(false)); assertThat(BooleanUtils.isNotTrue(true), is(false)); assertThat(BooleanUtils.isTrue(true), is(true)); assertThat(BooleanUtils.negate(Boolean.FALSE), is(true)); assertThat(BooleanUtils.or(new boolean[] { true }), is(true)); assertThat(BooleanUtils.or(new boolean[] { true, false }), is(true)); assertThat(BooleanUtils.toBoolean(Boolean.TRUE), is(true)); assertThat(BooleanUtils.toBoolean(0), is(false)); assertThat(BooleanUtils.toBoolean(1), is(true)); assertThat(BooleanUtils.toBoolean((String) null), is(false)); assertThat(BooleanUtils.toBoolean("true"), is(true)); assertThat(BooleanUtils.toBoolean("hoge"), is(false)); assertThat(BooleanUtils.toBooleanDefaultIfNull(null, false), is(false)); assertThat(BooleanUtils.toBooleanObject(0), is(Boolean.FALSE)); assertThat(BooleanUtils.toBooleanObject(1), is(Boolean.TRUE)); assertThat(BooleanUtils.toInteger(true), is(1)); assertThat(BooleanUtils.toInteger(false), is(0)); assertThat(BooleanUtils.toIntegerObject(true), is(Integer.valueOf(1))); assertThat(BooleanUtils.toIntegerObject(false), is(Integer.valueOf(0))); assertThat(BooleanUtils.toString(true, "true", "false"), is("true")); assertThat(BooleanUtils.toString(false, "true", "false"), is("false")); assertThat(BooleanUtils.toStringOnOff(true), is("on")); assertThat(BooleanUtils.toStringOnOff(false), is("off")); assertThat(BooleanUtils.toStringTrueFalse(true), is("true")); assertThat(BooleanUtils.toStringTrueFalse(false), is("false")); assertThat(BooleanUtils.toStringYesNo(true), is("yes")); assertThat(BooleanUtils.toStringYesNo(false), is("no")); assertThat(BooleanUtils.xor(new boolean[] { true }), is(true)); assertThat(BooleanUtils.xor(new boolean[] { true, false }), is(true)); assertThat(BooleanUtils.xor(new boolean[] { true, true }), is(false)); }