001/*
002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.platform.ui.web.auth.service;
020
021import org.nuxeo.runtime.model.SimpleContributionRegistry;
022
023/**
024 * Registry handling hot-reload and merge of {@link LoginScreenConfig} contributions.
025 *
026 * @since 7.10
027 */
028public class LoginScreenConfigRegistry extends SimpleContributionRegistry<LoginScreenConfig> {
029
030    LoginScreenConfig config;
031
032    @Override
033    public String getContributionId(LoginScreenConfig contrib) {
034        // only one contrib
035        return "static";
036    }
037
038    @Override
039    public void contributionUpdated(String id, LoginScreenConfig contrib, LoginScreenConfig newOrigContrib) {
040        config = contrib;
041    }
042
043    @Override
044    public void contributionRemoved(String id, LoginScreenConfig origContrib) {
045        config = currentContribs.get("static");
046    }
047
048    @Override
049    public boolean isSupportingMerge() {
050        return true;
051    }
052
053    @Override
054    public LoginScreenConfig clone(LoginScreenConfig orig) {
055        return orig.clone();
056    }
057
058    @Override
059    public void merge(LoginScreenConfig src, LoginScreenConfig dst) {
060        dst.merge(src);
061    }
062
063    public LoginScreenConfig getConfig() {
064        return config;
065    }
066
067}