List of usage examples for org.apache.commons.lang StringUtils remove
public static String remove(String str, char remove)
Removes all occurrences of a character from within the source string.
From source file:org.eclipse.wb.tests.gef.UiContext.java
/** * Normalizes given {@link String} by removing special characters. *//*from ww w . ja v a2 s . co m*/ private static String normalizeTextForComparing(String s) { s = s.trim(); s = StringUtils.remove(s, '&'); s = StringUtils.substringBefore(s, "\t"); return s; }
From source file:org.ednovo.gooru.core.api.model.UserTransModel.java
public String getUsernameDisplay() { String usernameDisplay = username; if (username == null || username.isEmpty()) { String firstName = ""; if (this.getFirstName() != null) { firstName = this.getFirstName(); firstName = StringUtils.remove(firstName, " "); }/*from ww w . j a v a2 s. c o m*/ String lastName = ""; if (this.getLastName() != null) { lastName = this.getLastName(); } usernameDisplay = firstName; if (lastName.length() > 0) { usernameDisplay = usernameDisplay + lastName.substring(0, 1); } if (usernameDisplay.length() > 20) { usernameDisplay = usernameDisplay.substring(0, 20); } } return usernameDisplay; }
From source file:org.ednovo.gooru.domain.service.authentication.AccountServiceImpl.java
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public User userAuthentication(User newUser, final String secretKey, final String apiKey, final String source, final String userCategory, final HttpServletRequest request) { if (secretKey == null || !secretKey.equalsIgnoreCase(settingService.getConfigSetting( ConfigConstants.GOORU_AUTHENTICATION_SECERT_KEY, 0, TaxonomyUtil.GOORU_ORG_UID))) { throw new UnauthorizedException(generateErrorMessage(GL0082, "secret") + secretKey, GL0082); }//from w w w. j a va 2 s . c o m boolean registerUser = false; final Identity identity = new Identity(); identity.setExternalId(newUser.getEmailId()); User userIdentity = this.getUserService().findByIdentity(identity); UserToken sessionToken = null; if (userIdentity == null) { try { if (newUser.getUsername() == null) { newUser.setFirstName(StringUtils.remove(newUser.getFirstName(), " ")); newUser.setUsername(newUser.getFirstName()); if (newUser.getLastName() != null && newUser.getLastName().length() > 0) { newUser.setUsername(newUser.getUsername() + newUser.getLastName().substring(0, 1)); } final User user = this.getUserRepository().findUserWithoutOrganization(newUser.getUsername()); if (user != null && user.getUsername().equalsIgnoreCase(newUser.getUsername())) { final Random randomNumber = new Random(); newUser.setUsername(newUser.getUsername() + randomNumber.nextInt(1000)); } } userIdentity = this.getUserManagementService().createUser(newUser, null, null, 1, 0, null, null, null, null, null, null, null, source, null, request, userCategory, null); registerUser = true; } catch (Exception e) { LOGGER.error("Error : " + e); } } Identity newIdentity = null; if (userIdentity.getIdentities() != null && userIdentity.getIdentities().size() > 0) { newIdentity = userIdentity.getIdentities().iterator().next(); if (newIdentity != null) { newIdentity.setLoginType(source); newIdentity.setLastLogin(new Date(System.currentTimeMillis())); this.getUserRepository().save(newIdentity); } } if (sessionToken == null) { final Application application = this.getApplicationRepository().getApplication(apiKey); rejectIfNull(application, GL0056, 404, APPLICATION); sessionToken = this.getUserManagementService().createSessionToken(userIdentity, request.getSession().getId(), application); } request.getSession().setAttribute(Constants.SESSION_TOKEN, sessionToken.getToken()); if (!registerUser) { try { this.getAccountEventlog().getEventLogs(newIdentity, sessionToken, true); indexHandler.setReIndexRequest(userIdentity.getPartyUid(), IndexProcessor.INDEX, USER, sessionToken.getToken(), false, false); } catch (JSONException e) { LOGGER.error("Error : " + e); } } try { newUser = (User) BeanUtils.cloneBean(userIdentity); } catch (Exception e) { LOGGER.error("Error : " + e); } request.getSession().setAttribute(Constants.USER, newUser); newUser.setToken(sessionToken.getToken()); request.getSession().setAttribute(Constants.SESSION_TOKEN, sessionToken.getToken()); if (sessionToken.getApplication() != null) { request.getSession().setAttribute(Constants.APPLICATION_KEY, sessionToken.getApplication().getKey()); } return newUser; }
From source file:org.egov.lib.rrbac.filter.RuleInterceptorFilter.java
/** * Gets the action.// w ww . j a v a 2 s. com * @param request the request * @return the action */ private Action getAction(final HttpServletRequest request) { Action action; final String actionId = request.getParameter("actionid"); if ((actionId == null) || (actionId.length() == 0)) { final String contextPath = request.getContextPath(); final String requestURI = StringUtils.remove(request.getRequestURI(), contextPath); action = this.actionService.getActionByUrlAndContextRoot(requestURI, StringUtils.remove(contextPath, '/')); } else { action = (Action) this.actionService.getActionById(Long.valueOf(actionId)); } return action; }
From source file:org.egov.ptis.workflow.filter.ActionsBasedOnWorkFlowFilter.java
private Action getAction(HttpServletRequest request) { Action action;/*w w w .j ava2 s. c om*/ String actionId = request.getParameter("actionid"); if (actionId == null || actionId.length() == 0) { String requestURI = request.getRequestURI(); String contextPath = request.getContextPath(); requestURI = StringUtils.remove(requestURI, contextPath); action = actionService.getActionByUrlAndContextRoot(requestURI, StringUtils.remove(contextPath, '/')); } else { action = actionService.getActionById(Long.valueOf(actionId)); } return action; }
From source file:org.exoplatform.cms.Utils.java
public static boolean isValidEmailAddresses(String addressList) throws Exception { if (isEmpty(addressList)) return true; addressList = StringUtils.remove(addressList, " "); addressList = StringUtils.replace(addressList, ";", ","); try {//from w ww .j a v a2 s .com InternetAddress[] iAdds = InternetAddress.parse(addressList, true); String emailRegex = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[_A-Za-z0-9-.]+\\.[A-Za-z]{2,5}"; for (int i = 0; i < iAdds.length; i++) { if (!iAdds[i].getAddress().matches(emailRegex)) return false; } } catch (AddressException e) { return false; } return true; }
From source file:org.exoplatform.contact.CalendarUtils.java
public static boolean isValidEmailAddresses(String value) { if (isEmpty(value)) return true; value = StringUtils.remove(value, " "); value = StringUtils.replace(value, SEMICOLON, COMMA); try {//from w ww .j a v a 2s. c om InternetAddress[] iAdds = InternetAddress.parse(value, true); String emailRegex = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[_A-Za-z0-9-.]+\\.[A-Za-z]{2,6}"; for (int i = 0; i < iAdds.length; i++) { if (!iAdds[i].getAddress().matches(emailRegex)) return false; } } catch (AddressException e) { return false; } return true; }
From source file:org.exoplatform.forum.common.webui.UIPermissionPanel.java
public static String[] splitValues(String str) { if (CommonUtils.isEmpty(str) == false) { str = StringUtils.remove(str, CommonUtils.SPACE); if (str.contains(CommonUtils.COMMA)) { str = str.replaceAll(CommonUtils.SEMICOLON, CommonUtils.COMMA); return str.trim().split(CommonUtils.COMMA); } else {//from w ww.j a v a 2s . com str = str.replaceAll(CommonUtils.COMMA, CommonUtils.SEMICOLON); return str.trim().split(CommonUtils.SEMICOLON); } } else return new String[] { CommonUtils.EMPTY_STR }; }
From source file:org.exoplatform.forum.ForumUtils.java
public static boolean isValidEmailAddresses(String addressList) { if (isEmpty(addressList)) return true; addressList = StringUtils.remove(addressList, " "); addressList = StringUtils.replace(addressList, ";", COMMA); try {/*w w w . j a v a 2 s . co m*/ InternetAddress[] iAdds = InternetAddress.parse(addressList, true); String emailRegex = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[_A-Za-z0-9-.]+\\.[A-Za-z]{2,5}"; for (int i = 0; i < iAdds.length; i++) { if (!iAdds[i].getAddress().matches(emailRegex)) return false; } } catch (AddressException e) { return false; } return true; }
From source file:org.exoplatform.forum.ForumUtils.java
public static String[] splitForForum(String str) { if (!isEmpty(str)) { str = StringUtils.remove(str, " "); if (str.contains(COMMA)) { str = str.replaceAll(";", COMMA); return str.trim().split(COMMA); } else {//from w w w . j a v a 2 s .c om str = str.replaceAll(COMMA, ";"); return str.trim().split(";"); } } else return new String[] { EMPTY_STR }; }