Skip to content
Snippets Groups Projects
Commit 61139532 authored by brinn's avatar brinn
Browse files

[BIS-149/SP-237] Display settings for custom web UIs.

Change interface for web app settings to use WebAppSettings object and add methods getWebAppSettings and setWebAppSettings to IOpenbisServiceFacade.

SVN: 26339
parent ae0ee5a9
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import ch.systemsx.cisd.openbis.generic.shared.DatabaseCreateOrDeleteModificatio
import ch.systemsx.cisd.openbis.generic.shared.ICommonServer;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.NewVocabularyTerm;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.WebAppSettings;
import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind;
......@@ -108,7 +109,7 @@ public class GeneralInformationChangingService extends
@Transactional(readOnly = true)
@RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER)
@SuppressWarnings("deprecation")
public Map<String, String> getCustomDisplaySettings(String sessionToken, String webAppId)
public WebAppSettings getWebAppSettings(String sessionToken, String webAppId)
{
final Session session = getSession(sessionToken);
return session.getPerson().getDisplaySettings().getCustomWebAppSettings(webAppId);
......@@ -118,12 +119,11 @@ public class GeneralInformationChangingService extends
@Transactional(readOnly = false)
@RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER)
@SuppressWarnings("deprecation")
public void setCustomDisplaySettings(String sessionToken, String webAppId,
Map<String, String> customDisplaySettings)
public void setWebAppSettings(String sessionToken, WebAppSettings webAppSettings)
{
final Session session = getSession(sessionToken);
final DisplaySettings displaySettings = session.getPerson().getDisplaySettings();
displaySettings.setCustomWebAppSettings(webAppId, customDisplaySettings);
displaySettings.setCustomWebAppSettings(webAppSettings);
saveDisplaySettings(session.getSessionToken(), null, -1);
}
......
......@@ -23,6 +23,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext;
import ch.systemsx.cisd.openbis.generic.shared.AbstractServerLogger;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.NewVocabularyTerm;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.WebAppSettings;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
......@@ -65,17 +66,17 @@ class GeneralInformationChangingServiceLogger extends AbstractServerLogger imple
}
@Override
public Map<String, String> getCustomDisplaySettings(String sessionToken, String webAppId)
public WebAppSettings getWebAppSettings(String sessionToken, String webAppId)
{
logAccess(sessionToken, "get-custom-display-settings", "WEB_APP_ID(%s)", webAppId);
return null;
}
@Override
public void setCustomDisplaySettings(String sessionToken, String webAppId,
Map<String, String> customDisplaySettings)
public void setWebAppSettings(String sessionToken, WebAppSettings webAppSettings)
{
logAccess(sessionToken, "set-custom-display-settings", "WEB_APP_ID(%s)", webAppId);
logAccess(sessionToken, "set-custom-display-settings", "WEB_APP_ID(%s)",
webAppSettings.getWebAppId());
}
@Override
......
......@@ -22,6 +22,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.WebAppSettings;
/**
* Class storing personalized display settings. This class implements {@link Serializable} not only
* for transferring it's content remotely but also to store it in the database. Thus, CHANGES IN
......@@ -311,7 +313,7 @@ public class DisplaySettings implements Serializable
* @deprecated Don't use in generic web client - will be overwritten.
*/
@Deprecated
public synchronized Map<String, String> getCustomWebAppSettings(String webAppId)
public synchronized WebAppSettings getCustomWebAppSettings(String webAppId)
{
if (customWebAppDisplaySettings == null)
{
......@@ -323,21 +325,20 @@ public class DisplaySettings implements Serializable
settings = new HashMap<String, String>();
customWebAppDisplaySettings.put(webAppId, settings);
}
return settings;
return new WebAppSettings(webAppId, settings);
}
/**
* @deprecated Don't use in generic web client - will be overwritten.
*/
@Deprecated
public synchronized void setCustomWebAppSettings(String webAppId,
Map<String, String> customDisplaySettings)
public synchronized void setCustomWebAppSettings(WebAppSettings settings)
{
if (customWebAppDisplaySettings == null)
{
customWebAppDisplaySettings = new HashMap<String, Map<String, String>>();
}
customWebAppDisplaySettings.put(webAppId, customDisplaySettings);
customWebAppDisplaySettings.put(settings.getWebAppId(), settings.getSettings());
}
/**
......
......@@ -20,6 +20,7 @@ import java.util.Map;
import ch.systemsx.cisd.common.api.IRpcService;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.NewVocabularyTerm;
import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.WebAppSettings;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
/**
......@@ -64,23 +65,20 @@ public interface IGeneralInformationChangingService extends IRpcService
NewVocabularyTerm term);
/**
* Returns the custom display settings for a given custom web app.
* Returns the persistent settings for a given custom web app.
*
* @param webAppId The id of the custom web app to get the display settings for.
*
* @since 1.2
*/
public Map<String, String> getCustomDisplaySettings(String sessionToken, String webAppId);
public WebAppSettings getWebAppSettings(String sessionToken, String webAppId);
/**
* Sets the custom display settings for a given custom web app.
*
* @param webAppId The id of the custom web app to set the display settings for.
* @param customDisplaySettings The new display settings
* Sets the persistent settings for a given custom web app.
* @param webAppSettings The new display settings
*
* @since 1.2
*/
public void setCustomDisplaySettings(String sessionToken, String webAppId,
Map<String, String> customDisplaySettings);
public void setWebAppSettings(String sessionToken, WebAppSettings webAppSettings);
}
/*
* 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.api.v1.dto;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import ch.systemsx.cisd.base.annotation.JsonObject;
/**
* A map containing persistent settings for an openBIS web app.
*
* @author Bernd Rinn
*/
@JsonObject("WebAppSettings")
public class WebAppSettings implements Serializable, Map<String, String>
{
private static final long serialVersionUID = 1L;
private String webAppId;
private Map<String, String> settings;
public WebAppSettings(String webAppId, Map<String, String> settings)
{
this.webAppId = webAppId;
this.settings = settings;
}
public String getWebAppId()
{
return webAppId;
}
public Map<String, String> getSettings()
{
return settings;
}
@Override
public int size()
{
return settings.size();
}
@Override
public boolean isEmpty()
{
return settings.isEmpty();
}
@Override
public boolean containsKey(Object key)
{
return settings.containsKey(key);
}
@Override
public boolean containsValue(Object value)
{
return settings.containsValue(value);
}
@Override
public String get(Object key)
{
return settings.get(key);
}
@Override
public String put(String key, String value)
{
return settings.put(key, value);
}
@Override
public String remove(Object key)
{
return settings.remove(key);
}
@Override
public void putAll(Map<? extends String, ? extends String> m)
{
settings.putAll(m);
}
@Override
public void clear()
{
settings.clear();
}
@Override
public Set<String> keySet()
{
return settings.keySet();
}
@Override
public Collection<String> values()
{
return settings.values();
}
@Override
public Set<java.util.Map.Entry<String, String>> entrySet()
{
return settings.entrySet();
}
@Override
public String toString()
{
final ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
builder.append(getWebAppId());
builder.append(settings);
return builder.toString();
}
//
// JSON-RPC
//
@SuppressWarnings("unused")
private WebAppSettings()
{
}
@SuppressWarnings("unused")
private void setWebAppId(String webAppId)
{
this.webAppId = webAppId;
}
@SuppressWarnings("unused")
private void setSettings(Map<String, String> settings)
{
this.settings = settings;
}
}
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