com.adobe.cq.dam.index.builder.IndexRule Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2014 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
************************************************************************/
package com.adobe.cq.dam.index.builder;
import com.adobe.cq.dam.index.builder.api.PropertyDefinition;
import com.google.common.collect.ImmutableMap;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import java.util.HashMap;
import java.util.List;
/**
* This class represents IndexRule for Oak Lucene Index
*/
@Deprecated
public class IndexRule {
String primaryType;
List propertyDefinitions;
public IndexRule(String primaryType, List propDef) {
this.primaryType = primaryType;
this.propertyDefinitions = propDef;
}
/**
* @return return primaryType
for IndexRule
*/
public String primaryType() {
return primaryType;
}
/**
* @return PropertyDefinition
for IndexRule
*/
public List propertyDefinition() {
return propertyDefinitions;
}
/**
* Creates IndexRule
under given resource
*
* @throws PersistenceException
*/
public void build(Resource resource) throws PersistenceException {
ResourceResolver resolver = resource.getResourceResolver();
Resource primaryTypeNode = resolver.create(resource, primaryType, new HashMap());
Resource propertiesNode = resolver.create(primaryTypeNode, LuceneIndexConstants.PROP_NODE,
ImmutableMap.of(JcrConstants.JCR_PRIMARYTYPE, (Object) "nt:unstructured"));
for (PropertyDefinition propDef : propertyDefinitions) {
propDef.build(propertiesNode);
}
}
}