Search in sources :

Example 21 with StringBundler

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();
}
Also used : StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 22 with StringBundler

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 = &#63;.
 *
 * @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());
}
Also used : Club(com.liferay.roster.model.Club) NoSuchClubException(com.liferay.roster.exception.NoSuchClubException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 23 with StringBundler

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);
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleMarkdownConverter(com.liferay.knowledgebase.admin.importer.util.KBArticleMarkdownConverter) KBArticleImportException(com.liferay.knowledgebase.KBArticleImportException) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) IOException(java.io.IOException) KBArticleImportException(com.liferay.knowledgebase.KBArticleImportException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 24 with StringBundler

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();
}
Also used : StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 25 with StringBundler

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();
}
Also used : StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

StringBundler (com.liferay.portal.kernel.util.StringBundler)790 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)469 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)413 Session (com.liferay.portal.kernel.dao.orm.Session)365 Query (com.liferay.portal.kernel.dao.orm.Query)361 SystemException (com.liferay.portal.kernel.exception.SystemException)338 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)214 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)203 KBArticle (com.liferay.knowledgebase.model.KBArticle)203 List (java.util.List)180 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)173 ArrayList (java.util.ArrayList)173 Song (org.liferay.jukebox.model.Song)64 NoSuchSongException (org.liferay.jukebox.NoSuchSongException)61 Album (org.liferay.jukebox.model.Album)58 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)54 Artist (org.liferay.jukebox.model.Artist)47 NoSuchArtistException (org.liferay.jukebox.NoSuchArtistException)44 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)38 KBComment (com.liferay.knowledgebase.model.KBComment)36