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.io.IOException ; 26 import java.util.Hashtable ; 27 import java.util.Set ; 28 import java.util.Vector ; 29 30 public class ContentSmallTextField extends ContentField implements ContentSimpleField { 31 private static org.apache.log4j.Logger logger 32 = org.apache.log4j.Logger.getLogger (ContentSmallTextField.class); 33 34 35 protected ContentSmallTextField (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 (), ctnid.intValue (), fieldDefID.intValue (), 46 fieldType.intValue (), connectType.intValue (), aclID.intValue (), activeAndStagingEntryStates, 47 activeAndStagedDBValues); 48 } 49 50 public static synchronized ContentSmallTextField createSmallText (int siteID, 51 int pageID, 52 int containerID, 53 int fieldDefID, 54 int parentAclID, 55 int aclID, 56 String text, 57 ParamBean jParams) 58 throws JahiaException { 59 ContentSmallTextField result = 60 (ContentSmallTextField) ContentField.createField (siteID, pageID, 61 containerID, fieldDefID, 62 ContentFieldTypes.SMALLTEXT, 63 ConnectionTypes.LOCAL, 64 parentAclID, aclID); 65 EntrySaveRequest saveRequest = new EntrySaveRequest (jParams.getUser (), 66 jParams.getLocale ().toString ()); 67 68 result.setText (text, saveRequest); 69 return result; 70 } 71 72 81 public String getValue (ParamBean jParams, ContentObjectEntryState entryState) 82 throws JahiaException { 83 if (entryState == null) { 84 return ""; 85 } 86 String result = this.getDBValue (entryState); 87 88 if (result == null || result.equals ("<empty>")) { 89 result = new String (); 90 } 91 return result; 92 } 93 94 98 public void setText (String value, EntrySaveRequest saveRequest) throws JahiaException { 99 preSet (value, saveRequest); 100 } 101 102 110 public String getValueForSearch (ParamBean jParams, 111 ContentObjectEntryState entryState) throws JahiaException { 112 return getDBValue (entryState); 114 } 115 116 132 public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState, 133 ContentObjectEntryState toEntryState, 134 ParamBean jParams, 135 StateModificationContext stateModifContext) 136 throws JahiaException { 137 return new ActivationTestResults (); 138 } 139 140 protected ActivationTestResults isContentValidForActivation ( 141 Set languageCodes, 142 ParamBean jParams, 143 StateModificationContext stateModifContext) throws JahiaException { 144 145 return new ActivationTestResults (); 146 } 147 148 151 public boolean isShared () { 152 return false; 153 } 154 155 176 protected void serializeContentToXML (XmlWriter xmlWriter, 177 XMLSerializationOptions xmlSerializationOptions, 178 ContentObjectEntryState entryState, 179 ParamBean paramBean) throws IOException { 180 try { 181 String result = getDBValue (entryState); 183 xmlWriter.writeCData (result); 184 } catch (JahiaException je) { 185 logger.debug ("Error while serializing small text field to XML : ", je); 186 } 187 } 188 189 } 190 | Popular Tags |