Example usage for com.liferay.portal.servlet.filters.cache CacheUtil clearCache

List of usage examples for com.liferay.portal.servlet.filters.cache CacheUtil clearCache

Introduction

In this page you can find the example usage for com.liferay.portal.servlet.filters.cache CacheUtil clearCache.

Prototype

public static void clearCache(long companyId) 

Source Link

Usage

From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java

License:Open Source License

@Ignore
@Test//ww w  .  j  a va2s . co m
public void testLayoutPermissionPropagationWithLinkEnabled() throws Exception {

    setLinkEnabled(true);

    Role role = RoleLocalServiceUtil.getRole(TestPropsValues.getCompanyId(), RoleConstants.POWER_USER);

    ResourcePermissionServiceUtil.setIndividualResourcePermissions(prototypeLayout.getGroupId(),
            prototypeLayout.getCompanyId(), Layout.class.getName(),
            String.valueOf(prototypeLayout.getPrimaryKey()), role.getRoleId(),
            new String[] { ActionKeys.CUSTOMIZE });

    prototypeLayout = updateModifiedDate(prototypeLayout, new Date(System.currentTimeMillis() + Time.MINUTE));

    CacheUtil.clearCache(prototypeLayout.getCompanyId());

    propagateChanges(group);

    Assert.assertTrue(ResourcePermissionLocalServiceUtil.hasResourcePermission(layout.getCompanyId(),
            Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(layout.getPrimaryKey()),
            role.getRoleId(), ActionKeys.CUSTOMIZE));
}

From source file:com.liferay.journal.model.listener.internal.DDMTemplateModelListener.java

License:Open Source License

protected void clearCache(DDMTemplate ddmTemplate) {
    if (ddmTemplate == null) {
        return;/*from  w  w  w .ja  v a  2s.  co m*/
    }

    // Article cache

    _journalContent.clearCache(ddmTemplate.getTemplateKey());

    // Layout cache

    CacheUtil.clearCache(ddmTemplate.getCompanyId());
}

From source file:com.liferay.journal.model.listener.JournalArticleModelListener.java

License:Open Source License

protected void clearCache(JournalArticle article) {
    if (article == null) {
        return;/*from  w ww.  j a  va 2s  .  c o  m*/
    }

    // Journal content

    _journalContent.clearCache(article.getGroupId(), article.getArticleId(), article.getDDMTemplateKey());

    // Layout cache

    CacheUtil.clearCache(article.getCompanyId());
}

From source file:com.liferay.portlet.journal.model.JournalArticleListener.java

License:Open Source License

protected void clearCache(JournalArticle article) {

    // Journal content

    JournalContentUtil.clearCache();/*from  w  ww .  j  a v a2  s. com*/

    // Layout cache

    CacheUtil.clearCache(article.getCompanyId());
}

From source file:com.liferay.portlet.journal.model.JournalTemplateListener.java

License:Open Source License

protected void clearCache(JournalTemplate template) {

    // Freemarker cache

    String freeMarkerTemplateId = template.getCompanyId() + template.getGroupId() + template.getTemplateId();

    FreeMarkerEngineUtil.flushTemplate(freeMarkerTemplateId);

    // Journal content

    JournalContentUtil.clearCache();//from ww w. j  a  v  a  2  s .co m

    // Layout cache

    CacheUtil.clearCache(template.getCompanyId());

    // Liferay resource cache

    LiferayResourceCacheUtil.remove(_RESOURCE_TEMPLATE_NAME_SPACE.concat(freeMarkerTemplateId));

    // Velocity cache

    VelocityEngineUtil.flushTemplate(freeMarkerTemplateId);
}

From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

public void checkArticles() throws PortalException, SystemException {
    Date now = new Date();

    List<JournalArticle> articles = journalArticleFinder.findByExpirationDate(0,
            WorkflowConstants.STATUS_APPROVED, now);

    if (_log.isDebugEnabled()) {
        _log.debug("Expiring " + articles.size() + " articles");
    }//  w  w  w  .j  a  va  2 s.c  om

    Set<Long> companyIds = new HashSet<Long>();

    for (JournalArticle article : articles) {
        article.setStatus(WorkflowConstants.STATUS_EXPIRED);

        journalArticlePersistence.update(article, false);

        if (article.isIndexable()) {
            Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);

            indexer.delete(article);
        }

        updatePreviousApprovedArticle(article);

        JournalContentUtil.clearCache(article.getGroupId(), article.getArticleId(), article.getTemplateId());

        companyIds.add(article.getCompanyId());
    }

    for (long companyId : companyIds) {
        CacheUtil.clearCache(companyId);
    }

    articles = journalArticleFinder.findByReviewDate(0, now,
            new Date(now.getTime() - _JOURNAL_ARTICLE_CHECK_INTERVAL));

    if (_log.isDebugEnabled()) {
        _log.debug("Sending review notifications for " + articles.size() + " articles");
    }

    for (JournalArticle article : articles) {
        String articleURL = StringPool.BLANK;

        long ownerId = article.getGroupId();
        int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP;
        long plid = PortletKeys.PREFS_PLID_SHARED;
        String portletId = PortletKeys.JOURNAL;

        PortletPreferences preferences = portletPreferencesLocalService.getPreferences(article.getCompanyId(),
                ownerId, ownerType, plid, portletId);

        sendEmail(article, articleURL, preferences, "review", new ServiceContext());
    }
}

From source file:com.liferay.portlet.portletconfiguration.action.EditPermissionsAction.java

License:Open Source License

protected void updateGroupPermissions(ActionRequest actionRequest) throws Exception {

    Layout layout = (Layout) actionRequest.getAttribute(WebKeys.LAYOUT);

    long resourceId = ParamUtil.getLong(actionRequest, "resourceId");
    long groupId = ParamUtil.getLong(actionRequest, "groupId");
    String[] actionIds = StringUtil.split(ParamUtil.getString(actionRequest, "groupIdActionIds"));

    PermissionServiceUtil.setGroupPermissions(groupId, actionIds, resourceId);

    if (!layout.isPrivateLayout()) {
        Resource resource = ResourceLocalServiceUtil.getResource(resourceId);

        if (resource.getPrimKey().startsWith(layout.getPlid() + PortletConstants.LAYOUT_SEPARATOR)) {

            CacheUtil.clearCache(layout.getCompanyId());
        }//from   w ww.java 2s.  c o  m
    }
}