use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.
the class ClubModelImpl method toXmlString.
@Override
public String toXmlString() {
StringBundler sb = new StringBundler(19);
sb.append("<model><model-name>");
sb.append("com.liferay.roster.model.Club");
sb.append("</model-name>");
sb.append("<column><column-name>uuid</column-name><column-value><![CDATA[");
sb.append(getUuid());
sb.append("]]></column-value></column>");
sb.append("<column><column-name>clubId</column-name><column-value><![CDATA[");
sb.append(getClubId());
sb.append("]]></column-value></column>");
sb.append("<column><column-name>createDate</column-name><column-value><![CDATA[");
sb.append(getCreateDate());
sb.append("]]></column-value></column>");
sb.append("<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
sb.append(getModifiedDate());
sb.append("]]></column-value></column>");
sb.append("<column><column-name>name</column-name><column-value><![CDATA[");
sb.append(getName());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.
the class ClubPersistenceImpl method findByUuid_First.
/**
* Returns the first club in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching club
* @throws NoSuchClubException if a matching club could not be found
*/
@Override
public Club findByUuid_First(String uuid, OrderByComparator<Club> orderByComparator) throws NoSuchClubException {
Club club = fetchByUuid_First(uuid, orderByComparator);
if (club != null) {
return club;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchClubException(msg.toString());
}
use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.
the class KBArticleImporter method addKBArticleMarkdown.
protected KBArticle addKBArticleMarkdown(long userId, long groupId, long parentKBFolderId, long parentResourceClassNameId, long parentResourcePrimaryKey, String markdown, String fileEntryName, ZipReader zipReader, Map<String, String> metadata, PrioritizationStrategy prioritizationStrategy, ServiceContext serviceContext) throws KBArticleImportException, SystemException {
if (Validator.isNull(markdown)) {
throw new KBArticleImportException("Markdown is null for file entry " + fileEntryName);
}
KBArticleMarkdownConverter kbArticleMarkdownConverter = new KBArticleMarkdownConverter(markdown, fileEntryName, metadata);
String urlTitle = kbArticleMarkdownConverter.getUrlTitle();
KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(groupId, parentKBFolderId, urlTitle);
boolean newKBArticle = false;
if (kbArticle == null) {
newKBArticle = true;
}
try {
if (kbArticle == null) {
int workflowAction = serviceContext.getWorkflowAction();
serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
kbArticle = KBArticleLocalServiceUtil.addKBArticle(userId, parentResourceClassNameId, parentResourcePrimaryKey, kbArticleMarkdownConverter.getTitle(), urlTitle, markdown, null, kbArticleMarkdownConverter.getSourceURL(), null, null, serviceContext);
serviceContext.setWorkflowAction(workflowAction);
}
} catch (Exception e) {
StringBundler sb = new StringBundler(4);
sb.append("Unable to add basic KB article for file entry ");
sb.append(fileEntryName);
sb.append(": ");
sb.append(e.getLocalizedMessage());
throw new KBArticleImportException(sb.toString(), e);
}
try {
String html = kbArticleMarkdownConverter.processAttachmentsReferences(userId, kbArticle, zipReader, new HashMap<String, FileEntry>());
kbArticle = KBArticleLocalServiceUtil.updateKBArticle(userId, kbArticle.getResourcePrimKey(), kbArticleMarkdownConverter.getTitle(), html, kbArticle.getDescription(), kbArticleMarkdownConverter.getSourceURL(), null, null, null, serviceContext);
if (newKBArticle) {
prioritizationStrategy.addKBArticle(kbArticle, fileEntryName);
} else {
prioritizationStrategy.updateKBArticle(kbArticle, fileEntryName);
}
return kbArticle;
} catch (Exception e) {
StringBundler sb = new StringBundler(4);
sb.append("Unable to update KB article for file entry ");
sb.append(fileEntryName);
sb.append(": ");
sb.append(e.getLocalizedMessage());
throw new KBArticleImportException(sb.toString(), e);
}
}
use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.
the class KBArticleMarkdownConverter method buildSourceURL.
protected String buildSourceURL(String baseSourceURL, String fileEntryName) {
if (!Validator.isUrl(baseSourceURL)) {
return null;
}
int pos = baseSourceURL.length() - 1;
while (pos >= 0) {
char c = baseSourceURL.charAt(pos);
if (c != CharPool.SLASH) {
break;
}
pos--;
}
StringBundler sb = new StringBundler(3);
sb.append(baseSourceURL.substring(0, pos + 1));
if (!fileEntryName.startsWith(StringPool.SLASH)) {
sb.append(StringPool.SLASH);
}
sb.append(fileEntryName);
return sb.toString();
}
use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.
the class KBArticleMarkdownConverter method stripIds.
protected String stripIds(String content) {
int index = content.indexOf("[](id=");
if (index == -1) {
return content;
}
StringBundler sb = new StringBundler();
do {
int x = content.indexOf(StringPool.EQUAL, index);
int y = content.indexOf(StringPool.CLOSE_PARENTHESIS, x);
if (y != -1) {
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);
}
break;
}
} while ((index = content.indexOf("[](id=")) != -1);
sb.append(content);
return sb.toString();
}
Aggregations