Project

General

Profile

« Previous | Next » 

Revision 466620b1

Added by Andreas Müller almost 3 years ago

fix #9665 filter propertyChange events for created and updated

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/aspectj/PropertyChangeAspect.aj
45 45
		if (property==null){
46 46
			proceed( cb );
47 47
		}else{			
48
			property.setAccessible(true);
49 48
			String propertyName = property.getName();
50
			//logger.debug("execSetter: The property is ["+propertyName+"]");
51
			try {
52
				// use property attribute directly, not through get method.
53
				// get method might modify things, like setting a UUID when called for the first time.
54
				// Also get methods for booleans start with "is" or "has"
55
				Object oldValue = property.get(cb);
56
				proceed( cb );
57
				Object newValue = property.get(cb);
58
                //logger.debug ("Prop: " + propertyName);
59
                //logger.debug("OLD:" + oldValue);
60
                //logger.debug("New:" + newValue);
61
				if (! isPersistentSet(newValue) && ! isPersistentSet(oldValue)  ){
62
					cb.firePropertyChange( propertyName, oldValue, newValue);
63
				}
64
			} catch (NoSuchMethodException |IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
65
				e.printStackTrace();
66
				proceed( cb );
67
			}
49
			if (logger.isDebugEnabled()){ logger.debug("execSetter: The property is ["+propertyName+"]");}
50
			if ("updated".equals(propertyName) || "updatedBy".equals(propertyName) ||
51
			    "created".equals(propertyName) || "createdBy".equals(propertyName) ||
52
			    "cacheStrategy".equals(propertyName)){
53
			    proceed (cb);
54
			}else{
55
    			property.setAccessible(true);
56
    			try {
57
    				// use property attribute directly, not through get method.
58
    				// get method might modify things, like setting a UUID when called for the first time.
59
    				// Also get methods for booleans start with "is" or "has"
60
    				Object oldValue = property.get(cb);
61
    				proceed( cb );
62
    				Object newValue = property.get(cb);
63
                    //logger.debug ("Prop: " + propertyName);
64
                    //logger.debug("OLD:" + oldValue);
65
                    //logger.debug("New:" + newValue);
66
    				if (! isPersistentSet(newValue) && ! isPersistentSet(oldValue)  ){
67
    					cb.firePropertyChange( propertyName, oldValue, newValue);
68
    				}
69
    			} catch (NoSuchMethodException |IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
70
    				e.printStackTrace();
71
    				proceed( cb );
72
    			}
73
    	    }
68 74
		}
69 75
	}
70 76
	

Also available in: Unified diff