List of usage examples for com.liferay.portal.kernel.util StringPool QUOTE
String QUOTE
To view the source code for com.liferay.portal.kernel.util StringPool QUOTE.
Click Source Link
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testAddCalendarBookingDoesNotNotifyCreatorTwice() throws Exception { ServiceContext serviceContext = createServiceContext(); _invitingUser = UserTestUtil.addUser(); Calendar calendar = CalendarTestUtil.addCalendar(_invitingUser, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(_user, serviceContext); long startTime = System.currentTimeMillis() + Time.MINUTE; long endTime = startTime + Time.HOUR; long firstReminder = Time.MINUTE; serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingTestUtil.addCalendarBooking(_invitingUser, calendar, new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), startTime, endTime, null, (int) firstReminder, NotificationType.EMAIL, 0, NotificationType.EMAIL, serviceContext); CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking, CalendarBookingWorkflowConstants.STATUS_APPROVED, serviceContext); CalendarBookingLocalServiceUtil.checkCalendarBookings(); String mailMessageSubject = "Calendar: Event Reminder for " + StringPool.QUOTE + calendarBooking.getTitle(LocaleUtil.getDefault()) + StringPool.QUOTE; List<com.dumbster.smtp.MailMessage> mailMessages = MailServiceTestUtil.getMailMessages("Subject", mailMessageSubject);/*from www .ja v a 2s . c o m*/ Assert.assertEquals(mailMessages.toString(), 2, mailMessages.size()); }
From source file:com.liferay.dynamic.data.mapping.form.evaluator.impl.internal.functions.CallFunction.java
License:Open Source License
protected Object createResultMapValue(String token, Map<String, String[]> outputParameterNameToPathsMap) { String[] paths = GetterUtil.getStringValues(outputParameterNameToPathsMap.get(token)); if (isKeyValueMapping(paths)) { return createKeyValueMappingJSONObject(paths); }//w w w. ja va 2s. com try { token = token.replace(StringPool.APOSTROPHE, StringPool.QUOTE); return _jsonFactory.createJSONObject(token); } catch (JSONException jsone) { if (_log.isDebugEnabled()) { _log.debug(jsone, jsone); } return token; } }
From source file:com.liferay.jira.metrics.client.JiraClientImpl.java
License:Open Source License
protected static int getIssuesMetricsByProjectStatusComponentPriority(Project project, String statusName, BasicComponent component, Priority priority) throws JiraConnectionException { StringBundler sb = new StringBundler(19); sb.append(PortletPropsValues.JIRA_BASE_QUERY); sb.append(" AND project = "); sb.append(project.getKey());// ww w.j a v a 2 s. c o m sb.append(" AND status = "); sb.append(StringPool.QUOTE); sb.append(statusName); sb.append(StringPool.QUOTE); sb.append(" AND component = "); sb.append(StringPool.QUOTE); sb.append(component.getName()); sb.append(StringPool.QUOTE); sb.append(" AND "); sb.append(StringPool.QUOTE); sb.append("Fix Priority"); sb.append(StringPool.QUOTE); if (priority == null) { sb.append(" IS EMPTY"); } else { sb.append(" = "); sb.append(StringPool.QUOTE); sb.append(priority.getId()); sb.append(StringPool.QUOTE); } SearchRestClient searchClient = _getClient().getSearchClient(); Promise<SearchResult> promise = searchClient.searchJql(sb.toString()); int total = 0; try { SearchResult result = promise.claim(); total = result.getTotal(); } catch (Exception e) { _log.error("Exception when trying to obtain a result for the query [ " + sb.toString() + "] : " + e.getMessage(), e); } return total; }
From source file:com.liferay.jira.metrics.util.graph.GraphData.java
License:Open Source License
protected void concatQuotedAttribute(StringBundler sb, String attributeName, String attributeValue) { sb.append(attributeName);//from w w w . j a v a 2s . co m sb.append(StringPool.COLON); sb.append(StringPool.QUOTE); sb.append(attributeValue); sb.append(StringPool.QUOTE); }
From source file:com.liferay.knowledgebase.admin.importer.util.KBArticleImporterUtil.java
License:Open Source License
public static String extractImageFileName(String html) { String imageSrc = null;//w w w .j a v a 2 s. com String[] lines = StringUtil.split(html, StringPool.QUOTE); for (int i = 0; i < lines.length; i++) { if (lines[i].endsWith("src=")) { if ((i + 1) < lines.length) { imageSrc = lines[i + 1]; } break; } } if (Validator.isNull(imageSrc)) { if (_log.isWarnEnabled()) { _log.warn("Missing src attribute for image " + html); } return null; } String[] paths = StringUtil.split(imageSrc, StringPool.SLASH); if (paths.length < 1) { if (_log.isWarnEnabled()) { _log.warn("Expected image file path to contain a slash " + html); } return null; } return paths[paths.length - 1]; }
From source file:com.liferay.message.boards.parser.bbcode.internal.HtmlBBCodeTranslatorImpl.java
License:Open Source License
protected void handleImageAttributes(StringBundler sb, String attributes) { Matcher matcher = _attributesPattern.matcher(attributes); while (matcher.find()) { String attributeName = matcher.group(1); if (Validator.isNotNull(attributeName) && _imageAttributes.contains(StringUtil.toLowerCase(attributeName))) { String attributeValue = matcher.group(2); sb.append(StringPool.SPACE); sb.append(attributeName);/*w w w. j av a 2 s .co m*/ sb.append(StringPool.EQUAL); sb.append(StringPool.QUOTE); sb.append(HtmlUtil.escapeAttribute(attributeValue)); sb.append(StringPool.QUOTE); } } }
From source file:com.liferay.newsletter.service.impl.NewsletterCampaignLocalServiceImpl.java
License:Open Source License
protected void sendEmail(long contactId, NewsletterCampaign campaign) throws PortalException, SystemException { String passwordString = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_PASSWORD); String userString = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_USER); String host = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST); String port = PortletProps.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_PORT); if (passwordString.isEmpty()) { passwordString = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST); }/*from w w w .jav a 2s .com*/ if (userString.isEmpty()) { userString = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST); } if (host.isEmpty()) { host = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST); } if (port.isEmpty()) { port = PropsUtil.get(PropsKeys.MAIL_SESSION_MAIL_SMTP_HOST); } Properties properties = new Properties(); properties.put(NewsletterConstants.MAIL_TRANSPORT_PROTOCOL, "smtp"); properties.put(NewsletterConstants.MAIL_SMTP_HOST, host); properties.put(NewsletterConstants.MAIL_SMTP_SOCKET_FACTORY_PORT, port); properties.put(NewsletterConstants.MAIL_SMTP_PORT, port); properties.put(NewsletterConstants.MAIL_SMTP_SOCKET_FACTORY_FALLBACK, "false"); properties.put(NewsletterConstants.MAIL_SMTP_STARTTLS_ENABLE, "true"); properties.put(NewsletterConstants.MAIL_SMTP_AUTH, "true"); MailAuthenticator mailAuthenticator = new MailAuthenticator(userString, passwordString); Session session = Session.getInstance(properties, mailAuthenticator); String senderEmail = campaign.getSenderEmail(); String emailSubject = campaign.getEmailSubject(); NewsletterContent content = campaign.getContent(); String senderName = campaign.getSenderName(); StringBundler sb = new StringBundler(10); sb.append(StringPool.QUOTE); sb.append(senderName); sb.append(StringPool.QUOTE); sb.append(StringPool.SPACE); sb.append(StringPool.LESS_THAN); sb.append(senderEmail); sb.append(StringPool.GREATER_THAN); String from = sb.toString(); NewsletterContact contact = newsletterContactLocalService.getContact(contactId); try { MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setRecipient(Message.RecipientType.TO, new InternetAddress(contact.getEmail())); message.setSentDate(new Date()); message.setSubject(emailSubject); message.setContent(content.getContent(), "text/html"); Transport.send(message); } catch (Exception e) { throw new SendEmailException(e.getMessage()); } }
From source file:com.liferay.opensocial.shindig.oauth.LiferayOAuthStoreProvider.java
License:Open Source License
private OAuthConsumer _getOAuthConsumer(String keyFileName, String keyName) { OAuthConsumer oAuthConsumer = new OAuthConsumerImpl(); oAuthConsumer.setConsumerKey(_DEFAULT_CONSUMER_KEY); oAuthConsumer.setServiceName(_DEFAULT_SERVICE_NAME); String consumerSecret = null; String path = PropsUtil.get(PropsKeys.LIFERAY_HOME).concat(_KEY_DIR); path = path.replaceAll(StringPool.QUOTE, StringPool.BLANK); keyFileName = path.concat(keyFileName); try {/*w w w . ja va2 s . com*/ consumerSecret = FileUtil.read(keyFileName); } catch (Exception e) { } finally { if (consumerSecret == null) { if (!FileUtil.exists(path)) { FileUtil.mkdirs(path); } if (_log.isWarnEnabled()) { _log.warn("Unable to load OAuth key from " + keyFileName); } return null; } } consumerSecret = _convertFromOpenSsl(consumerSecret); oAuthConsumer.setConsumerSecret(consumerSecret); oAuthConsumer.setKeyType(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE); oAuthConsumer.setKeyName(keyName); return oAuthConsumer; }
From source file:com.liferay.portlet.documentlibrary.util.DLFileEntryIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { addStatus(contextQuery, searchContext); if (searchContext.isIncludeAttachments()) { addRelatedClassNames(contextQuery, searchContext); }/*from w w w .j av a 2 s. c o m*/ contextQuery.addRequiredTerm(Field.HIDDEN, searchContext.isIncludeAttachments()); addSearchClassTypeIds(contextQuery, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { String[] ddmStructureFieldNameParts = StringUtil.split(ddmStructureFieldName, StringPool.SLASH); DDMStructure structure = DDMStructureLocalServiceUtil .getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1])); String fieldName = StringUtil.replaceLast(ddmStructureFieldNameParts[2], StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())), StringPool.BLANK); try { ddmStructureFieldValue = DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName)); } catch (StructureFieldException sfe) { } contextQuery.addRequiredTerm(ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE); } String[] mimeTypes = (String[]) searchContext.getAttribute("mimeTypes"); if (ArrayUtil.isNotEmpty(mimeTypes)) { BooleanQuery mimeTypesQuery = BooleanQueryFactoryUtil.create(searchContext); for (String mimeType : mimeTypes) { mimeTypesQuery.addTerm("mimeType", StringUtil.replace(mimeType, CharPool.FORWARD_SLASH, CharPool.UNDERLINE)); } contextQuery.add(mimeTypesQuery, BooleanClauseOccur.MUST); } }
From source file:com.liferay.portlet.journal.util.JournalArticleIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID); if ((classNameId != null) && (classNameId.longValue() != 0)) { contextQuery.addRequiredTerm("classNameId", classNameId.toString()); }/*from w ww . j a v a2 s . c o m*/ addStatus(contextQuery, searchContext); addSearchClassTypeIds(contextQuery, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { String[] ddmStructureFieldNameParts = StringUtil.split(ddmStructureFieldName, StringPool.SLASH); DDMStructure structure = DDMStructureLocalServiceUtil .getStructure(GetterUtil.getLong(ddmStructureFieldNameParts[1])); String fieldName = StringUtil.replaceLast(ddmStructureFieldNameParts[2], StringPool.UNDERLINE.concat(LocaleUtil.toLanguageId(searchContext.getLocale())), StringPool.BLANK); try { ddmStructureFieldValue = DDMUtil.getIndexedFieldValue(ddmStructureFieldValue, structure.getFieldType(fieldName)); } catch (StructureFieldException sfe) { } contextQuery.addRequiredTerm(ddmStructureFieldName, StringPool.QUOTE + ddmStructureFieldValue + StringPool.QUOTE); } String articleType = (String) searchContext.getAttribute("articleType"); if (Validator.isNotNull(articleType)) { contextQuery.addRequiredTerm(Field.TYPE, articleType); } String ddmStructureKey = (String) searchContext.getAttribute("ddmStructureKey"); if (Validator.isNotNull(ddmStructureKey)) { contextQuery.addRequiredTerm("ddmStructureKey", ddmStructureKey); } String ddmTemplateKey = (String) searchContext.getAttribute("ddmTemplateKey"); if (Validator.isNotNull(ddmTemplateKey)) { contextQuery.addRequiredTerm("ddmTemplateKey", ddmTemplateKey); } }