Catalog alignment
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / togglz / ToggleConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.togglz;
22
23 import org.openecomp.sdc.be.resources.data.togglz.ToggleableFeature;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.stereotype.Component;
26 import org.togglz.core.Feature;
27 import org.togglz.core.manager.TogglzConfig;
28 import org.togglz.core.repository.StateRepository;
29 import org.togglz.core.repository.cache.CachingStateRepository;
30 import org.togglz.core.user.SimpleFeatureUser;
31 import org.togglz.core.user.UserProvider;
32
33 @Component
34 public class ToggleConfiguration implements TogglzConfig {
35     @Autowired
36     private CassandraCustomStateRepository cassandraCustomStateRepository;
37
38     @Override
39     public Class<? extends Feature> getFeatureClass() {
40         return ToggleableFeature.class;
41     }
42
43     @Override
44     public StateRepository getStateRepository() {
45         return new CachingStateRepository(cassandraCustomStateRepository, 10000);
46     }
47
48     @Override
49     public UserProvider getUserProvider() {
50         return () -> new SimpleFeatureUser("admin", true);
51     }
52 }