Expand my Community achievements bar.

SOLVED

Upgrading Older Blog components to AEM 6.2

Avatar

Level 2

Hi Guys,

I am working on a old small site built on CQ 5.5  In this older implementation they have copied the Out of the Box Blog components into the apps folder.  It looks like they copied the out of the box Blog page component into the apps folder and customized it. This components uses the a lot of older API's. I have listed some of them below. Most of these are not present any more in AEM 6.2. As a sample i have also given the feed.jsp which is a part of blog page. The feed uses Atom feed renderer for blog and blog entry nodes.

There is also a lot of content they built using these blog  templates. Can anyone please advice how can i upgrade these components and how i can migrate this content. Is there a one on one replacement for these API's? Also any ideas how i can migrate the blog content.

                     com.day.cq.rewriter.linkchecker.LinkCheckerSettings,

                     com.day.cq.wcm.api.WCMMode"

                   com.day.cq.collab.blog.Blog,

                   com.day.cq.collab.blog.BlogManager,

                   com.day.cq.collab.blog.BlogEntry,

                   com.day.cq.collab.blog.BlogEntryFilter,

                   com.day.cq.collab.blog.TagEntryFilter,

                   com.day.cq.collab.blog.AuthorEntryFilter,

                   com.day.cq.collab.commons.Comment,

                   com.day.cq.commons.ProductInfoService,

                   com.day.cq.commons.ProductInfo,

                   com.day.cq.wcm.api.WCMMode,

                   org.apache.sling.api.resource.Resource,

                   org.apache.sling.api.resource.ResourceResolver,

------------------------------------------------------------------------------------------------------------------------------------------

Feed.jsp

------------------------------------------------------------------------------------------------------------------------------------------

<%--

  Copyright 1997-2009 Day Management AG

  Barfuesserplatz 6, 4001 Basel, Switzerland

  All Rights Reserved.

  This software is the confidential and proprietary information of

  Day Management AG, ("Confidential Information"). You shall not

  disclose such Confidential Information and shall use it only in

  accordance with the terms of the license agreement you entered into

  with Day.

  ==============================================================================

  Atom feed renderer for blog and blog entry nodes

  - Draws the current blog as a feed, listing its blog entries as feed entries

  - Draws the current blog entry as a feed, listing its comments as feed entries

--%>

<%@ page session="false" %><%

%><%@ page import="java.util.List,

                   java.util.ArrayList,

                   java.util.Collections,

                   com.day.cq.collab.blog.Blog,

                   com.day.cq.collab.blog.BlogManager,

                   com.day.cq.collab.blog.BlogEntry,

                   com.day.cq.collab.blog.BlogEntryFilter,

                   com.day.cq.collab.blog.TagEntryFilter,

                   com.day.cq.collab.blog.AuthorEntryFilter,

                   com.day.cq.collab.commons.Comment,

                   com.day.cq.commons.ProductInfoService,

                   com.day.cq.commons.ProductInfo,

                   com.day.cq.wcm.api.WCMMode,

                   org.apache.sling.api.resource.Resource,

                   org.apache.sling.api.resource.ResourceResolver,

                   java.util.Iterator,

                   org.apache.sling.api.resource.ValueMap,

                   com.day.cq.wcm.api.components.ComponentContext" %><%

%><%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%

%><%@ taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%

%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%

%><%@ taglib prefix="atom" uri="http://sling.apache.org/taglibs/atom/1.0" %><%

%><cq:defineObjects /><%!

    /**

     * Descends the resource hierarchy until a blog entry list component is found,

     * then the value of the limit property is returned.

     * @param res The resource

     * @return The limit

     */

    protected static int findLimit(Resource res) {

        int limit = -1;

        ResourceResolver rr = res.getResourceResolver();

        try {

            Iterator<Resource> children = rr.listChildren(res);

            while (children.hasNext()) {

                Resource child = children.next();

                if (child.getResourceType().equals("collab/blog/components/entrylist") || child.getResourceType().equals("csr/blog/components/entrylist")) {

                    limit = child.adaptTo(ValueMap.class).get("limit", -1);

                    break;

               }

                limit = findLimit(child);

            }

        } catch (Exception e) {}

        return limit;

    }

%><%

    try {

        ProductInfo pi = sling.getService(ProductInfoService.class).getInfo();

        WCMMode.DISABLED.toRequest(request);

        String tag = request.getParameter(Blog.PARAM_TAG);

        String author = request.getParameter(Blog.PARAM_AUTHOR);

       BlogManager blogMgr = resource.getResourceResolver().adaptTo(BlogManager.class);

        Blog blog = blogMgr.getBlog(slingRequest, resource.getPath());

        BlogEntry entry = blog.getEntry();

        String url = blog.getFullUrl();

       String feedUrl = blog.isEntry() ? entry.getFeedUrl(true) : blog.getFeedUrl(true);

        String link = blog.isEntry() ? entry.getFullUrl() : blog.getFullUrl();

        String title = blog.isEntry() ? entry.getTitle() : blog.getTitle();

        String subTitle = blog.isEntry() ? entry.getAuthor() : blog.getDescription();

        String genUri = pi.getUrl();

        String genName = pi.getName();

        String genVersion = pi.getShortVersion();

        int limit = findLimit(resource);

                //6-5-2014 adjust entry limit function to search blog children under extra blog child node, enables author to specify limit for feed in entries component

        String resourcePath = resource.getPath();

        if(resourcePath.equals("/content/csr/home/blog/jcr:content")) {

        limit = findLimit(resource.getChild("blog"));

        }

        //Adobe recommended fix for server 500 error

        request.setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, true);

        // NOTE WELL: atom: is a taglib, not generated output.  Don't be tempted to encode attribute

        // values.  (We may not even need to filter the HTML element content, but we currently do.)

        %><atom:feed id="<%= url %>"><%

            %><atom:title><%= xssAPI.filterHTML(title) %></atom:title><%

            if (!"".equals(subTitle)) {

                %><atom:subtitle><%= xssAPI.filterHTML(subTitle) %></atom:subtitle><%

            }

        %><atom:link href="<%= feedUrl %>" rel="self"/><%

        %><atom:link href="<%= link %>"/><%

        %><atom:generator uri="<%= genUri %>" version="<%= genVersion %>"><%= xssAPI.filterHTML(genName) %></atom:generator><%

        if (blog.isEntry()) {

            // blog entry: list comments

            if (entry.hasComments()) {

                List<Comment> comments = entry.getComments();

                Collections.reverse(comments);

                for (Comment comment : comments) {

                    String path = comment.getPath() + ".feedentry";

                    %><sling:include path="<%= path %>"/><%

                }

            }

        } else {

            int count = 1;

            // blog: list blog entries

            List<BlogEntry> entries;

            if (tag != null || author != null) {

                List<BlogEntryFilter> filters = new ArrayList<BlogEntryFilter>();

                if (tag != null) {

                    filters.add(new TagEntryFilter(tag));

                }

                if (author != null) {

                    filters.add(new AuthorEntryFilter(author));

                }

                entries = blog.getEntries(filters);

            } else {

                entries = blog.getEntries();

            }

            for (BlogEntry child : entries) {

                String path = child.getPage().getContentResource().getPath() + ".feedentry";

                %><sling:include path="<%= path %>"/><%

                if (limit > 0 && count == limit) {

                    break;

                }

               count++;

            }

        }

        %></atom:feed><%

    } catch (Exception e) {

        log.error("error rendering feed for blog", e);

    }

%>

1 Accepted Solution

Avatar

Correct answer by
Employee

There are 3 generations of communities components:

1.      Collab components that were present from about 5.4 through 6.0, which held all UGC in-memory

2.       Social components that were present from 5.6.0 through 6.1, which used a custom bucketing/indexing system in JCR

3.       SRP/SCF components introduced in a limited scale for 6.0 which uses an abstraction at the Sling level to store UGC in configured locations, and as of 6.2 this is the only generation supported

The cq-social-collabmigrate-pkg is for upgrading from Collab to Social components (1->2).  There is an open source tool for upgrading from Social to SCF (2->3) https://github.com/Adobe-Marketing-Cloud/aem-communities-ugc-migration

There is not a tool that will migrate from Collab to SRP/SCF (1->3). AEM 6.2 no longer has the bundles for the bucketing/indexing services, so the collabmigrate tool (which existed in 6.0 upgrade) will not start in AEM 6.2. 

The most practical option IMO would be to customize the aem-communities-ugc-migration tool since source is posted on github at the above link

(1) : Upgrading to AEM 6.2 Communities

View solution in original post

2 Replies

Avatar

Level 2

Hi Guys, Any ideas, i am really out of ideas and dont know of any way on how to deal with this content.

Avatar

Correct answer by
Employee

There are 3 generations of communities components:

1.      Collab components that were present from about 5.4 through 6.0, which held all UGC in-memory

2.       Social components that were present from 5.6.0 through 6.1, which used a custom bucketing/indexing system in JCR

3.       SRP/SCF components introduced in a limited scale for 6.0 which uses an abstraction at the Sling level to store UGC in configured locations, and as of 6.2 this is the only generation supported

The cq-social-collabmigrate-pkg is for upgrading from Collab to Social components (1->2).  There is an open source tool for upgrading from Social to SCF (2->3) https://github.com/Adobe-Marketing-Cloud/aem-communities-ugc-migration

There is not a tool that will migrate from Collab to SRP/SCF (1->3). AEM 6.2 no longer has the bundles for the bucketing/indexing services, so the collabmigrate tool (which existed in 6.0 upgrade) will not start in AEM 6.2. 

The most practical option IMO would be to customize the aem-communities-ugc-migration tool since source is posted on github at the above link

(1) : Upgrading to AEM 6.2 Communities