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

LMS-2766 Introducing property 'disabled-technologies' in service.properties to...

LMS-2766 Introducing property 'disabled-technologies' in service.properties to disable technologies in GUI and core plugins.

SVN: 24364
parent f284a6b6
No related branches found
No related tags found
No related merge requests found
Showing
with 119 additions and 11 deletions
...@@ -61,10 +61,8 @@ public abstract class AbstractClientPluginFactory<V extends IViewContext<? exten ...@@ -61,10 +61,8 @@ public abstract class AbstractClientPluginFactory<V extends IViewContext<? exten
protected boolean checkEnabledProperty(String technology) protected boolean checkEnabledProperty(String technology)
{ {
String enabledProperty = return viewContext.getModel().getApplicationInfo().getDisabledTechnologies()
viewContext.getModel().getApplicationInfo().getWebClientConfiguration() .contains(technology) == false;
.getPropertyOrNull(technology, "enabled");
return enabledProperty == null || Boolean.TRUE.toString().equals(enabledProperty);
} }
protected abstract IModule maybeCreateModule(); protected abstract IModule maybeCreateModule();
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.dto; package ch.systemsx.cisd.openbis.generic.client.web.client.dto;
import java.util.Set;
import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.rpc.IsSerializable;
import ch.systemsx.cisd.openbis.generic.shared.basic.annotation.DoNotEscape; import ch.systemsx.cisd.openbis.generic.shared.basic.annotation.DoNotEscape;
...@@ -39,6 +41,8 @@ public final class ApplicationInfo implements IsSerializable ...@@ -39,6 +41,8 @@ public final class ApplicationInfo implements IsSerializable
private WebClientConfiguration webClientConfiguration; private WebClientConfiguration webClientConfiguration;
private Set<String> disabledTechnologies;
private int maxResults = 100000; private int maxResults = 100000;
public int getMaxResults() public int getMaxResults()
...@@ -104,4 +108,14 @@ public final class ApplicationInfo implements IsSerializable ...@@ -104,4 +108,14 @@ public final class ApplicationInfo implements IsSerializable
return webClientConfiguration; return webClientConfiguration;
} }
public Set<String> getDisabledTechnologies()
{
return disabledTechnologies;
}
public void setDisabledTechnologies(Set<String> disabledTechnologies)
{
this.disabledTechnologies = disabledTechnologies;
}
} }
...@@ -77,6 +77,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader; ...@@ -77,6 +77,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelColumnHeader;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.WebClientConfiguration;
import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO;
import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils;
/** /**
* An <i>abstract</i> {@link IClientService} implementation. * An <i>abstract</i> {@link IClientService} implementation.
...@@ -431,6 +432,8 @@ public abstract class AbstractClientService implements IClientService, ...@@ -431,6 +432,8 @@ public abstract class AbstractClientService implements IClientService,
applicationInfo.setWebClientConfiguration(commonApplicationInfo applicationInfo.setWebClientConfiguration(commonApplicationInfo
.getWebClientConfiguration()); .getWebClientConfiguration());
} }
applicationInfo.setDisabledTechnologies(ServerUtils.extractSet(getServiceProperties()
.getProperty("disabled-technologies")));
applicationInfo.setArchivingConfigured(isArchivingConfigured()); applicationInfo.setArchivingConfigured(isArchivingConfigured());
applicationInfo.setVersion(getVersion()); applicationInfo.setVersion(getVersion());
return applicationInfo; return applicationInfo;
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
package ch.systemsx.cisd.openbis.generic.server.coreplugin; package ch.systemsx.cisd.openbis.generic.server.coreplugin;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
...@@ -25,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse; ...@@ -25,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.server.ICommonServerForInternalUse;
import ch.systemsx.cisd.openbis.generic.server.coreplugin.CorePluginScanner.ScannerType; import ch.systemsx.cisd.openbis.generic.server.coreplugin.CorePluginScanner.ScannerType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CorePlugin; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CorePlugin;
import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO;
import ch.systemsx.cisd.openbis.generic.shared.util.ServerUtils;
/** /**
* @author Kaloyan Enimanev * @author Kaloyan Enimanev
...@@ -37,6 +41,8 @@ public class CorePluginRegistrator implements InitializingBean ...@@ -37,6 +41,8 @@ public class CorePluginRegistrator implements InitializingBean
private String pluginsFolderName; private String pluginsFolderName;
private Set<String> disabledTechnologies = new HashSet<String>();
/** /**
* Loads and installs the deployed core plugins. Invoked from the Spring container after the * Loads and installs the deployed core plugins. Invoked from the Spring container after the
* object is initialized. * object is initialized.
...@@ -54,12 +60,15 @@ public class CorePluginRegistrator implements InitializingBean ...@@ -54,12 +60,15 @@ public class CorePluginRegistrator implements InitializingBean
String sessionToken = getSessionToken(); String sessionToken = getSessionToken();
for (CorePlugin plugin : pluginScanner.scanForPlugins()) for (CorePlugin plugin : pluginScanner.scanForPlugins())
{ {
try if (disabledTechnologies.contains(plugin.getName()) == false)
{
commonServer.registerPlugin(sessionToken, plugin, pluginScanner);
} catch (Exception ex)
{ {
operationLog.error("Failed to install core plugin: " + plugin, ex); try
{
commonServer.registerPlugin(sessionToken, plugin, pluginScanner);
} catch (Exception ex)
{
operationLog.error("Failed to install core plugin: " + plugin, ex);
}
} }
} }
} }
...@@ -75,6 +84,11 @@ public class CorePluginRegistrator implements InitializingBean ...@@ -75,6 +84,11 @@ public class CorePluginRegistrator implements InitializingBean
this.pluginsFolderName = pluginsFolderName; this.pluginsFolderName = pluginsFolderName;
} }
public void setDisabledTechnologies(String listOfDisabledTechnologies)
{
disabledTechnologies = ServerUtils.extractSet(listOfDisabledTechnologies);
}
public void setCommonServer(ICommonServerForInternalUse commonServer) public void setCommonServer(ICommonServerForInternalUse commonServer)
{ {
this.commonServer = commonServer; this.commonServer = commonServer;
......
...@@ -59,4 +59,24 @@ public class ServerUtils ...@@ -59,4 +59,24 @@ public class ServerUtils
} }
return duplicated; return duplicated;
} }
/**
* Extracts from the comma-separated list of strings all distinct strings.
*
* @return an empty list if the argument is <code>null</code>, an empty string or starts with
* '${'.
*/
public static Set<String> extractSet(String commaSeparatedList)
{
Set<String> result = new HashSet<String>();
if (commaSeparatedList != null && commaSeparatedList.startsWith("${") == false)
{
String[] terms = commaSeparatedList.split(",");
for (String term : terms)
{
result.add(term.trim());
}
}
return result;
}
} }
...@@ -229,6 +229,7 @@ ...@@ -229,6 +229,7 @@
<bean id="core-plugin-registrator" class="ch.systemsx.cisd.openbis.generic.server.coreplugin.CorePluginRegistrator"> <bean id="core-plugin-registrator" class="ch.systemsx.cisd.openbis.generic.server.coreplugin.CorePluginRegistrator">
<property name="commonServer" ref="common-server"/> <property name="commonServer" ref="common-server"/>
<property name="pluginsFolderName" value="${core-plugins-folder}"/> <property name="pluginsFolderName" value="${core-plugins-folder}"/>
<property name="disabledTechnologies" value="${disabled-technologies}"/>
</bean> </bean>
<!-- <!--
......
/*
* Copyright 2012 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.shared.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
/**
* @author Franz-Josef Elmer
*/
public class ServerUtilsTest extends AssertJUnit
{
@Test
public void testExtractSetWithNullArgument()
{
assertEquals("[]", ServerUtils.extractSet(null).toString());
}
@Test
public void testExtractSetWithUnassignedProperty()
{
assertEquals("[]", ServerUtils.extractSet("${blabla}").toString());
}
@Test
public void testExtractSetWithOneElement()
{
assertEquals("[blabla]", ServerUtils.extractSet(" blabla ").toString());
}
@Test
public void testExtractSetWithThreeElementsOneDuplicated()
{
Set<String> set = ServerUtils.extractSet(" a, b, a ");
ArrayList<String> list = new ArrayList<String>(set);
Collections.sort(list);
assertEquals("[a, b]", list.toString());
}
}
...@@ -89,7 +89,6 @@ microscopy-dataset-view.hide-file-view = true ...@@ -89,7 +89,6 @@ microscopy-dataset-view.hide-file-view = true
technologies = proteomics, screening technologies = proteomics, screening
#proteomics.enabled = false
# Relative path of cache. Default value is 'cache'. # Relative path of cache. Default value is 'cache'.
proteomics.cache-folder = ../../../web-client-data-cache proteomics.cache-folder = ../../../web-client-data-cache
# Minimum free disk space needed for the cache. Default value is 1 GB. # Minimum free disk space needed for the cache. Default value is 1 GB.
...@@ -97,7 +96,6 @@ proteomics.cache-folder = ../../../web-client-data-cache ...@@ -97,7 +96,6 @@ proteomics.cache-folder = ../../../web-client-data-cache
# Maximum retention time. Data older than this time will be removed from cache. Default value is a week. # Maximum retention time. Data older than this time will be removed from cache. Default value is a week.
#proteomics.maximum-retention-time-in-days = 7 #proteomics.maximum-retention-time-in-days = 7
#screening.enabled = false
screening.image-viewer-enabled = true screening.image-viewer-enabled = true
# Material properties of the configured type will be rendered as links # Material properties of the configured type will be rendered as links
# to the material detail view. # to the material detail view.
......
...@@ -72,6 +72,9 @@ hibernate.search.maxResults = 100000 ...@@ -72,6 +72,9 @@ hibernate.search.maxResults = 100000
# If 'async', the update of indices will be done in a separate thread. # If 'async', the update of indices will be done in a separate thread.
hibernate.search.worker.execution=async hibernate.search.worker.execution=async
# Comma-separated list of technologies which are disabled. By default all technologies are enabled.
#disabled-technologies = proteomics
web-client-configuration-file = etc/web-client.properties web-client-configuration-file = etc/web-client.properties
core-plugins-folder=dist/core-plugins core-plugins-folder=dist/core-plugins
......
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