Package: UserStoreUIUtils

UserStoreUIUtils

nameinstructionbranchcomplexitylinemethod
UserStoreUIUtils()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
mergePropertyValues(Properties, Map)
M: 110 C: 0
0%
M: 18 C: 0
0%
M: 10 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3: *
4: * WSO2 Inc. licenses this file to you under the Apache License,
5: * Version 2.0 (the "License"); you may not use this file except
6: * in compliance with the License.
7: * You may obtain a copy of the License at
8: *
9: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing,
12: * software distributed under the License is distributed on an
13: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14: * KIND, either express or implied. See the License for the
15: * specific language governing permissions and limitations
16: * under the License.
17: */
18: package org.wso2.carbon.identity.user.store.configuration.ui.utils;
19:
20:
21: import org.wso2.carbon.core.AbstractAdmin;
22: import org.wso2.carbon.identity.user.store.configuration.stub.api.Properties;
23: import org.wso2.carbon.identity.user.store.configuration.stub.api.Property;
24:
25: import java.util.Map;
26:
27:
28: public class UserStoreUIUtils extends AbstractAdmin {
29: /**
30: * Merge the defined property values of an available user store with the required set of properties
31: *
32: * @param properties
33: * @param tempProperties
34: * @return
35: */
36: public static Properties mergePropertyValues(Properties properties, Map<String, String> tempProperties) {
37: Property[] mandatories = properties.getMandatoryProperties();
38: Property[] optionals = properties.getOptionalProperties();
39: Property[] advancedProperties = properties.getAdvancedProperties();
40:
41:• if (mandatories[0] != null) {
42:• for (int i = 0; i < mandatories.length; i++) {
43: Property property = mandatories[i];
44:• if (tempProperties.get(property.getName()) != null) {
45: mandatories[i].setValue(tempProperties.get(property.getName()));
46: }
47: }
48: }
49:
50:• if (optionals[0] != null) {
51:• for (int i = 0; i < optionals.length; i++) {
52: Property property = optionals[i];
53:• if (tempProperties.get(property.getName()) != null) {
54: optionals[i].setValue(tempProperties.get(property.getName()));
55: }
56: }
57: }
58:
59:• if (advancedProperties[0] != null) {
60:• for (int i = 0; i < advancedProperties.length; i++) {
61: Property property = advancedProperties[i];
62:• if (tempProperties.get(property.getName()) != null) {
63: advancedProperties[i].setValue(tempProperties.get(property.getName()));
64: }
65: }
66: }
67:
68: properties.setMandatoryProperties(mandatories);
69: properties.setOptionalProperties(optionals);
70: properties.setAdvancedProperties(advancedProperties);
71: return properties;
72: }
73:
74: }