List of usage examples for org.apache.commons.lang3 StringUtils defaultString
public static String defaultString(final String str)
Returns either the passed in String, or if the String is null , an empty String ("").
StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"
From source file:com.netsteadfast.greenstep.bsc.command.KpiDateRangeScoreCommand.java
@Override public boolean execute(Context context) throws Exception { if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) { return false; }//from ww w.j a v a 2s.c o m BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); String frequency = (String) context.get("frequency"); String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim(); String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim(); String startDate = StringUtils.defaultString((String) context.get("startDate")).trim(); String endDate = StringUtils.defaultString((String) context.get("endDate")).trim(); //BscReportSupportUtils.loadExpression(); 2015-04-11 rem //long beg = System.currentTimeMillis(); for (VisionVO vision : treeObj.getVisions()) { for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { // 2015-04-11 add ExecutorService kpiCalculationPool = Executors .newFixedThreadPool(SimpleUtils.getAvailableProcessors(objective.getKpis().size())); for (KpiVO kpi : objective.getKpis()) { /* 2015-04-11 rem if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency) ) { this.fillDateRangeMonth(kpi, frequency, startDate, endDate); } else { this.fillDateRangeYear(kpi, frequency, startYearDate, endYearDate); } */ // 2015-04-11 add ScoreCalculationCallableData data = new ScoreCalculationCallableData(); data.setDefaultMode(false); data.setKpi(kpi); data.setFrequency(frequency); data.setDate1(startYearDate); data.setDate2(endYearDate); if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency)) { data.setDate1(startDate); data.setDate2(endDate); } data = kpiCalculationPool.submit(new ScoreCalculationCallable(data)).get(); } kpiCalculationPool.shutdown(); } } } //long end = System.currentTimeMillis(); //System.out.println( this.getClass().getName() + " use time(MS) = " + (end-beg) ); return false; }
From source file:com.netsteadfast.greenstep.sys.GreenStepMobileFormAuthenticationFilter.java
protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { String username = StringUtils.defaultString(this.getUsername(request)); String password = StringUtils.defaultString(this.getPassword(request)); String captcha = StringUtils.defaultString(this.getCaptcha(request)); //boolean rememberMe = StringUtils.defaultString(isRememberMe(request)); boolean rememberMe = false; String host = StringUtils.defaultString(getHost(request)); char pwd[] = null; try {//ww w .j a v a 2s . c o m ShiroLoginSupport loginSupport = new ShiroLoginSupport(); pwd = loginSupport.getAccountService().tranPassword(password).toCharArray(); } catch (Exception e) { e.printStackTrace(); } return new GreenStepBaseUsernamePasswordToken(username, pwd, rememberMe, host, captcha); }
From source file:com.sonicle.webtop.core.util.NotificationHelper.java
/** * Creates strings map (No-Reply version) for notification (simple body) template * @param locale/*from w w w.ja v a2s .c om*/ * @param source * @param bodyHeader * @param bodyMessage * @return */ public static Map<String, String> createNoReplayDefaultBodyTplStrings(Locale locale, String source, String bodyHeader, String bodyMessage) { HashMap<String, String> map = new HashMap<>(); map.put("bodyHeader", StringUtils.defaultString(bodyHeader)); map.put("bodyMessage", StringUtils.defaultString(bodyMessage)); map.put("footerHeader", MessageFormat.format( WT.lookupResource(CoreManifest.ID, locale, CoreLocaleKey.TPL_NOTIFICATION_NOREPLY_FOOTER_HEADER), source)); map.put("footerMessage", WT.lookupResource(CoreManifest.ID, locale, CoreLocaleKey.TPL_NOTIFICATION_NOREPLY_FOOTER_MESSAGE)); return map; }
From source file:org.meruvian.yama.social.core.AbstractSocialService.java
@Override public OAuth2Parameters getParameters() { OAuth2Parameters parameters = new OAuth2Parameters(); parameters.setRedirectUri(redirectUri); parameters.setScope(StringUtils.defaultString(scope)); parameters.setState(StringUtils.defaultString(state)); return parameters; }
From source file:de.micromata.genome.gwiki.page.impl.PropsEditContext.java
public String getPropsValue() { if (propsArtefakt.getCompiledObject() == null) { return ""; }/*from www . j a v a2 s.c o m*/ return StringUtils.defaultString(propsArtefakt.getCompiledObject().getStringValue(propDescriptor.getKey())); }
From source file:com.netsteadfast.greenstep.util.SystemSettingConfigureUtils.java
public static String getMailEnableValue() { SysCodeVO sysCode = getMailEnable(); return StringUtils.defaultString(sysCode.getParam1()).trim(); }
From source file:io.mapzone.controller.vm.http.AuthTokenValidator.java
/** * //from w w w . jav a2 s . c o m * * @throws HttpProvisionRuntimeException If project does not exists. */ public boolean checkAuthToken() { ProjectInstanceIdentifier pid = new ProjectInstanceIdentifier(request); // check param token; ignore parameter char case Optional<String> requestToken = requestParameter(REQUEST_PARAM_TOKEN); if (requestToken.isPresent()) { if (!isValidToken(requestToken.get(), pid)) { throw new HttpProvisionRuntimeException(401, "Given auth token is not valid for this project."); } return true; } // check path parts String path = StringUtils.defaultString(request.getPathInfo()); for (String part : StringUtils.split(path, '/')) { if (isValidToken(part, pid)) { return true; } } return false; }
From source file:info.magnolia.module.servletsanity.support.ServletAssert.java
public static void printRequestInfo(HttpServletRequest request, HttpServletResponse response, String location) throws IOException { append("");/*from w w w. j av a 2 s . co m*/ append(""); append("###################################"); append("##"); append("## " + location); append("##"); append("##############"); append(""); appendRequestChain(request); appendResponseChain(response); append("Path elements:"); append(" RequestUri = " + request.getRequestURI()); append(" ContextPath = " + request.getContextPath()); append(" ServletPath = " + request.getServletPath()); append(" PathInfo = " + request.getPathInfo()); append(" QueryString = " + request.getQueryString()); String x = request.getContextPath() + request.getServletPath() + StringUtils.defaultString(request.getPathInfo()); if (!request.getRequestURI().equals(x)) { append("ERROR RequestURI is [" + request.getRequestURI() + "] according to spec it should be [" + x + "]"); } else { append(" Request path elements are in sync (requestURI = contextPath + servletPath + pathInfo) (SRV 3.4)"); } append(""); append("Forward attributes:"); printAttribute(request, "javax.servlet.forward.request_uri"); printAttribute(request, "javax.servlet.forward.context_path"); printAttribute(request, "javax.servlet.forward.servlet_path"); printAttribute(request, "javax.servlet.forward.path_info"); printAttribute(request, "javax.servlet.forward.query_string"); append(""); append("Include attributes:"); printAttribute(request, "javax.servlet.include.request_uri"); printAttribute(request, "javax.servlet.include.context_path"); printAttribute(request, "javax.servlet.include.servlet_path"); printAttribute(request, "javax.servlet.include.path_info"); printAttribute(request, "javax.servlet.include.query_string"); append(""); }
From source file:com.mirth.connect.client.ui.attachments.RegexAttachmentDialog.java
public RegexAttachmentDialog(AttachmentHandlerProperties properties) { super(PlatformUI.MIRTH_FRAME, true); this.parent = PlatformUI.MIRTH_FRAME; setTitle("Set Attachment Properties"); getContentPane().setBackground(UIConstants.BACKGROUND_COLOR); setLayout(new MigLayout("novisualpadding, hidemode 3, insets 12", "[fill, grow]")); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setPreferredSize(new Dimension(650, 550)); initComponents();//w w w .ja va2 s.com initLayout(); initInboundReplacementTable(); initOutboundReplacementTable(); attachmentHandlerProperties = properties; List<RegexInfo> regexInfoList = new ArrayList<RegexInfo>(); if (attachmentHandlerProperties.getProperties().containsKey("regex.pattern")) { String regex = StringUtils .defaultString(attachmentHandlerProperties.getProperties().get("regex.pattern")); String mimeType = StringUtils .defaultString(attachmentHandlerProperties.getProperties().get("regex.mimetype")); regexInfoList.add(new RegexInfo(regex, mimeType)); } int count = 0; while (attachmentHandlerProperties.getProperties().containsKey("regex.pattern" + count)) { String regex = StringUtils .defaultString(attachmentHandlerProperties.getProperties().get("regex.pattern" + count)); String mimeType = StringUtils .defaultString(attachmentHandlerProperties.getProperties().get("regex.mimetype" + count)); regexInfoList.add(new RegexInfo(regex, mimeType)); count++; } Object[][] regexTableData = new Object[regexInfoList.size()][2]; int i = 0; for (RegexInfo regexInfo : regexInfoList) { regexTableData[i][0] = regexInfo.pattern; regexTableData[i][1] = regexInfo.mimeType; i++; } ((RefreshTableModel) regexTable.getModel()).refreshDataVector(regexTableData); count = 0; while (attachmentHandlerProperties.getProperties().containsKey("regex.replaceKey" + count)) { DefaultTableModel tableModel = (DefaultTableModel) inboundReplacementTable.getModel(); tableModel.addRow( new Object[] { attachmentHandlerProperties.getProperties().get("regex.replaceKey" + count), attachmentHandlerProperties.getProperties().get("regex.replaceValue" + count) }); count++; } count = 0; while (attachmentHandlerProperties.getProperties().containsKey("outbound.regex.replaceKey" + count)) { DefaultTableModel tableModel = (DefaultTableModel) outboundReplacementTable.getModel(); tableModel.addRow(new Object[] { attachmentHandlerProperties.getProperties().get("outbound.regex.replaceKey" + count), attachmentHandlerProperties.getProperties().get("outbound.regex.replaceValue" + count) }); count++; } setLocationRelativeTo(parent); setVisible(true); }
From source file:baggage.hypertoolkit.request.RequestParser.java
protected void validateRequiredKey(String requiredKey, Bag<String, String> parameters) throws InvalidRequestException { if (!parameters.containsKey(StringUtils.defaultString(requiredKey))) { throw new InvalidRequestException(requiredKey); } else {/*from ww w . j a v a 2 s .com*/ final String value = parameters.get(StringUtils.defaultString(requiredKey)); if (StringUtils.isEmpty(value)) { throw new InvalidRequestException(requiredKey); } } }