gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.action.CustomAttributeAction クラス
org.gluu.oxtrust.action.CustomAttributeAction の継承関係図
Inheritance graph
org.gluu.oxtrust.action.CustomAttributeAction 連携図
Collaboration graph

公開メンバ関数

void init ()
 
void initCustomAttributes (List< GluuAttribute > attributes, List< GluuCustomAttribute > customAttributes, List< String > origins, String[] objectClassTypes, String[] objectClassDisplayNames)
 
Map< String, List< GluuAttribute > > groupAttributesByOrigin (List< GluuAttribute > attributes)
 
boolean containsCustomAttribute (GluuAttribute attribute)
 
void addCustomAttribute (String inum, boolean mandatory)
 
void addMultiValuesInAttributes (String inum, boolean mandatory)
 
void removeMultiValuesInAttributes (String inum, boolean mandatory, String removeValue)
 
void addCustomAttribute (String inum)
 
void addCustomAttributes (List< GluuCustomAttribute > newCustomAttributes)
 
void removeCustomAttribute (String inum)
 
void refreshCustomAttributes (List< GluuCustomAttribute > newCustomAttributes)
 
String getOriginForAttribute (GluuAttribute attribute)
 
GluuCustomAttribute getCustomAttribute (String inum)
 
GluuAttribute getCustomAttribute (String origin, String name)
 
List< GluuCustomAttributedetectRemovedAttributes ()
 
void updateOriginCustomAttributes ()
 
List< GluuAttribute > getAttributes ()
 
Map< GluuAttribute, String > getAttributeIds ()
 
void setAttributeIds (Map< GluuAttribute, String > attributeIds)
 
Map< String, List< GluuAttribute > > getAttributeByOrigin ()
 
void setAttributeByOrigin (Map< String, List< GluuAttribute >> attributeByOrigin)
 
Map< String, String > getOriginDisplayNames ()
 
List< GluuCustomAttributegetCustomAttributes ()
 
String getActiveOrigin ()
 
void setActiveOrigin (String activeOrigin)
 
void uploadImage (FileUploadEvent event)
 
void addPhoto (String inum)
 
byte [] getPhotoThumbData (String inum)
 
String getPhotoSourceName (String inum)
 
void removePhoto (String inum)
 
void savePhotos ()
 
void cancelPhotos ()
 
void deletePhotos ()
 
void renderAttribute (ComponentSystemEvent event)
 
void destroy ()
 
void validateAttributeValues (ComponentSystemEvent event)
 

非公開メンバ関数

String [] removeElementFromArray (String [] n, String removeElement)
 
void deselectCustomAttributes (List< GluuCustomAttribute > customAttributes)
 
void selectCustomAttributes (List< GluuCustomAttribute > customAttributes)
 
void setIconImageImpl (GluuCustomAttribute customAttribute, GluuImage image)
 
void removeRemovedPhotos ()
 

非公開変数類

Logger log
 
Identity identity
 
FacesMessages facesMessages
 
AttributeService attributeService
 
ImageService imageService
 
GluuImage uploadedImage
 
List< GluuAttribute > attributes
 
Map< GluuAttribute, String > attributeIds
 
Map< String, GluuAttribute > attributeToIds
 
Map< String, List< GluuAttribute > > attributeByOrigin
 
Map< String, GluuAttribute > attributeInums
 
List< String > availableAttributeIds
 
Map< String, String > originDisplayNames
 
String activeOrigin
 
List< GluuImage > addedPhotos
 
List< GluuImage > removedPhotos
 
List< GluuCustomAttributecustomAttributes
 
ArrayList< GluuCustomAttributeorigCustomAttributes
 

静的非公開変数類

static final long serialVersionUID = -719594782175672946L
 

詳解

Action class for work with custom attributes

著者
Yuriy Movchan Date: 12/24/2012

関数詳解

◆ addCustomAttribute() [1/2]

void org.gluu.oxtrust.action.CustomAttributeAction.addCustomAttribute ( String  inum,
boolean  mandatory 
)
inline
171  {
172  if (StringHelper.isEmpty(inum)) {
173  return;
174  }
175 
176  GluuAttribute tmpAttribute = attributeInums.get(inum);
177  if ((tmpAttribute == null) || containsCustomAttribute(tmpAttribute)) {
178  return;
179  }
180 
181  String id = this.attributeIds.get(tmpAttribute);
182  this.availableAttributeIds.remove(id);
183 
184  GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(), (String) null, true, mandatory);
185  tmpGluuPersonAttribute.setMetadata(tmpAttribute);
186 
187  this.customAttributes.add(tmpGluuPersonAttribute);
188  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90
boolean containsCustomAttribute(GluuAttribute attribute)
Definition: CustomAttributeAction.java:157

◆ addCustomAttribute() [2/2]

void org.gluu.oxtrust.action.CustomAttributeAction.addCustomAttribute ( String  inum)
inline
263  {
264  addCustomAttribute(inum, false);
265  }
void addCustomAttribute(String inum, boolean mandatory)
Definition: CustomAttributeAction.java:171

◆ addCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.addCustomAttributes ( List< GluuCustomAttribute newCustomAttributes)
inline
267  {
268  attributeService.setAttributeMetadata(newCustomAttributes, this.attributes);
269 
270  for (GluuCustomAttribute newCustomAttribute : newCustomAttributes) {
271  GluuAttribute metaData = newCustomAttribute.getMetadata();
272  if (metaData != null) {
273  addCustomAttribute(metaData.getInum(), newCustomAttribute.isMandatory());
274  }
275  }
276  }
AttributeService attributeService
Definition: CustomAttributeAction.java:70
List< GluuAttribute > attributes
Definition: CustomAttributeAction.java:77
void addCustomAttribute(String inum, boolean mandatory)
Definition: CustomAttributeAction.java:171
void setAttributeMetadata(List< GluuCustomAttribute > customAttributes, List< GluuAttribute > attributes)
Definition: AttributeService.java:553

◆ addMultiValuesInAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.addMultiValuesInAttributes ( String  inum,
boolean  mandatory 
)
inline
189  {
190  if (StringHelper.isEmpty(inum)) {
191  return;
192  }
193 
194  GluuAttribute tmpAttribute = this.attributeInums.get(inum);
195  if (tmpAttribute == null) {
196  return;
197  }
198 
199  String id = this.attributeIds.get(tmpAttribute);
200  this.availableAttributeIds.remove(id);
201 
202  String[] values = null;
203  int index = 0;
204  for (GluuCustomAttribute customAttribute : this.customAttributes) {
205  if (tmpAttribute.equals(customAttribute.getMetadata())) {
206  values = customAttribute.getValues();
207  break;
208  }
209  index ++;
210  }
211 
212  String[] newValues = new String[values.length+1];
213  System.arraycopy(values, 0 , newValues , 0 , values.length);
214  removeCustomAttribute(inum);
215  GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(),newValues , true, mandatory);
216  tmpGluuPersonAttribute.setMetadata(tmpAttribute);
217 
218  this.customAttributes.add(index,tmpGluuPersonAttribute);
219  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
void removeCustomAttribute(String inum)
Definition: CustomAttributeAction.java:278
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ addPhoto()

void org.gluu.oxtrust.action.CustomAttributeAction.addPhoto ( String  inum)
inline
448  {
449  if (this.uploadedImage == null) {
450  return;
451  }
452 
453  GluuCustomAttribute customAttribute = getCustomAttribute(inum);
454  if (customAttribute == null) {
455  return;
456  }
457 
458  setIconImageImpl(customAttribute, this.uploadedImage);
459  }
GluuCustomAttribute getCustomAttribute(String inum)
Definition: CustomAttributeAction.java:338
void setIconImageImpl(GluuCustomAttribute customAttribute, GluuImage image)
Definition: CustomAttributeAction.java:461
GluuImage uploadedImage
Definition: CustomAttributeAction.java:75

◆ cancelPhotos()

void org.gluu.oxtrust.action.CustomAttributeAction.cancelPhotos ( )
inline
536  {
537  for (GluuImage image : addedPhotos) {
538  imageService.deleteImage(image);
539  }
540 
541  removedPhotos.clear();
542  }
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
void deleteImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:142
List< GluuImage > removedPhotos
Definition: CustomAttributeAction.java:88
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ containsCustomAttribute()

boolean org.gluu.oxtrust.action.CustomAttributeAction.containsCustomAttribute ( GluuAttribute  attribute)
inline
157  {
158  if (attribute == null) {
159  return false;
160  }
161 
162  for (GluuCustomAttribute customAttribute : this.customAttributes) {
163  if (attribute.equals(customAttribute.getMetadata())) {
164  return true;
165  }
166  }
167 
168  return false;
169  }
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ deletePhotos()

void org.gluu.oxtrust.action.CustomAttributeAction.deletePhotos ( )
inline
544  {
545  for (GluuCustomAttribute customAttribute : this.customAttributes) {
546  if (AttributeDataType.BINARY.equals(customAttribute.getMetadata().getDataType())) {
547  removePhoto(customAttribute.getMetadata().getInum());
548  }
549  }
550 
552  }
void removePhoto(String inum)
Definition: CustomAttributeAction.java:495
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90
void removeRemovedPhotos()
Definition: CustomAttributeAction.java:518

◆ deselectCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.deselectCustomAttributes ( List< GluuCustomAttribute customAttributes)
inlineprivate
300  {
301  for (GluuCustomAttribute customAttribute : customAttributes) {
302  String id = this.attributeIds.get(customAttribute);
303  this.availableAttributeIds.add(id);
304  }
305  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ destroy()

void org.gluu.oxtrust.action.CustomAttributeAction.destroy ( )
inline
564  {
565  // When user decided to leave form without saving we must remove added
566  // images from disk
567  cancelPhotos();
568  }
void cancelPhotos()
Definition: CustomAttributeAction.java:536

◆ detectRemovedAttributes()

List<GluuCustomAttribute> org.gluu.oxtrust.action.CustomAttributeAction.detectRemovedAttributes ( )
inline
368  {
369  Set<String> origCustomAttributesSet = new HashSet<String>();
370 
371  for (GluuCustomAttribute origCustomAttribute : origCustomAttributes) {
372  String attributeName = StringHelper.toLowerCase(origCustomAttribute.getName());
373  origCustomAttributesSet.add(attributeName);
374  }
375 
376  for (GluuCustomAttribute currentCustomAttribute : customAttributes) {
377  String attributeName = StringHelper.toLowerCase(currentCustomAttribute.getName());
378  origCustomAttributesSet.remove(attributeName);
379  }
380 
381  List<GluuCustomAttribute> removedCustomAttributes = new ArrayList<GluuCustomAttribute>(origCustomAttributesSet.size());
382  for (String removeCustomAttribute : origCustomAttributesSet) {
383  removedCustomAttributes.add(new GluuCustomAttribute(removeCustomAttribute, new String[0]));
384  }
385 
386  return removedCustomAttributes;
387  }
ArrayList< GluuCustomAttribute > origCustomAttributes
Definition: CustomAttributeAction.java:91
void removeCustomAttribute(String inum)
Definition: CustomAttributeAction.java:278
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ getActiveOrigin()

String org.gluu.oxtrust.action.CustomAttributeAction.getActiveOrigin ( )
inline
422  {
423  return activeOrigin;
424  }
String activeOrigin
Definition: CustomAttributeAction.java:85

◆ getAttributeByOrigin()

Map<String, List<GluuAttribute> > org.gluu.oxtrust.action.CustomAttributeAction.getAttributeByOrigin ( )
inline
406  {
407  return attributeByOrigin;
408  }
Map< String, List< GluuAttribute > > attributeByOrigin
Definition: CustomAttributeAction.java:80

◆ getAttributeIds()

Map<GluuAttribute, String> org.gluu.oxtrust.action.CustomAttributeAction.getAttributeIds ( )
inline
398  {
399  return attributeIds;
400  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78

◆ getAttributes()

List<GluuAttribute> org.gluu.oxtrust.action.CustomAttributeAction.getAttributes ( )
inline
394  {
395  return attributes;
396  }
List< GluuAttribute > attributes
Definition: CustomAttributeAction.java:77

◆ getCustomAttribute() [1/2]

GluuCustomAttribute org.gluu.oxtrust.action.CustomAttributeAction.getCustomAttribute ( String  inum)
inline
338  {
339  if (StringHelper.isEmpty(inum)) {
340  return null;
341  }
342 
343  GluuAttribute tmpAttribute = attributeInums.get(inum);
344  for (GluuCustomAttribute customAttribute : this.customAttributes) {
345  if ((customAttribute.getMetadata() != null) && customAttribute.getMetadata().equals(tmpAttribute)) {
346  return customAttribute;
347  }
348  }
349 
350  return null;
351  }
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ getCustomAttribute() [2/2]

GluuAttribute org.gluu.oxtrust.action.CustomAttributeAction.getCustomAttribute ( String  origin,
String  name 
)
inline
353  {
354  List<GluuAttribute> originAttributes = attributeByOrigin.get(origin);
355  if (originAttributes == null) {
356  return null;
357  }
358 
359  for (GluuAttribute attribute : originAttributes) {
360  if (StringHelper.equalsIgnoreCase(attribute.getName(), name)) {
361  return attribute;
362  }
363  }
364 
365  return null;
366  }
Map< String, List< GluuAttribute > > attributeByOrigin
Definition: CustomAttributeAction.java:80

◆ getCustomAttributes()

List<GluuCustomAttribute> org.gluu.oxtrust.action.CustomAttributeAction.getCustomAttributes ( )
inline
418  {
419  return new ArrayList<GluuCustomAttribute>(customAttributes);
420  }
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ getOriginDisplayNames()

Map<String, String> org.gluu.oxtrust.action.CustomAttributeAction.getOriginDisplayNames ( )
inline
414  {
415  return originDisplayNames;
416  }
Map< String, String > originDisplayNames
Definition: CustomAttributeAction.java:84

◆ getOriginForAttribute()

String org.gluu.oxtrust.action.CustomAttributeAction.getOriginForAttribute ( GluuAttribute  attribute)
inline

Override this method if you need to organize attributes to some specific set of origins.

引数
attribute
戻り値
attribute.getOrigin()
334  {
335  return attribute.getOrigin();
336  }

◆ getPhotoSourceName()

String org.gluu.oxtrust.action.CustomAttributeAction.getPhotoSourceName ( String  inum)
inline
484  {
485  GluuCustomAttribute customAttribute = getCustomAttribute(inum);
486  if (customAttribute != null) {
487  GluuImage image = imageService.getImage(customAttribute);
488 
489  return image == null ? null : image.getSourceName();
490  }
491 
492  return null;
493  }
GluuImage getImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:127
GluuCustomAttribute getCustomAttribute(String inum)
Definition: CustomAttributeAction.java:338
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ getPhotoThumbData()

byte [] org.gluu.oxtrust.action.CustomAttributeAction.getPhotoThumbData ( String  inum)
inline
471  {
472  GluuCustomAttribute customAttribute = getCustomAttribute(inum);
473  if (customAttribute != null) {
474  GluuImage image = imageService.getImage(customAttribute);
475  if(image != null){
476  image.setStoreTemporary(addedPhotos.contains(image));
477  return imageService.getThumImageData(image);
478  }
479  }
480 
482  }
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
GluuImage getImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:127
GluuCustomAttribute getCustomAttribute(String inum)
Definition: CustomAttributeAction.java:338
byte [] getBlankPhotoData()
Definition: ImageService.java:157
byte [] getThumImageData(GluuCustomAttribute customAttribute)
Definition: ImageService.java:165
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ groupAttributesByOrigin()

Map<String, List<GluuAttribute> > org.gluu.oxtrust.action.CustomAttributeAction.groupAttributesByOrigin ( List< GluuAttribute >  attributes)
inline
141  {
142  Map<String, List<GluuAttribute>> resultMap = new HashMap<String, List<GluuAttribute>>();
143 
144  for (GluuAttribute attribute : attributes) {
145  String origin = attribute.getOrigin();
146 
147  if (resultMap.containsKey(origin)) {
148  resultMap.get(origin).add(attribute);
149  } else {
150  resultMap.put(origin, new ArrayList<GluuAttribute>(Arrays.asList(attribute)));
151  }
152  }
153 
154  return resultMap;
155  }
List< GluuAttribute > attributes
Definition: CustomAttributeAction.java:77

◆ init()

void org.gluu.oxtrust.action.CustomAttributeAction.init ( )
inline
94  {
95  this.addedPhotos = new ArrayList<GluuImage>();
96  this.removedPhotos = new ArrayList<GluuImage>();
97  }
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
List< GluuImage > removedPhotos
Definition: CustomAttributeAction.java:88

◆ initCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.initCustomAttributes ( List< GluuAttribute >  attributes,
List< GluuCustomAttribute customAttributes,
List< String >  origins,
String []  objectClassTypes,
String []  objectClassDisplayNames 
)
inline
100  {
101  this.attributes = new ArrayList<GluuAttribute>(attributes);
103  this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);
104 
105  // Set meta-data and sort by metadata.displayName
106  attributeService.setAttributeMetadata(customAttributes, this.attributes);
107  attributeService.sortCustomAttributes(customAttributes, "metadata.displayName");
108 
109  // Prepare map which allows to build tab
111 
112  // Init special list and maps
113  this.availableAttributeIds = new ArrayList<String>();
114  this.attributeIds = new IdentityHashMap<GluuAttribute, String>();
115  this.attributeToIds = new HashMap<String, GluuAttribute>();
116  this.attributeInums = new HashMap<String, GluuAttribute>();
117 
118  int componentId = 1;
119  for (GluuAttribute attribute : attributes) {
120  log.debug("attribute: {}", attribute.getName());
121  String id = "a" + String.valueOf(componentId++) + "Id";
122  this.availableAttributeIds.add(id);
123  this.attributeInums.put(attribute.getInum(), attribute);
124  this.attributeIds.put(attribute, id);
125  this.attributeToIds.put(id, attribute);
126  }
127 
128  // Init origin display names
129  this.originDisplayNames = attributeService.getAllAttributeOriginDisplayNames(origins, objectClassTypes, objectClassDisplayNames);
130  this.activeOrigin = this.originDisplayNames.get(origins.get(0));
131 
132  // Sync Ids map
133  for (GluuCustomAttribute personAttribute : customAttributes) {
134  if (personAttribute.getMetadata() != null) {
135  String id = this.attributeIds.get(personAttribute.getMetadata());
136  this.availableAttributeIds.remove(id);
137  }
138  }
139  }
AttributeService attributeService
Definition: CustomAttributeAction.java:70
Map< String, GluuAttribute > attributeToIds
Definition: CustomAttributeAction.java:79
String activeOrigin
Definition: CustomAttributeAction.java:85
List< GluuAttribute > attributes
Definition: CustomAttributeAction.java:77
Map< String, List< GluuAttribute > > groupAttributesByOrigin(List< GluuAttribute > attributes)
Definition: CustomAttributeAction.java:141
ArrayList< GluuCustomAttribute > origCustomAttributes
Definition: CustomAttributeAction.java:91
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
Logger log
Definition: CustomAttributeAction.java:61
Map< String, String > originDisplayNames
Definition: CustomAttributeAction.java:84
Map< String, String > getAllAttributeOriginDisplayNames(List< String > attributeOriginList, String[] objectClassTypes, String[] objectClassDisplayNames)
Definition: AttributeService.java:223
void sortCustomAttributes(List< GluuCustomAttribute > customAttributes, String sortByProperties)
Definition: AttributeService.java:604
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90
void setAttributeMetadata(List< GluuCustomAttribute > customAttributes, List< GluuAttribute > attributes)
Definition: AttributeService.java:553
Map< String, List< GluuAttribute > > attributeByOrigin
Definition: CustomAttributeAction.java:80

◆ refreshCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.refreshCustomAttributes ( List< GluuCustomAttribute newCustomAttributes)
inline
319  {
321 
322  this.customAttributes = newCustomAttributes;
323 
324  selectCustomAttributes(newCustomAttributes);
325  }
void deselectCustomAttributes(List< GluuCustomAttribute > customAttributes)
Definition: CustomAttributeAction.java:300
void selectCustomAttributes(List< GluuCustomAttribute > customAttributes)
Definition: CustomAttributeAction.java:307
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ removeCustomAttribute()

void org.gluu.oxtrust.action.CustomAttributeAction.removeCustomAttribute ( String  inum)
inline
278  {
279  if (StringHelper.isEmpty(inum)) {
280  return;
281  }
282 
283  GluuAttribute tmpAttribute = attributeInums.get(inum);
284  if ((tmpAttribute == null) || !containsCustomAttribute(tmpAttribute)) {
285  return;
286  }
287 
288  String id = this.attributeIds.get(tmpAttribute);
289  this.availableAttributeIds.add(id);
290 
291  for (Iterator<GluuCustomAttribute> iterator = this.customAttributes.iterator(); iterator.hasNext();) {
292  GluuCustomAttribute tmpGluuPersonAttribute = iterator.next();
293  if (tmpAttribute.equals(tmpGluuPersonAttribute.getMetadata())) {
294  iterator.remove();
295  break;
296  }
297  }
298  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90
boolean containsCustomAttribute(GluuAttribute attribute)
Definition: CustomAttributeAction.java:157

◆ removeElementFromArray()

String [] org.gluu.oxtrust.action.CustomAttributeAction.removeElementFromArray ( String []  n,
String  removeElement 
)
inlineprivate
252  {
253  if(removeElement.isEmpty()){
254  removeElement = null ;
255  }
256  List<String> list = new ArrayList<String>();
257  Collections.addAll(list, n);
258  list.remove(removeElement);
259  n = list.toArray(new String[list.size()]);
260  return n;
261  }

◆ removeMultiValuesInAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.removeMultiValuesInAttributes ( String  inum,
boolean  mandatory,
String  removeValue 
)
inline
220  {
221  if (StringHelper.isEmpty(inum)) {
222  return;
223  }
224 
225  GluuAttribute tmpAttribute = this.attributeInums.get(inum);
226  if (tmpAttribute == null) {
227  return;
228  }
229 
230  String id = this.attributeIds.get(tmpAttribute);
231  this.availableAttributeIds.remove(id);
232 
233  String[] values = null;
234  String[] newValues = null;
235  int index = 0;
236  for (GluuCustomAttribute customAttribute : this.customAttributes) {
237  if (tmpAttribute.equals(customAttribute.getMetadata())) {
238  values = customAttribute.getValues();
239  newValues = removeElementFromArray(values , removeValue);
240  break;
241  }
242  index ++;
243  }
244 
245  removeCustomAttribute(inum);
246  GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(),newValues , true, mandatory);
247  tmpGluuPersonAttribute.setMetadata(tmpAttribute);
248 
249  this.customAttributes.add(index,tmpGluuPersonAttribute);
250  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
String [] removeElementFromArray(String [] n, String removeElement)
Definition: CustomAttributeAction.java:252
void removeCustomAttribute(String inum)
Definition: CustomAttributeAction.java:278
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ removePhoto()

void org.gluu.oxtrust.action.CustomAttributeAction.removePhoto ( String  inum)
inline
495  {
496  if (StringHelper.isEmpty(inum)) {
497  return;
498  }
499 
500  GluuCustomAttribute customAttribute = getCustomAttribute(inum);
501  if ((customAttribute == null) || StringHelper.isEmpty(customAttribute.getValue())) {
502  return;
503  }
504 
505  GluuImage image = imageService.getImage(customAttribute);
506  if(image!=null){
507  image.setStoreTemporary(addedPhotos.contains(image));
508  if (image.isStoreTemporary()) {
509  imageService.deleteImage(image);
510  addedPhotos.remove(image);
511  } else {
512  removedPhotos.add(image);
513  }
514  }
515  customAttribute.setValue(null);
516  }
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
GluuImage getImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:127
GluuCustomAttribute getCustomAttribute(String inum)
Definition: CustomAttributeAction.java:338
void deleteImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:142
List< GluuImage > removedPhotos
Definition: CustomAttributeAction.java:88
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ removeRemovedPhotos()

void org.gluu.oxtrust.action.CustomAttributeAction.removeRemovedPhotos ( )
inlineprivate
518  {
519  for (GluuImage image : removedPhotos) {
520  imageService.deleteImage(image);
521  }
522 
523  removedPhotos.clear();
524  }
void deleteImage(GluuCustomAttribute customAttribute)
Definition: ImageService.java:142
List< GluuImage > removedPhotos
Definition: CustomAttributeAction.java:88
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ renderAttribute()

void org.gluu.oxtrust.action.CustomAttributeAction.renderAttribute ( ComponentSystemEvent  event)
inline
554  {
555  // Replace dummy component id with real one
556  String dummyId = event.getComponent().getAttributes().get("aid").toString();
557  String clientId = event.getComponent().getClientId();
558 
559  GluuAttribute attribute = this.attributeToIds.get(dummyId);
560  this.attributeIds.put(attribute, clientId);
561  }
Map< String, GluuAttribute > attributeToIds
Definition: CustomAttributeAction.java:79
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78

◆ savePhotos()

void org.gluu.oxtrust.action.CustomAttributeAction.savePhotos ( )
inline
526  {
527  // Move added photos to persistent location
528  for (GluuImage image : addedPhotos) {
530  }
531 
532  addedPhotos.clear();
534  }
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
void moveImageToPersistentStore(GluuImage image)
Definition: ImageService.java:194
void removeRemovedPhotos()
Definition: CustomAttributeAction.java:518
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ selectCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.selectCustomAttributes ( List< GluuCustomAttribute customAttributes)
inlineprivate
307  {
308  for (GluuCustomAttribute customAttribute : this.customAttributes) {
309  GluuAttribute tmpAttribute = attributeInums.get(customAttribute.getMetadata().getInum());
310  if ((tmpAttribute == null) || containsCustomAttribute(tmpAttribute)) {
311  continue;
312  }
313 
314  String id = this.attributeIds.get(tmpAttribute);
315  this.availableAttributeIds.remove(id);
316  }
317  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78
List< String > availableAttributeIds
Definition: CustomAttributeAction.java:82
Map< String, GluuAttribute > attributeInums
Definition: CustomAttributeAction.java:81
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90
boolean containsCustomAttribute(GluuAttribute attribute)
Definition: CustomAttributeAction.java:157

◆ setActiveOrigin()

void org.gluu.oxtrust.action.CustomAttributeAction.setActiveOrigin ( String  activeOrigin)
inline
426  {
427  this.activeOrigin = activeOrigin;
428  }
String activeOrigin
Definition: CustomAttributeAction.java:85

◆ setAttributeByOrigin()

void org.gluu.oxtrust.action.CustomAttributeAction.setAttributeByOrigin ( Map< String, List< GluuAttribute >>  attributeByOrigin)
inline
410  {
412  }
Map< String, List< GluuAttribute > > attributeByOrigin
Definition: CustomAttributeAction.java:80

◆ setAttributeIds()

void org.gluu.oxtrust.action.CustomAttributeAction.setAttributeIds ( Map< GluuAttribute, String >  attributeIds)
inline
402  {
403  this.attributeIds = attributeIds;
404  }
Map< GluuAttribute, String > attributeIds
Definition: CustomAttributeAction.java:78

◆ setIconImageImpl()

void org.gluu.oxtrust.action.CustomAttributeAction.setIconImageImpl ( GluuCustomAttribute  customAttribute,
GluuImage  image 
)
inlineprivate
461  {
462  GluuImage oldImage = imageService.getGluuImageFromXML(customAttribute.getValue());
463  if (oldImage != null) {
464  removedPhotos.add(oldImage);
465  }
466 
467  customAttribute.setValue(imageService.getXMLFromGluuImage(image));
468  addedPhotos.add(image);
469  }
GluuImage getGluuImageFromXML(String xml)
Definition: ImageService.java:54
List< GluuImage > addedPhotos
Definition: CustomAttributeAction.java:87
String getXMLFromGluuImage(GluuImage photo)
Definition: ImageService.java:50
List< GluuImage > removedPhotos
Definition: CustomAttributeAction.java:88
ImageService imageService
Definition: CustomAttributeAction.java:73

◆ updateOriginCustomAttributes()

void org.gluu.oxtrust.action.CustomAttributeAction.updateOriginCustomAttributes ( )
inline
389  {
390  this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);
391 
392  }
ArrayList< GluuCustomAttribute > origCustomAttributes
Definition: CustomAttributeAction.java:91
List< GluuCustomAttribute > customAttributes
Definition: CustomAttributeAction.java:90

◆ uploadImage()

void org.gluu.oxtrust.action.CustomAttributeAction.uploadImage ( FileUploadEvent  event)
inline
430  {
431  UploadedFile uploadedFile = event.getUploadedFile();
432  this.uploadedImage = null;
433  try {
434  GluuImage image = imageService.constructImage(identity.getUser(), uploadedFile);
435  image.setStoreTemporary(true);
436  if (imageService.createImageFiles(image)) {
437  this.uploadedImage = image;
438  }
439  } finally {
440  try {
441  uploadedFile.delete();
442  } catch (IOException ex) {
443  log.error("Failed to remove temporary image", ex);
444  }
445  }
446  }
GluuCustomPerson getUser()
Definition: Identity.java:39
Logger log
Definition: CustomAttributeAction.java:61
GluuImage uploadedImage
Definition: CustomAttributeAction.java:75
Identity identity
Definition: CustomAttributeAction.java:64
boolean createImageFiles(GluuImage image, int thumbWidth, int thumbHeight)
Definition: ImageService.java:100
ImageService imageService
Definition: CustomAttributeAction.java:73
GluuImage constructImage(GluuCustomPerson creator, UploadedFile uploadedFile)
Definition: ImageService.java:67

◆ validateAttributeValues()

void org.gluu.oxtrust.action.CustomAttributeAction.validateAttributeValues ( ComponentSystemEvent  event)
inline
570  {
571  final FacesContext facesContext = FacesContext.getCurrentInstance();
572  final List<Object> values = new ArrayList<Object>();
573 
574  event.getComponent().visitTree(VisitContext.createVisitContext(facesContext), new VisitCallback() {
575  @Override
576  public VisitResult visit(VisitContext context, UIComponent target) {
577  if (target instanceof UIInput) {
578  GluuAttribute attribute = (GluuAttribute) target.getAttributes().get("attribute");
579  if (attribute != null) {
580  values.add(((UIInput) target).getValue());
581  }
582  }
583 
584  return VisitResult.ACCEPT;
585  }
586  });
587 
588  values.removeAll(Arrays.asList(null, ""));
589  Set<Object> uniqValues = new HashSet<Object>(values);
590 
591  if (values.size() != uniqValues.size()) {
592  event.getComponent().visitTree(VisitContext.createVisitContext(facesContext), new VisitCallback() {
593  @Override
594  public VisitResult visit(VisitContext context, UIComponent target) {
595  if (target instanceof UIInput) {
596  GluuAttribute attribute = (GluuAttribute) target.getAttributes().get("attribute");
597  if (attribute != null) {
598  ((UIInput) target).setValid(false);
599 
600  String message = "Please fill out an unique value for all of '" + attribute.getDisplayName() + "' fields";
601  facesMessages.add(target.getClientId(facesContext), FacesMessage.SEVERITY_ERROR, message);
602  }
603  }
604  return VisitResult.ACCEPT;
605  }
606  });
607 
608  facesContext.validationFailed();
609  }
610  }
FacesMessages facesMessages
Definition: CustomAttributeAction.java:67

メンバ詳解

◆ activeOrigin

String org.gluu.oxtrust.action.CustomAttributeAction.activeOrigin
private

◆ addedPhotos

List<GluuImage> org.gluu.oxtrust.action.CustomAttributeAction.addedPhotos
private

◆ attributeByOrigin

Map<String, List<GluuAttribute> > org.gluu.oxtrust.action.CustomAttributeAction.attributeByOrigin
private

◆ attributeIds

Map<GluuAttribute, String> org.gluu.oxtrust.action.CustomAttributeAction.attributeIds
private

◆ attributeInums

Map<String, GluuAttribute> org.gluu.oxtrust.action.CustomAttributeAction.attributeInums
private

◆ attributes

List<GluuAttribute> org.gluu.oxtrust.action.CustomAttributeAction.attributes
private

◆ attributeService

AttributeService org.gluu.oxtrust.action.CustomAttributeAction.attributeService
private

◆ attributeToIds

Map<String, GluuAttribute> org.gluu.oxtrust.action.CustomAttributeAction.attributeToIds
private

◆ availableAttributeIds

List<String> org.gluu.oxtrust.action.CustomAttributeAction.availableAttributeIds
private

◆ customAttributes

List<GluuCustomAttribute> org.gluu.oxtrust.action.CustomAttributeAction.customAttributes
private

◆ facesMessages

FacesMessages org.gluu.oxtrust.action.CustomAttributeAction.facesMessages
private

◆ identity

Identity org.gluu.oxtrust.action.CustomAttributeAction.identity
private

◆ imageService

ImageService org.gluu.oxtrust.action.CustomAttributeAction.imageService
private

◆ log

Logger org.gluu.oxtrust.action.CustomAttributeAction.log
private

◆ origCustomAttributes

ArrayList<GluuCustomAttribute> org.gluu.oxtrust.action.CustomAttributeAction.origCustomAttributes
private

◆ originDisplayNames

Map<String, String> org.gluu.oxtrust.action.CustomAttributeAction.originDisplayNames
private

◆ removedPhotos

List<GluuImage> org.gluu.oxtrust.action.CustomAttributeAction.removedPhotos
private

◆ serialVersionUID

final long org.gluu.oxtrust.action.CustomAttributeAction.serialVersionUID = -719594782175672946L
staticprivate

◆ uploadedImage

GluuImage org.gluu.oxtrust.action.CustomAttributeAction.uploadedImage
private

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