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.ecm.webui.component.admin.templates;
18  
19  import java.io.ByteArrayInputStream;
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  import javax.jcr.Node;
24  import javax.jcr.Value;
25  import javax.jcr.version.VersionHistory;
26  
27  import org.exoplatform.ecm.jcr.model.VersionNode;
28  import org.exoplatform.ecm.webui.form.UIFormInputSetWithAction;
29  import org.exoplatform.ecm.webui.form.validator.ECMNameValidator;
30  import org.exoplatform.ecm.webui.selector.UISelectable;
31  import org.exoplatform.ecm.webui.utils.Utils;
32  import org.exoplatform.services.cms.templates.TemplateService;
33  import org.exoplatform.services.organization.OrganizationService;
34  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
35  import org.exoplatform.web.application.ApplicationMessage;
36  import org.exoplatform.webui.config.annotation.ComponentConfig;
37  import org.exoplatform.webui.config.annotation.EventConfig;
38  import org.exoplatform.webui.core.UIApplication;
39  import org.exoplatform.webui.core.UIComponent;
40  import org.exoplatform.webui.core.UIPopupWindow;
41  import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
42  import org.exoplatform.webui.core.model.SelectItemOption;
43  import org.exoplatform.webui.event.Event;
44  import org.exoplatform.webui.event.Event.Phase;
45  import org.exoplatform.webui.event.EventListener;
46  import org.exoplatform.webui.form.UIForm;
47  import org.exoplatform.webui.form.UIFormSelectBox;
48  import org.exoplatform.webui.form.UIFormStringInput;
49  import org.exoplatform.webui.form.UIFormTextAreaInput;
50  import org.exoplatform.webui.form.input.UICheckBoxInput;
51  import org.exoplatform.webui.form.validator.MandatoryValidator;
52  
53  /**
54   * Created by The eXo Platform SARL
55   * Author : pham tuan
56   *          phamtuanchip@yahoo.de
57   * Oct 03, 2006
58   * 9:43:23 AM
59   */
60  @ComponentConfig(
61      lifecycle = UIFormLifecycle.class,
62      template = "system:/groovy/webui/form/UIForm.gtmpl",
63      events = {
64        @EventConfig(listeners = UITemplateContent.SaveActionListener.class),
65        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.ChangeActionListener.class),
66        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.CancelActionListener.class),
67        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.RestoreActionListener.class),
68        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.RefreshActionListener.class),
69        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.AddPermissionActionListener.class),
70        @EventConfig(phase=Phase.DECODE, listeners = UITemplateContent.RemovePermissionActionListener.class)
71      }
72  )
73  public class UITemplateContent extends UIForm implements UISelectable {
74  
75    final static public String FIELD_SELECT_VERSION = "selectVersion" ;
76    final static public String FIELD_CONTENT = "content" ;
77    final static public String FIELD_NAME = "name" ;
78    final static public String FIELD_VIEWPERMISSION = "viewPermission" ;
79    final static public String FIELD_ENABLE_VERSION = "enableVersion" ;
80    final static public String[] REG_EXPRESSION = {"[", "]", ":", "&", "%"} ;
81  
82    private boolean isAddNew_ = true ;
83    private String nodeTypeName_ ;
84    private List<String> listVersion_ = new ArrayList<String>() ;
85    private String templateType;
86  
87    final static public String TEMPLATE_PERMISSION = "TemplatePermission" ;
88  
89    public UITemplateContent() throws Exception {
90      List<SelectItemOption<String>> options = new ArrayList<SelectItemOption<String>>() ;
91      UIFormSelectBox versions =
92        new UIFormSelectBox(FIELD_SELECT_VERSION, FIELD_SELECT_VERSION, options) ;
93      versions.setOnChange("Change") ;
94      versions.setRendered(false) ;
95      addUIFormInput(versions) ;
96      addUIFormInput(new UIFormTextAreaInput(FIELD_CONTENT, FIELD_CONTENT, null).addValidator(MandatoryValidator.class)) ;
97      addUIFormInput(new UIFormStringInput(FIELD_NAME, FIELD_NAME, null).addValidator(MandatoryValidator.class).
98                     addValidator(ECMNameValidator.class)) ;
99      UICheckBoxInput isVersion =
100       new UICheckBoxInput(FIELD_ENABLE_VERSION , FIELD_ENABLE_VERSION, null) ;
101     isVersion.setRendered(false) ;
102     addUIFormInput(isVersion) ;
103     UIFormInputSetWithAction uiActionTab = new UIFormInputSetWithAction("UITemplateContent");
104     uiActionTab.addUIFormInput(new UIFormStringInput(FIELD_VIEWPERMISSION,
105                                                      FIELD_VIEWPERMISSION,
106                                                      null).setDisabled(true).addValidator(MandatoryValidator.class));
107     uiActionTab.setActionInfo(FIELD_VIEWPERMISSION, new String[] { "AddPermission",
108         "RemovePermission" });
109     addUIComponentInput(uiActionTab) ;
110   }
111 
112   public void setTemplateType(String templateType) { this.templateType = templateType; }
113 
114   public String getTemplateType() { return templateType; }
115 
116   public void setNodeTypeName (String nodeType) {nodeTypeName_ = nodeType ;}
117 
118   public void update(String templateName) throws Exception {
119     if(templateName != null) {
120       isAddNew_ = false ;
121       TemplateService templateService = getApplicationComponent(TemplateService.class) ;
122       String templateContent = templateService.getTemplate(templateType, nodeTypeName_, templateName) ;
123       Node template =
124         templateService.getTemplateNode(templateType, nodeTypeName_, templateName, WCMCoreUtils.getSystemSessionProvider()) ;
125       getUICheckBoxInput(FIELD_ENABLE_VERSION).setRendered(true) ;
126       String templateRole =
127         templateService.getTemplateRoles(template) ;
128       boolean isVersioned = template.isNodeType(Utils.MIX_VERSIONABLE) ;
129       if(isVersioned) {
130         getUIFormSelectBox(FIELD_SELECT_VERSION).setRendered(true) ;
131         getUIFormSelectBox(FIELD_SELECT_VERSION).setOptions(getVersionValues(template)) ;
132         getUIFormSelectBox(FIELD_SELECT_VERSION).setValue(template.getBaseVersion().getName()) ;
133         getUICheckBoxInput(FIELD_ENABLE_VERSION).setDisabled(true);
134         getUICheckBoxInput(FIELD_ENABLE_VERSION).setChecked(true) ;
135         setActions(new String[]{"Save", "Restore", "Refresh", "Cancel"}) ;
136       } else {
137         getUIFormSelectBox(FIELD_SELECT_VERSION).setRendered(false) ;
138         getUICheckBoxInput(FIELD_ENABLE_VERSION).setDisabled(false);
139         getUICheckBoxInput(FIELD_ENABLE_VERSION).setChecked(false) ;
140         setActions( new String[]{"Save", "Refresh", "Cancel"}) ;
141       }
142       getUIFormTextAreaInput(FIELD_CONTENT).setValue(templateContent) ;
143       getUIStringInput(FIELD_NAME).setValue(template.getName()) ;
144       getUIStringInput(FIELD_NAME).setDisabled(true);
145       getUIStringInput(FIELD_VIEWPERMISSION).setValue(templateRole) ;
146       return ;
147     }
148     isAddNew_ = true ;
149     getUIFormSelectBox(FIELD_SELECT_VERSION).setRendered(false) ;
150     getUICheckBoxInput(FIELD_ENABLE_VERSION).setRendered(false) ;
151     getUIStringInput(FIELD_NAME).setDisabled(false);
152     setActions( new String[]{"Save", "Refresh", "Cancel"}) ;
153   }
154 
155 
156 
157   private void refresh() throws Exception {
158     UIViewTemplate uiViewTemplate = getAncestorOfType(UIViewTemplate.class) ;
159     uiViewTemplate.refresh() ;
160     UIComponent parent = getParent() ;
161     if(parent instanceof UIDialogTab) {
162       uiViewTemplate.setSelectedTab(UIDialogTab.class.getSimpleName()) ;
163     } else if(parent instanceof UIViewTab) {
164       uiViewTemplate.setSelectedTab(UIViewTab.class.getSimpleName()) ;
165     } else if(parent instanceof UISkinTab) {
166       uiViewTemplate.setSelectedTab(UISkinTab.class.getSimpleName()) ;
167     }
168     update(null) ;
169     reset() ;
170   }
171 
172   private VersionNode getRootVersion(Node node) throws Exception{
173     VersionHistory vH = node.getVersionHistory() ;
174     if(vH != null) return new VersionNode(vH.getRootVersion(), node.getSession()) ;
175     return null ;
176   }
177   private List<String> getNodeVersions(List<VersionNode> children) throws Exception {
178     List<VersionNode> child = new ArrayList<VersionNode>() ;
179     for(VersionNode version : children) {
180       listVersion_.add(version.getName()) ;
181       child = version.getChildren() ;
182       if(!child.isEmpty()) getNodeVersions(child) ;
183     }
184     return listVersion_ ;
185   }
186 
187   private List<SelectItemOption<String>> getVersionValues(Node node) throws Exception {
188     List<SelectItemOption<String>> options = new ArrayList<SelectItemOption<String>>() ;
189     List<VersionNode> children = getRootVersion(node).getChildren() ;
190     listVersion_.clear() ;
191     List<String> versionList = getNodeVersions(children) ;
192     for(int i = 0; i < versionList.size(); i++) {
193       for(int j = i + 1; j < versionList.size(); j ++) {
194         if( Integer.parseInt(versionList.get(j)) < Integer.parseInt(versionList.get(i))) {
195           String temp = versionList.get(i) ;
196           versionList.set(i, versionList.get(j)) ;
197           versionList.set(j, temp) ;
198         }
199       }
200       options.add(new SelectItemOption<String>(versionList.get(i), versionList.get(i))) ;
201     }
202     return options ;
203   }
204 
205   @SuppressWarnings("unused")
206   public void doSelect(String selectField, Object value) {
207     String viewPermission = getUIStringInput(FIELD_VIEWPERMISSION).getValue();
208     if (viewPermission == null) viewPermission = "";
209     if ((viewPermission != null) && (viewPermission.length() == 0)) {
210       viewPermission = value.toString();
211     } else {
212       StringBuffer sb = new StringBuffer();
213       sb.append(viewPermission).append(",").append(value.toString());
214       viewPermission = sb.toString();
215     }
216     getUIStringInput(FIELD_VIEWPERMISSION).setValue(viewPermission) ;    
217   }
218 
219   static public class RestoreActionListener extends EventListener<UITemplateContent> {
220     public void execute(Event<UITemplateContent> event) throws Exception {
221       UITemplateContent uiForm = event.getSource() ;
222       UITemplatesManager uiManager = uiForm.getAncestorOfType(UITemplatesManager.class) ;
223       String name = uiForm.getUIStringInput(FIELD_NAME).getValue() ;
224       TemplateService templateService = uiForm.getApplicationComponent(TemplateService.class) ;
225       Node node = templateService.getTemplateNode(uiForm.getTemplateType(),  uiForm.nodeTypeName_,
226           name, WCMCoreUtils.getSystemSessionProvider()) ;
227       String vesion = uiForm.getUIFormSelectBox(FIELD_SELECT_VERSION).getValue() ;
228       String baseVesion = node.getBaseVersion().getName() ;
229       UIApplication app = uiForm.getAncestorOfType(UIApplication.class) ;
230       if(vesion.equals(baseVesion)) return ;
231       node.checkout() ;
232       node.restore(vesion, true) ;
233       Object[] args = {uiForm.getUIStringInput(FIELD_SELECT_VERSION).getValue()} ;
234       app.addMessage(new ApplicationMessage("UITemplateContent.msg.version-restored", args)) ;
235       uiForm.refresh() ;
236       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
237 
238     }
239   }
240 
241   static public class SaveActionListener extends EventListener<UITemplateContent> {
242     public void execute(Event<UITemplateContent> event) throws Exception {
243       UITemplateContent uiForm = event.getSource() ;
244       UITemplatesManager uiManager = uiForm.getAncestorOfType(UITemplatesManager.class) ;
245       UIApplication uiApp = uiForm.getAncestorOfType(UIApplication.class) ;
246       String name = uiForm.getUIStringInput(FIELD_NAME).getValue() ;
247       if(name == null || name.trim().length() == 0) {
248         Object[] args = { FIELD_NAME } ;
249         uiApp.addMessage(new ApplicationMessage("ECMNameValidator.msg.empty-input", args,
250                                                 ApplicationMessage.WARNING)) ;
251 
252         return ;
253       }
254       if(!Utils.isNameValid(name, UITemplateContent.REG_EXPRESSION)){
255         uiApp.addMessage(new ApplicationMessage("UITemplateContent.msg.name-invalid", null,
256                                                 ApplicationMessage.WARNING)) ;
257 
258         return ;
259       }
260       String content = uiForm.getUIFormTextAreaInput(FIELD_CONTENT).getValue() ;
261       if(content == null) content = "" ;
262       UIFormInputSetWithAction permField = uiForm.getChildById("UITemplateContent") ;
263       String role = permField.getUIStringInput(FIELD_VIEWPERMISSION).getValue() ;
264       
265       
266         
267       if ((role == null) || (role.trim().length() == 0)) {
268         uiApp.addMessage(new ApplicationMessage("UITemplateForm.msg.role-require",
269                                                 null,
270                                                 ApplicationMessage.WARNING));        
271         return;
272       }
273       UIViewTemplate uiViewTemplate = uiForm.getAncestorOfType(UIViewTemplate.class) ;
274       if(uiForm.getId().equals(UIDialogTab.DIALOG_FORM_NAME)) {
275         UIDialogTab uiDialogTab = uiViewTemplate.getChild(UIDialogTab.class) ;
276         if(uiDialogTab.getListDialog().contains(name) && uiForm.isAddNew_) {
277           Object[] args = { name } ;
278           uiApp.addMessage(new ApplicationMessage("UITemplateContent.msg.name-exist", args,
279                                                   ApplicationMessage.WARNING)) ;
280 
281           return ;
282         }
283       } else if(uiForm.getId().equals(UIViewTab.VIEW_FORM_NAME)) {
284         UIViewTab uiViewTab = uiViewTemplate.getChild(UIViewTab.class) ;
285         if(uiViewTab.getListView().contains(name) && uiForm.isAddNew_) {
286           Object[] args = { name } ;
287           uiApp.addMessage(new ApplicationMessage("UITemplateContent.msg.name-exist", args,
288                                                   ApplicationMessage.WARNING)) ;
289 
290           return ;
291         }
292       } else if(uiForm.getId().equals(UISkinTab.SKIN_FORM_NAME)) {
293         UISkinTab uiSkinTab = uiViewTemplate.getChild(UISkinTab.class) ;
294         if(uiSkinTab.getListSkin().contains(name) && uiForm.isAddNew_) {
295           Object[] args = { name } ;
296           uiApp.addMessage(new ApplicationMessage("UITemplateContent.msg.name-exist", args,
297                                                   ApplicationMessage.WARNING)) ;
298 
299           return ;
300         }
301       }
302       TemplateService templateService = uiForm.getApplicationComponent(TemplateService.class) ;
303       boolean isEnableVersioning =
304         uiForm.getUICheckBoxInput(FIELD_ENABLE_VERSION).isChecked() ;
305       if(uiForm.isAddNew_){
306         templateService.addTemplate(uiForm.getTemplateType(), uiForm.nodeTypeName_, null, false, name, new String[] {role},
307             new ByteArrayInputStream(content.getBytes("utf-8")));
308       } else {
309         Node node =
310           templateService.getTemplateNode(uiForm.getTemplateType(), uiForm.nodeTypeName_, name,
311               WCMCoreUtils.getSystemSessionProvider()) ;
312         if(isEnableVersioning && !node.isNodeType(Utils.MIX_VERSIONABLE)) {
313           node.addMixin(Utils.MIX_VERSIONABLE) ;
314         }
315         if (areValidPermissions(role, uiForm)) {
316           templateService.addTemplate(uiForm.getTemplateType(),
317                                       uiForm.nodeTypeName_,
318                                       null,
319                                       false,
320                                       name,
321                                       new String[] { role },
322                                       new ByteArrayInputStream(content.getBytes("utf-8")));
323         } else {
324           return;
325         }
326         node.save() ;
327         if(isEnableVersioning) {
328           node.checkin() ;
329           node.checkout();
330         }
331       }
332       uiForm.refresh() ;
333       uiForm.isAddNew_ = true ;
334       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
335     }
336   }
337 
338   static public class ChangeActionListener extends EventListener<UITemplateContent> {
339     public void execute(Event<UITemplateContent> event) throws Exception {
340       UITemplateContent uiForm = event.getSource() ;
341       UITemplatesManager uiManager = uiForm.getAncestorOfType(UITemplatesManager.class) ;
342       String name = uiForm.getUIStringInput(FIELD_NAME).getValue() ;
343       TemplateService templateService = uiForm.getApplicationComponent(TemplateService.class) ;
344       Node node = templateService.getTemplateNode(uiForm.getTemplateType(), uiForm.nodeTypeName_,
345           name, WCMCoreUtils.getSystemSessionProvider()) ;
346       String version = uiForm.getUIFormSelectBox(FIELD_SELECT_VERSION).getValue() ;
347       String path = node.getVersionHistory().getVersion(version).getPath() ;
348       VersionNode versionNode = uiForm.getRootVersion(node).findVersionNode(path) ;
349       Node frozenNode = versionNode.getNode(Utils.JCR_FROZEN) ;
350       String content = templateService.getTemplate(frozenNode);
351       uiForm.getUIFormTextAreaInput(FIELD_CONTENT).setValue(content) ;
352       if (frozenNode.hasProperty(Utils.EXO_ROLES)) {
353         StringBuilder rule = new StringBuilder() ;
354         Value[] rules = frozenNode.getProperty(Utils.EXO_ROLES).getValues() ;
355         for(int i = 0; i < rules.length; i++) {
356           rule.append(rules[i].getString());
357         }
358         uiForm.getUIStringInput(FIELD_VIEWPERMISSION).setValue(rule.toString());
359       }
360       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
361     }
362   }
363 
364   static public class AddPermissionActionListener extends EventListener<UITemplateContent> {
365     public void execute(Event<UITemplateContent> event) throws Exception {
366       UITemplateContent uiTempContent = event.getSource() ;      
367       UITemplatesManager uiManager = uiTempContent.getAncestorOfType(UITemplatesManager.class) ;
368       
369       UIViewTemplate uiViewTemp = uiTempContent.getAncestorOfType(UIViewTemplate.class) ; 
370       String membership = uiTempContent.getUIStringInput(FIELD_VIEWPERMISSION).getValue() ;
371       uiManager.initPopupPermission(uiTempContent.getId(), membership) ;
372       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
373       if(uiTempContent.getId().equals(UIDialogTab.DIALOG_FORM_NAME)) {
374         uiViewTemp.setSelectedTab(UIDialogTab.class.getSimpleName()) ;
375       } else if(uiTempContent.getId().equals(UIViewTab.VIEW_FORM_NAME)) {
376         uiViewTemp.setSelectedTab(UIViewTab.class.getSimpleName()) ;
377       } else if(uiTempContent.getId().equals(UISkinTab.SKIN_FORM_NAME)) {
378         uiViewTemp.setSelectedTab(UISkinTab.class.getSimpleName()) ;
379       }
380       UIPopupWindow uiPopup = uiManager.getChildById(UITemplateContent.TEMPLATE_PERMISSION);
381       event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup) ;
382     }
383   }
384 
385   static public class RemovePermissionActionListener extends EventListener<UITemplateContent> {
386     public void execute(Event<UITemplateContent> event) throws Exception {
387       UITemplateContent uiTemplateContent = event.getSource();
388       uiTemplateContent.getUIStringInput(FIELD_VIEWPERMISSION).setValue(null);
389       event.getRequestContext().addUIComponentToUpdateByAjax(uiTemplateContent);
390     }
391   }
392 
393   static public class RefreshActionListener extends EventListener<UITemplateContent> {
394     public void execute(Event<UITemplateContent> event) throws Exception {
395       UITemplateContent uiForm = event.getSource() ;
396       UITemplatesManager uiManager = uiForm.getAncestorOfType(UITemplatesManager.class) ;
397       if(!uiForm.isAddNew_) {
398         uiForm.update(uiForm.getUIStringInput(UITemplateContent.FIELD_NAME).getValue()) ;
399         return ;
400       }
401       uiForm.update(null) ;
402       uiForm.reset() ;
403       uiForm.refresh() ;
404       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
405     }
406   }
407 
408   static public class CancelActionListener extends EventListener<UITemplateContent> {
409     public void execute(Event<UITemplateContent> event) throws Exception {
410       UITemplateContent uiTemplateContent = event.getSource() ;      
411       UITemplatesManager uiManager = uiTemplateContent.getAncestorOfType(UITemplatesManager.class) ;
412       uiManager.removeChildById(UIDialogTab.DIALOG_FORM_NAME + TEMPLATE_PERMISSION) ;
413       uiManager.removeChildById(UIViewTab.VIEW_FORM_NAME + TEMPLATE_PERMISSION) ;
414       uiManager.removeChildById(UISkinTab.SKIN_FORM_NAME + TEMPLATE_PERMISSION) ;
415       uiTemplateContent.reset() ;
416       UIPopupWindow uiPopupWindow = uiManager.getChildById(UITemplatesManager.POPUP_TEMPLATE_ID) ;
417       uiPopupWindow.setShow(false) ;
418       event.getRequestContext().addUIComponentToUpdateByAjax(uiManager) ;
419     }
420   }
421 
422   private static boolean areValidPermissions(String permissions,
423                                              UITemplateContent uiTemplateContent) throws Exception {
424     Boolean areValidPermissions = false;
425     UIApplication uiApp = uiTemplateContent.getAncestorOfType(UIApplication.class);
426     if (permissions == null || permissions.trim().length() == 0) {
427       uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-null",
428                                               null,
429                                               ApplicationMessage.WARNING));
430 
431       areValidPermissions = false;
432       return areValidPermissions;
433     }
434 
435     OrganizationService oservice = WCMCoreUtils.getService(OrganizationService.class);
436     String[] arrPermissions = permissions.split(",");
437     for (String itemPermission : arrPermissions) {
438       if (itemPermission.length() == 0) {
439         uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
440                                                 null,
441                                                 ApplicationMessage.WARNING));
442 
443         areValidPermissions = false;
444         return areValidPermissions;
445       }
446       if (itemPermission.contains(":")) {
447         String[] permission = itemPermission.split(":");
448         if ((permission[0] == null) || (permission[0].length() == 0)) {
449           uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
450                                                   null,
451                                                   ApplicationMessage.WARNING));
452 
453           areValidPermissions = false;
454           return areValidPermissions;
455         } else if (!permission[0].equals("*") && (oservice.getMembershipTypeHandler().findMembershipType(permission[0]) == null)) {
456           uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
457                                                   null,
458                                                   ApplicationMessage.WARNING));
459 
460           areValidPermissions = false;
461           return areValidPermissions;
462         }
463         if ((permission[1] == null) || (permission[1].length() == 0)) {
464           uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
465                                                   null,
466                                                   ApplicationMessage.WARNING));
467 
468           areValidPermissions = false;
469           return areValidPermissions;
470         } else if (oservice.getGroupHandler().findGroupById(permission[1]) == null) {
471           uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
472                                                   null,
473                                                   ApplicationMessage.WARNING));
474 
475           areValidPermissions = false;
476           return areValidPermissions;
477         }
478       } else {
479         if (!itemPermission.equals("*")) {
480           uiApp.addMessage(new ApplicationMessage("UIDriveForm.msg.permission-path-invalid",
481                                                   null,
482                                                   ApplicationMessage.WARNING));
483 
484           areValidPermissions = false;
485           return areValidPermissions;
486         }
487       }
488     }
489     areValidPermissions = true;
490     return areValidPermissions;
491   }
492 }