mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
SEARCH-180: Changing to alfresco,archive properties passed in.
This commit is contained in:
@@ -97,8 +97,8 @@ public class AlfrescoCoreAdminHandler extends CoreAdminHandler
|
||||
informationServers = new ConcurrentHashMap<String, InformationServer>();
|
||||
this.scheduler = new SolrTrackerScheduler(this);
|
||||
|
||||
boolean createDefaultCores = Boolean.valueOf(ConfigUtil.locateProperty(ALFRESCO_DEFAULTS, "false"));
|
||||
if (createDefaultCores)
|
||||
String createDefaultCores = ConfigUtil.locateProperty(ALFRESCO_DEFAULTS, "");
|
||||
if (createDefaultCores != null && !createDefaultCores.isEmpty())
|
||||
{
|
||||
Runnable runnable = () ->
|
||||
{
|
||||
@@ -110,18 +110,7 @@ public class AlfrescoCoreAdminHandler extends CoreAdminHandler
|
||||
{
|
||||
//Don't care
|
||||
}
|
||||
|
||||
log.info("Attempting to create default alfresco cores, workspace and archive stores.");
|
||||
SolrQueryResponse response = new SolrQueryResponse();
|
||||
try
|
||||
{
|
||||
newDefaultCore("alfresco", StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
|
||||
newDefaultCore("archive", StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Failed to create default alfresco cores (workspace/archive stores)", e);
|
||||
}
|
||||
setupNewDefaultCores(createDefaultCores);
|
||||
};
|
||||
|
||||
Thread thread = new Thread(runnable);
|
||||
@@ -129,6 +118,39 @@ public class AlfrescoCoreAdminHandler extends CoreAdminHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new default cores based on the "createDefaultCores" String passed in
|
||||
* @param createDefaultCores comma delimited list of corenames.
|
||||
*/
|
||||
protected void setupNewDefaultCores(String createDefaultCores)
|
||||
{
|
||||
|
||||
SolrQueryResponse response = new SolrQueryResponse();
|
||||
try
|
||||
{
|
||||
String[] coreNames = createDefaultCores.toLowerCase().split(",");
|
||||
for (String coreName:coreNames)
|
||||
{
|
||||
log.info("Attempting to create default alfresco core: "+coreName);
|
||||
switch (coreName)
|
||||
{
|
||||
case "archive":
|
||||
newDefaultCore("archive", StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
|
||||
break;
|
||||
case "alfresco":
|
||||
newDefaultCore("alfresco", StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DEFAULT_TEMPLATE, null, response);
|
||||
break;
|
||||
default:
|
||||
log.error("Invalid '"+ALFRESCO_DEFAULTS+"' permitted values are alfresco,archive");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Failed to create default alfresco cores (workspace/archive stores)", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutsdown services that exist outside of the core.
|
||||
*/
|
||||
|
||||
@@ -1551,7 +1551,9 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
{
|
||||
destroyServers();
|
||||
distribTearDown();
|
||||
FileUtils.deleteDirectory(testDir);
|
||||
|
||||
boolean keepTests = Boolean.valueOf(System.getProperty("keep.tests"));
|
||||
if (!keepTests) FileUtils.deleteDirectory(testDir);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.solr;
|
||||
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CoreAdminParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.core.CoreContainer;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.alfresco.solr.AlfrescoSolrUtils.assertSummaryCorrect;
|
||||
import static org.alfresco.solr.AlfrescoSolrUtils.getCore;
|
||||
|
||||
/**
|
||||
* Tests creating the default alfresco cores with a property.
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
@SolrTestCaseJ4.SuppressSSL
|
||||
@LuceneTestCase.SuppressCodecs({"Appending","Lucene3x","Lucene40","Lucene41","Lucene42","Lucene43", "Lucene44", "Lucene45","Lucene46","Lucene47","Lucene48","Lucene49"})
|
||||
public class CoresCreateViaPropertyTest extends AbstractAlfrescoDistributedTest
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
final String JETTY_SERVER_ID = this.getClass().getSimpleName();
|
||||
|
||||
@Rule
|
||||
public JettyServerRule jetty = new JettyServerRule(JETTY_SERVER_ID, 0, null, null);
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setProps()
|
||||
{
|
||||
System.setProperty(AlfrescoCoreAdminHandler.ALFRESCO_DEFAULTS, "alfresco,archive");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
protected static void cleanupProp()
|
||||
{
|
||||
System.clearProperty(AlfrescoCoreAdminHandler.ALFRESCO_DEFAULTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newCoreUsingAllDefaults() throws Exception
|
||||
{
|
||||
CoreContainer coreContainer = jettyContainers.get(JETTY_SERVER_ID).getCoreContainer();
|
||||
|
||||
//Now create the new core with
|
||||
AlfrescoCoreAdminHandler coreAdminHandler = (AlfrescoCoreAdminHandler) coreContainer.getMultiCoreHandler();
|
||||
assertNotNull(coreAdminHandler);
|
||||
|
||||
TimeUnit.SECONDS.sleep(15); //Wait a little for background threads to catchup
|
||||
|
||||
//Get a reference to the new core
|
||||
SolrCore defaultCore = getCore(coreContainer, "alfresco");
|
||||
SolrCore archiveCore = getCore(coreContainer, "archive");
|
||||
|
||||
assertNotNull(defaultCore);
|
||||
assertNotNull(archiveCore);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.solr.config;
|
||||
|
||||
import org.alfresco.solr.AlfrescoCoreAdminHandler;
|
||||
import org.alfresco.solr.SolrInformationServer;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class ConfigUtilTest {
|
||||
assertEquals("SOLR_GETHIN",ConfigUtil.convertPropertyNameToEnvironmentParam("gethin"));
|
||||
assertEquals("SOLR_SOLR_CONTENT_DIR",ConfigUtil.convertPropertyNameToEnvironmentParam("solr.content.dir"));
|
||||
assertEquals("SOLR_SOLR_MODEL_DIR",ConfigUtil.convertPropertyNameToEnvironmentParam("solr.model.dir"));
|
||||
assertEquals("SOLR_CREATE_ALFRESCO_DEFAULTS",ConfigUtil.convertPropertyNameToEnvironmentParam(AlfrescoCoreAdminHandler.ALFRESCO_DEFAULTS));
|
||||
assertEquals("SOLR_SOLR_HOST",ConfigUtil.convertPropertyNameToEnvironmentParam(SolrInformationServer.SOLR_HOST));
|
||||
assertEquals("SOLR_SOLR_PORT",ConfigUtil.convertPropertyNameToEnvironmentParam(SolrInformationServer.SOLR_PORT));
|
||||
assertEquals("SOLR_SOLR_BASEURL",ConfigUtil.convertPropertyNameToEnvironmentParam(SolrInformationServer.SOLR_BASEURL));
|
||||
|
||||
@@ -25,6 +25,8 @@ services:
|
||||
#Alfresco needs to know how to call solr
|
||||
SOLR_SOLR_HOST: solr6
|
||||
SOLR_SOLR_PORT: 8983
|
||||
#Create the alfresco and archive cores
|
||||
SOLR_CREATE_ALFRESCO_DEFAULTS : alfresco,archive
|
||||
ports:
|
||||
- "8083:8983" #Browser port
|
||||
- "1044:1044" #Java debugging
|
||||
|
||||
Reference in New Issue
Block a user