View Javadoc
1   /*
2    * Copyright (C) 2003-2007 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.services.cms.templates.impl;
18  
19  import org.exoplatform.container.component.BaseComponentPlugin;
20  import org.exoplatform.container.configuration.ConfigurationManager;
21  import org.exoplatform.container.xml.InitParams;
22  import org.exoplatform.container.xml.ObjectParameter;
23  import org.exoplatform.container.xml.ValueParam;
24  import org.exoplatform.services.cms.BasePath;
25  import org.exoplatform.services.cms.impl.DMSConfiguration;
26  import org.exoplatform.services.cms.impl.DMSRepositoryConfiguration;
27  import org.exoplatform.services.cms.impl.Utils;
28  import org.exoplatform.services.cms.templates.TemplateService;
29  import org.exoplatform.services.jcr.RepositoryService;
30  import org.exoplatform.services.jcr.core.ManageableRepository;
31  import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
32  import org.exoplatform.services.log.ExoLogger;
33  import org.exoplatform.services.log.Log;
34  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
35  
36  import javax.jcr.Node;
37  import javax.jcr.PathNotFoundException;
38  import javax.jcr.PropertyType;
39  import javax.jcr.RepositoryException;
40  import javax.jcr.Session;
41  import javax.jcr.Value;
42  import javax.jcr.ValueFormatException;
43  import javax.jcr.nodetype.NodeDefinition;
44  import javax.jcr.nodetype.NodeType;
45  import javax.jcr.nodetype.NodeTypeIterator;
46  import javax.jcr.nodetype.NodeTypeManager;
47  import javax.jcr.nodetype.PropertyDefinition;
48  import java.io.InputStream;
49  import java.util.ArrayList;
50  import java.util.HashSet;
51  import java.util.Iterator;
52  import java.util.List;
53  import java.util.Set;
54  
55  public class TemplatePlugin extends BaseComponentPlugin {
56  
57    static final public String   DIALOGS                    = "dialogs";
58  
59    static final public String   VIEWS                      = "views";
60  
61    static final public String   SKINS                      = "skins";
62  
63    static final public String   DEFAULT_DIALOG             = "dialog1";
64  
65    static final public String   DEFAULT_VIEW               = "view1";
66  
67    static final String[]        UNDELETABLE_TEMPLATES      = { DEFAULT_DIALOG, DEFAULT_VIEW };
68  
69    static final public String   DEFAULT_DIALOGS_PATH       = "/" + DIALOGS + "/" + DEFAULT_DIALOG;
70  
71    static final public String   DEFAULT_VIEWS_PATH         = "/" + VIEWS + "/" + DEFAULT_VIEW;
72  
73    static final public String   NT_UNSTRUCTURED            = "nt:unstructured";
74  
75    static final public String   DOCUMENT_TEMPLATE_PROP     = "isDocumentTemplate";
76  
77    static final public String   TEMPLATE_LABEL             = "label";
78  
79    public static final String[] EXO_ROLES_DEFAULT          = new String[] { "*" };
80  
81    private static final String  NAME;
82  
83    private static final String  COMMENT_TEMPLATE;
84  
85    private static final String  HEADER_VIEW;
86  
87    private static final String  JAVA_HEADER_VIEW;
88  
89    private static final String  DEF_FIELD_PROPERTY;
90  
91    private static final String  FIELD_PROPERTY;
92  
93    private static final String  START_DIALOG_FORM;
94  
95    private static final String  END_DIALOG_FORM;
96  
97    private static final String  TD_LABEL;
98  
99    private static final String  TD_COMPONENT;
100 
101   private static final String  START_TABLE;
102 
103   private static final String  END_TABLE;
104 
105   private static final String  START_TR;
106 
107   private static final String  END_TR;
108 
109   private static final String  CHECK_PROPERTY;
110 
111   private static final String  GET_PROPERTY;
112 
113   private static final String  START_JAVA;
114 
115   private static final String  END_JAVA;
116 
117   private static final String  DEFAULT_CSS;
118 
119   private static final String  JCR_PRIMARY_TYPE = "jcr:primaryType";
120 
121   private static final String  JCR_MIXIN_TYPES = "jcr:mixinTypes";
122 
123   private RepositoryService repositoryService_;
124   private ConfigurationManager  configManager_;
125   private NodeHierarchyCreator nodeHierarchyCreator_;
126   private String cmsTemplatesBasePath_ ;
127   private InitParams params_ ;
128   private String storedLocation_ ;
129   private boolean autoCreateInNewRepository_=false;
130   private static final Log LOG = ExoLogger.getLogger(TemplatePlugin.class.getName());
131   private Set<String> configuredNodeTypes;
132 
133   private TemplateService templateService;
134 
135   static {
136 
137     COMMENT_TEMPLATE = "<%\n// Generate template for nodetype automatically\n%>\n";
138 
139     HEADER_VIEW = new StringBuilder("<style>\n")
140                     .append("\t<% _ctx.include(uicomponent.getTemplateSkin(\"${NodeType}\", \"Stylesheet\")); %>\n")
141                     .append("</style>\n").toString();
142 
143     JAVA_HEADER_VIEW = new StringBuilder("<%\n\tdef node = uicomponent.getNode();\n")
144                         .append("\tdef name = node.getName();\n")
145                         .append("\tdef values;\n")
146                         .append("\tdef valueDisplay;\n%>").toString();
147 
148     DEF_FIELD_PROPERTY = "\t\t\t\t\t<%\n\t\t\t\t\t\tString[] fieldProperty; \n\t\t\t\t\t%>\n";
149 
150     FIELD_PROPERTY = "fieldProperty";
151 
152     START_DIALOG_FORM = new StringBuilder("<div class=\"UIForm FormLayout FormScrollLayout\">\n")
153                         .append("\t<% uiform.begin();\n")
154                         .append("\t   /* start render action*/\n")
155                         .append("\t   if (uiform.isShowActionsOnTop()) uiform.processRenderAction();\n")
156                         .append("\t   /* end render action*/\n")
157                         .append("\t%> \n")
158                         .append("\t\t<div class=\"HorizontalLayout\">\n").toString();
159 
160     NAME = new StringBuilder("\n\t\t\t\t\t<%\n")
161             .append("\t\t\t\t\t\tString[] fieldName = [\"jcrPath=/node\", \"editable=if-null\", \"validate=empty,name\"];\n")
162             .append("\t\t\t\t\t\tuicomponent.addTextField(\"name\", fieldName);\n")
163             .append("\t\t\t\t\t%>\n").toString();
164 
165     START_TABLE = "\n\t\t\t<table class=\"UIFormGrid\">\n";
166 
167     START_TR = "\n\t\t\t\t<tr>\n";
168 
169     END_TR = "\t\t\t\t</tr>";
170 
171     START_JAVA = "\n\t\t\t\t<%\n";
172 
173     END_JAVA = "\n\t\t\t\t%>";
174 
175     CHECK_PROPERTY = "\t\t\t\t if (node.hasProperty(\"${propertyname}\")) {";
176 
177     GET_PROPERTY = "node.getProperty(\"${propertyname}\")";
178 
179     TD_LABEL = new StringBuilder("").append("\t\t\t\t\t<td class=\"FieldLabel\">")
180                 .append("<%=_ctx.appRes(\"${nodetypename}.dialog.label.${propertyname}\")%>")
181                 .append("</td>").toString();
182 
183     TD_COMPONENT = new StringBuilder("\n").append("\t\t\t\t\t<td class=\"FieldComponent\">")
184                     .append("${contentcomponent}").append("\t\t\t\t\t</td>\n").toString();
185 
186     END_TABLE = "\n\t\t\t</table>\n";
187 
188     END_DIALOG_FORM = new StringBuilder("").append("\t\t</div>\n")
189                         .append("\t<% /* start render action*/\n")
190                         .append("\t   if (!uiform.isShowActionsOnTop()) uiform.processRenderAction();\n")
191                         .append("\t   /* end render action*/\n")
192                         .append("\t   uiform.end();\n\t%>\n").append("</div>").toString();
193 
194     DEFAULT_CSS = new StringBuilder(".UIFormGrid {")
195                     .append("\n\tborder:1px solid #B7B7B7;")
196                     .append("\n\tborder-collapse:collapse;")
197                     .append("\n\tmargin:auto;")
198                     .append("\n\tpadding-left:1px;")
199                     .append("\n\ttable-layout:fixed;")
200                     .append("\n}")
201                     .append("\n\n.UIFormGrid .FieldLabel {")
202                     .append("\n\tfont-weight:bold;")
203                     .append("\n\twidth:auto;")
204                     .append("\n}")
205                     .append("\n\n.UIFormGrid td {")
206                     .append("\n\tborder-left:1px solid #CCCCCC;")
207                     .append("\n\tborder-right:1px solid #CCCCCC;")
208                     .append("\n\tborder-top:1px solid #FFFFFF;")
209                     .append("\n\tbackground:#F3F3F3 none repeat scroll 0 0;")
210                     .append("\n\theight:20px;")
211                     .append("\n\tline-height:20px;")
212                     .append("\n\tpadding:4px;")
213                     .append("\n}").toString();
214   }
215 
216   /**
217    * DMS configuration which used to store informations
218    */
219   private DMSConfiguration dmsConfiguration_;
220 
221   public TemplatePlugin(InitParams params,
222                         RepositoryService jcrService,
223                         ConfigurationManager configManager,
224                         NodeHierarchyCreator nodeHierarchyCreator,
225                         DMSConfiguration dmsConfiguration) throws Exception {
226     nodeHierarchyCreator_ = nodeHierarchyCreator;
227     repositoryService_ = jcrService;
228     configManager_ = configManager;
229     cmsTemplatesBasePath_ = nodeHierarchyCreator_.getJcrPath(BasePath.CMS_TEMPLATES_PATH);
230     params_ = params;
231     ValueParam locationParam = params_.getValueParam("storedLocation") ;
232     storedLocation_ = locationParam.getValue();
233     ValueParam param = params_.getValueParam("autoCreateInNewRepository");
234     if(param!=null) {
235       autoCreateInNewRepository_ = Boolean.parseBoolean(param.getValue());
236     }
237     dmsConfiguration_ = dmsConfiguration;
238     templateService = WCMCoreUtils.getService(TemplateService.class);
239   }
240 
241   public void init() throws Exception {
242     configuredNodeTypes = new HashSet<String>();
243     importPredefineTemplates() ;
244   }
245 
246   @SuppressWarnings("rawtypes")
247   private void addTemplate(TemplateConfig templateConfig, Node templatesHome, String storedLocation) throws Exception {
248     Set<String> editedPredefinedNodeTypes = templateService.getAllEditedConfiguredNodeTypes();
249     NodeTypeManager ntManager = templatesHome.getSession().getWorkspace().getNodeTypeManager() ;
250     NodeTypeIterator nodetypeIter = ntManager.getAllNodeTypes();
251     List<String> listNodeTypeName = new ArrayList<String>();
252     while (nodetypeIter.hasNext()) {
253       NodeType n1 = nodetypeIter.nextNodeType();
254       listNodeTypeName.add(n1.getName());
255     }
256     List nodetypes = templateConfig.getNodeTypes();
257     TemplateConfig.NodeType nodeType = null ;
258     Iterator iter = nodetypes.iterator() ;
259     while(iter.hasNext()) {
260       nodeType = (TemplateConfig.NodeType) iter.next();
261       if(Utils.getAllEditedConfiguredData(
262         "ContentTemplateList", "EditedConfiguredTemplateList", true).contains(nodeType.getNodetypeName())
263         || !listNodeTypeName.contains(nodeType.getNodetypeName())) {
264         if (LOG.isErrorEnabled()) {
265           LOG.error("The nodetype: " + nodeType.getNodetypeName() + " or its templates doesn't exist!");
266         }
267         continue;
268       }
269       
270       configuredNodeTypes.add(nodeType.getNodetypeName());
271 
272       // Do not update predefined templates which was edited by user
273       if (editedPredefinedNodeTypes.contains(nodeType.getNodetypeName())) continue;
274       
275       Node nodeTypeHome = null;
276       nodeTypeHome = Utils.makePath(templatesHome, nodeType.getNodetypeName(), NT_UNSTRUCTURED);
277       if(nodeType.getDocumentTemplate())
278         nodeTypeHome.setProperty(DOCUMENT_TEMPLATE_PROP, true) ;
279       else
280         nodeTypeHome.setProperty(DOCUMENT_TEMPLATE_PROP, false) ;
281 
282       nodeTypeHome.setProperty(TEMPLATE_LABEL, nodeType.getLabel()) ;
283 
284       List dialogs = nodeType.getReferencedDialog();
285       addNode(storedLocation, nodeType, dialogs, DIALOGS, templatesHome);
286 
287       List views = nodeType.getReferencedView();
288       addNode(storedLocation, nodeType, views, VIEWS, templatesHome);
289 
290       List skins = nodeType.getReferencedSkin();
291       if(skins != null) {
292         addNode(storedLocation, nodeType, skins, SKINS, templatesHome);
293       }
294     }
295   }
296 
297   public void setBasePath(String basePath) { cmsTemplatesBasePath_ = basePath ; }
298 
299   @SuppressWarnings("unchecked")
300   private void importPredefineTemplates() throws Exception {
301     ManageableRepository repository = repositoryService_.getCurrentRepository();
302     DMSRepositoryConfiguration dmsRepoConfig = dmsConfiguration_.getConfig();
303     String workspace = dmsRepoConfig.getSystemWorkspace();
304     Session session = repository.getSystemSession(workspace) ;
305     Node templatesHome = Utils.makePath(session.getRootNode(), cmsTemplatesBasePath_, NT_UNSTRUCTURED);
306     TemplateConfig templateConfig = null ;
307     Iterator<ObjectParameter> iter = params_.getObjectParamIterator() ;
308     while(iter.hasNext()) {
309       Object object = iter.next().getObject() ;
310       if(!(object instanceof TemplateConfig)) {
311         break ;
312       }
313       templateConfig = (TemplateConfig)object ;
314       addTemplate(templateConfig,templatesHome,storedLocation_) ;
315     }
316     session.logout();
317   }
318 
319   @SuppressWarnings("rawtypes")
320   private void addNode(String basePath, TemplateConfig.NodeType nodeType, List templates, String templateType,
321       Node templatesHome)  throws Exception {
322     for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
323       TemplateConfig.Template template = (TemplateConfig.Template) iterator.next();
324       String templateFileName = template.getTemplateFile();
325       String path = basePath + templateFileName;
326       InputStream in = configManager_.getInputStream(path);
327       String nodeName = templateFileName.substring(templateFileName.lastIndexOf("/") + 1, templateFileName.indexOf("."));
328       Node nodeTypeHome = null;
329       if (!templatesHome.hasNode(nodeType.getNodetypeName())) {
330         nodeTypeHome = Utils.makePath(templatesHome, nodeType.getNodetypeName(), NT_UNSTRUCTURED);
331       } else {
332         nodeTypeHome = templatesHome.getNode(nodeType.getNodetypeName());
333       }
334       Node specifiedTemplatesHome = null;
335       try {
336         specifiedTemplatesHome = nodeTypeHome.getNode(templateType);
337       } catch(PathNotFoundException e) {
338         specifiedTemplatesHome = Utils.makePath(nodeTypeHome, templateType, NT_UNSTRUCTURED);
339       }
340       if(!specifiedTemplatesHome.hasNode(nodeName)) {
341         templateService.addTemplate(templateType,
342                                     nodeType.getNodetypeName(),
343                                     nodeType.getLabel(),
344                                     nodeType.getDocumentTemplate(),
345                                     nodeName,
346                                     template.getParsedRoles(),
347                                     in,
348                                     templatesHome);
349       }
350     }
351   }
352 
353   /**
354    * Build default style sheet
355    * @param nodeType
356    * @return
357    */
358   public String buildStyleSheet(NodeType nodeType) {
359     return COMMENT_TEMPLATE.concat(DEFAULT_CSS);
360   }
361 
362   /**
363    * Build string of dialog form template base on properties of nodetype
364    * @param nodeType
365    * @return
366    */
367   public String buildDialogForm(NodeType nodeType) throws ValueFormatException, RepositoryException {
368     StringBuilder buildDialogForm = new StringBuilder(COMMENT_TEMPLATE);
369     buildDialogForm.append(START_DIALOG_FORM).append(START_TABLE);
370     buildDialogForm.append(START_TR);
371     buildDialogForm.append(DEF_FIELD_PROPERTY);
372     buildDialogForm.append(TD_LABEL.replace("${nodetypename}", nodeType.getName())
373                                    .replace(":", "_")
374                                    .replace("${propertyname}", "name"));
375     buildDialogForm.append(TD_COMPONENT.replace("${contentcomponent}", NAME));
376     buildDialogForm.append(END_TR);
377     buildDialogForm.append(buildDialogNodeType(nodeType));
378     buildDialogForm.append(END_TABLE);
379     buildDialogForm.append(END_DIALOG_FORM);
380     return buildDialogForm.toString();
381   }
382 
383   /**
384    * Build string of dialog template base on properties of nodetype
385    * @param nodeType
386    * @return
387    */
388   private String buildDialogNodeType(NodeType nodeType) throws ValueFormatException, RepositoryException {
389     return buildDialogNodeType(nodeType, "/node/");
390   }
391 
392   /**
393    * Build string of dialog template base on properties of nodetype
394    * @param nodeType
395    * @return
396    */
397   private String buildDialogNodeType(NodeType nodeType, String jcrPath) throws ValueFormatException,
398                                                                        RepositoryException {
399     StringBuilder buildDialogNodeType = new StringBuilder();
400     StringBuilder componentField;
401     String propertyNameFormat;
402     String propertyPath;
403     String propertyId;
404     StringBuilder params;
405     StringBuilder validate;
406     StringBuilder defaultValues;
407     Value[] defaultValuesArr;
408     // Render all property defined in NodeType
409     PropertyDefinition[] prodefs = nodeType.getPropertyDefinitions();
410     for (PropertyDefinition prodef : prodefs) {
411       // Dismiss all auto created property
412       String propertyName = prodef.getName();
413       if (prodef.isAutoCreated() || "*".equals(propertyName)
414           || JCR_PRIMARY_TYPE.equals(propertyName) || JCR_MIXIN_TYPES.equals(propertyName))
415         continue;
416       propertyNameFormat = propertyName.replace(":", "_");
417       propertyPath = jcrPath.concat(propertyName);
418       propertyId = propertyPath.replace(":", "_");
419       componentField = new StringBuilder("\n\t\t\t\t\t\tuicomponent.addTextField(\"").append(propertyId)
420                                                                                      .append("\", ");
421       validate = new StringBuilder("validate=");
422       buildDialogNodeType.append(START_TR);
423       buildDialogNodeType.append(TD_LABEL.replace("${nodetypename}", nodeType.getName())
424                                          .replace(":", "_")
425                                          .replace("${propertyname}", propertyNameFormat));
426       params = new StringBuilder("\t\t\t\t\t\t").append(FIELD_PROPERTY)
427                                                 .append(" = [\"jcrPath=")
428                                                 .append(propertyPath)
429                                                 .append("\"");
430       if (prodef.isMultiple()) {
431         params.append(", \"multiValues=true\"");
432       }
433 
434       if (prodef.isMandatory()) {
435         validate.append("empty,");
436       }
437 
438       // Select component field base on required type
439       switch (prodef.getRequiredType()) {
440 
441       case PropertyType.BOOLEAN :
442         params.append(", \"options=true,false\"");
443         componentField = new StringBuilder("\n\t\t\t\t\t\tuicomponent.addSelectBoxField(\"").append(propertyId)
444                                                                                             .append("\", ");
445         break;
446 
447       case PropertyType.STRING :
448         break;
449 
450       case PropertyType.DATE :
451         validate.append("datetime,");
452         params.append(", \"options=displaytime\", \"visible=true\"");
453         componentField = new StringBuilder("\n\t\t\t\t\t\tuicomponent.addCalendarField(\"").append(propertyId)
454                                                                                            .append("\", ");
455         break;
456 
457       case PropertyType.LONG :
458         validate.append("number,");
459         break;
460 
461       case PropertyType.DOUBLE :
462         validate.append("number,");
463         break;
464 
465       case PropertyType.REFERENCE :
466         params.append(", \"reference=true\", \"editable=false\"");
467         break;
468 
469       case PropertyType.BINARY :
470         componentField = new StringBuilder("\n\t\t\t\t\t\tuicomponent.addUploadField(\"").append(propertyId)
471                                                                                          .append("\", ");
472         break;
473 
474       default:
475         break;
476       }
477 
478       defaultValuesArr = prodef.getDefaultValues();
479       if (defaultValuesArr != null) {
480         defaultValues = new StringBuilder("defaultValues=");
481         for(Value value : defaultValuesArr) {
482           defaultValues.append(value.getString()).append(",");
483         }
484         if (defaultValues.indexOf(",") > -1) {
485           params.append(", \"").append(defaultValues.deleteCharAt(defaultValues.length() - 1)).append("\"");
486         }
487       }
488 
489       if (validate.indexOf(",") > -1) {
490         params.append(", \"").append(validate.deleteCharAt(validate.length() - 1)).append("\"");
491       }
492 
493       params.append("];");
494       componentField.append(FIELD_PROPERTY).append(");");
495       buildDialogNodeType.append(TD_COMPONENT.replace("${contentcomponent}",
496                                                       START_JAVA.concat(params.append(componentField)
497                                                                               .append(END_JAVA)
498                                                                               .append("\n")
499                                                                               .toString())));
500       buildDialogNodeType.append(END_TR);
501     }
502 
503     // Render all property for all Child Node if have by call recursive
504     NodeDefinition[] childdefs = nodeType.getChildNodeDefinitions();
505     for (NodeDefinition childdef : childdefs) {
506       if (childdef != null) {
507         for (NodeType requiredNodeType : childdef.getRequiredPrimaryTypes()) {
508           if (childdef.getName().equals("*")) {
509             jcrPath = jcrPath.concat(childdef.getRequiredPrimaryTypes()[0].getName()).concat("/");
510           } else {
511             jcrPath = jcrPath.concat(childdef.getName()).concat("/");
512           }
513           buildDialogNodeType.append(buildDialogNodeType(requiredNodeType, jcrPath));
514         }
515       }
516     }
517     return buildDialogNodeType.toString();
518   }
519 
520   /**
521    * Build string of view template form base on properties of nodetype
522    * @param nodeType
523    * @return
524    */
525   public String buildViewForm(NodeType nodeType) {
526     StringBuilder buildViewForm = new StringBuilder(COMMENT_TEMPLATE);
527     buildViewForm.append(HEADER_VIEW.replace("${NodeType}", nodeType.getName()));
528     buildViewForm.append(JAVA_HEADER_VIEW);
529     buildViewForm.append("\n\t\t<div id=\"$uicomponent.id\">");
530     buildViewForm.append(START_TABLE);
531     buildViewForm.append(START_TR);
532     buildViewForm.append(TD_LABEL.replace("${nodetypename}", nodeType.getName())
533                                  .replace(":", "_")
534                                  .replace("${propertyname}", "name"));
535     buildViewForm.append(TD_COMPONENT.replace("${contentcomponent}\t\t\t\t\t", "${name}"));
536     buildViewForm.append(END_TR);
537     buildViewForm.append(buildViewNodeType(nodeType));
538     buildViewForm.append(END_TABLE);
539     buildViewForm.append("\t\t</div>");
540     return buildViewForm.toString();
541   }
542 
543   /**
544    * Build string of view template base on properties of nodetype
545    * @param nodeType
546    * @return
547    */
548   private String buildViewNodeType(NodeType nodeType) {
549     StringBuilder buildViewNodeType = new StringBuilder();
550     String label = TD_LABEL.replace("${nodetypename}", nodeType.getName().replace(":", "_"));
551     PropertyDefinition[] prodefs = nodeType.getPropertyDefinitions();
552     for (PropertyDefinition prodef : prodefs) {
553       buildViewNodeType.append(START_JAVA).append(CHECK_PROPERTY.replace("${propertyname}", prodef.getName())).append(END_JAVA);
554       buildViewNodeType.append(START_TR);
555       buildViewNodeType.append(label.replace("${propertyname}", prodef.getName().replace(":", "_")));
556       buildViewNodeType.append(START_JAVA);
557       if (prodef.getRequiredType() == PropertyType.BINARY) {
558         if (prodef.isMultiple()) {
559           buildViewNodeType.append("\t\t\t\t\t// Render for multi value;\n");
560           buildViewNodeType.append("\t\t\t\t\tvalues = ")
561                            .append(GET_PROPERTY.replace("${propertyname}", prodef.getName()))
562                            .append(".getValues()")
563                            .append(";\n");
564           buildViewNodeType.append("\t\t\t\t\tvalueDisplay = \"\";\n");
565           buildViewNodeType.append("\t\t\t\t\tfor(value in values) {\n" );
566           buildViewNodeType.append("\t\t\t\t\t\tvalueDisplay += \"BINARY DATA\" + \",\";\n" );
567           buildViewNodeType.append("\t\t\t\t\t}\n" );
568           buildViewNodeType.append("\t\t\t\t\tif (valueDisplay.length() > 0 && valueDisplay.indexOf(\",\") > -1) "
569               + "valueDisplay = valueDisplay.substring(0, valueDisplay.length() - 1);");
570 
571         } else {
572           buildViewNodeType.append("\t\t\t\t\t// Render for single value;\n");
573           buildViewNodeType.append("\t\t\t\t\tvalueDisplay = \"BINARY DATA\"");
574         }
575       } else {
576         if (prodef.isMultiple()) {
577           buildViewNodeType.append("\t\t\t\t\t// Render for multi value;\n");
578           buildViewNodeType.append("\t\t\t\t\tvalues = ")
579                            .append(GET_PROPERTY.replace("${propertyname}", prodef.getName()))
580                            .append(".getValues()")
581                            .append(";\n");
582           buildViewNodeType.append("\t\t\t\t\tvalueDisplay = \"\";\n");
583           buildViewNodeType.append("\t\t\t\t\tfor(value in values) {\n" );
584           buildViewNodeType.append("\t\t\t\t\t\tvalueDisplay += value.getString() + \",\";\n" );
585           buildViewNodeType.append("\t\t\t\t\t}\n" );
586           buildViewNodeType.append("\t\t\t\t\tif (valueDisplay.length() > 0 && valueDisplay.indexOf(\",\") > -1) "
587               + "valueDisplay = valueDisplay.substring(0, valueDisplay.length() - 1);");
588 
589         } else {
590           buildViewNodeType.append("\t\t\t\t\t// Render for single value;\n");
591           buildViewNodeType.append("\t\t\t\t\tvalueDisplay = ")
592                            .append(GET_PROPERTY.replace("${propertyname}", prodef.getName()))
593                            .append(".getString();");
594         }
595       }
596       buildViewNodeType.append(END_JAVA);
597       buildViewNodeType.append(TD_COMPONENT.replace("${contentcomponent}\t\t\t\t\t", "${valueDisplay}"));
598       buildViewNodeType.append(END_TR);
599       buildViewNodeType.append(START_JAVA).append("\t\t\t\t\t}").append(END_JAVA);
600     }
601     return buildViewNodeType.toString();
602   }
603 
604   public Set<String> getAllConfiguredNodeTypes() {
605     return configuredNodeTypes;
606   }
607 }