KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > fields > ContentDateField


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

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 JavaDoc;
26 import java.util.Set JavaDoc;
27 import java.util.Vector JavaDoc;
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     //--------------------------------------------------------------------------
34
protected ContentDateField (Integer JavaDoc ID,
35                                 Integer JavaDoc jahiaID,
36                                 Integer JavaDoc pageID,
37                                 Integer JavaDoc ctnid,
38                                 Integer JavaDoc fieldDefID,
39                                 Integer JavaDoc fieldType,
40                                 Integer JavaDoc connectType,
41                                 Integer JavaDoc aclID,
42                                 Vector JavaDoc activeAndStagingEntryStates,
43                                 Hashtable JavaDoc 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     //--------------------------------------------------------------------------
51
public static synchronized ContentDateField
52             createDate (int siteID,
53                         int pageID,
54                         int containerID,
55                         int fieldDefID,
56                         int parentAclID, int aclID,
57                         String JavaDoc 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     //--------------------------------------------------------------------------
76
/**
77      * Gets the String representation of this field. In case of an Application,
78      * it will be the output of the application, in case of a bigtext it will
79      * be the full content of the bigtext, etc. This is called by the public
80      * method getValue of ContentField, which does the entryState resolving
81      * This method should call getDBValue to get the DBValue
82      */

83     public String JavaDoc getValue (ParamBean jParams,
84                                ContentObjectEntryState entryState)
85             throws JahiaException {
86         //return FormDataManager.getInstance().formDecode(getDBValue(entryState));
87
return getDBValue (entryState);
88     }
89
90     //--------------------------------------------------------------------------
91
/**
92      * Sets the String representation of this field.
93      * This method should call preSet and postSet.
94      */

95     public void setValue (String JavaDoc value,
96                           EntrySaveRequest saveRequest)
97             throws JahiaException {
98         if (value == null) {
99             value = "";
100         }
101         preSet (value, saveRequest);
102     }
103
104     //--------------------------------------------------------------------------
105
/**
106      * get the Value that will be added to the search engine for this field.
107      * for a bigtext it will be the content of the bigtext, for an application
108      * the string will be empty!
109      * Do not return null, return an empty string instead.
110      *
111      * @param jParams the jParam containing the loadVersion and locales
112      */

113     public String JavaDoc getValueForSearch (ParamBean jParams,
114                                      ContentObjectEntryState entryState)
115             throws JahiaException {
116         //return FormDataManager.getInstance().formDecode(getDBValue(entryState));
117
return getDBValue (entryState);
118     }
119
120     //--------------------------------------------------------------------------
121
/**
122      * This method is called when there is a workflow state change
123      * Such as staged mode -> active mode (validation), active -> inactive (for versioning)
124      * and also staged mode -> other staged mode (workflow)
125      * This method should not write/change the DBValue, the service handles that.
126      *
127      * @param fromEntryState the entry state that is currently was in the database
128      * @param toEntryState the entry state that will be written to the database
129      * @param jParams ParamBean object used to get information about the user
130      * doing the request, the current locale, etc...
131      *
132      * @return null if the entry state change wasn't an activation, otherwise it
133      * returns an object that contains the status of the activation (whether
134      * successfull, partial or failed, as well as messages describing the
135      * warnings during the activation process)
136      */

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     //--------------------------------------------------------------------------
146
protected ActivationTestResults isContentValidForActivation (
147             Set JavaDoc languageCodes,
148             ParamBean jParams,
149             StateModificationContext stateModifContext)
150             throws JahiaException {
151         /** @todo to be implemented */
152         return new ActivationTestResults ();
153     }
154
155     //--------------------------------------------------------------------------
156
/**
157      * Is this kind of field shared (i.e. not one version for each language,
158      * but one version for every language)
159      */

160     public boolean isShared () {
161         return true;
162     }
163
164     /**
165      * This is called on all content fields to have them serialized only their
166      * specific part. The actual field metadata seriliazing is handled by the
167      * ContentField class. This method is called multiple times per field
168      * according to the workflow state, languages and versioning entries we
169      * want to serialize.
170      *
171      * @param xmlWriter the XML writer object in which to write the XML output
172      * @param xmlSerializationOptions options used to activate/bypass certain
173      * output of elements.
174      * @param entryState the ContentFieldEntryState for which to generate the
175      * XML export.
176      * @param paramBean specifies context of serialization, such as current
177      * user, current request parameters, entry load request, URL generation
178      * information such as ServerName, ServerPort, ContextPath, etc... URL
179      * generation is an important part of XML serialization and this is why
180      * we pass this parameter down, as well as user rights checking.
181      *
182      * @throws IOException in case there was an error writing to the Writer
183      * output object.
184      */

185     protected void serializeContentToXML (XmlWriter xmlWriter,
186                                           XMLSerializationOptions xmlSerializationOptions,
187                                           ContentObjectEntryState entryState,
188                                           ParamBean paramBean) throws java.io.IOException JavaDoc {
189         try {
190             //String result = FormDataManager.getInstance().formDecode(getDBValue(entryState));
191
String JavaDoc 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