Example usage for com.liferay.portal.kernel.util HtmlUtil extractText

List of usage examples for com.liferay.portal.kernel.util HtmlUtil extractText

Introduction

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

Prototype

public static String extractText(String html) 

Source Link

Document

Extracts the raw text from the HTML input, compressing its whitespace and removing all attributes, scripts, and styles.

Usage

From source file:br.com.prodevelopment.lapidarios.loja.service.impl.LojaLocalServiceImpl.java

License:Open Source License

public void updateAsset(long userId, Loja loja, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds) throws PortalException, SystemException {

    boolean visible = true;

    String summary = HtmlUtil.extractText(StringUtil.shorten(loja.getNomeFantasia(), 500));

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, loja.getGroupId(), loja.getCreateDate(),
            loja.getModifiedDate(), Loja.class.getName(), loja.getLojaId(), loja.getUuid(), 0, assetCategoryIds,
            assetTagNames, visible, null, null, null, ContentTypes.TEXT_HTML, loja.getNomeFantasia(),
            loja.getNomeFantasia(), summary, null, null, 0, 0, null, false);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);
}

From source file:ca.efendi.datafeeds.search.CJProductIndexer.java

License:Apache License

@Override
protected Document doGetDocument(final CJProduct object) throws Exception {
    final Document document = getBaseModelDocument(CLASS_NAME, object);
    document.addText(Field.CAPTION, object.getName());
    document.addText(Field.CONTENT, HtmlUtil.extractText(object.getDescription()));
    document.addText(Field.DESCRIPTION, object.getDescription());
    document.addDate(Field.MODIFIED_DATE, object.getModifiedDate());
    //document.addText(Field.SUBTITLE, blogsEntry.getSubtitle());
    document.addText(Field.TITLE, object.getName());
    return document;
}

From source file:ca.efendi.datafeeds.service.impl.CJProductLocalServiceImpl.java

License:Open Source License

@Override
@Indexable(type = IndexableType.REINDEX)
public CJProduct refresh(final FtpSubscription subscription, final CJProduct newCJProduct)
        throws PortalException {

    final Date now = new Date();

    CJProduct cjProduct;//from  w  ww  . ja  v a2s .  c om

    try {
        cjProduct = cjProductPersistence.findByPROGRAM_CATALOG_SKU(newCJProduct.getProgramName(),
                newCJProduct.getCatalogName(), newCJProduct.getSku());
    } catch (final NoSuchCJProductException e) {

        final long productId = counterLocalService.increment(CJProduct.class.getName());

        cjProduct = cjProductPersistence.create(productId);

        resourceLocalService.addModelResources(subscription.getCompanyId(), subscription.getGroupId(),
                subscription.getUserId(), CJProduct.class.getName(), productId, new String[] { "VIEW" },
                new String[] { "VIEW" });

        cjProduct.setUuid(PortalUUIDUtil.generate());
        cjProduct.setGroupId(subscription.getGroupId());
        cjProduct.setCompanyId(subscription.getCompanyId());
        cjProduct.setUserId(subscription.getUserId());
        cjProduct.setUserName(subscription.getUserName());

        cjProduct.setProgramName(newCJProduct.getProgramName());
        cjProduct.setCatalogName(newCJProduct.getCatalogName());
        cjProduct.setSku(newCJProduct.getSku());

        // TODO: is it already implemented by Liferay?
        //cjProduct.setCreateDate(now);

    }

    cjProduct.setProgramUrl(newCJProduct.getProgramUrl());
    cjProduct.setLastUpdated(newCJProduct.getLastUpdated());
    cjProduct.setName(newCJProduct.getName());
    cjProduct.setKeywords(newCJProduct.getKeywords());
    cjProduct.setDescription(newCJProduct.getDescription());
    cjProduct.setManufacturer(newCJProduct.getManufacturer());
    cjProduct.setManufacturerId(newCJProduct.getManufacturerId());
    cjProduct.setCurrency(newCJProduct.getCurrency());
    cjProduct.setPrice(newCJProduct.getPrice());
    cjProduct.setBuyUrl(newCJProduct.getBuyUrl());
    cjProduct.setImpressionUrl(newCJProduct.getImpressionUrl());
    cjProduct.setImageUrl(newCJProduct.getImageUrl());
    cjProduct.setInStock(newCJProduct.getInStock());

    // TODO: is it already implemented by Liferay?
    //cjProduct.setModifiedDate(now);

    //cjProduct.setCompanyId(COMPANY_ID);
    //cjProduct.setGroupId(GROUP_ID);
    //cjProduct.setUserId(USER_ID);

    Date current = new Date();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, 1);
    Date expire = cal.getTime();

    /* assetEntryLocalService.updateEntry(
        cjProduct.getUserId(), cjProduct.getGroupId(), CJProduct.class.getName(),
        cjProduct.getProductId(),
        new long[]{}, //serviceContext.getAssetCategoryIds(),
        new String[]{"shopping"}); //serviceContext.getAssetTagNames());
            
     assetEntryLocalService.updateEntry(
        CJProduct.class.getName(),
        cjProduct.getProductId(),
        current,
        expire,
        true,
        true);
    */

    String summary = HtmlUtil.extractText(StringUtil.shorten(cjProduct.getDescription(), 500));

    long[] assetCategoryIds = null;
    String[] assetTagNames = null;
    boolean visible = true;
    Double priority = null;

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(cjProduct.getUserId(), cjProduct.getGroupId(),
            cjProduct.getCreateDate(), cjProduct.getModifiedDate(), CJProduct.class.getName(),
            cjProduct.getProductId(), cjProduct.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible,
            current, expire, current, expire, ContentTypes.TEXT_HTML, cjProduct.getName(),
            cjProduct.getDescription(), summary, cjProduct.getBuyUrl(), null, 0, 0, priority);

    long[] assetLinkEntryIds = null;

    assetLinkLocalService.updateLinks(cjProduct.getUserId(), assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);

    Indexer<CJProduct> indexer = IndexerRegistryUtil.nullSafeGetIndexer(CJProduct.class);

    indexer.reindex(cjProduct);

    return cjProductPersistence.update(cjProduct);

}

From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java

License:Open Source License

@Override
public void updateAsset(long userId, Contact contact, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds, Double priority) throws PortalException {

    // TODO//w ww .j  av a  2 s .  c o m
    boolean visible = true;
    // boolean visible = false;
    // if (contact.isApproved()) {
    // visible = true;
    // publishDate = contact.getCreateDate();
    // }

    Date publishDate = contact.getCreateDate();

    // TODO
    String description = "TODO: contact description";
    String summary = HtmlUtil.extractText(StringUtil.shorten(contact.getCard(), 500));

    String className = Contact.class.getName();
    long classPK = contact.getContactId();

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, contact.getGroupId(),
            contact.getCreateDate(), contact.getModifiedDate(), className, classPK, contact.getUuid(), 0,
            assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null,
            ContentTypes.TEXT_HTML,
            // contact.getName(),
            "TODO: contact.getName()", description, summary, null, null, 0, 0, priority);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);

    // assetEntryLocalService.updateVisible(Contact.class.getName(),
    // classPK, visible);

}

From source file:ch.inofix.referencemanager.service.impl.BibliographyLocalServiceImpl.java

License:Open Source License

public void updateAsset(long userId, Bibliography bibliography, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds, Double priority) throws PortalException {

    boolean visible = false;

    Date publishDate = null;/* ww  w .ja  v  a2  s  .c o m*/

    if (bibliography.isApproved()) {
        visible = true;
        publishDate = bibliography.getCreateDate();
    }

    String summary = HtmlUtil.extractText(StringUtil.shorten(bibliography.getTitle(), 500));

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, bibliography.getGroupId(),
            bibliography.getCreateDate(), bibliography.getModifiedDate(), Bibliography.class.getName(),
            bibliography.getBibliographyId(), bibliography.getUuid(), 0, assetCategoryIds, assetTagNames, true,
            visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, bibliography.getTitle(),
            bibliography.getTitle(), summary, null, null, 0, 0, priority);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);
}

From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java

License:Open Source License

public void updateAsset(long userId, Reference reference, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds, Double priority) throws PortalException {

    boolean visible = false;

    Date publishDate = null;//from  w  w w.  j av a2s .c  o m

    if (reference.isApproved()) {
        visible = true;

        publishDate = reference.getCreateDate();
    }

    String summary = HtmlUtil.extractText(StringUtil.shorten(reference.getCitation(), 500));

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, reference.getGroupId(),
            reference.getCreateDate(), reference.getModifiedDate(), Reference.class.getName(),
            reference.getReferenceId(), reference.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible,
            null, null, publishDate, null, ContentTypes.TEXT_HTML, reference.getTitle(),
            reference.getCitation(), summary, null, null, 0, 0, priority);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);
}

From source file:ch.inofix.timetracker.service.impl.TaskRecordLocalServiceImpl.java

License:Open Source License

@Override
public void updateAsset(long userId, TaskRecord taskRecord, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds, Double priority) throws PortalException {

    // TODO//from   ww  w . jav a  2 s .  c  om
    boolean visible = true;
    // boolean visible = false;
    // if (taskRecord.isApproved()) {
    // visible = true;
    // publishDate = taskRecord.getCreateDate();
    // }

    Date publishDate = null;

    String summary = HtmlUtil.extractText(StringUtil.shorten(taskRecord.getWorkPackage(), 500));

    String className = TaskRecord.class.getName();
    long classPK = taskRecord.getTaskRecordId();

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, taskRecord.getGroupId(),
            taskRecord.getCreateDate(), taskRecord.getModifiedDate(), className, classPK, taskRecord.getUuid(),
            0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null,
            ContentTypes.TEXT_HTML, taskRecord.getWorkPackage(), taskRecord.getWorkPackage(), summary, null,
            null, 0, 0, priority);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);
}

From source file:com.cd.learning.hook.MBMailMessage.java

License:Open Source License

public String getBody() {
    if (Validator.isNotNull(_plainBody)) {
        return GetterUtil.getString(_plainBody);
    } else if (Validator.isNotNull(_htmlBody)) {
        return HtmlUtil.extractText(_htmlBody);
    } else {/*w w w  .  j  a va2  s  .c o  m*/
        return "-";
    }
}

From source file:com.liferay.blogs.internal.search.BlogsEntryIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(BlogsEntry blogsEntry) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, blogsEntry);

    document.addText(Field.CAPTION, blogsEntry.getCoverImageCaption());
    document.addText(Field.CONTENT, HtmlUtil.extractText(blogsEntry.getContent()));
    document.addText(Field.DESCRIPTION, blogsEntry.getDescription());
    document.addDate(Field.MODIFIED_DATE, blogsEntry.getModifiedDate());
    document.addText(Field.SUBTITLE, blogsEntry.getSubtitle());
    document.addText(Field.TITLE, blogsEntry.getTitle());

    return document;
}

From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

@Override
public void updateAsset(long userId, BlogsEntry entry, long[] assetCategoryIds, String[] assetTagNames,
        long[] assetLinkEntryIds, Double priority) throws PortalException {

    boolean visible = false;

    if (entry.isApproved()) {
        visible = true;//from w  w w .j a  v  a  2  s.  co m
    }

    String summary = HtmlUtil.extractText(StringUtil.shorten(entry.getContent(), 500));

    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, entry.getGroupId(),
            entry.getCreateDate(), entry.getModifiedDate(), BlogsEntry.class.getName(), entry.getEntryId(),
            entry.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, null, null,
            ContentTypes.TEXT_HTML, entry.getTitle(), entry.getDescription(), summary, null, null, 0, 0,
            priority);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
            AssetLinkConstants.TYPE_RELATED);
}