Package org.apache.cocoon.components.search.components

Examples of org.apache.cocoon.components.search.components.IndexManager


            String newPublicationId, String publicationsUri) throws MalformedURLException,
            IOException, ParserConfigurationException, SAXException, SourceNotFoundException,
            TransformerConfigurationException, TransformerException, ServiceException,
            ConfigurationException {
        ModifiableSource indexSource = null;
        IndexManager indexManager = null;
        try {

            // RGE: Soc addition
            // First, patch the xconf patchfile with the new publication name

            String indexDir = "lenya/pubs/" + newPublicationId + "/work/lucene/index";

            indexSource = (ModifiableSource) resolver
                    .resolveURI(publicationsUri
                            + "/"
                            + newPublicationId
                            + "/config/"
                            + org.apache.cocoon.components.search.components.impl.IndexManagerImpl.INDEX_CONF_FILE);
            Document indexDoc = DocumentHelper.readDocument(indexSource.getInputStream());
            Element[] indexElement = DocumentHelper.getChildren(indexDoc.getDocumentElement(),
                    null, "index");

            for (int i = 0; i < indexElement.length; i++) {
                String id = indexElement[i].getAttribute("id");
                String area = id.split("-")[1];
                indexElement[i].setAttribute("id", newPublicationId + "-" + area);
                indexElement[i].setAttribute("directory", indexDir + "/" + area + "/index");
            }

            save(indexDoc, indexSource);

            // Second, configure the index and add it to the IndexManager

            indexManager = (IndexManager) manager.lookup(IndexManager.ROLE);

            indexManager.addIndexes(indexSource);

            // TODO: release all objects!

            // RGE: End Soc addition
View Full Code Here


            }
        }
    }

    protected void setIndexer(String indexId) throws SAXException {
        IndexManager indexManager = null;
        try {
            indexManager = (IndexManager) manager.lookup(IndexManager.ROLE);
            index = indexManager.getIndex(indexId);
            if (index == null) {
                handleError("index [" + indexId + "] no found in the index definition");
            }
            else {
                indexer = index.getIndexer();
View Full Code Here

        String clear = atts.getValue(LUCENE_URI, LUCENE_INDEXING_CREATE_ATTRIBUTE);
        attrs = new AttributesImpl(atts);

        // set the indexer
        try {
            IndexManager indexM = (IndexManager) manager.lookup(IndexManager.ROLE);
            index = indexM.getIndex(id);
            if (index == null) {
                handleError("index [" + id + "] no found in the index definition");
            }
            indexer = index.getIndexer();
            manager.release(indexM);
View Full Code Here

            String newPublicationId, String publicationsUri) throws MalformedURLException,
            IOException, ParserConfigurationException, SAXException, SourceNotFoundException,
            TransformerConfigurationException, TransformerException, ServiceException,
            ConfigurationException {
        ModifiableSource indexSource = null;
        IndexManager indexManager = null;
        try {

            // RGE: Soc addition
            // First, patch the xconf patchfile with the new publication name

            String indexDir = "lenya/pubs/" + newPublicationId + "/work/lucene/index";

            indexSource = (ModifiableSource) resolver
                    .resolveURI(publicationsUri
                            + "/"
                            + newPublicationId
                            + "/config/"
                            + org.apache.cocoon.components.search.components.impl.IndexManagerImpl.INDEX_CONF_FILE);
            Document indexDoc = DocumentHelper.readDocument(indexSource.getInputStream());
            Element[] indexElement = DocumentHelper.getChildren(indexDoc.getDocumentElement(),
                    null, "index");

            for (int i = 0; i < indexElement.length; i++) {
                String id = indexElement[i].getAttribute("id");
                String area = id.split("-")[1];
                indexElement[i].setAttribute("id", newPublicationId + "-" + area);
                indexElement[i].setAttribute("directory", indexDir + "/" + area + "/index");
            }

            save(indexDoc, indexSource);

            // Second, configure the index and add it to the IndexManager

            indexManager = (IndexManager) manager.lookup(IndexManager.ROLE);

            indexManager.addIndexes(indexSource);

            // TODO: release all objects!

            // RGE: End Soc addition
View Full Code Here

*/
public class SearchTest extends AbstractAccessControlTest {

    public void testSearch() throws Exception {
        LuceneCocoonSearcher searcher = null;
        IndexManager indexManager = null;
        try {
            searcher = (LuceneCocoonSearcher) getManager().lookup(LuceneCocoonSearcher.ROLE);
            indexManager = (IndexManager) getManager().lookup(IndexManager.ROLE);
            Index index = indexManager.getIndex("test-authoring");
            searcher.setDirectory(index.getDirectory());

            Term term = new Term("body", "tutorial");
            Query query = new TermQuery(term);

View Full Code Here

            String newPublicationId, String publicationsUri) throws MalformedURLException,
            IOException, ParserConfigurationException, SAXException, SourceNotFoundException,
            TransformerConfigurationException, TransformerException, ServiceException,
            ConfigurationException {
        ModifiableSource indexSource = null;
        IndexManager indexManager = null;
        try {

            // RGE: Soc addition
            // First, patch the xconf patchfile with the new publication name

            String indexDir = "lenya/pubs/" + newPublicationId + "/work/lucene/index";

            indexSource = (ModifiableSource) resolver
                    .resolveURI(publicationsUri
                            + "/"
                            + newPublicationId
                            + "/config/"
                            + org.apache.cocoon.components.search.components.impl.IndexManagerImpl.INDEX_CONF_FILE);
            Document indexDoc = DocumentHelper.readDocument(indexSource.getInputStream());
            Element[] indexElement = DocumentHelper.getChildren(indexDoc.getDocumentElement(),
                    null, "index");

            for (int i = 0; i < indexElement.length; i++) {
                String id = indexElement[i].getAttribute("id");
                String area = id.split("-")[1];
                indexElement[i].setAttribute("id", newPublicationId + "-" + area);
                indexElement[i].setAttribute("directory", indexDir + "/" + area + "/index");
            }

            save(indexDoc, indexSource);

            // Second, configure the index and add it to the IndexManager

            indexManager = (IndexManager) this.manager.lookup(IndexManager.ROLE);

            indexManager.addIndexes(indexSource);

            // TODO: release all objects!

            // RGE: End Soc addition
View Full Code Here

    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
            throws ConfigurationException {

        String value = null;
       
        IndexManager indexManager = null;
        try {
            indexManager = (IndexManager) this.serviceManager.lookup(IndexManager.ROLE);
           
            Index index = indexManager.getIndex(name);
           
            if (index == null) {
                throw new ConfigurationException("no search index with id [" + name + "] found.");
            }
           
View Full Code Here

            }
        }
    }

    protected void setIndexer(String indexId) throws SAXException {
        IndexManager indexManager = null;
        try {
            indexManager = (IndexManager) manager.lookup(IndexManager.ROLE);
            index = indexManager.getIndex(indexId);
            if (index == null) {
                handleError("index [" + indexId + "] no found in the index definition");
            }
            else {
                indexer = index.getIndexer();
View Full Code Here

TOP

Related Classes of org.apache.cocoon.components.search.components.IndexManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.