1 16 17 18 package org.jahia.services.containers; 19 20 import org.jahia.data.fields.JahiaField; 21 import org.jahia.data.events.JahiaEvent; 22 import org.jahia.data.events.JahiaEventListener; 23 import org.jahia.exceptions.*; 24 import org.jahia.services.fields.ContentField; 25 26 35 public class FieldsChangeEventListener extends JahiaEventListener 36 { 37 38 private static org.apache.log4j.Logger logger = 39 org.apache.log4j.Logger.getLogger (FieldsChangeEventListener.class); 40 41 private static final String CLASS_NAME = FieldsChangeEventListener.class.getName(); 42 43 public static final String FIELD_ADDED = "fieldAdded"; 44 public static final String FIELD_UPDATED = "fieldUpdated"; 45 public static final String FIELD_DELETED = "fieldDeleted"; 46 47 public FieldsChangeEventListener() throws JahiaException { 48 } 49 50 56 public void fieldAdded( JahiaEvent je ) { 57 JahiaField theField = (JahiaField) je.getObject(); 58 if ( theField != null ){ 59 notifyChange(theField.getID()); 60 } 61 } 62 63 69 public void fieldUpdated( JahiaEvent je ) { 70 JahiaField theField = (JahiaField) je.getObject(); 71 if ( theField != null ){ 72 notifyChange(theField.getID()); 73 } 74 } 75 76 82 public void fieldDeleted( JahiaEvent je ) { 83 JahiaField theField = (JahiaField) je.getObject(); 84 if ( theField != null ){ 85 notifyChange(theField.getID()); 86 } 87 } 88 89 96 public synchronized void notifyChange( int fieldId ) { 97 try { 98 ContentField contentField = ContentField.getField(fieldId); 99 notifyChange(contentField); 100 } catch ( JahiaException je ){ 101 logger.debug("Exception looking for field " + fieldId, je); 102 } 103 } 104 105 112 public synchronized void notifyChange( ContentField contentField ) { 113 114 if ( contentField == null ){ 115 return; 116 } 117 ContentContainerTools.getInstance() 118 .invalidateFieldIDsByContainerFromCache(contentField.getContainerID()); 119 } 120 121 } 122 | Popular Tags |