List of usage examples for com.liferay.portal.kernel.util StringPool SPACE
String SPACE
To view the source code for com.liferay.portal.kernel.util StringPool SPACE.
Click Source Link
From source file:com.liferay.tools.sourceformatter.XMLSourceProcessor.java
License:Open Source License
protected List<String> getColumnNames(String fileName, String entityName) throws Exception { List<String> columnNames = new ArrayList<String>(); Pattern pattern = Pattern.compile("create table " + entityName + "_? \\(\n([\\s\\S]*?)\n\\);"); Matcher matcher = pattern.matcher(getTablesContent(fileName)); if (!matcher.find()) { return columnNames; }// w ww . ja v a 2s .c o m String tableContent = matcher.group(1); UnsyncBufferedReader unsyncBufferedReader = new UnsyncBufferedReader(new UnsyncStringReader(tableContent)); String line = null; while ((line = unsyncBufferedReader.readLine()) != null) { line = StringUtil.trim(line); String columnName = line.substring(0, line.indexOf(StringPool.SPACE)); columnName = StringUtil.replace(columnName, StringPool.UNDERLINE, StringPool.BLANK); columnNames.add(columnName); } return columnNames; }
From source file:com.liferay.util.ant.Java2WsddTask.java
License:Open Source License
private static String _format(String content) throws Exception { content = HtmlUtil.stripComments(content); Document document = SAXReaderUtil.read(content); Element rootElement = document.getRootElement(); Element serviceElement = rootElement.element("service"); Map<String, Element> arrayMappingElements = new TreeMap<String, Element>(); Map<String, Element> typeMappingElements = new TreeMap<String, Element>(); Map<String, Element> operationElements = new TreeMap<String, Element>(); Map<String, Element> parameterElements = new TreeMap<String, Element>(); for (Element element : serviceElement.elements()) { String elementName = element.getName(); if (elementName.equals("arrayMapping")) { element.detach();//from w w w. j a v a 2 s. com arrayMappingElements.put(element.formattedString(), element); } else if (elementName.equals("operation")) { element.detach(); StringBundler sb = new StringBundler(); String name = element.attributeValue("name"); sb.append(name); sb.append("_METHOD_"); for (Element parameterElement : element.elements("parameter")) { String type = parameterElement.attributeValue("type"); sb.append(type); sb.append("_PARAMETER_"); } operationElements.put(sb.toString(), element); } else if (elementName.equals("parameter")) { element.detach(); String name = element.attributeValue("name"); if (name.equals("allowedMethods")) { Attribute valueAttribute = element.attribute("value"); String[] values = StringUtil.split(valueAttribute.getValue(), CharPool.SPACE); Arrays.sort(values); valueAttribute.setValue(StringUtil.merge(values, StringPool.SPACE)); } else if (name.equals("schemaUnqualified")) { Attribute valueAttribute = element.attribute("value"); String[] values = StringUtil.split(valueAttribute.getValue()); Arrays.sort(values); valueAttribute.setValue(StringUtil.merge(values)); } parameterElements.put(name, element); } else if (elementName.equals("typeMapping")) { element.detach(); typeMappingElements.put(element.formattedString(), element); } } _addElements(serviceElement, arrayMappingElements); _addElements(serviceElement, typeMappingElements); _addElements(serviceElement, operationElements); _addElements(serviceElement, parameterElements); content = StringUtil.replace(document.formattedString(), "\"/>", "\" />"); return content; }
From source file:com.liferay.util.bridges.mvc.MVCPortlet.java
License:Open Source License
@Override public void init() throws PortletException { super.init(); templatePath = _getInitParameter("template-path"); if (Validator.isNull(templatePath)) { templatePath = StringPool.SLASH; } else if (templatePath.contains(StringPool.BACK_SLASH) || templatePath.contains(StringPool.DOUBLE_SLASH) || templatePath.contains(StringPool.PERIOD) || templatePath.contains(StringPool.SPACE)) { throw new PortletException("template-path " + templatePath + " has invalid characters"); } else if (!templatePath.startsWith(StringPool.SLASH) || !templatePath.endsWith(StringPool.SLASH)) { throw new PortletException("template-path " + templatePath + " must start and end with a /"); }//from w ww . j av a 2s.c om aboutTemplate = _getInitParameter("about-template"); configTemplate = _getInitParameter("config-template"); editTemplate = _getInitParameter("edit-template"); editDefaultsTemplate = _getInitParameter("edit-defaults-template"); editGuestTemplate = _getInitParameter("edit-guest-template"); helpTemplate = _getInitParameter("help-template"); previewTemplate = _getInitParameter("preview-template"); printTemplate = _getInitParameter("print-template"); viewTemplate = _getInitParameter("view-template"); clearRequestParameters = GetterUtil.getBoolean(getInitParameter("clear-request-parameters")); copyRequestParameters = GetterUtil.getBoolean(getInitParameter("copy-request-parameters")); String packagePrefix = getInitParameter(ActionCommandCache.ACTION_PACKAGE_NAME); if (Validator.isNotNull(packagePrefix)) { _actionCommandCache = new ActionCommandCache(packagePrefix); } }
From source file:com.liferay.util.mail.InternetAddressUtil.java
License:Open Source License
public static String toString(Address address) { InternetAddress internetAddress = (InternetAddress) address; if (internetAddress != null) { StringBundler sb = new StringBundler(5); String personal = internetAddress.getPersonal(); String emailAddress = internetAddress.getAddress(); if (Validator.isNotNull(personal)) { sb.append(personal);/*from w w w . j av a2 s. c o m*/ sb.append(StringPool.SPACE); sb.append(StringPool.LESS_THAN); sb.append(emailAddress); sb.append(StringPool.GREATER_THAN); } else { sb.append(emailAddress); } return sb.toString(); } return StringPool.BLANK; }
From source file:com.liferay.wiki.engine.creole.internal.parser.visitor.impl.XhtmlTranslationVisitor.java
License:Open Source License
@Override public void visit(LineNode lineNode) { traverse(lineNode.getChildASTNodes(), null, StringPool.SPACE); }
From source file:com.liferay.wiki.engine.markdown.pegdown.ast.LiferayPegDownProcessor.java
License:Open Source License
protected String stripIds(String content) { int index = content.indexOf("[](id="); if (index == -1) { return content; }//from www . j av a 2s . c o m StringBundler sb = new StringBundler(); do { int x = content.indexOf(StringPool.EQUAL, index); int y = content.indexOf(StringPool.CLOSE_PARENTHESIS, x); if (y != -1) { int z = content.indexOf("</h", y); if (z != (y + 1)) { sb.append(content.substring(0, y + 1)); } else { sb.append(StringUtil.trimTrailing(content.substring(0, index))); } content = content.substring(y + 1); } else { if (_log.isWarnEnabled()) { String msg = content.substring(index); // Get the invalid id text from the content int spaceIndex = content.indexOf(StringPool.SPACE); if (spaceIndex != -1) { msg = content.substring(index, spaceIndex); } _log.warn("Missing ')' for web content containing header id " + msg); } // Since no close parenthesis remains in the content, stop // stripping out IDs and simply include all of the remaining // content break; } } while ((index = content.indexOf("[](id=")) != -1); sb.append(content); return sb.toString(); }
From source file:com.liferay.wiki.internal.exportimport.data.handler.WikiNodeStagedModelDataHandler.java
License:Open Source License
protected String getNodeName(PortletDataContext portletDataContext, WikiNode node, String name, int count) throws Exception { WikiNode existingNode = _wikiNodeLocalService.fetchNode(portletDataContext.getScopeGroupId(), name); if (existingNode == null) { return name; }// www . ja va 2s . c o m String nodeName = node.getName(); return getNodeName(portletDataContext, node, nodeName.concat(StringPool.SPACE).concat(String.valueOf(count)), ++count); }
From source file:com.liferay.wiki.internal.translator.MediaWikiToCreoleTranslator.java
License:Open Source License
@Override protected String postProcess(String content) { if (_strictImportMode) { content = runRegexp(content, "\\{{2}Special:(.*?)\\}{2}", StringPool.BLANK); content = runRegexp(content, "\\{{2}(.*?)\\}{2}", StringPool.BLANK); content = runRegexp(content, "(?s)\\{{2}(.*?)\\}{2}", StringPool.BLANK); } else {/*from w w w .j ava 2 s .co m*/ content = runRegexp(content, "\\{{2}Special:(.*?)\\}{2}", "{{{$1}}}\n"); content = runRegexp(content, "\\{{2}(.*?)\\}{2}", "{{{$1}}}"); content = runRegexp(content, "([^\\{])(\\{{2})([^\\{])", "$1\n{{{\n$3"); content = runRegexp(content, "([^\\}])(\\}{2})([^\\}])", "$1\n}}}\n$3"); } // LEP-6118 Matcher matcher = _titlePattern.matcher(content); if (matcher.find()) { content = runRegexp(content, "^===([^=]+)===", "====$1===="); content = runRegexp(content, "^==([^=]+)==", "===$1==="); content = runRegexp(content, "^=([^=]+)=", "==$1=="); } // Remove HTML tags for (Pattern pattern : _htmlTagPatterns) { matcher = pattern.matcher(content); content = matcher.replaceAll(StringPool.BLANK); } for (String htmlTag : _HTML_TAGS) { content = StringUtil.replace(content, htmlTag, StringPool.BLANK); } // Images matcher = _imagePattern.matcher(content); StringBuffer sb = new StringBuffer(content); int level = 0; int offset = 0; int originalLength = 0; int prefixLength = 0; while (matcher.find()) { level = 0; prefixLength = matcher.end(2) - matcher.start(2); for (int i = matcher.start(0) + offset; i < sb.length() - 1; i++) { if ((sb.charAt(i) == '[') && (sb.charAt(i + 1) == '[')) { level++; } else if ((sb.charAt(i) == ']') && (sb.charAt(i + 1) == ']')) { level--; if (level == 0) { originalLength = (i + 2) - (matcher.start(0) + offset); break; } } } int imageStartPos = matcher.end(3) + offset; int imageEndPos = matcher.start(2) + offset + originalLength - 4; String image = "{{" + MediaWikiImporter.SHARED_IMAGES_TITLE + "/" + StringUtil.toLowerCase(sb.substring(imageStartPos, imageEndPos)) + "}}"; int imageLength = image.length(); image = StringUtil.replace(image, "[[", StringPool.BLANK); image = StringUtil.replace(image, "]]", StringPool.BLANK); sb.replace(matcher.start(0) + offset, matcher.start(0) + originalLength + offset, image); offset += MediaWikiImporter.SHARED_IMAGES_TITLE.length() - prefixLength - (imageLength - image.length()); } content = sb.toString(); // Tables matcher = _tablePattern.matcher(content); sb = new StringBuffer(content); String mediaWikiTable = null; offset = 0; originalLength = 0; while (matcher.find()) { mediaWikiTable = sb.substring(matcher.start(1) + offset, matcher.end(1) + offset); originalLength = mediaWikiTable.length() + 4; Matcher matcher1 = _mediaWikiTablePattern1.matcher(mediaWikiTable); mediaWikiTable = matcher1.replaceAll(StringPool.BLANK); Matcher matcher2 = _mediaWikiTablePattern2.matcher(mediaWikiTable); mediaWikiTable = matcher2.replaceAll("$1"); Matcher matcher3 = _mediaWikiTablePattern3.matcher(mediaWikiTable); mediaWikiTable = matcher3.replaceAll("===$1==="); Matcher matcher4 = _mediaWikiTablePattern4.matcher(mediaWikiTable); mediaWikiTable = matcher4.replaceAll("|=$1|"); mediaWikiTable = StringUtil.replace(mediaWikiTable, CharPool.NEW_LINE, StringPool.BLANK); mediaWikiTable = StringUtil.replace(mediaWikiTable, CharPool.RETURN, StringPool.BLANK); mediaWikiTable = StringUtil.replace(mediaWikiTable, "|-", "\n\r"); mediaWikiTable = StringUtil.replace(mediaWikiTable, "||", "|"); mediaWikiTable = StringUtil.replace(mediaWikiTable, "////", StringPool.BLANK); sb.replace(matcher.start(0) + offset, matcher.start(0) + originalLength + offset, mediaWikiTable); offset += mediaWikiTable.length() - originalLength; } content = sb.toString(); content = runRegexp(content, "/{2}(\\{{3})", "$1"); content = runRegexp(content, "(\\}{3})/{2}", "$1"); // Remove underscores from links matcher = _linkPattern.matcher(content); sb = new StringBuffer(content); while (matcher.find()) { String link = matcher.group(1).replace(StringPool.UNDERLINE, StringPool.SPACE); sb.replace(matcher.start(1), matcher.end(1), link); } return TABLE_OF_CONTENTS + super.postProcess(sb.toString()); }
From source file:com.liferay.wiki.service.impl.WikiPageServiceImpl.java
License:Open Source License
protected String exportToRSS(String name, String description, String type, double version, String displayStyle, String feedURL, String entryURL, String attachmentURLPrefix, List<WikiPage> pages, boolean diff, Locale locale) throws PortalException { SyndFeed syndFeed = new SyndFeedImpl(); syndFeed.setDescription(description); List<SyndEntry> syndEntries = new ArrayList<>(); syndFeed.setEntries(syndEntries);/*from w w w. j a v a2s . c om*/ WikiPage latestPage = null; StringBundler sb = new StringBundler(6); for (WikiPage page : pages) { SyndEntry syndEntry = new SyndEntryImpl(); String author = PortalUtil.getUserName(page); syndEntry.setAuthor(author); SyndContent syndContent = new SyndContentImpl(); syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT); sb.setIndex(0); sb.append(entryURL); if (entryURL.endsWith(StringPool.SLASH)) { sb.append(HttpUtil.encodeURL(page.getTitle())); } if (diff) { if ((latestPage != null) || (pages.size() == 1)) { sb.append(StringPool.QUESTION); sb.append(PortalUtil.getPortletNamespace(WikiPortletKeys.WIKI)); sb.append("version="); sb.append(page.getVersion()); String value = null; if (latestPage == null) { value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix); } else { try { value = wikiEngineRenderer.diffHtml(latestPage, page, null, null, attachmentURLPrefix); } catch (PortalException pe) { throw pe; } catch (SystemException se) { throw se; } catch (Exception e) { throw new SystemException(e); } } syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } } else { String value = null; WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider .getConfiguration(WikiGroupServiceOverriddenConfiguration.class, new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME)); if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) { value = StringUtil.shorten(HtmlUtil.extractText(page.getContent()), wikiGroupServiceOverriddenConfiguration.rssAbstractLength(), StringPool.BLANK); } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) { value = StringPool.BLANK; } else { value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix); } syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } syndEntry.setLink(sb.toString()); syndEntry.setPublishedDate(page.getCreateDate()); String title = page.getTitle() + StringPool.SPACE + page.getVersion(); if (page.isMinorEdit()) { title += StringPool.SPACE + StringPool.OPEN_PARENTHESIS + LanguageUtil.get(locale, "minor-edit") + StringPool.CLOSE_PARENTHESIS; } syndEntry.setTitle(title); syndEntry.setUpdatedDate(page.getModifiedDate()); syndEntry.setUri(sb.toString()); latestPage = page; } syndFeed.setFeedType(RSSUtil.getFeedType(type, version)); List<SyndLink> syndLinks = new ArrayList<>(); syndFeed.setLinks(syndLinks); SyndLink syndLinkSelf = new SyndLinkImpl(); syndLinks.add(syndLinkSelf); syndLinkSelf.setHref(feedURL); syndLinkSelf.setRel("self"); syndFeed.setPublishedDate(new Date()); syndFeed.setTitle(name); syndFeed.setUri(feedURL); try { return RSSUtil.export(syndFeed); } catch (FeedException fe) { throw new SystemException(fe); } }
From source file:com.liferay.wiki.web.internal.portlet.template.WikiPortletDisplayTemplateHandler.java
License:Open Source License
@Override public String getName(Locale locale) { ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); String portletTitle = PortalUtil.getPortletTitle(WikiPortletKeys.WIKI, resourceBundle); return portletTitle.concat(StringPool.SPACE).concat(LanguageUtil.get(locale, "template")); }