gluu
関数 | 変数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.model.scim2.util.traversalClass クラス
org.gluu.oxtrust.model.scim2.util.traversalClass 連携図
Collaboration graph

関数

 traversalClass (Class baseClass)
 
void traverse (String prefix, Map< String, Object > source, Map< String, Object > destination, boolean replacing)
 
void traverseDelete (Map< String, Object > source, String path)
 

変数

String error
 

非公開メンバ関数

String getNewPrefix (String prefix, String key)
 
Map< String, Object > smallerMap (String prefix, Map< String, Object > source, Object destination, boolean replacing)
 
Collection adjustPrimarySubAttributes (Collection input, int nFreshEntries)
 

非公開変数類

Logger log = LogManager.getLogger(getClass())
 
Class base
 

詳解

Helper class to traverse a SCIM resource object recursively.

構築子と解体子

◆ traversalClass()

org.gluu.oxtrust.model.scim2.util.traversalClass.traversalClass ( Class  baseClass)
inlinepackage
39  {
40  base=baseClass;
41  }
Class base
Definition: ScimResourceUtil.java:37

関数詳解

◆ adjustPrimarySubAttributes()

Collection org.gluu.oxtrust.model.scim2.util.traversalClass.adjustPrimarySubAttributes ( Collection  input,
int  nFreshEntries 
)
inlineprivate
128  {
129 
130  int i;
131  Object array[]=input.toArray();
132  for (i=0; i<nFreshEntries; i++){
133  Object item=array[i];
134  if (item!=null && item instanceof Map){
135  Map<String, Object> map=(Map<String, Object>) item;
136  Object primaryObj=map.get("primary");
137  if (primaryObj!=null && primaryObj.toString().equals("true"))
138  break;
139  }
140  else //Means this collection is not made up of complex attributes, so we can abort the operation
141  i=array.length;
142  }
143  //Set the remaining to primary="false"
144  for (i=i+1;i<array.length;i++){
145  Object item=array[i];
146  if (item!=null && item instanceof Map) {
147  Map<String, Object> map = IntrospectUtil.strObjMap(item);
148  Object primaryObj = map.get("primary");
149  if (primaryObj != null && primaryObj.toString().equals("true")){
150  map.put("primary", false);
151  log.info("Setting primary = false for item whose associated value is {}", map.get("value"));
152  }
153  }
154  }
155  return Arrays.asList(array);
156  }
Logger log
Definition: ScimResourceUtil.java:34

◆ getNewPrefix()

String org.gluu.oxtrust.model.scim2.util.traversalClass.getNewPrefix ( String  prefix,
String  key 
)
inlineprivate
43  {
44  return prefix + (prefix.length()==0 ? "" : ".") + key;
45  }

◆ smallerMap()

Map<String, Object> org.gluu.oxtrust.model.scim2.util.traversalClass.smallerMap ( String  prefix,
Map< String, Object >  source,
Object  destination,
boolean  replacing 
)
inlineprivate
47  {
48  Map<String, Object> smallMap = (destination==null) ? new HashMap<String, Object>() : IntrospectUtil.strObjMap(destination);
49  traverse(prefix, source, smallMap, replacing);
50  return smallMap.size()==0 ? null : smallMap;
51  }
void traverse(String prefix, Map< String, Object > source, Map< String, Object > destination, boolean replacing)
Definition: ScimResourceUtil.java:53

◆ traverse()

void org.gluu.oxtrust.model.scim2.util.traversalClass.traverse ( String  prefix,
Map< String, Object >  source,
Map< String, Object >  destination,
boolean  replacing 
)
inlinepackage
53  {
54 
55  for (String key : source.keySet()) {
56  Object value = source.get(key);
57  Object destValue = destination.get(key);
58 
59  if (value!=null && error==null) {
60  //Atributes related to extensions evaluate null here
61  Attribute attrAnnot=IntrospectUtil.getFieldAnnotation(getNewPrefix(prefix, key), base, Attribute.class);
62 
63  if (attrAnnot != null && !attrAnnot.mutability().equals(READ_ONLY)) {
64  if (value instanceof Map)
65  value = smallerMap(getNewPrefix(prefix, key), IntrospectUtil.strObjMap(value), destValue, replacing);
66  else
67  if (attrAnnot.mutability().equals(IMMUTABLE) && destValue != null && !value.equals(destValue)) {
68  //provokes no more traversals
69  error = "Invalid value passed for immutable attribute " + key;
70  value = null;
71  }
72 
73  if (value != null) {
74 
75  if (IntrospectUtil.isCollection(value.getClass())) {
76  Collection col=(Collection) value;
77  int size=col.size();
78 
79  if (!replacing) { //we need to add to the existing collection
80  if (destValue!=null) {
81 
82  if (!IntrospectUtil.isCollection(destValue.getClass()))
83  log.warn("Value {} was expected to be a collection", destValue);
84  else
85  col.addAll((Collection) destValue);
86  }
87  }
88  //Do the arrangement so that only one primary="true" can stay in data
89  value = col.size()==0 ? null : adjustPrimarySubAttributes(col, size);
90  }
91  destination.put(key, value);
92  }
93  }
94  }
95  }
96  }
String getNewPrefix(String prefix, String key)
Definition: ScimResourceUtil.java:43
Logger log
Definition: ScimResourceUtil.java:34
Collection adjustPrimarySubAttributes(Collection input, int nFreshEntries)
Definition: ScimResourceUtil.java:128
Class base
Definition: ScimResourceUtil.java:37
String error
Definition: ScimResourceUtil.java:36
Map< String, Object > smallerMap(String prefix, Map< String, Object > source, Object destination, boolean replacing)
Definition: ScimResourceUtil.java:47

◆ traverseDelete()

void org.gluu.oxtrust.model.scim2.util.traversalClass.traverseDelete ( Map< String, Object >  source,
String  path 
)
inlinepackage
98  {
99 
100  int i=path.indexOf(".");
101  Object value=null;
102 
103  if (i==-1)
104  source.remove(path);
105  else {
106  String key = path.substring(0, i);
107  value = source.get(key);
108  path=path.substring(i+1);
109  }
110 
111  if (value!=null)
112  try {
113  //If it's a map we must recurse
114  traverseDelete(IntrospectUtil.strObjMap(value), path);
115  }
116  catch (Exception e){
117  if (IntrospectUtil.isCollection(value.getClass())){
118  Collection col=(Collection) value;
119  for (Object item : col) {
120  if (item instanceof Map)
121  traverseDelete(IntrospectUtil.strObjMap(item), path);
122  }
123  }
124  }
125 
126  }
void traverseDelete(Map< String, Object > source, String path)
Definition: ScimResourceUtil.java:98

メンバ詳解

◆ base

Class org.gluu.oxtrust.model.scim2.util.traversalClass.base
private

◆ error

String org.gluu.oxtrust.model.scim2.util.traversalClass.error
package

◆ log

Logger org.gluu.oxtrust.model.scim2.util.traversalClass.log = LogManager.getLogger(getClass())
private

このクラス詳解は次のファイルから抽出されました: