List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:hudson.plugins.sonar.model.LightProjectConfig.java
public String getProjectVersion() { return StringUtils.trimToEmpty(projectVersion); }
From source file:com.edgenius.wiki.ext.todo.TodoHandler.java
public List<RenderPiece> handle(RenderContext renderContext, Map<String, String> values) throws RenderHandlerException { if (values == null || StringUtils.isBlank(values.get(NameConstants.NAME))) { throw new RenderHandlerException("TODO must have a name, i.e., {todo:name=work}"); }/*from w ww .java 2 s .co m*/ try { //get unique index ID for same page Todos render Integer pageKey = (Integer) renderContext.getGlobalParam(TodoHandler.class.getName()); if (pageKey == null) pageKey = 1; else ++pageKey; renderContext.putGlobalParam(TodoHandler.class.getName(), pageKey); String todoName = values.get(NameConstants.NAME).trim(); String statusString = StringUtils.trimToEmpty(values.get("status")); String deleteAction = StringUtils.trimToEmpty(values.get("deleteon")); Map<String, Object> map = new HashMap<String, Object>(); //keep original markup - but not put it into wajax attribute map.put("todoMarkup", values.remove("markup")); map.put("todoWajax", RichTagUtil.buildWajaxAttributeString(this.getClass().getName(), values)); map.put("readonly", !editable); map.put("pageUuid", renderContext.getPageUuid()); map.put("todoKey", pageKey); map.put("todoName", todoName); map.put("statuses", statusString); map.put("deleteAction", deleteAction); Todo todo = todoService.getTodoByName(renderContext.getPageUuid(), todoName); if (todo == null) { todo = new Todo(); } todo.setStatusString(statusString, deleteAction); todoService.fillTodosAndStatuses(map, todo); return Arrays .asList((RenderPiece) new TextModel(pluginService.renderMacro("todo", map, renderContext))); } catch (PluginRenderException e) { throw new RenderHandlerException("Todo can't be rendered."); } }
From source file:com.hangum.tadpole.rdb.core.editors.main.utils.ExtMakeContentAssistUtil.java
/** * make content assist util/*from w ww.ja va 2 s .c o m*/ * * @param userDB * @param strQuery * @param intPosition * @return */ public String makeContentAssist(final UserDBDAO userDB, String strQuery, final int intPosition) throws Exception { strQuery = StringUtils.replace(strQuery, "\n", " "); String listContentAssist = ""; // ? String[] strPrevArryCursor = SQLTextUtil.findPreCursorObjectArry(strQuery, intPosition); String strCursor = strPrevArryCursor[0] + strPrevArryCursor[1]; if (logger.isDebugEnabled()) logger.debug("\t position text is [" + strCursor + "]"); // ? . String strPrevKeyword = SQLTextUtil.findPrevKeywork(strQuery, intPosition); if (logger.isDebugEnabled()) logger.debug("\t prevous keyword is : [" + strPrevKeyword + "]"); CONTENT_ASSIST_KEYWORD_TYPE prevKeywordType = null; // ? ? . strQuery = StringUtils.removeEnd(StringUtils.trimToEmpty(strQuery), ";") + " "; // ? ? ? ?, ? . if (!"".equals(strPrevKeyword)) { if (SQLConstants.listTableKeywords.contains(strPrevKeyword)) { prevKeywordType = CONTENT_ASSIST_KEYWORD_TYPE.TABLE; } else if (SQLConstants.listColumnKeywords.contains(strPrevKeyword)) { prevKeywordType = CONTENT_ASSIST_KEYWORD_TYPE.COLUMN; } } if (prevKeywordType != null) { if (strCursor.length() == 0) { // ?? ?? . if (prevKeywordType == CONTENT_ASSIST_KEYWORD_TYPE.COLUMN) { if (logger.isDebugEnabled()) logger.debug("==========[0][CURSOR][COLUMN] content assist : "); listContentAssist = getTableColumnAlias(userDB, strQuery, strCursor); // ? ?? . } else { if (logger.isDebugEnabled()) logger.debug("==========[0][CURSOR][TABLE] content assist : "); // insert ? ? ? . listContentAssist = ifInsertGetColumn(userDB, strQuery, strCursor); // ? ? ?? . if ("".equals(listContentAssist)) { listContentAssist = getSchemaOrTableContentAssist(userDB, strPrevArryCursor); } } if (logger.isDebugEnabled()) logger.debug("\t result : " + listContentAssist); } else { // ?? ?? . if (prevKeywordType == CONTENT_ASSIST_KEYWORD_TYPE.COLUMN) { if (logger.isDebugEnabled()) logger.debug("+++++++++++[1][DEFAULT][COLUMN] content assist : " + listContentAssist); listContentAssist = getTableColumnAlias(userDB, strQuery, strCursor); } else { // ?, ? ?, ?? . if (logger.isDebugEnabled()) logger.debug("+++++++++++[1][DEFAULT][TABLE] content assist : " + listContentAssist); // insert ? ? ? . listContentAssist = ifInsertGetColumn(userDB, strQuery, strCursor); // ? ? ?? . if ("".equals(listContentAssist)) { listContentAssist = getSchemaOrTableContentAssist(userDB, strPrevArryCursor); } } if (logger.isDebugEnabled()) logger.debug("\t result : " + listContentAssist); } } else { if (logger.isDebugEnabled()) logger.debug("[NONE] content assist : " + listContentAssist); } return listContentAssist; }
From source file:ch.entwine.weblounge.kernel.security.SpringSecurityFormAuthentication.java
/** * {@inheritDoc}/*from w ww . j a va 2 s .c om*/ * * @see org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter#attemptAuthentication(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (postOnly && !"POSTS".equals(request.getMethod())) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); } // Get the username String username = StringUtils.trimToEmpty(request.getParameter(SPRING_SECURITY_FORM_USERNAME_KEY)); // Get the password String password = request.getParameter(SPRING_SECURITY_FORM_PASSWORD_KEY); if (password == null) { password = ""; } // Using the extracted credentials, create an authentication request UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); // Place the last username attempted into HttpSession for views HttpSession session = request.getSession(false); if (session != null || getAllowSessionCreation()) { request.getSession().setAttribute(SPRING_SECURITY_LAST_USERNAME_KEY, TextEscapeUtils.escapeEntities(username)); } return this.getAuthenticationManager().authenticate(authRequest); }
From source file:hudson.plugins.sonar.SonarRunner.java
private static void appendMaskedArg(ArgumentListBuilder args, String name, String value) { value = StringUtils.trimToEmpty(value); if (StringUtils.isNotEmpty(value)) { args.addMasked("-D" + name + "=" + value); }/*from ww w . jav a 2 s .co m*/ }
From source file:com.learningobjects.community.abgm.servlet.ConfigServlet.java
private void doUpdate(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info("Updating configuration"); String updateMessage = ""; try {//from ww w. j ava2s.com SystemProperties sp = SystemProperties.getInstance(); sp.setProperty("scheduleType", StringUtils.trimToEmpty(request.getParameter("scheduleType"))); sp.setProperty("standardSchedule", StringUtils.trimToEmpty(request.getParameter("standardSchedule"))); sp.setProperty("customSchedule", StringUtils.trimToEmpty(request.getParameter("customSchedule"))); if (sp.getProperty("scheduleType").equals("standard")) { sp.setProperty("schedule", StringUtils.trimToEmpty(request.getParameter("standardSchedule"))); } else { sp.setProperty("schedule", StringUtils.trimToEmpty(request.getParameter("customSchedule"))); } sp.setProperty("groupFileLocation", StringUtils.trimToEmpty(request.getParameter("groupFileLocation"))); sp.setProperty("groupMembershipFileLocation", StringUtils.trimToEmpty(request.getParameter("groupMembershipFileLocation"))); sp.setUpdateExistingGroups( "yes".equals(StringUtils.trimToEmpty(request.getParameter("updateExistingGroups")))); String logFileLocation = StringUtils.trimToEmpty(request.getParameter("logFileLocation")); File logDirectory = new File(logFileLocation); if ((logDirectory.isDirectory() || logDirectory.mkdirs()) && LoggerFactory.setLoggingDirectory(logDirectory)) { sp.setProperty("logFileLocation", logFileLocation); } else { updateMessage += "The logging directory was not updated as the directory does not exist and could not be created."; } sp.store(); for (Entry<Object, Object> e : sp.entrySet()) { logger.config(e.getKey() + " = " + e.getValue()); } // update quartz SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory(); Scheduler scheduler = schedFact.getScheduler(); scheduler.deleteJob("myJob", Scheduler.DEFAULT_GROUP); if (sp.getProperty("schedule", "").length() > 0) { JobDetail jobDetail = new JobDetail("myJob", Scheduler.DEFAULT_GROUP, ControllerJob.class); CronTrigger trigger = new CronTrigger("myTrigger", Scheduler.DEFAULT_GROUP, SystemProperties.getInstance().getProperty("schedule")); trigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING); scheduler.scheduleJob(jobDetail, trigger); } logger.info("Configuration successfully updated"); sendReceipt(request, response, updateMessage.length() == 0 ? "The changes have been applied successfully." : updateMessage, true, null); } catch (SchedulerException e) { sendReceipt(request, response, "There was an error processing your request", false, e); logger.log(Level.WARNING, "There was an error updating the configuration", e); } catch (ParseException e) { sendReceipt(request, response, "There was an error processing your request", false, e); logger.log(Level.WARNING, "There was an error updating the configuration", e); } catch (FileNotFoundException e) { sendReceipt(request, response, "There was an error processing your request", false, e); logger.log(Level.WARNING, "There was an error updating the configuration", e); } catch (IOException e) { sendReceipt(request, response, "There was an error processing your request", false, e); logger.log(Level.WARNING, "There was an error updating the configuration", e); } }
From source file:hudson.plugins.sonar.model.LightProjectConfig.java
public String getProjectDescription() { return StringUtils.trimToEmpty(projectDescription); }
From source file:com.edgenius.wiki.gwt.server.SearchControllerImpl.java
public SearchResultModel search(QueryModel query, int selectPageNumber, int returnCount) { SearchResultModel model = new SearchResultModel(); try {/*from ww w. j a v a2 s . c om*/ List<String> adv = new ArrayList<String>(); if (query.keywordType != 0) { adv.add(Character.valueOf(SearchService.ADV_KEYWORD_TYPE).toString() + query.keywordType); } if (!StringUtils.isBlank(query.from)) { adv.add(Character.valueOf(SearchService.ADV_DATE_SCOPE).toString() + StringUtils.trimToEmpty(query.from) + ":" + StringUtils.trimToEmpty(query.to)); } if (!StringUtils.isBlank(query.space)) { adv.add(Character.valueOf(SearchService.ADV_SPACE).toString() + StringUtils.trimToEmpty(query.space)); } if (query.type != 0) { adv.add(Character.valueOf(SearchService.ADV_SOURCE_TYPES).toString() + query.type); } if (query.sortBy != 0) { adv.add(Character.valueOf(SearchService.ADV_GROUP_BY).toString() + query.sortBy); } String[] advQ = null; if (adv.size() > 0) advQ = adv.toArray(new String[adv.size()]); SearchResult searchResult = searchService.search(query.keyword, selectPageNumber, returnCount, WikiUtil.getUser(), advQ); SearchUtil.copyResultToModel(searchResult, model); return model; } catch (SearchException e) { model.errorCode = ErrorCode.SEARCH_ERROR; return model; } }
From source file:com.egt.data.general.xdp3.ElementoSegmentoCachedRowSetDataProvider3.java
@Override public String getComandoSelect() { Bitacora.trace(this.getClass(), "getComandoSelect", tablaRecursoCombinado, columnaIdentificacionRecursoCombinado, columnaCodigoRecursoCombinado, columnaNombreRecursoCombinado); /**//* ww w .j a v a 2 s.c o m*/ String base = "consulta_" + this.getTablaDestino() + "_1"; String cisb = COLUMNA_ID_SEGMENTO; String ccsb = "codigo_segmento"; String cnsb = "nombre_segmento"; /**/ String join = StringUtils.trimToEmpty(tablaRecursoCombinado); String circ = StringUtils.trimToEmpty(columnaIdentificacionRecursoCombinado); String ccrc = StringUtils.trimToEmpty(columnaCodigoRecursoCombinado); String cnrc = StringUtils.trimToEmpty(columnaNombreRecursoCombinado); /**/ String c; /**/ if (StringUtils.isBlank(join) || StringUtils.isBlank(circ)) { c = super.getComandoSelect(); } else if (StringUtils.isBlank(ccrc) && StringUtils.isBlank(cnrc)) { c = super.getComandoSelect(); } else { c = "SELECT"; /**/ c += c1(base, COLUMNA_ID_ELEMENTO_SEGMENTO); c += c1(base, COLUMNA_VERSION_ELEMENTO_SEGMENTO); c += c1(base, COLUMNA_ID_CONJUNTO_SEGMENTO); /**/ c += c1(base, "codigo_conjunto_segmento_1x1y3"); c += c1(base, "nombre_conjunto_segmento_1x1y4"); c += c1(base, "descripcion_conjunto_seg_1x1y5"); c += c1(base, "id_clase_recurso_1x1y6"); /**/ c += c1(base, COLUMNA_ID_SEGMENTO); c += c1(base, COLUMNA_VALOR_SEGMENTO); c += c1(base, COLUMNA_SIGNIFICADO_SEGMENTO); /**/ if (StringUtils.isBlank(ccrc)) { c += c1(base, ccsb); } else { c += c3(join, ccrc, ccsb); } if (StringUtils.isBlank(cnrc)) { c += c1(base, cnsb); } else { c += c3(join, cnrc, cnsb); } c = StringUtils.chomp(c, ","); c += " FROM " + base + " LEFT OUTER JOIN " + join; c += " ON " + join + "." + circ + " = " + base + "." + cisb; c += " "; } return c; }
From source file:com.vangent.hieos.services.xds.bridge.mapper.ContentParser.java
/** * Method description/*from w w w . ja va 2 s .c o m*/ * * * * @param elem * @param expr * @param prefixes * @param uris * * @return * * @throws XPathHelperException */ private String parseText(OMElement elem, String expr, String[] prefixes, String[] uris) throws XPathHelperException { String result = XPathHelper.stringValueOf(elem, expr, prefixes, uris); return StringUtils.trimToEmpty(result); }