GraniteContent.java 17.4 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.google.common.collect.ImmutableList
 *  com.google.common.collect.ImmutableSet
 *  org.apache.jackrabbit.oak.api.PropertyState
 *  org.apache.jackrabbit.oak.api.Type
 *  org.apache.jackrabbit.oak.plugins.index.IndexUtils
 *  org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper
 *  org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer
 *  org.apache.jackrabbit.oak.spi.state.NodeBuilder
 */
package com.adobe.granite.repository.impl;

import com.adobe.granite.repository.impl.IndexPropertyUtil;
import com.adobe.granite.repository.impl.lucene.util.LuceneAggregate;
import com.adobe.granite.repository.impl.lucene.util.LuceneAggregateDefinition;
import com.adobe.granite.repository.impl.lucene.util.LuceneAggregateInclude;
import com.adobe.granite.repository.impl.lucene.util.LuceneIndexProperty;
import com.adobe.granite.repository.impl.lucene.util.LuceneIndexRule;
import com.adobe.granite.repository.impl.lucene.util.LucenePropertyIndexDefinition;
import com.adobe.granite.repository.impl.nodetype.Version;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.index.IndexUtils;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper;
import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;

public final class GraniteContent
implements RepositoryInitializer {
    static final List<String> GENERIC_LUCENE_EXCLUDES = ImmutableList.of((Object)"/var", (Object)"/etc/replication", (Object)"/etc/workflow/instances", (Object)"/jcr:system");

    public void initialize(NodeBuilder builder) {
        if (builder.hasChildNode("oak:index")) {
            LucenePropertyIndexDefinition includes;
            NodeBuilder nodeType;
            NodeBuilder slingResourceTypeIndex;
            NodeBuilder index = builder.child("oak:index");
            IndexUtils.createReferenceIndex((NodeBuilder)index);
            IndexPropertyUtil.property(index, "jcrLanguage", "jcr:language", "mix:language", false);
            IndexPropertyUtil.property(index, "jcrLockOwner", "jcr:lockOwner");
            IndexPropertyUtil.property(index, "jcrFrozenMixinTypes", "jcr:frozenMixinTypes");
            IndexPropertyUtil.property(index, "slingAlias", "sling:alias");
            IndexPropertyUtil.property(index, "slingResource", "sling:resource");
            IndexPropertyUtil.property(index, "slingResources", "sling:resources");
            if (index.hasChildNode("slingResourceType") && (slingResourceTypeIndex = index.getChildNode("slingResourceType")).getProperty("entryCount") != null) {
                slingResourceTypeIndex.removeProperty("entryCount");
            }
            IndexPropertyUtil.property(index, "slingResourceType", "sling:resourceType");
            IndexPropertyUtil.property(index, "slingResourceSuperType", "sling:resourceSuperType");
            IndexPropertyUtil.property(index, "slingVanityPath", "sling:vanityPath");
            IndexPropertyUtil.property(index, "slingeventEventId", "slingevent:eventId");
            IndexPropertyUtil.property(index, "cqCloudServiceConfigs", "cq:cloudserviceconfigs");
            IndexPropertyUtil.property(index, "cqCloudServiceConfig", "cq:cloudserviceconfig");
            IndexPropertyUtil.property(index, "cqCugEnabled", "cq:cugEnabled");
            IndexPropertyUtil.property(index, "cqDefaultFormFor", "cq:defaultFormFor");
            IndexPropertyUtil.property(index, "cqKeywords", "cq:keywords");
            IndexPropertyUtil.property(index, "cqMaster", "cq:master");
            IndexPropertyUtil.property(index, "cqOwnerCanvasPage", "cq:ownerCanvasPage");
            IndexPropertyUtil.property(index, "cqParentPath", "cq:parentPath");
            IndexPropertyUtil.property(index, "cqTemplate", "cq:template");
            IndexPropertyUtil.property(index, "cqVariantFamily", "cq:variantFamily");
            IndexPropertyUtil.property(index, "damResolvedPath", "dam:resolvedPath");
            IndexPropertyUtil.property(index, "damScene7ID", "dam:scene7ID");
            IndexPropertyUtil.property(index, "damS7watch", "dam:s7Swatch");
            IndexPropertyUtil.property(index, "containeeInstanceId", "containeeInstanceId");
            IndexPropertyUtil.property(index, "contentPath", "contentPath");
            IndexPropertyUtil.property(index, "event.job.topic", "event.job.topic");
            IndexPropertyUtil.property(index, "extensionType", "extensionType");
            IndexPropertyUtil.property(index, "lockCreated", "lock.created");
            IndexPropertyUtil.property(index, "status", "status");
            IndexPropertyUtil.property(index, "type", "type");
            IndexPropertyUtil.property(index, "guideComponentType", "guideComponentType");
            IndexPropertyUtil.property(index, "fpContentType", "fpContentType");
            IndexPropertyUtil.property(index, "cqLastReplicationAction", "cq:lastReplicationAction");
            IndexPropertyUtil.property(index, "damStatus", "dam:status");
            IndexPropertyUtil.property(index, "verb", "verb");
            IndexPropertyUtil.property(index, "campaignpath", "campaignpath");
            IndexPropertyUtil.property(index, "cqAcUUID", "cq:acUUID");
            IndexPropertyUtil.property(index, "active", "active");
            IndexPropertyUtil.property(index, "deviceIdentificationMode", "cq:deviceIdentificationMode");
            IndexPropertyUtil.property(index, "cqPayloadPath", "path", "cq:Payload");
            if (!index.hasChildNode("lucene")) {
                NodeBuilder idx = LuceneIndexHelper.newLuceneIndexDefinition((NodeBuilder)index, (String)"lucene", (Set)LuceneIndexHelper.JR_PROPERTY_INCLUDES, (Set)ImmutableSet.of((Object)"analyticsProvider", (Object)"analyticsSnippet", (Object)"hideInNav", (Object)"offTime", (Object)"onTime", (Object)"cq:allowedTemplates", (Object[])new String[]{"cq:childrenOrder", "cq:cugEnabled", "cq:cugPrincipals", "cq:cugRealm", "cq:designPath", "cq:isCancelledForChildren", "cq:isDeep", "cq:lastModified", "cq:lastModifiedBy", "cq:lastPublished", "cq:lastPublishedBy", "cq:lastReplicated", "cq:lastReplicatedBy", "cq:lastReplicationAction", "cq:lastReplicationStatus", "cq:lastRolledout", "cq:lastRolledoutBy", "cq:name", "cq:parentPath", "cq:segments", "cq:siblingOrder", "cq:template", "cq:trigger", "cq:versionComment", "jcr:createdBy", "jcr:lastModifiedBy", "sling:alias", "sling:vanityPath", "async-status", "async-start", "async-done", "runtimeId", "leaderElectionId"}), (String)"async");
                idx.setProperty("compatVersion", (Object)2);
                idx.setProperty("codec", (Object)"Lucene46");
                idx.setProperty("async", (Object)"fulltext-async");
                idx.setProperty("indexPath", (Object)"/oak:index/lucene", Type.STRING);
                idx.setProperty("excludedPaths", GENERIC_LUCENE_EXCLUDES, Type.STRINGS);
                NodeBuilder aggregates = idx.child("aggregates").setProperty("jcr:primaryType", (Object)"nt:unstructured", Type.NAME);
                aggregates.child("nt:file").setProperty("jcr:primaryType", (Object)"nt:unstructured", Type.NAME).child("include0").setProperty("jcr:primaryType", (Object)"nt:unstructured", Type.NAME).setProperty("path", (Object)"jcr:content").setProperty("relativeNode", (Object)false);
            }
            if (index.hasChildNode("nodetype")) {
                nodeType = index.child("nodetype");
                int version = Version.getIndexVersion(nodeType);
                if (version == -1) {
                    nodeType.removeProperty("declaringNodeTypes");
                }
                if (version < Version.AVAILABLE_VERSIONS.last().getVersion()) {
                    Set<String> declarigNodeTypes = Version.processDeclaringNodeTypes(nodeType, Version.AVAILABLE_VERSIONS);
                    nodeType = IndexUtils.createIndexDefinition((NodeBuilder)index, (String)"nodetype", (boolean)true, (boolean)false, (Collection)ImmutableList.of((Object)"jcr:primaryType", (Object)"jcr:mixinTypes"), declarigNodeTypes);
                    nodeType.setProperty("nodeTypeListDefined", (Object)true).setProperty("version", (Object)Long.valueOf(Version.AVAILABLE_VERSIONS.last().getVersion()), Type.LONG).setProperty("reindex", (Object)true);
                }
            }
            if ((nodeType = index.getChildNode("nodetype")).exists() && nodeType.hasProperty("entryCount")) {
                nodeType.removeProperty("entryCount");
            }
            if (!index.hasChildNode("counter")) {
                index.child("counter").setProperty("jcr:primaryType", (Object)"oak:QueryIndexDefinition", Type.NAME).setProperty("type", (Object)"counter").setProperty("async", (Object)"async");
            }
            IndexPropertyUtil.luceneProperty(index, "workflowDataLucene", false, null, null, null, new LucenePropertyIndexDefinition("workflow", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("granite:InboxItem", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("startTime", true, "startTime", 5, true), (Object)new LuceneIndexProperty("assignee", true, "assignee", 1), (Object)new LuceneIndexProperty("status", true, "status", 1))), (Object)new LuceneIndexRule("cq:Workflow", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("startTime", true, "startTime", 5, true), (Object)new LuceneIndexProperty("endTime", true, "endTime", 5, true), (Object)new LuceneIndexProperty("status", true, "status", 1))))));
            IndexPropertyUtil.luceneProperty(index, "ntBaseLucene", false, null, GENERIC_LUCENE_EXCLUDES, null, new LucenePropertyIndexDefinition("tags", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("nt:base", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("cqTags", true, "cq:tags", 1), (Object)new LuceneIndexProperty("offTime", true, "offTime", 5, true), (Object)new LuceneIndexProperty("onTime", true, "onTime", 5, true), (Object)new LuceneIndexProperty("analytics_pageviews", true, "analytics_pageviews", 3, true), (Object)new LuceneIndexProperty("analytics_visitors", true, "analytics_visitors", 3, true), (Object)new LuceneIndexProperty("analytics_averagetimespentonpage", true, "analytics_averagetimespentonpage", Integer.MIN_VALUE, true), (Object[])new LuceneIndexProperty[0])))));
            IndexPropertyUtil.luceneProperty(index, "cqTagLucene", false, null, GENERIC_LUCENE_EXCLUDES, null, new LucenePropertyIndexDefinition("cqTag", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("cq:Tag", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("jcrTitle", true, "jcr:title", 1, false, true), (Object)new LuceneIndexProperty("cqMovedTo", true, "cq:movedTo", 1))))));
            if (!index.hasChildNode("users")) {
                includes = new LucenePropertyIndexDefinition("users", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("rep:User", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("repPrincipalName", true, "rep:principalName", 1, true, true), (Object)new LuceneIndexProperty("repAuthorizableId", true, "rep:authorizableId", 1, true, true).withUseInSuggest(true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("profileEmail", true, "profile/email", 1, false, true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("profileGivenName", true, "profile/givenName", 1, false, true).withUseInSuggest(true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("profileFamilyName", true, "profile/familyName", 1, false, true).withUseInSuggest(true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("profileGender", true, "profile/gender", 1, false, true).withNodeScopeIndex(true), (Object[])new LuceneIndexProperty[0]))));
                IndexPropertyUtil.luceneProperty(index, "users", false, null, GENERIC_LUCENE_EXCLUDES, null, includes);
            }
            if (!index.hasChildNode("groups")) {
                includes = new LucenePropertyIndexDefinition("groups", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("rep:Group", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("repPrincipalName", true, "rep:principalName", 1, true, true), (Object)new LuceneIndexProperty("repAuthorizableId", true, "rep:authorizableId", 1, true, true).withUseInSuggest(true).withNodeScopeIndex(true)))));
                IndexPropertyUtil.luceneProperty(index, "groups", false, null, GENERIC_LUCENE_EXCLUDES, null, includes);
            }
            LuceneAggregateDefinition cqPageAggregates = new LuceneAggregateDefinition("cq:Page", (Set<LuceneAggregate>)ImmutableSet.of((Object)new LuceneAggregate("cq:Page", (Set<LuceneAggregateInclude>)ImmutableSet.of((Object)new LuceneAggregateInclude("include0", "jcr:content", true, null))), (Object)new LuceneAggregate("nt:file", (Set<LuceneAggregateInclude>)ImmutableSet.of((Object)new LuceneAggregateInclude("include0", "jcr:content"))), (Object)new LuceneAggregate("cq:PageContent", (Set<LuceneAggregateInclude>)ImmutableSet.of((Object)new LuceneAggregateInclude("include0", "*"), (Object)new LuceneAggregateInclude("include1", "*/*"), (Object)new LuceneAggregateInclude("include2", "*/*/*"), (Object)new LuceneAggregateInclude("include3", "*/*/*/*")))));
            LucenePropertyIndexDefinition cqPageIncludes = new LucenePropertyIndexDefinition("cq:Page", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("cq:Page", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("cqLastModified", true, "jcr:content/cq:lastModified", 5, true, false), (Object)new LuceneIndexProperty("jcrTitle", true, "jcr:content/jcr:title", 1, false, false, true, true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("pageTitle", true, "jcr:content/pageTitle", 1, false, false, true, true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("navTitle", true, "jcr:content/navTitle", 1, false, false, true, true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("nodeName", true, ":nodeName", 1, false, false, true, true).withNodeScopeIndex(true), (Object)new LuceneIndexProperty("cqLastRolledoutBy", true, "jcr:content/cq:lastRolledoutBy", 1), (Object[])new LuceneIndexProperty[0]))));
            IndexPropertyUtil.luceneProperty(index, "cqPageLucene", true, null, GENERIC_LUCENE_EXCLUDES, cqPageAggregates, cqPageIncludes);
            if (!index.hasChildNode("cqProjectLucene")) {
                LuceneAggregateDefinition cqProjectAggregates = new LuceneAggregateDefinition("cq:Project", (Set<LuceneAggregate>)ImmutableSet.of((Object)new LuceneAggregate("cq:Project", (Set<LuceneAggregateInclude>)ImmutableSet.of((Object)new LuceneAggregateInclude("include0", "jcr:content", true, null)))));
                LucenePropertyIndexDefinition cqProjectIncludes = new LucenePropertyIndexDefinition("cq:Project", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("cq:Project", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("cqTemplate", true, "jcr:content/cq:template", 1), (Object)new LuceneIndexProperty("jcrTitle", true, "jcr:content/jcr:title", 1, false, true, true, true), (Object)new LuceneIndexProperty("jcrDescription", true, "jcr:content/jcr:description", 1, false, true, true, true), (Object)new LuceneIndexProperty("projectdueDate", true, "jcr:content/project.dueDate", 5, true), (Object)new LuceneIndexProperty("active", true, "jcr:content/active", 6)))));
                IndexPropertyUtil.luceneProperty(index, "cqProjectLucene", false, null, GENERIC_LUCENE_EXCLUDES, cqProjectAggregates, cqProjectIncludes);
            }
            IndexPropertyUtil.luceneProperty(index, "slingeventJob", false, ImmutableList.of((Object)"/var/eventing"), null, null, new LucenePropertyIndexDefinition("slingevent:Job", (Set<LuceneIndexRule>)ImmutableSet.of((Object)new LuceneIndexRule("slingevent:Job", (Set<LuceneIndexProperty>)ImmutableSet.of((Object)new LuceneIndexProperty("eventJobTopic", true, "event.job.topic", 1, false, true), (Object)new LuceneIndexProperty("slingeventCreated", true, "slingevent:created", 5, true), (Object)new LuceneIndexProperty("finishedState", true, "slingevent:finishedState", 1).withNullCheckEnabled(true))))));
            IndexPropertyUtil.disableOrderedOrProperty(index, "damSha1");
            IndexPropertyUtil.disableOrderedOrProperty(index, "videoCodec");
            IndexPropertyUtil.disableOrderedOrProperty(index, "xmpMMDocumentId");
            IndexPropertyUtil.disableOrderedOrProperty(index, "xmpMMInstanceId");
            IndexPropertyUtil.disableOrderedOrProperty(index, "damFileSize");
            IndexPropertyUtil.disableOrderedOrProperty(index, "dcFormat");
            IndexPropertyUtil.disableOrderedOrProperty(index, "onTime");
            IndexPropertyUtil.disableOrderedOrProperty(index, "offTime");
            IndexPropertyUtil.disableOrderedOrProperty(index, "cqLastModified");
            IndexPropertyUtil.disableOrderedOrProperty(index, "analytics_pageviews");
            IndexPropertyUtil.disableOrderedOrProperty(index, "analytics_visitors");
            IndexPropertyUtil.disableOrderedOrProperty(index, "analytics_averagetimespentonpage");
            IndexPropertyUtil.disableOrderedOrProperty(index, "cqLastRolledoutBy");
            IndexPropertyUtil.disableOrderedOrProperty(index, "event.job.topic");
        }
    }
}