KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc;
26 import java.util.Hashtable JavaDoc;
27 import java.util.Set JavaDoc;
28 import java.util.Vector JavaDoc;
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     //--------------------------------------------------------------------------
35
protected ContentUndefinedField (Integer JavaDoc ID,
36                                      Integer JavaDoc jahiaID,
37                                      Integer JavaDoc pageID,
38                                      Integer JavaDoc ctnid,
39                                      Integer JavaDoc fieldDefID,
40                                      Integer JavaDoc fieldType,
41                                      Integer JavaDoc connectType,
42                                      Integer JavaDoc aclID,
43                                      Vector JavaDoc activeAndStagingEntryStates,
44                                      Hashtable JavaDoc 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     //--------------------------------------------------------------------------
52
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     //--------------------------------------------------------------------------
70
/**
71      * Gets the String representation of this field. In case of an Application,
72      * it will be the output of the application, in case of a bigtext it will
73      * be the full content of the bigtext, etc. This is called by the public
74      * method getValue of ContentField, which does the entryState resolving
75      * This method should call getDBValue to get the DBValue
76      */

77     public String JavaDoc getValue (ParamBean jParams,
78                                ContentObjectEntryState entryState)
79             throws JahiaException {
80         //return FormDataManager.getInstance().formDecode(getDBValue(entryState));
81
return getDBValue (entryState);
82     }
83
84     //--------------------------------------------------------------------------
85
/**
86      * get the Value that will be added to the search engine for this field.
87      * for a bigtext it will be the content of the bigtext, for an application
88      * the string will be empty!
89      * Do not return null, return an empty string instead.
90      *
91      * @param jParams the jParam containing the loadVersion and locales
92      */

93     public String JavaDoc getValueForSearch (ParamBean jParams,
94                                      ContentObjectEntryState entryState)
95             throws JahiaException {
96         return getDBValue (entryState);
97     }
98
99     //--------------------------------------------------------------------------
100
/**
101      * This method is called when there is a workflow state change
102      * Such as staged mode -> active mode (validation), active -> inactive (for versioning)
103      * and also staged mode -> other staged mode (workflow)
104      * This method should not write/change the DBValue, the service handles that.
105      *
106      * @param fromEntryState the entry state that is currently was in the database
107      * @param toEntryState the entry state that will be written to the database
108      * @param jParams ParamBean object used to get information about the user
109      * doing the request, the current locale, etc...
110      *
111      * @return null if the entry state change wasn't an activation, otherwise it
112      * returns an object that contains the status of the activation (whether
113      * successfull, partial or failed, as well as messages describing the
114      * warnings during the activation process)
115      */

116     public ActivationTestResults changeEntryState (ContentObjectEntryState fromEntryState,
117                                                    ContentObjectEntryState toEntryState,
118                                                    ParamBean jParams,
119                                                    StateModificationContext stateModifContext)
120             throws JahiaException {
121         return null;
122     }
123
124     //--------------------------------------------------------------------------
125
protected ActivationTestResults isContentValidForActivation (
126             Set JavaDoc languageCodes,
127             ParamBean jParams,
128             StateModificationContext stateModifContext)
129             throws JahiaException {
130         /** @todo to be implemented */
131         return new ActivationTestResults ();
132     }
133
134     //--------------------------------------------------------------------------
135
/**
136      * Is this kind of field shared (i.e. not one version for each language,
137      * but one version for every language)
138      */

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     /**
156      * This is called on all content fields to have them serialized only their
157      * specific part. The actual field metadata seriliazing is handled by the
158      * ContentField class. This method is called multiple times per field
159      * according to the workflow state, languages and versioning entries we
160      * want to serialize.
161      *
162      * @param xmlWriter the XML writer object in which to write the XML output
163      * @param xmlSerializationOptions options used to activate/bypass certain
164      * output of elements.
165      * @param entryState the ContentFieldEntryState for which to generate the
166      * XML export.
167      * @param paramBean specifies context of serialization, such as current
168      * user, current request parameters, entry load request, URL generation
169      * information such as ServerName, ServerPort, ContextPath, etc... URL
170      * generation is an important part of XML serialization and this is why
171      * we pass this parameter down, as well as user rights checking.
172      *
173      * @throws IOException in case there was an error writing to the Writer
174      * output object.
175      */

176     protected void serializeContentToXML (XmlWriter xmlWriter,
177                                           XMLSerializationOptions
178             xmlSerializationOptions,
179                                           ContentObjectEntryState entryState,
180                                           ParamBean paramBean)
181             throws IOException JavaDoc {
182         try {
183             //String result = FormDataManager.getInstance().formDecode(getDBValue(entryState));
184
String JavaDoc 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