Java Code Examples for org.apache.commons.lang3.StringUtils#equals()

The following examples show how to use org.apache.commons.lang3.StringUtils#equals() . These examples are extracted from open source projects. 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
private static List<ConfigGroupEnum> compareMD5(final HttpServletRequest request) {
    List<ConfigGroupEnum> changedGroup = new ArrayList<>(4);
    for (ConfigGroupEnum group : ConfigGroupEnum.values()) {
        // md5,lastModifyTime
        String[] params = StringUtils.split(request.getParameter(group.name()), ',');
        if (params == null || params.length != 2) {
            throw new SoulException("group param invalid:" + request.getParameter(group.name()));
        }
        String clientMd5 = params[0];
        long clientModifyTime = NumberUtils.toLong(params[1]);
        ConfigDataCache serverCache = CACHE.get(group.name());
        if (!StringUtils.equals(clientMd5, serverCache.getMd5()) && clientModifyTime < serverCache.getLastModifyTime()) {
            changedGroup.add(group);
        }
    }
    return changedGroup;
}
 
Example 2
private boolean isJobComplete(ExecutableDao executableDao, ExecutablePO job) {
    String jobId = job.getUuid();
    boolean isComplete = false;
    try {
        ExecutableOutputPO output = executableDao.getJobOutput(jobId);
        String status = output.getStatus();
        String jobType = job.getType();
        if (jobType.equals(CubingJob.class.getName())
                || jobType.equals(CheckpointExecutable.class.getName())) {
            if (StringUtils.equals(status, ExecutableState.SUCCEED.toString())
                    || StringUtils.equals(status, ExecutableState.DISCARDED.toString())) {
                isComplete = true;
            }
        } else if (jobType.equals(CardinalityExecutable.class.getName())) {
            // Ignore state of DefaultChainedExecutable
            isComplete = true;
        }
    } catch (PersistentException e) {
        logger.error("Get job output failed for job uuid: {}", jobId, e);
        isComplete = true; // job output broken --> will be treat as complete
    }

    return isComplete;
}
 
Example 3
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
	Element element = cachePreviewImage.get(flag);
	ActionResult<Wo> result = new ActionResult<>();
	Wo wo = null;
	if (null != element && null != element.getObjectValue()) {
		PreviewImageResultObject obj = (PreviewImageResultObject) element.getObjectValue();
		if (!StringUtils.equals(effectivePerson.getDistinguishedName(), obj.getPerson())) {
			throw new ExceptionAccessDenied(effectivePerson);
		}
		wo = new Wo(obj.getBytes(), this.contentType(true, obj.getName()),
				this.contentDisposition(true, obj.getName()));
		result.setData(wo);
	} else {
		throw new ExceptionPreviewImageResultObject(flag);
	}
	result.setData(wo);
	return result;
}
 
Example 4
private void appendExistingColumnLog(ColumnMapping newMapping, ColumnMapping existingMapping, StringBuilder log) {
    String oldMappingValue = StringUtils.defaultIfEmpty(existingMapping.getDatabaseColumn(), NO_VALUE),
            newMappingValue = StringUtils.defaultIfEmpty(newMapping.getDatabaseColumn(), NO_VALUE),
            oldDefaultValue = StringUtils.defaultIfEmpty(existingMapping.getDefaultValue(), NO_VALUE),
            newDefaultValue = StringUtils.defaultIfEmpty(newMapping.getDefaultValue(), NO_VALUE);
    Boolean oldMandatorySlider = existingMapping.isMandatory();
    if (!StringUtils.equals(oldMappingValue, newMappingValue)) {
        log.append(", ").append(String.format("changed database mapping from \"%s\" to \"%s\"",
                oldMappingValue, newMappingValue));
    }
    if (oldMandatorySlider != newMapping.isMandatory()) {
        log.append(", ").append(String.format("mandatory set to %b", newMapping.isMandatory()));
    }
    if (!StringUtils.equals(oldDefaultValue, newDefaultValue)) {
        log.append(", ").append(String.format("default value changed from %s to %s", oldDefaultValue, newDefaultValue));
    }
}
 
Example 5
protected Long durationCompletedWork(Business business, DateRange dateRange, String applicationId, String processId,
		String unit, String person) throws Exception {
	EntityManager em = business.entityManagerContainer().get(WorkCompleted.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<Long> cq = cb.createQuery(Long.class);
	Root<WorkCompleted> root = cq.from(WorkCompleted.class);
	Predicate p = cb.between(root.get(WorkCompleted_.completedTime), dateRange.getStart(), dateRange.getEnd());
	if (!StringUtils.equals(applicationId, StandardJaxrsAction.EMPTY_SYMBOL)) {
		p = cb.and(p, cb.equal(root.get(WorkCompleted_.application), applicationId));
	}
	if (!StringUtils.equals(processId, StandardJaxrsAction.EMPTY_SYMBOL)) {
		p = cb.and(p, cb.equal(root.get(WorkCompleted_.process), processId));
	}
	if (!StringUtils.equals(unit, StandardJaxrsAction.EMPTY_SYMBOL)) {
		List<String> units = new ArrayList<>();
		units.add(unit);
		units.addAll(business.organization().unit().listWithUnitSubNested(unit));
		p = cb.and(p, root.get(WorkCompleted_.creatorUnit).in(units));
	}
	if (!StringUtils.equals(person, StandardJaxrsAction.EMPTY_SYMBOL)) {
		p = cb.and(p, cb.equal(root.get(WorkCompleted_.creatorPerson), person));
	}
	cq.select(cb.sum(root.get(WorkCompleted_.duration))).where(p);
	return em.createQuery(cq).getSingleResult();
}
 
Example 6
/**
 * 添加候选人
 */
@RequestMapping("task/candidate/add/{taskId}")
@ResponseBody
public String addCandidates(@PathVariable("taskId") String taskId, @RequestParam("userOrGroupIds[]") String[] userOrGroupIds,
                            @RequestParam("type[]") String[] types, HttpServletRequest request) {
    // 设置当前操作人,对于调用活动可以获取到当前操作人
    String currentUserId = UserUtil.getUserFromSession(request.getSession()).getId();
    identityService.setAuthenticatedUserId(currentUserId);

    for (int i = 0; i < userOrGroupIds.length; i++) {
        String type = types[i];
        if (StringUtils.equals("user", type)) {
            taskService.addCandidateUser(taskId, userOrGroupIds[i]);
        } else if (StringUtils.equals("group", type)) {
            taskService.addCandidateGroup(taskId, userOrGroupIds[i]);
        }
    }
    return "success";
}
 
Example 7
/**
 * Converts the given list of Strings to a list of Pattern objects
 *
 * @param regexps
 *            A list of regex pattern strings
 *
 * @exception IllegalArgumentException
 *            if one of the patterns has invalid regular expression
 *            syntax
 */
private List<Pattern> getRegExPatterns(List<String> regexps) {

    ArrayList<Pattern> patterns = new ArrayList<>();
    for (String regexp : regexps) {
        String regex = StringUtils.trimToNull(regexp);
        if (regex != null) {
            // if :empty: is in any of the then return an empty list
            if (StringUtils.equals(":empty:", regex)) return new ArrayList<>();

            try {
                patterns.add(Pattern.compile(regex, Pattern.CASE_INSENSITIVE));
            } catch (PatternSyntaxException e) {
                throw new IllegalArgumentException("Illegal Regular Expression Syntax: [" + regex + "] - " + e.getMessage());
            }
        }
    }
    return patterns;
}
 
Example 8
private PersonAttribute checkPersonAttribute(Business business, PullResult result, Person person, User user,
		String name, String value) throws Exception {
	EntityManagerContainer emc = business.entityManagerContainer();
	EntityManager em = emc.get(PersonAttribute.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<PersonAttribute> cq = cb.createQuery(PersonAttribute.class);
	Root<PersonAttribute> root = cq.from(PersonAttribute.class);
	Predicate p = cb.equal(root.get(PersonAttribute_.person), person.getId());
	p = cb.and(p, cb.equal(root.get(PersonAttribute_.name), name));
	List<PersonAttribute> os = em.createQuery(cq.select(root).where(p)).setMaxResults(1).getResultList();
	PersonAttribute personAttribute = null;
	if (os.size() == 0) {
		personAttribute = this.createPersonAttribute(business, result, person, name, value);
	} else {
		personAttribute = os.get(0);
		if (!StringUtils.equals(personAttribute.getAttributeList().get(0), value)) {
			personAttribute = this.updatePersonAttribute(business, result, personAttribute, name, value);
		}
	}
	return personAttribute;
}
 
Example 9
/**
 * 二次验证
 *
 * @param validate 验证码组件提交上来的NECaptchaValidate值
 * @param user     用户
 * @return
 */
public boolean verify(String validate, String user) {
    if (StringUtils.isEmpty(validate) || StringUtils.equals(validate, "null")) {
        return false;
    }
    user = (user == null) ? "" : user; // bugfix:如果user为null会出现签名错误的问题
    Map<String, String> params = new HashMap<String, String>();
    params.put("captchaId", captchaId);
    params.put("validate", validate);
    params.put("user", user);
    // 公共参数
    params.put("secretId", secretPair.secretId);
    params.put("version", VERSION);
    params.put("timestamp", String.valueOf(System.currentTimeMillis()));
    params.put("nonce", String.valueOf(ThreadLocalRandom.current().nextInt()));
    // 计算请求参数签名信息
    String signature = sign(secretPair.secretKey, params);
    params.put("signature", signature);

    String resp = HttpClient4Utils.sendPost(VERIFY_API, params);
    System.out.println("resp = " + resp);
    return verifyRet(resp);
}
 
Example 10
Source Project: Thunder   File: MQEntity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object object) {
    if (!(object instanceof MQEntity)) {
        return false;
    }

    MQEntity mqEntity = (MQEntity) object;
    if (StringUtils.equals(this.queueId, mqEntity.queueId)
            && StringUtils.equals(this.topicId, mqEntity.topicId)
            && StringUtils.equals(this.jndiInitialContextFactoryId, mqEntity.jndiInitialContextFactoryId)
            && StringUtils.equals(this.initialConnectionFactoryId, mqEntity.initialConnectionFactoryId)
            && StringUtils.equals(this.pooledConnectionFactoryId, mqEntity.pooledConnectionFactoryId)
            && this.propertiesMap.equals(mqEntity.propertiesMap)) {
        return true;
    }

    return false;
}
 
Example 11
Source Project: BACnet4J   File: MstpNode.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void readInputStream() {
    try {
        if (in.available() > 0) {
            readCount = in.read(readArray);
            if (DEBUG)
                debug("in: " + StreamUtils.dumpArrayHex(readArray, 0, readCount));
            inputBuffer.push(readArray, 0, readCount);
            eventCount += readCount;
            noise();
        }
    }
    catch (IOException e) {
        if (StringUtils.equals(e.getMessage(), "Stream closed."))
            throw new RuntimeException(e);
        if (LOG.isLoggable(Level.FINE))
            LOG.log(Level.FINE, "Input stream listener exception", e);
        receiveError = true;
    }
}
 
Example 12
/**
 * @param file Default encryption setting for file
 * @return Return custom key for AWS-KMS if set for bucket in preferences. Otherwise default SSE algorithm.
 */
@Override
public Algorithm getDefault(final Path file) {
    final String key = String.format("s3.encryption.key.%s", containerService.getContainer(file).getName());
    if(StringUtils.isNotBlank(preferences.getProperty(key))) {
        return Algorithm.fromString(preferences.getProperty(key));
    }
    // Return default setting in preferences
    final String setting = preferences.getProperty("s3.encryption.algorithm");
    if(StringUtils.equals(SSE_AES256.algorithm, setting)) {
        return SSE_AES256;
    }
    return Algorithm.NONE;
}
 
Example 13
Source Project: FoxBPM   File: DataVariableMgmtInstance.java    License: Apache License 2.0 5 votes vote down vote up
public VariableInstanceEntity getDataVariableByExpressionId(String expressionId) {
	for (VariableInstanceEntity dataVariableInstance : variableInstanceEntities) {
		if (StringUtils.equals(dataVariableInstance.getKey(), expressionId)) {
			return dataVariableInstance;
		}
	}
	return null;
}
 
Example 14
private ClassInfo scanModuleClassInfo(String name) throws Exception {
	try (ScanResult scanResult = new ClassGraph().enableAnnotationInfo().scan()) {
		List<ClassInfo> classInfos = scanResult.getClassesWithAnnotation(Module.class.getName());
		for (ClassInfo info : classInfos) {
			Class<?> clz = Class.forName(info.getName());
			if (StringUtils.equals(clz.getSimpleName(), name)) {
				return info;
			}
		}
		return null;
	}
}
 
Example 15
Source Project: DBus   File: MonitorSpoutDataProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean isBelong(String str) {
    if (StringUtils.isBlank(str))
        return false;
    String[] vals = StringUtils.split(str, ".");
    return StringUtils.equals("data_increment_heartbeat", vals[0]);
}
 
Example 16
/**
 * Validate the properties that have been set from this HTTP request, and
 * return an <code>ActionMessages</code> object that encapsulates any
 * validation errors that have been found. If no errors are found, return
 * <code>null</code> or an <code>ActionMessages</code> object with no
 * recorded error messages.
 * 
 * @param mapping
 *            The mapping used to select this instance
 * @param request
 *            The servlet request we are processing
 * @return errors
 */
@Override
public ActionErrors formSpecificValidate(ActionMapping mapping, HttpServletRequest request) {
	ActionErrors actionErrors = new ActionErrors();
	boolean doNotDelete = request.getParameter("delete") == null || request.getParameter("delete").isEmpty();
	if (doNotDelete && "save".equals(action)) {
		if (username == null || username.length() < 3) {
			actionErrors.add("username", new ActionMessage("error.username.tooShort"));
		} else if(username.length() > 180) {
			actionErrors.add("username", new ActionMessage("error.username.tooLong"));
		}

		if (!StringUtils.equals(password, passwordConfirm)) {
			actionErrors.add("password", new ActionMessage("error.password.mismatch"));
		}

		if (StringUtils.isBlank(fullname) || fullname.length() < 2) {
			actionErrors.add("fullname", new ActionMessage("error.name.too.short"));
		} else if (fullname.length() > 100) {
			actionErrors.add("fullname", new ActionMessage("error.username.tooLong"));
		}

		if (StringUtils.isBlank(firstname) || firstname.length() < 2) {
			actionErrors.add("firstname", new ActionMessage("error.name.too.short"));
		} else if (firstname.length() > 100) {
			actionErrors.add("firstname", new ActionMessage("error.username.tooLong"));
		}

		if (StringUtils.isBlank(companyName) || companyName.length() < 2) {
			actionErrors.add("companyName", new ActionMessage("error.company.tooShort"));
		} else if (companyName.length() > 100) {
			actionErrors.add("companyName", new ActionMessage("error.company.tooLong"));
		}

		if (GenericValidator.isBlankOrNull(this.email) || !AgnitasEmailValidator.getInstance().isValid(email)) {
			actionErrors.add("mailForReport", new ActionMessage("error.invalid.email"));
		}
	}
	return actionErrors;
}
 
Example 17
Source Project: para   File: Vote.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @return true if vote is negative
 */
public boolean isDownvote() {
	return StringUtils.equals(this.value, DOWN.toString());
}
 
Example 18
@AssertTrue(message = "Confirm email must be the same as your email.")
public boolean isEmailValid() {
	return StringUtils.equals(getUser().getEmail(), getConfirmEmail());
}
 
Example 19
private boolean isFilteredSearch() {
     return !StringUtils.equals(searchString, defaultSearchString);
}
 
Example 20
private boolean isAuthenticated(final AuthenticationCookie cookie) {
  for (final CredentialsAuthenticator authenticator : authenticators) {
    if (StringUtils.equals(cookie.getAuthenticatorId(), authenticator.getId())) return true;
  }
  return false;
}