Skip to content
Snippets Groups Projects
Commit 4b0da559 authored by felmer's avatar felmer
Browse files

SP-71, BIS-52: disable all core-plugins in DSS for old installations.

SVN: 25534
parent 31ef6899
No related branches found
No related tags found
No related merge requests found
......@@ -57,11 +57,12 @@ public class SetEnableTechnologiesVariableAction implements PanelAction
{
// The technologyCheckBoxesAction is a 'preactivate' action to populate the technology check
// boxes.
// But in case of console installation the 'preactivate' action isn't execute. We can
// execute it here without any check whether we are console or GUI based installation
// because the GUI sets the technology flags and naothing will be populated from existing
// But in case of console installation the 'preactivate' action isn't executed. We can
// execute it here without any check whether this is a console-based or GUI-based
// installation
// because the GUI sets the technology flags and nothing will be populated from existing
// service.properties.
technologyCheckBoxesAction.executeAction(data, handler);
technologyCheckBoxesAction.executeAction(data, handler);
boolean isFirstTimeInstallation = GlobalInstallationContext.isFirstTimeInstallation;
File installDir = GlobalInstallationContext.installDir;
updateEnabledTechnologyProperty(data, isFirstTimeInstallation, installDir);
......@@ -84,7 +85,7 @@ public class SetEnableTechnologiesVariableAction implements PanelAction
private void updateDisabledDssPluginsProperty(AutomatedInstallData data, File installDir)
{
Set<String> disabledTechnologies = new LinkedHashSet<String>();
Set<String> technologies = new HashSet<String>();
Set<String> technologies = new LinkedHashSet<String>();
for (String technology : GlobalInstallationContext.TECHNOLOGIES)
{
String technologyFlag = data.getVariable(technology);
......@@ -96,12 +97,12 @@ public class SetEnableTechnologiesVariableAction implements PanelAction
}
File configFile = new File(installDir, Utils.DSS_PATH + Utils.SERVICE_PROPERTIES_PATH);
List<String> list = FileUtilities.loadToStringList(configFile);
updateDisabledDssPluginsProperty(list, technologies, disabledTechnologies);
updateDisabledDssPluginsProperty(list, technologies, disabledTechnologies, installDir);
Utils.updateConfigFile(configFile, list);
}
private void updateDisabledDssPluginsProperty(List<String> list, Set<String> technologies,
Set<String> disabledTechnologies)
Set<String> disabledTechnologies, File installDir)
{
for (int i = 0; i < list.size(); i++)
{
......@@ -117,7 +118,17 @@ public class SetEnableTechnologiesVariableAction implements PanelAction
return;
}
}
String pluginsList = mergeWithDisabledPluginsList("", technologies, disabledTechnologies);
String pluginsList;
if (Utils.hasCorePluginsFolder(installDir))
{
pluginsList = mergeWithDisabledPluginsList("", technologies, disabledTechnologies);
} else
{
// A very old openBIS instance does not have a core plugins folder. Thus, all
// core plugins have to be disabled in order to avoid possible conflicts of
// existing DSS service.properties with a core plugin.
pluginsList = mergeWithDisabledPluginsList("", technologies, technologies);
}
list.add(DISABLED_CORE_PLUGINS_KEY + " = " + pluginsList);
}
......@@ -174,7 +185,6 @@ public class SetEnableTechnologiesVariableAction implements PanelAction
builder.append(technology.toLowerCase());
}
}
System.out.println("disabled technologies:"+builder);
return builder.toString();
}
......
......@@ -39,11 +39,17 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities;
class Utils
{
private static final String SERVERS_PATH = "servers/";
static final String CORE_PLUGINS_PATH = SERVERS_PATH + "core-plugins/";
static final String AS_PATH = SERVERS_PATH + "openBIS-server/jetty/";
static final String DSS_PATH = SERVERS_PATH + "datastore_server/";
static final String SERVICE_PROPERTIES_PATH = "etc/service.properties";
static final String JETTY_XML_PATH = "etc/jetty.xml";
static final String KEYSTORE_PATH = "etc/openBIS.keystore";
static boolean hasCorePluginsFolder(File installDir)
{
return new File(installDir, CORE_PLUGINS_PATH).isDirectory();
}
static String tryToGetServicePropertyOfAS(File installDir, String propertyKey)
{
......
......@@ -45,6 +45,7 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities;
*/
public class SetEnableTechnologiesVariableActionTest extends AbstractFileSystemTestCase
{
private File corePluginsFolder;
private File configFile;
private File dssConfigFile;
......@@ -52,6 +53,8 @@ public class SetEnableTechnologiesVariableActionTest extends AbstractFileSystemT
@BeforeMethod
public void setUp()
{
corePluginsFolder = new File(workingDirectory, Utils.CORE_PLUGINS_PATH);
corePluginsFolder.mkdirs();
configFile = new File(workingDirectory, Utils.AS_PATH + Utils.SERVICE_PROPERTIES_PATH);
configFile.getParentFile().mkdirs();
dssConfigFile = new File(workingDirectory, Utils.DSS_PATH + Utils.SERVICE_PROPERTIES_PATH);
......@@ -68,6 +71,7 @@ public class SetEnableTechnologiesVariableActionTest extends AbstractFileSystemT
@AfterMethod
public void tearDown()
{
FileUtilities.deleteRecursively(corePluginsFolder);
configFile.delete();
dssConfigFile.delete();
}
......@@ -116,8 +120,9 @@ public class SetEnableTechnologiesVariableActionTest extends AbstractFileSystemT
}
@Test
public void testUpdateUnchangedProperty()
public void testUpdateInstallationWithoutCorePluginsFolder()
{
FileUtilities.deleteRecursively(corePluginsFolder);
FileUtilities.writeToFile(configFile, "abc = 123\n" + ENABLED_TECHNOLOGIES_KEY
+ "=proteomics");
Properties variables = new Properties();
......@@ -126,6 +131,23 @@ public class SetEnableTechnologiesVariableActionTest extends AbstractFileSystemT
updateEnabledTechnologyProperties(variables, false);
assertEquals("[abc = 123, " + ENABLED_TECHNOLOGIES_KEY + "=proteomics]", FileUtilities
.loadToStringList(configFile).toString());
assertEquals("[" + DISABLED_CORE_PLUGINS_KEY + " = proteomics, screening, illumina-ngs]",
FileUtilities.loadToStringList(dssConfigFile).toString());
}
@Test
public void testUpdateUnchangedProperty()
{
FileUtilities.writeToFile(configFile, "abc = 123\n" + ENABLED_TECHNOLOGIES_KEY
+ "=proteomics");
Properties variables = new Properties();
variables.setProperty(TECHNOLOGY_PROTEOMICS, "true");
variables.setProperty(TECHNOLOGY_SCREENING, "false");
updateEnabledTechnologyProperties(variables, false);
assertEquals("[abc = 123, " + ENABLED_TECHNOLOGIES_KEY + "=proteomics]", FileUtilities
.loadToStringList(configFile).toString());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment