List of usage examples for org.apache.commons.lang StringUtils endsWith
public static boolean endsWith(String str, String suffix)
Check if a String ends with a specified suffix.
From source file:com.glaf.activiti.executionlistener.SqlUpdateByProcessInstanceListener.java
public void notify(DelegateExecution execution) throws Exception { logger.debug("-------------------------------------------------------"); logger.debug("-------------SqlUpdateByProcessInstanceListener--------"); logger.debug("-------------------------------------------------------"); String tableName = table.getExpressionText(); if (StringUtils.startsWith(tableName, "#{") && StringUtils.endsWith(tableName, "}")) { tableName = (String) table.getValue(execution); }/*from w ww . j a v a 2 s . c o m*/ CommandContext commandContext = Context.getCommandContext(); ExecutionEntity executionEntity = commandContext.getExecutionEntityManager() .findExecutionById(execution.getId()); String processDefinitionId = executionEntity.getProcessDefinitionId(); ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessDefinitionEntityManager() .findProcessDefinitionById(processDefinitionId); String processName = processDefinitionEntity.getKey(); Map<String, Object> params = new java.util.HashMap<String, Object>(); Map<String, Object> variables = execution.getVariables(); if (variables != null && variables.size() > 0) { Iterator<String> iterator = variables.keySet().iterator(); while (iterator.hasNext()) { String variableName = iterator.next(); if (params.get(variableName) == null) { Object value = execution.getVariable(variableName); params.put(variableName, value); } } } params.put(Constants.BUSINESS_KEY, execution.getProcessBusinessKey()); params.put("processInstanceId", execution.getProcessInstanceId()); params.put("processDefinitionId", processDefinitionEntity.getId()); params.put("processName", processName); params.put("now", new Date()); params.put("today", new Date()); params.put("currentDate", new Date()); String variable = (String) execution.getVariable(fields.getExpressionText()); JSONObject jsonObject = JSON.parseObject(variable); TableModel tableModel = new TableModel(); tableModel.setTableName(tableName); ColumnModel idColumn = new ColumnModel(); idColumn.setColumnName(processInstanceField.getExpressionText()); idColumn.setJavaType("String"); idColumn.setValue(execution.getProcessInstanceId()); tableModel.setIdColumn(idColumn); Iterator<Entry<String, Object>> iterator = jsonObject.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String columnName = (String) entry.getKey(); String value = (String) entry.getValue(); if (value.indexOf("#{") != -1 && value.indexOf("}") != -1) { value = value.substring(2, value.length() - 1); Object x = params.get(value); if (x != null) { ColumnModel column = new ColumnModel(); column.setColumnName(columnName); column.setJavaType(x.getClass().getSimpleName()); column.setValue(x); tableModel.addColumn(column); } } else { Object x = params.get(value); if (x != null) { ColumnModel column = new ColumnModel(); column.setColumnName(columnName); column.setJavaType(x.getClass().getSimpleName()); column.setValue(x); tableModel.addColumn(column); } } } commandContext.getDbSqlSession().getSqlSession().update("updateBusinessTableDataByPrimaryKey", tableModel); }
From source file:com.xx_dev.apn.proxy.remotechooser.ApnProxyRemoteChooser.java
private static ApnProxyRemoteRule getApplyRemoteRule(String host) { for (ApnProxyRemoteRule remoteRule : ApnProxyConfig.getConfig().getRemoteRuleList()) { for (String originalHost : remoteRule.getOriginalHostList()) { if (StringUtils.equals(originalHost, host) || StringUtils.endsWith(host, "." + originalHost)) { return remoteRule; }// w w w . j av a 2 s . c om } } return null; }
From source file:at.pagu.soldockr.core.HttpSolrServerFactory.java
private void appendCoreToBaseUrl(String core, SolrServer solrServer) { if (StringUtils.isNotEmpty(core) && assertSolrServerInstance(solrServer)) { HttpSolrServer httpSolrServer = (HttpSolrServer) solrServer; String url = httpSolrServer.getBaseURL(); if (!StringUtils.endsWith(SLASH, url)) { url = url + SLASH;// ww w .j ava2 s.c o m } url = url + core; httpSolrServer.setBaseURL(url); } }
From source file:hydrograph.ui.validators.impl.FTPProtocolSelectionValidator.java
private boolean validatePort(String text, String propertyName) { if (StringUtils.isNotBlank(text)) { Matcher matcher = Pattern.compile("[\\d]*").matcher(text); if ((matcher.matches()) || ((StringUtils.startsWith(text, "@{") && StringUtils.endsWith(text, "}")) && !StringUtils.contains(text, "@{}"))) { return true; }//from ww w . j av a 2 s .c o m errorMessage = propertyName + " is mandatory"; } errorMessage = propertyName + " is not integer value or valid parameter"; return false; }
From source file:com.evolveum.midpoint.ninja.action.worker.ImportProducerWorker.java
@Override public void run() { Log log = context.getLog();// w ww . ja v a2 s.co m log.info("Starting import"); operation.start(); try (InputStream input = openInputStream()) { if (!options.isZip()) { processStream(input); } else { ZipInputStream zis = new ZipInputStream(input); ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { if (entry.isDirectory()) { continue; } if (!StringUtils.endsWith(entry.getName().toLowerCase(), ".xml")) { continue; } log.info("Processing file {}", entry.getName()); processStream(zis); } } } catch (IOException ex) { log.error("Unexpected error occurred, reason: {}", ex, ex.getMessage()); } catch (NinjaException ex) { log.error(ex.getMessage(), ex); } finally { markDone(); if (isWorkersDone()) { if (!operation.isFinished()) { operation.producerFinish(); } } } }
From source file:net.geoprism.SessionFilter.java
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) req; HttpServletResponse httpRes = (HttpServletResponse) res; // response time logging req.setAttribute("startTime", (Long) (new Date().getTime())); HttpSession session = httpReq.getSession(); WebClientSession clientSession = (WebClientSession) session.getAttribute(ClientConstants.CLIENTSESSION); // This isLoggedIn check is not 100% sufficient, it doesn't go to the server // and check, it only does it locally, so if the session has expired it'l // let it through. if (clientSession != null && clientSession.getRequest().isLoggedIn()) { try {//from w ww.j a v a2s .com req.setAttribute(ClientConstants.CLIENTREQUEST, clientSession.getRequest()); chain.doFilter(req, res); } catch (Throwable t) { while (t.getCause() != null && !t.getCause().equals(t)) { t = t.getCause(); } if (t instanceof InvalidSessionExceptionDTO) { // If we're asynchronous, we want to return a serialized exception if (StringUtils.endsWith(httpReq.getRequestURL().toString(), ".mojax")) { ErrorUtility.prepareAjaxThrowable(t, httpRes); } else { // Not an asynchronous request, redirect to the login page. httpRes.sendRedirect(httpReq.getContextPath() + "/loginRedirect"); } } else { if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } } return; } else if (pathAllowed(httpReq)) { chain.doFilter(req, res); return; } else { // The user is not logged in // If we're asynchronous, we want to return a serialized exception if (StringUtils.endsWith(httpReq.getRequestURL().toString(), ".mojax")) { ErrorUtility.prepareAjaxThrowable(new InvalidSessionExceptionDTO(), httpRes); } else { // Not an asynchronous request, redirect to the login page. httpRes.sendRedirect(httpReq.getContextPath() + "/loginRedirect"); } } }
From source file:com.enonic.cms.server.service.dwr.DwrServletWrapper.java
private void setContentType(HttpServletRequest req, HttpServletResponse res) { String url = req.getRequestURL().toString(); if (StringUtils.endsWith(url, ".js")) { res.setContentType("text/javascript"); }/* w w w .j a v a2 s. co m*/ }
From source file:com.google.gdt.eclipse.designer.model.widgets.NumberLabelInfo.java
/** * @return the icon {@link Image} which corresponds to the type argument of this * <code>NumberLabel</code> instance. *///from w ww . j a v a 2 s . c o m private Image getTypeIcon() { Expression creationExpression = (Expression) getCreationSupport().getNode(); ITypeBinding creationBinding = AstNodeUtils.getTypeBinding(creationExpression); ITypeBinding typeBinding = AstNodeUtils.getTypeBindingArgument(creationBinding, 0); String typeName = AstNodeUtils.getFullyQualifiedName(typeBinding, false); for (CreationDescription creation : getDescription().getCreations()) { if (StringUtils.endsWith(typeName, "." + creation.getId())) { return creation.getIcon(); } } return null; }
From source file:com.liferay.alloy.util.DefaultValueUtil.java
public static boolean isValidStringValue(String value) { value = StringUtil.trim(GetterUtil.getString(value)); if (Validator.isNull(value)) { return false; }//from w w w . j a va2 s.com if (StringUtils.isAlpha(value) || (!StringUtils.containsIgnoreCase(value, _GENERATED) && !StringUtils.isAlpha(value.substring(0, 1)) && !StringUtils.endsWith(value, StringPool.PERIOD))) { return true; } return false; }
From source file:cec.easyshop.storefront.controllers.pages.LoginPageController.java
protected void storeReferer(final String referer, final HttpServletRequest request, final HttpServletResponse response) { if (StringUtils.isNotBlank(referer) && !StringUtils.endsWith(referer, "/login") && StringUtils.contains(referer, request.getServerName())) { httpSessionRequestCache.saveRequest(request, response); }/*w ww .java 2 s . co m*/ }