List of usage examples for com.liferay.portal.kernel.util StringUtil toLowerCase
public static String toLowerCase(String s)
From source file:com.bemis.portal.customer.service.impl.CustomerProfileLocalServiceImpl.java
License:Open Source License
protected String formatCountryName(String countryName) { return StringUtil.toLowerCase(countryName.replace(StringPool.SPACE, StringPool.DASH)); }
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static void collectPartContent(Part part, MBMailMessage mbMailMessage) throws Exception { Object partContent = part.getContent(); String contentType = StringUtil.toLowerCase(part.getContentType()); if ((part.getDisposition() != null) && StringUtil.equalsIgnoreCase(part.getDisposition(), MimeMessage.ATTACHMENT)) { if (_log.isDebugEnabled()) { _log.debug("Processing attachment"); }/*from ww w. ja va 2s .co m*/ byte[] bytes = null; if (partContent instanceof String) { bytes = ((String) partContent).getBytes(); } else if (partContent instanceof InputStream) { bytes = JavaMailUtil.getBytes(part); } mbMailMessage.addBytes(part.getFileName(), bytes); } else { if (partContent instanceof MimeMultipart) { MimeMultipart mimeMultipart = (MimeMultipart) partContent; collectMultipartContent(mimeMultipart, mbMailMessage); } else if (partContent instanceof String) { Map<String, Object> options = new HashMap<String, Object>(); options.put("emailPartToMBMessageBody", Boolean.TRUE); String messageBody = SanitizerUtil.sanitize(0, 0, 0, MBMessage.class.getName(), 0, contentType, Sanitizer.MODE_ALL, (String) partContent, options); if (contentType.startsWith(ContentTypes.TEXT_HTML)) { mbMailMessage.setHtmlBody(messageBody); } else { mbMailMessage.setPlainBody(messageBody); } } } }
From source file:com.custom.portal.security.ldap.CustomDefaultLDAPToPortalConverter.java
License:Open Source License
@Override public CustomLDAPUser importLDAPUser(long companyId, Attributes attributes, Properties userMappings, Properties userExpandoMappings, Properties contactMappings, Properties contactExpandoMappings, String password) throws Exception { boolean autoScreenName = PrefsPropsUtil.getBoolean(companyId, PropsKeys.USERS_SCREEN_NAME_ALWAYS_AUTOGENERATE); String screenName = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.SCREEN_NAME) .toLowerCase();//w ww. j a v a2s . c o m String emailAddress = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.EMAIL_ADDRESS); if (_log.isDebugEnabled()) { _log.debug("Screen name " + screenName + " and email address " + emailAddress); } String firstName = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.FIRST_NAME); String middleName = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.MIDDLE_NAME); String lastName = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.LAST_NAME); if (Validator.isNull(firstName) || Validator.isNull(lastName)) { String fullName = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.FULL_NAME); FullNameGenerator fullNameGenerator = FullNameGeneratorFactory.getInstance(); String[] names = fullNameGenerator.splitFullName(fullName); firstName = names[0]; middleName = names[1]; lastName = names[2]; } if (!autoScreenName && Validator.isNull(screenName)) { throw new UserScreenNameException("Screen name cannot be null for " + ContactConstants.getFullName(firstName, middleName, lastName)); } if (Validator.isNull(emailAddress) && PrefsPropsUtil.getBoolean(companyId, PropsKeys.USERS_EMAIL_ADDRESS_REQUIRED)) { throw new UserEmailAddressException("Email address cannot be null for " + ContactConstants.getFullName(firstName, middleName, lastName)); } CustomLDAPUser ldapUser = new CustomLDAPUser(); ldapUser.setAutoPassword(password.equals(StringPool.BLANK)); ldapUser.setAutoScreenName(autoScreenName); Contact contact = ContactUtil.create(0); int prefixId = getListTypeId(attributes, contactMappings, ContactConverterKeys.PREFIX, ListTypeConstants.CONTACT_PREFIX); contact.setPrefixId(prefixId); int suffixId = getListTypeId(attributes, contactMappings, ContactConverterKeys.SUFFIX, ListTypeConstants.CONTACT_SUFFIX); contact.setSuffixId(suffixId); String gender = LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.GENDER); gender = StringUtil.toLowerCase(gender); if (GetterUtil.getBoolean(gender) || gender.equals("female")) { contact.setMale(false); } else { contact.setMale(true); } try { Date birthday = DateUtil.parseDate( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.BIRTHDAY), LocaleUtil.getDefault()); contact.setBirthday(birthday); } catch (ParseException pe) { Calendar birthdayCalendar = CalendarFactoryUtil.getCalendar(1970, Calendar.JANUARY, 1); contact.setBirthday(birthdayCalendar.getTime()); } contact.setSmsSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.SMS_SN)); contact.setAimSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.AIM_SN)); contact.setFacebookSn( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.FACEBOOK_SN)); contact.setIcqSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.ICQ_SN)); contact.setJabberSn( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.JABBER_SN)); contact.setMsnSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.MSN_SN)); contact.setMySpaceSn( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.MYSPACE_SN)); contact.setSkypeSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.SKYPE_SN)); contact.setTwitterSn( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.TWITTER_SN)); contact.setYmSn(LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.YM_SN)); contact.setJobTitle( LDAPUtil.getAttributeString(attributes, contactMappings, ContactConverterKeys.JOB_TITLE)); ldapUser.setContact(contact); Map<String, String[]> contactExpandoAttributes = getExpandoAttributes(attributes, contactExpandoMappings); ldapUser.setContactExpandoAttributes(contactExpandoAttributes); Phone phone = PhoneUtil.create(0); phone.setNumber( (LDAPUtil.getAttributeString(attributes, contactMappings, CustomContactConverterKeys.PHONE))); ldapUser.setPhone(phone); Address address = AddressUtil.create(0); address.setCity( (LDAPUtil.getAttributeString(attributes, contactMappings, CustomContactConverterKeys.CITY))); address.setZip((LDAPUtil.getAttributeString(attributes, contactMappings, CustomContactConverterKeys.ZIP))); address.setStreet1( (LDAPUtil.getAttributeString(attributes, contactMappings, CustomContactConverterKeys.STREET))); ldapUser.setAddress(address); ldapUser.setCreatorUserId(0); ldapUser.setGroupIds(null); ldapUser.setOrganizationIds(null); ldapUser.setPasswordReset(false); Object portrait = LDAPUtil.getAttributeObject(attributes, userMappings.getProperty(UserConverterKeys.PORTRAIT)); if (portrait != null) { byte[] portraitBytes = (byte[]) portrait; if (portraitBytes.length > 0) { ldapUser.setPortraitBytes((byte[]) portrait); } ldapUser.setUpdatePortrait(true); } ldapUser.setRoleIds(null); ldapUser.setSendEmail(false); ServiceContext serviceContext = new ServiceContext(); String uuid = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.UUID); serviceContext.setUuid(uuid); ldapUser.setServiceContext(serviceContext); ldapUser.setUpdatePassword(!password.equals(StringPool.BLANK)); User user = UserUtil.create(0); user.setCompanyId(companyId); user.setEmailAddress(emailAddress); user.setFirstName(firstName); String jobTitle = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.JOB_TITLE); user.setJobTitle(jobTitle); Locale locale = LocaleUtil.getDefault(); user.setLanguageId(locale.toString()); user.setLastName(lastName); user.setMiddleName(middleName); user.setOpenId(StringPool.BLANK); user.setPasswordUnencrypted(password); user.setScreenName(screenName); String status = LDAPUtil.getAttributeString(attributes, userMappings, UserConverterKeys.STATUS); if (Validator.isNotNull(status)) { user.setStatus(GetterUtil.getInteger(status)); } ldapUser.setUser(user); Map<String, String[]> userExpandoAttributes = getExpandoAttributes(attributes, userExpandoMappings); ldapUser.setUserExpandoAttributes(userExpandoAttributes); ldapUser.setUserGroupIds(null); ldapUser.setUserGroupRoles(null); return ldapUser; }
From source file:com.idetronic.subur.service.impl.ExpertiseLocalServiceImpl.java
License:Open Source License
@Override public Expertise addExpertise(long userId, String name, ServiceContext serviceContext) throws SystemException, PortalException { User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); Date now = new Date(); long expertiseId = CounterLocalServiceUtil.increment(Expertise.class.getName()); Expertise expertise = expertisePersistence.create(expertiseId); expertise.setGroupId(groupId);/*w w w . j a v a2 s. c o m*/ expertise.setCompanyId(user.getCompanyId()); expertise.setUserId(userId); ; expertise.setCreateDate(now); expertise.setModifiedDate(now); name = StringUtil.trim(name); validate(name); expertise.setName(name); expertise.setIndexedName(StringUtil.toLowerCase(name)); expertisePersistence.update(expertise); return expertise; }
From source file:com.idetronic.subur.service.impl.ResearchInterestLocalServiceImpl.java
License:Open Source License
@Override public ResearchInterest addResearchInterest(long userId, String name, ServiceContext serviceContext) throws SystemException, PortalException { User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); Date now = new Date(); long researchInterestId = CounterLocalServiceUtil.increment(ResearchInterest.class.getName()); ResearchInterest researchInterest = researchInterestPersistence.create(researchInterestId); researchInterest.setGroupId(groupId); researchInterest.setCompanyId(user.getCompanyId()); researchInterest.setUserId(userId);//from w w w .j av a2 s .c o m ; researchInterest.setCreateDate(now); researchInterest.setModifiedDate(now); name = StringUtil.trim(name); validate(name); researchInterest.setName(name); researchInterest.setIndexedName(StringUtil.toLowerCase(name)); researchInterestPersistence.update(researchInterest); return researchInterest; }
From source file:com.liferay.adaptive.media.blogs.internal.exportimport.data.handler.test.AMBlogsEntryStagedModelDataHandlerTest.java
License:Open Source License
private void _assertHTMLEquals(String expectedHTML, String actualHTML) throws Exception { Assert.assertEquals(_removeSpacing(StringUtil.toLowerCase(expectedHTML)), _removeSpacing(StringUtil.toLowerCase(actualHTML))); }
From source file:com.liferay.adaptive.media.image.content.transformer.internal.HtmlContentTransformerImplTest.java
License:Open Source License
@Test public void testTheAttributeIsCaseInsensitive() throws Exception { Mockito.when(_adaptiveMediaImageHTMLTagFactory.create("<img data-fileentryid=\"1989\" src=\"adaptable\"/>", _fileEntry)).thenReturn("<whatever></whatever>"); StringBundler expectedSB = new StringBundler(5); expectedSB.append("<div><div><whatever></whatever></div></div><br/>"); StringBundler originalSB = new StringBundler(4); originalSB.append("<div><div>"); originalSB.append("<img data-fileEntryId=\"1989\" "); originalSB.append("src=\"adaptable\"/>"); originalSB.append("</div></div><br/>"); Assert.assertEquals(expectedSB.toString(), _htmlContentTransformer.transform(StringUtil.toLowerCase(originalSB.toString()))); }
From source file:com.liferay.akismet.hook.service.impl.AkismetMBMessageLocalServiceImpl.java
License:Open Source License
protected AkismetData updateAkismetData(MBMessage message, ServiceContext serviceContext) { if (!AkismetUtil.hasRequiredInfo(serviceContext)) { return null; }/*ww w . j a va2 s .c o m*/ String permalink = getPermalink(message, serviceContext); Map<String, String> headers = serviceContext.getHeaders(); String referrer = headers.get("referer"); String userAgent = headers.get(StringUtil.toLowerCase(HttpHeaders.USER_AGENT)); String userIP = serviceContext.getRemoteAddr(); return AkismetDataLocalServiceUtil.updateAkismetData(MBMessage.class.getName(), message.getMessageId(), AkismetConstants.TYPE_COMMENT, permalink, referrer, userAgent, userIP, StringPool.BLANK); }
From source file:com.liferay.akismet.hook.service.impl.AkismetWikiPageLocalServiceImpl.java
License:Open Source License
protected AkismetData updateAkismetData(WikiPage page, ServiceContext serviceContext) { if (!AkismetUtil.hasRequiredInfo(serviceContext)) { return null; }/*from w ww.jav a2 s . c om*/ String permalink = getPermalink(page, serviceContext); Map<String, String> headers = serviceContext.getHeaders(); String referrer = headers.get("referer"); String userAgent = headers.get(StringUtil.toLowerCase(HttpHeaders.USER_AGENT)); String userIP = serviceContext.getRemoteAddr(); return AkismetDataLocalServiceUtil.updateAkismetData(WikiPage.class.getName(), page.getPageId(), AkismetConstants.TYPE_WIKI, permalink, referrer, userAgent, userIP, StringPool.BLANK); }
From source file:com.liferay.akismet.util.AkismetUtil.java
License:Open Source License
public static boolean hasRequiredInfo(ServiceContext serviceContext) { Map<String, String> headers = serviceContext.getHeaders(); if (headers == null) { return false; }/* ww w . j a v a2 s .co m*/ String userAgent = headers.get(StringUtil.toLowerCase(HttpHeaders.USER_AGENT)); if (Validator.isNull(userAgent)) { return false; } String userIP = serviceContext.getRemoteAddr(); if (Validator.isNull(userIP)) { return false; } return true; }