List of usage examples for org.apache.commons.lang3 StringUtils trimToNull
public static String trimToNull(final String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .
From source file:org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.java
protected void createLocalizationValues(String processDefinitionId, Process process) { if (process == null) { return;// w w w .j a va 2 s . c om } CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService(); ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId); boolean localizationValuesChanged = false; List<ExtensionElement> localizationElements = process.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String processId = process.getId(); if (isEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, processId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, processId, documentation, infoNode); localizationValuesChanged = true; } break; } } } boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } if (localizationValuesChanged) { dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode); } }
From source file:org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.java
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) { boolean localizationValuesChanged = false; if (flowElements == null) { return localizationValuesChanged; }// w ww . j av a 2 s. co m CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService(); for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask || flowElement instanceof SubProcess) { List<ExtensionElement> localizationElements = flowElement.getExtensionElements() .get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX .equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String flowElementId = flowElement.getId(); if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode); localizationValuesChanged = true; } break; } } } if (flowElement instanceof SubProcess) { SubProcess subprocess = (SubProcess) flowElement; boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements( subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } } } } return localizationValuesChanged; }
From source file:org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.java
protected boolean localizeDataObjectElements(List<ValuedDataObject> dataObjects, ObjectNode infoNode) { boolean localizationValuesChanged = false; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService();//from w w w .jav a 2 s . co m for (ValuedDataObject dataObject : dataObjects) { List<ExtensionElement> localizationElements = dataObject.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX .equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } if (name != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, dataObject.getId(), name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, dataObject.getId(), documentation, infoNode); localizationValuesChanged = true; } } } } } return localizationValuesChanged; }
From source file:org.activiti.engine.impl.bpmn.parser.handler.UserTaskParseHandler.java
protected Map<String, String> generateResourceLists(String resourceExpression) { Map<String, String> resourceLists = null; if (resourceExpression != null) { StringBuilder userExpression = new StringBuilder(50); StringBuilder groupExpression = new StringBuilder(50); List<String> assignmentList = CommaSplitter.splitCommas(resourceExpression); for (String assignmentValue : assignmentList) { assignmentValue = StringUtils.trimToNull(assignmentValue); if (assignmentValue == null) { continue; }//from w ww .j a v a2 s .co m if (assignmentValue.startsWith(USER)) { List<String> userList = CommaSplitter.splitCommas( assignmentValue.substring(USER.length() + 1, assignmentValue.length() - 1).trim()); for (String user : userList) { if (StringUtils.isNotEmpty(userExpression.toString())) { userExpression.append(COMMA_SPACE); } userExpression.append(user); } } else if (assignmentValue.startsWith(GROUP)) { List<String> groupList = CommaSplitter.splitCommas( assignmentValue.substring(GROUP.length() + 1, assignmentValue.length() - 1).trim()); for (String group : groupList) { if (StringUtils.isNotEmpty(groupExpression.toString())) { groupExpression.append(COMMA_SPACE); } groupExpression.append(group); } } else { if (StringUtils.isNotEmpty(groupExpression.toString())) { groupExpression.append(COMMA_SPACE); } groupExpression.append(assignmentValue); } } resourceLists = new HashMap<String, String>(); resourceLists.put(USER, userExpression.toString()); resourceLists.put(GROUP, groupExpression.toString()); } return resourceLists; }
From source file:org.activiti5.engine.impl.bpmn.deployer.BpmnDeployer.java
protected void createLocalizationValues(String processDefinitionId, Process process) { if (process == null) return;//w ww. jav a2s .c o m CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService(); ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId); boolean localizationValuesChanged = false; List<ExtensionElement> localizationElements = process.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String processId = process.getId(); if (isEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, processId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, processId, documentation, infoNode); localizationValuesChanged = true; } break; } } } boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } if (localizationValuesChanged) { dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode); } }
From source file:org.activiti5.engine.impl.bpmn.deployer.BpmnDeployer.java
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) { boolean localizationValuesChanged = false; if (flowElements == null) return localizationValuesChanged; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService();//www. ja v a 2 s . c om for (FlowElement flowElement : flowElements) { if (flowElement instanceof UserTask || flowElement instanceof SubProcess) { List<ExtensionElement> localizationElements = flowElement.getExtensionElements() .get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX .equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } String flowElementId = flowElement.getId(); if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode); localizationValuesChanged = true; } break; } } } if (flowElement instanceof SubProcess) { SubProcess subprocess = (SubProcess) flowElement; boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements( subprocess.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) { localizationValuesChanged = true; } } } } return localizationValuesChanged; }
From source file:org.activiti5.engine.impl.bpmn.deployer.BpmnDeployer.java
protected boolean localizeDataObjectElements(List<ValuedDataObject> dataObjects, ObjectNode infoNode) { boolean localizationValuesChanged = false; CommandContext commandContext = Context.getCommandContext(); DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration() .getDynamicBpmnService();/* w w w. jav a 2s. com*/ for (ValuedDataObject dataObject : dataObjects) { List<ExtensionElement> localizationElements = dataObject.getExtensionElements().get("localization"); if (localizationElements != null) { for (ExtensionElement localizationElement : localizationElements) { if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX .equals(localizationElement.getNamespacePrefix())) { String locale = localizationElement.getAttributeValue(null, "locale"); String name = localizationElement.getAttributeValue(null, "name"); String documentation = null; List<ExtensionElement> documentationElements = localizationElement.getChildElements() .get("documentation"); if (documentationElements != null) { for (ExtensionElement documentationElement : documentationElements) { documentation = StringUtils.trimToNull(documentationElement.getElementText()); break; } } if (name != null && isEqualToCurrentLocalizationValue(locale, dataObject.getName(), DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false) { dynamicBpmnService.changeLocalizationName(locale, dataObject.getName(), name, infoNode); localizationValuesChanged = true; } if (documentation != null && isEqualToCurrentLocalizationValue(locale, dataObject.getName(), DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false) { dynamicBpmnService.changeLocalizationDescription(locale, dataObject.getName(), documentation, infoNode); localizationValuesChanged = true; } } } } } return localizationValuesChanged; }
From source file:org.ahp.login.action.ProcessLogin.java
@Override public ActionForward process(ActionMapping pActionMapping, ActionForm pActionForm, HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) { LoginForm lLoginForm = (LoginForm) pActionForm; String lSubmitAction = StringUtils.trimToNull(lLoginForm.getSubmitAction()); if (lSubmitAction != null) { if (SubmitActions.LOGIN.toString().equals(lSubmitAction)) { String lLoginName = lLoginForm.getLoginName(); String lPassword = lLoginForm.getPassword(); if (!mLoginService.doesUserExist(lLoginName)) { ActionMessages lActionMessages = new ActionMessages(); lActionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(LOGIN_ERROR_KEY_PREFIX + ".loginname.notexists")); this.saveErrors(pHttpServletRequest, lActionMessages); lLoginForm.setNextPage(NavigateActions.DisplayLogin.toString()); return pActionMapping.findForward(NavigateActions.DisplayLogin.toString()); }// ww w . j a va2 s . c om boolean lAuthenticated = mLoginService.isUserAuthenticated(lLoginName, lPassword); if (lAuthenticated) { LOGGER.debug("Login Successful"); User lUser = mLoginService.loadUserByLoginName(lLoginName); pHttpServletRequest.getSession().setAttribute(LOGGED_IN_USER, lUser); lLoginForm.setNextPage("DisplayHomePage"); } lLoginForm.setNextPage(NavigateActions.DisplayHomePage.toString()); } } return pActionMapping.findForward(NavigateActions.DisplayLogin.toString()); }
From source file:org.ahp.login.form.LoginForm.java
@Override public ActionErrors validate(ActionMapping pActionMapping, HttpServletRequest pHttpServletRequest) { ActionErrors lActionErrors = new ActionErrors(); String lSubmitAction = StringUtils.trimToNull(this.getSubmitAction()); if (lSubmitAction != null && SubmitActions.LOGIN.toString().equals((lSubmitAction))) { LoginValidator.validateLoginForm(this, lActionErrors); }//from w w w.j av a 2 s.c o m return lActionErrors; }
From source file:org.ahp.vinavidai.console.action.ProcessQuizConsole.java
@Override public ActionForward process(ActionMapping pActionMapping, ActionForm pActionForm, HttpServletRequest pHttpServletRequest, HttpServletResponse pHttpServletResponse) { User lLoggedInUser = AhpActionHelper.getLoggedInUser(pHttpServletRequest); QuizConsoleForm lQuizConsoleForm = (QuizConsoleForm) pActionForm; String lSubmitAction = StringUtils.trimToNull(lQuizConsoleForm.getSubmitAction()); lQuizConsoleForm.setNextPage(NavigateActions.DisplayQuizConsole.toString()); return pActionMapping.findForward(NavigateActions.DisplayQuizConsole.toString()); }