1 13 package org.jahia.services.fields; 14 15 import org.jahia.data.ConnectionTypes; 16 import org.jahia.data.fields.FieldTypes; 17 import org.jahia.exceptions.JahiaException; 18 import org.jahia.params.ParamBean; 19 import org.jahia.services.version.ActivationTestResults; 20 import org.jahia.services.version.ContentObjectEntryState; 21 import org.jahia.services.version.StateModificationContext; 22 import org.jahia.utils.xml.XMLSerializationOptions; 23 import org.jahia.utils.xml.XmlWriter; 24 25 import java.io.IOException ; 26 import java.util.Hashtable ; 27 import java.util.Set ; 28 import java.util.Vector ; 29 30 public class ContentUndefinedField extends ContentField implements ContentSimpleField { 31 private static org.apache.log4j.Logger logger 32 = org.apache.log4j.Logger.getLogger (ContentUndefinedField.class); 33 34 protected ContentUndefinedField (Integer ID, 36 Integer jahiaID, 37 Integer pageID, 38 Integer ctnid, 39 Integer fieldDefID, 40 Integer fieldType, 41 Integer connectType, 42 Integer aclID, 43 Vector activeAndStagingEntryStates, 44 Hashtable activeAndStagedDBValues) { 45 super (ID.intValue (), jahiaID.intValue (), pageID.intValue (), 46 ctnid.intValue (), fieldDefID.intValue (), fieldType.intValue (), 47 connectType.intValue (), aclID.intValue (), 48 activeAndStagingEntryStates, activeAndStagedDBValues); 49 } 50 51 public static synchronized ContentUndefinedField 53 createUndefined (int siteID, 54 int pageID, 55 int containerID, 56 int fieldDefID, 57 int parentAclID, int aclID, 58 ParamBean jParams) 59 throws JahiaException { 60 ContentUndefinedField result = 61 (ContentUndefinedField) 62 ContentField.createField (siteID, pageID, containerID, 63 fieldDefID, ContentFieldTypes.BOOLEAN, 64 ConnectionTypes.LOCAL, parentAclID, 65 aclID); 66 return result; 67 } 68 69 77 public String getValue (ParamBean jParams, 78 ContentObjectEntryState entryState) 79 throws JahiaException { 80 return getDBValue (entryState); 82 } 83 84 93 public String getValueForSearch (ParamBean jParams, 94 ContentObjectEntryState entryState) 95 throws JahiaException { 96 return getDBValue (entryState); 97 } 98 99 116 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 117 ContentObjectEntryState toEntryState, 118 ParamBean jParams, 119 StateModificationContext stateModifContext) 120 throws JahiaException { 121 return null; 122 } 123 124 protected ActivationTestResults isContentValidForActivation ( 126 Set languageCodes, 127 ParamBean jParams, 128 StateModificationContext stateModifContext) 129 throws JahiaException { 130 131 return new ActivationTestResults (); 132 } 133 134 139 public boolean isShared () { 140 if (this.getType () == FieldTypes.UNDEFINED 141 || this.getType () == FieldTypes.APPLICATION 142 || this.getType () == FieldTypes.BOOLEAN 143 || this.getType () == FieldTypes.COLOR 144 || this.getType () == FieldTypes.DATE 145 || this.getType () == FieldTypes.FLOAT 146 || this.getType () == FieldTypes.INTEGER 147 || this.getType () == FieldTypes.PAGE 148 || this.getType () == FieldTypes.SMALLTEXT_SHARED_LANG) { 149 return true; 150 } else { 151 return false; 152 } 153 } 154 155 176 protected void serializeContentToXML (XmlWriter xmlWriter, 177 XMLSerializationOptions 178 xmlSerializationOptions, 179 ContentObjectEntryState entryState, 180 ParamBean paramBean) 181 throws IOException { 182 try { 183 String result = getDBValue (entryState); 185 xmlWriter.writeCData (result); 186 } catch (JahiaException je) { 187 logger.debug ("Error while serializing small text field to XML : ", je); 188 } 189 } 190 191 192 } 193 | Popular Tags |