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

The following examples show how to use org.apache.commons.lang3.StringUtils#isNotEmpty() . 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
@Override
public void referenceChanged(ReferenceEvent<String> e)
{
	if (e.getSource() == nameRef)
	{
		if (StringUtils.isEmpty(tabNameRef.get()))
		{
			titleLabel.setText(e.getNewReference());
		}
	}
	else
	{
		if (StringUtils.isNotEmpty(e.getNewReference()))
		{
			titleLabel.setText(e.getNewReference());
		}
		else
		{
			titleLabel.setText(nameRef.get());
		}
	}
}
 
Example 2
protected void createItemDefinitions(BpmnModel bpmnModel) {

        for (org.flowable.bpmn.model.ItemDefinition itemDefinitionElement : bpmnModel.getItemDefinitions().values()) {

            if (!itemDefinitionMap.containsKey(itemDefinitionElement.getId())) {
                StructureDefinition structure = null;

                try {
                    // it is a class
                    Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
                    structure = new ClassStructureDefinition(classStructure);
                } catch (FlowableException e) {
                    // it is a reference to a different structure
                    structure = structureDefinitionMap.get(itemDefinitionElement.getStructureRef());
                }

                ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
                if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
                    itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
                }

                itemDefinitionMap.put(itemDefinition.getId(), itemDefinition);
            }
        }
    }
 
Example 3
private void ifTaskIdentitiesEmptyForceToCreatorOrMaintenance(AeiObjects aeiObjects, Manual manual,
		TaskIdentities taskIdentities) throws Exception {
	if (taskIdentities.isEmpty()) {
		String identity = aeiObjects.business().organization().identity()
				.get(aeiObjects.getWork().getCreatorIdentity());
		if (StringUtils.isNotEmpty(identity)) {
			logger.info("{}[{}]未能找到指定的处理人, 标题:{}, id:{}, 强制指定处理人为活动的创建身份:{}.", aeiObjects.getProcess().getName(),
					manual.getName(), aeiObjects.getWork().getTitle(), aeiObjects.getWork().getId(), identity);
			taskIdentities.addIdentity(identity);
		} else {
			identity = aeiObjects.business().organization().identity()
					.get(Config.processPlatform().getMaintenanceIdentity());
			if (StringUtils.isNotEmpty(identity)) {
				logger.info("{}[{}]未能找到指定的处理人, 也没有能找到工作创建人, 标题:{}, id:{},  强制指定处理人为系统维护身份:{}.",
						aeiObjects.getProcess().getName(), manual.getName(), aeiObjects.getWork().getTitle(),
						aeiObjects.getWork().getId(), identity);
				taskIdentities.addIdentity(identity);
			} else {
				throw new ExceptionExpectedEmpty(aeiObjects.getWork().getTitle(), aeiObjects.getWork().getId(),
						aeiObjects.getActivity().getName(), aeiObjects.getActivity().getId());
			}
		}
	}
}
 
Example 4
Source Project: red5-io   File: XMLUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Converts string representation of XML into Document
 * 
 * @param str
 *            String representation of XML
 * @return DOM object
 * @throws IOException
 *             I/O exception
 */
public static Document stringToDoc(String str) throws IOException {
    if (StringUtils.isNotEmpty(str)) {
        try (Reader reader = new StringReader(str)) {
            DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = db.parse(new InputSource(reader));

            return doc;
        } catch (Exception ex) {
            log.debug("String: {}", str);
            throw new IOException(String.format("Error converting from string to doc %s", ex.getMessage()));
        }
    } else {
        throw new IOException("Error - could not convert empty string to doc");
    }
}
 
Example 5
@RequestMapping(value = "/{groupId}/users", method = RequestMethod.GET)
public ResultListDataRepresentation getGroupUsers(@PathVariable String groupId, @RequestParam(required = false) String filter, @RequestParam(required = false) Integer page,
    @RequestParam(required = false) Integer pageSize) {
  validateAdminRole();
  int pageValue = page != null ? page.intValue() : 0;
  int pageSizeValue = pageSize != null ? pageSize.intValue() : 50;
  
  UserQuery userQuery = identityService.createUserQuery().memberOfGroup(groupId);
  if (StringUtils.isNotEmpty(filter)) {
    userQuery.userFullNameLike("%" + filter + "%");
  }
  List<User> users = userQuery.listPage(pageValue, pageSizeValue);
  
  List<UserRepresentation> userRepresentations = new ArrayList<UserRepresentation>(users.size());
  for (User user : users) {
    userRepresentations.add(new UserRepresentation(user));
  }

  ResultListDataRepresentation resultListDataRepresentation = new ResultListDataRepresentation(userRepresentations);
  resultListDataRepresentation.setStart(pageValue * pageSizeValue);
  resultListDataRepresentation.setSize(userRepresentations.size());
  resultListDataRepresentation.setTotal(userQuery.count());
  return resultListDataRepresentation;
}
 
Example 6
private FileInfo concreteAttachment(StorageMapping mapping, Document document, String name, EffectivePerson effectivePerson, String site) throws Exception {
	FileInfo attachment = new FileInfo();
	String fileName = UUID.randomUUID().toString();
	String extension = FilenameUtils.getExtension( name );
	if ( StringUtils.isNotEmpty(extension)) {
		fileName = fileName + "." + extension;
	}else{
		throw new Exception("file extension is empty.");
	}
	if( name.indexOf( "\\" ) >0 ){
		name = StringUtils.substringAfterLast( name, "\\");
	}
	if( name.indexOf( "/" ) >0 ){
		name = StringUtils.substringAfterLast( name, "/");
	}
	attachment.setCreateTime( new Date() );
	attachment.setLastUpdateTime( new Date() );
	attachment.setExtension( extension );
	attachment.setName( name );
	attachment.setFileName( fileName );
	attachment.setStorage( mapping.getName() );
	attachment.setAppId( document.getAppId() );
	attachment.setCategoryId( document.getCategoryId() );
	attachment.setDocumentId( document.getId() );
	attachment.setCreatorUid( effectivePerson.getDistinguishedName() );
	attachment.setSite( site );
	attachment.setFileHost( "" );
	attachment.setFileType("ATTACHMENT");
	attachment.setFileExtType( getExtType( extension ) );
	attachment.setFilePath( "" );
	return attachment;
}
 
Example 7
Source Project: wind-im   File: SiteConfig.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 判断是否为普通管理员
 * 
 * @param siteUserId
 * @return
 */
public static boolean isSiteManager(String siteUserId) {
	if (isSiteSuperAdmin(siteUserId)) {
		return true;
	}
	if (siteManagerSet != null && StringUtils.isNotEmpty(siteUserId)) {
		return siteManagerSet.contains(siteUserId);
	}
	return false;
}
 
Example 8
/**
 * Processing clean cache event
 *
 * @param cacheKey the key to clean on cache
 */
public void processCleanCacheEvent(ContentCacheKey cacheKey, Boolean isPartialKey) {
    if (cacheKey != null && StringUtils.isNotEmpty(cacheKey.getKey())) {
        if (isPartialKey) {
            cache.evictMatch(cacheKey);
        } else {
            cache.evict(cacheKey);
        }
        LOGGER.info("Deleting content cache key {} with partial match {}", cacheKey.getKey(), isPartialKey);
    } else {
        LOGGER.warn("Deleting all cache because we don't have key");
        cache.clear();
    }
}
 
Example 9
static void createPath(ZooKeeper zk, String path, CreateMode createMode, List<ACL> acl) throws Exception {
	String[] list = path.split("/");
	String zkPath = "";
	for (String str : list) {
		if (StringUtils.isNotEmpty(str)) {
			zkPath = zkPath + "/" + str;
			if (zk.exists(zkPath, false) == null) {
				zk.create(zkPath, null, acl, createMode);
			}
		}
	}
}
 
Example 10
public String escapeHtml(String value, boolean escapeNewlines) {
    /*
     * Velocity tools depend on this returning empty string (and never null),
     * they also depend on this handling a null input and converting it to null
     */
    String val = "";
    if (StringUtils.isNotEmpty(value)){
        val = StringEscapeUtils.escapeHtml4(value);
        if (escapeNewlines && val != null) {
            val = val.replace("\n", "<br/>\n");
        }
    }
    return val;
}
 
Example 11
Source Project: QuickProject   File: BaseSQLProvider.java    License: Apache License 2.0 5 votes vote down vote up
public static SQL WHERE_CUSTOM(SQL sql, Class modelClass, Map<String, Object> dataMap, List<CustomQueryParam> customQueryParams, String tableAlias) {
        Map<String, Property> properties = ModelUtils.getProperties(modelClass, null);

//        int i = 0;
        for (CustomQueryParam customQueryParam : customQueryParams) {
            String key = customQueryParam.getProperty();
            Property property = properties.get(key);
            if (property == null) {
                continue;
            }
            String condition = "";
            if (StringUtils.isNotEmpty(tableAlias)) {
                condition = tableAlias + "." + condition;
            }
            if (customQueryParam instanceof WithValueQueryParam) {
                WithValueQueryParam withValueQueryParam = (WithValueQueryParam) customQueryParam;
                dataMap.put(dataMap.size() + "", withValueQueryParam.getValue());
                // 不能以property为key放入dataMap,因为可能有相同的property,如> & <
                condition = condition + property.getColumnName() + " " + withValueQueryParam.getOperator() + " #{" + (dataMap.size() - 1) + "}";
//                i++;
            } else if (customQueryParam instanceof NoValueQueryParam) {
                NoValueQueryParam noValueQueryParam = (NoValueQueryParam) customQueryParam;
                condition = condition + property.getColumnName() + " " + noValueQueryParam.getCondition();
            }
            sql.WHERE(condition);
        }
        return sql;
    }
 
Example 12
public void process_table_OKR_WORK_REPORT_PROCESSLOG() throws Exception {
	List<String> all_entity_ids = null;
	Business business = null;
	String old_name = null;
	OkrWorkReportProcessLog entity = null;
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		business = new Business(emc);
		all_entity_ids = business.okrWorkReportProcessLogFactory().listAll();
		if( ListTools.isNotEmpty(all_entity_ids )) {
			emc.beginTransaction( OkrWorkReportProcessLog.class );
			for( String _id : all_entity_ids ) {
				entity = emc.find( _id, OkrWorkReportProcessLog.class );
				if( entity != null ) {
					old_name = entity.getProcessorIdentity();
					if( StringUtils.isNotEmpty(old_name) && UpdateIdentityMap.getIdentityWithOldName( old_name ) != null ) {
						entity.setProcessorIdentity( UpdateIdentityMap.getIdentityWithOldName(old_name));
					}
					old_name = entity.getProcessorName();
					if( StringUtils.isNotEmpty(old_name) && UpdatePersonMap.getPersonWithOldName( old_name ) != null ) {
						entity.setProcessorName( UpdatePersonMap.getPersonWithOldName(old_name));
					}
					old_name = entity.getProcessorTopUnitName();
					if( StringUtils.isNotEmpty(old_name) && UpdateUnitMap.getUnitWithOldName( old_name ) != null ) {
						entity.setProcessorTopUnitName( UpdateUnitMap.getUnitWithOldName(old_name));
					}
					old_name = entity.getProcessorUnitName();
					if( StringUtils.isNotEmpty(old_name) && UpdateUnitMap.getUnitWithOldName( old_name ) != null ) {
						entity.setProcessorUnitName( UpdateUnitMap.getUnitWithOldName(old_name));
					}
				}
			}
			emc.commit();
		}
	}catch( Exception e ){
		throw e;
	}
}
 
Example 13
@Override
protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    ValuedDataObject dataObject = (ValuedDataObject) element;

    if (StringUtils.isNotEmpty(dataObject.getId()) && dataObject.getValue() != null) {

        if (!didWriteExtensionStartElement) {
            xtw.writeStartElement(ELEMENT_EXTENSIONS);
            didWriteExtensionStartElement = true;
        }

        xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_DATA_VALUE, FLOWABLE_EXTENSIONS_NAMESPACE);
        if (dataObject.getValue() != null) {
            String value = null;
            if (dataObject instanceof DateDataObject) {
                value = sdf.format(dataObject.getValue());
            } else {
                value = dataObject.getValue().toString();
            }

            if (dataObject instanceof StringDataObject && xmlChars.matcher(value).find()) {
                xtw.writeCData(value);
            } else {
                xtw.writeCharacters(value);
            }
        }
        xtw.writeEndElement();
    }

    return didWriteExtensionStartElement;
}
 
Example 14
Source Project: data-prep   File: APIClientTest.java    License: Apache License 2.0 5 votes vote down vote up
private Response getExportResponse(String preparationId, String datasetId, String stepId, String csvDelimiter,
        String fileName, Integer expectedStatus) {
    RequestSpecification exportRequest = given() //
            .formParam("exportType", "CSV") //
            .formParam(ExportFormat.PREFIX + CSVFormat.ParametersCSV.ENCLOSURE_MODE, //
                    CSVFormat.ParametersCSV.ENCLOSURE_ALL_FIELDS) //
            .formParam("preparationId", preparationId) //
            .formParam("stepId", stepId);

    if (datasetId != null) {
        exportRequest.formParam("datasetId", datasetId);
    }

    if (StringUtils.isNotEmpty(csvDelimiter)) {
        exportRequest.formParam(ExportFormat.PREFIX + CSVFormat.ParametersCSV.FIELDS_DELIMITER, csvDelimiter);
    }

    if (StringUtils.isNotEmpty(fileName)) {
        exportRequest.formParam(ExportFormat.PREFIX + "fileName", fileName);
    }

    if (expectedStatus != null) {
        exportRequest //
                .when() //
                .expect() //
                .statusCode(expectedStatus) //
                .log() //
                .ifError();
    }

    return exportRequest.get("/api/export");
}
 
Example 15
Source Project: hermes   File: ProductManageController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 新增产品处理(保存到数据库)
 */
@RequestMapping("/doadd")
public String doadd(SimpleProduct product, RedirectAttributes attr, String id) {
	try {
		Product p = null;
		String msg = null;
		Product cp = productService.loadByCode(product.getCode());
		if (StringUtils.isNotEmpty(id)) {
			p = productService.loadById(id);
			if (cp != null && !cp.getId().equals(p.getId())) {
				attr.addFlashAttribute("msg", "该产品已存在,无法继续添加");
				return "redirect:/product/add";
			}
			msg = "修改产品成功";
		} else {
			if (cp != null) {
				attr.addFlashAttribute("msg", "该产品已存在,无法继续添加");
				return "redirect:/product/add";
			}
			msg = "添加产品成功";
			p = new Product();
			p.setStatus(Product.Status.VALID);
			//设置产品月缴管理费
			setProductMonthFee(p);
		}
		productService.editProduct(p, product);
		attr.addFlashAttribute("msg", msg);
		return "redirect:/product/index";
	} catch (Exception e) {
		Logger.error("新增产品异常", e);
		if (StringUtils.isNotEmpty(id)) {
			attr.addFlashAttribute("msg", "修改产品失败");
			return "redirect:/product/detail/" + id;
		} else {
			attr.addFlashAttribute("msg", "添加产品失败");
			return "redirect:/product/add";
		}
	}
}
 
Example 16
@Override
public ReviveModelResultRepresentation reviveProcessModelHistory(ModelHistory modelHistory, User user, String newVersionComment) {
    Model latestModel = modelRepository.get(modelHistory.getModelId());
    if (latestModel == null) {
        throw new IllegalArgumentException("No process model found with id: " + modelHistory.getModelId());
    }

    // Store the current model in history
    ModelHistory latestModelHistory = createNewModelhistory(latestModel);
    persistModelHistory(latestModelHistory);

    // Populate the actual latest version with the properties in the historic model
    latestModel.setVersion(latestModel.getVersion() + 1);
    latestModel.setLastUpdated(new Date());
    latestModel.setLastUpdatedBy(user.getId());
    latestModel.setName(modelHistory.getName());
    latestModel.setKey(modelHistory.getKey());
    latestModel.setDescription(modelHistory.getDescription());
    latestModel.setModelEditorJson(modelHistory.getModelEditorJson());
    latestModel.setModelType(modelHistory.getModelType());
    latestModel.setComment(newVersionComment);
    persistModel(latestModel);

    ReviveModelResultRepresentation result = new ReviveModelResultRepresentation();

    // For apps, we need to make sure the referenced processes exist as models.
    // It could be the user has deleted the process model in the meantime. We give back that info to the user.
    if (latestModel.getModelType() == AbstractModel.MODEL_TYPE_APP) {
        if (StringUtils.isNotEmpty(latestModel.getModelEditorJson())) {
            try {
                AppDefinition appDefinition = objectMapper.readValue(latestModel.getModelEditorJson(), AppDefinition.class);
                for (AppModelDefinition appModelDefinition : appDefinition.getModels()) {
                    if (modelRepository.get(appModelDefinition.getId()) == null) {
                        result.getUnresolvedModels().add(new UnresolveModelRepresentation(appModelDefinition.getId(),
                                appModelDefinition.getName(), appModelDefinition.getLastUpdatedBy()));
                    }
                }
            } catch (Exception e) {
                LOGGER.error("Could not deserialize app model json (id = {})", latestModel.getId(), e);
            }
        }
    }

    return result;
}
 
Example 17
@Override
public void execute(DelegateExecution execution) {
    Object value = null;
    try {
        CommandContext commandContext = CommandContextUtil.getCommandContext();
        String skipExpressionText = null;
        if (skipExpression != null) {
            skipExpressionText = skipExpression.getExpressionText();
        }
        boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(skipExpressionText, serviceTaskId, execution, commandContext);
        if (!isSkipExpressionEnabled || !SkipExpressionUtil.shouldSkipFlowElement(skipExpressionText, serviceTaskId, execution, commandContext)) {

            if (CommandContextUtil.getProcessEngineConfiguration(commandContext).isEnableProcessDefinitionInfoCache()) {
                ObjectNode taskElementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId());
                if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION)) {
                    String overrideExpression = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION).asText();
                    if (StringUtils.isNotEmpty(overrideExpression) && !overrideExpression.equals(expression.getExpressionText())) {
                        expression = CommandContextUtil.getProcessEngineConfiguration(commandContext).getExpressionManager().createExpression(overrideExpression);
                    }
                }
            }

            value = expression.getValue(execution);
            if (resultVariable != null) {
                if (storeResultVariableAsTransient) {
                    if (useLocalScopeForResultVariable) {
                        execution.setTransientVariableLocal(resultVariable, value);
                    } else {
                        execution.setTransientVariable(resultVariable, value);
                    }
                } else {
                    if (useLocalScopeForResultVariable) {
                        execution.setVariableLocal(resultVariable, value);
                    } else {
                        execution.setVariable(resultVariable, value);
                    }
                }
            }
        }
        if (!this.triggerable) {
            leave(execution);
        }

    } catch (Exception exc) {

        Throwable cause = exc;
        BpmnError error = null;
        while (cause != null) {
            if (cause instanceof BpmnError) {
                error = (BpmnError) cause;
                break;
            } else if (cause instanceof RuntimeException) {
                if (ErrorPropagation.mapException((RuntimeException) cause, (ExecutionEntity) execution, mapExceptions)) {
                    return;
                }
            }
            cause = cause.getCause();
        }

        if (error != null) {
            ErrorPropagation.propagateError(error, execution);
        } else {
            throw exc;
        }
    }
}
 
Example 18
Source Project: pmq   File: UiTopicService.java    License: Apache License 2.0 4 votes vote down vote up
public TopicReportResponse getTopicReport(TopicGetListRequest topicGetListRequest) {
	lastAccessTime = System.currentTimeMillis();
	int page = Integer.parseInt(topicGetListRequest.getPage());
	int pageSize = Integer.parseInt(topicGetListRequest.getLimit());
	List<TopicVo> topicVoList = new ArrayList<>();

	Map<String, List<ConsumerGroupTopicEntity>> topicSubscribeMap = consumerGroupTopicService
			.getTopicSubscribeMap();
	for (TopicVo topicVo : topicVoListRf.get()) {
		if (StringUtils.isNotEmpty(topicGetListRequest.getName())) {
			if (!topicGetListRequest.getName().equals(topicVo.getName())) {
				continue;
			}
		}

		if (StringUtils.isNotEmpty(topicGetListRequest.getTopicExceptionType())) {
			// 过滤掉非僵尸topic
			if ("1".equals(topicGetListRequest.getTopicExceptionType())) {
				if (topicVo.getMsgCount() > 0) {// 过滤有消息的topic
					continue;
				}
				if (topicSubscribeMap.containsKey(topicVo.getOriginName())) {// 过滤已经被订阅的topic
					continue;
				}
				//排除创建时间不到三天的topic
				if (System.currentTimeMillis()-topicVo.getInsertTime().getTime() < 3 * 24 * 60 * 60
						* 1000) {
					continue;
				}
			}

			// 过滤掉负责人正常的topic
			if ("2".equals(topicGetListRequest.getTopicExceptionType())) {
				List<String> ownerIds = Arrays.asList(topicVo.getOwnerIds().split(","));
				if (uiQueueOffsetService.isOwnerAvailable(ownerIds)) {
					continue;
				}
			}

			//过滤掉已经被订阅的topic
			if("3".equals(topicGetListRequest.getTopicExceptionType())){
				if (topicSubscribeMap.containsKey(topicVo.getOriginName())) {// 过滤已经被订阅的topic
					continue;
				}
			}
		}

		if (StringUtils.isNotEmpty(topicGetListRequest.getQueueManagementType())) {
			if ("1".equals(topicGetListRequest.getQueueManagementType())) {
				if (!shouldShrink.equals(topicVo.getIsReasonable())) {
					continue;
				}
			}

			if ("2".equals(topicGetListRequest.getQueueManagementType())) {
				if (!shouldExpand.equals(topicVo.getIsReasonable())) {
					continue;
				}
			}
		}

		topicVoList.add(topicVo);
	}

	int t = topicVoList.size();
	if ((page * pageSize) > topicVoList.size()) {
		topicVoList = topicVoList.subList((page - 1) * pageSize, topicVoList.size());
	} else {
		topicVoList = topicVoList.subList((page - 1) * pageSize, page * pageSize);
	}
	return new TopicReportResponse(new Long(t), topicVoList);

}
 
Example 19
Source Project: ftdc   File: ReqFromBankToFuture.java    License: Apache License 2.0 4 votes vote down vote up
public void setTradingDay(String tradingDay) {
	if (StringUtils.isNotEmpty(tradingDay)) {
		System.arraycopy(tradingDay.getBytes(), 0, this.tradingDay, 0, tradingDay.getBytes().length);
	}
}
 
Example 20
Source Project: flow-android   File: FlowAsyncClient.java    License: MIT License 4 votes vote down vote up
private static void useCsrfToken() {
    if (StringUtils.isNotEmpty(csrfToken)) {
        client.addHeader("X-CSRF-Token", csrfToken);
    }
}