1 13 package org.jahia.services.fields; 14 15 import org.jahia.data.ConnectionTypes; 16 import org.jahia.exceptions.JahiaException; 17 import org.jahia.params.ParamBean; 18 import org.jahia.services.version.ActivationTestResults; 19 import org.jahia.services.version.ContentObjectEntryState; 20 import org.jahia.services.version.EntrySaveRequest; 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.util.Hashtable ; 26 import java.util.Set ; 27 import java.util.Vector ; 28 29 public class ContentDateField extends ContentField { 30 private static org.apache.log4j.Logger logger 31 = org.apache.log4j.Logger.getLogger (ContentDateField.class); 32 33 protected ContentDateField (Integer ID, 35 Integer jahiaID, 36 Integer pageID, 37 Integer ctnid, 38 Integer fieldDefID, 39 Integer fieldType, 40 Integer connectType, 41 Integer aclID, 42 Vector activeAndStagingEntryStates, 43 Hashtable activeAndStagedDBValues) { 44 super (ID.intValue (), jahiaID.intValue (), pageID.intValue (), 45 ctnid.intValue (), fieldDefID.intValue (), fieldType.intValue (), 46 connectType.intValue (), aclID.intValue (), 47 activeAndStagingEntryStates, activeAndStagedDBValues); 48 } 49 50 public static synchronized ContentDateField 52 createDate (int siteID, 53 int pageID, 54 int containerID, 55 int fieldDefID, 56 int parentAclID, int aclID, 57 String value, 58 ParamBean jParams) 59 throws JahiaException { 60 ContentDateField result = 61 (ContentDateField) 62 ContentField.createField (siteID, pageID, containerID, 63 fieldDefID, ContentFieldTypes.BOOLEAN, 64 ConnectionTypes.LOCAL, parentAclID, 65 aclID); 66 67 EntrySaveRequest saveRequest = 68 new EntrySaveRequest (jParams.getUser (), 69 ContentField.SHARED_LANGUAGE); 70 71 result.setValue (value, saveRequest); 72 return result; 73 } 74 75 83 public String getValue (ParamBean jParams, 84 ContentObjectEntryState entryState) 85 throws JahiaException { 86 return getDBValue (entryState); 88 } 89 90 95 public void setValue (String value, 96 EntrySaveRequest saveRequest) 97 throws JahiaException { 98 if (value == null) { 99 value = ""; 100 } 101 preSet (value, saveRequest); 102 } 103 104 113 public String getValueForSearch (ParamBean jParams, 114 ContentObjectEntryState entryState) 115 throws JahiaException { 116 return getDBValue (entryState); 118 } 119 120 137 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 138 ContentObjectEntryState toEntryState, 139 ParamBean jParams, 140 StateModificationContext stateModifContext) 141 throws JahiaException { 142 return new ActivationTestResults (); 143 } 144 145 protected ActivationTestResults isContentValidForActivation ( 147 Set languageCodes, 148 ParamBean jParams, 149 StateModificationContext stateModifContext) 150 throws JahiaException { 151 152 return new ActivationTestResults (); 153 } 154 155 160 public boolean isShared () { 161 return true; 162 } 163 164 185 protected void serializeContentToXML (XmlWriter xmlWriter, 186 XMLSerializationOptions xmlSerializationOptions, 187 ContentObjectEntryState entryState, 188 ParamBean paramBean) throws java.io.IOException { 189 try { 190 String result = getDBValue (entryState); 192 xmlWriter.writeText (result); 193 } catch (JahiaException je) { 194 logger.debug ("Error while serializing small text field to XML : ", je); 195 } 196 } 197 198 199 } 200 | Popular Tags |