List of usage examples for org.apache.commons.lang StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang StringUtils EMPTY.
Click Source Link
""
. From source file:info.magnolia.cms.beans.config.VirtualURIManager.java
/** * checks for the requested URI mapping in Server config : Servlet Specification 2.3 Section 10 "Mapping Requests to * Servlets".//w w w. jav a 2s. co m * @return URI string mapping */ public String getURIMapping(String uri) { Iterator e = cachedURImapping.keySet().iterator(); String mappedURI = StringUtils.EMPTY; int lastMatchedPatternlength = 0; while (e.hasNext()) { UrlPattern p = (UrlPattern) e.next(); if (p.match(uri)) { int patternLength = p.getLength(); if (lastMatchedPatternlength < patternLength) { lastMatchedPatternlength = patternLength; mappedURI = ((String[]) cachedURImapping.get(p))[0]; } } } return mappedURI; }
From source file:com.microsoft.alm.plugin.idea.tfvc.ui.settings.ProjectConfigurableFormTest.java
@Test public void testLoad_TfDetected() { when(mockPropertyService.getProperty(PropertyService.PROP_TF_HOME)).thenReturn(StringUtils.EMPTY); when(TfTool.tryDetectTf()).thenReturn("/path/to/detected/cmd/tf"); form.load();/*from w w w . ja v a 2 s. c o m*/ assertEquals("/path/to/detected/cmd/tf", form.getCurrentExecutablePath()); }
From source file:com.sugaronrest.restapicalls.methodcalls.GetLinkedEntryList.java
/** * Gets linked entries [SugarCRM REST method - get_entry_list]. * * @param url REST API Url.//w w w . j a v a2s . c om * @param sessionId Session identifier. * @param moduleName SugarCRM module name. * @param selectFields Selected field list. * @param linkedSelectFields Linked field info. * @param queryString Formatted query string. * @param maxCountResult Maximum number of entries to return. * @return ReadLinkedEntryListResponse object * @throws Exception */ public static ReadLinkedEntryListResponse run(String url, String sessionId, String moduleName, List<String> selectFields, List<Object> linkedSelectFields, String queryString, int maxCountResult) throws Exception { ReadLinkedEntryListResponse readLinkedEntryListResponse = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); requestData.put("query", queryString); requestData.put("order_by", StringUtils.EMPTY); requestData.put("offset", 0); requestData.put("select_fields", selectFields); boolean linkedInfoNotSet = ((linkedSelectFields == null) || (linkedSelectFields.size() == 0)); requestData.put("link_name_to_fields_array", linkedInfoNotSet ? StringUtils.EMPTY : linkedSelectFields); requestData.put("max_results", maxCountResult); requestData.put("deleted", 0); requestData.put("favorites", false); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "get_entry_list"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asJson(); if (response == null) { readLinkedEntryListResponse = new ReadLinkedEntryListResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); readLinkedEntryListResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST); readLinkedEntryListResponse.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { readLinkedEntryListResponse = mapper.readValue(jsonResponse, ReadLinkedEntryListResponse.class); } } if (readLinkedEntryListResponse == null) { readLinkedEntryListResponse = new ReadLinkedEntryListResponse(); readLinkedEntryListResponse.setError(errorResponse); readLinkedEntryListResponse.setStatusCode(HttpStatus.SC_OK); if (errorResponse != null) { readLinkedEntryListResponse.setStatusCode(errorResponse.getStatusCode()); } } else { readLinkedEntryListResponse.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { readLinkedEntryListResponse = new ReadLinkedEntryListResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); readLinkedEntryListResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); readLinkedEntryListResponse.setError(errorResponse); } readLinkedEntryListResponse.setJsonRawRequest(jsonRequest); readLinkedEntryListResponse.setJsonRawResponse(jsonResponse); return readLinkedEntryListResponse; }
From source file:com.sugaronrest.restapicalls.methodcalls.GetLinkedEntry.java
/** * Gets linked entry[SugarCRM REST method - get_entry]. * * @param url REST API Url.// ww w . j av a 2s .c om * @param sessionId Session identifier. * @param moduleName SugarCRM module name. * @param identifier The entity identifier. * @param selectFields Selected field list. * @param linkedSelectFields Linked field info. * @return ReadLinkedEntryResponse object */ public static ReadLinkedEntryResponse run(String url, String sessionId, String moduleName, String identifier, List<String> selectFields, List<Object> linkedSelectFields) { ReadLinkedEntryResponse readLinkedEntryResponse = null; ErrorResponse errorResponse = null; String jsonRequest = new String(); String jsonResponse = new String(); ObjectMapper mapper = JsonObjectMapper.getMapper(); try { Map<String, Object> requestData = new LinkedHashMap<String, Object>(); requestData.put("session", sessionId); requestData.put("module_name", moduleName); requestData.put("id", identifier); requestData.put("select_fields", selectFields); boolean linkedInfoNotSet = ((linkedSelectFields == null) || (linkedSelectFields.size() == 0)); requestData.put("link_name_to_fields_array", linkedInfoNotSet ? StringUtils.EMPTY : linkedSelectFields); requestData.put("track_view", false); String jsonRequestData = mapper.writeValueAsString(requestData); Map<String, Object> request = new LinkedHashMap<String, Object>(); request.put("method", "get_entry"); request.put("input_type", "json"); request.put("response_type", "json"); request.put("rest_data", requestData); jsonRequest = mapper.writeValueAsString(request); request.put("rest_data", jsonRequestData); HttpResponse response = Unirest.post(url).fields(request).asString(); if (response == null) { readLinkedEntryResponse = new ReadLinkedEntryResponse(); errorResponse = ErrorResponse.format("An error has occurred!", "No data returned."); readLinkedEntryResponse.setStatusCode(HttpStatus.SC_BAD_REQUEST); readLinkedEntryResponse.setError(errorResponse); } else { jsonResponse = response.getBody().toString(); if (StringUtils.isNotBlank(jsonResponse)) { // First check if we have an error errorResponse = ErrorResponse.fromJson(jsonResponse); if (errorResponse == null) { readLinkedEntryResponse = mapper.readValue(jsonResponse, ReadLinkedEntryResponse.class); } } if (readLinkedEntryResponse == null) { readLinkedEntryResponse = new ReadLinkedEntryResponse(); readLinkedEntryResponse.setError(errorResponse); readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK); if (errorResponse != null) { readLinkedEntryResponse.setStatusCode(errorResponse.getStatusCode()); } } else { readLinkedEntryResponse.setStatusCode(HttpStatus.SC_OK); } } } catch (Exception exception) { readLinkedEntryResponse = new ReadLinkedEntryResponse(); errorResponse = ErrorResponse.format(exception, exception.getMessage()); readLinkedEntryResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); errorResponse.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR); readLinkedEntryResponse.setError(errorResponse); } readLinkedEntryResponse.setJsonRawRequest(jsonRequest); readLinkedEntryResponse.setJsonRawResponse(jsonResponse); return readLinkedEntryResponse; }
From source file:me.smoe.lzy.rest.advice.ExceptionAdvice.java
private String failEntity(Throwable throwable) { Code code = Code.ERROR;/*from www. ja v a 2 s . c o m*/ String message = StringUtils.EMPTY; if (throwable instanceof ServiceException) { ServiceException serviceException = (ServiceException) throwable; code = serviceException.getCode() == null ? Code.BUSINESS_FAIL : serviceException.getCode(); message = serviceException.getMessage(); } return FailResult.toJson(code, message); }
From source file:fr.paris.lutece.plugins.workflow.modules.mappings.business.CodeMappingFilter.java
/** * Constructor */ public CodeMappingFilter() { _strCode = StringUtils.EMPTY; _strLabelCode = StringUtils.EMPTY; _strMappingTypeKey = StringUtils.EMPTY; _strReferenceCode = StringUtils.EMPTY; }
From source file:info.magnolia.cms.gui.dialog.DialogPassword.java
/** * @see info.magnolia.cms.gui.dialog.DialogControl#drawHtml(Writer) *///from w ww.j av a 2 s . c o m public void drawHtml(Writer out) throws IOException { Password control = new Password(this.getName(), this.getValue()); if (this.getConfigValue("saveInfo").equals("false")) { //$NON-NLS-1$ //$NON-NLS-2$ control.setSaveInfo(false); } control.setCssClass(CssConstants.CSSCLASS_EDIT); control.setCssStyles("width", this.getConfigValue("width", "100%")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ control.setEncoding(ControlImpl.ENCODING_BASE64); if (this.getConfigValue("onchange", null) != null) { //$NON-NLS-1$ control.setEvent("onchange", this.getConfigValue("onchange")); //$NON-NLS-1$ //$NON-NLS-2$ } this.drawHtmlPre(out); out.write(control.getHtml()); if (this.getConfigValue("verification", "true").equals("true")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Password control2 = new Password(this.getName() + "_verification", StringUtils.EMPTY); //$NON-NLS-1$ // Password control2=new Password(this.getName()+"_verifiaction",this.getValue()); // control2.setEncoding(ControlImpl.ENCODING_UNIX); control2.setSaveInfo(false); control2.setCssClass(CssConstants.CSSCLASS_EDIT); control2.setCssStyles("width", //$NON-NLS-1$ this.getConfigValue("width", "100%")); //$NON-NLS-1$ //$NON-NLS-2$ control2.setEvent("onchange", //$NON-NLS-1$ "mgnlDialogPasswordVerify('" + this.getName() + "')"); //$NON-NLS-1$ //$NON-NLS-2$ // todo: verification on submit; think about out.write("<div class=\"" //$NON-NLS-1$ + CssConstants.CSSCLASS_DESCRIPTION + "\">" //$NON-NLS-1$ + getMessage("dialog.password.verify") //$NON-NLS-1$ + "</div>"); //$NON-NLS-1$ out.write(control2.getHtml()); } this.drawHtmlPost(out); }
From source file:com.ms.commons.file.excel.ExcelParser.java
@SuppressWarnings({ "deprecation", "unused" }) public String[] splitLine() throws Exception { if (m_iCurrentRow == m_iNbRows) return null; HSSFRow row = m_sheet.getRow(m_iCurrentRow); if (row == null) { return null; } else {/*from w ww. j a v a 2s . com*/ int cellIndex = 0; int noOfCells = row.getPhysicalNumberOfCells(); short firstCellNum = row.getFirstCellNum(); short lastCellNum = row.getLastCellNum(); String[] values = new String[lastCellNum]; if (firstCellNum >= 0 && lastCellNum >= 0) { for (short iCurrent = firstCellNum; iCurrent < lastCellNum; iCurrent++) { HSSFCell cell = (HSSFCell) row.getCell(iCurrent); if (cell == null) { values[iCurrent] = StringUtils.EMPTY; cellIndex++; continue; } else { switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: double value = cell.getNumericCellValue(); if (HSSFDateUtil.isCellDateFormatted(cell)) { if (HSSFDateUtil.isValidExcelDate(value)) { Date date = HSSFDateUtil.getJavaDate(value); SimpleDateFormat dateFormat = new SimpleDateFormat(JAVA_TOSTRING); values[iCurrent] = dateFormat.format(date); } else { throw new Exception("Invalid Date value found at row number " + row.getRowNum() + " and column number " + cell.getCellNum()); } } else { values[iCurrent] = value + StringUtils.EMPTY; } break; case HSSFCell.CELL_TYPE_STRING: values[iCurrent] = cell.getStringCellValue(); break; case HSSFCell.CELL_TYPE_BLANK: values[iCurrent] = null; break; default: values[iCurrent] = null; } } } } m_iCurrentRow++; return values; } }
From source file:eu.europa.esig.dss.client.http.proxy.ProxyPreferenceManager.java
/** * Get list of excluded hosts of the HTTP proxy * * @return comma separated list of hosts *///ww w .ja v a 2 s . com public String getHttpExcludedHosts() { ProxyPreference preference = getProxyDao().get(ProxyKey.HTTP_EXCLUDE); return preference != null ? preference.getValue() : StringUtils.EMPTY; }
From source file:fr.paris.lutece.portal.business.portlet.PortletImpl.java
/** * Must be overloaded to return the Portlet Xml code without the heading XML * * @param request The HTTP servlet request * @return none/*from w w w . ja v a 2 s.co m*/ */ @Override public String getXml(HttpServletRequest request) { return StringUtils.EMPTY; }