Example usage for com.liferay.portal.kernel.util StringPool COMMA

List of usage examples for com.liferay.portal.kernel.util StringPool COMMA

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool COMMA.

Prototype

String COMMA

To view the source code for com.liferay.portal.kernel.util StringPool COMMA.

Click Source Link

Usage

From source file:com.liferay.jira.metrics.util.graph.GraphData.java

License:Open Source License

protected void concatCloseAndContinue(StringBundler sb) {
    sb.append(StringPool.CLOSE_CURLY_BRACE);
    sb.append(StringPool.COMMA);
}

From source file:com.liferay.jira.metrics.util.graph.GraphData.java

License:Open Source License

private void _concatAttribute(StringBundler sb, String attributeName, String attributeValue, boolean comma) {

    sb.append(attributeName);//from w  w w.  ja v  a  2  s .  c o m
    sb.append(StringPool.COLON);
    sb.append(attributeValue);

    if (comma) {
        sb.append(StringPool.COMMA);
    }
}

From source file:com.liferay.journal.internal.upgrade.v1_1_1.UpgradeFileUploadsConfiguration.java

License:Open Source License

protected void upgradeFileUploadsConfiguration() throws Exception {
    JournalFileUploadsConfiguration defaultConfig = ConfigurableUtil
            .createConfigurable(JournalFileUploadsConfiguration.class, new HashMapDictionary<>());

    Dictionary properties = new HashMapDictionary();

    properties.put("imageExtensions", _prefsProps.getStringArray(_OLD_KEY_JOURNAL_IMAGE_EXTENSIONS,
            StringPool.COMMA, defaultConfig.imageExtensions()));
    properties.put("largeImageMaxSize",
            _prefsProps.getLong(_OLD_KEY_JOURNAL_IMAGE_SMALL_MAX_SIZE, defaultConfig.smallImageMaxSize()));

    Configuration configuration = _configurationAdmin
            .getConfiguration(JournalFileUploadsConfiguration.class.getName(), StringPool.QUESTION);

    configuration.update(properties);//  www .ja  v  a  2  s.  c o m

    PortletPreferences portletPreferences = _prefsProps.getPreferences();

    portletPreferences.reset(_OLD_KEY_JOURNAL_IMAGE_EXTENSIONS);
    portletPreferences.reset(_OLD_KEY_JOURNAL_IMAGE_SMALL_MAX_SIZE);
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticleLocalizationPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalArticleLocalization> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from  w ww.  ja  v a  2 s. co m*/

    Map<Serializable, JournalArticleLocalization> map = new HashMap<Serializable, JournalArticleLocalization>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalArticleLocalization journalArticleLocalization = fetchByPrimaryKey(primaryKey);

        if (journalArticleLocalization != null) {
            map.put(primaryKey, journalArticleLocalization);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(
                JournalArticleLocalizationModelImpl.ENTITY_CACHE_ENABLED, JournalArticleLocalizationImpl.class,
                primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalArticleLocalization) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALARTICLELOCALIZATION_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalArticleLocalization journalArticleLocalization : (List<JournalArticleLocalization>) q
                .list()) {
            map.put(journalArticleLocalization.getPrimaryKeyObj(), journalArticleLocalization);

            cacheResult(journalArticleLocalization);

            uncachedPrimaryKeys.remove(journalArticleLocalization.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalArticleLocalizationModelImpl.ENTITY_CACHE_ENABLED,
                    JournalArticleLocalizationImpl.class, primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticlePersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalArticle> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from ww w  . j av  a  2  s .  co  m*/

    Map<Serializable, JournalArticle> map = new HashMap<Serializable, JournalArticle>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalArticle journalArticle = fetchByPrimaryKey(primaryKey);

        if (journalArticle != null) {
            map.put(primaryKey, journalArticle);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED,
                JournalArticleImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalArticle) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALARTICLE_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalArticle journalArticle : (List<JournalArticle>) q.list()) {
            map.put(journalArticle.getPrimaryKeyObj(), journalArticle);

            cacheResult(journalArticle);

            uncachedPrimaryKeys.remove(journalArticle.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalArticleModelImpl.ENTITY_CACHE_ENABLED, JournalArticleImpl.class,
                    primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalArticleResourcePersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalArticleResource> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from   w ww  .j ava 2s. c  o  m*/

    Map<Serializable, JournalArticleResource> map = new HashMap<Serializable, JournalArticleResource>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalArticleResource journalArticleResource = fetchByPrimaryKey(primaryKey);

        if (journalArticleResource != null) {
            map.put(primaryKey, journalArticleResource);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
                JournalArticleResourceImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalArticleResource) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALARTICLERESOURCE_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalArticleResource journalArticleResource : (List<JournalArticleResource>) q.list()) {
            map.put(journalArticleResource.getPrimaryKeyObj(), journalArticleResource);

            cacheResult(journalArticleResource);

            uncachedPrimaryKeys.remove(journalArticleResource.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalArticleResourceModelImpl.ENTITY_CACHE_ENABLED,
                    JournalArticleResourceImpl.class, primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalContentSearchPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalContentSearch> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//from   w  ww  .  j  av  a  2 s . c o  m

    Map<Serializable, JournalContentSearch> map = new HashMap<Serializable, JournalContentSearch>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalContentSearch journalContentSearch = fetchByPrimaryKey(primaryKey);

        if (journalContentSearch != null) {
            map.put(primaryKey, journalContentSearch);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
                JournalContentSearchImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalContentSearch) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalContentSearch journalContentSearch : (List<JournalContentSearch>) q.list()) {
            map.put(journalContentSearch.getPrimaryKeyObj(), journalContentSearch);

            cacheResult(journalContentSearch);

            uncachedPrimaryKeys.remove(journalContentSearch.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
                    JournalContentSearchImpl.class, primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalFeedPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalFeed> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from  www  . j av  a 2s  . co  m*/

    Map<Serializable, JournalFeed> map = new HashMap<Serializable, JournalFeed>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalFeed journalFeed = fetchByPrimaryKey(primaryKey);

        if (journalFeed != null) {
            map.put(primaryKey, journalFeed);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED,
                JournalFeedImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalFeed) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALFEED_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalFeed journalFeed : (List<JournalFeed>) q.list()) {
            map.put(journalFeed.getPrimaryKeyObj(), journalFeed);

            cacheResult(journalFeed);

            uncachedPrimaryKeys.remove(journalFeed.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalFeedModelImpl.ENTITY_CACHE_ENABLED, JournalFeedImpl.class, primaryKey,
                    nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.service.persistence.impl.JournalFolderPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, JournalFolder> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }//from  w ww. j ava  2 s  . co  m

    Map<Serializable, JournalFolder> map = new HashMap<Serializable, JournalFolder>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        JournalFolder journalFolder = fetchByPrimaryKey(primaryKey);

        if (journalFolder != null) {
            map.put(primaryKey, journalFolder);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Serializable serializable = entityCache.getResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
                JournalFolderImpl.class, primaryKey);

        if (serializable != nullModel) {
            if (serializable == null) {
                if (uncachedPrimaryKeys == null) {
                    uncachedPrimaryKeys = new HashSet<Serializable>();
                }

                uncachedPrimaryKeys.add(primaryKey);
            } else {
                map.put(primaryKey, (JournalFolder) serializable);
            }
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_JOURNALFOLDER_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append((long) primaryKey);

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (JournalFolder journalFolder : (List<JournalFolder>) q.list()) {
            map.put(journalFolder.getPrimaryKeyObj(), journalFolder);

            cacheResult(journalFolder);

            uncachedPrimaryKeys.remove(journalFolder.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            entityCache.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED, JournalFolderImpl.class,
                    primaryKey, nullModel);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static String prepareLocalizedContentForImport(String content, Locale defaultImportLocale)
        throws LocaleException {

    try {//from w w  w .ja va2s  .c  o  m
        Document oldDocument = SAXReaderUtil.read(content);

        Document newDocument = SAXReaderUtil.read(content);

        Element newRootElement = newDocument.getRootElement();

        Attribute availableLocalesAttribute = newRootElement.attribute("available-locales");

        if (availableLocalesAttribute == null) {
            newRootElement = newRootElement.addAttribute("available-locales", StringPool.BLANK);

            availableLocalesAttribute = newRootElement.attribute("available-locales");
        }

        String defaultImportLanguageId = LocaleUtil.toLanguageId(defaultImportLocale);

        if (!StringUtil.contains(availableLocalesAttribute.getValue(), defaultImportLanguageId)) {

            if (Validator.isNull(availableLocalesAttribute.getValue())) {
                availableLocalesAttribute.setValue(defaultImportLanguageId);
            } else {
                availableLocalesAttribute.setValue(
                        availableLocalesAttribute.getValue() + StringPool.COMMA + defaultImportLanguageId);
            }

            _mergeArticleContentUpdate(oldDocument, newRootElement,
                    LocaleUtil.toLanguageId(defaultImportLocale));

            content = XMLUtil.formatXML(newDocument);
        }

        Attribute defaultLocaleAttribute = newRootElement.attribute("default-locale");

        if (defaultLocaleAttribute == null) {
            newRootElement = newRootElement.addAttribute("default-locale", StringPool.BLANK);

            defaultLocaleAttribute = newRootElement.attribute("default-locale");
        }

        Locale defaultContentLocale = LocaleUtil.fromLanguageId(defaultLocaleAttribute.getValue());

        if (!LocaleUtil.equals(defaultContentLocale, defaultImportLocale)) {
            defaultLocaleAttribute.setValue(defaultImportLanguageId);

            content = XMLUtil.formatXML(newDocument);
        }
    } catch (Exception e) {
        throw new LocaleException(LocaleException.TYPE_CONTENT,
                "The locale " + defaultImportLocale + " is not available");
    }

    return content;
}