1 19 20 package com.sslexplorer.properties; 21 22 import com.sslexplorer.boot.PropertyDefinition; 23 import com.sslexplorer.core.CoreAttributeConstants; 24 import com.sslexplorer.core.CoreEvent; 25 import com.sslexplorer.core.CoreEventConstants; 26 import com.sslexplorer.properties.impl.profile.ProfileProperties; 27 import com.sslexplorer.security.SessionInfo; 28 29 35 public class PropertyChangeEvent extends CoreEvent { 36 37 39 private String oldValue; 40 private String newValue; 41 private PropertyProfile profile; 42 43 53 public PropertyChangeEvent(Object source, PropertyDefinition def, SessionInfo session, String oldValue, String newValue, int state) { 54 this(source, CoreEventConstants.PROPERTY_CHANGED, def, session, oldValue, newValue, state); 55 } 56 57 58 69 public PropertyChangeEvent(Object source, int code, PropertyDefinition def, SessionInfo session, String oldValue, String newValue, int state) { 70 this(source, code, def, session, null, oldValue, newValue, state); 71 } 72 73 74 86 public PropertyChangeEvent(Object source, int code, PropertyDefinition def, SessionInfo session, PropertyProfile profile, String oldValue, String newValue, int state) { 87 super(source, code, def, session, state); 88 if (oldValue == null) { 89 oldValue = ""; 90 } 91 this.oldValue = oldValue; 92 this.newValue = newValue; 93 this.addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_CLASS, def.getPropertyClass().getName()); 94 this.addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_OLD_VALUE, oldValue == null ? def.getDefaultValue() : oldValue); 95 this.addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_NEW_VALUE, newValue); 96 this.addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_NAME, def == null ? "<unknown>" : def.getName()); 97 this.profile = profile; 98 if(profile != null && def != null && def.getPropertyClass() instanceof ProfileProperties) { 99 addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_PROFILE_NAME, profile.getResourceName()); 100 addAttribute(CoreAttributeConstants.EVENT_ATTR_PROPERTY_PROFILE_DESCRIPTION, profile.getResourceDescription()); 101 } 102 } 103 104 109 public String getOldValue() { 110 return oldValue; 111 } 112 113 118 public String getNewValue() { 119 return newValue; 120 } 121 122 127 public PropertyDefinition getDefinition() { 128 return (PropertyDefinition)getParameter(); 129 } 130 131 } 132 | Popular Tags |