diff --git a/config/alfresco/web-client-application-context.xml b/config/alfresco/web-client-application-context.xml index 5bfe6e9791..59abafcb03 100644 --- a/config/alfresco/web-client-application-context.xml +++ b/config/alfresco/web-client-application-context.xml @@ -76,52 +76,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - alfresco:/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.content_forms.childname}/${form.name}/cm:strings - alfresco:/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.content_forms.childname}/cm:strings - - classpath:alfresco/messages/webclient - - - - ${xforms.formatCaption} - - diff --git a/config/alfresco/web-client-config-actions.xml b/config/alfresco/web-client-config-actions.xml index a59a2bc672..1543fcaf7e 100644 --- a/config/alfresco/web-client-config-actions.xml +++ b/config/alfresco/web-client-config-actions.xml @@ -486,56 +486,6 @@ wizard:createContent - - - - Write,AddChildren - - org.alfresco.web.action.evaluator.EditFormEvaluator - edit_form - /images/icons/edit_form.gif - wizard:editForm - #{BrowseBean.setupSpaceAction} - - #{actionContext.id} - - - - - - org.alfresco.web.action.evaluator.CreateWebFormEvaluator - create_web_form - /images/icons/create_form.gif - wizard:createWebForm - - - - - - Write,AddChildren - - org.alfresco.web.action.evaluator.EditWebFormEvaluator - edit_web_form - /images/icons/edit_form.gif - wizard:editWebForm - #{BrowseBean.setupSpaceAction} - - #{actionContext.id} - - - - - - org.alfresco.web.action.evaluator.RegenerateRenditionsEvaluator - regenerate_renditions - /images/icons/regenerate_renditions.gif - wizard:regenerateRenditions - #{BrowseBean.setupSpaceAction} - - #{actionContext.id} - - - @@ -555,14 +505,6 @@ /images/icons/create_space.gif wizard:createSpace - - - - org.alfresco.web.action.evaluator.CreateWebProjectEvaluator - create_website - /images/icons/create_website.gif - wizard:createWebsite - @@ -1042,8 +984,6 @@ - - @@ -1058,7 +998,6 @@ - diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index f0c7f88d04..2aabda2ac0 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -140,122 +140,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -264,54 +156,6 @@ icon="/images/icons/import_large.gif" title-id="import" description-id="import_info" /> - - - - - - - - - - - - - - - - - - - - - - - - @@ -320,48 +164,6 @@ managed-bean="ReleaseTestServerDialog" icon="/images/icons/release_server_large.gif" title-id="release_server_title" description-id="release_server_info" /> - - - - - - - - - - - - - - - - - - - - @@ -564,20 +366,10 @@ icon="/images/icons/details_large.gif" title-id="details_of" description-id="documentdetails_description" show-ok-button="false" error-message-id="empty_message" /> - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - diff --git a/config/alfresco/web-client-config-properties.xml b/config/alfresco/web-client-config-properties.xml index 1ee3d11e8d..23064c0f43 100644 --- a/config/alfresco/web-client-config-properties.xml +++ b/config/alfresco/web-client-config-properties.xml @@ -38,47 +38,6 @@ ignore-if-missing="false" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -518,163 +477,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/alfresco/web-client-config-wizards.xml b/config/alfresco/web-client-config-wizards.xml index 29751f5893..c6f01a7551 100644 --- a/config/alfresco/web-client-config-wizards.xml +++ b/config/alfresco/web-client-config-wizards.xml @@ -6,120 +6,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -303,10 +302,6 @@ jsp="/jsp/dashboards/dashlets/myspaces-webscript.jsp" /> - - @@ -449,7 +444,6 @@ - diff --git a/pom.xml b/pom.xml index c0470d3949..6cc2302d47 100644 --- a/pom.xml +++ b/pom.xml @@ -80,11 +80,6 @@ commons-logging commons-logging - - net.sf.chiba - chiba - 1.3.0-alfresco-patched - org.apache.james apache-mime4j-dom diff --git a/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java deleted file mode 100644 index 4e77c6af72..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/CreateFormEvaluator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; - -/** - * UI Action Evaluator - Create Form in the Forms DataDictionary folder - * - * @author Kevin Roast - */ -public class CreateFormEvaluator extends BaseActionEvaluator -{ - private static final long serialVersionUID = 4475319627518524432L; - - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(Node node) - { - final FacesContext fc = FacesContext.getCurrentInstance(); - final ServiceRegistry services = Repository.getServiceRegistry(fc); - final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // get the path to the current name - compare last element with the Forms folder name - final Path path = navigator.getCurrentNode().getNodePath(); - final Path.Element element = path.get(path.size() - 1); - final String endPath = element.getPrefixedString(services.getNamespaceService()); - - // check we have the permission to create nodes in that Forma folder - return (Application.getContentFormsFolderName(fc).equals(endPath) && - navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN)); - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/CreateProjectEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateProjectEvaluator.java deleted file mode 100644 index 9274d9940b..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/CreateProjectEvaluator.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; - -/** - * UI Action Evaluator - Create Project Collaboration Space in the Projects folder - * - * @author Kevin Roast - */ -public class CreateProjectEvaluator extends BaseActionEvaluator -{ - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(Node node) - { - FacesContext fc = FacesContext.getCurrentInstance(); - ServiceRegistry services = Repository.getServiceRegistry(fc); - NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // get the path to the current name - compare last element with the Website folder assoc name - Path path = navigator.getCurrentNode().getNodePath(); - Path.Element element = path.get(path.size() - 1); - String endPath = element.getPrefixedString(services.getNamespaceService()); - - if (Application.getProjectsFolderName(fc).equals(endPath)) - { - // check we have the permission to create nodes in the Projects folder - return navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN); - } - return false; - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/CreateWebFormEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateWebFormEvaluator.java deleted file mode 100644 index 1d6165a7c0..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/CreateWebFormEvaluator.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; - -/** - * UI Action Evaluator - Create Web Forms in the Web Forms DataDictionary folder - * - */ -public class CreateWebFormEvaluator extends BaseActionEvaluator -{ - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(Node node) - { - final FacesContext fc = FacesContext.getCurrentInstance(); - final ServiceRegistry services = Repository.getServiceRegistry(fc); - final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // get the path to the current name - compare last element with the Web Forms folder name - final Path path = navigator.getCurrentNode().getNodePath(); - final Path.Element element = path.get(path.size() - 1); - final String endPath = element.getPrefixedString(services.getNamespaceService()); - - // check we have the permission to create nodes in that Web Forms folder - return (Application.getWebContentFormsFolderName(fc).equals(endPath) && - navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN)); - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/CreateWebProjectEvaluator.java b/source/java/org/alfresco/web/action/evaluator/CreateWebProjectEvaluator.java deleted file mode 100644 index 7d97ccb680..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/CreateWebProjectEvaluator.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.Path; -import org.alfresco.service.cmr.security.PermissionService; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.bean.repository.Repository; - -/** - * UI Action Evaluator - Create Web Project in the Websites folder - * - * @author Kevin Roast - */ -public class CreateWebProjectEvaluator extends BaseActionEvaluator -{ - private static final long serialVersionUID = 9061864145360361349L; - - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(Node node) - { - FacesContext fc = FacesContext.getCurrentInstance(); - ServiceRegistry services = Repository.getServiceRegistry(fc); - NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // get the path to the current name - compare last element with the Website folder assoc name - Path path = navigator.getCurrentNode().getNodePath(); - Path.Element element = path.get(path.size() - 1); - String endPath = element.getPrefixedString(services.getNamespaceService()); - - if (Application.getWebsitesFolderName(fc).equals(endPath)) - { - // check we have the permission to create nodes in that Website folder - return navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN); - } - return false; - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/EditFormEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditFormEvaluator.java deleted file mode 100644 index 84d320ec3a..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/EditFormEvaluator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.action.evaluator; - -import org.alfresco.web.bean.repository.Node; - -/** - * UI Action Evaluator - Edit Form in the Forms DataDictionary folder - * - * @author Ariel Backenroth - */ -public class EditFormEvaluator extends BaseActionEvaluator -{ - private static final long serialVersionUID = -509493291648778510L; - - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(final Node node) - { -// // WCM -// final FacesContext fc = FacesContext.getCurrentInstance(); -// final ServiceRegistry services = Repository.getServiceRegistry(fc); -// final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); -// -// // get the path to the current name - compare last element with the Forms folder name -// final Path path = navigator.getCurrentNode().getNodePath(); -// final Path.Element element = path.get(path.size() - 1); -// final String endPath = element.getPrefixedString(services.getNamespaceService()); -// -// return (Application.getContentFormsFolderName(fc).equals(endPath) && -// node.hasAspect(WCMAppModel.ASPECT_FORM)); - return false; - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/EditWebFormEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditWebFormEvaluator.java deleted file mode 100644 index 03214bd399..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/EditWebFormEvaluator.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.action.evaluator; - -import org.alfresco.web.bean.repository.Node; - -/** - * UI Action Evaluator - Edit Web Form in the Web Forms DataDictionary folder - * - * @author Ariel Backenroth - */ -public class EditWebFormEvaluator extends BaseActionEvaluator -{ - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(final Node node) - { -// // WCM -// final FacesContext fc = FacesContext.getCurrentInstance(); -// final ServiceRegistry services = Repository.getServiceRegistry(fc); -// final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); -// -// // get the path to the current name - compare last element with the Web Forms folder name -// final Path path = navigator.getCurrentNode().getNodePath(); -// final Path.Element element = path.get(path.size() - 1); -// final String endPath = element.getPrefixedString(services.getNamespaceService()); -// -// return (Application.getWebContentFormsFolderName(fc).equals(endPath) && -// node.hasAspect(WCMAppModel.ASPECT_FORM)); - return false; - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/ManagePermissionIsMainStoreEvaluator.java b/source/java/org/alfresco/web/action/evaluator/ManagePermissionIsMainStoreEvaluator.java deleted file mode 100644 index e7adc2d883..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/ManagePermissionIsMainStoreEvaluator.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -package org.alfresco.web.action.evaluator; - -import org.alfresco.web.bean.repository.Node; - -/** - * UI Action Evaluator - Evaluates whether the change and remove permissions action should be visible. - * - * @author Sergey Gavrusev - */ -public class ManagePermissionIsMainStoreEvaluator extends BaseActionEvaluator -{ - - private static final long serialVersionUID = 4221869509273412546L; - - /* - * (non-Javadoc) - * - * @see org.alfresco.web.action.evaluator.BaseActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(final Node node) - { - boolean result = false; -// // WCM -// final String path = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef()).getSecond(); -// if (!AVMUtil.isMainStore(AVMUtil.getStoreName(path))) -// { -// result = true; -// } - return result; - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.web.action.evaluator.BaseActionEvaluator#evaluate(java.lang.Object) - */ - @Override - public boolean evaluate(final Object obj) - { -// // WCM -// if (obj instanceof ManagePermissionsDialog) -// { -// return ((ManagePermissionsDialog) obj).isRendered(); -// } - return false; - } - -} diff --git a/source/java/org/alfresco/web/action/evaluator/RegenerateRenditionsEvaluator.java b/source/java/org/alfresco/web/action/evaluator/RegenerateRenditionsEvaluator.java deleted file mode 100644 index 426c431c10..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/RegenerateRenditionsEvaluator.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import org.alfresco.web.bean.repository.Node; - -/** - * UI Action Evaluator for Regenerate Renditions in the Web Forms DataDictionary folder - * - * @author Ariel Backenroth - */ -public class RegenerateRenditionsEvaluator extends BaseActionEvaluator -{ - private static final long serialVersionUID = -3479861093052578775L; - - /** - * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - public boolean evaluate(final Node node) - { - // Sparta: disable/remove WCM/AVM - return false; - - /* - // is the authenticated user permitted to execute the regenerate renditions action - // against at least one web project - boolean isUserAllowed = false; - - final FacesContext fc = FacesContext.getCurrentInstance(); - final ServiceRegistry services = Repository.getServiceRegistry(fc); - final PermissionService permissionService = services.getPermissionService(); - final WebProjectService webProjectService = services.getWebProjectService(); - final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // before looking for web projects ensure the root folder is present i.e. WCM is enabled! - if (!webProjectService.hasWebProjectsRoot()) - { - return false; - } - - // check that the authenticated user has CONTENT MANAGER permissions for at least one web project - // this will ensure that the action appears only if the user is able to regenerate renditions - // for at least one web project - List wpInfos = webProjectService.listWebProjects(); - for (WebProjectInfo wpInfo : wpInfos) - { - if(permissionService.hasPermission(wpInfo.getNodeRef(), PermissionService.WCM_CONTENT_MANAGER) == AccessStatus.ALLOWED) - { - isUserAllowed = true; - break; - } - } - - // TODO improve how we determine whether the form supports the ability to regenerate renditions or not - - // get the path to the current name - compare each path element with the Web Forms folder name - final Path path = navigator.getCurrentNode().getNodePath(); - - boolean isWebFormsPath = false; - Iterator itr = path.iterator(); - while (itr.hasNext()) - { - Path.Element element = (Path.Element)itr.next(); - String pathElement = element.getPrefixedString(services.getNamespaceService()); - if (Application.getWebContentFormsFolderName(fc).equals(pathElement)) - { - isWebFormsPath = true; - break; - } - } - - return (node.hasAspect(WCMAppModel.ASPECT_RENDERING_ENGINE_TEMPLATE) || isWebFormsPath) && isUserAllowed; - */ - } -} diff --git a/source/java/org/alfresco/web/action/evaluator/ViewPermissionEvaluator.java b/source/java/org/alfresco/web/action/evaluator/ViewPermissionEvaluator.java deleted file mode 100644 index 4ffdcd9f59..0000000000 --- a/source/java/org/alfresco/web/action/evaluator/ViewPermissionEvaluator.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.action.evaluator; - -import org.alfresco.web.bean.repository.Node; - -/** - * UI Action Evaluator - Evaluates whether the view permissions action should be visible. - * - * @author Sergey Gavrusev - */ -public class ViewPermissionEvaluator extends BaseActionEvaluator -{ - - private static final long serialVersionUID = 1340473144312214960L; - - /* - * (non-Javadoc) - * - * @see org.alfresco.web.action.evaluator.BaseActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) - */ - @Override - public boolean evaluate(final Node node) - { - boolean result = true; -// // WCM -// final String path = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef()).getSecond(); -// if (!AVMUtil.isMainStore(AVMUtil.getStoreName(path))) -// { -// result = false; -// } - return result; - - } - - /* - * (non-Javadoc) - * - * @see org.alfresco.web.action.evaluator.BaseActionEvaluator#evaluate(java.lang.Object) - */ - @Override - public boolean evaluate(Object obj) - { -// // WCM -// if (obj instanceof ManagePermissionsDialog) -// { -// return !((ManagePermissionsDialog) obj).isRendered(); -// } - return false; - } - -} diff --git a/source/java/org/alfresco/web/app/Application.java b/source/java/org/alfresco/web/app/Application.java index aa6129d3f7..6bdda2eecf 100644 --- a/source/java/org/alfresco/web/app/Application.java +++ b/source/java/org/alfresco/web/app/Application.java @@ -28,7 +28,6 @@ import java.util.ResourceBundle; import javax.faces.context.FacesContext; import javax.servlet.ServletContext; import javax.servlet.ServletException; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -641,70 +640,6 @@ public class Application return getGuestHomeFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); } - /** - * @return the Websites folder name - */ - public static String getWebsitesFolderName(ServletContext context) - { - return getWebsitesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the Websites folder name - */ - public static String getWebsitesFolderName(FacesContext context) - { - return getWebsitesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the WCM Content Forms folder name - */ - public static String getWebContentFormsFolderName(ServletContext context) - { - return getWebContentFormsFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the WCM Content Forms folder name - */ - public static String getWebContentFormsFolderName(FacesContext context) - { - return getWebContentFormsFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the Content Forms folder name - */ - public static String getContentFormsFolderName(ServletContext context) - { - return getContentFormsFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the Content Forms folder name - */ - public static String getContentFormsFolderName(FacesContext context) - { - return getContentFormsFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); - } - - /** -<<<<<<< .working - * @return the Projects folder name - */ - public static String getProjectsFolderName(ServletContext context) - { - return getProjectsFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); - } - - /** - * @return the Projects folder name - */ - public static String getProjectsFolderName(FacesContext context) - { - return getProjectsFolderName(FacesContextUtils.getRequiredWebApplicationContext(context)); - } /** * Set the language locale for the current user context @@ -1259,78 +1194,6 @@ public class Application return guestHomeFolderName; } - /** - * Returns the Websites folder name - * - * @param context The Spring context - * @return The Websites folder name - */ - private static String getWebsitesFolderName(WebApplicationContext context) - { - if (websitesFolderName == null) - { - ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP); - Properties configuration = bootstrap.getConfiguration(); - websitesFolderName = configuration.getProperty("spaces.wcm.childname"); - } - - return websitesFolderName; - } - - /** - * Returns the Projects folder name - * - * @param context The Spring context - * @return The Projects folder name - */ - private static String getProjectsFolderName(WebApplicationContext context) - { - if (projectsFolderName == null) - { - ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP); - Properties configuration = bootstrap.getConfiguration(); - projectsFolderName = configuration.getProperty("spaces.projects.childname"); - } - - return projectsFolderName; - } - - /** - * Returns the WCM Content Forms folder name - * - * @param context The Spring context - * @return The WCM Content Forms folder name - */ - private static String getWebContentFormsFolderName(WebApplicationContext context) - { - if (webContentFormsFolderName == null) - { - ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP); - Properties configuration = bootstrap.getConfiguration(); - webContentFormsFolderName = configuration.getProperty("spaces.wcm_content_forms.childname"); - } - - return webContentFormsFolderName; - } - - /** - * Returns the Content Forms folder name - * - * @param context The Spring context - * @return The WCM Content Forms folder name - */ - private static String getContentFormsFolderName(WebApplicationContext context) - { - if (contentFormsFolderName == null) - { - ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP); - Properties configuration = bootstrap.getConfiguration(); - contentFormsFolderName = configuration.getProperty("spaces.content_forms.childname"); - } - - return contentFormsFolderName; - } - /** * Retrieves the configured error page for the application * diff --git a/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java b/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java deleted file mode 100644 index 344cf8bbb8..0000000000 --- a/source/java/org/alfresco/web/app/servlet/command/EditWebContentCommand.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.app.servlet.command; - -import java.util.Map; - -import javax.faces.context.FacesContext; -import javax.servlet.ServletContext; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.web.app.servlet.BaseServlet; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.springframework.extensions.surf.util.ParameterCheck; - -/** - * Command to execute the Edit Web Content (xforms) wizard via url. - *

- * Arguments: webproject = the GUID of the webproject to create the content in - * sandbox = the sandbox to create the content in - * path = path to the form instance data for edit - * - * @author Kevin Roast - */ -public class EditWebContentCommand extends BaseUIActionCommand -{ - public static final String PROP_WEBPROJECTID = "webproject"; - public static final String PROP_SANDBOX = "sandbox"; - public static final String PROP_PATH = "path"; - - private static final String[] PROPERTIES = new String[] { - PROP_SERVLETCONTEXT, PROP_REQUEST, PROP_RESPONSE, PROP_WEBPROJECTID, PROP_SANDBOX, PROP_PATH}; - - /** - * @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map) - */ - public Object execute(ServiceRegistry serviceRegistry, Map properties) - { - ServletContext sc = (ServletContext)properties.get(PROP_SERVLETCONTEXT); - ServletRequest req = (ServletRequest)properties.get(PROP_REQUEST); - ServletResponse res = (ServletResponse)properties.get(PROP_RESPONSE); - FacesContext fc = FacesHelper.getFacesContext(req, res, sc); -// AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME); // WCM - NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME); - - // setup context from url args in properties map - String webProjectId = (String)properties.get(PROP_WEBPROJECTID); - ParameterCheck.mandatoryString(PROP_WEBPROJECTID, webProjectId); - String sandbox = (String)properties.get(PROP_SANDBOX); - ParameterCheck.mandatoryString(PROP_SANDBOX, sandbox); - String path = (String)properties.get(PROP_PATH); - ParameterCheck.mandatoryString(PROP_PATH, path); - navigator.setCurrentNodeId(webProjectId); -// // WCM -// avmBrowseBean.setSandbox(sandbox); -// // navigation handler is called directly in this method -// avmBrowseBean.setupEditAction(path); - - String viewId = fc.getViewRoot().getViewId(); - try - { - sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res); - } - catch (Exception e) - { - throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e); - } - - return null; - } - - /** - * @see org.alfresco.web.app.servlet.command.Command#getPropertyNames() - */ - public String[] getPropertyNames() - { - return PROPERTIES; - } -} diff --git a/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java b/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java index b25aaa57ce..b639e9bbc3 100644 --- a/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java +++ b/source/java/org/alfresco/web/app/servlet/command/UIActionCommandProcessor.java @@ -47,12 +47,9 @@ import org.alfresco.web.ui.common.Utils; */ public class UIActionCommandProcessor implements ExtCommandProcessor { - /** - * - */ - private static final String MANAGE_TASK = "managetask"; + private static final String MANAGE_TASK = "managetask"; -public static final String PARAM_CONTAINER = "container"; + public static final String PARAM_CONTAINER = "container"; private ServletContext sc = null; private String command = null; @@ -61,9 +58,6 @@ public static final String PARAM_CONTAINER = "container"; static { // add our commands to the command registry -// // WCM -// CommandFactory.getInstance().registerCommand("createwebcontent", CreateWebContentCommand.class); - CommandFactory.getInstance().registerCommand("editwebcontent", EditWebContentCommand.class); CommandFactory.getInstance().registerCommand(MANAGE_TASK, ManageTaskDialogCommand.class); CommandFactory.getInstance().registerCommand("editcontentprops", EditContentPropertiesCommand.class); CommandFactory.getInstance().registerCommand("userprofile", UserProfileDialogCommand.class); @@ -81,7 +75,7 @@ public static final String PARAM_CONTAINER = "container"; { this.args = new HashMap(args); } - if(MANAGE_TASK.equals(command)) + if (MANAGE_TASK.equals(command)) { String taskId = args.get(ManageTaskDialogCommand.PROP_TASKID); return WorkflowUtil.isTaskEditable(taskId, sc); diff --git a/source/java/org/alfresco/web/bean/admin/AdminNodeBrowseBean.java b/source/java/org/alfresco/web/bean/admin/AdminNodeBrowseBean.java index 86b977cc6c..b5d284974c 100644 --- a/source/java/org/alfresco/web/bean/admin/AdminNodeBrowseBean.java +++ b/source/java/org/alfresco/web/bean/admin/AdminNodeBrowseBean.java @@ -102,7 +102,6 @@ public class AdminNodeBrowseBean implements Serializable transient private DataModel assocs = null; transient private DataModel permissions = null; transient private DataModel permissionMasks = null; - transient private DataModel avmStoreProps = null; // supporting repository services transient private TransactionService transactionService; @@ -111,8 +110,6 @@ public class AdminNodeBrowseBean implements Serializable transient private SearchService searchService; transient private NamespaceService namespaceService; transient private PermissionService permissionService; -// // WCM -// transient private AVMService avmService; /** * @param transactionService transaction service @@ -216,24 +213,6 @@ public class AdminNodeBrowseBean implements Serializable return permissionService; } -// // WCM -// /** -// * @param avmService AVM service -// */ -// public void setAVMService(AVMService avmService) -// { -// this.avmService = avmService; -// } -// -// private AVMService getAVMService() -// { -// if (avmService == null) -// { -// avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService(); -// } -// return avmService; -// } -// /** * Gets the list of repository stores * @@ -424,18 +403,9 @@ public class AdminNodeBrowseBean implements Serializable { if (permissionMasks == null) { -// // WCM -// if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) -// { -// List nodePermissions = new ArrayList(getPermissionService().getAllSetPermissions(nodeRef.getStoreRef())); -// permissionMasks = new ListDataModel(nodePermissions); -// } -// else -// { - List noReadPermissions = new ArrayList(1); - noReadPermissions.add(new NoStoreMask()); - permissionMasks = new ListDataModel(noReadPermissions); -// } + List noReadPermissions = new ArrayList(1); + noReadPermissions.add(new NoStoreMask()); + permissionMasks = new ListDataModel(noReadPermissions); } return permissionMasks; } @@ -476,43 +446,6 @@ public class AdminNodeBrowseBean implements Serializable } return assocs; } -// -// // WCM -// public boolean getInAVMStore() -// { -// return nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM); -// } -// -// // WCM -// public DataModel getAVMStoreProperties() -// { -// if (avmStoreProps == null) -// { -// // work out the store name from current nodeRef -// String store = nodeRef.getStoreRef().getIdentifier(); -// Map props = getAVMService().getStoreProperties(store); -// List> storeProperties = new ArrayList>(); -// -// for (Map.Entry property : props.entrySet()) -// { -// Map map = new HashMap(2); -// map.put("name", property.getKey().toString()); -// map.put("type", property.getValue().getActualTypeString()); -// String val = property.getValue().getStringValue(); -// if (val == null) -// { -// val = "null"; -// } -// map.put("value", val); -// -// storeProperties.add(map); -// } -// -// avmStoreProps = new ListDataModel(storeProperties); -// } -// -// return avmStoreProps; -// } /** * Gets the current query language @@ -585,8 +518,6 @@ public class AdminNodeBrowseBean implements Serializable NodeRef rootNode = getNodeService().getRootNode(storeRef); setNodeRef(rootNode); - this.avmStoreProps = null; - return "success"; } diff --git a/source/java/org/alfresco/web/bean/clipboard/AbstractClipboardItem.java b/source/java/org/alfresco/web/bean/clipboard/AbstractClipboardItem.java index 48813a9f52..0b1d2028de 100644 --- a/source/java/org/alfresco/web/bean/clipboard/AbstractClipboardItem.java +++ b/source/java/org/alfresco/web/bean/clipboard/AbstractClipboardItem.java @@ -59,9 +59,6 @@ abstract class AbstractClipboardItem implements ClipboardItem private QName type; private String icon; -// // WCM -// transient protected AVMService avmService; -// private List customPasteViewIds; @@ -93,21 +90,6 @@ abstract class AbstractClipboardItem implements ClipboardItem this.customPasteViewIds = customPasteViewIds; } -// // WCM -// public void setAvmService(AVMService avmService) -// { -// this.avmService = avmService; -// } -// -// protected AVMService getAvmService() -// { -// if (avmService == null) -// { -// avmService = getServiceRegistry().getAVMLockingAwareService(); -// } -// return avmService; -// } -// public ClipboardStatus getMode() { return this.mode; @@ -226,29 +208,4 @@ abstract class AbstractClipboardItem implements ClipboardItem return (nodeRefs.size() != 0); } -// -// // WCM -// protected void recursiveFormCheck(AVMNodeDescriptor desc) -// { -// if (desc.isFile()) -// { -// String filePath = desc.getPath(); -// if (avmService.hasAspect(-1, filePath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) -// { -// avmService.removeAspect(filePath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA); -// } -// if (avmService.hasAspect(-1, filePath, WCMAppModel.ASPECT_RENDITION)) -// { -// avmService.removeAspect(filePath, WCMAppModel.ASPECT_RENDITION); -// } -// } -// else -// { -// Map listing = getAvmService().getDirectoryListing(desc); -// for (Map.Entry entry : listing.entrySet()) -// { -// recursiveFormCheck(entry.getValue()); -// } -// } -// } } diff --git a/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java b/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java index f581a153bd..7aa759bed6 100644 --- a/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java +++ b/source/java/org/alfresco/web/bean/clipboard/ClipboardBean.java @@ -330,16 +330,6 @@ public class ClipboardBean implements Serializable { item = new WorkspaceClipboardItem(ref, parent, mode, customPasteViewIds); } -// // WCM -// else if (StoreRef.PROTOCOL_AVM.equals(ref.getStoreRef().getProtocol())) -// { -// item = new AVMClipboardItem(ref, mode, customPasteViewIds); -// } -// else -// { -// logger.warn("Unable to add item to clipboard - unknown store protocol: " + ref.getStoreRef().getProtocol()); -// } -// if (item != null) { // check for duplicates first @@ -364,8 +354,6 @@ public class ClipboardBean implements Serializable FacesContext context = FacesContext.getCurrentInstance(); if (Application.getClientConfig(context).isClipboardStatusVisible()) { -// // WCM -// String pattern = Application.getMessage(context, StoreRef.PROTOCOL_AVM.equals(ref.getStoreRef().getProtocol()) ? "node_added_clipboard_avm" : "node_added_clipboard"); String pattern = Application.getMessage(context, "node_added_clipboard"); String msg = MessageFormat.format(pattern, items.size()); FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg); diff --git a/source/java/org/alfresco/web/bean/clipboard/WorkspaceClipboardItem.java b/source/java/org/alfresco/web/bean/clipboard/WorkspaceClipboardItem.java index f616684324..152cfdef91 100644 --- a/source/java/org/alfresco/web/bean/clipboard/WorkspaceClipboardItem.java +++ b/source/java/org/alfresco/web/bean/clipboard/WorkspaceClipboardItem.java @@ -55,7 +55,6 @@ public class WorkspaceClipboardItem extends AbstractClipboardItem private static final long serialVersionUID = -1686557602737846009L; private static final String WORKSPACE_PASTE_VIEW_ID = "/jsp/browse/browse.jsp"; -// private static final String AVM_PASTE_VIEW_ID = "/jsp/wcm/browse-sandbox.jsp"; // WCM private static final String FORUMS_PASTE_VIEW_ID = "/jsp/forums/forums.jsp"; private static final String FORUM_PASTE_VIEW_ID = "/jsp/forums/forum.jsp"; @@ -96,24 +95,8 @@ public class WorkspaceClipboardItem extends AbstractClipboardItem */ public boolean canCopyToViewId(String viewId) { -// // WCM -// if (AVM_PASTE_VIEW_ID.equals(viewId)) -// { -// AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), AVMBrowseBean.BEAN_NAME); -// String destPath = avmBrowseBean.getCurrentPath(); -// -// if (WCMUtil.isStagingStore(WCMUtil.getStoreName(destPath))) -// { -// return false; -// } -// -// return true; -// } -// else - { - return super.canCopyToViewId(viewId) || (WORKSPACE_PASTE_VIEW_ID.equals(viewId) || /*AVM_PASTE_VIEW_ID.equals(viewId) || WCM */ - FORUMS_PASTE_VIEW_ID.equals(viewId) || FORUM_PASTE_VIEW_ID.equals(viewId)); - } + return super.canCopyToViewId(viewId) || (WORKSPACE_PASTE_VIEW_ID.equals(viewId) || + FORUMS_PASTE_VIEW_ID.equals(viewId) || FORUM_PASTE_VIEW_ID.equals(viewId)); } /** @@ -121,8 +104,8 @@ public class WorkspaceClipboardItem extends AbstractClipboardItem */ public boolean canMoveToViewId(String viewId) { - return super.canMoveToViewId(viewId) || (WORKSPACE_PASTE_VIEW_ID.equals(viewId) || FORUMS_PASTE_VIEW_ID.equals(viewId) || - FORUM_PASTE_VIEW_ID.equals(viewId)); + return super.canMoveToViewId(viewId) || (WORKSPACE_PASTE_VIEW_ID.equals(viewId) || FORUMS_PASTE_VIEW_ID.equals(viewId) || + FORUM_PASTE_VIEW_ID.equals(viewId)); } /** @@ -346,75 +329,6 @@ public class WorkspaceClipboardItem extends AbstractClipboardItem } return true; } -// // WCM -// else if (AVM_PASTE_VIEW_ID.equals(viewId)) -// { -// AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME); -// -// final String destPath = avmBrowseBean.getCurrentPath(); -// final NodeRef destRef = AVMNodeConverter.ToNodeRef(-1, destPath); -// -// final CrossRepositoryCopyService crossRepoCopyService = getServiceRegistry().getCrossRepositoryCopyService(); -// -// // initial name to attempt the copy of the item with -// String name = getName(); -// -// for(;;) -// { -// try -// { -// final String currentName = name; -// -// // attempt each copy/paste in its own transaction -// retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback() -// { -// public Void execute() throws Throwable -// { -// if (getMode() == ClipboardStatus.COPY) -// { -// // COPY operation -// if (logger.isDebugEnabled()) -// logger.debug("Attempting to copy node: " + getNodeRef() + " into node ID: " + destRef.toString()); -// -// // inter-store copy operation -// crossRepoCopyService.copy(getNodeRef(), destRef, currentName); -// -// if (destRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) -// { -// // ETHREEOH-2110 -// AVMNodeDescriptor desc = getAvmService().lookup(-1, destPath + "/" + currentName); -// recursiveFormCheck(desc); -// } -// } -// else -// { -// // this should not occur as the canMoveToViewId() will return false -// throw new Exception("Move operation not supported between stores."); -// } -// return null; -// } -// }); -// -// // We got here without error, so no need to loop with a new name -// break; -// } -// catch (FileExistsException fileExistsErr) -// { -// // If mode is COPY, have another go around the loop with a new name -// if (getMode() == ClipboardStatus.COPY) -// { -// String copyOf = Application.getMessage(fc, MSG_COPY_OF); -// name = copyOf + ' ' + name; -// } -// else -// { -// // we should not rename an item when it is being moved - so exit -// throw fileExistsErr; -// } -// } -// } -// return true; -// } else { return false; diff --git a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java index dba4dfb101..226bf5437c 100644 --- a/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java +++ b/source/java/org/alfresco/web/bean/coci/CheckinCheckoutDialog.java @@ -317,24 +317,7 @@ public class CheckinCheckoutDialog extends BaseDialogBean { boolean editingInline = false; Node node = setupContentDocument(id); - -// // WCM -// if (node.hasAspect(WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) -// { -// editingInline = true; -// -// // editable form document -// FacesContext fc = FacesContext.getCurrentInstance(); -// this.navigator.setupDispatchContext(node); -// -// // TODO - rename editContent Wizard since it only deals with editing form content -// fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "wizard:editContent"); -// } -// -// // detect the inline editing aspect to see which edit mode to use -// else if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && -// node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null && -// ((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true) + if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) && node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null && ((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true) diff --git a/source/java/org/alfresco/web/bean/content/CreateContentWizard.java b/source/java/org/alfresco/web/bean/content/CreateContentWizard.java index d0a0bde930..0af555771d 100644 --- a/source/java/org/alfresco/web/bean/content/CreateContentWizard.java +++ b/source/java/org/alfresco/web/bean/content/CreateContentWizard.java @@ -18,11 +18,8 @@ */ package org.alfresco.web.bean.content; -import java.io.Serializable; import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -31,30 +28,21 @@ import javax.faces.context.FacesContext; import javax.faces.event.ValueChangeEvent; import javax.faces.model.SelectItem; -import org.springframework.extensions.config.Config; -import org.springframework.extensions.config.ConfigElement; -import org.springframework.extensions.config.ConfigService; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.model.FileExistsException; -import org.alfresco.service.namespace.QName; import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; -import org.alfresco.web.forms.Form; -import org.alfresco.web.forms.FormNotFoundException; -import org.alfresco.web.forms.FormProcessor; -import org.alfresco.web.forms.FormsService; -import org.alfresco.util.XMLUtil; import org.alfresco.web.ui.common.Utils; -import org.apache.commons.io.FilenameUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; +import org.springframework.extensions.config.Config; +import org.springframework.extensions.config.ConfigElement; +import org.springframework.extensions.config.ConfigService; /** * Bean implementation for the "Create Content Wizard" dialog @@ -68,35 +56,9 @@ public class CreateContentWizard extends BaseContentWizard protected String content = null; protected List createMimeTypes; - transient protected FormsService formsService; - protected String formName; - protected FormProcessor.Session formProcessorSession = null; - transient protected Document instanceDataDocument = null; - private static Log logger = LogFactory.getLog(CreateContentWizard.class); - /** - * @param formsService The FormsService to set. - */ - public void setFormsService(final FormsService formsService) - { - this.formsService = formsService; - } - - /** - * @return the formsService - */ - private FormsService getFormsService() - { - //check for null for cluster environment - if (formsService == null) - { - formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService"); - } - return formsService; - } - // ------------------------------------------------------------------------------ // Wizard implementation @@ -104,25 +66,8 @@ public class CreateContentWizard extends BaseContentWizard @Override public String finish() { - // if a form is entered, then save the form instance data as XML ... - if (this.instanceDataDocument != null) - { - this.content = XMLUtil.toString(this.instanceDataDocument, true); - - this.mimeType = MimetypeMap.MIMETYPE_XML; // belts & braces - override mimetype (in case is not set to XML) - } - String result = super.finish(); -// // WCM -// if ((super.createdNode != null) && (this.instanceDataDocument != null)) -// { -// final Map props = new HashMap(1, 1.0f); -// props.put(WCMAppModel.PROP_PARENT_FORM_NAME, getFormName()); -// props.put(WCMAppModel.PROP_ORIGINAL_PARENT_PATH, ""); -// getNodeService().addAspect(super.createdNode, WCMAppModel.ASPECT_FORM_INSTANCE_DATA, props); -// } -// return result; } @@ -144,14 +89,6 @@ public class CreateContentWizard extends BaseContentWizard this.content = null; this.inlineEdit = true; this.mimeType = MimetypeMap.MIMETYPE_HTML; - this.formName = ""; - - this.instanceDataDocument = null; - if (this.formProcessorSession != null) - { - this.formProcessorSession.destroy(); - } - this.formProcessorSession = null; } @Override @@ -299,11 +236,6 @@ public class CreateContentWizard extends BaseContentWizard { ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance()); - if (this.instanceDataDocument != null) - { - this.mimeType = MimetypeMap.MIMETYPE_XML; // belts & braces - override mimetype (in case is not set to XML) - } - // TODO: show first few lines of content here? return buildSummary( new String[] {bundle.getString("file_name"), @@ -313,81 +245,6 @@ public class CreateContentWizard extends BaseContentWizard getSummaryMimeType(this.mimeType)}); } - /** - * @return List of UI items to represent the full list of available ECM Forms - */ - public List getFormsList() - { - Collection

forms = this.getFormsService().getForms(); - List items = new ArrayList(forms.size()+1); - items.add(new SelectItem("", "")); - for (Form form : forms) - { - items.add(new SelectItem(form.getName(), form.getTitle())); - } - return items; - } - - public String getFormName() - { - return this.formName; - } - - public void setFormName(String formName) - { - this.formName = formName; - } - - public Form getForm() throws FormNotFoundException - { - return (this.getFormName() != null - ? getFormsService().getForm(formName) - : null); - } - - public FormProcessor.Session getFormProcessorSession() - { - return this.formProcessorSession; - } - - public void setFormProcessorSession(final FormProcessor.Session formProcessorSession) - { - this.formProcessorSession = formProcessorSession; - } - - public Document getInstanceDataDocument() - { - if (this.instanceDataDocument == null) - { - final String content = this.getContent(); - try - { - this.instanceDataDocument = (content != null - ? XMLUtil.parse(content) - : XMLUtil.newDocument()); - } - catch (Exception e) - { - Utils.addErrorMessage("error parsing document", e); - this.instanceDataDocument = XMLUtil.newDocument(); - } - } - return this.instanceDataDocument; - } - - /** Overrides in order to strip an xml extension if the user entered it */ - // TODO do we need ? it is currently referenced in create-forms.jsp (copied from wcm create-xml.jsp) - @Override - public String getFileName() - { - final String result = super.getFileName(); - return (result != null && - MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && - this.getFormName() != null && - "xml".equals(FilenameUtils.getExtension(result).toLowerCase()) - ? FilenameUtils.removeExtension(result) - : result); - } // ------------------------------------------------------------------------------ // Action event handlers diff --git a/source/java/org/alfresco/web/bean/content/EditContentWizard.java b/source/java/org/alfresco/web/bean/content/EditContentWizard.java index 48658d774a..9c2ea9ba8b 100644 --- a/source/java/org/alfresco/web/bean/content/EditContentWizard.java +++ b/source/java/org/alfresco/web/bean/content/EditContentWizard.java @@ -28,9 +28,6 @@ import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.web.bean.repository.Node; -import org.alfresco.web.forms.Form; -import org.alfresco.web.forms.FormNotFoundException; -import org.alfresco.web.ui.common.Utils; /** * Bean implementation for the "Edit Content Wizard" dialog @@ -40,7 +37,6 @@ public class EditContentWizard extends CreateContentWizard private static final long serialVersionUID = 1640754719164511019L; private NodeRef nodeRef; - private Form form; // ------------------------------------------------------------------------------ // Wizard implementation @@ -48,7 +44,6 @@ public class EditContentWizard extends CreateContentWizard @Override public void init(final Map parameters) { - // TODO - currently assumes this is form content super.init(parameters); Node node = this.navigator.getDispatchContextNode(); if (node == null) @@ -56,17 +51,6 @@ public class EditContentWizard extends CreateContentWizard throw new IllegalArgumentException("Edit Form wizard requires action node context."); } this.nodeRef = node.getNodeRef(); - try - { -// // WCM -// formName = (String)getNodeService().getProperty(nodeRef, WCMAppModel.PROP_PARENT_FORM_NAME); // getFormName() ... - form = formsService.getForm(this.formName); - } - catch (FormNotFoundException fnfe) - { - Utils.addErrorMessage(fnfe.getMessage(), fnfe); - throw new IllegalArgumentException(fnfe); - } this.content = this.getContentService().getReader(nodeRef, ContentModel.PROP_CONTENT).getContentString(); @@ -92,10 +76,4 @@ public class EditContentWizard extends CreateContentWizard { return outcome; } - - @Override - public Form getForm() - { - return this.form; - } } diff --git a/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java b/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java index 389cbcb1a3..f79a2e43f7 100644 --- a/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java +++ b/source/java/org/alfresco/web/bean/workflow/StartWorkflowWizard.java @@ -84,7 +84,6 @@ public class StartWorkflowWizard extends BaseWizardBean transient protected List availableWorkflows; transient private Map workflows; - protected List wcmWorkflows; protected List excludedWorkflows; protected List invitationWorkflows; protected List publishingWorkflows; @@ -570,9 +569,6 @@ public class StartWorkflowWizard extends BaseWizardBean this.availableWorkflows = new ArrayList(4); this.workflows = new HashMap(4); - // get the list of configured WCM workflows and filter these from - // the list as these workflows are specific to WCM functionality and AVM stores - List configuredWcmWorkflows = this.getWCMWorkflowNames(); List configuredInvitationWorkflows = this.getInvitationServiceWorkflowNames(); List publishingWorkflows = this.getPublishingWorkflowNames(); List excludedWorkflows = this.getExcludedWorkflows(); @@ -582,8 +578,7 @@ public class StartWorkflowWizard extends BaseWizardBean { String name = workflowDef.name; - if (configuredWcmWorkflows.contains(name) == false && - configuredInvitationWorkflows.contains(name) == false && + if (configuredInvitationWorkflows.contains(name) == false && publishingWorkflows.contains(name) == false && excludedWorkflows.contains(name) == false) { @@ -736,63 +731,6 @@ public class StartWorkflowWizard extends BaseWizardBean } } - /** - * Get the Names of the WCM workflows. - * - * @return The names of the WCM workflows. - */ - protected List getWCMWorkflowNames() - { - if ((wcmWorkflows == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) - { - FacesContext fc = FacesContext.getCurrentInstance(); - ConfigElement config = Application.getConfigService(fc).getGlobalConfig().getConfigElement("wcm"); - if (config != null) - { - // get the main WCM workflows - ConfigElement workflowConfig = config.getChild("workflows"); - if (workflowConfig != null) - { - StringTokenizer t = new StringTokenizer(workflowConfig.getValue().trim(), ", "); - wcmWorkflows = new ArrayList(t.countTokens()); - while (t.hasMoreTokens()) - { - String wfName = "jbpm$" + t.nextToken(); - wcmWorkflows.add(wfName); - } - } - else - { - if (logger.isWarnEnabled()) - logger.warn("WARNING: Unable to find WCM 'workflows' config element definition."); - } - - // get the admin WCM workflows - ConfigElement adminWorkflowConfig = config.getChild("admin-workflows"); - if (adminWorkflowConfig != null) - { - StringTokenizer t = new StringTokenizer(adminWorkflowConfig.getValue().trim(), ", "); - while (t.hasMoreTokens()) - { - String wfName = "jbpm$" + t.nextToken(); - wcmWorkflows.add(wfName); - } - } - else - { - if (logger.isWarnEnabled()) - logger.warn("WARNING: Unable to find WCM 'admin-workflows' config element definition."); - } - } - else - { - logger.warn("WARNING: Unable to find 'wcm' config element definition."); - } - } - - return wcmWorkflows; - } - /** * Get the Names of globally excluded workflow-names. * diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java index ca53464cfd..f163680a0a 100644 --- a/source/java/org/alfresco/web/config/ClientConfigElement.java +++ b/source/java/org/alfresco/web/config/ClientConfigElement.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.List; import org.alfresco.service.namespace.QName; -import org.alfresco.util.ExpiringValueCache; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.config.ConfigElement; @@ -61,8 +60,6 @@ public class ClientConfigElement extends ConfigElementAdapter private String homeSpacePermission = null; private boolean nodeSummaryEnabled = true; private String initialLocation = "myalfresco"; - private ExpiringValueCache wcmDomain = new ExpiringValueCache(1000*10L); - private ExpiringValueCache wcmPort = new ExpiringValueCache(1000*10L); private String defaultHomeSpacePath = "/app:company_home/app:user_homes"; private boolean clipboardStatusVisible = true; private boolean pasteAllAndClear = true; @@ -664,56 +661,6 @@ public class ClientConfigElement extends ConfigElementAdapter this.initialLocation = initialLocation; } -// // WCM -// /** -// * @return Returns the WCM Domain obtained from the Virtualisation Server registry. -// */ -// public String getWCMDomain() -// { -// String value = this.wcmDomain.get(); -// if (value == null) -// { -// VirtServerRegistry vServerRegistry = Repository.getServiceRegistry( -// FacesContext.getCurrentInstance()).getVirtServerRegistry(); -// value = vServerRegistry.getVirtServerFQDN(); -// if (value == null) -// { -// value = JNDIConstants.DEFAULT_VSERVER_IP; -// if (logger.isDebugEnabled()) -// { -// logger.debug("Virtualisation Server not started - reverting to default IP: " + value); -// } -// } -// this.wcmDomain.put(value); -// } -// return value; -// } -// -// /** -// * @return Returns the WCM Port obtained from the Virtualisation Server registry. -// */ -// public String getWCMPort() -// { -// String value = this.wcmPort.get(); -// if (value == null) -// { -// VirtServerRegistry vServerRegistry = Repository.getServiceRegistry( -// FacesContext.getCurrentInstance()).getVirtServerRegistry(); -// Integer iValue = vServerRegistry.getVirtServerHttpPort(); -// if (iValue == null) -// { -// iValue = JNDIConstants.DEFAULT_VSERVER_PORT; -// if (logger.isDebugEnabled()) -// { -// logger.debug("Virtualisation Server not started - reverting to default port: " + iValue); -// } -// } -// value = iValue.toString(); -// this.wcmPort.put(value); -// } -// return value; -// } -// /*package*/ void setAllowGuestConfig(boolean allow) { this.allowGuestConfig = allow; diff --git a/source/java/org/alfresco/web/forms/Form.java b/source/java/org/alfresco/web/forms/Form.java deleted file mode 100644 index 88ecd3e428..0000000000 --- a/source/java/org/alfresco/web/forms/Form.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.cmr.workflow.WorkflowDefinition; -import org.alfresco.service.namespace.QName; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Encapsulation of a form. - * - * @author Ariel Backenroth - */ -public interface Form - extends Serializable -{ - - /** the name of the form, which must be unique within the FormsService */ - public String getName(); - - /** the title of the form */ - public String getTitle(); - - /** the description of the form */ - public String getDescription(); - - /** the root tag to use within the schema */ - public String getSchemaRootElementName(); - - /** the output path pattern for form instance data */ - public String getOutputPathPattern(); - - /** - * @return the default workflow associated with this form or null - * if none is configured. - */ - public WorkflowDefinition getDefaultWorkflow(); - - /** - * @return the parameters for the default workflow or null - * if none were configured. - */ - public Map getDefaultWorkflowParameters(); - - /** the xml schema for this template type */ - public Document getSchema() - throws IOException, SAXException; - - /** - * provides the output path for the form instance data based on the - * configured output path pattern. - * - * @param formInstanceData the parsed xml content - * @param formInstanceDataFileName the file name provided by the user. - * @param parentAVMPath the parent avm path - * @param webappName the current webapp name - * - * @return the path to use for writing the form instance data. - */ - public String getOutputPathForFormInstanceData(final Document formInstanceData, - final String formInstanceDataFileName, - final String parentAVMPath, - final String webappName); - - //XXXarielb not used currently and not sure if it's necessary... - // public void addInputMethod(final TemplateInputMethod in); - - /** - * Provides a set of input methods for this template. - */ - public List getFormProcessors(); - - /** - * adds an output method to this template type. - */ - public void addRenderingEngineTemplate(RenderingEngineTemplate output); - - /** - * Provides the set of output methods for this template. - */ - public List getRenderingEngineTemplates(); - - /** - * Provides the rendering engine template by name. - * - * @param name the name of the rendering engine template. - * @return the rendering engine template or null if not found. - */ - public RenderingEngineTemplate getRenderingEngineTemplate(final String name); - - /** - * @return true if WCM Form, false if ECM form - */ - public boolean isWebForm(); -} diff --git a/source/java/org/alfresco/web/forms/FormDataFunctions.java b/source/java/org/alfresco/web/forms/FormDataFunctions.java deleted file mode 100644 index 86f914afa6..0000000000 --- a/source/java/org/alfresco/web/forms/FormDataFunctions.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Common implementation of functions called in the context of FormDataRenderers. - * This uses AVMRemote rather than AVMService so that in can be used in the context - * of both the alfresco webapp and the virtualization server. - * - * @author Ariel Backenroth - * @author Arseny Kovalchuk (Fix for the ETWOONE-241 and ETWOTWO-504 issues) - */ -public class FormDataFunctions -{ - private static final Log LOGGER = LogFactory.getLog(FormDataFunctions.class); - -// // WCM -// private final AVMRemote avmRemote; -// - private ThreadLocal dbf = new ThreadLocal(); - - public FormDataFunctions(/*final AVMRemote avmRemote*/) - { -// this.avmRemote = avmRemote; - } - - /** - * Loads and parses an xml document at the specified path using avm remote. - * - * @param avmPath a path within the avm repository. - * @return the parsed document. - */ - public Document parseXMLDocument(final String avmPath) - throws IOException, - SAXException - { -// // WCM -// final InputStream istream = this.avmRemote.getFileInputStream(-1, avmPath); -// try -// { -// return parseXML(istream); -// } -// finally -// { -// istream.close(); -// } - return null; - } - - /** - * Loads and parses all xml documents at the specified path generated by the - * specified form using avm remote. - * - * @param formName a form name - * @param avmPath a path within the avm repository. - * @return the parsed document. - */ - public Map parseXMLDocuments(final String formName, final String avmPath) - throws IOException, - SAXException - { -// // WCM -// final Map entries = -// this.avmRemote.getDirectoryListing(-1, avmPath); -// final Map result = new HashMap(); -// for (Map.Entry entry : entries.entrySet()) -// { -// final String entryName = entry.getKey(); -// AVMNodeDescriptor entryNode = entry.getValue(); -// if (entryNode.isFile()) -// { -// PropertyValue pv = -// this.avmRemote.getNodeProperty(-1, -// avmPath + '/' + entryName, -// WCMAppModel.PROP_PARENT_FORM_NAME); -// if (pv == null || -// pv.getStringValue() == null || -// !((String)pv.getStringValue()).equals(formName)) -// { -// // it's not generated by the same template type -// continue; -// } -// -// pv = this.avmRemote.getNodeProperty(-1, -// avmPath + '/' + entryName, -// WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE); -// -// if (pv != null) -// { -// // it's generated by a rendering engine (it's not the xml file) -// continue; -// } -// final InputStream istream = this.avmRemote.getFileInputStream(-1, avmPath + '/' + entryName); -// try -// { -// // result.put(entryName, XMLUtil.parse(istream)); -// result.put(entryName, parseXML(istream)); -// } -// finally -// { -// istream.close(); -// } -// } -// } -// return result; - return null; - } - - /* - * We need an internal method for XML parsing with ThreadLocal DocumentBuilderFactory - * to avoid a multithread access to the parser in XMLUtils. - * Fix of the bug reported in https://issues.alfresco.com/jira/browse/ETWOONE-241 reported. - */ - private Document parseXML(InputStream is) throws IOException, SAXException - { - Document result = null; - try - { - DocumentBuilderFactory localDbf = dbf.get(); - if (localDbf == null) - { - localDbf = DocumentBuilderFactory.newInstance(); - } - localDbf.setNamespaceAware(true); - localDbf.setValidating(false); - dbf.set(localDbf); - DocumentBuilder builder = localDbf.newDocumentBuilder(); - result = builder.parse(is); - } - catch (ParserConfigurationException pce) - { - LOGGER.error(pce); - } - - return result; - } - - - /** - * Encodes invalid HTML characters. (Fix for ETWOTWO-504 issue) - * This code was adopted from WebDAVHelper.encodeHTML() method with some restrictions. - * @see press-relese.xsl for pattern. - * - * @param text to encode - * @return encoded text - * @throws IOException - * @throws SAXException - */ - public String encodeQuotes(String text) throws IOException, SAXException - { - if (text == null) - { - return ""; - } - - StringBuilder sb = null; //create on demand - String enc; - char c; - for (int i = 0; i < text.length(); i++) - { - enc = null; - c = text.charAt(i); - switch (c) - { - case '"': enc = """; break; //" - //case '&': enc = "&"; break; //& - //case '<': enc = "<"; break; //< - //case '>': enc = ">"; break; //> - - //german umlauts - case '\u00E4' : enc = "ä"; break; - case '\u00C4' : enc = "Ä"; break; - case '\u00F6' : enc = "ö"; break; - case '\u00D6' : enc = "Ö"; break; - case '\u00FC' : enc = "ü"; break; - case '\u00DC' : enc = "Ü"; break; - case '\u00DF' : enc = "ß"; break; - - //misc - //case 0x80: enc = "€"; break; sometimes euro symbol is ascii 128, should we suport it? - case '\u20AC': enc = "€"; break; - case '\u00AB': enc = "«"; break; - case '\u00BB': enc = "»"; break; - case '\u00A0': enc = " "; break; - - //case '': enc = "&trade"; break; - - default: - if (((int)c) >= 0x80) - { - //encode all non basic latin characters - enc = "&#" + ((int)c) + ";"; - } - break; - } - - if (enc != null) - { - if (sb == null) - { - String soFar = text.substring(0, i); - sb = new StringBuilder(i + 8); - sb.append(soFar); - } - sb.append(enc); - } - else - { - if (sb != null) - { - sb.append(c); - } - } - } - - if (sb == null) - { - return text; - } - else - { - return sb.toString(); - } - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/web/forms/FormInstanceData.java b/source/java/org/alfresco/web/forms/FormInstanceData.java deleted file mode 100644 index f60cfa95bd..0000000000 --- a/source/java/org/alfresco/web/forms/FormInstanceData.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.Serializable; -import java.util.List; - -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Encapsulation of form instance data. - * - * @author Ariel Backenroth - */ -public interface FormInstanceData - extends Serializable -{ - - ///////////////////////////////////////////////////////////////////////////// - - public static class RegenerateResult implements Serializable - { - - private static final long serialVersionUID = -3827878774655260635L; - - private final RenderingEngineTemplate ret; - private final String path; - private final Rendition r; - private final Exception e; - private final String lockOwner; // existing lock owner otherwise null - - public RegenerateResult(final RenderingEngineTemplate ret, - final String path, - final Rendition r, - final String lockOwner) - { - this.ret = ret; - this.r = r; - this.e = null; - this.path = path; - this.lockOwner = lockOwner; - } - - public RegenerateResult(final RenderingEngineTemplate ret, - final String path, - final Exception e, - final String lockOwner) - { - this.ret = ret; - this.e = e; - this.r = null; - this.path = path; - this.lockOwner = lockOwner; - } - - public RenderingEngineTemplate getRenderingEngineTemplate() - { - return this.ret; - } - - public String getPath() - { - return this.path; - } - - public Rendition getRendition() - { - return this.r; - } - - public Exception getException() - { - return this.e; - } - - public String getLockOwner() - { - return this.lockOwner; - } - } - - ///////////////////////////////////////////////////////////////////////////// - - /** the form generate this form instance data */ - public Form getForm() - throws FormNotFoundException; - - /** the name of this instance data */ - public String getName(); - - /** the path relative to the containing webapp */ - public String getWebappRelativePath(); - - /** the path relative to the sandbox */ - public String getSandboxRelativePath(); - - /** the path to the contents of this form instance data */ - public String getPath(); - - /** the url to the asset */ - public String getUrl(); - - /** returns the parsed form instance data */ - public Document getDocument() - throws IOException, SAXException; - - /** Regenerates all renditions of this form instance data */ - public List regenerateRenditions() - throws FormNotFoundException; - - /** returns all renditions of this form instance data */ - public List getRenditions(); - - /** returns all renditions of this form instance data (include deleted AVM nodes) */ - public List getRenditions(boolean includeDeleted); -} diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java deleted file mode 100644 index a407635840..0000000000 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.DataTypeDefinition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.util.XMLUtil; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.repository.Repository; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Encapsulation of a rendition. - * - * @author Ariel Backenroth - */ -/* package */ class FormInstanceDataImpl implements FormInstanceData -{ - private static final long serialVersionUID = -7806221587661854013L; - - private static final Log logger = LogFactory.getLog(RenditionImpl.class); - - private final NodeRef nodeRef; -// // WCM -// private final WebProject webProject; - private transient FormsService formsService; - - /* package */ FormInstanceDataImpl(final NodeRef nodeRef, - final FormsService formsService) - { - this.nodeRef = null; -// // WCM -// this(nodeRef, formsService, null); - } - -// // WCM -// /* package */ FormInstanceDataImpl(final NodeRef nodeRef, -// final FormsService formsService, -// final WebProject webProject) -// { -// this.webProject = webProject; -// -// if (nodeRef == null) -// { -// throw new NullPointerException(); -// } -// if (formsService == null) -// { -// throw new NullPointerException(); -// } -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// -// Pair avmVersionPath = AVMNodeConverter.ToAVMVersionPath(nodeRef); -// -// if (avmService.lookup(avmVersionPath.getFirst(), avmVersionPath.getSecond()) == null) -// { -// throw new IllegalArgumentException("Not found: " + avmVersionPath.getSecond()); -// } -// -// if (!avmService.hasAspect(avmVersionPath.getFirst(), avmVersionPath.getSecond(), -// WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) -// { -// throw new IllegalArgumentException("node " + nodeRef + -// " does not have aspect " + WCMAppModel.ASPECT_FORM_INSTANCE_DATA); -// } -// this.nodeRef = nodeRef; -// this.formsService = formsService; -// } -// -// /* package */ FormInstanceDataImpl(final int version, -// final String avmPath, -// final FormsService formsService) -// { -// this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService); -// } -// - private FormsService getFormsService() - { - if (formsService == null) - { - formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService"); - } - return formsService; - } - - /** the name of this rendition */ - public String getName() - { -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// ContentModel.PROP_NAME).getStringValue(); -// // WCM -// return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1]; - return null; - } - - public String getWebappRelativePath() - { -// // WCM -// return AVMUtil.getWebappRelativePath(this.getPath()); - return null; - } - - public String getSandboxRelativePath() - { -// // WCM -// return AVMUtil.getSandboxRelativePath(this.getPath()); - return null; - } - - public String getPath() - { -// // WCM -// return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); - return null; - } - - public Document getDocument() - throws IOException, SAXException - { -// // WCM -// return XMLUtil.parse(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(), -// this.getServiceRegistry().getAVMService()); - return null; - } - - public Form getForm() - throws FormNotFoundException - { - final String parentFormName = this.getParentFormName(); - try - { -// // WCM -// // TODO - forms should be identified by nodeRef rather than name (which can be non-unique) -// if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) -// { -// if (webProject != null) -// { -// return webProject.getForm(parentFormName); -// } -// - return this.getFormsService().getWebForm(parentFormName); -// } -// else -// { -// return this.getFormsService().getForm(parentFormName); -// } - } - catch (FormNotFoundException fnfe) - { -// // WCM -// if (webProject != null) -// { -// throw new FormNotFoundException(parentFormName, webProject, this); -// } -// - throw new FormNotFoundException(parentFormName, this); - } - } - - /** the node ref containing the contents of this rendition */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - public String getUrl() - { -// // WCM -// return AVMUtil.getPreviewURI(this.getPath()); - return ""; - } - - public List regenerateRenditions() - throws FormNotFoundException - { - if (logger.isDebugEnabled()) - { - logger.debug("regenerating renditions of " + this); - } - -// // WCM -// AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService(); -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// PropertyValue pv = avmService.getNodeProperty( -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// WCMAppModel.PROP_ORIGINAL_PARENT_PATH); -// -// String originalParentAvmPath = (pv == null) ? -// AVMNodeConverter.SplitBase(this.getPath())[0] : pv.getStringValue(); -// -// final HashSet allRets = -// new HashSet(this.getForm().getRenderingEngineTemplates()); - final List result = new LinkedList(); -// // WCM -// // regenerate existing renditions -// String path = null; -// -// for (final Rendition r : this.getRenditions()) -// { -// // Try to skip renditions without rendering engine template. -// if (r instanceof RenditionImpl) -// { -// RenditionImpl rImpl = (RenditionImpl)r; -// RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate(); -// if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl)) -// { -// RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret; -// if (!retImpl.isExists()) -// { -// continue; -// } -// } -// -// } -// final RenderingEngineTemplate ret = r.getRenderingEngineTemplate(); -// if (ret == null || !allRets.contains(ret)) -// { -// continue; -// } -// -// String lockOwner = null; -// try -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("regenerating rendition " + r + " using template " + ret); -// } -// -// path = r.getPath(); -// lockOwner = avmLockService.getLockOwner(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); -// if (lockOwner != null) -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("Lock already exists for " + path); -// } -// } -// -// ret.render(this, r); -// allRets.remove(ret); -// result.add(new RegenerateResult(ret, path, r, lockOwner)); -// } -// catch (Exception e) -// { -// result.add(new RegenerateResult(ret, path, e, lockOwner)); -// -// // remove lock if there wasn't one before -// if (lockOwner == null) -// { -// avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path)); -// -// if (logger.isDebugEnabled()) -// { -// logger.debug("Removed lock for " + path + " as it failed to generate"); -// } -// } -// } -// } -// -// // get current username for lock checks -// String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName(); -// -// // render all renditions for newly added templates -// for (final RenderingEngineTemplate ret : allRets) -// { -// String lockOwner = null; -// String currentLockStore = null; -// boolean lockModified = false; -// -// try -// { -// path = ret.getOutputPathForRendition(this, originalParentAvmPath, getName().replaceAll("(.+)\\..*", "$1")); -// -// if (logger.isDebugEnabled()) -// { -// logger.debug("regenerating rendition of " + this.getPath() + -// " at " + path + " using template " + ret); -// } -// -// String storeId = AVMUtil.getStoreId(path); -// String storePath = AVMUtil.getStoreRelativePath(path); -// String storeName = AVMUtil.getStoreName(path); -// -// Map lockData = avmLockService.getLockData(storeId, storePath); -// if (lockData != null) -// { -// lockOwner = avmLockService.getLockOwner(storeId, storePath); -// currentLockStore = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME); -// } -// -// if (lockOwner != null) -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("Lock already exists for " + path); -// } -// -// if (currentLockStore.equals(storeName) == false) -// { -// if (lockOwner.equals(username)) -// { -// lockModified = true; -// -// // lock already exists on path, check it's owned by the current user -// if (logger.isDebugEnabled()) -// { -// logger.debug("transferring lock from " + currentLockStore + " to " + storeName + " for path: " + path); -// } -// -// lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, storeName); -// avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData); -// } -// } -// } -// -// result.add(new RegenerateResult(ret, path, ret.render(this, path), lockOwner)); -// } -// catch (Exception e) -// { -// result.add(new RegenerateResult(ret, path, e, lockOwner)); -// -// String storeId = AVMUtil.getStoreId(path); -// String storePath = AVMUtil.getStoreRelativePath(path); -// String storeName = AVMUtil.getStoreName(path); -// -// if (lockOwner == null) -// { -// // remove lock if there wasn't one before -// avmLockService.removeLock(storeId, storePath); -// -// if (logger.isDebugEnabled()) -// { -// logger.debug("Removed lock for " + path + " as it failed to generate"); -// } -// } -// else if (lockModified) -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("transferring lock from " + storeName + " to " + currentLockStore + " for path: " + path); -// } -// -// Map lockData = avmLockService.getLockData(storeId, storePath); -// lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, currentLockStore); -// avmLockService.modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData); -// } -// } -// } - return result; - } - - public List getRenditions() - { - return getRenditions(false); - } - - public List getRenditions(boolean includeDeleted) - { -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); -// final PropertyValue pv = -// avmService.getNodeProperty(-1, this.getPath(), WCMAppModel.PROP_RENDITIONS); -// final Collection renditionPaths = (pv == null -// ? Collections.EMPTY_LIST -// : pv.getCollection(DataTypeDefinition.TEXT)); -// final String storeName = AVMUtil.getStoreName(this.getPath()); -// final List result = new ArrayList(renditionPaths.size()); -// for (Serializable path : renditionPaths) -// { -// String avmRenditionPath = AVMUtil.buildAVMPath(storeName, (String)path); -// if (avmService.lookup(-1, avmRenditionPath, includeDeleted) == null) -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("ignoring dangling rendition at: " + avmRenditionPath); -// } -// } -// else -// { -// final Rendition r = new RenditionImpl(-1, -// avmRenditionPath, -// this.getFormsService()); -// try -// { -// if (!this.equals(r.getPrimaryFormInstanceData(includeDeleted))) -// { -// if (logger.isDebugEnabled()) -// { -// logger.debug("rendition " + r + -// " points at form instance data " + r.getPrimaryFormInstanceData(includeDeleted) + -// " instead of " + this + ". Not including in renditions list."); -// } -// continue; -// } -// } -// catch (FileNotFoundException fnfe) -// { -// continue; -// } -// if (r.getRenderingEngineTemplate() != null) -// { -// result.add(r); -// } -// } -// } -// return result; - return null; - } - - private ServiceRegistry getServiceRegistry() - { - final FacesContext fc = FacesContext.getCurrentInstance(); - return Repository.getServiceRegistry(fc); - } - - public int hashCode() - { - return this.getPath().hashCode(); - } - - public String toString() - { - try - { - return (this.getClass().getName() + "{path : " + this.getPath() + - ", form : " + this.getForm().getName() + "}"); - } - catch (FormNotFoundException fnfe) - { - return (this.getClass().getName() + "{path : " + this.getPath() + - ", form : " + this.getParentFormName() + " NOT_FOUND! }"); - - } - } - - public boolean equals(final Object other) - { - return (other instanceof FormInstanceDataImpl && - this.getNodeRef().equals(((FormInstanceDataImpl)other).getNodeRef())); - - } - - protected String getParentFormName() - { -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// WCMAppModel.PROP_PARENT_FORM_NAME).getStringValue(); - return null; - } -} diff --git a/source/java/org/alfresco/web/forms/FormNotFoundException.java b/source/java/org/alfresco/web/forms/FormNotFoundException.java deleted file mode 100644 index f761693a69..0000000000 --- a/source/java/org/alfresco/web/forms/FormNotFoundException.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.FileNotFoundException; -import java.text.MessageFormat; - -import javax.faces.context.FacesContext; - -import org.alfresco.web.app.Application; - -/** - * Error when a form cannot be resolved. - * - * @author Ariel Backenroth - */ -public class FormNotFoundException - extends FileNotFoundException -{ - private final String formName; -// private final WebProject webProject; // WCM - private final FormInstanceData fid; - - public FormNotFoundException(final String formName) - { - super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), - "form_not_found"), - formName)); - this.formName = formName; -// this.webProject = null; // WCM - this.fid = null; - } - - public FormNotFoundException(final String formName, final FormInstanceData fid) - { - super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), - "form_not_found_for_form_instance_data"), - formName, - fid.getPath())); - this.formName = formName; - this.fid = fid; -// this.webProject = null; // WCM - } - -// // WCM -// public FormNotFoundException(final String formName, final WebProject webProject) -// { -// super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), -// "form_not_found_in_web_project"), -// formName, -// webProject.getName())); -// this.formName = formName; -// this.webProject = webProject; -// this.fid = null; -// } -// -// public FormNotFoundException(final String formName, final WebProject webProject, final FormInstanceData fid) -// { -// super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), -// "form_not_found_for_form_instance_data_in_web_project"), -// formName, -// webProject.getName(), -// fid.getPath())); -// this.formName = formName; -// this.webProject = webProject; -// this.fid = fid; -// } -// -// public FormNotFoundException(final Form form, final WebProject webProject) -// { -// super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), -// "form_not_configured_for_web_project"), -// form.getName(), -// webProject.getName())); -// this.formName = form.getName(); -// this.webProject = webProject; -// this.fid = null; -// } -// -// public FormNotFoundException(final Form form, final WebProject webProject, final FormInstanceData fid) -// { -// super(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), -// "form_associated_with_form_instance_data_not_configured_for_web_project"), -// form.getName(), -// fid.getPath(), -// webProject.getName())); -// this.formName = form.getName(); -// this.webProject = webProject; -// this.fid = fid; -// } -// - public String getFormName() - { - return this.formName; - } - -// // WCM -// public WebProject getWebProject() -// { -// return this.webProject; -// } -} diff --git a/source/java/org/alfresco/web/forms/FormProcessor.java b/source/java/org/alfresco/web/forms/FormProcessor.java deleted file mode 100644 index d065941c10..0000000000 --- a/source/java/org/alfresco/web/forms/FormProcessor.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.Serializable; -import java.io.Writer; - -import org.w3c.dom.Document; - -/** - * Generates a user interface for inputing data into a template. - * @author Ariel Backenroth - */ -public interface FormProcessor - extends Serializable -{ - - ///////////////////////////////////////////////////////////////////////////// - - /** - * An abstraction layer around the xml content which allows - * for reseting the xml content being collected by the input method. - */ - public interface Session extends Serializable - { - - /** Returns the set of file uploaded during the session. */ -// public NodeRef[] getUploadedFiles(); - - /** Destroys the session and releases all resources used by it */ - public void destroy(); - - /** Returns the form used by the session. */ - public Form getForm(); - - /** Returns the current state of the form instance data */ - public Document getFormInstanceData(); - - /** Returns the name of the form instance data being modified */ - public String getFormInstanceDataName(); - } - - ///////////////////////////////////////////////////////////////////////////// - - /** - * Exception for errors encoutered during form processing. - */ - public static class ProcessingException - extends Exception - { - - private static final long serialVersionUID = -1067792684180745503L; - - public ProcessingException(final String msg) - { - super(msg); - } - - public ProcessingException(final Exception cause) - { - super(cause); - } - - public ProcessingException(final String msg, final Exception cause) - { - super(msg, cause); - } - } - - ///////////////////////////////////////////////////////////////////////////// - - /** - * Processes a user interface for inputing data into a form. - * - * @param formInstanceData provides the xml instance data if available. - * @param formInstanceDataName the name of the form instance data being modified. - * @param form the form to generate for - * @param out the writer to write the output to. - */ - public Session process(final Document formInstanceData, - final String formInstanceDataName, - final Form form, - final Writer out) - throws ProcessingException; - - /** - * Processes a user interface for inputing data into a form. - * - * @param session the session to use. - * @param out the writer to write the output to. - */ - public void process(final Session session, - final Writer out) - throws ProcessingException; -} diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java deleted file mode 100644 index f3d301aefb..0000000000 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.faces.context.FacesContext; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.web.app.Application; -import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.data.IDataContainer; -import org.alfresco.web.data.QuickSort; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Provides management of forms. - * - * @author Ariel Backenroth - */ -public final class FormsService -{ - private static final Log LOGGER = LogFactory.getLog(FormsService.class); - - private static final RenderingEngine[] RENDERING_ENGINES = new RenderingEngine[] - { - new FreeMarkerRenderingEngine(), - new XSLTRenderingEngine(), - new XSLFORenderingEngine() - }; - - private final ContentService contentService; - private final NodeService nodeService; - private final NamespaceService namespaceService; - private final SearchService searchService; - - private NodeRef contentFormsNodeRef; - private NodeRef webContentFormsNodeRef; - - /** instantiated using spring */ - public FormsService(final ContentService contentService, - final NodeService nodeService, - final NamespaceService namespaceService, - final SearchService searchService, - final PolicyComponent policyComponent) - { - this.contentService = contentService; - this.nodeService = nodeService; - this.namespaceService = namespaceService; - this.searchService = searchService; -// // WCM -// policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), -// WCMAppModel.TYPE_FORMFOLDER, -// new JavaBehaviour(this, -// "handleMoveFormFolder", -// Behaviour.NotificationFrequency.FIRST_EVENT)); -// policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), -// WCMAppModel.TYPE_FORMFOLDER, -// new JavaBehaviour(this, -// "handleDeleteFormFolder", -// Behaviour.NotificationFrequency.FIRST_EVENT)); - } - - /** - * Provides all registered rendering engines. - */ - public RenderingEngine[] getRenderingEngines() - { - return FormsService.RENDERING_ENGINES; - } - - /** - * Returns the rendering engine with the given name. - * - * @param name the name of the rendering engine. - * - * @return the rendering engine or null if not found. - */ - public RenderingEngine getRenderingEngine(final String name) - { - for (RenderingEngine re : this.getRenderingEngines()) - { - if (re.getName().equals(name)) - { - return re; - } - } - return null; - } - - public RenderingEngine guessRenderingEngine(final String fileName) - { - for (RenderingEngine re : this.getRenderingEngines()) - { - if (fileName.endsWith(re.getDefaultTemplateFileExtension())) - { - return re; - } - } - return null; - } - - /** - * @return the cached reference to the WCM Content Forms folder - */ - public NodeRef getContentFormsNodeRef() - { - if (this.contentFormsNodeRef == null) - { - final FacesContext fc = FacesContext.getCurrentInstance(); - final String xpath = (Application.getRootPath(fc) + "/" + - Application.getGlossaryFolderName(fc) + "/" + - Application.getContentFormsFolderName(fc)); - - this.contentFormsNodeRef = getNodeRefFromXPath(xpath); - } - return this.contentFormsNodeRef; - } - - /** - * @return the cached reference to the WCM Content Forms folder - */ - public NodeRef getWebContentFormsNodeRef() - { - if (this.webContentFormsNodeRef == null) - { - final FacesContext fc = FacesContext.getCurrentInstance(); - final String xpath = (Application.getRootPath(fc) + "/" + - Application.getGlossaryFolderName(fc) + "/" + - Application.getWebContentFormsFolderName(fc)); - - this.webContentFormsNodeRef = getNodeRefFromXPath(xpath); - } - return this.webContentFormsNodeRef; - } - - private NodeRef getNodeRefFromXPath(String xpath) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("locating noderef at " + xpath); - final List results = - searchService.selectNodes(this.nodeService.getRootNode(Repository.getStoreRef()), - xpath, - null, - namespaceService, - false); - return (results != null && results.size() == 1 ? results.get(0) : null); - } - - /** - * returns registered forms - * - * @return registered (ECM) forms - */ - public Collection getForms() - { -// // WCM -// final String query = -// "+ASPECT:\"" + WCMAppModel.ASPECT_FORM + -// "\" +PARENT:\"" + this.getContentFormsNodeRef() + "\""; -// -// return getForms(query); - return null; - } - - /** - * returns registered web forms - * - * @return registered (WCM) forms - */ - public Collection getWebForms() - { -// // WCM -// final String query = -// "+ASPECT:\"" + WCMAppModel.ASPECT_FORM + -// "\" +PARENT:\"" + this.getWebContentFormsNodeRef() + "\""; -// -// return getForms(query); - return null; - } - - private Collection getForms(String query) - { - final ResultSet rs = this.searchService.query(Repository.getStoreRef(), - SearchService.LANGUAGE_LUCENE, - query); - try - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("found " + rs.length() + " form definitions"); - final Collection result = new ArrayList(rs.length()); - for (final ResultSetRow row : rs) - { - result.add(this.getForm(row.getNodeRef())); - } - QuickSort sorter = new QuickSort((List)result, "name", true, IDataContainer.SORT_CASEINSENSITIVE); - sorter.sort(); - - return result; - } - finally - { - rs.close(); - } - } - - /** - * return the form by name or null if not found - * - * @return the form by name or null if not found - * @deprecated - */ - public Form getForm(final String name) - throws FormNotFoundException - { - final NodeRef result = this.nodeService.getChildByName(this.getContentFormsNodeRef(), - ContentModel.ASSOC_CONTAINS, - name); - if (result == null) - { - throw new FormNotFoundException(name); - } - return this.getForm(result); - } - - /** - * return the web form by name or null if not found - * - * @return the (WCM) form by name or null if not found - * @deprecated - */ - public Form getWebForm(final String name) - throws FormNotFoundException - { - final NodeRef result = this.nodeService.getChildByName(this.getWebContentFormsNodeRef(), - ContentModel.ASSOC_CONTAINS, - name); - if (result == null) - { - throw new FormNotFoundException(name); - } - return this.getForm(result); - } - - // WCM - /** - * Returns the form backed by the given NodeRef. The NodeRef should - * point to the schema for this form. - * - * @param nodeRef the node ref for the schema for the form - * @return the form for the given node ref. - */ - public Form getForm(final NodeRef nodeRef) - { -// // WCM -// if (!this.nodeService.hasAspect(nodeRef, WCMAppModel.ASPECT_FORM)) -// { -// throw new IllegalArgumentException("node " + nodeRef + " is not a form"); -// } -// final Form result = new FormImpl(nodeRef, this); -// if (LOGGER.isDebugEnabled()) -// LOGGER.debug("loaded form " + result + " for noderef " + nodeRef); -// return result; - return null; - } - - public FormInstanceData getFormInstanceData(final int version, final String avmPath) throws FormNotFoundException - { -// // WCM -// return this.getFormInstanceData(AVMNodeConverter.ToNodeRef(version, avmPath)); - return null; - } - - public FormInstanceData getFormInstanceData(final NodeRef nodeRef) throws FormNotFoundException - { -// // WCM -// final String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(); -// final WebProject webProject = new WebProject(avmPath); -// -// FormInstanceData fid = null; -// try -// { -// fid = new FormInstanceDataImpl(nodeRef, this, webProject); -// return fid; -// } -// catch (IllegalArgumentException iae) -// { -// // note: FormNotFoundException extends FileNotFoundException -// throw new FormNotFoundException(iae.getMessage()); -// } - return null; - } - - public Rendition getRendition(final int version, final String avmPath) - { -// // WCM -// return this.getRendition(AVMNodeConverter.ToNodeRef(version, avmPath)); - return null; - } - - public Rendition getRendition(final NodeRef nodeRef) - { - return new RenditionImpl(nodeRef, this); - } - -// // WCM -// public List getAssociatedWebProjects(final Form form) -// { -// final List formConfigurations = this.getFormConfigurations(form.getName()); -// if (LOGGER.isDebugEnabled()) -// { -// LOGGER.debug("found " + formConfigurations.size() + -// " web projects configured with " + form.getName()); -// } -// final List result = new ArrayList(formConfigurations.size()); -// for (final NodeRef ref : formConfigurations) -// { -// final List parents = this.nodeService.getParentAssocs(ref); -// assert parents.size() != 1 : ("expected only one parent for " + ref + -// " got " + parents.size()); -// result.add(new WebProject(parents.get(0).getParentRef())); -// } -// return result; -// } -// - // event handlers - - public void handleMoveFormFolder(final ChildAssociationRef oldChild, final ChildAssociationRef newChild) - { -// // WCM -// final String oldName = oldChild.getQName().getLocalName(); -// final String newName = newChild.getQName().getLocalName(); -// final List formConfigurations = this.getFormConfigurations(oldName); -// // find all webprojects that used the old name -// if (LOGGER.isDebugEnabled()) -// { -// LOGGER.debug("handling rename (" + oldName + -// " => " + newName + -// ") for " + formConfigurations.size()); -// } -// for (final NodeRef ref : formConfigurations) -// { -// this.nodeService.setProperty(ref, -// WCMAppModel.PROP_FORMNAME, -// newName); -// } - } - - public void handleDeleteFormFolder(final ChildAssociationRef childRef, - final boolean isArchivedNode) - { -// // WCM -// final String formName = childRef.getQName().getLocalName(); -// final List formConfigurations = this.getFormConfigurations(formName); -// for (final NodeRef ref : formConfigurations) -// { -// final List parents = this.nodeService.getParentAssocs(ref); -// assert parents.size() != 1 : ("expected only one parent for " + ref + -// " got " + parents.size()); -// final NodeRef parentRef = parents.get(0).getParentRef(); -// if (LOGGER.isDebugEnabled()) -// { -// -// LOGGER.debug("removing configuration for " + formName + -// " from web project " + this.nodeService.getProperty(parentRef, ContentModel.PROP_NAME)); -// } -// // ALF-3751: Validate this is the real form folder rather than a copy -// if (childRef.getParentRef().equals(parentRef)) -// { -// this.nodeService.removeChild(parentRef, ref); -// } -// } - } -// -// // WCM -// /** -// * Return the list of web project nodes that reference a form name in their model -// */ -// private List getFormConfigurations(final String formName) -// { -// final String query = -// "+TYPE:\"" + WCMAppModel.TYPE_WEBFORM + "\"" + -// " +@" + Repository.escapeQName(WCMAppModel.PROP_FORMNAME) + -// ":\"" + formName + "\""; -// final ResultSet rs = this.searchService.query(Repository.getStoreRef(), -// SearchService.LANGUAGE_LUCENE, -// query); -// try -// { -// if (LOGGER.isDebugEnabled()) -// { -// LOGGER.debug("query " + query + " returned " + rs.length() + " results"); -// } -// final List result = new ArrayList(rs.length()); -// for (final ResultSetRow row : rs) -// { -// result.add(row.getNodeRef()); -// } -// return result; -// } -// finally -// { -// rs.close(); -// } -// } -} diff --git a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java b/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java deleted file mode 100644 index 935e295284..0000000000 --- a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.SAXException; - -import freemarker.cache.TemplateLoader; -import freemarker.ext.dom.NodeModel; -import freemarker.template.Configuration; -import freemarker.template.SimpleDate; -import freemarker.template.SimpleHash; -import freemarker.template.SimpleNumber; -import freemarker.template.SimpleScalar; -import freemarker.template.SimpleSequence; -import freemarker.template.Template; -import freemarker.template.TemplateBooleanModel; -import freemarker.template.TemplateException; -import freemarker.template.TemplateExceptionHandler; -import freemarker.template.TemplateHashModel; -import freemarker.template.TemplateMethodModel; -import freemarker.template.TemplateModel; -import freemarker.template.TemplateModelException; - -/** - * Implementation of a form data renderer for processing xml instance data - * using a freemarker template. - * - * @author Ariel Backenroth - */ -public class FreeMarkerRenderingEngine - implements RenderingEngine -{ - - private static final Log LOGGER = LogFactory.getLog(FreeMarkerRenderingEngine.class); - - public FreeMarkerRenderingEngine() { } - - public String getName() { return "FreeMarker"; } - - public String getDefaultTemplateFileExtension() { return "ftl"; } - - /** - * Renders the rendition using the configured freemarker template. This - * provides a root map to the freemarker template which places the xml document, and - * a variable named alfresco at the root. the alfresco variable contains a hash of - * all parameters and all extension functions. - */ - public void render(final Map model, - final RenderingEngineTemplate ret, - final OutputStream out) - throws IOException, - RenderingEngine.RenderingException, - SAXException - { - - final Configuration cfg = new Configuration(); - cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); - cfg.setTemplateLoader(new TemplateLoader() - { - public void closeTemplateSource(final Object templateSource) - throws IOException - { - ((InputStream)templateSource).close(); - } - - public Object findTemplateSource(final String name) - throws IOException - { - LOGGER.debug("request to load template " + name); - -// // WCM -// final RenderingEngine.TemplateResourceResolver trr = (RenderingEngine.TemplateResourceResolver) -// model.get(RenderingEngineTemplateImpl.PROP_RESOURCE_RESOLVER); - final RenderingEngine.TemplateResourceResolver trr = null; - - return trr.resolve(name); - } - - public long getLastModified(final Object templateSource) - { - // no caching for now... - return System.currentTimeMillis(); - } - - public Reader getReader(final Object templateSource, final String encoding) - throws IOException - { - return new InputStreamReader((InputStream)templateSource); - } - }); - final Template t = new Template("freemarker_template", - new InputStreamReader(ret.getInputStream()), - cfg); - final TemplateHashModel rootModel = this.convertModel(model); - - // process the form - try - { - t.process(rootModel, new OutputStreamWriter(out)); - } - catch (final TemplateException te) - { - LOGGER.debug(te); - throw new RenderingEngine.RenderingException(te); - } - finally - { - out.flush(); - out.close(); - } - } - - private TemplateHashModel convertModel(final Map model) - { - final List rootModelObjects = new LinkedList(); - final SimpleHash result = new SimpleHash() - { - public TemplateModel get(final String key) - throws TemplateModelException - { - TemplateModel result = super.get(key); - if (result == null) - { - for (TemplateHashModel m : rootModelObjects) - { - result = m.get(key); - if (result != null) - { - break; - } - } - } - return result; - } - }; - for (final Map.Entry entry : model.entrySet()) - { - final QName qn = entry.getKey(); - if (qn.equals(RenderingEngine.ROOT_NAMESPACE)) - { - final TemplateModel m = this.convertValue(entry.getValue()); - if (m instanceof TemplateHashModel) - { - rootModelObjects.add((TemplateHashModel)m); - } - else - { - throw new IllegalArgumentException("root namespace values must be convertable to " + TemplateHashModel.class.getName() + - ". converted " + entry.getValue().getClass().getName() + - " to " + m.getClass().getName() + "."); - } - } -// // WCM -// else if (qn.equals(RenderingEngineTemplateImpl.PROP_RESOURCE_RESOLVER)) -// { -// continue; -// } - else - { - final String[] splitQName = QName.splitPrefixedQName(qn.toPrefixString()); - final String variableName = splitQName[1]; - - //insert - if (NamespaceService.DEFAULT_PREFIX.equals(splitQName[0])) - { - result.put(variableName, this.convertValue(entry.getValue())); - } - else - { - SimpleHash prefixModel = null; - final String prefix = splitQName[0]; - try - { - try - { - prefixModel = (SimpleHash)result.get(prefix); - } - catch (ClassCastException cce) - { - throw new ClassCastException("expected value of " + prefix + - " to be a " + SimpleHash.class.getName() + - ". found a " + result.get(prefix).getClass().getName()); - } - } - catch (TemplateModelException tme) - { - } - if (prefixModel == null) - { - prefixModel = new SimpleHash(); - result.put(prefix, prefixModel); - } - - prefixModel.put(variableName, - this.convertValue(entry.getValue())); - } - } - } - return result; - } - - private TemplateModel convertValue(final Object value) - { - LOGGER.debug("converting value " + value); - if (value == null) - { - return null; - } - else if (value.getClass().isArray()) - { - final Object[] array = (Object[])value; - LOGGER.debug("converting array of " + array.getClass().getComponentType() + - " size " + array.length); - final SimpleSequence result = new SimpleSequence(); - for (int i = 0; i < array.length; i++) - { - result.add(this.convertValue(array[i])); - } - return result; - } - else if (value instanceof String) - { - return new SimpleScalar((String)value); - } - else if (value instanceof Number) - { - return new SimpleNumber((Number)value); - } - else if (value instanceof Boolean) - { - return (Boolean)value ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; - } - else if (value instanceof Date) - { - return new SimpleDate(((Date)value), SimpleDate.DATETIME); - } - else if (value instanceof Document) - { - return NodeModel.wrap((Document)value); - } - else if (value instanceof Node) - { - return NodeModel.wrap((Node)value); - } - else if (value instanceof RenderingEngine.TemplateProcessorMethod) - { - return new TemplateMethodModel() - { - public Object exec(final List args) - throws TemplateModelException - { - try - { - LOGGER.debug("invoking template processor method " + value + - " with " + args.size() + " arguments"); - final Object result = ((TemplateProcessorMethod)value).exec(args.toArray(new Object[args.size()])); - return FreeMarkerRenderingEngine.this.convertValue(result); - } - catch (Exception e) - { - throw new TemplateModelException(e); - } - } - }; - } - else - { - throw new IllegalArgumentException("unable to convert value " + value.getClass().getName()); - } - } -} diff --git a/source/java/org/alfresco/web/forms/FreeMarkerUtil.java b/source/java/org/alfresco/web/forms/FreeMarkerUtil.java deleted file mode 100644 index eec98e37e4..0000000000 --- a/source/java/org/alfresco/web/forms/FreeMarkerUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.*; -import java.util.LinkedList; -import javax.xml.XMLConstants; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.xml.sax.SAXException; - -/** - * FreeMarker utility functions. - * - * @author Ariel Backenroth - */ -public class FreeMarkerUtil -{ - public static String buildNamespaceDeclaration(final Document xml) - { - final Element docEl = xml.getDocumentElement(); - final NamedNodeMap attributes = docEl.getAttributes(); - final StringBuilder result = new StringBuilder(); - for (int i = 0; i < attributes.getLength(); i++) - { - final Node a = attributes.item(i); - if (a.getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) - { - final String prefix = a.getNodeName().substring((XMLConstants.XMLNS_ATTRIBUTE + ":").length()); - final String uri = a.getNodeValue(); - if (result.length() != 0) - { - result.append(",\n"); - } - result.append("\"").append(prefix).append("\":\"").append(uri).append("\""); - } - } - return "<#ftl ns_prefixes={\n" + result.toString() + "}>\n"; - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/web/forms/RenderingEngine.java b/source/java/org/alfresco/web/forms/RenderingEngine.java deleted file mode 100644 index b48dd78448..0000000000 --- a/source/java/org/alfresco/web/forms/RenderingEngine.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.Map; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.service.namespace.QName; -import org.xml.sax.SAXException; - -/** - * Serializes the xml instance data collected by a form to a writer. - * - * @author Ariel Backenroth - */ -public interface RenderingEngine - extends Serializable -{ - ///////////////////////////////////////////////////////////////////////////// - - public static class RenderingException extends Exception - { - private static final long serialVersionUID = 6831222399250770060L; - - public RenderingException(final String msg) - { - super(msg); - } - - public RenderingException(final Exception cause) - { - super(cause); - } - - public RenderingException(final String msg, final Exception cause) - { - super(msg, cause); - } - } - - public static class TemplateNotFoundException extends AlfrescoRuntimeException - { - private static final long serialVersionUID = 3232973289475043471L; - - public TemplateNotFoundException(final String msg) - { - super(msg); - } - - public TemplateNotFoundException(final String msg, final Exception cause) - { - super(msg, cause); - } - } - - ///////////////////////////////////////////////////////////////////////////// - - public interface TemplateProcessorMethod - extends Serializable - { - public Object exec(final Object[] arguments) - throws Exception; - } - - ///////////////////////////////////////////////////////////////////////////// - - public interface TemplateResourceResolver - extends Serializable - { - public InputStream resolve(final String resourceName) - throws IOException; - } - - ///////////////////////////////////////////////////////////////////////////// - - public final static QName ROOT_NAMESPACE = - QName.createQName(null, "root_namespace"); - - /** - * Returns the rendering engines name. - * - * @return the name of the rendering engine. - */ - public String getName(); - - - /** - * Returns the default file extension for rendering engine templates for this - * rendering engine. - * - * @return the default file extension for rendering engine templates for this - * rendering engine. - */ - public String getDefaultTemplateFileExtension(); - - /** - * Renders the xml data in to a presentation format. - * - * @param model The model - * @param ret the rendering engine template - * @param out The output stream to write to - */ - public void render(final Map model, - final RenderingEngineTemplate ret, - final OutputStream out) - throws IOException, RenderingException, SAXException; -} diff --git a/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java b/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java deleted file mode 100644 index c463bee4c3..0000000000 --- a/source/java/org/alfresco/web/forms/RenderingEngineTemplate.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import org.alfresco.service.cmr.repository.NodeRef; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Serializable; -import java.util.Map; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Describes a template that is used for rendering form instance data. - * - * @author Ariel Backenroth - */ -public interface RenderingEngineTemplate - extends Serializable -{ - /** the name of the rendering engine template */ - public String getName(); - - /** the title of the rendering engine template */ - public String getTitle(); - - /** the description of the rendering engine template */ - public String getDescription(); - - /** the output path pattern for renditions */ - public String getOutputPathPattern(); - - /** - * Provides the rendering engine to use to process this template. - * - * @return the rendering engine to use to process this template. - */ - public RenderingEngine getRenderingEngine(); - - /** - * Provides an input stream to the rendering engine template. - * - * @return the input stream to the rendering engine template. - */ - public InputStream getInputStream() - throws IOException; - - /** - * Returns the output path for the rendition. - * - * @param formInstanceData the form instance data to use for - * processing the pattern. - * @param currentAVMPath the current path where the form is being created. - * @param name the name which is used in a pattern - * @return the output path for the rendition. - */ - public String getOutputPathForRendition(final FormInstanceData formInstanceData, - final String currentAVMPath, final String name); - - /** - * Returns the mimetype to use when generating content for this - * output method. - * - * @return the mimetype to use when generating content for this - * output method, such as text/html, text/xml, application/pdf. - */ - public String getMimetypeForRendition(); - - /** - * Produces a rendition of the provided formInstanceData. - * - * @param formInstanceData the form instance data for which to produce - * the rendition. - * @param renditionAVMPath the path to use for the rendition. - */ - public Rendition render(final FormInstanceData formInstanceData, - final String renditionAVMPath) - throws IOException, - SAXException, - RenderingEngine.RenderingException; - - /** - * Produces a rendition of the provided formInstanceData to an existing - * rendition. - * - * @param formInstanceData the form instance data for which to produce - * the rendition. - * @param rendition the rendition to rerender - */ - public void render(final FormInstanceData formInstanceData, - final Rendition rendition) - throws IOException, - SAXException, - RenderingEngine.RenderingException; -} diff --git a/source/java/org/alfresco/web/forms/Rendition.java b/source/java/org/alfresco/web/forms/Rendition.java deleted file mode 100644 index a1786e90fd..0000000000 --- a/source/java/org/alfresco/web/forms/Rendition.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Serializable; -import org.xml.sax.SAXException; - -/** - * Encapsulation of a rendition. - * - * @author Ariel Backenroth - */ -public interface Rendition - extends Serializable -{ - /** the name of this rendition */ - public String getName(); - - /** the description of this rendition */ - public String getDescription(); - - /** the path relative to the containing webapp */ - public String getWebappRelativePath(); - - /** the path relative to the sandbox */ - public String getSandboxRelativePath(); - - /** the primary form instance data used to generate this rendition */ - public FormInstanceData getPrimaryFormInstanceData() - throws FileNotFoundException; - - /** the primary form instance data used to generate this rendition (include deleted AVM nodes) */ - public FormInstanceData getPrimaryFormInstanceData(boolean includeDeleted) - throws FileNotFoundException; - - /** the rendering engine template that generated this rendition */ - public RenderingEngineTemplate getRenderingEngineTemplate(); - - /** the path to the contents of this rendition */ - public String getPath(); - - /** the url to the asset */ - public String getUrl(); - - /** the file type image for the rendition */ - public String getFileTypeImage(); - - /** the output stream for the rendition */ - public OutputStream getOutputStream(); - - /** the HTML label attribute for UI */ - public String getLabelAttribute(); - - /** the HTML description attribute for UI */ - public String getDescriptionAttribute(); - - /** regenerates the contents of this rendition using the primary form instance data */ - public void regenerate() - throws IOException, - RenderingEngine.RenderingException, - SAXException; - - /** regenerates the contents of this rendition using the provided form instance data*/ - public void regenerate(final FormInstanceData formInstanceData) - throws IOException, - RenderingEngine.RenderingException, - SAXException; -} diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java deleted file mode 100644 index f2d9c0b8c0..0000000000 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; - -import javax.faces.context.FacesContext; - -import org.alfresco.repo.web.scripts.FileTypeImageUtils; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.ui.common.Utils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.xml.sax.SAXException; - -/** - * Encapsulation of a rendition. - * - * @author Ariel Backenroth - */ -/* package */ class RenditionImpl - implements Rendition -{ - - private static final long serialVersionUID = -342658762155499039L; - - private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class); - - private final NodeRef nodeRef; - transient private FormsService formsService; - transient private RenderingEngineTemplate renderingEngineTemplate; - private String descriptionAttribute; - - /* package */ RenditionImpl(final NodeRef nodeRef, final FormsService formsService) - { - if (nodeRef == null) - { - throw new NullPointerException(); - } - if (formsService == null) - { - throw new NullPointerException(); - } -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// if (!avmService.hasAspect(AVMNodeConverter.ToAVMVersionPath(nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(), -// WCMAppModel.ASPECT_RENDITION)) -// { -// throw new IllegalArgumentException("node " + nodeRef + -// " does not have aspect " + WCMAppModel.ASPECT_RENDITION); -// } - this.nodeRef = nodeRef; - this.formsService = formsService; - } - - /* package */ RenditionImpl(final int version, - final String avmPath, - final FormsService formsService) - { -// // WCM -// this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService); - this(null, formsService); - } - - private FormsService getFormsService() - { - if (formsService == null) - { - formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService"); - } - return formsService; - } - - - /** the name of this rendition */ - public String getName() - { -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// ContentModel.PROP_NAME).getStringValue(); -// // WCM -// return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1]; - return null; - } - - /** the description of this rendition */ - public String getDescription() - { -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMService(); -// return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// ContentModel.PROP_DESCRIPTION).getStringValue(); - return null; - } - - public String getWebappRelativePath() - { -// // WCM -// return AVMUtil.getWebappRelativePath(this.getPath()); - return null; - } - - public String getSandboxRelativePath() - { -// // WCM -// return AVMUtil.getSandboxRelativePath(this.getPath()); - return null; - } - - public FormInstanceData getPrimaryFormInstanceData() - throws FileNotFoundException - { - return getPrimaryFormInstanceData(false); - } - - public FormInstanceData getPrimaryFormInstanceData(boolean includeDeleted) - throws FileNotFoundException - { -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); -// final String fidAVMStoreRelativePath = (String) -// avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA).getValue(DataTypeDefinition.TEXT); -// String avmStore = AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); -// avmStore = avmStore.substring(0, avmStore.indexOf(':')); -// final String path = avmStore + ':' + fidAVMStoreRelativePath; -// if (avmService.lookup(-1, path, includeDeleted) == null) -// { -// throw new FileNotFoundException("unable to find primary form instance data " + path); -// } -// return this.getFormsService().getFormInstanceData(-1, path); - return null; - } - - /** the rendering engine template that generated this rendition */ - public RenderingEngineTemplate getRenderingEngineTemplate() - { -// // WCM -// if (this.renderingEngineTemplate == null) -// { -// final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); -// PropertyValue pv = -// avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE); -// if (pv == null) -// { -// LOGGER.debug("property " + WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE + -// " not set on " + this.getPath()); -// return null; -// } -// -// final NodeRef retNodeRef = (NodeRef)pv.getValue(DataTypeDefinition.NODE_REF); -// if (retNodeRef == null) -// { -// LOGGER.debug("unable to locate parent rendering engine template of rendition " + -// this.getPath()); -// return null; -// } -// pv = avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(), -// AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(), -// WCMAppModel.PROP_PARENT_RENDITION_PROPERTIES); -// if (pv == null) -// { -// LOGGER.debug("property " + WCMAppModel.PROP_PARENT_RENDITION_PROPERTIES + -// " not set on " + this.getPath()); -// return null; -// } -// -// final NodeRef rpNodeRef = (NodeRef)pv.getValue(DataTypeDefinition.NODE_REF); -// if (rpNodeRef == null) -// { -// LOGGER.debug("unable to locate parent rendering engine template properties of rendition " + -// this.getPath()); -// return null; -// } -// this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef, this.getFormsService()); -// } -// return this.renderingEngineTemplate; - return null; - } - - /** the node ref containing the contents of this rendition */ - public NodeRef getNodeRef() - { - return this.nodeRef; - } - - public String getPath() - { -// // WCM -// return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(); - return null; - } - - public String getUrl() - { -// // WCM -// return AVMUtil.getPreviewURI(this.getPath()); - return null; - } - - public String getFileTypeImage() - { - return FileTypeImageUtils.getFileTypeImage(this.getName(), false); - } - - public OutputStream getOutputStream() - { -// // WCM -// final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService(); -// final Pair p = AVMNodeConverter.ToAVMVersionPath(this.nodeRef); -// return (avmService.lookup(p.getFirst(), p.getSecond()) == null -// ? avmService.createFile(AVMNodeConverter.SplitBase(p.getSecond())[0], -// AVMNodeConverter.SplitBase(p.getSecond())[1]) -// : avmService.getFileOutputStream(this.getPath())); - return null; - } - - public void regenerate() - throws IOException, - RenderingEngine.RenderingException, - SAXException - { - this.regenerate(this.getPrimaryFormInstanceData()); - } - - @Deprecated - public void regenerate(final FormInstanceData formInstanceData) - throws IOException, - RenderingEngine.RenderingException, - SAXException - { - this.getRenderingEngineTemplate().render(formInstanceData, this); - } - - private ServiceRegistry getServiceRegistry() - { - final FacesContext fc = FacesContext.getCurrentInstance(); - return Repository.getServiceRegistry(fc); - } - - public int hashCode() - { - return this.getPath().hashCode(); - } - - public boolean equals(final Object other) - { - return (other instanceof RenditionImpl && - this.getNodeRef().equals(((RenditionImpl)other).getNodeRef())); - } - - public String toString() - { - return (this.getClass().getName() + - "{path : " + this.getPath() + - ", rendering_engine_template : " + this.getRenderingEngineTemplate() + - "}"); - } - - public String getDescriptionAttribute() - { - if (StringUtils.isEmpty(this.descriptionAttribute)) - { - this.descriptionAttribute = buildDescriptionAttribute(); - } - return this.descriptionAttribute; - } - - public String getLabelAttribute() - { - StringBuilder builder = new StringBuilder(""); - builder.append(Utils.encode(this.getName())); - builder.append(""); - return builder.toString(); - } - - private String buildDescriptionAttribute() - { - int hashCode = hashCode(); - String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath(); - StringBuilder attribute = new StringBuilder(255); - attribute.append(""); - attribute.append("\"").append(getName()).append("\""); - attribute.append("").append(getDescription()).append(""); - return attribute.toString(); - } -} diff --git a/source/java/org/alfresco/web/forms/XSLFORenderingEngine.java b/source/java/org/alfresco/web/forms/XSLFORenderingEngine.java deleted file mode 100644 index 8b3ddd0f98..0000000000 --- a/source/java/org/alfresco/web/forms/XSLFORenderingEngine.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; - -import javax.xml.transform.sax.SAXResult; - -import org.alfresco.service.namespace.QName; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.fop.apps.FOPException; -import org.apache.fop.apps.FOUserAgent; -import org.apache.fop.apps.Fop; -import org.apache.fop.apps.FopFactory; -import org.apache.fop.apps.MimeConstants; -import org.xml.sax.SAXException; - -/** - * A rendering engine which uses xsl-fo templates to generate renditions of form - * instance data. - * - * @author Ariel Backenroth - */ -public class XSLFORenderingEngine extends XSLTRenderingEngine -{ - - private static final Log LOGGER = LogFactory.getLog(XSLFORenderingEngine.class); - - private static final Map MIME_TYPES = new HashMap(); - static - { - MIME_TYPES.put(MimeConstants.MIME_PDF, MimeConstants.MIME_PDF); - - MIME_TYPES.put(MimeConstants.MIME_POSTSCRIPT, MimeConstants.MIME_POSTSCRIPT); - MIME_TYPES.put(MimeConstants.MIME_EPS, MimeConstants.MIME_POSTSCRIPT); - - MIME_TYPES.put(MimeConstants.MIME_PLAIN_TEXT, MimeConstants.MIME_PLAIN_TEXT); - - MIME_TYPES.put(MimeConstants.MIME_RTF, MimeConstants.MIME_RTF); - MIME_TYPES.put(MimeConstants.MIME_RTF_ALT1, MimeConstants.MIME_RTF); - MIME_TYPES.put(MimeConstants.MIME_RTF_ALT2, MimeConstants.MIME_RTF); - - MIME_TYPES.put(MimeConstants.MIME_MIF, MimeConstants.MIME_MIF); - MIME_TYPES.put("application/x-mif", MimeConstants.MIME_MIF); - - MIME_TYPES.put(MimeConstants.MIME_SVG, MimeConstants.MIME_SVG); - - // looks like a dependency is missing - removing for now - // MIME_TYPES.put(MimeConstants.MIME_GIF, MimeConstants.MIME_GIF); - MIME_TYPES.put(MimeConstants.MIME_PNG, MimeConstants.MIME_PNG); - MIME_TYPES.put(MimeConstants.MIME_JPEG, MimeConstants.MIME_JPEG); - MIME_TYPES.put(MimeConstants.MIME_TIFF, MimeConstants.MIME_TIFF); - }; - - public XSLFORenderingEngine() - { - super(); - } - - public String getName() - { - return "XSL-FO"; - } - - public String getDefaultTemplateFileExtension() - { - return "fo"; - } - - @Override - public void render(final Map model, final RenderingEngineTemplate ret, final OutputStream out) - throws IOException, RenderingEngine.RenderingException, SAXException - { - - String mimetype = MIME_TYPES.get(ret.getMimetypeForRendition()); - if (mimetype == null) { throw new RenderingEngine.RenderingException("mimetype " - + ret.getMimetypeForRendition() + " is not supported by " + this.getName()); } - try - { - final FopFactory fopFactory = FopFactory.newInstance(); - final FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); - final Fop fop = fopFactory.newFop(mimetype, foUserAgent, out); - // Resulting SAX events (the generated FO) must be piped through to - // FOP - super.render(model, ret, new SAXResult(fop.getDefaultHandler())); - - } - catch (FOPException fope) - { - throw new RenderingEngine.RenderingException(fope); - } - finally - { - out.close(); - } - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java b/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java deleted file mode 100644 index bd25514b29..0000000000 --- a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java +++ /dev/null @@ -1,526 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.URIResolver; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.alfresco.service.namespace.QName; -import org.alfresco.util.XMLUtil; -import org.apache.bsf.BSFManager; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xml.dtm.ref.DTMNodeProxy; -import org.apache.xml.utils.Constants; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.traversal.NodeFilter; -import org.w3c.dom.traversal.NodeIterator; -import org.xml.sax.SAXException; - -/** - * A rendering engine which uses xsl templates to render renditions of - * form instance data. - * - * @author Ariel Backenroth - */ -public class XSLTRenderingEngine - implements RenderingEngine -{ - - ///////////////////////////////////////////////////////////////////////////// - - public static class ProcessorMethodInvoker - { - private final static HashMap PROCESSOR_METHODS = - new HashMap(); - - public ProcessorMethodInvoker() { } - - private Object[] convertArguments(final Object[] arguments) - { - final List result = new LinkedList(); - for (int i = 0; i < arguments.length; i++) - { - LOGGER.debug("args[" + i + "] = " + arguments[i] + - "(" + (arguments[i] != null - ? arguments[i].getClass().getName() - : "null") + ")"); - if (arguments[i] == null || - arguments[i] instanceof String || - arguments[i] instanceof Number) - { - result.add(arguments[i]); - } - else if (arguments[i] instanceof DTMNodeProxy) - { - result.add(((DTMNodeProxy)arguments[i]).getStringValue()); - } - else if (arguments[i] instanceof Node) - { - LOGGER.debug("node type is " + ((Node)arguments[i]).getNodeType() + - " content " + ((Node)arguments[i]).getTextContent()); - result.add(((Node)arguments[i]).getNodeValue()); - } - else if (arguments[i] instanceof NodeIterator) - { - Node n = ((NodeIterator)arguments[i]).nextNode(); - while (n != null) - { - LOGGER.debug("iterated to node " + n + " type " + n.getNodeType() + - " value " + n.getNodeValue() + - " tc " + n.getTextContent() + - " nn " + n.getNodeName() + - " sv " + ((org.apache.xml.dtm.ref.DTMNodeProxy)n).getStringValue()); - if (n instanceof DTMNodeProxy) - { - result.add(((DTMNodeProxy)n).getStringValue()); - } - else - { - result.add(n); - } - n = ((NodeIterator)arguments[i]).nextNode(); - } - } - else - { - throw new IllegalArgumentException("unable to convert argument " + arguments[i]); - } - } - - return result.toArray(new Object[result.size()]); - } - - public Object invokeMethod(final String id, Object[] arguments) - throws Exception - { - if (!PROCESSOR_METHODS.containsKey(id)) - { - throw new NullPointerException("unable to find method " + id); - } - - final TemplateProcessorMethod method = PROCESSOR_METHODS.get(id); - arguments = this.convertArguments(arguments); - LOGGER.debug("invoking " + id + " with " + arguments.length); - - Object result = method.exec(arguments); - LOGGER.debug(id + " returned a " + result); - if (result == null) - { - return null; - } - else if (result.getClass().isArray() && - Node.class.isAssignableFrom(result.getClass().getComponentType())) - { - LOGGER.debug("converting " + result + " to a node iterator"); - final Node[] array = (Node[])result; - return new NodeIterator() - { - private int index = 0; - private boolean detached = false; - - public void detach() - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("detaching NodeIterator"); - this.detached = true; - } - - public boolean getExpandEntityReferences() { return true; } - public int getWhatToShow() { return NodeFilter.SHOW_ALL; } - - public Node getRoot() - { - return (array.length == 0 - ? null - : array[0].getOwnerDocument().getDocumentElement()); - } - - public NodeFilter getFilter() - { - return new NodeFilter() - { - public short acceptNode(final Node n) - { - return NodeFilter.FILTER_ACCEPT; - } - }; - } - - public Node nextNode() - throws DOMException - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("NodeIterator.nextNode(" + index + ")"); - if (this.detached) - throw new DOMException(DOMException.INVALID_STATE_ERR, null); - return index == array.length ? null : array[index++]; - } - - public Node previousNode() - throws DOMException - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("NodeIterator.previousNode(" + index + ")"); - if (this.detached) - throw new DOMException(DOMException.INVALID_STATE_ERR, null); - return index == -1 ? null : array[index--]; - } - }; - } - else if (result instanceof String || - result instanceof Number || - result instanceof Node) - { - LOGGER.debug("returning " + result + " as is"); - return result; - } - else - { - throw new IllegalArgumentException("unable to convert " + result.getClass().getName()); - } - } - } - - ///////////////////////////////////////////////////////////////////////////// - - private static final Log LOGGER = LogFactory.getLog(XSLTRenderingEngine.class); - - public XSLTRenderingEngine() { } - - public String getName() { return "XSLT"; } - - public String getDefaultTemplateFileExtension() { return "xsl"; } - - /** - * Adds a script element to the xsl which makes static methods on this - * object available to the xsl tempalte. - * - * @param xslTemplate the xsl template - */ - protected List addScripts(final Map model, - final Document xslTemplate) - { - final Map>> methods = - new HashMap>>(); - for (final Map.Entry entry : model.entrySet()) - { - if (entry.getValue() instanceof TemplateProcessorMethod) - { - final String prefix = QName.splitPrefixedQName(entry.getKey().toPrefixString())[0]; - final QName qn = QName.createQName(entry.getKey().getNamespaceURI(), - prefix); - if (!methods.containsKey(qn)) - { - methods.put(qn, new LinkedList()); - } - methods.get(qn).add(entry); - } - } - - final Element docEl = xslTemplate.getDocumentElement(); - final String XALAN_NS = Constants.S_BUILTIN_EXTENSIONS_URL; - final String XALAN_NS_PREFIX = "xalan"; - docEl.setAttribute("xmlns:" + XALAN_NS_PREFIX, XALAN_NS); - - final Set excludePrefixes = new HashSet(); - if (docEl.hasAttribute("exclude-result-prefixes")) - { - excludePrefixes.addAll(Arrays.asList(docEl.getAttribute("exclude-result-prefixes").split(" "))); - } - excludePrefixes.add(XALAN_NS_PREFIX); - - final List result = new LinkedList(); - for (QName ns : methods.keySet()) - { - final String prefix = ns.getLocalName(); - docEl.setAttribute("xmlns:" + prefix, ns.getNamespaceURI()); - excludePrefixes.add(prefix); - - final Element compEl = xslTemplate.createElementNS(XALAN_NS, - XALAN_NS_PREFIX + ":component"); - compEl.setAttribute("prefix", prefix); - docEl.appendChild(compEl); - String functionNames = null; - final Element scriptEl = xslTemplate.createElementNS(XALAN_NS, - XALAN_NS_PREFIX + ":script"); - scriptEl.setAttribute("lang", "javascript"); - final StringBuilder js = - new StringBuilder("var _xsltp_invoke = java.lang.Class.forName('" + ProcessorMethodInvoker.class.getName() + - "').newInstance();\n" + - "function _xsltp_to_java_array(js_array) {\n" + - "var java_array = java.lang.reflect.Array.newInstance(java.lang.Object, js_array.length);\n" + - "for (var i = 0; i < js_array.length; i++) { java_array[i] = js_array[i]; }\n" + - "return java_array; }\n"); - for (final Map.Entry entry : methods.get(ns)) - { - if (functionNames == null) - { - functionNames = entry.getKey().getLocalName(); - } - else - { - functionNames += " " + entry.getKey().getLocalName(); - } - final String id = entry.getKey().getLocalName() + entry.getValue().hashCode(); - js.append("function " + entry.getKey().getLocalName() + - "() { return _xsltp_invoke.invokeMethod('" + id + - "', _xsltp_to_java_array(arguments)); }\n"); - ProcessorMethodInvoker.PROCESSOR_METHODS.put(id, (TemplateProcessorMethod)entry.getValue()); - result.add(id); - } - LOGGER.debug("generated JavaScript bindings:\n" + js); - scriptEl.appendChild(xslTemplate.createTextNode(js.toString())); - compEl.setAttribute("functions", functionNames); - compEl.appendChild(scriptEl); - } - docEl.setAttribute("exclude-result-prefixes", - StringUtils.join(excludePrefixes.toArray(new String[excludePrefixes.size()]), " ")); - return result; - } - - /** - * Adds the specified parameters to the xsl template as variables within the - * alfresco namespace. - * - * @param model the variables to place within the xsl template - * @param xslTemplate the xsl template - */ - protected void addParameters(final Map model, - final Document xslTemplate) - { - final Element docEl = xslTemplate.getDocumentElement(); - final String XSL_NS = docEl.getNamespaceURI(); - final String XSL_NS_PREFIX = docEl.getPrefix(); - - for (Map.Entry e : model.entrySet()) - { - if (RenderingEngine.ROOT_NAMESPACE.equals(e.getKey())) - { - continue; - } - final Element el = xslTemplate.createElementNS(XSL_NS, XSL_NS_PREFIX + ":variable"); - el.setAttribute("name", e.getKey().toPrefixString()); - final Object o = e.getValue(); - if (o instanceof String || o instanceof Number || o instanceof Boolean) - { - el.appendChild(xslTemplate.createTextNode(o.toString())); - docEl.insertBefore(el, docEl.getFirstChild()); - } - } - } - - protected Source getXMLSource(final Map model) - { - if (!model.containsKey(RenderingEngine.ROOT_NAMESPACE)) - { - return null; - } - final Object o = model.get(RenderingEngine.ROOT_NAMESPACE); - if (!(o instanceof Document)) - { - throw new IllegalArgumentException("expected root namespace object to be a " + Document.class.getName() + - ". found a " + o.getClass().getName()); - } - return new DOMSource((Document)o); - } - - public void render(final Map model, - final RenderingEngineTemplate ret, - final OutputStream out) - throws IOException, - RenderingEngine.RenderingException, - SAXException - { - this.render(model, ret, new StreamResult(out)); - } - - public void render(final Map model, - final RenderingEngineTemplate ret, - final Result result) - throws IOException, - RenderingEngine.RenderingException, - SAXException - { - System.setProperty("org.apache.xalan.extensions.bsf.BSFManager", - BSFManager.class.getName()); - Document xslTemplate = null; - try - { - xslTemplate = XMLUtil.parse(ret.getInputStream()); - } - catch (final SAXException sax) - { - throw new RenderingEngine.RenderingException(sax); - } - this.addScripts(model, xslTemplate); - this.addParameters(model, xslTemplate); - - final LinkedList errors = new LinkedList(); - final ErrorListener errorListener = new ErrorListener() - { - public void error(final TransformerException te) - throws TransformerException - { - LOGGER.debug("error " + te.getMessageAndLocation()); - errors.add(te); - } - - public void fatalError(final TransformerException te) - throws TransformerException - { - LOGGER.debug("fatalError " + te.getMessageAndLocation()); - throw te; - } - - public void warning(final TransformerException te) - throws TransformerException - { - LOGGER.debug("warning " + te.getMessageAndLocation()); - errors.add(te); - } - }; - - // create a uri resolver to resolve document() calls to the virtualized - // web application - final URIResolver uriResolver = new URIResolver() - { - public Source resolve(final String href, String base) - throws TransformerException - { - LOGGER.debug("request to resolve href " + href + - " using base " + base); -// // WCM -// final RenderingEngine.TemplateResourceResolver trr = (RenderingEngine.TemplateResourceResolver) -// model.get(RenderingEngineTemplateImpl.PROP_RESOURCE_RESOLVER); - final RenderingEngine.TemplateResourceResolver trr = null; - - InputStream in = null; - try - { - in = trr.resolve(href); - } - catch (Exception e) - { - throw new TransformerException("unable to load " + href, e); - } - - if (in == null) - { - throw new TransformerException("unable to resolve href " + href); - } - - try - { - final Document d = XMLUtil.parse(in); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("loaded " + XMLUtil.toString(d)); - return new DOMSource(d); - } - catch (Exception e) - { - throw new TransformerException("unable to load " + href, e); - } - } - }; - - Source xmlSource = this.getXMLSource(model); - - Transformer t = null; - try - { - final TransformerFactory tf = TransformerFactory.newInstance(); - tf.setErrorListener(errorListener); - tf.setURIResolver(uriResolver); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("xslTemplate: \n" + XMLUtil.toString(xslTemplate)); - } - - t = tf.newTransformer(new DOMSource(xslTemplate)); - - if (errors.size() != 0) - { - final StringBuilder msg = new StringBuilder("errors encountered creating tranformer ... \n"); - for (TransformerException te : errors) - { - msg.append(te.getMessageAndLocation()).append("\n"); - } - throw new RenderingEngine.RenderingException(msg.toString()); - } - - t.setErrorListener(errorListener); - t.setURIResolver(uriResolver); - t.setParameter("versionParam", "2.0"); - } - catch (TransformerConfigurationException tce) - { - LOGGER.error(tce); - throw new RenderingEngine.RenderingException(tce); - } - - try - { - t.transform(xmlSource, result); - } - catch (TransformerException te) - { - LOGGER.error(te.getMessageAndLocation()); - throw new RenderingEngine.RenderingException(te); - } - catch (Exception e) - { - LOGGER.error("unexpected error " + e); - throw new RenderingEngine.RenderingException(e); - } - - if (errors.size() != 0) - { - final StringBuilder msg = new StringBuilder("errors encountered during transformation ... \n"); - for (TransformerException te : errors) - { - msg.append(te.getMessageAndLocation()).append("\n"); - } - throw new RenderingEngine.RenderingException(msg.toString()); - } - } -} diff --git a/source/java/org/alfresco/web/forms/xforms/FormBuilderException.java b/source/java/org/alfresco/web/forms/xforms/FormBuilderException.java deleted file mode 100644 index a5c9d4e62d..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/FormBuilderException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms.xforms; - - -/** - * This exception is thrown when implementations of SchemaFormBuilder - * encounters an error building a form. - * - * @author Brian Dueck - */ -public class FormBuilderException - extends Exception -{ - - /** - * Creates a new instance of FormBuilderException without detail message. - */ - public FormBuilderException() { } - - /** - * Constructs an instance of FormBuilderException with the specified detail message. - * - * @param msg the detail message. - */ - public FormBuilderException(String msg) - { - super(msg); - } - - /** - * Constructs an instance of FormBuilderException with the specified root exception. - * - * @param x The root exception. - */ - public FormBuilderException(Exception x) - { - super(x); - } - - /** - * Constructs an instance of FormBuilderException with the specified root exception. - * - * @param msg the detail message. - * @param x The root exception. - */ - public FormBuilderException(String msg, Exception x) - { - super(msg, x); - } -} diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java b/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java deleted file mode 100644 index 8c3d81472a..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java +++ /dev/null @@ -1,3401 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms.xforms; - -import java.io.Serializable; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Stack; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.regex.Pattern; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.Pair; -import org.alfresco.web.app.Application; -import org.alfresco.util.XMLUtil; -import org.apache.commons.jxpath.JXPathContext; -import org.apache.commons.jxpath.Pointer; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xerces.impl.xs.SchemaSymbols; -import org.apache.xerces.xs.StringList; -import org.apache.xerces.xs.XSAnnotation; -import org.apache.xerces.xs.XSAttributeDeclaration; -import org.apache.xerces.xs.XSAttributeUse; -import org.apache.xerces.xs.XSComplexTypeDefinition; -import org.apache.xerces.xs.XSConstants; -import org.apache.xerces.xs.XSElementDeclaration; -import org.apache.xerces.xs.XSModel; -import org.apache.xerces.xs.XSModelGroup; -import org.apache.xerces.xs.XSMultiValueFacet; -import org.apache.xerces.xs.XSObject; -import org.apache.xerces.xs.XSObjectList; -import org.apache.xerces.xs.XSParticle; -import org.apache.xerces.xs.XSSimpleTypeDefinition; -import org.apache.xerces.xs.XSTerm; -import org.apache.xerces.xs.XSTypeDefinition; -import org.chiba.xml.dom.DOMUtil; -import org.chiba.xml.ns.NamespaceConstants; -import org.chiba.xml.ns.NamespaceResolver; -import org.w3c.dom.Attr; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -/** - * An abstract implementation of the Schema2XForms interface allowing - * an XForm to be automatically generated for an XML Schema definition. - * This abstract class implements the buildForm and buildFormAsString methods - * and associated helper but relies on concrete subclasses to implement other - * required interface methods (createXXX, startXXX, and endXXX methods). - * - * @author $Author: unl $ - */ -public class Schema2XForms implements Serializable -{ - private static final long serialVersionUID = -2751398323635817643L; - - ///////////////////////////////////////////////////////////////////////////// - - public enum SubmitMethod - { - POST("post"), - GET("get"), - PUT("put"), - FORM_DATA_POST("form-data-post"), - URL_ENCODED_POST("urlencoded-post"); - - private final String value; - - SubmitMethod(final String value) - { - this.value = value; - } - - public String toString() - { - return this.value; - } - } - - ///////////////////////////////////////////////////////////////////////////// - - private final static Log LOGGER = LogFactory.getLog(Schema2XForms.class); - - private static final Pattern repeatableNamePattern = Pattern.compile("\\[.+\\]"); - - private final static int LONG_LIST_SIZE = 5; - - private final String action; - private final SubmitMethod submitMethod; - private final String base; - private final boolean formatCaption; - @SuppressWarnings("unchecked") - private final Stack parentStack = new Stack(); - - /** - * generic counter -> replaced by an hashMap with: - * keys: name of the elements - * values: "Long" representing the counter for this element - */ - private final Map counter = new HashMap(); - private String targetNamespace; - - /** - * each entry is keyed by the type name - * value is an ArrayList that contains the XSTypeDefinition's which - * are compatible with the specific type. Compatible means that - * can be used as a substituted type using xsi:type - * In order for it to be compatible, it cannot be abstract, and - * it must be derived by extension. - * The ArrayList does not contain its own type + has the other types only once - */ - private TreeMap> typeTree; - - /** - * Creates a new Schema2XForms object. - * - * @param action _UNDOCUMENTED_ - * @param submitMethod _UNDOCUMENTED_ - * @param formatCaption - */ - public Schema2XForms(final String action, - final SubmitMethod submitMethod, - final String base, final boolean formatCaption) - { - reset(); - - this.formatCaption = formatCaption; - this.action = action; - this.submitMethod = submitMethod; - this.base = base; - } - - /** - * Generate the XForm based on a user supplied XML Schema. - * - * @param instanceDocument The document source for the XML Schema. - * @param schemaDocument Schema document - * @param rootElementName Name of the root element - * @param resourceBundle Strings to use - * @return The Document containing the XForm. - * @throws org.chiba.tools.schemabuilder.FormBuilderException - * If an error occurs building the XForm. - */ - public Pair buildXForm(final Document instanceDocument, - final Document schemaDocument, - String rootElementName, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - final XSModel schema = SchemaUtil.parseSchema(schemaDocument, true); - this.typeTree = SchemaUtil.buildTypeTree(schema); - - //refCounter = 0; - this.counter.clear(); - - final Document xformsDocument = this.createFormTemplate(rootElementName); - - //find form element: last element created - final Element formSection = (Element) - xformsDocument.getDocumentElement().getLastChild(); - final Element modelSection = (Element) - xformsDocument.getDocumentElement().getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, - "model").item(0); - - //add XMLSchema if we use schema types - final Element importedSchemaDocumentElement = (Element) - xformsDocument.importNode(schemaDocument.getDocumentElement(), true); - importedSchemaDocumentElement.setAttributeNS(null, "id", "schema-1"); - - NodeList nl = importedSchemaDocumentElement.getChildNodes(); - boolean hasExternalSchema = false; - - for (int i = 0; i < nl.getLength(); i++) - { - Node current = nl.item(i); - if (current.getNamespaceURI() != null && current.getNamespaceURI().equals(NamespaceConstants.XMLSCHEMA_NS)) - { - String localName = current.getLocalName(); - if (localName.equals("include") || localName.equals("import")) - { - hasExternalSchema = true; - break; - } - } - } - - // ALF-8105 / ETWOTWO-1384: Only embed the schema if it does not reference externals - if (!hasExternalSchema) - { - modelSection.appendChild(importedSchemaDocumentElement); - } - - //check if target namespace - final StringList schemaNamespaces = schema.getNamespaces(); - final HashMap schemaNamespacesMap = new HashMap(); - if (schemaNamespaces.getLength() != 0) - { - // will return null if no target namespace was specified - this.targetNamespace = schemaNamespaces.item(0); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[buildXForm] using targetNamespace " + this.targetNamespace); - - for (int i = 0; i < schemaNamespaces.getLength(); i++) - { - if (schemaNamespaces.item(i) == null) - { - continue; - } - final String prefix = addNamespace(xformsDocument.getDocumentElement(), - schemaDocument.lookupPrefix(schemaNamespaces.item(i)), - schemaNamespaces.item(i)); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[buildXForm] adding namespace " + schemaNamespaces.item(i) + - " with prefix " + prefix + - " to xform and default instance element"); - } - schemaNamespacesMap.put(prefix, schemaNamespaces.item(i)); - } - } - - //if target namespace & we use the schema types: add it to form ns declarations -// if (this.targetNamespace != null && this.targetNamespace.length() != 0) -// envelopeElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, -// "xmlns:schema", -// this.targetNamespace); - - - final XSElementDeclaration rootElementDecl = - schema.getElementDeclaration(rootElementName, this.targetNamespace); - if (rootElementDecl == null) - { - throw new FormBuilderException("Invalid root element tag name [" - + rootElementName - + ", targetNamespace = " - + this.targetNamespace - + "]"); - } - - rootElementName = this.getElementName(rootElementDecl, xformsDocument); - final Element instanceElement = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":instance"); - modelSection.appendChild(instanceElement); - this.setXFormsId(instanceElement); - - final Element defaultInstanceDocumentElement = xformsDocument.createElement(rootElementName); - addNamespace(defaultInstanceDocumentElement, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, - NamespaceConstants.XMLSCHEMA_INSTANCE_NS); - if (this.targetNamespace != null) - { - final String targetNamespacePrefix = schemaDocument.lookupPrefix(this.targetNamespace); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[buildXForm] adding target namespace " + this.targetNamespace + - " with prefix " + targetNamespacePrefix + - " to xform and default instance element"); - } - - addNamespace(defaultInstanceDocumentElement, - targetNamespacePrefix, - this.targetNamespace); - addNamespace(xformsDocument.getDocumentElement(), - targetNamespacePrefix, - this.targetNamespace); - } - - Element prototypeInstanceElement = null; - if (instanceDocument == null || instanceDocument.getDocumentElement() == null) - { - instanceElement.appendChild(defaultInstanceDocumentElement); - } - else - { - Element instanceDocumentElement = instanceDocument.getDocumentElement(); - if (!instanceDocumentElement.getNodeName().equals(rootElementName)) - { - throw new IllegalArgumentException("instance document root tag name invalid. " + - "expected " + rootElementName + - ", got " + instanceDocumentElement.getNodeName()); - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[buildXForm] importing rootElement from other document"); - - prototypeInstanceElement = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":instance"); - modelSection.appendChild(prototypeInstanceElement); - this.setXFormsId(prototypeInstanceElement, "instance_prototype"); - prototypeInstanceElement.appendChild(defaultInstanceDocumentElement); - } - - final Element rootGroup = this.addElement(xformsDocument, - modelSection, - defaultInstanceDocumentElement, - formSection, - schema, - rootElementDecl, - "/" + this.getElementName(rootElementDecl, xformsDocument), - new SchemaUtil.Occurrence(1, 1), - resourceBundle); - if (rootGroup.getNodeName() != NamespaceConstants.XFORMS_PREFIX + ":group") - { - throw new FormBuilderException("Expected root form element to be a " + NamespaceConstants.XFORMS_PREFIX + - ":group, not a " + rootGroup.getNodeName() + - ". Ensure that " + this.getElementName(rootElementDecl, xformsDocument) + - " is a concrete type that has no extensions. " + - "Types with extensions are not supported for " + - "the root element of a form."); - } - this.setXFormsId(rootGroup, "alfresco-xforms-root-group"); - - if (prototypeInstanceElement != null) - { - Schema2XForms.rebuildInstance(prototypeInstanceElement, instanceDocument, - instanceElement, schemaNamespacesMap); - } - - this.createSubmitElements(xformsDocument, modelSection, rootGroup); - this.createTriggersForRepeats(xformsDocument, rootGroup); - - final Comment comment = - xformsDocument.createComment("This XForm was generated by " + this.getClass().getName() + - " on " + (new Date()) + " from the '" + rootElementName + - "' element of the '" + this.targetNamespace + "' XML Schema."); - xformsDocument.getDocumentElement().insertBefore(comment, - xformsDocument.getDocumentElement().getFirstChild()); - xformsDocument.normalizeDocument(); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[buildXForm] Returning XForm =\n" + XMLUtil.toString(xformsDocument)); - - return new Pair(xformsDocument, schema); - } - - /** - * Reset the Schema2XForms to default values. - */ - public void reset() - { - this.counter.clear(); - } - - @SuppressWarnings("unchecked") - public static void rebuildInstance(final Node prototypeNode, final Node oldInstanceNode, - final Node newInstanceNode, - - final HashMap schemaNamespaces) - { - final JXPathContext prototypeContext = JXPathContext.newContext(prototypeNode); - prototypeContext.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI); - final JXPathContext instanceContext = JXPathContext.newContext(oldInstanceNode); - instanceContext.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI); - - for (final String prefix : schemaNamespaces.keySet()) - { - prototypeContext.registerNamespace(prefix, schemaNamespaces.get(prefix)); - instanceContext.registerNamespace(prefix, schemaNamespaces.get(prefix)); - } - - // Evaluate non-recursive XPaths for all prototype elements at this level - final Iterator it = prototypeContext.iteratePointers("*"); - while (it.hasNext()) - { - final Pointer p = it.next(); - Element proto = (Element) p.getNode(); - String path = p.asPath(); - // check if this is a prototype element with the attribute set - boolean isPrototype = proto.hasAttributeNS(NamespaceService.ALFRESCO_URI, "prototype") - && proto.getAttributeNS(NamespaceService.ALFRESCO_URI, "prototype").equals("true"); - - // We shouldn't locate a repeatable child with a fixed path - if (isPrototype) - { - path = path.replaceAll("\\[(\\d+)\\]", "[position() >= $1]"); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[rebuildInstance] evaluating prototyped nodes " + path); - } - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[rebuildInstance] evaluating child node with positional path " + path); - } - } - - Document newInstanceDocument = newInstanceNode.getOwnerDocument(); - - // Locate the corresponding nodes in the instance document - List l = (List) instanceContext.selectNodes(path); - - // If the prototype node isn't a prototype element, copy it in as a missing node, complete with all its children. We won't need to recurse on this node - if (l.isEmpty()) - { - if (!isPrototype) - { - LOGGER.debug("[rebuildInstance] copying in missing node " + proto.getNodeName() + " to " - + XMLUtil.buildXPath(newInstanceNode, newInstanceDocument.getDocumentElement())); - - // Clone the prototype node and all its children - Element clone = (Element)proto.cloneNode(true); - newInstanceNode.appendChild(clone); - - if (oldInstanceNode instanceof Document) - { - // add XMLSchema instance NS - addNamespace(clone, NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, - NamespaceConstants.XMLSCHEMA_INSTANCE_NS); - } - } - } - else - { - // Otherwise, append the matches from the old instance document in order - for (Node old : l) - { - Element oldEl = (Element)old; - - // Copy the old instance element rather than cloning it, so we don't copy over attributes - Element clone = null; - String nSUri = oldEl.getNamespaceURI(); - if (nSUri == null) - { - clone = newInstanceDocument.createElement(oldEl.getTagName()); - } - else - { - clone = newInstanceDocument.createElementNS(nSUri, oldEl.getTagName()); - } - newInstanceNode.appendChild(clone); - - if (oldInstanceNode instanceof Document) - { - // add XMLSchema instance NS - addNamespace(clone, NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, - NamespaceConstants.XMLSCHEMA_INSTANCE_NS); - } - - // Copy over child text if this is not a complex type - boolean isEmpty = true; - for (Node n = old.getFirstChild(); n != null; n = n.getNextSibling()) - { - if (n instanceof Text) - { - clone.appendChild(newInstanceDocument.importNode(n, false)); - isEmpty = false; - } - else if (n instanceof Element) - { - break; - } - } - - // Populate the nil attribute. It may be true or false - if (proto.hasAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, "nil")) - { - clone.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil", String.valueOf(isEmpty)); - } - - // Copy over attributes present in the prototype - NamedNodeMap attributes = proto.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) - { - Attr attribute = (Attr) attributes.item(i); - String localName = attribute.getLocalName(); - if (localName == null) - { - String name = attribute.getName(); - if (oldEl.hasAttribute(name)) - { - clone.setAttributeNode((Attr) newInstanceDocument.importNode(oldEl.getAttributeNode(name), - false)); - } - else - { - LOGGER.debug("[rebuildInstance] copying in missing attribute " + attribute.getNodeName() - + " to " + XMLUtil.buildXPath(clone, newInstanceDocument.getDocumentElement())); - - clone.setAttributeNode((Attr) attribute.cloneNode(false)); - } - } - else - { - String namespace = attribute.getNamespaceURI(); - if (!((!isEmpty - && (namespace.equals(NamespaceConstants.XMLSCHEMA_INSTANCE_NS) && localName.equals("nil")) || (namespace - .equals(NamespaceService.ALFRESCO_URI) && localName.equals("prototype"))))) - { - if (oldEl.hasAttributeNS(namespace, localName)) - { - clone.setAttributeNodeNS((Attr) newInstanceDocument.importNode(oldEl.getAttributeNodeNS( - namespace, localName), false)); - } - else - { - LOGGER.debug("[rebuildInstance] copying in missing attribute " + attribute.getNodeName() - + " to " + XMLUtil.buildXPath(clone, newInstanceDocument.getDocumentElement())); - - clone.setAttributeNodeNS((Attr) attribute.cloneNode(false)); - } - } - } - } - - // recurse on children - rebuildInstance(proto, oldEl, clone, schemaNamespaces); - } - } - - // Now add in a new copy of the prototype - if (isPrototype) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[rebuildInstance] appending " - + proto.getNodeName() - + " to " - + XMLUtil.buildXPath(newInstanceNode, newInstanceDocument - .getDocumentElement())); - } - newInstanceNode.appendChild(proto.cloneNode(true)); - } - } - } - - public static void removePrototypeNodes(final Node instanceDocumentElement) - { - final Map> prototypes = - new HashMap>(); - final NodeList children = instanceDocumentElement.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) - { - if (! (children.item(i) instanceof Element)) - { - continue; - } - final String nodeName = children.item(i).getNodeName(); - if (! prototypes.containsKey(nodeName)) - { - prototypes.put(nodeName, new LinkedList()); - } - prototypes.get(nodeName).add((Element)children.item(i)); - } - - for (LinkedList l : prototypes.values()) - { - for (Element e : l) - { - if (e.hasAttributeNS(NamespaceService.ALFRESCO_URI, "prototype")) - { - assert "true".equals(e.getAttributeNS(NamespaceService.ALFRESCO_URI, - "prototype")); - e.removeAttributeNS(NamespaceService.ALFRESCO_URI, "prototype"); - - if (l.getLast().equals(e)) - { - e.getParentNode().removeChild(e); - } - } - if (e.getParentNode() != null) - { - Schema2XForms.removePrototypeNodes(e); - } - } - } - } - - protected String setXFormsId(final Element el) - { - return this.setXFormsId(el, null); - } - - protected String setXFormsId(final Element el, String id) - { - if (el.hasAttributeNS(null, "id")) - { - el.removeAttributeNS(null, "id"); - } - if (id == null) - { - final String name = el.getLocalName(); - final Long l = this.counter.get(name); - final long count = (l != null) ? l : 0; - - // increment the counter - this.counter.put(name, new Long(count + 1)); - - id = name + "_" + count; - } - el.setAttributeNS(null, "id", id); - return id; - } - - /** - * method to set an Id to this element and to all XForms descendants of this element - */ - private void resetXFormIds(final Element newControl) - { - if (newControl.getNamespaceURI() != null && - newControl.getNamespaceURI().equals(NamespaceConstants.XFORMS_NS)) - { - this.setXFormsId(newControl); - } - - //recursive call - final NodeList children = newControl.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) - { - final Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) - { - this.resetXFormIds((Element) child); - } - } - } - - /** - * _UNDOCUMENTED_ - * - * @param xForm _UNDOCUMENTED_ - * @param choicesElement _UNDOCUMENTED_ - * @param choiceValues _UNDOCUMENTED_ - */ - protected void addChoicesForSelectControl(final Document xForm, - final Element choicesElement, - final Map choiceValues, - final ResourceBundle resourceBundle) - { - for (Map.Entry choice : choiceValues.entrySet()) - { - final Element item = this.createXFormsItem(xForm, - this.createCaption(choice.getKey(), - choice.getValue(), - resourceBundle), - choice.getKey()); - choicesElement.appendChild(item); - } - } - - /** - */ - protected Map addChoicesForSelectSwitchControl(final Document xformsDocument, - final Element formSection, - final List choiceValues, - final String typeBindId) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addChoicesForSelectSwitchControl] values = "); - for (XSTypeDefinition type : choiceValues) - { - LOGGER.debug(" - " + type.getName()); - } - } - - final Map result = new HashMap(); - for (XSTypeDefinition type : choiceValues) - { - final String textValue = type.getName(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addChoicesForSelectSwitchControl] processing " + textValue); - } - - //build the case element - final Element caseElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":case"); - caseElement.appendChild(this.createLabel(xformsDocument, textValue)); - final String caseId = this.setXFormsId(caseElement); - result.put(textValue, caseElement); - - final Element toggle = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":toggle"); - this.setXFormsId(toggle); - toggle.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":case", - caseId); - - final Element setValue = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":setvalue"); - setValue.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind", - typeBindId); - setValue.appendChild(xformsDocument.createTextNode(textValue)); - - formSection.appendChild(this.createTrigger(xformsDocument, - null, - typeBindId, - textValue, - toggle, - setValue)); - } - return result; - } - - private static String extractPropertyFromAnnotation(final String namespace, - final String elementName, - final XSAnnotation annotation, - final ResourceBundle resourceBundle) - { - if (annotation == null) - { - return null; - } - // write annotation to empty doc - final Document doc = XMLUtil.newDocument(); - annotation.writeAnnotation(doc, XSAnnotation.W3C_DOM_DOCUMENT); - - final NodeList d = doc.getElementsByTagNameNS(namespace, elementName); - if (d.getLength() == 0) - { - return null; - } - if (d.getLength() > 1) - { - LOGGER.warn("[extractPropertyFromAnnotation] expected exactly one value for " + namespace + - ":" + elementName + - ". found " + d.getLength()); - } - String result = DOMUtil.getTextNodeAsString(d.item(0)); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug(namespace + ":" + elementName + " = " + result); - - if (result.startsWith("${") && result.endsWith("}") && resourceBundle != null) - { - result = result.substring("${".length(), result.length() - "}".length()); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[extractPropertyFromAnnotation] looking up key " + result + " in bundle " + resourceBundle); - - try - { - result = resourceBundle.getString(result); - } - catch (MissingResourceException mse) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[extractPropertyFromAnnotation] unable to find key " + result, mse); - - result = "$$" + result + "$$"; - } - } - return result; - } - - private void addAttributeSet(final Document xformsDocument, - final Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSComplexTypeDefinition controlType, - final XSElementDeclaration owner, - final String pathToRoot, - final boolean checkIfExtension, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - XSObjectList attrUses = controlType.getAttributeUses(); - - if (attrUses == null) - { - return; - } - for (int i = 0; i < attrUses.getLength(); i++) - { - final XSAttributeUse currentAttributeUse = (XSAttributeUse)attrUses.item(i); - final XSAttributeDeclaration currentAttribute = - currentAttributeUse.getAttrDeclaration(); - - String attributeName = currentAttributeUse.getName(); - if (attributeName == null || attributeName.length() == 0) - { - attributeName = currentAttributeUse.getAttrDeclaration().getName(); - } - - //test if extended ! - if (checkIfExtension && - SchemaUtil.doesAttributeComeFromExtension(currentAttributeUse, controlType)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addAttributeSet] This attribute comes from an extension: recopy form controls. Model section =\n" + - XMLUtil.toString(modelSection)); - } - - //find the existing bind Id - //(modelSection is the enclosing bind of the element) - final NodeList binds = modelSection.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "bind"); - String bindId = null; - for (int j = 0; j < binds.getLength() && bindId == null; j++) - { - Element bind = (Element) binds.item(j); - String nodeset = bind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset"); - if (nodeset != null) - { - //remove "@" in nodeset - String name = nodeset.substring(1); - if (name.equals(attributeName)) - { - bindId = bind.getAttributeNS(null, "id"); - } - } - } - - //find the control - Element control = null; - if (bindId != null) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addAttributeSet] bindId found: " + bindId); - - JXPathContext context = JXPathContext.newContext(formSection.getOwnerDocument()); - final Pointer pointer = - context.getPointer("//*[@" + NamespaceConstants.XFORMS_PREFIX + ":bind='" + bindId + "']"); - if (pointer != null) - { - control = (Element)pointer.getNode(); - } - else if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addAttributeSet] unable to resolve pointer for: //*[@" + NamespaceConstants.XFORMS_PREFIX + ":bind='" + bindId + "']"); - } - } - - if (LOGGER.isDebugEnabled()) - { - if (control == null) - { - LOGGER.debug("[addAttributeSet] control = "); - } - else - { - LOGGER.debug("[addAttributeSet] control = " + control.getTagName()); - } - } - - //copy it - if (control == null) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Corresponding control not found"); - } - else - { - Element newControl = (Element) control.cloneNode(true); - //set new Ids to XForm elements - this.resetXFormIds(newControl); - - formSection.appendChild(newControl); - } - } - else - { - String attrNamespace = currentAttribute.getNamespace(); - String namespacePrefix = ""; - if (attrNamespace != null && attrNamespace.length() > 0) - { - String prefix =NamespaceResolver.getPrefix(xformsDocument.getDocumentElement(), attrNamespace); - if (prefix!= null && prefix.length() > 0) - { - namespacePrefix = prefix + ":"; - } - } - - final String newPathToRoot = - (pathToRoot == null || pathToRoot.length() == 0 - ? "@" + namespacePrefix + currentAttribute.getName() - : (pathToRoot.endsWith("/") - ? pathToRoot + "@" + namespacePrefix + currentAttribute.getName() - : pathToRoot + "/@"+ namespacePrefix + currentAttribute.getName())); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addAttributeSet] adding attribute " + attributeName +" at " + newPathToRoot); - - try - { - String defaultValue = (currentAttributeUse.getConstraintType() == XSConstants.VC_NONE - ? null - : currentAttributeUse.getConstraintValue()); - // make sure boolean attributes have a default value - if (defaultValue == null && "boolean".equals(currentAttribute.getTypeDefinition().getName())) - { - defaultValue = "false"; - } - - if (namespacePrefix.length() > 0) - { - defaultInstanceElement.setAttributeNS(this.targetNamespace, - attributeName, - defaultValue); - } - else - { - defaultInstanceElement.setAttribute(attributeName, defaultValue); - } - } - catch (Exception e) - { - throw new FormBuilderException("error retrieving default value for attribute " + - attributeName + " at " + newPathToRoot, e); - } - this.addSimpleType(xformsDocument, - modelSection, - formSection, - schema, - currentAttribute.getTypeDefinition(), - currentAttributeUse, - newPathToRoot, - resourceBundle); - } - } - } - - private Element addComplexType(final Document xformsDocument, - Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSComplexTypeDefinition controlType, - final XSElementDeclaration owner, - String pathToRoot, - final SchemaUtil.Occurrence occurs, - boolean relative, - final boolean checkIfExtension, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - if (controlType == null) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] addComplexType control type is null for pathToRoot = " - + pathToRoot); - } - return null; - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] Start addComplexType for " + controlType.getName() + " (" + pathToRoot + ")," + - " owner = " + (owner == null ? "null" : owner.getName())); - } - - // add a group node and recurse - final Element groupElement = this.createGroup(xformsDocument, - modelSection, - formSection, - owner, - resourceBundle); -// final SchemaUtil.Occurrence o = SchemaUtil.getOccurrence(owner); - final Element repeatSection = this.addRepeatIfNecessary(xformsDocument, - modelSection, - groupElement, - controlType, - pathToRoot, - occurs); - if (repeatSection != groupElement) - { - groupElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "repeated"); - - // we have a repeat - relative = true; - } - - if (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED || - (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE && - controlType.getAttributeUses() != null && - controlType.getAttributeUses().getLength() > 0)) - { - XSTypeDefinition base = controlType.getBaseType(); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] Control type is mixed, base type = " + base.getName()); - } - - if (base != null && base != controlType) - { - if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) - { - this.addSimpleType(xformsDocument, - modelSection, - repeatSection, - schema, - (XSSimpleTypeDefinition)base, - owner.getName(), - owner, - pathToRoot, - occurs, - resourceBundle); - } - else - { - LOGGER.warn("[addComplexType] addComplexTypeChildren for mixed type with basic type complex!"); - } - } - } - else if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] Control content type = " + controlType.getContentType()); - } - - // check for compatible subtypes - // of controlType. - // add a type switch if there are any - // compatible sub-types (i.e. anything - // that derives from controlType) - // add child elements - if (relative) - { - pathToRoot = ""; - - //modelSection: find the last element put in the modelSection = bind - modelSection = DOMUtil.getLastChildElement(modelSection); - } - - //attributes - this.addAttributeSet(xformsDocument, - modelSection, - defaultInstanceElement, - repeatSection, - schema, - controlType, - owner, - pathToRoot, - checkIfExtension, - resourceBundle); - - //process group - final XSParticle particle = controlType.getParticle(); - if (particle != null) - { - final XSTerm term = particle.getTerm(); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] Particle of " + controlType.getName() + - " is" + (term instanceof XSModelGroup ? "" : " not") + - " a group: " + term.getClass().getName()); - } - - if (term instanceof XSModelGroup) - { - - switch (((XSModelGroup)term).getCompositor()) - { - case XSModelGroup.COMPOSITOR_CHOICE: - LOGGER.warn("term " + term.getName() + " of particle " + particle.getName() + - " of type " + controlType.getName() + " in " + owner.getName() + - " describes a " + NamespaceConstants.XMLSCHEMA_PREFIX + - ":choice which is not yet supported, adding it as a " + - NamespaceConstants.XMLSCHEMA_PREFIX + ":sequence"); - break; - case XSModelGroup.COMPOSITOR_ALL: - LOGGER.warn("term " + term.getName() + " of particle " + particle.getName() + - " of type " + controlType.getName() + " in " + owner.getName() + - " describes a " + NamespaceConstants.XMLSCHEMA_PREFIX + - ":all which is not yet supported, adding it as a " + - NamespaceConstants.XMLSCHEMA_PREFIX + ":sequence"); - break; - case XSModelGroup.COMPOSITOR_SEQUENCE: - break; - } - //call addGroup on this group - this.addGroup(xformsDocument, - modelSection, - defaultInstanceElement, - repeatSection, - schema, - (XSModelGroup)term, - controlType, - owner, - pathToRoot, - new SchemaUtil.Occurrence(particle), - checkIfExtension, - resourceBundle); - } - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addComplexType] End of addComplexType for " + controlType.getName()); - } - - return groupElement; - } - - /** - * add an element to the XForms document: the bind + the control - * (only the control if "withBind" is false) - */ - private Element addElement(final Document xformsDocument, - final Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSElementDeclaration elementDecl, - final String pathToRoot, - final SchemaUtil.Occurrence occurs, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addElement] adding element " + elementDecl + " at path " + pathToRoot); - - XSTypeDefinition controlType = elementDecl.getTypeDefinition(); - if (controlType == null) - { - // TODO!!! Figure out why this happens... for now just warn... - // seems to happen when there is an element of type IDREFS - LOGGER.warn("WARNING!!! controlType is null for " + elementDecl + - ", " + elementDecl.getName()); - return null; - } - - if (controlType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && - ((XSComplexTypeDefinition)controlType).getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) - { - controlType = ((XSComplexTypeDefinition)controlType).getSimpleType(); - } - - if (controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) - { - return this.addSimpleType(xformsDocument, - modelSection, - formSection, - schema, - (XSSimpleTypeDefinition) controlType, - elementDecl.getName(), - elementDecl, - pathToRoot, - occurs, - resourceBundle); - } - - if (controlType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && - "anyType".equals(controlType.getName())) - { - return this.addSimpleType(xformsDocument, - modelSection, - formSection, - schema, - (XSComplexTypeDefinition)controlType, - elementDecl.getName(), - elementDecl, - pathToRoot, - occurs, - resourceBundle); - } - - if (controlType.getTypeCategory() != XSTypeDefinition.COMPLEX_TYPE) - { - throw new FormBuilderException("Unsupported type [" + elementDecl.getType() + - "] for node [" + controlType.getName() + "]"); - } - - boolean relative = true; - final String typeName = controlType.getName(); - final boolean typeIsAbstract = ((XSComplexTypeDefinition)controlType).getAbstract(); - final TreeSet compatibleTypes = - typeName != null ? this.typeTree.get(typeName) : null; - - if (compatibleTypes == null && typeName != null && LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElement] No compatible type found for " + typeName); - } - - if (typeName != null && compatibleTypes != null) - { - relative = false; - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElement] compatible types for " + typeName + ":"); - for (XSTypeDefinition compType : compatibleTypes) - { - LOGGER.debug("[addElement] compatible type name = " + compType.getName()); - } - } - - if (!typeIsAbstract && compatibleTypes.size() == 0) - { - relative = true; - } - else if (typeIsAbstract && compatibleTypes.size() == 1) - { - // only one compatible type, set the controlType value - // and fall through - controlType = compatibleTypes.first(); - relative = true; - } - else if (typeIsAbstract && compatibleTypes.size() == 0) - { - // name not null but no compatibleType? - relative = false; - } - else - { - return this.addElementWithMultipleCompatibleTypes(xformsDocument, - modelSection, - defaultInstanceElement, - formSection, - schema, - elementDecl, - compatibleTypes, - pathToRoot, - resourceBundle, - occurs); - } - } - - if (!relative) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addElement] bind is not relative for " + elementDecl.getName()); - } - else - { -// final SchemaUtil.Occurrence occurs = SchemaUtil.getOccurrence(elementDecl); - //create the bind in case it is a repeat - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElement] Adding empty bind for control " + controlType + - " type " + typeName + - " nodeset " + pathToRoot + - " occurs " + occurs); - } - - // create the element and add it to the model. - boolean isRepeated = isRepeated(occurs, controlType); - final Element bindElement = - this.createBind(xformsDocument, - pathToRoot + (isRepeated ? "[position() != last()]" : "")); - - modelSection.appendChild(bindElement); - this.startBindElement(bindElement, - schema, - controlType, - null, - occurs); - } - return this.addComplexType(xformsDocument, - modelSection, - defaultInstanceElement, - formSection, - schema, - (XSComplexTypeDefinition)controlType, - elementDecl, - pathToRoot, - occurs, - true, - false, - resourceBundle); - } - - private Element addElementWithMultipleCompatibleTypes(final Document xformsDocument, - Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSElementDeclaration elementDecl, - final TreeSet compatibleTypes, - final String pathToRoot, - final ResourceBundle resourceBundle, - final SchemaUtil.Occurrence occurs) - throws FormBuilderException - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addElementWithMultipleCompatibleTypes] adding element " + elementDecl + " at path " + pathToRoot); - - // look for compatible types - final XSTypeDefinition controlType = elementDecl.getTypeDefinition(); - - //get possible values - final List enumValues = new LinkedList(); - //add the type (if not abstract) - if (!((XSComplexTypeDefinition)controlType).getAbstract()) - { - enumValues.add(controlType); - } - - //add compatible types - enumValues.addAll(compatibleTypes); - - // multiple compatible types for this element exist - // in the schema - allow the user to choose from - // between compatible non-abstract types - boolean isRepeated = isRepeated(occurs, controlType); - Element bindElement = this.createBind(xformsDocument, pathToRoot + "/@xsi:type"); - String bindId = bindElement.getAttributeNS(null, "id"); - modelSection.appendChild(bindElement); - this.startBindElement(bindElement, schema, controlType, null, occurs); - - //add the "element" bind, in addition - final Element bindElement2 = this.createBind(xformsDocument, - pathToRoot + (isRepeated ? "[position() != last()]" : "")); - modelSection.appendChild(bindElement2); - this.startBindElement(bindElement2, schema, controlType, null, occurs); - - // add content to select1 - final Map caseTypes = - this.addChoicesForSelectSwitchControl(xformsDocument, formSection, enumValues, bindId); - - //add switch - final Element switchElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":switch"); - switchElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind", - bindId); - switchElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "full"); - - formSection.appendChild(switchElement); - - if (!((XSComplexTypeDefinition)controlType).getAbstract()) - { - final Element firstCaseElement = caseTypes.get(controlType.getName()); - switchElement.appendChild(firstCaseElement); - final Element firstGroupElement = this.addComplexType(xformsDocument, - modelSection, - defaultInstanceElement, - firstCaseElement, - schema, - (XSComplexTypeDefinition)controlType, - elementDecl, - pathToRoot, - SchemaUtil.getOccurrence(elementDecl), - true, - false, - resourceBundle); - firstGroupElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - ""); - } - - defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":type", - (((XSComplexTypeDefinition)controlType).getAbstract() - ? compatibleTypes.first().getName() - : controlType.getName())); - defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil", - "true"); - - /////////////// add sub types ////////////// - // add each compatible type within - // a case statement - for (final XSTypeDefinition type : compatibleTypes) - { - final String compatibleTypeName = type.getName(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug(type == null - ? ("[addElementWithMultipleCompatibleTypes] compatible type is null!! type = " + - compatibleTypeName + ", targetNamespace = " + this.targetNamespace) - : ("[addElementWithMultipleCompatibleTypes] adding compatible type " + type.getName())); - } - - if (type == null || type.getTypeCategory() != XSTypeDefinition.COMPLEX_TYPE) - { - continue; - } - - final Element caseElement = caseTypes.get(type.getName()); - switchElement.appendChild(caseElement); - - // ALF-9524 fix, add an extra element to the instance for each type that extends the abstract parent - Element newDefaultInstanceElement = xformsDocument.createElement(getElementName(type, xformsDocument)); - - Attr nodesetAttr = modelSection.getAttributeNodeNS(NamespaceConstants.XFORMS_NS, "nodeset"); - // construct the nodeset that is used in bind for abstract type - String desiredBindNodeset = getElementName(elementDecl, xformsDocument) + (isRepeated ? "[position() != last()]" : ""); - - // check the current bind - if (nodesetAttr == null || !nodesetAttr.getValue().equals(desiredBindNodeset)) - { - // look for desired bind in children - Element newModelSection = DOMUtil.getElementByAttributeValueNS(modelSection, NamespaceConstants.XFORMS_NS, "bind", NamespaceConstants.XFORMS_NS, "nodeset", desiredBindNodeset); - - if (newModelSection == null) - { - // look for absolute path - desiredBindNodeset = "/" + desiredBindNodeset; - newModelSection = DOMUtil.getElementByAttributeValueNS(modelSection, NamespaceConstants.XFORMS_NS, "bind", NamespaceConstants.XFORMS_NS, "nodeset", desiredBindNodeset); - } - - modelSection = newModelSection; - } - - // create the extra bind for each child of abstract type - Element bindElement3 = this.createBind(xformsDocument, getElementName(type, xformsDocument)); - modelSection.appendChild(bindElement3); - bindElement3 = this.startBindElement(bindElement3, schema, controlType, elementDecl, occurs); - - // add the relevant attribute that checks the value of parent' @xsi:type - bindElement3.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":relevant", - "../@xsi:type='" + type.getName() + "'"); - - final Element groupElement = this.addComplexType(xformsDocument, - modelSection, - newDefaultInstanceElement, - caseElement, - schema, - (XSComplexTypeDefinition) type, - elementDecl, - pathToRoot, - SchemaUtil.getOccurrence(elementDecl), - true, - true, - resourceBundle); - groupElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - ""); - - defaultInstanceElement.appendChild(newDefaultInstanceElement.cloneNode(true)); - - // modify bind to add a "relevant" attribute that checks the value of @xsi:type - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementWithMultipleCompatibleTypes] Model section =\n" + XMLUtil.toString(bindElement3)); - } - - final NodeList binds = bindElement3.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "bind"); - for (int i = 0; i < binds.getLength(); i++) - { - final Element subBind = (Element) binds.item(i); - String name = subBind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset"); - - // ETHREEOH-3308 fix - name = repeatableNamePattern.matcher(name).replaceAll(""); - - if (!subBind.getParentNode().getAttributes().getNamedItem("id").getNodeValue().equals( - bindElement3.getAttribute("id"))) - { - continue; - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementWithMultipleCompatibleTypes] Testing sub-bind with nodeset " + name); - } - - Pair parsed = parseName(name, xformsDocument); - - if (!SchemaUtil.isElementDeclaredIn(parsed.getFirst(), parsed.getSecond(), (XSComplexTypeDefinition) type, false) && - !SchemaUtil.isAttributeDeclaredIn(parsed.getFirst(), parsed.getSecond(), (XSComplexTypeDefinition) type, false)) - { - continue; - } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementWithMultipleCompatibleTypes] Element/Attribute " + name + - " declared in type " + type.getName() + - ": adding relevant attribute"); - } - - //test sub types of this type - //TreeSet subCompatibleTypes = (TreeSet) typeTree.get(type); - - String newRelevant = "../../@xsi:type='" + type.getName() + "'"; - if (this.typeTree.containsKey(type.getName())) - { - for (XSTypeDefinition otherType : this.typeTree.get(type.getName())) - { - newRelevant = newRelevant + " or ../../@xsi:type='" + otherType.getName() + "'"; - } - } - - //change relevant attribute - final String relevant = subBind.getAttributeNS(NamespaceConstants.XFORMS_NS, "relevant"); - if (relevant != null && relevant.length() != 0) - { - newRelevant = ("(" + relevant + - ") and " + newRelevant); - } - subBind.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":relevant", - newRelevant); - } - } - return switchElement; - } - - /** - */ - private void addGroup(final Document xformsDocument, - final Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSModelGroup group, - final XSComplexTypeDefinition controlType, - final XSElementDeclaration owner, - final String pathToRoot, - final SchemaUtil.Occurrence occurs, - final boolean checkIfExtension, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - if (group == null) - { - return; - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] Start of addGroup, from owner = " + owner.getName() + - " and controlType = " + controlType.getName()); - LOGGER.debug("[addGroup] group before =\n" + XMLUtil.toString(formSection)); - } - - final Element repeatSection = this.addRepeatIfNecessary(xformsDocument, - modelSection, - formSection, - owner.getTypeDefinition(), - pathToRoot, - occurs); - - final XSObjectList particles = group.getParticles(); - for (int counter = 0; counter < particles.getLength(); counter++) - { - final XSParticle currentNode = (XSParticle)particles.item(counter); - XSTerm term = currentNode.getTerm(); - final SchemaUtil.Occurrence childOccurs = new SchemaUtil.Occurrence(currentNode); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] next term = " + term.getName() + - ", occurs = " + childOccurs); - } - - if (term instanceof XSModelGroup) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] term is a group"); - } - - this.addGroup(xformsDocument, - modelSection, - defaultInstanceElement, - repeatSection, - schema, - ((XSModelGroup) term), - controlType, - owner, - pathToRoot, - childOccurs, - checkIfExtension, - resourceBundle); - } - else if (term instanceof XSElementDeclaration) - { - XSElementDeclaration element = (XSElementDeclaration) term; - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] term is an element declaration: " - + term.getName()); - } - - //special case for types already added because used in an extension - //do not add it when it comes from an extension !!! - //-> make a copy from the existing form control - if (checkIfExtension && - SchemaUtil.doesElementComeFromExtension(element, controlType)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] This element comes from an extension: recopy form controls. Model Section =\n" + - XMLUtil.toString(modelSection)); - } - - //find the existing bind Id - //(modelSection is the enclosing bind of the element) - NodeList binds = modelSection.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "bind"); - String bindId = null; - for (int i = 0; i < binds.getLength() && bindId == null; i++) - { - Element bind = (Element)binds.item(i); - String nodeset = bind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset"); - - Pair parsed = parseName(nodeset, xformsDocument); - - if (nodeset != null && EqualsHelper.nullSafeEquals(parsed.getSecond(), element.getNamespace()) && parsed.getFirst().equals(element.getName())) - { - bindId = bind.getAttributeNS(null, "id"); - } - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addGroup] found bindId " + bindId + " for element " + element.getName()); - - //find the control - Element control = null; - if (bindId != null) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] bindId found: " + bindId); - } - - final JXPathContext context = - JXPathContext.newContext(formSection.getOwnerDocument()); - final Pointer pointer = - context.getPointer("//*[@" + NamespaceConstants.XFORMS_PREFIX + ":bind='" + bindId + "']"); - if (pointer != null) - { - control = (Element) pointer.getNode(); - } - else if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] unable to resolve pointer for: //*[@" + NamespaceConstants.XFORMS_PREFIX + ":bind='" + bindId + "']"); - } - } - - if (LOGGER.isDebugEnabled()) - { - if (control == null) - { - LOGGER.debug("[addGroup] control = "); - } - else - { - LOGGER.debug("[addGroup] control = " + control.getTagName()); - } - } - - //copy it - if (control == null) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Corresponding control not found"); - - this.addElementToGroup(xformsDocument, - modelSection, - defaultInstanceElement, - repeatSection, - schema, - element, - pathToRoot, - childOccurs, - resourceBundle); - } - else - { - Element newControl = (Element)control.cloneNode(true); - //set new Ids to XForm elements - this.resetXFormIds(newControl); - - repeatSection.appendChild(newControl); - } - } - else - { - this.addElementToGroup(xformsDocument, - modelSection, - defaultInstanceElement, - repeatSection, - schema, - element, - pathToRoot, - childOccurs, - resourceBundle); - } - } - else - { - LOGGER.warn("Unhandled term " + term + - " found in group from " + owner.getName() + - " for pathToRoot = " + pathToRoot); - } - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] group after =\n" + XMLUtil.toString(formSection)); - LOGGER.debug("[addGroup] End of addGroup, from owner = " + owner.getName() + - " and controlType = " + controlType.getName()); - } - } - - @SuppressWarnings("unchecked") - private void addElementToGroup(final Document xformsDocument, - final Element modelSection, - final Element defaultInstanceElement, - final Element formSection, - final XSModel schema, - final XSElementDeclaration element, - final String pathToRoot, - final SchemaUtil.Occurrence occurs, - final ResourceBundle resourceBundle) - throws FormBuilderException - { - //add it normally - final String elementName = this.getElementName(element, xformsDocument); - final String path = (pathToRoot.length() == 0 - ? elementName - : pathToRoot + "/" + elementName); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addElementToGroup] Start addElement to group " + elementName + " at " + path + " parentStack " + this.parentStack); - - if (this.parentStack.contains(element)) - { - throw new FormBuilderException("recursion detected at element " + elementName); - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addElementToGroup] pushing element " + element + " onto parent stack"); - - this.parentStack.push(element); - - final Element newDefaultInstanceElement = xformsDocument.createElement(elementName); - if (element.getConstraintType() != XSConstants.VC_NONE) - { - Node value = xformsDocument.createTextNode(element.getConstraintValue()); - newDefaultInstanceElement.appendChild(value); - } - else if ("boolean".equals(element.getTypeDefinition().getName())) - { - // we have a boolean element without a default value, default to false - Node value = xformsDocument.createTextNode("false"); - newDefaultInstanceElement.appendChild(value); - } - - this.addElement(xformsDocument, - modelSection, - newDefaultInstanceElement, - formSection, - schema, - element, - path, - occurs, - resourceBundle); - - Object poppedElement = this.parentStack.pop(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementToGroup] popped element " + poppedElement + " from parent stack"); - LOGGER.debug("[addElementToGroup] adding " + (occurs.maximum == 1 - ? 1 - : occurs.minimum + 1) + - " default instance element for " + elementName + - " at path " + path); - } - - // update the default instance - if (isRepeated(occurs, element.getTypeDefinition())) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementToGroup] adding " + (occurs.minimum + 1) + - " default instance elements for " + elementName + - " at path " + path); - } - - for (int i = 0; i < occurs.minimum + 1; i++) - { - final Element e = (Element)newDefaultInstanceElement.cloneNode(true); - if (i == occurs.minimum) - { - e.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":prototype", - "true"); - } - defaultInstanceElement.appendChild(e); - } - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addElementToGroup] adding one default instance element for " + elementName + - " at path " + path); - } - - if (occurs.minimum == 0) - { - newDefaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil", - "true"); - } - defaultInstanceElement.appendChild(newDefaultInstanceElement); - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addGroup] End of addElementToGroup, group = " + elementName); - } - } - - /** - * Add a repeat section if maxOccurs > 1. - */ - private Element addRepeatIfNecessary(final Document xformsDocument, - final Element modelSection, - final Element formSection, - final XSTypeDefinition controlType, - final String pathToRoot, - final SchemaUtil.Occurrence o) - { - - // add xforms:repeat section if this element re-occurs - if ((o.isOptional() && (controlType instanceof XSSimpleTypeDefinition || "anyType".equals(controlType.getName()))) || - (o.maximum == 1 && o.minimum == 1) || (controlType instanceof XSComplexTypeDefinition && pathToRoot.equals(""))) - { - return formSection; - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addRepeatIfNecessary] for multiple element for type " + - controlType.getName() + ", maxOccurs = " + o.maximum); - } - - final Element repeatSection = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":repeat"); - - //bind instead of repeat - //repeatSection.setAttributeNS(NamespaceConstants.XFORMS_NS,NamespaceConstants.XFORMS_PREFIX + ":nodeset",pathToRoot); - // bind -> last element in the modelSection - Element bind = DOMUtil.getLastChildElement(modelSection); - - // ALF-9524 fix, previously we've added extra bind element, so last child is not correct for repeatable switch - String attribute = bind.getAttribute(NamespaceConstants.XFORMS_PREFIX + ":relevant"); - if (controlType instanceof XSComplexTypeDefinition && - ((XSComplexTypeDefinition)controlType).getDerivationMethod() == XSConstants.DERIVATION_EXTENSION && - attribute != null && !attribute.isEmpty()) - { - bind = modelSection; - } - - String bindId = null; - - if (bind != null && - bind.getLocalName() != null && - "bind".equals(bind.getLocalName())) - { - bindId = bind.getAttributeNS(null, "id"); - } - else - { - LOGGER.warn("[addRepeatIfNecessary] bind not found: " + bind - + " (model selection name = " + modelSection.getNodeName() + ")"); - - //if no bind is found -> modelSection is already a bind, get its parent last child - bind = DOMUtil.getLastChildElement(modelSection.getParentNode()); - - if (bind != null && - bind.getLocalName() != null && - "bind".equals(bind.getLocalName())) - { - bindId = bind.getAttributeNS(null, "id"); - } - else - { - LOGGER.warn("[addRepeatIfNecessary] bind really not found"); - } - } - - repeatSection.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind", - bindId); - this.setXFormsId(repeatSection); - - //appearance=full is more user friendly - repeatSection.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "full"); - - formSection.appendChild(repeatSection); - - //add a group inside the repeat? - final Element group = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":group"); - group.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "repeated"); - this.setXFormsId(group); - repeatSection.appendChild(group); - return group; - } - - /** - */ - private Element addSimpleType(final Document xformsDocument, - final Element modelSection, - Element formSection, - final XSModel schema, - final XSTypeDefinition controlType, - final String owningElementName, - final XSObject owner, - final String pathToRoot, - final SchemaUtil.Occurrence occurs, - final ResourceBundle resourceBundle) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[addSimpleType] for " + controlType.getName() + - " (owningElementName = " + owningElementName + ")," + - " occurs = [" + occurs + "]"); - if (owner != null) - { - LOGGER.debug("[addSimpleType] owner is " + owner.getClass() + ", name is " + owner.getName()); - } - } - - // create the element and add it to the model. - boolean isRepeated = isRepeated(occurs, controlType); - Element bindElement = - this.createBind(xformsDocument, pathToRoot + (isRepeated ? "[position() != last()]" : "")); - String bindId = bindElement.getAttributeNS(null, "id"); - modelSection.appendChild(bindElement); - bindElement = this.startBindElement(bindElement, schema, controlType, owner, occurs); - - // add a group if a repeat ! - if (owner instanceof XSElementDeclaration && occurs.isRepeated()) - { - final Element groupElement = this.createGroup(xformsDocument, - modelSection, - formSection, - (XSElementDeclaration)owner, - resourceBundle); - groupElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "repeated"); - - //set content - formSection = groupElement; - } - - //eventual repeat - final Element repeatSection = this.addRepeatIfNecessary(xformsDocument, - modelSection, - formSection, - controlType, - pathToRoot, - occurs); - - // create the form control element - //put a wrapper for the repeat content, but only if it is really a repeat - if (repeatSection != formSection) - { - //if there is a repeat -> create another bind with "." - final Element bindElement2 = this.createBind(xformsDocument, "."); - final String bindId2 = bindElement2.getAttributeNS(null, "id"); - bindElement.appendChild(bindElement2); - bindElement = bindElement2; - bindId = bindId2; - } - - final String caption = (owner != null - ? this.createCaption(owner, resourceBundle) - : this.createCaption(owningElementName)); - final Element formControl = this.createFormControl(xformsDocument, - schema, - caption, - controlType, - owner, - bindId, - bindElement, - occurs, - resourceBundle); - repeatSection.appendChild(formControl); - - // if this is a repeatable then set ref to point to current element - // not sure if this is a workaround or this is just the way XForms works... - // - //if (!repeatSection.equals(formSection)) - //formControl.setAttributeNS(NamespaceConstants.XFORMS_NS, - //NamespaceConstants.XFORMS_PREFIX + ":ref", - //"."); - - //add selector if repeat - //if (repeatSection != formSection) - //this.addSelector(xformsDocument, (Element) formControl.getParentNode()); - - return formSection; - } - - private Element addSimpleType(final Document xformsDocument, - final Element modelSection, - final Element formSection, - final XSModel schema, - final XSSimpleTypeDefinition controlType, - final XSAttributeUse owningAttribute, - final String pathToRoot, - final ResourceBundle resourceBundle) - { - return this.addSimpleType(xformsDocument, - modelSection, - formSection, - schema, - controlType, - owningAttribute.getAttrDeclaration().getName(), - owningAttribute, - pathToRoot, - new SchemaUtil.Occurrence(owningAttribute.getRequired() ? 1 : 0, 1), - resourceBundle); - } - - private Element createFormControl(final Document xformsDocument, - final XSModel schema, - final String caption, - final XSTypeDefinition controlType, - final XSObject owner, - final String bindId, - final Element bindElement, - final SchemaUtil.Occurrence o, - final ResourceBundle resourceBundle) - { - Element formControl = null; - if (controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE && - ((XSSimpleTypeDefinition)controlType).getItemType() != null) - { - formControl = this.createControlForListType(xformsDocument, - (XSSimpleTypeDefinition)controlType, - owner, - caption, - bindElement, - resourceBundle); - } - else if (controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE && - ((XSSimpleTypeDefinition)controlType).isDefinedFacet(XSSimpleTypeDefinition.FACET_ENUMERATION)) - { - formControl = this.createControlForEnumerationType(xformsDocument, - (XSSimpleTypeDefinition)controlType, - owner, - caption, - bindElement, - resourceBundle); - } - else if (controlType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && - "anyType".equals(controlType.getName())) - { - formControl = this.createControlForAnyType(xformsDocument, caption, controlType); - } - else - { - formControl = this.createControlForAtomicType(xformsDocument, - (XSSimpleTypeDefinition)controlType, - owner, - caption, - resourceBundle); - } - - formControl.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind", - bindId); - - // TODO: Enhance alert statement based on facet restrictions. - // TODO: Enhance to support minOccurs > 1 and maxOccurs > 1. - // TODO: Add i18n/l10n suppport to this - use java MessageFormatter... - // - // e.g. Please provide a valid value for 'Address'. 'Address' is a mandatory decimal field. - // - final Element alertElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":alert"); - formControl.appendChild(alertElement); - this.setXFormsId(alertElement); - - String alert = Schema2XForms.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "alert", - this.getAnnotation(owner), - resourceBundle); - if (alert == null) - { - alert = ("Please provide a valid value for '" + caption + "'." + - " '" + caption + - "' is " + (o.minimum == 0 ? "an optional" : "a required") + " '" + - this.createCaption(this.getXFormsTypeName(xformsDocument, schema, controlType)) + - "' value."); - } - alertElement.appendChild(xformsDocument.createTextNode(alert)); - - final String hint = Schema2XForms.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "hint", - this.getAnnotation(owner), - resourceBundle); - if (hint != null) - { - final Element hintElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":hint"); - formControl.appendChild(hintElement); - this.setXFormsId(hintElement); - hintElement.appendChild(xformsDocument.createTextNode(hint)); - } - return formControl; - } - - /** - * used to get the type name that will be used in the XForms document - * - * @param xformsDocument - * @param schema - * @param controlType the type from which we want the name - * @return the complete type name (with namespace prefix) of the type in the XForms doc - */ - protected String getXFormsTypeName(final Document xformsDocument, - final XSModel schema, - final XSTypeDefinition controlType) - { - final Element context = xformsDocument.getDocumentElement(); - final String typeName = controlType.getName(); - final String typeNS = controlType.getNamespace(); - - //if we use XMLSchema types: - //first check if it is a simple type named in the XMLSchema - if (controlType.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE || - typeName == null || - typeName.length() == 0 || - schema.getTypeDefinition(typeName, typeNS) == null || - (typeNS != null && NamespaceConstants.XMLSCHEMA_NS.equals(typeNS))) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[getXFormsTypeName] using built in type for " + typeName); - - //use built in type - return SchemaUtil.getBuiltInTypeName(controlType); - } - - //type is globally defined - //use schema type - - //local type name - String localTypeName = typeName; - final int index = typeName.indexOf(':'); - if (index > -1 && typeName.length() > index) - { - localTypeName = typeName.substring(index + 1); - } - - //completeTypeName = new prefix + local name - String result = localTypeName; - if (typeNS != null) - { - //namespace prefix in this document - final String prefix = NamespaceResolver.getPrefix(context, typeNS); - if (prefix != null && prefix.length() != 0) - { - result = prefix + ":" + localTypeName; - } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[getXFormsTypeName] resolved namespace prefix for uri " + typeNS + - " to " + prefix + - " using document element " + context); - } - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[getXFormsTypeName] typeName = " + typeName + - ", typeNS = " + typeNS + - ", result = " + result); - } - return result; - } - - private Document createFormTemplate(final String formId) - { - final Document xformsDocument = XMLUtil.newDocument(); - - final Element envelopeElement = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS, - NamespaceConstants.XHTML_PREFIX + ":html"); - xformsDocument.appendChild(envelopeElement); - - //set namespace attribute - addNamespace(envelopeElement, - NamespaceConstants.XHTML_PREFIX, - NamespaceConstants.XHTML_NS); - addNamespace(envelopeElement, - NamespaceConstants.XFORMS_PREFIX, - NamespaceConstants.XFORMS_NS); - addNamespace(envelopeElement, - NamespaceConstants.XMLEVENTS_PREFIX, - NamespaceConstants.XMLEVENTS_NS); - addNamespace(envelopeElement, - NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX, - NamespaceConstants.XMLSCHEMA_INSTANCE_NS); - addNamespace(envelopeElement, - NamespaceService.ALFRESCO_PREFIX, - NamespaceService.ALFRESCO_URI); - - //base - if (this.base != null && this.base.length() != 0) - { - envelopeElement.setAttributeNS(NamespaceConstants.XML_NS, - NamespaceConstants.XML_PREFIX + ":base", - this.base); - } - - //model element - final Element modelElement = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":model"); - modelElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":functions", - NamespaceConstants.CHIBA_PREFIX + ":match"); - this.setXFormsId(modelElement); - final Element modelWrapper = - xformsDocument.createElementNS(NamespaceConstants.XHTML_NS, - NamespaceConstants.XHTML_PREFIX + ":head"); - modelWrapper.appendChild(modelElement); - envelopeElement.appendChild(modelWrapper); - - //form control wrapper -> created by wrapper - //Element formWrapper = xformsDocument.createElement("body"); - //envelopeElement.appendChild(formWrapper); - final Element formWrapper = - xformsDocument.createElementNS(NamespaceConstants.XHTML_NS, - NamespaceConstants.XHTML_PREFIX + ":body"); - envelopeElement.appendChild(formWrapper); - return xformsDocument; - } - - private Element createGroup(final Document xformsDocument, - final Element modelSection, - final Element formSection, - final XSElementDeclaration owner, - final ResourceBundle resourceBundle) - { - // add a group node and recurse - final Element result = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":group"); - this.setXFormsId(result); - final String appearance = extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "appearance", - this.getAnnotation(owner), - resourceBundle); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - appearance == null || appearance.length() == 0 ? "full" : appearance); - - formSection.appendChild(result); - result.appendChild(this.createLabel(xformsDocument, - this.createCaption(owner, resourceBundle))); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[createGroup] group =\n" + XMLUtil.toString(result)); - } - return result; - } - - public String createCaption(final String text, - final XSObject o, - final ResourceBundle resourceBundle) - { - return this.createCaption(text, this.getAnnotation(o), resourceBundle); - } - - public String createCaption(final String text, - final XSAnnotation annotation, - final ResourceBundle resourceBundle) - { - final String s = Schema2XForms.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "label", - annotation, - resourceBundle); - return s != null ? s : this.createCaption(text); - } - - /** - * Creates a caption for the provided text extracted from the XML Schema. - * The implementation is responsible for reformatting the provided string to make it - * suitable to be displayed to users of the XForm. This typically includes translating - * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly - * captions (e.g. Customer Street Address). - * - * @param text The string value to be reformatted for use as a caption. - * @return The caption. - */ - public String createCaption(String text) - { - if (formatCaption == false) - { - return text; - } - // if the word is all upper case, then set to lower case and continue - if (text.equals(text.toUpperCase())) - { - text = text.toLowerCase(); - } - final String[] s = text.split("[-_\\ ]"); - final StringBuffer result = new StringBuffer(); - for (int i = 0; i < s.length; i++) - { - if (i != 0) - { - result.append(' '); - } - if (s[i].length() > 1) - { - result.append(Character.toUpperCase(s[i].charAt(0)) + - s[i].substring(1, s[i].length())); - } - else - { - result.append(s[i]); - } - } - return result.toString(); - } - - /** - * Creates a caption for the provided XML Schema attribute. - * The implementation is responsible for providing an appropriate caption - * suitable to be displayed to users of the XForm. This typically includes translating - * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly - * captions (e.g. Customer Street Address). - * - * @param attribute The XML schema attribute for which a caption is required. - * @return The caption. - */ - public String createCaption(final XSAttributeDeclaration attribute, - final ResourceBundle resourceBundle) - { - return this.createCaption(attribute.getName(), attribute, resourceBundle); - } - - public String createCaption(final XSAttributeUse attribute, - final ResourceBundle resourceBundle) - { - return this.createCaption(attribute.getAttrDeclaration().getName(), attribute, resourceBundle); - } - - /** - * Creates a caption for the provided XML Schema element. - * The implementation is responsible for providing an appropriate caption - * suitable to be displayed to users of the XForm. This typically includes translating - * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly - * captions (e.g. Customer Street Address). - * - * @param element The XML schema element for which a caption is required. - * @return The caption. - */ - public String createCaption(final XSElementDeclaration element, - final ResourceBundle resourceBundle) - { - return this.createCaption(element.getName(), element, resourceBundle); - } - - public String createCaption(final XSObject element, - final ResourceBundle resourceBundle) - { - if (element instanceof XSElementDeclaration) - { - return this.createCaption((XSElementDeclaration)element, resourceBundle); - } - if (element instanceof XSAttributeDeclaration) - { - return this.createCaption((XSAttributeDeclaration)element, resourceBundle); - } - if (element instanceof XSAttributeUse) - { - return this.createCaption((XSAttributeUse)element, resourceBundle); - } - else - { - LOGGER.warn("WARNING: createCaption: element is not an attribute nor an element: " - + element.getClass().getName()); - return null; - } - } - - /** - * Creates a form control for an XML Schema any type. - *
- * This method is called when the form builder determines a form control is required for - * an any type. - * The implementation of this method is responsible for creating an XML element of the - * appropriate type to receive a value for controlType. The caller is responsible - * for adding the returned element to the form and setting caption, bind, and other - * standard elements and attributes. - * - * @param xformsDocument The XForm document. - * @param controlType The XML Schema type for which the form control is to be created. - * @return The element for the form control. - */ - public Element createControlForAnyType(final Document xformsDocument, - final String caption, - final XSTypeDefinition controlType) - { - final Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":textarea"); - this.setXFormsId(control); - control.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - "compact"); - control.appendChild(this.createLabel(xformsDocument, caption)); - return control; - } - - /** - * Creates a form control for an XML Schema simple atomic type. - *

- * This method is called when the form builder determines a form control is required for - * an atomic type. - * The implementation of this method is responsible for creating an XML element of the - * appropriate type to receive a value for controlType. The caller is responsible - * for adding the returned element to the form and setting caption, bind, and other - * standard elements and attributes. - * - * @param xformsDocument The XForm document. - * @param controlType The XML Schema type for which the form control is to be created. - * @return The element for the form control. - */ - public Element createControlForAtomicType(final Document xformsDocument, - final XSSimpleTypeDefinition controlType, - final XSObject owner, - final String caption, - final ResourceBundle resourceBundle) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("[createControlForAtomicType] {name: " + controlType.getName() + - ", numeric: " + controlType.getNumeric() + - ", bounded: " + controlType.getBounded() + - ", finite: " + controlType.getFinite() + - ", ordered: " + controlType.getOrdered() + - ", final: " + controlType.getFinal() + - ", minInc: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE) + - ", maxInc: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE) + - ", minExc: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINEXCLUSIVE) + - ", maxExc: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE) + - ", totalDigits: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_TOTALDIGITS) + - ", length: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_LENGTH) + - ", minLength: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINLENGTH) + - ", maxLength: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXLENGTH) + - ", fractionDigits: " + controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_FRACTIONDIGITS) + - ", builtInTypeName: " + SchemaUtil.getBuiltInTypeName(controlType) + - ", builtInType: " + SchemaUtil.getBuiltInType(controlType) + - "}"); - } - String appearance = extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "appearance", - this.getAnnotation(owner), - resourceBundle); - Element result = null; - if (controlType.getNumeric()) - { - if (controlType.getBounded() && - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE) != null && - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE) != null) - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":range"); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":start", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE)); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":end", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE)); - } - else - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":input"); - } - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_FRACTIONDIGITS)) - { - String fractionDigits = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_FRACTIONDIGITS); - if (fractionDigits == null || fractionDigits.length() == 0) - { - final short builtInType = SchemaUtil.getBuiltInType(controlType); - fractionDigits = (builtInType >= XSConstants.INTEGER_DT && builtInType <= XSConstants.POSITIVEINTEGER_DT - ? "0" - : null); - } - if (fractionDigits != null) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":fractionDigits", - fractionDigits); - } - } - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_TOTALDIGITS)) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":totalDigits", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_TOTALDIGITS)); - - } - } - else - { - switch (SchemaUtil.getBuiltInType(controlType)) - { - case XSConstants.BOOLEAN_DT: - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":select1"); - final String[] values = { "true", "false" }; - for (String v : values) - { - final Element item = this.createXFormsItem(xformsDocument, v, v); - result.appendChild(item); - } - break; - } - case XSConstants.STRING_DT: - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":textarea"); - if (appearance == null || appearance.length() == 0) - { - appearance = "compact"; - } - break; - } - case XSConstants.ANYURI_DT: - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":upload"); - final Element e = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":filename"); - this.setXFormsId(e); - result.appendChild(e); - e.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":ref", - "."); - break; - } - default: - { - result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":input"); - if ((appearance == null || appearance.length() == 0) && - SchemaUtil.getBuiltInType(controlType) == XSConstants.NORMALIZEDSTRING_DT) - { - appearance = "full"; - } - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_LENGTH)) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":length", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_LENGTH)); - } - else if(controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MINLENGTH) || - controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXLENGTH)) - { - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MINLENGTH)) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":minLength", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINLENGTH)); - } - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXLENGTH)) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":maxLength", - controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXLENGTH)); - } - } - if (SchemaUtil.getBuiltInType(controlType) == XSConstants.DATE_DT) - { - String minInclusive = null; - String maxInclusive = null; - final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - final Calendar calendar = Calendar.getInstance(); - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE)) - { - minInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINEXCLUSIVE); - try - { - final Date d = sdf.parse(minInclusive); - calendar.setTime(d); - } - catch (ParseException pe) - { - LOGGER.error(pe); - } - calendar.roll(Calendar.DATE, true); - minInclusive = sdf.format(calendar.getTime()); - } - else if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MININCLUSIVE)) - { - minInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MININCLUSIVE); - } - if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE)) - { - maxInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXEXCLUSIVE); - try - { - final Date d = sdf.parse(maxInclusive); - calendar.setTime(d); - } - catch (ParseException pe) - { - LOGGER.error(pe); - } - calendar.roll(Calendar.DATE, false); - maxInclusive = sdf.format(calendar.getTime()); - } - else if (controlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE)) - { - maxInclusive = controlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXINCLUSIVE); - } - if (minInclusive != null) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":minInclusive", - minInclusive); - } - if (maxInclusive != null) - { - result.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":maxInclusive", - maxInclusive); - } - } - } - } - } - this.setXFormsId(result); - result.appendChild(this.createLabel(xformsDocument, caption)); - - if (appearance != null && appearance.length() != 0) - { - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - appearance); - } - return result; - } - - /** - * Creates a form control for an XML Schema simple type restricted by an enumeration. - * This method is called when the form builder determines a form control is required for - * an enumerated type. - * The implementation of this method is responsible for creating an XML element of the - * appropriate type to receive a value for controlType. The caller is responsible - * for adding the returned element to the form and setting caption, bind, and other - * standard elements and attributes. - * - * @param xformsDocument The XForm document. - * @param controlType The XML Schema type for which the form control is to be created. - * @param caption The caption for the form control. The caller The purpose of providing the caption - * is to permit the implementation to add a [Select1 .... ] message that involves the caption. - * @param bindElement The bind element for this control. The purpose of providing the bind element - * is to permit the implementation to add a isValid attribute to the bind element that prevents - * the [Select1 .... ] item from being selected. - * @return The element for the form control. - */ - public Element createControlForEnumerationType(final Document xformsDocument, - final XSSimpleTypeDefinition controlType, - final XSObject owner, - final String caption, - final Element bindElement, - final ResourceBundle resourceBundle) - { - // TODO: Figure out an intelligent or user determined way to decide between - // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply) - // Possibly look for special appInfo section in the schema and if not present default to comboBox... - // - // For now, use radio if enumValues < DEFAULT_LONG_LIST_MAX_SIZE otherwise use combobox - // - final StringList enumFacets = controlType.getLexicalEnumeration(); - if (enumFacets.getLength() <= 0) - { - return null; - } - - final Element control = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":select1"); - this.setXFormsId(control); - - //label - control.appendChild(this.createLabel(xformsDocument, caption)); - - final Element choices = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":choices"); - this.setXFormsId(choices); - - final XSObjectList mvFacets = controlType.getMultiValueFacets(); - if (mvFacets.getLength() != 1) - { - throw new RuntimeException("expected exactly one MultiValueFacet for " + controlType); - } - - final XSObjectList annotations = - ((XSMultiValueFacet)mvFacets.item(0)).getAnnotations(); - - final Map enumValues = - new LinkedHashMap(enumFacets.getLength()); - - String appearance = extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "appearance", - this.getAnnotation(owner), - resourceBundle); - if (appearance == null || appearance.length() == 0) - { - appearance = enumFacets.getLength() < Schema2XForms.LONG_LIST_SIZE ? "full" : "compact"; - } - - // if appearance is "full" a radio button control is used, in this case we don't want the - // please select option available - if (!"full".equals(appearance)) - { - final String nullValue = Application.getMessage(FacesContext.getCurrentInstance(), "please_select"); - enumValues.put(nullValue, null); - } - - for (int i = 0; i < enumFacets.getLength(); i++) - { - enumValues.put(enumFacets.item(i), - (annotations.getLength() == enumFacets.getLength() - ? (XSAnnotation)annotations.item(i) - : null)); - } - - control.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - appearance); - - control.appendChild(choices); - this.addChoicesForSelectControl(xformsDocument, choices, enumValues, resourceBundle); - return control; - } - - /** - * Creates a form control for an XML Schema simple list type. - *

- * This method is called when the form builder determines a form control is required for - * a list type. - * The implementation of this method is responsible for creating an XML element of the - * appropriate type to receive a value for controlType. The caller is responsible - * for adding the returned element to the form and setting caption, bind, and other - * standard elements and attributes. - * - * @param xformsDocument The XForm document. - * @param listType The XML Schema list type for which the form control is to be created. - * @param owner - * @param caption The caption for the form control. The caller The purpose of providing the caption - * is to permit the implementation to add a [Select1 .... ] message that involves the caption. - * @param bindElement The bind element for this control. The purpose of providing the bind element - * is to permit the implementation to add a isValid attribute to the bind element that prevents - * the [Select1 .... ] item from being selected. - * @param resourceBundle - * @return The element for the form control. - */ - public Element createControlForListType(final Document xformsDocument, - final XSSimpleTypeDefinition listType, - final XSObject owner, - final String caption, - final Element bindElement, - final ResourceBundle resourceBundle) - { - XSSimpleTypeDefinition controlType = listType.getItemType(); - - final StringList enumFacets = controlType.getLexicalEnumeration(); - if (enumFacets.getLength() <= 0) - { - return null; - } - Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":select"); - this.setXFormsId(control); - control.appendChild(this.createLabel(xformsDocument, caption)); - - final XSObjectList mvFacets = controlType.getMultiValueFacets(); - if (mvFacets.getLength() != 1) - { - throw new RuntimeException("expected exactly one MultiValueFacet for " + controlType); - } - - final XSObjectList annotations = - ((XSMultiValueFacet)mvFacets.item(0)).getAnnotations(); - - final Map enumValues = - new LinkedHashMap(enumFacets.getLength()); - for (int i = 0; i < enumFacets.getLength(); i++) - { - enumValues.put(enumFacets.item(i), - (annotations.getLength() == enumFacets.getLength() - ? (XSAnnotation)annotations.item(i) - : null)); - } - - // TODO: Figure out an intelligent or user determined way to decide between - // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply) - // Possibly look for special appInfo section in the schema and if not present default to checkBox... - // - // For now, use checkbox if there are < DEFAULT_LONG_LIST_MAX_SIZE items, otherwise use long control - String appearance = extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI, - "appearance", - this.getAnnotation(owner), - resourceBundle); - if (appearance == null || appearance.length() == 0) - { - appearance = enumValues.size() < Schema2XForms.LONG_LIST_SIZE ? "full" : "compact"; - } - control.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":appearance", - appearance); - final Element choices = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":choices"); - this.setXFormsId(choices); - control.appendChild(choices); - this.addChoicesForSelectControl(xformsDocument, choices, enumValues, resourceBundle); - return control; - } - - private XSAnnotation getAnnotation(final XSObject o) - { - return (o instanceof XSElementDeclaration - ? ((XSElementDeclaration)o).getAnnotation() - : (o instanceof XSAttributeDeclaration - ? ((XSAttributeDeclaration)o).getAnnotation() - : (o instanceof XSAttributeUse - ? ((XSAttributeUse)o).getAttrDeclaration().getAnnotation() - : null))); - } - - /** - * This method is invoked after an xforms:bind element is created for the specified SimpleType. - * The implementation is responsible for setting setting any/all bind attributes - * except for id and ref - these have been automatically set - * by the caller (and should not be touched by implementation of startBindElement) - * prior to invoking startBindElement. - * The caller automatically adds the returned element to the model section of - * the form. - * - * @param bindElement The bindElement being processed. - * @param schema XML Schema type of the element/attribute this bind is for. - * @param controlType - * @param owner - * @param o - * @return The bind Element to use in the XForm - bindElement or a replacement. - */ - public Element startBindElement(final Element bindElement, - final XSModel schema, - final XSTypeDefinition controlType, - final XSObject owner, - final SchemaUtil.Occurrence o) - { - // START WORKAROUND - // Due to a Chiba bug, anyType is not a recognized type name. - // so, if this is an anyType, then we'll just skip the type - // setting. - // - // type.getName() may be 'null' for anonymous types, so compare against - // static string (see bug #1172541 on sf.net) - final List constraints = new LinkedList(); - if (controlType instanceof XSSimpleTypeDefinition && - ((XSSimpleTypeDefinition)controlType).getBuiltInKind() != XSConstants.ANYSIMPLETYPE_DT) - { - String typeName = this.getXFormsTypeName(bindElement.getOwnerDocument(), - schema, - controlType); - if (typeName != null && typeName.length() != 0) - { - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":type", - typeName); - } - - typeName = SchemaUtil.getBuiltInTypeName(controlType); - if (typeName != null && typeName.length() != 0) - { - bindElement.setAttributeNS(NamespaceService.ALFRESCO_URI, - NamespaceService.ALFRESCO_PREFIX + ":builtInType", - typeName); - } - final StringList lexicalPatterns = ((XSSimpleTypeDefinition)controlType).getLexicalPattern(); - - // NOTE: from glen.johnson@alfresco.com - // Workaround to fix issue WCM-952 - // - // I added expression '&& !typeName.equals(SchemaSymbols.ATTVAL_INTEGER') - // onto the end of loop condition expression below. - // - // This is to stop the pattern matching constraint (using deprecated chiba:match() function) - // from being generated into binding elements that are linked to "xs:integer" - // elements (in the xform instance) - // - // If this pattern match constraint is indeed added to the binding element linked to - // a "xs:integer" element in the xform instance, then a value is always required - // for that element - even if the corresponding schema has minOccurs="0" for - // that element i.e. it causes a value to be required for "optional" xs:integer - // elements. - // - // Note that the chiba:match() function is unsupported and will be removed from Chiba - // in the future, so a solution enabling its complete removal will need to be found. - // I do not see why it has been included here. The Schema inside the xform - // model should take care of most validation needs. - // In the past, when I have completely removed this constraint (see CHK-2333), restrictions - // using in the Schema fail to get enforced - - // Causing the failure of org.alfresco.web.forms.xforms.Schema2XFormsTest.testConstraint() - // - for (int i = 0; lexicalPatterns != null && i < lexicalPatterns.getLength() - && !SchemaSymbols.ATTVAL_INTEGER.equals(typeName); i++) - { - String pattern = lexicalPatterns.item(i); - if (o.isOptional()) - { - pattern= "(" + pattern + ")?"; - } - constraints.add("chiba:match(., '" + pattern + "',null)"); - } - - XSSimpleTypeDefinition simpleControlType = ((XSSimpleTypeDefinition) controlType); - - if (simpleControlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MAXLENGTH)) - { - constraints.add("string-length(.) <= " + simpleControlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MAXLENGTH)); - } - - if (simpleControlType.isDefinedFacet(XSSimpleTypeDefinition.FACET_MINLENGTH)) - { - constraints.add("string-length(.) >= " + simpleControlType.getLexicalFacetValue(XSSimpleTypeDefinition.FACET_MINLENGTH)); - } - - } - - - final short constraintType = - (owner != null && owner instanceof XSElementDeclaration - ? ((XSElementDeclaration)owner).getConstraintType() - : (owner != null && owner instanceof XSAttributeDeclaration - ? ((XSAttributeDeclaration)owner).getConstraintType() - : (owner != null && owner instanceof XSAttributeUse - ? ((XSAttributeUse)owner).getConstraintType() - : XSConstants.VC_NONE))); - - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":readonly", - (constraintType == XSConstants.VC_FIXED) + "()"); - - if (controlType instanceof XSSimpleTypeDefinition) - { - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":required", - (o.minimum != 0) + "()"); - } - else if (controlType instanceof XSComplexTypeDefinition) - { - // make all complex types not required since it helps with validation - otherwise - // chiba seems to expect a nodevalue for the container element - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":required", - "false()"); - - } - - //no more minOccurs & maxOccurs element: add a constraint if maxOccurs>1: - //count(.) <= maxOccurs && count(.) >= minOccurs - final String nodeset = bindElement.getAttributeNS(NamespaceConstants.XFORMS_NS, - "nodeset"); - if (o.minimum > 1) - { - //if 0 or 1 -> no constraint (managed by "required") - constraints.add("count(../" + nodeset + ") >= " + o.minimum); - } - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":minOccurs", - String.valueOf(o.minimum)); - if (o.maximum > 1) - { - //if 1 or unbounded -> no constraint - constraints.add("count(../" + nodeset + ") <= " + o.maximum); - } - - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":maxOccurs", - o.isUnbounded() ? "unbounded" : String.valueOf(o.maximum)); - - if (constraints.size() != 0) - { - bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":constraint", - StringUtils.join((String[])constraints.toArray(new String[constraints.size()]), " and ")); - } - return bindElement; - } - - /** - * Get a fully qualified name for this element, and eventually declares a new prefix for the namespace if - * it was not declared before - * - * @param element - * @param xformsDocument - * @return The element name - */ - private String getElementName(final XSObject element, - final Document xformsDocument) - { - String elementName = element.getName(); - String namespace = element.getNamespace(); - if (namespace != null && namespace.length() != 0) - { - final String prefix = NamespaceResolver.getPrefix(xformsDocument.getDocumentElement(), namespace); - elementName = prefix + ":" + elementName; - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[getElementName] " + element.getName() + "," + namespace + " = " + elementName); - - return elementName; - } - - private static String addNamespace(final Element e, String nsPrefix, final String ns) - { - String prefix; - if ((prefix = NamespaceResolver.getPrefix(e, ns)) != null) - { - return prefix; - } - - if (nsPrefix == null || e.hasAttributeNS(NamespaceConstants.XMLNS_NS, nsPrefix)) - { - // Generate a unique prefix - int suffix = 1; - while (e.hasAttributeNS(NamespaceConstants.XMLNS_NS, nsPrefix = "ns" + suffix)) - { - suffix++; - } - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[addNamespace] adding namespace " + ns + " with prefix " + nsPrefix + " to " + e.getNodeName()); - - e.setAttributeNS(NamespaceConstants.XMLNS_NS, - NamespaceConstants.XMLNS_PREFIX + ':' + nsPrefix, - ns); - - return nsPrefix; - } - - private void createTriggersForRepeats(final Document xformsDocument, final Element rootGroup) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[createTriggersForRepeats] start"); - - final HashMap bindIdToBind = new HashMap(); - final NodeList binds = xformsDocument.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "bind"); - for (int i = 0; i < binds.getLength(); i++) - { - final Element b = (Element)binds.item(i); - bindIdToBind.put(b.getAttributeNS(null, "id"), b); - } - - final NodeList repeats = xformsDocument.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "repeat"); - final HashMap bindToRepeat = new HashMap(); - for (int i = 0; i < repeats.getLength(); i++) - { - Element r = (Element)repeats.item(i); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[createTriggersForRepeats] processing repeat " + r.getAttributeNS(null, "id")); - - Element bind = bindIdToBind.get(r.getAttributeNS(NamespaceConstants.XFORMS_NS, "bind")); - bindToRepeat.put(bind, r); - - String xpath = ""; - - do - { - if (xpath.length() != 0) - { - xpath = '/' + xpath; - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[createTriggersForRepeats] walking bind " + bind.getAttributeNS(null, "id")); - - String s = bind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset"); - s = s.replaceAll("^([^\\[]+).*$", "$1"); - if (bindToRepeat.containsKey(bind) && !r.equals(bindToRepeat.get(bind))) - { - s += "[index(\'" + bindToRepeat.get(bind).getAttributeNS(null, "id") + "\')]"; - } - xpath = s + xpath; - bind = ((NamespaceConstants.XFORMS_PREFIX + ":bind").equals(bind.getParentNode().getNodeName()) - ? (Element)bind.getParentNode() - : null); - } - while (bind != null); - this.createTriggersForRepeat(xformsDocument, - rootGroup, - r.getAttributeNS(null, "id"), - xpath, - r.getAttributeNS(NamespaceConstants.XFORMS_NS, "bind")); - } - } - - private Element createTrigger(final Document xformsDocument, - final String id, - final String bindId, - final String label, - final Element... actions) - { - final Element trigger = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":trigger"); - this.setXFormsId(trigger, id != null ? id : null); - - //copy the bind attribute - if (bindId != null) - { - trigger.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind", - bindId); - } - trigger.appendChild(this.createLabel(xformsDocument, label)); - - //insert action - final Element actionWrapper = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":action"); - trigger.appendChild(actionWrapper); - - for (final Element action : actions) - { - actionWrapper.appendChild(action); - this.setXFormsId(action); - } - return trigger; - } - - - /** - * add triggers to use the repeat elements (allow to add an element, ...) - */ - private void createTriggersForRepeat(final Document xformsDocument, - final Element rootGroup, - final String repeatId, - final String nodeset, - final String bindId) - { - //xforms:at = xforms:index from the "id" attribute on the repeat element - //trigger insert - Element action = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":insert"); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":nodeset", - nodeset); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":position", - "before"); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":at", - "1"); - - final Element trigger_insert_before = this.createTrigger(xformsDocument, - repeatId + "-insert_before", - bindId, - "insert at beginning", - action); - - action = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":insert"); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":nodeset", - nodeset); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":position", - "after"); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":at", - NamespaceConstants.XFORMS_PREFIX + ":index('" + repeatId + "')"); - - final Element trigger_insert_after = this.createTrigger(xformsDocument, - repeatId + "-insert_after", - bindId, - "insert after selected", - action); - - //trigger delete - action = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":delete"); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":nodeset", - nodeset); - action.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":at", - NamespaceConstants.XFORMS_PREFIX + ":index('" + repeatId + "')"); - - final Element trigger_delete = this.createTrigger(xformsDocument, - repeatId != null ? repeatId + "-delete" : null, - bindId, - "delete selected", - action); - - //add the triggers - rootGroup.appendChild(trigger_insert_before); - rootGroup.appendChild(trigger_insert_after); - rootGroup.appendChild(trigger_delete); - } - - private Element createSubmissionElement(final Document xformDocument, - final String id, - final boolean validate) - { - final Element result = xformDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":submission"); - - this.setXFormsId(result, id); - - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":validate", - validate ? "true" : "false"); - - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":action", - this.action == null ? "" : this.base + this.action); - - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":method", - (this.submitMethod != null - ? this.submitMethod - : Schema2XForms.SubmitMethod.POST).toString()); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":encoding", - "UTF-8"); - return result; - } - - private Element createSubmitControl(final Document xformsDocument, - final Element submission, - final String id, - final String label) - { - final Element result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":submit"); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":submission", - submission.getAttributeNS(null, "id")); - this.setXFormsId(result, id); - - result.appendChild(this.createLabel(xformsDocument, label)); - - return result; - } - - private void createSubmitElements(final Document xformsDocument, - final Element modelSection, - final Element rootGroup) - { - - Element submission = - this.createSubmissionElement(xformsDocument, "submission-validate", true); - modelSection.appendChild(submission); - - Element submit = this.createSubmitControl(xformsDocument, submission, "submit", "Submit"); - rootGroup.appendChild(submit); - - submission = this.createSubmissionElement(xformsDocument, "submission-draft", false); - modelSection.appendChild(submission); - - submit = this.createSubmitControl(xformsDocument, - submission, - "save-draft", - "Save Draft"); - rootGroup.appendChild(submit); - } - - private Element createXFormsItem(final Document xformsDocument, - final String label, - final String value) - { - final Element item = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":item"); - this.setXFormsId(item); - item.appendChild(this.createLabel(xformsDocument, label)); - - final Element e = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":value"); - this.setXFormsId(e); - e.appendChild(xformsDocument.createTextNode(value)); - item.appendChild(e); - return item; - } - - private Element createLabel(final Document xformsDocument, - final String label) - { - final Element e = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":label"); - this.setXFormsId(e); - e.appendChild(xformsDocument.createTextNode(label)); - return e; - } - - private Element createBind(final Document xformsDocument, - final String nodeset) - { - final Element result = - xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":bind"); - final String id = this.setXFormsId(result); - result.setAttributeNS(NamespaceConstants.XFORMS_NS, - NamespaceConstants.XFORMS_PREFIX + ":nodeset", - nodeset); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("[createBind] created bind " + id + " for nodeset " + nodeset); - - return result; - } - - private boolean isRepeated(SchemaUtil.Occurrence occurs, XSTypeDefinition type) - { - // return immediately if occurs signifies repeat - if (occurs.isRepeated()) - { - return true; - } - - boolean repeated = false; - - if (occurs.isOptional()) - { - // if element is optional check the type, for - // simple and 'any' types return false - - if ((type instanceof XSSimpleTypeDefinition == false) && - ("anyType".equals(type.getName()) == false)) - { - repeated = true; - } - } - - return repeated; - } - - /* - * split the name of element in two parts (localname, namespaceURI) - */ - private Pair parseName(String name, Document resolver) - { - int pos = name.indexOf(':'); - String localName = name; - String namespace = null; - - if (pos != -1) - { - localName = name.substring(pos + 1); - namespace = resolver.lookupNamespaceURI(name.substring(0, pos)); - } - - return new Pair(localName, namespace); - } -} diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsProperties.java b/source/java/org/alfresco/web/forms/xforms/Schema2XFormsProperties.java deleted file mode 100644 index 850871f887..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsProperties.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms.xforms; - -import java.io.InputStream; -import java.util.*; -import org.alfresco.model.ContentModel; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.forms.Form; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * @author Ariel Backenroth - */ -public class Schema2XFormsProperties -{ - ///////////////////////////////////////////////////////////////////////////// - - private class ResourceBundleWrapper - extends ResourceBundle - { - - private final ResourceBundle bundle; - private final ResourceBundle parent; - - public ResourceBundleWrapper(final ResourceBundle bundle, - final ResourceBundle parent) - { - LOGGER.debug("creating bundle " + bundle + - " with parent " + parent); - this.bundle = bundle; - this.parent = parent; - } - - public Enumeration getKeys() - { - final Enumeration bk = bundle.getKeys(); - final Enumeration pk = parent.getKeys(); - return new Enumeration() - { - - public boolean hasMoreElements() - { - return bk.hasMoreElements() || pk.hasMoreElements(); - } - - public String nextElement() - { - return (bk.hasMoreElements() - ? bk.nextElement() - : pk.nextElement()); - } - }; - } - - protected Object handleGetObject(final String key) - { - try - { - return this.bundle.getObject(key); - } - catch (MissingResourceException mre1) - { - try - { - return this.parent.getObject(key); - } - catch (MissingResourceException mre2) - { - return null; - } - } - } - } - - ///////////////////////////////////////////////////////////////////////////// - - private static final Log LOGGER = LogFactory.getLog(Schema2XFormsProperties.class); - - private final ContentService contentService; - private final NamespaceService namespaceService; - private final NodeService nodeService; - private final SearchService searchService; - private boolean formatCaption = true; - private String[] locations; - - public Schema2XFormsProperties(final ContentService contentService, - final NamespaceService namespaceService, - final NodeService nodeService, - final SearchService searchService) - { - this.contentService = contentService; - this.namespaceService = namespaceService; - this.nodeService = nodeService; - this.searchService = searchService; - } - - public ResourceBundle getResourceBundle(final Form form, final Locale locale) - { - final LinkedList bundles = new LinkedList(); - for (String location : this.locations) - { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - location = location.replace("${form.name}", - (NamespaceService.CONTENT_MODEL_PREFIX + - ':' + form.getName())); - if (location.startsWith("alfresco:")) - { - location = location.substring("alfresco:".length()); - loader = new ClassLoader(loader) - { - public InputStream getResourceAsStream(String name) - { - LOGGER.debug("loading resource " + name); - final ResultSet results = - searchService.query(Repository.getStoreRef(), - SearchService.LANGUAGE_LUCENE, - "PATH:\"" + name + "\""); - try - { - LOGGER.debug("search returned " + results.length() + - " results"); - if (results.length() == 1) - { - final NodeRef nr = results.getNodeRef(0); - final ContentReader reader = - contentService.getReader(nr, ContentModel.PROP_CONTENT); - return reader.getContentInputStream(); - } - else - { - return super.getResourceAsStream(name); - } - } - finally - { - results.close(); - } - } - }; - } - else if (location.startsWith("classpath:")) - { - location = location.substring("classpath:".length()); - } - - LOGGER.debug("using loader " + loader + " for location " + location); - try - { - final ResourceBundle rb = ResourceBundle.getBundle(location, - locale, - loader); - LOGGER.debug("found bundle " + rb + " for location " + location); - bundles.addFirst(rb); - } - catch (MissingResourceException mse) - { - LOGGER.debug("unable to located bundle at " + location + - ": " + mse.getMessage()); - } - } - - ResourceBundle result = null; - for (ResourceBundle rb : bundles) - { - result = (result == null ? rb : new ResourceBundleWrapper(rb, result)); - } - return result; - } - - public void setLocations(final String[] locations) - { - this.locations = locations; - } - - - public boolean isFormatCaption() - { - return formatCaption; - } - - public void setFormatCaption(boolean formatCaption) - { - this.formatCaption = formatCaption; - } - - public String toString() - { - return (this.getClass().getName() + "{" + - StringUtils.join(this.locations, ",") + - "}"); - } -} - diff --git a/source/java/org/alfresco/web/forms/xforms/SchemaUtil.java b/source/java/org/alfresco/web/forms/xforms/SchemaUtil.java deleted file mode 100644 index 35e9c74110..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/SchemaUtil.java +++ /dev/null @@ -1,761 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . */ -package org.alfresco.web.forms.xforms; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.TreeMap; -import java.util.TreeSet; - -import org.alfresco.util.EqualsHelper; -import org.alfresco.util.XMLUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xerces.xs.XSAttributeUse; -import org.apache.xerces.xs.XSComplexTypeDefinition; -import org.apache.xerces.xs.XSConstants; -import org.apache.xerces.xs.XSElementDeclaration; -import org.apache.xerces.xs.XSImplementation; -import org.apache.xerces.xs.XSLoader; -import org.apache.xerces.xs.XSModel; -import org.apache.xerces.xs.XSModelGroup; -import org.apache.xerces.xs.XSNamedMap; -import org.apache.xerces.xs.XSObjectList; -import org.apache.xerces.xs.XSParticle; -import org.apache.xerces.xs.XSSimpleTypeDefinition; -import org.apache.xerces.xs.XSTerm; -import org.apache.xerces.xs.XSTypeDefinition; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.DOMError; -import org.w3c.dom.DOMErrorHandler; -import org.w3c.dom.DOMLocator; -import org.w3c.dom.Document; -import org.w3c.dom.bootstrap.DOMImplementationRegistry; -import org.w3c.dom.ls.DOMImplementationLS; -import org.w3c.dom.ls.LSInput; - -/** - * Provides utility functions for xml schema parsing. - */ -public class SchemaUtil -{ - - //////////////////////////////////////////////////////////////////////////// - - public static class Occurrence - { - public final static int UNBOUNDED = -1; - - public final int minimum; - public final int maximum; - - public Occurrence(final XSParticle particle) - { - this(particle.getMinOccurs(), (particle.getMaxOccursUnbounded() - ? Occurrence.UNBOUNDED - : particle.getMaxOccurs())); - } - - public Occurrence(final int minimum) - { - this(minimum, Occurrence.UNBOUNDED); - } - - public Occurrence(final int minimum, final int maximum) - { - this.minimum = minimum; - this.maximum = maximum; - } - - public boolean isRepeated() - { - return this.isUnbounded() || this.maximum > 1; - } - - public boolean isOptional() - { - return this.minimum == 0 && this.maximum == 1; - } - - public boolean isUnbounded() - { - return this.maximum == UNBOUNDED; - } - - public String toString() - { - return "minimum=" + minimum + ", maximum=" + maximum; - } - } - - //////////////////////////////////////////////////////////////////////////// - - private final static Comparator TYPE_EXTENSION_SORTER = - new Comparator() - { - public int compare(final XSTypeDefinition type1, final XSTypeDefinition type2) - { - int result = 0; - if (type1 == null && type2 != null) - { - result = -1; - } - else if (type1 != null && type2 == null) - { - result = 1; - } - else if (type1 == type2 || (type1 == null && type2 == null)) - { - result = 0; - } - else - { - result = (type1.derivedFromType(type2, XSConstants.DERIVATION_EXTENSION) - ? 1 - : (type2.derivedFromType(type1, XSConstants.DERIVATION_EXTENSION) - ? -1 - : type1.getName().compareTo(type2.getName()))); - } - if (LOGGER.isDebugEnabled() && false) - LOGGER.debug("compare(" + type1 + ", " + type2 + ") = " + result); - return result; - } - }; - - //////////////////////////////////////////////////////////////////////////// - - private final static Log LOGGER = LogFactory.getLog(SchemaUtil.class); - - private final static HashMap DATA_TYPE_TO_NAME = - new HashMap(); - static - { - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.ANYSIMPLETYPE_DT, "anyType"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.ANYURI_DT, "anyURI"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.BASE64BINARY_DT, "base64Binary"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.BOOLEAN_DT, "boolean"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.BYTE_DT, "byte"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.DATETIME_DT, "dateTime"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.DATE_DT, "date"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.DECIMAL_DT, "decimal"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.DOUBLE_DT, "double"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.DURATION_DT, "duration"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.ENTITY_DT, "ENTITY"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.FLOAT_DT, "float"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.GDAY_DT, "gDay"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.GMONTHDAY_DT, "gMonthDay"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.GMONTH_DT, "gMonth"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.GYEARMONTH_DT, "gYearMonth"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.GYEAR_DT, "gYear"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.IDREF_DT, "IDREF"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.ID_DT, "ID"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.INTEGER_DT, "integer"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.INT_DT, "int"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.LANGUAGE_DT, "language"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.LONG_DT, "long"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NAME_DT, "Name"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NCNAME_DT, "NCName"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NEGATIVEINTEGER_DT, "negativeInteger"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NMTOKEN_DT, "NMTOKEN"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NONNEGATIVEINTEGER_DT, "nonNegativeInteger"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NONPOSITIVEINTEGER_DT, "nonPositiveInteger"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NORMALIZEDSTRING_DT, "normalizedString"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.NOTATION_DT, "NOTATION"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.POSITIVEINTEGER_DT, "positiveInteger"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.QNAME_DT, "QName"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.SHORT_DT, "short"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.STRING_DT, "string"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.TIME_DT, "time"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.TOKEN_DT, "TOKEN"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.UNSIGNEDBYTE_DT, "unsignedByte"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.UNSIGNEDINT_DT, "unsignedInt"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.UNSIGNEDLONG_DT, "unsignedLong"); - SchemaUtil.DATA_TYPE_TO_NAME.put(XSConstants.UNSIGNEDSHORT_DT, "unsignedShort"); - }; - - /** - * Returns the most-specific built-in base type for the provided type. - */ - public static short getBuiltInType(final XSTypeDefinition type) - { - // type.getName() may be 'null' for anonymous types, so compare against - // static string (see bug #1172541 on sf.net) - if (SchemaUtil.DATA_TYPE_TO_NAME.get(XSConstants.ANYSIMPLETYPE_DT).equals(type.getName())) - { - return XSConstants.ANYSIMPLETYPE_DT; - } - final XSSimpleTypeDefinition simpleType = (XSSimpleTypeDefinition) type; - final short result = simpleType.getBuiltInKind(); - return (result == XSConstants.LIST_DT - ? SchemaUtil.getBuiltInType(simpleType.getItemType()) - : result); - } - - public static String getBuiltInTypeName(final XSTypeDefinition type) - { - final short s = SchemaUtil.getBuiltInType(type); - return SchemaUtil.getBuiltInTypeName(s); - } - - public static String getBuiltInTypeName(final short type) - { - return SchemaUtil.DATA_TYPE_TO_NAME.get(type); - } - - public static XSModel parseSchema(final Document schemaDocument, - final boolean failOnError) - throws FormBuilderException - { - try - { - // Get DOM Implementation using DOM Registry - System.setProperty(DOMImplementationRegistry.PROPERTY, - "org.apache.xerces.dom.DOMXSImplementationSourceImpl"); - - final DOMImplementationRegistry registry = - DOMImplementationRegistry.newInstance(); - - final DOMImplementationLS lsImpl = (DOMImplementationLS) - registry.getDOMImplementation("XML 1.0 LS 3.0"); - if (lsImpl == null) - { - throw new FormBuilderException("unable to create DOMImplementationLS using " + registry); - } - final LSInput in = lsImpl.createLSInput(); - in.setStringData(XMLUtil.toString(schemaDocument)); - - final XSImplementation xsImpl = (XSImplementation) - registry.getDOMImplementation("XS-Loader"); - final XSLoader schemaLoader = xsImpl.createXSLoader(null); - final DOMConfiguration config = (DOMConfiguration)schemaLoader.getConfig(); - final LinkedList errors = new LinkedList(); - config.setParameter("error-handler", new DOMErrorHandler() - { - public boolean handleError(final DOMError domError) - { - errors.add(domError); - return true; - } - }); - - final XSModel result = schemaLoader.load(in); - if (failOnError && errors.size() != 0) - { - final HashSet messages = new HashSet(); - StringBuilder message = null; - for (DOMError e : errors) - { - message = new StringBuilder(); - final DOMLocator dl = e.getLocation(); - if (dl != null) - { - message.append("at line ").append(dl.getLineNumber()) - .append(" column ").append(dl.getColumnNumber()); - if (dl.getRelatedNode() != null) - { - message.append(" node ").append(dl.getRelatedNode().getNodeName()); - } - message.append(": ").append(e.getMessage()); - } - messages.add(message.toString()); - } - - message = new StringBuilder(); - message.append(messages.size() > 1 ? "errors" : "error").append(" parsing schema: \n"); - for (final String s : messages) - { - message.append(s).append("\n"); - } - - throw new FormBuilderException(message.toString()); - } - - if (result == null) - { - throw new FormBuilderException("invalid schema"); - } - return result; - } - catch (ClassNotFoundException x) - { - throw new FormBuilderException(x); - } - catch (InstantiationException x) - { - throw new FormBuilderException(x); - } - catch (IllegalAccessException x) - { - throw new FormBuilderException(x); - } - } - - private static void buildTypeTree(final XSTypeDefinition type, - final TreeSet descendents, - final TreeMap> typeTree) - { - if (type == null) - { - return; - } - if (LOGGER.isDebugEnabled()) - LOGGER.debug("buildTypeTree(" + type.getName() + ", " + descendents.size() + " descendents)"); - if (descendents.size() > 0) - { - TreeSet compatibleTypes = typeTree.get(type.getName()); - - if (compatibleTypes == null) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("no compatible types found for " + type.getName() + ", creating a new set"); - compatibleTypes = new TreeSet(TYPE_EXTENSION_SORTER); - typeTree.put(type.getName(), compatibleTypes); - } - if (LOGGER.isDebugEnabled()) - LOGGER.debug("adding " + descendents.size() + " descendents to " + type.getName()); - compatibleTypes.addAll(descendents); - } - - final XSTypeDefinition parentType = type.getBaseType(); - if (parentType == null || - type.getTypeCategory() != parentType.getTypeCategory()) - { - return; - } - - if (type != parentType && parentType.getName() != null && !parentType.getName().equals("anyType")) - { - TreeSet newDescendents = typeTree.get(parentType.getName()); - if (newDescendents == null) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("type tree doesn't contain " + parentType.getName() + - ", creating a new descendant set"); - newDescendents = new TreeSet(TYPE_EXTENSION_SORTER); - } - if (LOGGER.isDebugEnabled()) - LOGGER.debug("adding " + descendents.size() + " descendants to existing " + newDescendents.size() + - " descendants of " + parentType.getName()); - newDescendents.addAll(descendents); - - //extension (we only add it to "newDescendants" because we don't want - //to have a type descendant to itself, but to consider it for the parent - if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) - { - final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition)type; - if (complexType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION && - !complexType.getAbstract() && - !descendents.contains(type)) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("adding " + type.getName() + - " to existing " + newDescendents.size() + - " descendents of " + parentType.getName()); - newDescendents.add(type); - } - } - - //note: extensions are impossible on simpleTypes ! - SchemaUtil.buildTypeTree(parentType, newDescendents, typeTree); - } - } - - public static TreeMap> - buildTypeTree(final XSModel schema) - { - final TreeMap> result = new TreeMap>(); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("buildTypeTree " + schema); - // build the type tree for complex types - final XSNamedMap types = schema.getComponents(XSConstants.TYPE_DEFINITION); - for (int i = 0; i < types.getLength(); i++) - { - final XSTypeDefinition t = (XSTypeDefinition)types.item(i); - if (t.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) - { - final XSComplexTypeDefinition type = (XSComplexTypeDefinition)t; - SchemaUtil.buildTypeTree(type, - new TreeSet(TYPE_EXTENSION_SORTER), - result); - } - } - - // build the type tree for simple types - for (int i = 0; i < types.getLength(); i++) - { - final XSTypeDefinition t = (XSTypeDefinition)types.item(i); - if (t.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) - { - SchemaUtil.buildTypeTree((XSSimpleTypeDefinition)t, - new TreeSet(TYPE_EXTENSION_SORTER), - result); - } - } - - // print out type hierarchy for debugging purposes - if (LOGGER.isDebugEnabled()) - { - for (String typeName : result.keySet()) - { - TreeSet descendents = result.get(typeName); - LOGGER.debug(">>>> for " + typeName + " Descendants=\n "); - Iterator it = descendents.iterator(); - while (it.hasNext()) - { - XSTypeDefinition desc = it.next(); - LOGGER.debug(" " + desc.getName()); - } - } - } - return result; - } - - public static XSParticle findCorrespondingParticleInComplexType(final XSElementDeclaration elDecl) - { - final XSComplexTypeDefinition complexType = elDecl.getEnclosingCTDefinition(); - if (complexType == null) - { - LOGGER.warn("unable to find corresponding particle for " + elDecl.getName() + - ". no enclosing complex type."); - return null; - } - - final XSParticle particle = complexType.getParticle(); - final XSTerm term = particle.getTerm(); - if (! (term instanceof XSModelGroup)) - { - LOGGER.warn("unable to find corresponding particle for " + elDecl.getName() + - ". term " + term + " is not a model group."); - return null; - } - final XSParticle result = SchemaUtil.findCorrespondingParticleInModelGroup((XSModelGroup)term, elDecl); - if (result == null) - { - final String msg = ("unable to find corresponding particle for " + elDecl.getName() + - " in term " + term); - if (LOGGER.isDebugEnabled()) - { - throw new NullPointerException(msg); - } - else - { - LOGGER.warn(msg); - } - } - return result; - } - - private static XSParticle findCorrespondingParticleInModelGroup(final XSModelGroup modelGroup, - final XSElementDeclaration elDecl) - { - final XSObjectList particles = modelGroup.getParticles(); - if (particles == null || particles.getLength() == 0) - { - LOGGER.debug("unable to find corresponding particle for " + elDecl.getName() + - ". group " + modelGroup + " contains no particles."); - return null; - } - - for (int i = 0; i < particles.getLength(); i++) - { - XSParticle part = (XSParticle)particles.item(i); - final XSTerm thisTerm = part.getTerm(); - if (thisTerm instanceof XSModelGroup) - { - part = SchemaUtil.findCorrespondingParticleInModelGroup((XSModelGroup)thisTerm, elDecl); - if (part != null) - { - return part; - } - } - else - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("checking term " + thisTerm.getName() + - " in " + modelGroup.getName() + "(" + modelGroup.getClass().getName() + ")"); - } - if (thisTerm == elDecl) - { - return part; - } - } - } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("unable to find corresponding particle for " + elDecl.getName() + - ". " + elDecl.getName() + - " not found in " + particles.getLength() + " particles"); - } - return null; - } - - /** - * check that the element defined by this name is declared directly in the type - */ - public static boolean isElementDeclaredIn(String name, String namespace, - XSComplexTypeDefinition type, - boolean recursive) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("isElement " + name + " declared in " + type.getName()); - } - - //test if extension + declared in parent + not recursive -> NOK - if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) - { - XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType(); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("testing if it is not on parent " + parent.getName()); - if (SchemaUtil.isElementDeclaredIn(name, namespace, parent, true)) - return false; - } - - boolean found = false; - XSParticle particle = type.getParticle(); - if (particle != null) - { - XSTerm term = particle.getTerm(); - if (term instanceof XSModelGroup) - { - XSModelGroup group = (XSModelGroup) term; - found = SchemaUtil.isElementDeclaredIn(name, namespace, group); - } - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("isElement " + name + - " declared in " + type.getName() + ": " + found); - - return found; - } - - /** - * private recursive method called by isElementDeclaredIn(String name, XSComplexTypeDefinition type) - */ - public static boolean isElementDeclaredIn(String name, String namespace, XSModelGroup group) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("isElement " + name + " declared in group " + group.getName()); - - boolean found = false; - XSObjectList particles = group.getParticles(); - for (int i = 0; i < particles.getLength(); i++) - { - XSParticle subPart = (XSParticle)particles.item(i); - XSTerm subTerm = subPart.getTerm(); - if (subTerm instanceof XSElementDeclaration) - { - XSElementDeclaration elDecl = (XSElementDeclaration) subTerm; - if (EqualsHelper.nullSafeEquals(namespace, elDecl.getNamespace()) && name.equals(elDecl.getName())) - found = true; - } - else if (subTerm instanceof XSModelGroup) - { - found = SchemaUtil.isElementDeclaredIn(name, namespace, (XSModelGroup) subTerm); - } - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("isElement " + name + " declared in group " + group.getName() + ": " + found); - } - return found; - } - - public static boolean doesElementComeFromExtension(final XSElementDeclaration element, - final XSComplexTypeDefinition controlType) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("doesElementComeFromExtension for " + element.getName() + - " and controlType=" + controlType.getName()); - } - if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) - { - final XSTypeDefinition baseType = controlType.getBaseType(); - if (baseType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) - { - final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType; - if (SchemaUtil.isElementDeclaredIn(element.getName(), element.getNamespace(), complexType, true)) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("doesElementComeFromExtension: yes"); - } - return true; - } - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("doesElementComeFromExtension: recursive call on previous level"); - } - return SchemaUtil.doesElementComeFromExtension(element, complexType); - } - } - return false; - } - - /** - * check that the element defined by this name is declared directly in the type - */ - public static boolean isAttributeDeclaredIn(final XSAttributeUse attr, - final XSComplexTypeDefinition type, - final boolean recursive) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("is Attribute " + attr.getAttrDeclaration().getName() + " declared in " + type.getName()); - } - - //check on parent if not recursive - if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) - { - XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType(); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("testing if it is not on parent " + parent.getName()); - } - if (SchemaUtil.isAttributeDeclaredIn(attr, parent, true)) - { - return false; - } - } - - //check on this type (also checks recursively) - boolean found = false; - final XSObjectList attrs = type.getAttributeUses(); - for (int i = 0; i < attrs.getLength(); i++) - { - if ((XSAttributeUse)attrs.item(i) == attr) - { - found = true; - break; - } - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("is Attribute " + attr.getName() + - " declared in " + type.getName() + ": " + found); - } - - return found; - } - - /** - * check that the element defined by this name is declared directly in the type - * -> idem with string - */ - public static boolean isAttributeDeclaredIn(String attrName, String namespace, XSComplexTypeDefinition type, boolean recursive) - { - boolean found = false; - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName()); - - if (attrName.startsWith("@")) - attrName = attrName.substring(1); - - //check on parent if not recursive - if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) - { - XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType(); - if (LOGGER.isDebugEnabled()) - LOGGER.debug("testing if it is not on parent " + parent.getName()); - if (SchemaUtil.isAttributeDeclaredIn(attrName, namespace, parent, true)) - return false; - } - - //check on this type (also checks recursively) - final XSObjectList attrs = type.getAttributeUses(); - for (int i = 0; i < attrs.getLength() && !found; i++) - { - final XSAttributeUse anAttr = (XSAttributeUse) attrs.item(i); - if (anAttr != null) - { - String name = anAttr.getName(); - if (name == null || name.length() == 0) - name = anAttr.getAttrDeclaration().getName(); - if (EqualsHelper.nullSafeEquals(namespace, anAttr.getAttrDeclaration().getNamespace()) && attrName.equals(name)) - found = true; - } - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName() + ": " + found); - - return found; - } - - public static boolean doesAttributeComeFromExtension(XSAttributeUse attr, - XSComplexTypeDefinition controlType) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("doesAttributeComeFromExtension for " + attr.getAttrDeclaration().getName() + - " and controlType=" + controlType.getName()); - } - - if (controlType.getDerivationMethod() != XSConstants.DERIVATION_EXTENSION) - { - return false; - } - - final XSTypeDefinition baseType = controlType.getBaseType(); - if (baseType.getTypeCategory() != XSTypeDefinition.COMPLEX_TYPE) - { - return false; - } - - final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType; - if (SchemaUtil.isAttributeDeclaredIn(attr, complexType, true)) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("doesAttributeComeFromExtension: yes"); - return true; - } - - //recursive call - if (LOGGER.isDebugEnabled()) - LOGGER.debug("doesAttributeComeFromExtension: recursive call on previous level"); - return SchemaUtil.doesAttributeComeFromExtension(attr, complexType); - } - - /** - * finds the minOccurs and maxOccurs of an element declaration - * - * @return a table containing minOccurs and MaxOccurs - */ - public static Occurrence getOccurrence(final XSElementDeclaration elDecl) - { - //get occurance on encosing element declaration - final XSParticle particle = - SchemaUtil.findCorrespondingParticleInComplexType(elDecl); - final Occurrence result = particle == null ? new Occurrence(1, 1) : new Occurrence(particle); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("getOccurrence for " + elDecl.getName() + - ", " + result); - } - return result; - } -} diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java deleted file mode 100644 index cd97ca8d97..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java +++ /dev/null @@ -1,926 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms.xforms; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import javax.faces.context.ExternalContext; -import javax.faces.context.FacesContext; -import javax.faces.context.ResponseWriter; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; - -import org.alfresco.service.cmr.security.AuthenticationService; -import org.alfresco.util.Pair; -import org.alfresco.util.XMLUtil; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.bean.NavigationBean; -import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.forms.Form; -import org.alfresco.web.forms.FormProcessor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.xerces.xs.XSModel; -import org.chiba.xml.events.ChibaEventNames; -import org.chiba.xml.events.DOMEventNames; -import org.chiba.xml.events.XFormsEventNames; -import org.chiba.xml.events.XMLEvent; -import org.chiba.xml.ns.NamespaceConstants; -import org.chiba.xml.xforms.ChibaBean; -import org.chiba.xml.xforms.connector.AbstractConnector; -import org.chiba.xml.xforms.connector.SubmissionHandler; -import org.chiba.xml.xforms.core.Instance; -import org.chiba.xml.xforms.core.Model; -import org.chiba.xml.xforms.core.ModelItem; -import org.chiba.xml.xforms.core.Submission; -import org.chiba.xml.xforms.core.impl.DefaultValidatorMode; -import org.chiba.xml.xforms.exception.XFormsException; -import org.chiba.xml.xforms.ui.RepeatItem; -import org.chiba.xml.xforms.ui.Upload; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.events.Event; -import org.w3c.dom.events.EventListener; -import org.w3c.dom.events.EventTarget; -import org.xml.sax.SAXException; - - -/** - * Bean for interacting with the chiba processor from the ui using ajax requests. - * Manages the chiba bean lifecycle. - */ -public class XFormsBean implements Serializable -{ - private static final long serialVersionUID = -7979077333882370784L; - - ///////////////////////////////////////////////////////////////////////////// - - public static class AlfrescoSubmissionHandler - extends AbstractConnector - implements SubmissionHandler - { - - public Map submit(final Submission submission, - final Node instance) - throws XFormsException - { - if (XFormsBean.LOGGER.isDebugEnabled()) - { - XFormsBean.LOGGER.debug(this.getClass().getName() + - " recieved submission " + XMLUtil.toString(instance, true)); - } - final FacesContext fc = FacesContext.getCurrentInstance(); - //make the XFormsBean available for this session - final XFormsBean xforms = (XFormsBean)FacesHelper.getManagedBean(fc, BEAN_NAME); - xforms.handleSubmit(instance); - return Collections.EMPTY_MAP; - } - } - - ///////////////////////////////////////////////////////////////////////////// - - /** - */ - class XFormsSession implements FormProcessor.Session - { - private static final long serialVersionUID = 1L; - private final Document formInstanceData; - private final String formInstanceDataName; - private final Form form; - - private ChibaBean chibaBean; - private final Schema2XForms schema2XForms; - private final List eventLog = new LinkedList(); - - public XFormsSession(final Document formInstanceData, - final String formInstanceDataName, - final Form form, - final String baseUrl, - final boolean formatCaption) - { - this.formInstanceData = formInstanceData; - this.formInstanceDataName = formInstanceDataName; - this.form = form; - this.schema2XForms = new Schema2XForms(/* "/ajax/invoke/XFormsBean.handleAction" */ null, - Schema2XForms.SubmitMethod.POST, - /* baseUrl */ "alfresco:" + XFormsBean.class.getName(), formatCaption); - } - - public void destroy() - { - try - { - this.chibaBean.shutdown(); - } - catch (XFormsException xfe) - { - LOGGER.debug(xfe); - } - } - - public Form getForm() - { - return this.form; - } - - public Document getFormInstanceData() - { - return this.formInstanceData; - } - - public String getFormInstanceDataName() - { - return this.formInstanceDataName; - } - - public Schema2XForms getSchema2XForms() - { - return this.schema2XForms; - } - - public ChibaBean getChibaBean() - { - return this.chibaBean; - } - - public List getEventLog() - { - return this.eventLog; - } - } - - ///////////////////////////////////////////////////////////////////////////// - - private static final Log LOGGER = LogFactory.getLog(XFormsBean.class); - - private XFormsSession xformsSession; - private transient Schema2XFormsProperties schema2XFormsProperties; -// private AVMBrowseBean avmBrowseBean; // WCM - private NavigationBean navigator; - // lock for XFormSession.eventLog - private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock(); - private Lock writeLock = rwLock.writeLock(); - private Lock readLock = rwLock.readLock(); - - public static String BEAN_NAME = "XFormsBean"; - - public XFormsSession getXformsSession() - { - if (this.xformsSession == null) - { - throw new IllegalStateException("Incomplete user session. Please restart the form."); - } - return this.xformsSession; - } - - /** - * @param schema2XFormsProperties the schema2XFormsProperties to set. - */ - public void setSchema2XFormsProperties(final Schema2XFormsProperties schema2XFormsProperties) - { - this.schema2XFormsProperties = schema2XFormsProperties; - } - - protected Schema2XFormsProperties getSchema2XFormsProperties() - { - if (schema2XFormsProperties == null) - { - schema2XFormsProperties = (Schema2XFormsProperties)FacesHelper.getManagedBean( - FacesContext.getCurrentInstance(), "Schema2XFormsProperties"); - } - return schema2XFormsProperties; - } - -// // WCM -// /** -// * @param avmBrowseBean the avmBrowseBean to set. -// */ -// public void setAvmBrowseBean(final AVMBrowseBean avmBrowseBean) -// { -// this.avmBrowseBean = avmBrowseBean; -// } -// -// public void setNavigator(final NavigationBean navigator) -// { -// this.navigator = navigator; -// } -// - /** @param xformsSession the current session */ - public void setXFormsSession(final XFormsSession xformsSession) - throws FormBuilderException, - XFormsException - { - this.xformsSession = xformsSession; - - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final ExternalContext externalContext = facesContext.getExternalContext(); - final HttpServletRequest request = (HttpServletRequest) - externalContext.getRequest(); - final ServletContext servletContext = (ServletContext) - externalContext.getContext(); - - writeLock.lock(); - try - { - final ChibaBean chibaBean = new ChibaBean(); - chibaBean.setConfig(servletContext.getRealPath("/WEB-INF/chiba.xml")); - Pair chibaPair = this.getXFormsDocument(); - chibaBean.setXMLContainer(chibaPair.getFirst(), chibaPair.getSecond()); - - final EventTarget et = (EventTarget) - chibaBean.getXMLContainer().getDocumentElement(); - final EventListener el = new EventListener() - { - public void handleEvent(final Event e) - { - final XMLEvent xmle = (XMLEvent)e; - if (XFormsBean.LOGGER.isDebugEnabled()) - XFormsBean.LOGGER.debug("received event " + xmle.getType() + ": " + xmle); - - XFormsBean.this.xformsSession.eventLog.add(xmle); - } - }; - - // interaction events my occur during init so we have to register before - et.addEventListener(ChibaEventNames.LOAD_URI, el, true); - et.addEventListener(ChibaEventNames.RENDER_MESSAGE, el, true); - et.addEventListener(ChibaEventNames.REPLACE_ALL, el, true); - - et.addEventListener(XFormsEventNames.ENABLED, el, true); - et.addEventListener(XFormsEventNames.DISABLED, el, true); - et.addEventListener(XFormsEventNames.REQUIRED, el, true); - et.addEventListener(XFormsEventNames.OPTIONAL, el, true); - et.addEventListener(XFormsEventNames.READONLY, el, true); - et.addEventListener(XFormsEventNames.READWRITE, el, true); - et.addEventListener(XFormsEventNames.VALID, el, true); - et.addEventListener(XFormsEventNames.INVALID, el, true); - et.addEventListener(XFormsEventNames.IN_RANGE, el, true); - et.addEventListener(XFormsEventNames.OUT_OF_RANGE, el, true); - et.addEventListener(XFormsEventNames.SELECT, el, true); - et.addEventListener(XFormsEventNames.DESELECT, el, true); - et.addEventListener(XFormsEventNames.INSERT, el, true); - et.addEventListener(XFormsEventNames.DELETE, el, true); - - chibaBean.init(); - - // register for notification events - et.addEventListener(XFormsEventNames.SUBMIT, el, true); - et.addEventListener(XFormsEventNames.SUBMIT_DONE, el, true); - et.addEventListener(XFormsEventNames.SUBMIT_ERROR, el, true); - et.addEventListener(ChibaEventNames.STATE_CHANGED, el, true); - et.addEventListener(ChibaEventNames.PROTOTYPE_CLONED, el, true); - et.addEventListener(ChibaEventNames.ID_GENERATED, el, true); - et.addEventListener(ChibaEventNames.ITEM_INSERTED, el, true); - et.addEventListener(ChibaEventNames.ITEM_DELETED, el, true); - et.addEventListener(ChibaEventNames.INDEX_CHANGED, el, true); - et.addEventListener(ChibaEventNames.SWITCH_TOGGLED, el, true); - this.xformsSession.chibaBean = chibaBean; - } - finally - { - writeLock.unlock(); - } - } - - /** - * Initializes the chiba process with the xform and registers any necessary - * event listeners. - */ - public XFormsSession createSession(final Document formInstanceData, - final String formInstanceDataName, - final Form form) - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("initializing xforms session with form " + form.getName() + - " and instance data " + formInstanceDataName + - " (" + formInstanceData + ")"); - } - - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final ExternalContext externalContext = facesContext.getExternalContext(); - final HttpServletRequest request = (HttpServletRequest) - externalContext.getRequest(); - - final String baseUrl = (request.getScheme() + "://" + - request.getServerName() + ':' + - request.getServerPort() + - request.getContextPath()); - return this.new XFormsSession(formInstanceData, formInstanceDataName, form, baseUrl, getSchema2XFormsProperties().isFormatCaption()); - } - - /** - * Writes the xform out to the http servlet response. This allows - * us to use the browser to parse the xform using XMLHttpRequest. - */ - public void getXForm() throws IOException, XFormsException - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".getXForm()"); - final FacesContext context = FacesContext.getCurrentInstance(); - final ResponseWriter out = context.getResponseWriter(); - - readLock.lock(); - try - { - final ChibaBean chibaBean = this.getXformsSession().getChibaBean(); - final Node xformsDocument = chibaBean.getXMLContainer(); - XMLUtil.print(xformsDocument, out); - } - finally - { - readLock.unlock(); - } - } - - /** - * sets the value of a control in the processor. - */ - public void setXFormsValue() throws XFormsException, IOException - { - final FacesContext context = FacesContext.getCurrentInstance(); - final Map requestParameters = context.getExternalContext().getRequestParameterMap(); - final String id = (String)requestParameters.get("id"); - final String value = (String)requestParameters.get("value"); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".setXFormsValue(" + id + ", " + value + ")"); - - writeLock.lock(); - try - { - final ChibaBean chibaBean = this.getXformsSession().getChibaBean(); - - if (chibaBean.getContainer().lookup(id) instanceof Upload) - { - chibaBean.updateControlValue(id, null, value, value.getBytes("UTF-8")); - } - else - { - chibaBean.updateControlValue(id, value); - } - final ResponseWriter out = context.getResponseWriter(); - XMLUtil.print(this.getEventLog(), out); - out.close(); - } - finally - { - writeLock.unlock(); - } - } - - /** - * sets the value of a control in the processor. - */ - public void setRepeatIndeces() throws XFormsException, IOException - { - final FacesContext context = FacesContext.getCurrentInstance(); - final Map requestParameters = context.getExternalContext().getRequestParameterMap(); - final String repeatIds = (String)requestParameters.get("repeatIds"); - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".setRepeatIndeces(" + repeatIds + ")"); - - writeLock.lock(); - try - { - for (String id : repeatIds.split(",")) - { - final int index = Integer.parseInt((String)requestParameters.get(id)); - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".setRepeatIndex(" + id + ", " + index + ")"); - final ChibaBean chibaBean = this.getXformsSession().getChibaBean(); - chibaBean.updateRepeatIndex(id, index); - } - final ResponseWriter out = context.getResponseWriter(); - XMLUtil.print(this.getEventLog(), out); - out.close(); - } - finally - { - writeLock.unlock(); - } - } - - /** - * fires an action associated with a trigger. - */ - public void fireAction() throws XFormsException, IOException - { - final FacesContext context = FacesContext.getCurrentInstance(); - final Map requestParameters = context.getExternalContext().getRequestParameterMap(); - final String id = (String)requestParameters.get("id"); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".fireAction(" + id + ")"); - - writeLock.lock(); - try - { - final ChibaBean chibaBean = this.getXformsSession().getChibaBean(); - chibaBean.dispatch(id, DOMEventNames.ACTIVATE); - - final ResponseWriter out = context.getResponseWriter(); - XMLUtil.print(this.getEventLog(), out); - out.close(); - } - finally - { - writeLock.unlock(); - } - } - - /** - * handles submits and sets the instance data. - */ - public void handleAction() - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".handleAction"); - try - { - final FacesContext context = FacesContext.getCurrentInstance(); - final HttpServletRequest request = (HttpServletRequest) - context.getExternalContext().getRequest(); - final Document result = XMLUtil.parse(request.getInputStream()); - this.handleSubmit(result); - final Document instanceData = this.getXformsSession().getFormInstanceData(); - final ResponseWriter out = context.getResponseWriter(); - XMLUtil.print(instanceData, out, false); - out.close(); - } - catch (Throwable t) - { - LOGGER.error(t.getMessage(), t); - } - } - - public void handleSubmit(Node result) - { - final Document instanceData = this.getXformsSession().getFormInstanceData(); - Element documentElement = instanceData.getDocumentElement(); - if (documentElement != null) - { - instanceData.removeChild(documentElement); - } - if (result instanceof Document) - { - result = ((Document)result).getDocumentElement(); - } - documentElement = (Element)instanceData.importNode(result.cloneNode(true), true); - Schema2XForms.removePrototypeNodes(documentElement); - instanceData.appendChild(documentElement); - instanceData.normalizeDocument(); - } - - /** - * Swaps model nodes to implement reordering within repeats. - */ - public void swapRepeatItems() throws Exception - { - final FacesContext context = FacesContext.getCurrentInstance(); - final Map requestParameters = context.getExternalContext().getRequestParameterMap(); - - final String fromItemId = (String)requestParameters.get("fromItemId"); - final String toItemId = (String)requestParameters.get("toItemId"); - if (LOGGER.isDebugEnabled()) - LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")"); - - writeLock.lock(); - try - { - final ChibaBean chibaBean = this.getXformsSession().getChibaBean(); - final RepeatItem from = (RepeatItem)chibaBean.getContainer().lookup(fromItemId); - if (from == null) - { - throw new IllegalArgumentException("unable to find source repeat item " + fromItemId); - } - final RepeatItem to = (RepeatItem)chibaBean.getContainer().lookup(toItemId); - if (to == null) - { - throw new IllegalArgumentException("unable to find destination repeat item " + toItemId); - } - - this.swapRepeatItems(from, to); - - final ResponseWriter out = context.getResponseWriter(); - XMLUtil.print(this.getEventLog(), out); - out.close(); - } - finally - { - writeLock.unlock(); - } - } - - /** - * Introduced for ALF-10162 and ALF-10163 - * This method is used in JSF context to be able to validate last inserted values. - * Note! This method clears event log. Do not use it for form validation during AJAX actions, - * because this method doesn't return response. - * - * It is useful for Form validation, when Xform has been passed without AJAX "submit" action. - * @see CreateWebContentWizard - * @return - */ - public boolean isXformValid() - { - ChibaBean chibaBean = getXformsSession().getChibaBean(); - try - { - // throws XFormsException - chibaBean.dispatch("submit", DOMEventNames.ACTIVATE); - Node eventLogDoc = getEventLog(); - Node eventsNode = eventLogDoc.getFirstChild(); - if (eventsNode != null && "events".equals(eventsNode.getNodeName())) - { - NodeList childNodeList = eventsNode.getChildNodes(); - for(int i = 0; i < childNodeList.getLength(); i++) - { - Node childNode = childNodeList.item(i); - if ("xforms-submit-error".equals(childNode.getNodeName()) && - childNode.getAttributes().getNamedItem("targetId") != null && - "submission-validate".equals(childNode.getAttributes().getNamedItem("targetId").getNodeValue())) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Found xforms-submit-error, it means that form wasn't validated, throwing error"); - return false; - } - } - } - return true; - } - catch (XFormsException e) - { - return false; - } - } - - private void swapRepeatItems(final RepeatItem from, - final RepeatItem to) - throws XFormsException - { - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("swapping repeat item " + from + " with " + to); - LOGGER.debug("from instance id " + from.getInstanceId()); - } - final Model model = from.getModel(); - final Instance instance = model.getInstance(from.getInstanceId()); - assert instance == to.getModel().getInstance(to.getInstanceId()); - final String fromLocationPath = from.getLocationPath(); - final String toLocationPath = to.getLocationPath(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("from {id: " + from.getId() + ",position: " + from.getPosition() + - "} " + fromLocationPath + - "=" + instance.getModelItem(fromLocationPath).getValue()); - LOGGER.debug("to {id:" + to.getId() + ",position: " + to.getPosition() + - "} " + toLocationPath + - "=" + instance.getModelItem(toLocationPath).getValue()); - } - - String beforeLocation = toLocationPath; - final int toPosition = to.getPosition(); - if (from.getPosition() < toPosition) - { - final RepeatItem beforeItem = to.getRepeat().getRepeatItem(toPosition + 1); - beforeLocation = (beforeItem != null - ? beforeItem.getLocationPath() - : to.getRepeat().getLocationPath().replaceAll("\\[position\\(\\)[\\s]*!=[\\s]*last\\(\\)]$", - "[position()=last()]")); - } - if (LOGGER.isDebugEnabled()) - LOGGER.debug("inserting node before " + beforeLocation); - instance.insertNode(fromLocationPath, beforeLocation); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("deleting from " + from.getLocationPath()); - // need to reload from location path since it has moved - instance.deleteNode(from.getLocationPath()); - - to.getRepeat().setIndex(toPosition); - - model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REBUILD, null); - model.getContainer().dispatch(model.getTarget(), XFormsEventNames.RECALCULATE, null); - model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REVALIDATE, null); - model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REFRESH, null); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("swapped model data, instance data after manipulation:\n " + - XMLUtil.toString(instance.getInstanceDocument())); - } - } - - private static void rewriteInlineURIs(final Document schemaDocument, - final String cwdAvmPath) - { - final NodeList nl = - XMLUtil.combine(schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include"), - schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "import")); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("rewriting " + nl.getLength() + " includes"); - - for (int i = 0; i < nl.getLength(); i++) - { - final Element includeEl = (Element)nl.item(i); - if (includeEl.hasAttribute("schemaLocation")) - { - String uri = includeEl.getAttribute("schemaLocation"); - String finalURI = null; - - if (uri == null || uri.startsWith("http://") || uri.startsWith("https://")) - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("not rewriting " + uri); - - continue; - } - - if (uri.startsWith("webscript://")) - { - // It's a web script include / import - final FacesContext facesContext = FacesContext.getCurrentInstance(); - final ExternalContext externalContext = facesContext.getExternalContext(); - final HttpServletRequest request = (HttpServletRequest)externalContext.getRequest(); - - final String baseURI = (request.getScheme() + "://" + - request.getServerName() + ':' + - request.getServerPort() + - request.getContextPath() + "/wcservice"); - String rewrittenURI = uri; - -// // WCM -// if (uri.contains("${storeid}")) -// { -// final String storeId = AVMUtil.getStoreName(cwdAvmPath); -// rewrittenURI = uri.replace("${storeid}", storeId); -// } -// else if (uri.contains("{storeid}")) -// { -// final String storeId = AVMUtil.getStoreName(cwdAvmPath); -// rewrittenURI = uri.replace("{storeid}", storeId); -// } -// else -// { -// if (LOGGER.isDebugEnabled()) -// LOGGER.debug("no store id specified in webscript URI " + uri); -// } -// - if (uri.contains("${ticket}")) - { - AuthenticationService authenticationService = Repository.getServiceRegistry(facesContext).getAuthenticationService(); - final String ticket = authenticationService.getCurrentTicket(); - rewrittenURI = rewrittenURI.replace("${ticket}", ticket); - } - else if (uri.contains("{ticket}")) - { - AuthenticationService authenticationService = Repository.getServiceRegistry(facesContext).getAuthenticationService(); - final String ticket = authenticationService.getCurrentTicket(); - rewrittenURI = rewrittenURI.replace("{ticket}", ticket); - } - else - { - if (LOGGER.isDebugEnabled()) - LOGGER.debug("no ticket specified in webscript URI " + uri); - } - - rewrittenURI = rewrittenURI.replaceAll("%26","&"); - - finalURI = baseURI + rewrittenURI.replace("webscript://", "/"); - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("Final URI " + finalURI); - } - else - { -// // WCM -// // It's a web project asset include / import -// final String baseURI = (uri.charAt(0) == '/' -// ? AVMUtil.getPreviewURI(AVMUtil.getStoreName(cwdAvmPath)) -// : AVMUtil.getPreviewURI(cwdAvmPath)); -// -// finalURI = baseURI + uri; - } - - if (LOGGER.isDebugEnabled()) - LOGGER.debug("rewriting " + uri + " as " + finalURI); - - includeEl.setAttribute("schemaLocation", finalURI); - } - } - } - - private Node getEventLog() - { - final Document result = XMLUtil.newDocument(); - final Element eventsElement = result.createElement("events"); - result.appendChild(eventsElement); - - for (XMLEvent xfe : this.getXformsSession().getEventLog()) - { - final String type = xfe.getType(); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("adding event " + type + " to the event log"); - } - - final Element target = (Element)xfe.getTarget(); - - final Element eventElement = result.createElement(type); - eventsElement.appendChild(eventElement); - eventElement.setAttribute("targetId", target.getAttributeNS(null, "id")); - eventElement.setAttribute("targetName", target.getLocalName()); - - final Collection properties = xfe.getPropertyNames(); - if (properties != null) - { - for (Object name : properties) - { - final Object value = xfe.getContextInfo((String)name); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("adding property {" + name + - ":" + value + "} to event " + type); - } - - final Element propertyElement = result.createElement("property"); - eventElement.appendChild(propertyElement); - propertyElement.setAttribute("name", name.toString()); - propertyElement.setAttribute("value", - value != null ? value.toString() : null); - } - } - - if (LOGGER.isDebugEnabled() && XFormsEventNames.SUBMIT_ERROR.equals(type)) - { - // debug for figuring out which elements aren't valid for submit - LOGGER.debug("performing full revalidate"); - try - { - final Model model = this.getXformsSession().getChibaBean().getContainer().getDefaultModel(); - final Instance instance = model.getDefaultInstance(); - model.getValidator().validate(instance, "/", new DefaultValidatorMode()); - final Iterator it = instance.iterateModelItems("/"); - while (it.hasNext()) - { - final ModelItem modelItem = it.next(); - if (!modelItem.isValid()) - { - LOGGER.debug("model node " + modelItem.getNode() + " is invalid"); - } - if (modelItem.isRequired() && modelItem.getValue().length() == 0) - { - LOGGER.debug("model node " + modelItem.getNode() + " is empty and required"); - } - } - } - catch (final XFormsException xfe2) - { - LOGGER.debug("error performing revaliation", xfe2); - } - } - } - this.xformsSession.eventLog.clear(); - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("generated event log:\n" + XMLUtil.toString(result)); - } - return result; - } - - /** - * stores cookies that may exist in request and passes them on to processor for usage in - * HTTPConnectors. Instance loading and submission then uses these cookies. Important for - * applications using auth. - */ -// @SuppressWarnings("unchecked") -// private static void storeCookies(final javax.servlet.http.Cookie[] cookiesIn, -// final ChibaBean chibaBean){ -// if (cookiesIn != null) { -// org.apache.commons.httpclient.Cookie[] commonsCookies = -// new org.apache.commons.httpclient.Cookie[cookiesIn.length]; -// for (int i = 0; i < cookiesIn.length; i += 1) { -// commonsCookies[i] = -// new org.apache.commons.httpclient.Cookie(cookiesIn[i].getDomain(), -// cookiesIn[i].getName(), -// cookiesIn[i].getValue(), -// cookiesIn[i].getPath(), -// cookiesIn[i].getMaxAge(), -// cookiesIn[i].getSecure()); -// } -// chibaBean.getContext().put(AbstractHTTPConnector.REQUEST_COOKIE, -// commonsCookies); -// } -// } - - private Pair getXFormsDocument() - throws FormBuilderException - { - String path = null; -// // WCM -// if (this.getXformsSession().getForm().isWebForm()) -// { -// path = this.getCurrentAVMPath(); -// } -// else - { - path = this.getCurrentPath(); - } - - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("building xform for schema " + this.xformsSession.form.getName() + - " root element " + this.xformsSession.form.getSchemaRootElementName() + - " cwd " + path); - } - - final Locale locale = - Application.getLanguage(FacesContext.getCurrentInstance()); - final ResourceBundle resourceBundle = - getSchema2XFormsProperties().getResourceBundle(this.xformsSession.form, - locale); - try - { - final Document schemaDocument = this.xformsSession.form.getSchema(); - XFormsBean.rewriteInlineURIs(schemaDocument, path); - final String rootElementName = this.xformsSession.form.getSchemaRootElementName(); - final Pair result = - this.getXformsSession().getSchema2XForms().buildXForm(this.getXformsSession().getFormInstanceData(), - schemaDocument, - rootElementName, - resourceBundle); - if (LOGGER.isDebugEnabled()) - { - LOGGER.debug("generated xform: " + XMLUtil.toString(result.getFirst())); - } - return result; - } - catch (IOException ioe) - { - throw new FormBuilderException(ioe); - } - catch (SAXException saxe) - { - throw new FormBuilderException(saxe); - } - } - -// // WCM -// private String getCurrentAVMPath() -// { -// AVMNode node = this.avmBrowseBean.getAvmActionNode(); -// if (node == null) -// { -// return this.avmBrowseBean.getCurrentPath(); -// } -// -// final String result = node.getPath(); -// return node.isDirectory() ? result : AVMNodeConverter.SplitBase(result)[0]; -// } -// - private String getCurrentPath() - { - org.alfresco.web.bean.repository.Node node = this.navigator.getCurrentNode(); - if (node == null) - { - return null; - } - - final String result = node.getPath(); - return result; - } -} diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java deleted file mode 100644 index 64162572a0..0000000000 --- a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Copyright (C) 2005-2012 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.web.forms.xforms; - -import java.io.Writer; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.StringTokenizer; -import java.util.TreeSet; - -import javax.faces.context.FacesContext; - -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.util.XMLUtil; -import org.alfresco.web.app.Application; -import org.alfresco.web.app.servlet.FacesHelper; -import org.alfresco.web.forms.Form; -import org.alfresco.web.forms.FormProcessor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chiba.xml.ns.NamespaceConstants; -import org.chiba.xml.xforms.exception.XFormsException; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.extensions.config.ConfigElement; -import org.springframework.extensions.config.ConfigService; -import org.springframework.web.util.JavaScriptUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class XFormsProcessor implements FormProcessor -{ - - private static final Log LOGGER = LogFactory.getLog(XFormsProcessor.class); - - /** - * A triple of js variable name, namespace uri, and namespace prefix which - * will form javascript variables within alfresco.constants. - */ - private final static String[][] JS_NAMESPACES = - { - { "xforms", NamespaceConstants.XFORMS_NS, NamespaceConstants.XFORMS_PREFIX }, - { "xhtml", NamespaceConstants.XHTML_NS, NamespaceConstants.XHTML_PREFIX }, - { "chiba", NamespaceConstants.CHIBA_NS, NamespaceConstants.CHIBA_PREFIX }, - { "alfresco", NamespaceService.ALFRESCO_URI, NamespaceService.ALFRESCO_PREFIX } - }; - - /** Scripts needed to initialize the xforms client. */ - private final static String[] JS_SCRIPTS = - { - "/scripts/tiny_mce/" + (LOGGER.isDebugEnabled() - ? "tiny_mce_src.js" - : "tiny_mce.js"), - "/scripts/ajax/dojo/" + (LOGGER.isDebugEnabled() - ? "dojo.js.uncompressed.js" - : "dojo.js"), - "/scripts/ajax/mootools.v1.11.js", - "/scripts/ajax/common.js", - "/scripts/ajax/ajax_helper.js", - "/scripts/ajax/tiny_mce_wcm_extensions.js", - "/scripts/ajax/xforms.js", - "/scripts/ajax/file_picker_widget.js", - "/scripts/upload_helper.js", - "/scripts/ajax/dojo/src/date/serialize.js" - }; - - /** Localized strings needed by the xforms client. */ - private final static String[] BUNDLE_KEYS = - { - "add_content", - "cancel", - "change", - "click_to_edit", - "eg", - "go_up", - "idle", - "loading", - "path", - "select", - "upload", - "validation_provide_values_for_required_fields", - - "time_picker_title", - "time_picker_button_title", - "date_picker_title", - "date_picker_button_title", - "date_time_picker_title", - "date_time_picker_button_title", - "increase_week_label", - "decrease_week_label", - "increase_month_label", - "decrease_month_label", - "mandatory_parameter", - "state_expanded", - "state_not_expanded", - "select_path_menu", - "add_item_title", - "move_up_title", - "move_down_title", - "remove_item_title", - "item_title", - "accessibility_validation_message", - "accessibility_validation_message_with_error_count" - }; - - private static JSONObject widgetConfig = null; - - public XFormsProcessor() - { - if (XFormsProcessor.widgetConfig == null) - { - XFormsProcessor.widgetConfig = XFormsProcessor.loadConfig(); - } - } - - public Session process(final Document instanceDataDocument, - final String formInstanceDataName, - final Form form, - final Writer out) - throws FormProcessor.ProcessingException - { - final FacesContext fc = FacesContext.getCurrentInstance(); - //make the XFormsBean available for this session - final XFormsBean xforms = (XFormsBean) - FacesHelper.getManagedBean(fc, XFormsBean.BEAN_NAME); - final Session result = - xforms.createSession(instanceDataDocument, formInstanceDataName, form); - this.process(result, out); - return result; - } - - /** - * Generates html text which bootstraps the JavaScript code that will - * call back into the XFormsBean and get the xform and build the ui. - */ - public void process(final Session session, final Writer out) - throws FormProcessor.ProcessingException - { - final FacesContext fc = FacesContext.getCurrentInstance(); - //make the XFormsBean available for this session - final XFormsBean xforms = (XFormsBean) - FacesHelper.getManagedBean(fc, XFormsBean.BEAN_NAME); -// // WCM -// final AVMBrowseBean avmBrowseBean = (AVMBrowseBean) -// FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME); - try - { - xforms.setXFormsSession((XFormsBean.XFormsSession)session); - } - catch (FormBuilderException fbe) - { - LOGGER.error(fbe); - throw new ProcessingException(fbe); - } - catch (XFormsException xfe) - { - LOGGER.error(xfe); - throw new ProcessingException(xfe); - } - - final String contextPath = fc.getExternalContext().getRequestContextPath(); - final Document result = XMLUtil.newDocument(); - final String xformsUIDivId = "alfresco-xforms-ui"; - - // this div is where the ui will write to - final Element div = result.createElement("div"); - div.setAttribute("id", xformsUIDivId); - result.appendChild(div); - - Element e = result.createElement("link"); - e.setAttribute("rel", "stylesheet"); - e.setAttribute("type", "text/css"); - e.setAttribute("href", contextPath + "/css/xforms.css"); - div.appendChild(e); - - // a script with config information and globals. - e = result.createElement("script"); - e.setAttribute("type", "text/javascript"); - final StringBuilder js = new StringBuilder("\n"); - final String[] jsNamespacesObjects = - { - "alfresco", - "alfresco.constants", - "alfresco.xforms", - "alfresco.xforms.constants" - }; - for (final String jsNamespace : jsNamespacesObjects) - { - js.append(jsNamespace). - append(" = typeof "). - append(jsNamespace). - append(" == 'undefined' ? {} : "). - append(jsNamespace). - append(";\n"); - } - js.append("alfresco.constants.DEBUG = "). - append(LOGGER.isDebugEnabled()). - append(";\n"); - js.append("alfresco.constants.WEBAPP_CONTEXT = '"). - append(JavaScriptUtils.javaScriptEscape(contextPath)). - append("';\n"); - -// // WCM -// String avmWebApp = avmBrowseBean.getWebapp(); -// - // TODO - need better way to determine WCM vs ECM context - js.append("alfresco.constants.AVM_WEBAPP_CONTEXT = '"); -// // WCM -// if (avmWebApp != null) -// { -// js.append(JavaScriptUtils.javaScriptEscape(avmWebApp)); -// } - js.append("';\n"); - - // TODO - need better way to determine WCM vs ECM context - js.append("alfresco.constants.AVM_WEBAPP_URL = '"); -// // WCM -// if (avmWebApp != null) -// { -// //Use preview store because when user upload image it appears in preview, not in main store. -// String storeName = AVMUtil.getCorrespondingPreviewStoreName(avmBrowseBean.getSandbox()); -// if (storeName != null) -// { -// js.append(JavaScriptUtils.javaScriptEscape(fc.getExternalContext().getRequestContextPath() + "/wcs/api/path/content/avm/" + -// AVMUtil.buildStoreWebappPath(storeName, avmWebApp).replace(":",""))); -// } -// } -// - js.append("';\n"); - - js.append("alfresco.constants.AVM_WEBAPP_PREFIX = '"); -// // WCM -// if (avmWebApp != null) -// { -// String storeName = AVMUtil.getCorrespondingPreviewStoreName(avmBrowseBean.getSandbox()); -// if (storeName != null) -// { -// js.append(JavaScriptUtils.javaScriptEscape(fc.getExternalContext().getRequestContextPath() + "/wcs/api/path/content/avm/" + -// AVMUtil.buildSandboxRootPath(storeName).replace(":",""))); -// } -// } -// - js.append("';\n"); - js.append("alfresco.constants.LANGUAGE = '"); - String lang = Application.getLanguage(FacesContext.getCurrentInstance()).toString(); - // the language can be passed as "en_US" or just "en" - if (lang.length() > 4) - lang = lang.substring(0,lang.indexOf("_")); - js.append(lang); - js.append("';\n"); - js.append("alfresco.xforms.constants.XFORMS_UI_DIV_ID = '"). - append(xformsUIDivId). - append("';\n"); - js.append("alfresco.xforms.constants.FORM_INSTANCE_DATA_NAME = '"). - append(JavaScriptUtils.javaScriptEscape(session.getFormInstanceDataName())). - append("';\n"); - SimpleDateFormat sdf = (SimpleDateFormat) - SimpleDateFormat.getDateInstance(DateFormat.SHORT, - Application.getLanguage(fc)); - js.append("alfresco.xforms.constants.DATE_FORMAT = '"). - append(sdf.toPattern()). - append("';\n"); - sdf = (SimpleDateFormat) - SimpleDateFormat.getTimeInstance(DateFormat.SHORT, - Application.getLanguage(fc)); - js.append("alfresco.xforms.constants.TIME_FORMAT = '"). - append(sdf.toPattern()). - append("';\n"); - sdf = (SimpleDateFormat) - SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT, - Application.getLanguage(fc)); - js.append("alfresco.xforms.constants.DATE_TIME_FORMAT = '"). - append(sdf.toPattern()). - append("';\n"); - for (String[] ns : JS_NAMESPACES) - { - js.append("alfresco.xforms.constants."). - append(ns[0].toUpperCase()). - append("_NS = '").append(ns[1]).append("';\n"); - js.append("alfresco.xforms.constants."). - append(ns[0].toUpperCase()). - append("_PREFIX = '").append(ns[2]).append("';\n"); - } - - final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance()); - js.append("alfresco.resources = {\n"); - for (String k : BUNDLE_KEYS) - { - js.append(k). - append(": '"). - append(JavaScriptUtils.javaScriptEscape(bundle.getString(k))). - append("'"). - append(k.equals(BUNDLE_KEYS[BUNDLE_KEYS.length - 1]) ? "\n};" : ","). - append("\n"); - } - - try - { - js.append("alfresco.xforms.widgetConfig = \n"). - append(LOGGER.isDebugEnabled() - ? XFormsProcessor.widgetConfig.toString(0) - : XFormsProcessor.widgetConfig). - append("\n"); - } - catch (JSONException jsone) - { - LOGGER.error(jsone); - } - e.appendChild(result.createTextNode(js.toString())); - - div.appendChild(e); - - // include all our scripts, order is significant - for (final String script : JS_SCRIPTS) - { - if (script == null) - { - continue; - } - e = result.createElement("script"); - e.setAttribute("type", "text/javascript"); - e.setAttribute("src", contextPath + script); - e.appendChild(result.createTextNode("\n")); - div.appendChild(e); - } - - // output any custom scripts - ConfigElement config = Application.getConfigService(fc).getGlobalConfig().getConfigElement("wcm"); - if (config != null) - { - // get the custom scripts to include - ConfigElement xformsScriptsConfig = config.getChild("xforms-scripts"); - if (xformsScriptsConfig != null) - { - StringTokenizer t = new StringTokenizer(xformsScriptsConfig.getValue().trim(), ", "); - while (t.hasMoreTokens()) - { - e = result.createElement("script"); - e.setAttribute("type", "text/javascript"); - e.setAttribute("src", contextPath + t.nextToken()); - e.appendChild(result.createTextNode("\n")); - div.appendChild(e); - } - } - } - - XMLUtil.print(result, out); - } - - private static JSONObject loadConfig() - { - final ConfigService cfgService = Application.getConfigService(FacesContext.getCurrentInstance()); - final ConfigElement xformsConfig = cfgService.getGlobalConfig().getConfigElement("wcm").getChild("xforms"); - final List widgetConfig = xformsConfig.getChildren("widget"); - - class WidgetConfigElement - implements Comparable - { - public final String xformsType; - public final String xmlSchemaType; - public final String appearance; - public final String javascriptClassName; - private final Map params = new HashMap(); - - public WidgetConfigElement(final String xformsType, - final String xmlSchemaType, - final String appearance, - final String javascriptClassName) - { - if (xformsType == null) - { - throw new NullPointerException(); - } - this.xformsType = xformsType; - this.xmlSchemaType = xmlSchemaType; - this.appearance = appearance; - this.javascriptClassName = javascriptClassName; - } - - public void addParam(final String k, final String v) - { - this.params.put(k, v); - } - - public Map getParams() - { - return (this.params == null - ? (Map)Collections.EMPTY_MAP - : Collections.unmodifiableMap(this.params)); - } - - public int compareTo(final WidgetConfigElement other) - { - int result = this.xformsType.compareTo(other.xformsType); - if (result != 0) - { - return result; - } - - result = this.compareAttribute(this.xmlSchemaType, other.xmlSchemaType); - if (result != 0) - { - return result; - } - result = this.compareAttribute(this.appearance, other.appearance); - if (result != 0) - { - return result; - } - - if (LOGGER.isInfoEnabled()) - { - LOGGER.info("widget definitions " + this + " and " + other + " may collide"); - } - return 0; - } - - public String toString() - { - return (this.getClass().getName() + "{" + - "xformsType: "+ this.xformsType + - ", xmlSchemaType: " + this.xmlSchemaType + - ", appearance: " + this.appearance + - ", javascriptClassName: " + this.javascriptClassName + - ", numParams: " + this.getParams().size() + - "}"); - } - - private int compareAttribute(final String s1, final String s2) - { - return (s1 != null && s2 == null - ? 1 - : (s1 == null && s2 != null - ? -1 - : (s1 != null && s2 != null - ? s1.compareTo(s2) - : 0))); - } - } - - final TreeSet widgetConfigs = new TreeSet(); - for (final ConfigElement ce : widgetConfig) - { - final WidgetConfigElement wce = new WidgetConfigElement(ce.getAttribute("xforms-type"), - ce.getAttribute("xml-schema-type"), - ce.getAttribute("appearance"), - ce.getAttribute("javascript-class-name")); - - final List params = ce.getChildren("param"); - for (final ConfigElement p : params) - { - wce.addParam(p.getAttribute("name"), p.getValue()); - } - widgetConfigs.add(wce); - } - try - { - final JSONObject result = new JSONObject(); - for (final WidgetConfigElement wce : widgetConfigs) - { - if (!result.has(wce.xformsType)) - { - result.put(wce.xformsType, new JSONObject()); - } - final JSONObject xformsTypeObject = result.getJSONObject(wce.xformsType); - String s = wce.xmlSchemaType == null ? "*" : wce.xmlSchemaType; - if (!xformsTypeObject.has(s)) - { - xformsTypeObject.put(s, new JSONObject()); - } - final JSONObject schemaTypeObject = xformsTypeObject.getJSONObject(s); - s = wce.appearance == null ? "*" : wce.appearance; - final JSONObject o = new JSONObject(); - schemaTypeObject.put(s, o); - o.put("className", wce.javascriptClassName); - if (wce.getParams().size() != 0) - { - o.put("params", new JSONObject(wce.getParams())); - } - } - return result; - } - catch (JSONException jsone) - { - LOGGER.error(jsone, jsone); - return null; - } - } -} diff --git a/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java b/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java index ffe7bacc48..dcccdeb43c 100644 --- a/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java +++ b/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java @@ -222,11 +222,7 @@ public abstract class AbstractItemSelector extends UIInput NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), selection); if (!getNodeService(context).exists(nodeRef)) { -// // WCM -// nodeRef = new NodeRef(new StoreRef(StoreRef.PROTOCOL_AVM, avmStore), selection); -// Pair versionPathPair = AVMNodeConverter.ToAVMVersionPath(nodeRef); -// ((EditableValueHolder)this).setSubmittedValue(AVMNodeConverter.ToNodeRef(versionPathPair.getFirst(), versionPathPair.getSecond())); - throw new RuntimeException("WCM anticipation here."); + throw new RuntimeException("NodeRef not found."); } else { @@ -370,39 +366,7 @@ public abstract class AbstractItemSelector extends UIInput } else { - // WCM -// if (value.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) -// { -// Pair avmNode = AVMNodeConverter.ToAVMVersionPath(value); -// String avmPath = avmNode.getSecond(); -// -// int rootPosition = avmPath.indexOf(AVMUtil.DIR_ROOT); -// if(rootPosition > 0) -// { -// label = avmPath.substring(rootPosition + AVMUtil.DIR_ROOT.length()); -// if(label.length() == 0) -// { -// int storeEnd = avmPath.indexOf(":"); -// if(storeEnd > 0) -// { -// label = avmPath.substring(0, storeEnd); -// } -// else -// { -// label = "ROOT"; -// } -// } -// } -// else -// { -// // AVM path does not have ROOT -// label = avmPath; -// } -// } -// else -// { - label = Repository.getNameForNode(service, value); -// } + label = Repository.getNameForNode(service, value); showValueInHiddenField = true; } @@ -436,13 +400,6 @@ public abstract class AbstractItemSelector extends UIInput if (value != null) { fieldValue = encodeFieldValues(theMode, value.getId()); -// -// // WCM -// // setup the avmStore if the value represents an avm path -// if (value.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM)) -// { -// this.avmStore = value.getStoreRef().getIdentifier(); -// } } else { diff --git a/source/test-java/org/alfresco/web/config/WebClientConfigTest.java b/source/test-java/org/alfresco/web/config/WebClientConfigTest.java index 98dfff2d58..561828049b 100644 --- a/source/test-java/org/alfresco/web/config/WebClientConfigTest.java +++ b/source/test-java/org/alfresco/web/config/WebClientConfigTest.java @@ -925,143 +925,5 @@ public void testPropertyViewing() List attrs = clientConfig.getSimpleSearchAdditionalAttributes(); assertNotNull("Expecting a list of search attributes", attrs); assertEquals("Expecting 2 search attributes", 2, attrs.size()); - } - - public void testWCM() - { - // setup the config service - XMLConfigService svc = initXMLConfigService(TEST_CONFIG); - - // get the global config object - Config global = svc.getGlobalConfig(); - assertNotNull(global); - - // get the wcm config - ConfigElement wcmConfig = global.getConfigElement("wcm"); - assertNotNull(wcmConfig); - - // get the workflows config - ConfigElement workflows = wcmConfig.getChild("workflows"); - assertNotNull(workflows); - assertEquals("wcmwf:submit", workflows.getValue()); - - // get the admin workflows config - ConfigElement adminWorkflows = wcmConfig.getChild("admin-workflows"); - assertNotNull(adminWorkflows); - assertEquals("wcmwf:changerequest", adminWorkflows.getValue()); - - // get the browse page size config - ConfigElement viewsConfig = wcmConfig.getChild("views"); - assertNotNull(viewsConfig); - ConfigElement browsePageSizeConfig = viewsConfig.getChild("browse-page-size"); - assertNotNull(browsePageSizeConfig); - assertEquals("25", browsePageSizeConfig.getValue()); - - // get the deployment polling frequency - ConfigElement deploymentConfig = wcmConfig.getChild("deployment"); - assertNotNull(deploymentConfig); - ConfigElement pollingConfig = deploymentConfig.getChild("progress-polling-frequency"); - assertNotNull(pollingConfig); - assertEquals("2", pollingConfig.getValue()); - - // get the link validation polling frequency - ConfigElement linksConfig = wcmConfig.getChild("links-management"); - assertNotNull(linksConfig); - pollingConfig = linksConfig.getChild("progress-polling-frequency"); - assertNotNull(pollingConfig); - assertEquals("2", pollingConfig.getValue()); - - // get the widget config - ConfigElement xformsConfig = wcmConfig.getChild("xforms"); - assertNotNull(xformsConfig); - List widgetConfig = xformsConfig.getChildren("widget"); - assertEquals(2, widgetConfig.size()); - - // make sure the xforms-scripts config is NOT present - ConfigElement scriptsConfig = wcmConfig.getChild("xforms-scripts"); - assertNull(scriptsConfig); - - // make sure the custom config element is NOT present - ConfigElement customConfig = wcmConfig.getChild("custom-config"); - assertNull(customConfig); - } - - public void testWCMOverride() - { - // setup the config service - XMLConfigService svc = initXMLConfigService(TEST_CONFIG, TEST_CONFIG_OVERRIDE); - - // get the global config object - Config global = svc.getGlobalConfig(); - assertNotNull(global); - - // get the wcm config - ConfigElement wcmConfig = global.getConfigElement("wcm"); - assertNotNull(wcmConfig); - - // get the workflows config - ConfigElement workflows = wcmConfig.getChild("workflows"); - assertNotNull(workflows); - assertEquals("custom:submit", workflows.getValue().trim()); - - StringTokenizer t = new StringTokenizer(workflows.getValue().trim(), ", "); - while (t.hasMoreTokens()) - { - System.out.println("workflow = '" + t.nextToken() + "'"); - } - - // get the admin workflows config - ConfigElement adminWorkflows = wcmConfig.getChild("admin-workflows"); - assertNotNull(adminWorkflows); - assertEquals("custom:changerequest, custom:somejob", adminWorkflows.getValue()); - - t = new StringTokenizer(adminWorkflows.getValue().trim(), ", "); - while (t.hasMoreTokens()) - { - System.out.println("admin workflow = '" + t.nextToken() + "'"); - } - - // get the browse page size config - ConfigElement viewsConfig = wcmConfig.getChild("views"); - assertNotNull(viewsConfig); - ConfigElement browsePageSizeConfig = viewsConfig.getChild("browse-page-size"); - assertNotNull(browsePageSizeConfig); - assertEquals("50", browsePageSizeConfig.getValue()); - - // get the deployment polling frequency - ConfigElement deploymentConfig = wcmConfig.getChild("deployment"); - assertNotNull(deploymentConfig); - ConfigElement pollingConfig = deploymentConfig.getChild("progress-polling-frequency"); - assertNotNull(pollingConfig); - assertEquals("10", pollingConfig.getValue()); - - // get the link validation polling frequency - ConfigElement linksConfig = wcmConfig.getChild("links-management"); - assertNotNull(linksConfig); - pollingConfig = linksConfig.getChild("progress-polling-frequency"); - assertNotNull(pollingConfig); - assertEquals("15", pollingConfig.getValue()); - - // get the widget config - ConfigElement xformsConfig = wcmConfig.getChild("xforms"); - assertNotNull(xformsConfig); - List widgetConfig = xformsConfig.getChildren("widget"); - assertEquals(3, widgetConfig.size()); - - // make sure the xforms-scripts config is present - ConfigElement scriptsConfig = wcmConfig.getChild("xforms-scripts"); - assertNotNull(scriptsConfig); - assertEquals("/custom/custom-xforms.js, /custom/another-custom-xforms.js", scriptsConfig.getValue()); - - t = new StringTokenizer(scriptsConfig.getValue().trim(), ", "); - while (t.hasMoreTokens()) - { - System.out.println("custom script = '" + t.nextToken() + "'"); - } - - // make sure the custom config element is present - ConfigElement customConfig = wcmConfig.getChild("custom-config"); - assertNotNull(customConfig); - assertEquals("50", customConfig.getValue()); } } diff --git a/source/test-resources/test-config-override.xml b/source/test-resources/test-config-override.xml index 14e676cab8..0a3d184648 100644 --- a/source/test-resources/test-config-override.xml +++ b/source/test-resources/test-config-override.xml @@ -36,38 +36,6 @@ attr4 - - - - custom:submit - - - - custom:changerequest, custom:somejob - - - - 50 - - - - 10 - - - - 15 - - - - - - - - /custom/custom-xforms.js, /custom/another-custom-xforms.js - - - 50 - diff --git a/source/test-resources/test-config.xml b/source/test-resources/test-config.xml index 646e998a49..180dadc940 100644 --- a/source/test-resources/test-config.xml +++ b/source/test-resources/test-config.xml @@ -9,7 +9,6 @@ - @@ -81,33 +80,6 @@ - - - - wcmwf:submit - - - - wcmwf:changerequest - - - - 25 - - - - 2 - - - - 2 - - - - - - - diff --git a/source/test-resources/xforms/examples/article/article-details.ftl b/source/test-resources/xforms/examples/article/article-details.ftl deleted file mode 100644 index c634959bde..0000000000 --- a/source/test-resources/xforms/examples/article/article-details.ftl +++ /dev/null @@ -1,151 +0,0 @@ -<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/article","xsi":"http://www.w3.org/2001/XMLSchema-instance"}> - -

- -
- ${article.title} -
- - - - - -
- <#list article.page as page> - <#if page.page_title[0]??> -
${page.page_title}
- - <#if page.page_picture[0]??> - <#if page.page_picture.image["@xsi:nil"] == "false"> - <#if page_index % 2 == 1> -
- - <#if page.page_picture.caption["@xsi:nil"] == "false"> -
${page.page_picture.caption}
- -
- <#else> -
- - <#if page.page_picture.caption["@xsi:nil"] == "false"> -
${page.page_picture.caption}
- -
- - - - ${page.page_body} - -
-
-
Related
- <#if article.related[0]??> -
- -
- -
- - - diff --git a/source/test-resources/xforms/examples/article/article-feature.ftl b/source/test-resources/xforms/examples/article/article-feature.ftl deleted file mode 100644 index 322da242e9..0000000000 --- a/source/test-resources/xforms/examples/article/article-feature.ftl +++ /dev/null @@ -1,89 +0,0 @@ -<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/article","xsi":"http://www.w3.org/2001/XMLSchema-instance"}> - -
- -
- ${article.title} -
- - - - - diff --git a/source/test-resources/xforms/examples/article/article-list.xsl b/source/test-resources/xforms/examples/article/article-list.xsl deleted file mode 100644 index 065f391b7d..0000000000 --- a/source/test-resources/xforms/examples/article/article-list.xsl +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - -
- - - - /content/article/ - - -
-
-
diff --git a/source/test-resources/xforms/examples/article/article-pdf.xsl b/source/test-resources/xforms/examples/article/article-pdf.xsl deleted file mode 100644 index 6ed5c8acb4..0000000000 --- a/source/test-resources/xforms/examples/article/article-pdf.xsl +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - — - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/article/article.xsd b/source/test-resources/xforms/examples/article/article.xsd deleted file mode 100644 index 6acc73c019..0000000000 --- a/source/test-resources/xforms/examples/article/article.xsd +++ /dev/null @@ -1,461 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - Alabama - - - - - Alaska - - - - - Arizona - - - - - Arkansas - - - - - California - - - - - Colorado - - - - - Connecticut - - - - - District of Columbia - - - - - Delaware - - - - - Florida - - - - - Georgia - - - - - Hawaii - - - - - Idaho - - - - - Illinois - - - - - Indiana - - - - - Iowa - - - - - Kansas - - - - - Kentucky - - - - - Louisiana - - - - - Maine - - - - - Maryland - - - - - Massachusetts - - - - - Michigan - - - - - Minnesota - - - - - Mississippi - - - - - Missouri - - - - - Montana - - - - - Nebraska - - - - - Nevada - - - - - New Hampshire - - - - - New Jersey - - - - - New Mexico - - - - - New York - - - - - North Carolina - - - - - North Dakota - - - - - Ohio - - - - - Oklahoma - - - - - Oregon - - - - - Pennsylvania - - - - - Rhode Island - - - - - South Carolina - - - - - South Dakota - - - - - Tennessee - - - - - Texas - - - - - Utah - - - - - Vermont - - - - - Virginia - - - - - Washington - - - - - West Virginia - - - - - Wisconsin - - - - - Wyoming - - - - - - - - - - - - default - - - - - - - - - - - - - - - - - - - - The value entered is not a valid zip code. - - - - - - - - - - - - - - - - - - The value entered is not a valid email address. - - - - - - - - - - - - - - - - - - - - - - - - - - - - image_file_picker - - - - - - - - - - - - - - full - - - - - - - - - - - - - - search_restricted_file_picker - - - - - - - - - - - - - - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/article/article.xsl b/source/test-resources/xforms/examples/article/article.xsl deleted file mode 100644 index 7ebbf19c85..0000000000 --- a/source/test-resources/xforms/examples/article/article.xsl +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - <xsl:value-of select="/article:article/article:title" disable-output-escaping="yes"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - — - - -

- - - -
-

- -

-
- - /content/article/ - - -
- - , - -
-

- - - - - - - left - - - - -

-
- - -

- - - - - left - - - right - - -

- - - - - -
-
-
- - -
-
diff --git a/source/test-resources/xforms/examples/article/news-flash-details.ftl b/source/test-resources/xforms/examples/article/news-flash-details.ftl deleted file mode 100644 index 201e4785b4..0000000000 --- a/source/test-resources/xforms/examples/article/news-flash-details.ftl +++ /dev/null @@ -1,44 +0,0 @@ -<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/article","xsi":"http://www.w3.org/2001/XMLSchema-instance"}> - -
- -
- ${news_flash.title} -
- - - - -
- - diff --git a/source/test-resources/xforms/examples/article/user-profile-details-pdf.ftl b/source/test-resources/xforms/examples/article/user-profile-details-pdf.ftl deleted file mode 100644 index 0dc121157c..0000000000 --- a/source/test-resources/xforms/examples/article/user-profile-details-pdf.ftl +++ /dev/null @@ -1,36 +0,0 @@ -<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/article","xsi":"http://www.w3.org/2001/XMLSchema-instance","alf":"http://www.alfresco.org"}> - - - - <#if user_profile[0]??> - <#if user_profile.picture[0]??> - - - - - -
- - -
- ${user_profile.name.prefix}. ${user_profile.name.first} ${user_profile.name.last} -
-
- ${user_profile.bio} -
-
- <#if user_profile.address[0]??> - Address: - <#list user_profile.address.street as street> - ${street}  - -  ${user_profile.address.city}, ${user_profile.address.state} ${user_profile.address.zip} - -
-
- <#if user_profile.email[0]??> - Email: ${user_profile.email} - -
-
- diff --git a/source/test-resources/xforms/examples/article/user-profile-details.ftl b/source/test-resources/xforms/examples/article/user-profile-details.ftl deleted file mode 100644 index 9862290087..0000000000 --- a/source/test-resources/xforms/examples/article/user-profile-details.ftl +++ /dev/null @@ -1,50 +0,0 @@ -<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/article","xsi":"http://www.w3.org/2001/XMLSchema-instance"}> - - - - diff --git a/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.desc.xml b/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.desc.xml deleted file mode 100644 index 8781e2ddb9..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - WCM Schema for Category Selection - Generate part of schema for category selection - - extension - user - required - \ No newline at end of file diff --git a/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.html.ftl b/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.html.ftl deleted file mode 100644 index f24daa986b..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.html.ftl +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - Press Release - - - - - - - Whitepaper - - - - - - - diff --git a/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.js b/source/test-resources/xforms/examples/article/webscripts/CategorySelection.get.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.desc.xml b/source/test-resources/xforms/examples/article/webscripts/ContentList.get.desc.xml deleted file mode 100644 index f5c18cf607..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.desc.xml +++ /dev/null @@ -1,8 +0,0 @@ - - WCM Schema for Content Selection - Generate part of schema for content selection - - extension - user - required - \ No newline at end of file diff --git a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.html.ftl b/source/test-resources/xforms/examples/article/webscripts/ContentList.get.html.ftl deleted file mode 100644 index e998f6d0ea..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.html.ftl +++ /dev/null @@ -1,25 +0,0 @@ - -<#if results??> - - - - <#list results as result> - <#if ! result.hasAspect("{http://www.alfresco.org/model/wcmappmodel/1.0}rendition")> - - - - ${result.name?substring(0,result.name?index_of(".xml"))} - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.js b/source/test-resources/xforms/examples/article/webscripts/ContentList.get.js deleted file mode 100644 index 743e886dff..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.js +++ /dev/null @@ -1,70 +0,0 @@ -var contentList = null; - -if (args["storeid"] == null) { - - logger.log("ERROR: 'store' argument not specified."); - -} else { - - // Get the store id - var storeId = args["storeid"]; - - var store = avm.lookupStore(storeId); - - if ( store != null ) { - - // Get the form name - var formName = args["form"]; - - if ( formName != null ) { - - - var method = (args.method == null) ? "lucene" : args.method; - - if ( method == "lucene" ) { - - // Run the lucene query - var results = store.luceneSearch('@\\{http\\://www.alfresco.org/model/wcmappmodel/1.0\\}parentformname:"'+formName+'"'); - - contentList = results; - - } else { - - var path = (args.path == null) ? "/ROOT" : args.path; - - var storeRootNode = avm.lookupStoreRoot(storeId); - - // try xpath??? - - var results = avm.lookupNode(storeRootNode.path + path); - - var contentList = new Array(); - - if ( results.children != null ) { - - for ( var i = 0 ; i < results.children.length ; i ++ ) { - - var item = results.children[i]; - - if ( item.properties["{http://www.alfresco.org/model/wcmappmodel/1.0}parentformname"] == formName ) { - - contentList.push(item); - - } - - } - - } - - } - - } - - } else { - - - } - -} - -model.results= contentList; \ No newline at end of file diff --git a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.xml.ftl b/source/test-resources/xforms/examples/article/webscripts/ContentList.get.xml.ftl deleted file mode 100644 index e998f6d0ea..0000000000 --- a/source/test-resources/xforms/examples/article/webscripts/ContentList.get.xml.ftl +++ /dev/null @@ -1,25 +0,0 @@ - -<#if results??> - - - - <#list results as result> - <#if ! result.hasAspect("{http://www.alfresco.org/model/wcmappmodel/1.0}rendition")> - - - - ${result.name?substring(0,result.name?index_of(".xml"))} - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/getting-started-sample/alfresco-sample-website.war b/source/test-resources/xforms/examples/getting-started-sample/alfresco-sample-website.war deleted file mode 100644 index 4d104b95f1..0000000000 Binary files a/source/test-resources/xforms/examples/getting-started-sample/alfresco-sample-website.war and /dev/null differ diff --git a/source/test-resources/xforms/examples/getting-started-sample/company-footer.xsd b/source/test-resources/xforms/examples/getting-started-sample/company-footer.xsd deleted file mode 100644 index fa50b69da2..0000000000 --- a/source/test-resources/xforms/examples/getting-started-sample/company-footer.xsd +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/getting-started-sample/press-release-plain-text.ftl b/source/test-resources/xforms/examples/getting-started-sample/press-release-plain-text.ftl deleted file mode 100644 index 776362fa73..0000000000 --- a/source/test-resources/xforms/examples/getting-started-sample/press-release-plain-text.ftl +++ /dev/null @@ -1,38 +0,0 @@ -<#ftl ns_prefixes={"D", "http://www.alfresco.org/alfresco/pr"}> - -<#macro show_heading heading> -${heading} -<#list 1..heading?length as index>- - - -<@show_heading heading="Title: ${press_release.title}"/> - -<@show_heading heading="Abstract: ${press_release.abstract}"/> - -<#list press_release.body as body> - <#if body_index = 0> -${press_release.location}--${press_release.launch_date}-- - -${body?trim} - -<#list press_release.include_company_footer as cf> -<#assign cf_document=alf.parseXMLDocument(cf)> - -<@show_heading heading="About ${cf_document.name}"/> - <#list cf_document.body as body> -${body?trim} - - -<#if press_release.include_media_contacts = "true"> - -<@show_heading heading="Media Contacts"/> -John Newton -Alfresco Software Inc. -+44 1628 860639 -press@alfresco.com - -Chuck Tanowitz -Schwartz Communications -+1 781 684-0770 -alfresco@schwartz-pr.com - diff --git a/source/test-resources/xforms/examples/getting-started-sample/press-release.xml b/source/test-resources/xforms/examples/getting-started-sample/press-release.xml deleted file mode 100644 index febe60588f..0000000000 --- a/source/test-resources/xforms/examples/getting-started-sample/press-release.xml +++ /dev/null @@ -1,18 +0,0 @@ - - t - a - l - b1 - b2 - b2 - b2 - b2 - b2 - b55 - Alfresco - true - k - Event - 1978-08-08 - 1978-08-08 - diff --git a/source/test-resources/xforms/examples/getting-started-sample/press-release.xsd b/source/test-resources/xforms/examples/getting-started-sample/press-release.xsd deleted file mode 100644 index 636fc3443b..0000000000 --- a/source/test-resources/xforms/examples/getting-started-sample/press-release.xsd +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/getting-started-sample/press-release.xsl b/source/test-resources/xforms/examples/getting-started-sample/press-release.xsl deleted file mode 100644 index 01a856d692..0000000000 --- a/source/test-resources/xforms/examples/getting-started-sample/press-release.xsl +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - #include virtual="/assets/include_in_head.html" - <xsl:value-of select="/pr:press_release/pr:title"/> - - - - - - -
- #include virtual="/assets/include_main_navigation.html" - #include virtual="/about/navigation.html" -
 
- -
- - -

-

-

- -

- - -

-
- - - - -

About

- - -

-
-
- -

Media Contacts

-

John Newton
Alfresco Software Inc.
+44 1628 860639
press@alfresco.com

-

Chuck Tanowitz
Schwartz Communications
+1 781 684-0770
alfresco@schwartz-pr.com

-
- - - - - - view plain text version - -
- -
-
-

Press Releases By Category

- - - - - - - -
    - - - -
  • - - - - -
      - - - -
    • - - - font-weight:bold; - - - - - - -
    • -
      -
    -
    - - - - - - - - - -
    -
  • -
    -
-

Press Release Archive

- -
-
-
 
-
- - #include virtual="/assets/footer.html" - - -
-
diff --git a/source/test-resources/xforms/examples/note/note.xsd b/source/test-resources/xforms/examples/note/note.xsd deleted file mode 100644 index f665da9d29..0000000000 --- a/source/test-resources/xforms/examples/note/note.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/note/note.xsl b/source/test-resources/xforms/examples/note/note.xsl deleted file mode 100644 index 83967c0038..0000000000 --- a/source/test-resources/xforms/examples/note/note.xsl +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - <xsl:value-of select="/note/title"/> - - - - - - - -
To:
-
- -
From:
-
- -
- Subject: - - - - !!!!! - - -
-
- -
- -
-
- - -
diff --git a/source/test-resources/xforms/examples/person/person.xsd b/source/test-resources/xforms/examples/person/person.xsd deleted file mode 100644 index 884897a3f0..0000000000 --- a/source/test-resources/xforms/examples/person/person.xsd +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/press-release/press-release-full.ftl b/source/test-resources/xforms/examples/press-release/press-release-full.ftl deleted file mode 100644 index 4941edd031..0000000000 --- a/source/test-resources/xforms/examples/press-release/press-release-full.ftl +++ /dev/null @@ -1,36 +0,0 @@ -[#ftl ns_prefixes={"D", "http://www.alfresco.org/alfresco/press-release"}] - - - - ${PressRelease.Title} - -[#if PressRelease.Summary?exists] - -[/#if] -[#if PressRelease.Keyword?exists] - [#if PressRelease.Keyword?size > 0] - [#assign keywordString = ""] - [#list PressRelease.Keyword as Keyword] - [#assign keywordString = keywordString + "," + Keyword] - [/#list] - - [/#if] -[/#if] - - -

${PressRelease.Title}

-

${PressRelease.Body}

-[#if PressRelease.Image?exists] - -[/#if] - - -
-[#list avm.stores as store] - ${store.name}
-[/#list] -
- - - - diff --git a/source/test-resources/xforms/examples/press-release/press-release-full.xslt b/source/test-resources/xforms/examples/press-release/press-release-full.xslt deleted file mode 100644 index aca4141479..0000000000 --- a/source/test-resources/xforms/examples/press-release/press-release-full.xslt +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - <xsl:value-of select="/pr:PressRelease/pr:Title" disable-output-escaping="yes" /> - - - - - - - - - - - - - - - , - - - - - - - -

-

- - - - - - - - - -
- -
diff --git a/source/test-resources/xforms/examples/press-release/press-release-summary.xslt b/source/test-resources/xforms/examples/press-release/press-release-summary.xslt deleted file mode 100644 index 4085597579..0000000000 --- a/source/test-resources/xforms/examples/press-release/press-release-summary.xslt +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - .html - - - - -

-
- - -
- -
diff --git a/source/test-resources/xforms/examples/press-release/press-release.xsd b/source/test-resources/xforms/examples/press-release/press-release.xsd deleted file mode 100644 index 98945c7bb2..0000000000 --- a/source/test-resources/xforms/examples/press-release/press-release.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/product/product.xsd b/source/test-resources/xforms/examples/product/product.xsd deleted file mode 100644 index 4162b3188e..0000000000 --- a/source/test-resources/xforms/examples/product/product.xsd +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/product/product.xslt b/source/test-resources/xforms/examples/product/product.xslt deleted file mode 100644 index 4d72d57df5..0000000000 --- a/source/test-resources/xforms/examples/product/product.xslt +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - <xsl:value-of select="/pr:Product/pr:Title" disable-output-escaping="yes" /> - (<xsl:value-of select="/pr:Product/pr:SKU" disable-output-escaping="yes" />) - - - - - - - - - - - - - - - , - - - - - - - -

- - () -

- - - - - - - - - - - - - - - - - - -

- - -

Other product images:

- - - - - - -
-
-
- - -
- -
diff --git a/source/test-resources/xforms/examples/record/record.xsd b/source/test-resources/xforms/examples/record/record.xsd deleted file mode 100644 index 355a9f985e..0000000000 --- a/source/test-resources/xforms/examples/record/record.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/record/record.xsl b/source/test-resources/xforms/examples/record/record.xsl deleted file mode 100644 index e27545cc08..0000000000 --- a/source/test-resources/xforms/examples/record/record.xsl +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - <xsl:value-of select="/record/@title"/> - - -
Name:
-
Artist:
-
Genre:
-
Year:
- - -
-
diff --git a/source/test-resources/xforms/examples/user-registration/user-registration.xsd b/source/test-resources/xforms/examples/user-registration/user-registration.xsd deleted file mode 100644 index 639ca480c0..0000000000 --- a/source/test-resources/xforms/examples/user-registration/user-registration.xsd +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Britsh Columbia - - - - - New Brunswick - - - - - New Foundland - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wcm-form-samples-forms.acp b/source/test-resources/xforms/examples/wcm-form-samples-forms.acp deleted file mode 100644 index 75234ea288..0000000000 Binary files a/source/test-resources/xforms/examples/wcm-form-samples-forms.acp and /dev/null differ diff --git a/source/test-resources/xforms/examples/wcm-form-samples.amp b/source/test-resources/xforms/examples/wcm-form-samples.amp deleted file mode 100644 index 8babd601f6..0000000000 Binary files a/source/test-resources/xforms/examples/wcm-form-samples.amp and /dev/null differ diff --git a/source/test-resources/xforms/examples/webscript-import/pmonks-webscript-format-map-context.xml b/source/test-resources/xforms/examples/webscript-import/pmonks-webscript-format-map-context.xml deleted file mode 100644 index 4e2db26b61..0000000000 --- a/source/test-resources/xforms/examples/webscript-import/pmonks-webscript-format-map-context.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - text/xml - - - - - diff --git a/source/test-resources/xforms/examples/webscript-import/webscript-import-example.xsd b/source/test-resources/xforms/examples/webscript-import/webscript-import-example.xsd deleted file mode 100644 index abce914316..0000000000 --- a/source/test-resources/xforms/examples/webscript-import/webscript-import-example.xsd +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.desc.xml b/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.desc.xml deleted file mode 100644 index 9bd9e85368..0000000000 --- a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.desc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - Web Form Import Example - Example for testing import of a Web Script from a Web Form - /pmonks/webformimport?storeid={storeid} - any - user - diff --git a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.js b/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.js deleted file mode 100644 index 49f4d75e9c..0000000000 --- a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.js +++ /dev/null @@ -1,14 +0,0 @@ -// Parse arguments -var storeid = args.storeid; - -// Validate arguments -if (storeid == undefined || storeid == "") -{ - status.code = 400; - status.message = "Mandatory query string parameter 'storeid' was not provided."; - status.redirect = true; -} - -// Generate an id (in a truly terrible way, but it's just an example!) -model.storeid = storeid; -model.idValue = Math.floor(Math.random() * 1000); diff --git a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.xsd.ftl b/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.xsd.ftl deleted file mode 100644 index b42720211d..0000000000 --- a/source/test-resources/xforms/examples/webscript-import/webscripts/webscriptxformimport.get.xsd.ftl +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/alfresco-wsf-website.war b/source/test-resources/xforms/examples/wsf-website/alfresco-wsf-website.war deleted file mode 100644 index a2358e201f..0000000000 Binary files a/source/test-resources/xforms/examples/wsf-website/alfresco-wsf-website.war and /dev/null differ diff --git a/source/test-resources/xforms/examples/wsf-website/article/article-feature.xsl b/source/test-resources/xforms/examples/wsf-website/article/article-feature.xsl deleted file mode 100644 index c8e20d2ec1..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/article/article-feature.xsl +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - <%String channel = (String) request.getParameter("channel");%> - - - - <xsl:value-of select="/article:article/article:title" disable-output-escaping="yes"/> - - - - - - - - - - - - - - - - - -
- - - /views/pages/details.jsp?channel=<%=channel%>&content=/content/article/&title= - - - -
- - , - -
-

- - - - - - - left - - - - -

-
- - -
-
diff --git a/source/test-resources/xforms/examples/wsf-website/article/article-list.xsl b/source/test-resources/xforms/examples/wsf-website/article/article-list.xsl deleted file mode 100644 index e5efbbb5b5..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/article/article-list.xsl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - <%String channel = (String) request.getParameter("channel");%> - - - - -
- - /views/pages/details.jsp?channel=<%=channel%>&content=/content/article/&title= - - -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/article/article-rss.xsl b/source/test-resources/xforms/examples/wsf-website/article/article-rss.xsl deleted file mode 100644 index 24517e5644..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/article/article-rss.xsl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - <xsl:value-of select="/article:article/article:title" disable-output-escaping="yes"/> - /views/pages/details.jsp?content=/content/article/&title= - - 2000-01-01T12:00:00.000-00:00 - - - diff --git a/source/test-resources/xforms/examples/wsf-website/article/article.xsd b/source/test-resources/xforms/examples/wsf-website/article/article.xsd deleted file mode 100644 index e5d9fb87cc..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/article/article.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/article/article.xsl b/source/test-resources/xforms/examples/wsf-website/article/article.xsl deleted file mode 100644 index b3872c87c7..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/article/article.xsl +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - <xsl:value-of select="/article:article/article:title" disable-output-escaping="yes"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - — - - -

- - - -
-

- -

-
- - , - -
-

- - - - - - - left - - - - -

-
- - -

- - - - - left - - - right - - -

- - - - - -
-
-
- - -
-
diff --git a/source/test-resources/xforms/examples/wsf-website/motd/motd.xsd b/source/test-resources/xforms/examples/wsf-website/motd/motd.xsd deleted file mode 100644 index dce36ae970..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/motd/motd.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/motd/motd.xsl b/source/test-resources/xforms/examples/wsf-website/motd/motd.xsl deleted file mode 100644 index f07157e52d..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/motd/motd.xsl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - -
- -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media-list.xsl b/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media-list.xsl deleted file mode 100644 index 12356e69ee..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media-list.xsl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - <xsl:value-of select="/mm:multi-media/mm:title"/> - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media.xsd b/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media.xsd deleted file mode 100644 index 08f5ea7aa8..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/multi-media/multi-media.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/navigation/navigation-menu.xsl b/source/test-resources/xforms/examples/wsf-website/navigation/navigation-menu.xsl deleted file mode 100644 index 402a959e6b..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/navigation/navigation-menu.xsl +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/examples/wsf-website/navigation/navigation-sitemap.xsl b/source/test-resources/xforms/examples/wsf-website/navigation/navigation-sitemap.xsl deleted file mode 100644 index d924f7eab2..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/navigation/navigation-sitemap.xsl +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - /views/pages/index.jsp - - - - - - - /views/pages/main-channel.jsp?channel=/ - - - - - - - /views/pages/details.jsp?channel=/&content= - - - - - - - - - /views/pages/sub-channel.jsp?channel= - - - - - - - /views/pages/details.jsp?channel=&content= - - - - - - - - - /views/pages/sub-sub-channel.jsp?channel= - - - - - - - /views/pages/details.jsp?channel=&content= - - - - - - - - - - - /views/pages/details.jsp?channel=/&content= - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/navigation/navigation.xsd b/source/test-resources/xforms/examples/wsf-website/navigation/navigation.xsd deleted file mode 100644 index 695f8ad5ee..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/navigation/navigation.xsd +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-feature.xsl b/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-feature.xsl deleted file mode 100644 index 71e5c5352c..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-feature.xsl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - <%String channel = (String) request.getParameter("channel");%> - - - - - - - - -
- - /views/pages/details.jsp?channel=<%=channel%>&amp;content=/content/news-flash/&amp;title= - - - - -
- - -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-list.xsl b/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-list.xsl deleted file mode 100644 index 28f2b0f86d..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash-list.xsl +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - <%String channel = (String) request.getParameter("channel");%> - - - - -
- - /views/pages/details.jsp?channel=<%=channel%>&amp;content=/content/news-flash/&amp;title= - - -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsd b/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsd deleted file mode 100644 index 4de8d65905..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsd +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsl b/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsl deleted file mode 100644 index 6dd520592f..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/news-flash/news-flash.xsl +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - -
- -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/potd/potd.xsd b/source/test-resources/xforms/examples/wsf-website/potd/potd.xsd deleted file mode 100644 index 732abdb507..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/potd/potd.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/potd/potd.xsl b/source/test-resources/xforms/examples/wsf-website/potd/potd.xsl deleted file mode 100644 index c3d582215f..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/potd/potd.xsl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - potd_images[] = new Image(); - potd_images[].src =''; - - - diff --git a/source/test-resources/xforms/examples/wsf-website/profile/profile.xsd b/source/test-resources/xforms/examples/wsf-website/profile/profile.xsd deleted file mode 100644 index 60212cb09f..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/profile/profile.xsd +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/examples/wsf-website/profile/profile.xsl b/source/test-resources/xforms/examples/wsf-website/profile/profile.xsl deleted file mode 100644 index 36ac0ffffd..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/profile/profile.xsl +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - -
- - - - - - - left - - - 75 - - - 75 - - - - - - - - - - . -
- - -
-
- -
-
- -
-
- - - - - - - - # - addGeocode('',''); - Show Address - -
-
-
diff --git a/source/test-resources/xforms/examples/wsf-website/site-configuration/site-configuration.xsd b/source/test-resources/xforms/examples/wsf-website/site-configuration/site-configuration.xsd deleted file mode 100644 index fe2191e640..0000000000 --- a/source/test-resources/xforms/examples/wsf-website/site-configuration/site-configuration.xsd +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1046.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1046.xsd deleted file mode 100644 index 112b7a3ea9..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1046.xsd +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1351.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1351.xsd deleted file mode 100644 index 07fe32acff..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1351.xsd +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - default - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1811.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1811.xsd deleted file mode 100644 index a4e828f504..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1811.xsd +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - English (US) - - - - - - - Japanese - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - Article - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1886.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1886.xsd deleted file mode 100644 index ff891ebfc5..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1886.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - This control does not have an overridden alert - - - - - - - - Please enter a value for hint-alert - This control should have a hint. - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1940.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1940.xsd deleted file mode 100644 index 5662202cc7..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1940.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-1941.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-1941.xsd deleted file mode 100644 index aec6976011..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-1941.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETHREEOH-3117.xsd b/source/test-resources/xforms/tests/bugs/ETHREEOH-3117.xsd deleted file mode 100644 index 5996063472..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETHREEOH-3117.xsd +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETWOTWO-868.xsd b/source/test-resources/xforms/tests/bugs/ETWOTWO-868.xsd deleted file mode 100644 index 4c13f91215..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETWOTWO-868.xsd +++ /dev/null @@ -1,433 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - Alabama - - - - - Alaska - - - - - Arizona - - - - - Arkansas - - - - - California - - - - - Colorado - - - - - Connecticut - - - - - District of Columbia - - - - - Delaware - - - - - Florida - - - - - Georgia - - - - - Hawaii - - - - - Idaho - - - - - Illinois - - - - - Indiana - - - - - Iowa - - - - - Kansas - - - - - Kentucky - - - - - Louisiana - - - - - Maine - - - - - Maryland - - - - - Massachusetts - - - - - Michigan - - - - - Minnesota - - - - - Mississippi - - - - - Missouri - - - - - Montana - - - - - Nebraska - - - - - Nevada - - - - - New Hampshire - - - - - New Jersey - - - - - New Mexico - - - - - New York - - - - - North Carolina - - - - - North Dakota - - - - - Ohio - - - - - Oklahoma - - - - - Oregon - - - - - Pennsylvania - - - - - Rhode Island - - - - - South Carolina - - - - - South Dakota - - - - - Tennessee - - - - - Texas - - - - - Utah - - - - - Vermont - - - - - Virginia - - - - - Washington - - - - - West Virginia - - - - - Wisconsin - - - - - Wyoming - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - The value entered is not a valid zip code. - - - - - - - - - - - - - - - - - - The value entered is not a valid email address. - - - - - - - - - - - - - - - - - - image_file_picker - - - - - - - - - - - - - - full - - - - - - - - - - - - - - search_restricted_file_picker - - - - - - - - - - - - - - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETWOTWO-879.xsd b/source/test-resources/xforms/tests/bugs/ETWOTWO-879.xsd deleted file mode 100644 index 9b231023e1..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETWOTWO-879.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/bugs/ETWOTWO-950.xsd b/source/test-resources/xforms/tests/bugs/ETWOTWO-950.xsd deleted file mode 100644 index 7312c9e428..0000000000 --- a/source/test-resources/xforms/tests/bugs/ETWOTWO-950.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - Test Item - - - - - - - - - - - - Content Type - full - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/tests/bugs/datebug.xsd b/source/test-resources/xforms/tests/bugs/datebug.xsd deleted file mode 100644 index cdca517e95..0000000000 --- a/source/test-resources/xforms/tests/bugs/datebug.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/article.xsd b/source/test-resources/xforms/tests/rendering-engine/article.xsd deleted file mode 100644 index 5d1ef63d27..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/article.xsd +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/article.xslt b/source/test-resources/xforms/tests/rendering-engine/article.xslt deleted file mode 100644 index 68aec71105..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/article.xslt +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - <xsl:value-of select="/ar:Article/ar:Title" disable-output-escaping="yes" /> - - - - - - - - - - - - - - - , - - - - - - - -

-

- - - - - - - - - -
- -
diff --git a/source/test-resources/xforms/tests/rendering-engine/components-test.xsd b/source/test-resources/xforms/tests/rendering-engine/components-test.xsd deleted file mode 100644 index 8ad770d077..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/components-test.xsd +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - - - ${components-test.five_string_values.one} - - - - - - - ${components-test.five_string_values.two} - - - - - - - ${components-test.five_string_values.three} - - - - - - - ${components-test.five_string_values.four} - - - - - - - ${components-test.five_string_values.five} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${components-test.required_textfield.label} - ${components-test.required_textfield.alert} - - - - - - - ${components-test.optional_textfield.label} - ${components-test.optional_textfield.alert} - - - - - - - - - - - - - minimal - - - - - - - compact - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - full - this control should appear as radio buttons. - - - - - - - - full - Please select some of these numbers. This control should appear as a list. - - - - - - - - ${components-test.list_of_ten_select_three.label} - ${components-test.list_of_ten_select_three.alert} - Please select exactly three elements from this list. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/components-test.xsl b/source/test-resources/xforms/tests/rendering-engine/components-test.xsl deleted file mode 100644 index fb0d99e1d1..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/components-test.xsl +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - Component Test - - - - - - - -
Required Textfield:
-
- -
Optional Textfield:
-
- -
TextArea:
-
- -
Integer:
-
- -
Positive Integer:
-
- -
Double:
-
- -
Date:
-
- -
Radio:
-
- -
ComboBox:
-
- -
CheckBox:
-
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/default-values.xsd b/source/test-resources/xforms/tests/rendering-engine/default-values.xsd deleted file mode 100644 index badd831df3..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/default-values.xsd +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/default-values.xsl b/source/test-resources/xforms/tests/rendering-engine/default-values.xsl deleted file mode 100644 index da14742ce0..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/default-values.xsl +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.ftl b/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.ftl deleted file mode 100644 index cbaeaf0462..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.ftl +++ /dev/null @@ -1,67 +0,0 @@ -<#ftl ns_prefixes={"alf", "http://www.alfresco.org"}> - - - - Simple Test - - -
Generated by output-method-callout.ftl
- -
<#noparse>${alf.avm_sandbox_url}
- ${alf.avm_sandbox_url} - -
<#noparse>${alf.form_instance_data_file_name}
- ${alf.form_instance_data_file_name} - -
<#noparse>${alf.rendition_file_name}
- ${alf.rendition_file_name} - -
<#noparse>${alf.parent_path}
- ${alf.parent_path} - -
<#noparse>${alf.request_context_path}
- ${alf.request_context_path} - -
<#noparse>${alf.request_context_path}${simple.uri}
- ${alf.request_context_path}${simple.uri} - -
<#noparse>${alf._getAVMPath('foo')}
- ${alf._getAVMPath('foo')} - -
<#noparse>${alf._getAVMPath('/foo')}
- ${alf._getAVMPath('/foo')} - -
My value accessed using <#noparse>${simple.string}:
- ${simple.string} - -
My value accessed using <#noparse>$alf.parseXMLDocument(${alf.form_instance_data_file_name}):
- ${alf.parseXMLDocument(alf.form_instance_data_file_name).string} - -
Values from xml files generated by in ${alf.parent_path}:
-
    - <#list alf.parseXMLDocuments('form-data-functions-test') as d> -
  • -
    - <#noparse>${d["@alf:file_name"]} = ${d.string} -
    - ${d["@alf:file_name"]} = ${d.string} -
  • - -
- - diff --git a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsd b/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsd deleted file mode 100644 index 4588d4ac1e..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsd +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsl b/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsl deleted file mode 100644 index 00a5406552..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/form-data-functions-test.xsl +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - Simple Test - - -
Generated by output-method-callout.xsl
- -
- <xsl:value-of select="$alf:avm_sandbox_url"/> -
- - -
- <xsl:value-of select="$alf:form_instance_data_file_name"/> -
- - -
- <xsl:value-of select="$alf:rendition_file_name"/> -
- - -
- <xsl:value-of select="$alf:parent_path"/> -
- - -
- <xsl:value-of select="$alf:request_context_path"/> -
- - -
- <xsl:value-of select="$alf:request_context_path"/><xsl:value-of select="/simple/uri"/> -
- - -
- <xsl:value-of select="alf:_getAVMPath('foo')"/> -
- - -
- <xsl:value-of select="alf:_getAVMPath('/foo')"/> -
- - -
My value accessed using /simple/string:
- - -
My value accessed using alf:parseXMLDocument($alf:form_instance_data_file_name):
- - -
My value accessed using document(concat('/', $alf:form_instance_data_file_name)):
- - -
Values from xml files generated by in :
-
    - -
  • -
    - <xsl:value-of select="@alf:file_name"/> = <xsl:value-of select="string"/> -
    - - = - -
  • -
    -
- - -
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/html-block-with-attributes.xsd b/source/test-resources/xforms/tests/rendering-engine/html-block-with-attributes.xsd deleted file mode 100644 index d5f48eeed2..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/html-block-with-attributes.xsd +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/html-block.xsd b/source/test-resources/xforms/tests/rendering-engine/html-block.xsd deleted file mode 100644 index a49e3e7e93..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/html-block.xsd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/html-block.xslt b/source/test-resources/xforms/tests/rendering-engine/html-block.xslt deleted file mode 100644 index e3b7050fc0..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/html-block.xslt +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - <xsl:value-of select="/hb:HtmlBlock/hb:Title" disable-output-escaping="yes" /> - - - - - - - - - - - - - - - , - - - - - - - -

-

- - -
- -
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.ftl b/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.ftl deleted file mode 100644 index 13c795ae83..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.ftl +++ /dev/null @@ -1 +0,0 @@ -
Value from data dictionary is ${.vars["include-test"]["in-data-dictionary"]}
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.xsl b/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.xsl deleted file mode 100644 index fcd698f655..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test-data-dictionary.xsl +++ /dev/null @@ -1,10 +0,0 @@ - - - - -
Value from data dictonary is
-
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.ftl b/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.ftl deleted file mode 100644 index fd4c47a126..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.ftl +++ /dev/null @@ -1 +0,0 @@ -
Value from webapp is ${.vars["include-test"]["in-webapp"]}
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.xsl b/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.xsl deleted file mode 100644 index 9913061317..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test-webapp.xsl +++ /dev/null @@ -1,10 +0,0 @@ - - - - -
Value from webapp is
-
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test.ftl b/source/test-resources/xforms/tests/rendering-engine/include-test.ftl deleted file mode 100644 index 0d6997f62e..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test.ftl +++ /dev/null @@ -1,11 +0,0 @@ - - - Include Test - - -
Generated by include-test.ftl
-
Value from template is ${.vars["include-test"]["in-template"]}
- <#include "include-test-data-dictionary.ftl"> - <#include "include-test-webapp.ftl"> - - diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test.xsd b/source/test-resources/xforms/tests/rendering-engine/include-test.xsd deleted file mode 100644 index 3196e7d5cb..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test.xsd +++ /dev/null @@ -1,26 +0,0 @@ - - - - - This form demonstrates methods of including templates from templates. To set up configure the form like this: - configure include-test.xsl and include-test.ftl as the rendering engine templates for the form. - upload include-test-data-dictionary.* into the data dictionary folder created for the form (e.g. Data Dictionary/Web Forms/include-test - upload include-test-webapp.* into the root of your webapp directory within the web project. - - An example of including the output of a webscript can also be shown by creating a separate form using this schema - and the include-webscript-test.xsl and include-webscript-test.ftl files as the rendering engine templates. - - When the rendering template gets executed, it should be able to include all auxilliary xsls and ftls. - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/include-test.xsl b/source/test-resources/xforms/tests/rendering-engine/include-test.xsl deleted file mode 100644 index 06e2e46159..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-test.xsl +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -
Value from template is
-
- - - - - Include Test - - -
Generated by include-test.xsl
- - - - - -
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.ftl b/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.ftl deleted file mode 100644 index 1c6e96d578..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.ftl +++ /dev/null @@ -1,10 +0,0 @@ - - - Include Test - - -
Generated by include-webscript-test.ftl
-
Value from template is ${.vars["include-test"]["in-template"]}
- <#include "webscript://api/path/content/avm/{storeid}/www/avm_webapps/ROOT/include-test-webapp.ftl?ticket={ticket}"> - - diff --git a/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.xsl b/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.xsl deleted file mode 100644 index 8bfb61a517..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/include-webscript-test.xsl +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - -
Value from template is
-
- - - - - Include Test - - -
Generated by include-webscript-test.xsl
- - - - -
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsd b/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsd deleted file mode 100644 index 745c67135b..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsd +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsl b/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsl deleted file mode 100644 index ae49080b76..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/repeat-components.xsl +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - repeat-components - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
zero-to-one
one-to-one
- - one-to-inf - -
    - -
  • -
    -
-
- - zero-to-inf - -
    - -
  • -
    -
-
- - one-to-five - -
    - -
  • -
    -
-
- - zero-to-five - -
    - -
  • -
    -
-
- - one-to-five-multi - -
    - -
      -
    • -
    • -
    -
    -
-
- - zero-to-five-multi - -
    - -
  • -
      -
    • -
    • -
    -
  • -
    -
-
- - -
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsd b/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsd deleted file mode 100644 index de742f1742..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsl b/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsl deleted file mode 100644 index cafd1af2e6..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/repeat-simple-test.xsl +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - repeat-simple - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
zero-to-one
one-to-one
- - one-to-inf - -
    - -
  • -
    -
-
- - zero-to-inf - -
    - -
  • -
    -
-
- - one-to-five - -
    - -
  • -
    -
-
- - zero-to-five - -
    - -
  • -
    -
-
- - one-to-five-multi - -
    - -
      -
    • -
    • -
    -
    -
-
- - zero-to-five-multi - -
    - -
  • -
      -
    • -
    • -
    -
  • -
    -
-
- - -
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/simple-test.fo b/source/test-resources/xforms/tests/rendering-engine/simple-test.fo deleted file mode 100644 index 7425694203..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/simple-test.fo +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - Generated by simple-test.fo - - Captured string value: - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/simple-test.ftl b/source/test-resources/xforms/tests/rendering-engine/simple-test.ftl deleted file mode 100644 index ef98b6ead8..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/simple-test.ftl +++ /dev/null @@ -1,27 +0,0 @@ - - - - Simple Test - - -
Generated by simple-test.ftl
-
- Captured string value: - ${simple.string} -
- - diff --git a/source/test-resources/xforms/tests/rendering-engine/simple-test.xsd b/source/test-resources/xforms/tests/rendering-engine/simple-test.xsd deleted file mode 100644 index f105a6ddb1..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/simple-test.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/simple-test.xsl b/source/test-resources/xforms/tests/rendering-engine/simple-test.xsl deleted file mode 100644 index dc5b19d3d5..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/simple-test.xsl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - Simple Test - - -
Generated by simple-test.xsl
- - - - -
- -
- Captured string value: - -
-
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/strings.properties b/source/test-resources/xforms/tests/rendering-engine/strings.properties deleted file mode 100644 index 171fe53076..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/strings.properties +++ /dev/null @@ -1,9 +0,0 @@ -components-test.five_string_values.one=First -components-test.five_string_values.two=Second -components-test.five_string_values.three=Third -components-test.five_string_values.four=Fourth -components-test.five_string_values.five=Fifth -components-test.required_textfield.label=A Required Text Field -components-test.required_textfield.alert=Please enter a value in the required text field -components-test.list_of_ten_select_three.label=Select 3 -components-test.list_of_ten_select_three.alert=Please select 3 values in select 3 diff --git a/source/test-resources/xforms/tests/rendering-engine/strings_fr.properties b/source/test-resources/xforms/tests/rendering-engine/strings_fr.properties deleted file mode 100644 index 8f091b1dd8..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/strings_fr.properties +++ /dev/null @@ -1,9 +0,0 @@ -components-test.five_string_values.one=Un -components-test.five_string_values.two=Duex -components-test.five_string_values.three=Trois -components-test.five_string_values.four=Quatre -components-test.five_string_values.five=Cinq -components-test.required_textfield.label=Un gisement exigé des textes -components-test.required_textfield.alert=écrivent s'il vous plaît une valeur dans le domaine exigé des textes -components-test.list_of_ten_select_three.label=Choisissez 3 -components-test.list_of_ten_select_three.alert=s'il vous plaît 3 choises dans 3 choises diff --git a/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsd b/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsd deleted file mode 100644 index c76fab1f51..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsd +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - minimal - - - - - - - - full - - - - - - - custom - - - - - - - fullscreen - - - - - - - - - minimal - - - - - - - full - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsl b/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsl deleted file mode 100644 index a320800852..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/textarea-test.xsl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - textarea test - - -
Generated by textarea-test.xsl
- - - -
- -
- plain text: - -
-
- -
- rich text anyType: - -
-
- -
- rich text stringType: - -
-
- -
- rich text stringType attribute: - -
-
- -
- rich text stringType attribute: - -
-
-
diff --git a/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsd b/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsd deleted file mode 100644 index 0acfc2df46..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsl b/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsl deleted file mode 100644 index da14742ce0..0000000000 --- a/source/test-resources/xforms/tests/rendering-engine/xml-namespaces-test.xsl +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/attribute-group-test.xsd b/source/test-resources/xforms/tests/schema/attribute-group-test.xsd deleted file mode 100644 index 147dbf2326..0000000000 --- a/source/test-resources/xforms/tests/schema/attribute-group-test.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/attributes-test.xsd b/source/test-resources/xforms/tests/schema/attributes-test.xsd deleted file mode 100644 index dfd5a6efee..0000000000 --- a/source/test-resources/xforms/tests/schema/attributes-test.xsd +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/broken-import-negative-test.xsd b/source/test-resources/xforms/tests/schema/broken-import-negative-test.xsd deleted file mode 100644 index 9b01191c9c..0000000000 --- a/source/test-resources/xforms/tests/schema/broken-import-negative-test.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/datetime-test.xsd b/source/test-resources/xforms/tests/schema/datetime-test.xsd deleted file mode 100644 index fab369a8f2..0000000000 --- a/source/test-resources/xforms/tests/schema/datetime-test.xsd +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - minimal - - - - - - - - - - minimal - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/default-values-test.xsd b/source/test-resources/xforms/tests/schema/default-values-test.xsd deleted file mode 100644 index 109afee3f1..0000000000 --- a/source/test-resources/xforms/tests/schema/default-values-test.xsd +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - full - - - full - - - minimal - - - minimal - - - - - - - - - - - - - - - - - - - - full - - - full - - - minimal - - - minimal - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/element-ref-test.xsd b/source/test-resources/xforms/tests/schema/element-ref-test.xsd deleted file mode 100644 index 1c1930b45b..0000000000 --- a/source/test-resources/xforms/tests/schema/element-ref-test.xsd +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/empty-extension-test.xsd b/source/test-resources/xforms/tests/schema/empty-extension-test.xsd deleted file mode 100644 index 40ebd8e0cf..0000000000 --- a/source/test-resources/xforms/tests/schema/empty-extension-test.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/group-appearance-test.xsd b/source/test-resources/xforms/tests/schema/group-appearance-test.xsd deleted file mode 100644 index fcfea78458..0000000000 --- a/source/test-resources/xforms/tests/schema/group-appearance-test.xsd +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - full - - - compact - - - full - - - - minimal - - - minimal - - - - - - - - - minimal - - - - - - - - - - minimal - - - - - - - - minimal - - - - - - - - - - minimal - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/hidden-field-example.xsd b/source/test-resources/xforms/tests/schema/hidden-field-example.xsd deleted file mode 100644 index 5b75f2e56b..0000000000 --- a/source/test-resources/xforms/tests/schema/hidden-field-example.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - hidden - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/image.xsd b/source/test-resources/xforms/tests/schema/image.xsd deleted file mode 100644 index ae62cf4740..0000000000 --- a/source/test-resources/xforms/tests/schema/image.xsd +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/import-example.xsd b/source/test-resources/xforms/tests/schema/import-example.xsd deleted file mode 100644 index 7480da177a..0000000000 --- a/source/test-resources/xforms/tests/schema/import-example.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/imported.xsd b/source/test-resources/xforms/tests/schema/imported.xsd deleted file mode 100644 index bfd266134a..0000000000 --- a/source/test-resources/xforms/tests/schema/imported.xsd +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/inheritence-test.xsd b/source/test-resources/xforms/tests/schema/inheritence-test.xsd deleted file mode 100644 index 3556a698f5..0000000000 --- a/source/test-resources/xforms/tests/schema/inheritence-test.xsd +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/integer-test.xsd b/source/test-resources/xforms/tests/schema/integer-test.xsd deleted file mode 100644 index ff10cab1bc..0000000000 --- a/source/test-resources/xforms/tests/schema/integer-test.xsd +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Integer Restricted -10 to 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/list-test.xsd b/source/test-resources/xforms/tests/schema/list-test.xsd deleted file mode 100644 index 73a774a370..0000000000 --- a/source/test-resources/xforms/tests/schema/list-test.xsd +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - Teddy Roosevelt - - - - - - - - - - - - - new hampshire - - - - - new york - - - - - - rhode island - - - - - new jersey - - - - - - - - - north carolina - - - - - south carolina - - - - - - - - - - - - - - - - - - - - - full - - - - - - - compact - - - - - - - - - - - - - - full - - - - - - - compact - - - - - - - - - - - - - - - - - - - - full - - - - - - - compact - - - - - - - - - - - - - - full - - - - - - - compact - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/multi-form-schema-test.xsd b/source/test-resources/xforms/tests/schema/multi-form-schema-test.xsd deleted file mode 100644 index 151a13edff..0000000000 --- a/source/test-resources/xforms/tests/schema/multi-form-schema-test.xsd +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/multi-namespace-test-other.xsd b/source/test-resources/xforms/tests/schema/multi-namespace-test-other.xsd deleted file mode 100644 index a6d4321fd1..0000000000 --- a/source/test-resources/xforms/tests/schema/multi-namespace-test-other.xsd +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/multi-namespace-test.xsd b/source/test-resources/xforms/tests/schema/multi-namespace-test.xsd deleted file mode 100644 index 733ee46081..0000000000 --- a/source/test-resources/xforms/tests/schema/multi-namespace-test.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/multilingual-press-release.xsd b/source/test-resources/xforms/tests/schema/multilingual-press-release.xsd deleted file mode 100644 index af1d3025b0..0000000000 --- a/source/test-resources/xforms/tests/schema/multilingual-press-release.xsd +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/no-elements-test.xsd b/source/test-resources/xforms/tests/schema/no-elements-test.xsd deleted file mode 100644 index ea40bc45c7..0000000000 --- a/source/test-resources/xforms/tests/schema/no-elements-test.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/optional-required.xsd b/source/test-resources/xforms/tests/schema/optional-required.xsd deleted file mode 100644 index b0682c4ddb..0000000000 --- a/source/test-resources/xforms/tests/schema/optional-required.xsd +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/range-test.xsd b/source/test-resources/xforms/tests/schema/range-test.xsd deleted file mode 100644 index 71066e6d81..0000000000 --- a/source/test-resources/xforms/tests/schema/range-test.xsd +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/read-only-field.xsd b/source/test-resources/xforms/tests/schema/read-only-field.xsd deleted file mode 100644 index eb18747f09..0000000000 --- a/source/test-resources/xforms/tests/schema/read-only-field.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - Identifier - readonly - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/readonly-and-default-values-test.xsd b/source/test-resources/xforms/tests/schema/readonly-and-default-values-test.xsd deleted file mode 100644 index 109afee3f1..0000000000 --- a/source/test-resources/xforms/tests/schema/readonly-and-default-values-test.xsd +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - full - - - full - - - minimal - - - minimal - - - - - - - - - - - - - - - - - - - - full - - - full - - - minimal - - - minimal - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/recursive-test.xsd b/source/test-resources/xforms/tests/schema/recursive-test.xsd deleted file mode 100644 index ac61994e54..0000000000 --- a/source/test-resources/xforms/tests/schema/recursive-test.xsd +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/repeat-constraints.xsd b/source/test-resources/xforms/tests/schema/repeat-constraints.xsd deleted file mode 100644 index 4408a42dfd..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-constraints.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/repeat-multi.xsd b/source/test-resources/xforms/tests/schema/repeat-multi.xsd deleted file mode 100644 index 99c7df9a55..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-multi.xsd +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/repeat-nested-simple.xsd b/source/test-resources/xforms/tests/schema/repeat-nested-simple.xsd deleted file mode 100644 index 4307281eac..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-nested-simple.xsd +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/repeat-nested-test.xsd b/source/test-resources/xforms/tests/schema/repeat-nested-test.xsd deleted file mode 100644 index 27c2abd460..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-nested-test.xsd +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - GET - - - - - - - POST - - - - - - - - - - - - Text - - - - - - - Text Area - - - - - - - Checkbox - - - - - - - Selection (Single) - - - - - - - Selection (Multiple) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Form ID - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/tests/schema/repeat-submit-test.xsd b/source/test-resources/xforms/tests/schema/repeat-submit-test.xsd deleted file mode 100644 index 448afcbdcc..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-submit-test.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/repeat-textarea.xsd b/source/test-resources/xforms/tests/schema/repeat-textarea.xsd deleted file mode 100644 index bd67e93a7c..0000000000 --- a/source/test-resources/xforms/tests/schema/repeat-textarea.xsd +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/schema-from-forum.xsd b/source/test-resources/xforms/tests/schema/schema-from-forum.xsd deleted file mode 100644 index 4caca82f78..0000000000 --- a/source/test-resources/xforms/tests/schema/schema-from-forum.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - English - - - - - - - Français - - - - - - - - - - - - - - - - - - - - - How much will appear on index? - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/tests/schema/select1-test.xsd b/source/test-resources/xforms/tests/schema/select1-test.xsd deleted file mode 100644 index 8fe446f302..0000000000 --- a/source/test-resources/xforms/tests/schema/select1-test.xsd +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/switch-test.xsd b/source/test-resources/xforms/tests/schema/switch-test.xsd deleted file mode 100644 index cd5a8674a6..0000000000 --- a/source/test-resources/xforms/tests/schema/switch-test.xsd +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/test-asset-pickers.xsd b/source/test-resources/xforms/tests/schema/test-asset-pickers.xsd deleted file mode 100644 index 9e2d12a39f..0000000000 --- a/source/test-resources/xforms/tests/schema/test-asset-pickers.xsd +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/upload-simple-test.xsd b/source/test-resources/xforms/tests/schema/upload-simple-test.xsd deleted file mode 100644 index 19dc7ce4bc..0000000000 --- a/source/test-resources/xforms/tests/schema/upload-simple-test.xsd +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image_file_picker - - - folder_restricted_file_picker - - - search_restricted_file_picker - - - html_file_picker - - - folder_picker - - - file_picker - - - - - - - - diff --git a/source/test-resources/xforms/tests/schema/xspattern-test.xsd b/source/test-resources/xforms/tests/schema/xspattern-test.xsd deleted file mode 100644 index e86536d0b6..0000000000 --- a/source/test-resources/xforms/tests/schema/xspattern-test.xsd +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/all-widgets.xsd b/source/test-resources/xforms/unit-tests/all-widgets.xsd deleted file mode 100644 index e41144df02..0000000000 --- a/source/test-resources/xforms/unit-tests/all-widgets.xsd +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - custom - full - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file_picker - folder_picker - html_file_picker - image_file_picker - search_restricted_file_picker - folder_restricted_file_picker - - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - full - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/unit-tests/all-widgets_xform.xml b/source/test-resources/xforms/unit-tests/all-widgets_xform.xml deleted file mode 100644 index 981b6833c9..0000000000 --- a/source/test-resources/xforms/unit-tests/all-widgets_xform.xml +++ /dev/null @@ -1,1261 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - custom - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file_picker - - - - - - - folder_picker - - - - - - - html_file_picker - - - - - - - image_file_picker - - - - - - - search_restricted_file_picker - - - - - - - folder_restricted_file_picker - - - - - - - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - full - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - minimal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AllWidgets - - TextField NormalizedString - Please provide a valid value for 'TextField NormalizedString'. - 'TextField NormalizedString' is a required 'NormalizedString' value. - - - PlainTextEditor String Minimal - Please provide a valid value for 'PlainTextEditor String Minimal'. - 'PlainTextEditor String Minimal' is a required 'String' value. - - - RichTextEditor String - Please provide a valid value for 'RichTextEditor String'. - 'RichTextEditor String' is a required 'String' value. - - - RichTextEditor String Custom - Please provide a valid value for 'RichTextEditor String Custom'. - 'RichTextEditor String Custom' is a required 'String' value. - - - RichTextEditor String Full - Please provide a valid value for 'RichTextEditor String Full'. - 'RichTextEditor String Full' is a required 'String' value. - - - DatePicker Date - Please provide a valid value for 'DatePicker Date'. 'DatePicker Date' - is a required 'Date' value. - - - TimePicker Time - Please provide a valid value for 'TimePicker Time'. 'TimePicker Time' - is a required 'Time' value. - - - DateTimePicker DateTime - Please provide a valid value for 'DateTimePicker DateTime'. - 'DateTimePicker DateTime' is a required 'DateTime' value. - - - DayPicker GDay - Please provide a valid value for 'DayPicker GDay'. 'DayPicker GDay' is - a required 'GDay' value. - - - MonthPicker GMonth - Please provide a valid value for 'MonthPicker GMonth'. 'MonthPicker - GMonth' is a required 'GMonth' value. - - - YearPicker GYear - Please provide a valid value for 'YearPicker GYear'. 'YearPicker - GYear' is a required 'GYear' value. - - - MonthDayPicker GMonthDay - Please provide a valid value for 'MonthDayPicker GMonthDay'. - 'MonthDayPicker GMonthDay' is a required 'GMonthDay' value. - - - YearMonthPicker GYearMonth - Please provide a valid value for 'YearMonthPicker GYearMonth'. - 'YearMonthPicker GYearMonth' is a required 'GYearMonth' value. - - - - true - true - - - false - false - - Checkbox Boolean - Please provide a valid value for 'Checkbox Boolean'. 'Checkbox - Boolean' is a required 'Boolean' value. - - - NumericalRange Integer - Please provide a valid value for 'NumericalRange Integer'. - 'NumericalRange Integer' is a required 'Integer' value. - - - - FilePicker AnyURI - Please provide a valid value for 'FilePicker AnyURI'. 'FilePicker - AnyURI' is a required 'AnyURI' value. - - - - FilePicker AnyURI File Picker - Please provide a valid value for 'FilePicker AnyURI File Picker'. - 'FilePicker AnyURI File Picker' is a required 'AnyURI' value. - - - - FilePicker AnyURI Folder Picker - Please provide a valid value for 'FilePicker AnyURI Folder Picker'. - 'FilePicker AnyURI Folder Picker' is a required 'AnyURI' value. - - - - FilePicker AnyURI Html File Picker - Please provide a valid value for 'FilePicker AnyURI Html File Picker'. - 'FilePicker AnyURI Html File Picker' is a required 'AnyURI' value. - - - - FilePicker AnyURI Image File Picker - Please provide a valid value for 'FilePicker AnyURI Image File - Picker'. 'FilePicker AnyURI Image File Picker' is a required 'AnyURI' value. - - - - FilePicker AnyURI Search Restricted File Picker - Please provide a valid value for 'FilePicker AnyURI Search Restricted - File Picker'. 'FilePicker AnyURI Search Restricted File Picker' is a required 'AnyURI' - value. - - - - FilePicker AnyURI Folder Restricted File Picker - Please provide a valid value for 'FilePicker AnyURI Folder Restricted - File Picker'. 'FilePicker AnyURI Folder Restricted File Picker' is a required 'AnyURI' - value. - - - CheckboxSelect List Full - - - Checkbox List Full 1 - Checkbox List full 1 - - - Checkbox List Full 2 - Checkbox List full 2 - - - Checkbox List Full 3 - Checkbox List full 3 - - - Checkbox List Full 4 - Checkbox List full 4 - - - Checkbox List Full 5 - Checkbox List full 5 - - - Checkbox List Full 6 - Checkbox List full 6 - - - Checkbox List Full 7 - Checkbox List full 7 - - - Checkbox List Full 8 - Checkbox List full 8 - - - Checkbox List Full 9 - Checkbox List full 9 - - - Checkbox List Full 10 - Checkbox List full 10 - - - Please provide a valid value for 'CheckboxSelect List Full'. - 'CheckboxSelect List Full' is a required 'NormalizedString' value. - - - ListSelect List Minimal - - - List List Minimal 1 - List List minimal 1 - - - List List Minimal 2 - List List minimal 2 - - - List List Minimal 3 - List List minimal 3 - - - List List Minimal 4 - List List minimal 4 - - - List List Minimal 5 - List List minimal 5 - - - List List Minimal 6 - List List minimal 6 - - - List List Minimal 7 - List List minimal 7 - - - List List Minimal 8 - List List minimal 8 - - - List List Minimal 9 - List List minimal 9 - - - List List Minimal 10 - List List minimal 10 - - - Please provide a valid value for 'ListSelect List Minimal'. - 'ListSelect List Minimal' is a required 'NormalizedString' value. - - - CheckboxSelect List Default Short - - - Checkbox List Default Short 1 - Checkbox List default short 1 - - - Checkbox List Default Short 2 - Checkbox List default short 2 - - - Checkbox List Default Short 3 - Checkbox List default short 3 - - - Please provide a valid value for 'CheckboxSelect List Default Short'. - 'CheckboxSelect List Default Short' is a required 'NormalizedString' value. - - - ListSelect List Default Long - - - List List Default Long 1 - List List default long 1 - - - List List Default Long 2 - List List default long 2 - - - List List Default Long 3 - List List default long 3 - - - List List Default Long 4 - List List default long 4 - - - List List Default Long 5 - List List default long 5 - - - List List Default Long 6 - List List default long 6 - - - List List Default Long 7 - List List default long 7 - - - List List Default Long 8 - List List default long 8 - - - List List Default Long 9 - List List default long 9 - - - List List Default Long 10 - List List default long 10 - - - Please provide a valid value for 'ListSelect List Default Long'. - 'ListSelect List Default Long' is a required 'NormalizedString' value. - - - RadioSelect1 Enum Full - - - Radio Enum Full 1 - Radio enum full 1 - - - Radio Enum Full 2 - Radio enum full 2 - - - Radio Enum Full 3 - Radio enum full 3 - - - Radio Enum Full 4 - Radio enum full 4 - - - Radio Enum Full 5 - Radio enum full 5 - - - Radio Enum Full 6 - Radio enum full 6 - - - Radio Enum Full 7 - Radio enum full 7 - - - Radio Enum Full 8 - Radio enum full 8 - - - Radio Enum Full 9 - Radio enum full 9 - - - Radio Enum Full 10 - Radio enum full 10 - - - Please provide a valid value for 'RadioSelect1 Enum Full'. - 'RadioSelect1 Enum Full' is a required 'NormalizedString' value. - - - ComboboxSelect1 Enum Minimal - - - Please Select... - Please select... - - - Combobox Enum Minimal 1 - Combobox enum minimal 1 - - - Combobox Enum Minimal 2 - Combobox enum minimal 2 - - - Combobox Enum Minimal 3 - Combobox enum minimal 3 - - - Combobox Enum Minimal 4 - Combobox enum minimal 4 - - - Combobox Enum Minimal 5 - Combobox enum minimal 5 - - - Combobox Enum Minimal 6 - Combobox enum minimal 6 - - - Combobox Enum Minimal 7 - Combobox enum minimal 7 - - - Combobox Enum Minimal 8 - Combobox enum minimal 8 - - - Combobox Enum Minimal 9 - Combobox enum minimal 9 - - - Combobox Enum Minimal 10 - Combobox enum minimal 10 - - - Please provide a valid value for 'ComboboxSelect1 Enum Minimal'. - 'ComboboxSelect1 Enum Minimal' is a required 'NormalizedString' value. - - - RadioSelect1 Enum Default Short - - - Radio Enum Default Short 1 - Radio enum default short 1 - - - Radio Enum Default Short 2 - Radio enum default short 2 - - - Radio Enum Default Short 3 - Radio enum default short 3 - - - Please provide a valid value for 'RadioSelect1 Enum Default Short'. - 'RadioSelect1 Enum Default Short' is a required 'NormalizedString' value. - - - ComboboxSelect1 Enum Default Long - - - Please Select... - Please select... - - - Combobox Enum Default Long 1 - Combobox enum default long 1 - - - Combobox Enum Default Long 2 - Combobox enum default long 2 - - - Combobox Enum Default Long 3 - Combobox enum default long 3 - - - Combobox Enum Default Long 4 - Combobox enum default long 4 - - - Combobox Enum Default Long 5 - Combobox enum default long 5 - - - Combobox Enum Default Long 6 - Combobox enum default long 6 - - - Combobox Enum Default Long 7 - Combobox enum default long 7 - - - Combobox Enum Default Long 8 - Combobox enum default long 8 - - - Combobox Enum Default Long 9 - Combobox enum default long 9 - - - Combobox Enum Default Long 10 - Combobox enum default long 10 - - - Please provide a valid value for 'ComboboxSelect1 Enum Default Long'. - 'ComboboxSelect1 Enum Default Long' is a required 'NormalizedString' value. - - - VGroup ComplexType Sequence - - SequenceString - Please provide a valid value for 'SequenceString'. 'SequenceString' - is a required 'NormalizedString' value. - - - SequenceDecimal - Please provide a valid value for 'SequenceDecimal'. - 'SequenceDecimal' is a required 'Decimal' value. - - - - HGroup ComplexType All Minimal - - Horizontal1 - Please provide a valid value for 'Horizontal1'. 'Horizontal1' is a - required 'NormalizedString' value. - - - Horizontal2 - Please provide a valid value for 'Horizontal2'. 'Horizontal2' is a - required 'NormalizedString' value. - - - - Repeat 1to3 NormalizedString - - - - Repeat 1to3 NormalizedString - Please provide a valid value for 'Repeat 1to3 NormalizedString'. - 'Repeat 1to3 NormalizedString' is a required 'NormalizedString' value. - - - - - - baseComplexType - - - baseComplexType - - - - complexContentType - - - complexContentType - - - - complexContentType2 - - - complexContentType2 - - - - - baseComplexType - - Trigger SwitchGroup CaseGroup ComplexType - - Part1 - Please provide a valid value for 'Part1'. 'Part1' is a required - 'NormalizedString' value. - - - Part2 - Please provide a valid value for 'Part2'. 'Part2' is a required - 'NormalizedString' value. - - - - - complexContentType - - Trigger SwitchGroup CaseGroup ComplexType - - Part1 - Please provide a valid value for 'Part1'. 'Part1' is a required - 'NormalizedString' value. - - - Part2 - Please provide a valid value for 'Part2'. 'Part2' is a required - 'NormalizedString' value. - - - Part3 - Please provide a valid value for 'Part3'. 'Part3' is a required - 'NormalizedString' value. - - - Part4 - Please provide a valid value for 'Part4'. 'Part4' is a required - 'NormalizedString' value. - - - - - complexContentType2 - - Trigger SwitchGroup CaseGroup ComplexType - - Part1 - Please provide a valid value for 'Part1'. 'Part1' is a required - 'NormalizedString' value. - - - Part2 - Please provide a valid value for 'Part2'. 'Part2' is a required - 'NormalizedString' value. - - - Part5 - Please provide a valid value for 'Part5'. 'Part5' is a required - 'NormalizedString' value. - - - Part6 - Please provide a valid value for 'Part6'. 'Part6' is a required - 'NormalizedString' value. - - - - - - Submit - - - Save Draft - - - insert at beginning - - - - - - insert after selected - - - - - - delete selected - - - - - - - \ No newline at end of file diff --git a/source/test-resources/xforms/unit-tests/annotation-test.xsd b/source/test-resources/xforms/unit-tests/annotation-test.xsd deleted file mode 100644 index 12b95e35ae..0000000000 --- a/source/test-resources/xforms/unit-tests/annotation-test.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - upload_in_base - - - string_in_base - - - - - - - - - upload_in_struct - - - string_in_struct - - - - - - - - - - upload_in_root - - - string_in_root - - - - - - diff --git a/source/test-resources/xforms/unit-tests/constraint-test.xsd b/source/test-resources/xforms/unit-tests/constraint-test.xsd deleted file mode 100644 index 4fc4cc66bd..0000000000 --- a/source/test-resources/xforms/unit-tests/constraint-test.xsd +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/derived-type-test.xsd b/source/test-resources/xforms/unit-tests/derived-type-test.xsd deleted file mode 100644 index 0b4ade56e4..0000000000 --- a/source/test-resources/xforms/unit-tests/derived-type-test.xsd +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/number-test.xsd b/source/test-resources/xforms/unit-tests/number-test.xsd deleted file mode 100644 index 1e2375fa5c..0000000000 --- a/source/test-resources/xforms/unit-tests/number-test.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/one-string-test.xsd b/source/test-resources/xforms/unit-tests/one-string-test.xsd deleted file mode 100644 index 5781468893..0000000000 --- a/source/test-resources/xforms/unit-tests/one-string-test.xsd +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/recursive-test.xsd b/source/test-resources/xforms/unit-tests/recursive-test.xsd deleted file mode 100644 index 5fb3c566eb..0000000000 --- a/source/test-resources/xforms/unit-tests/recursive-test.xsd +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/repeat-constraints-test.xsd b/source/test-resources/xforms/unit-tests/repeat-constraints-test.xsd deleted file mode 100644 index 07e5c87892..0000000000 --- a/source/test-resources/xforms/unit-tests/repeat-constraints-test.xsd +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/root-element-with-extension-test.xsd b/source/test-resources/xforms/unit-tests/root-element-with-extension-test.xsd deleted file mode 100644 index 5226d1b323..0000000000 --- a/source/test-resources/xforms/unit-tests/root-element-with-extension-test.xsd +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/test-resources/xforms/unit-tests/switch-test.xsd b/source/test-resources/xforms/unit-tests/switch-test.xsd deleted file mode 100644 index 42b039f811..0000000000 --- a/source/test-resources/xforms/unit-tests/switch-test.xsd +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/web/WEB-INF/chiba.xml b/source/web/WEB-INF/chiba.xml deleted file mode 100644 index 21f10a7d8a..0000000000 --- a/source/web/WEB-INF/chiba.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index c4da3c1c33..50cf5e7c1a 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -824,10 +824,6 @@ dictionaryService #{DictionaryService} - - formsService - #{FormsService} - @@ -865,10 +861,6 @@ dictionaryService #{DictionaryService} - - formsService - #{FormsService} - diff --git a/source/web/WEB-INF/faces-config-navigation.xml b/source/web/WEB-INF/faces-config-navigation.xml index 55179b840c..2b88ff7136 100644 --- a/source/web/WEB-INF/faces-config-navigation.xml +++ b/source/web/WEB-INF/faces-config-navigation.xml @@ -583,45 +583,6 @@ - - /jsp/* - - browseWebsite - /jsp/wcm/browse-website.jsp - - - browseSandbox - /jsp/wcm/browse-sandbox.jsp - - - - updateAvmFile - /jsp/wcm/update-file.jsp - - - - showFileDetails - /jsp/wcm/file-details.jsp - - - showFolderDetails - /jsp/wcm/folder-details.jsp - - - - /jsp/wcm/* - - cancel - /jsp/wcm/browse-sandbox.jsp - - - - /jsp/* diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml index 5ac910e491..ca1eb93930 100644 --- a/source/web/WEB-INF/faces-config-repo.xml +++ b/source/web/WEB-INF/faces-config-repo.xml @@ -59,11 +59,6 @@ org.alfresco.web.ui.repo.component.UIContentSelector - - org.alfresco.faces.WebProjectFolderSelector - org.alfresco.web.ui.repo.component.UIWebProjectFolderSelector - - org.alfresco.faces.CategorySelector org.alfresco.web.ui.repo.component.UICategorySelector diff --git a/source/web/jsp/admin/node-browser.jsp b/source/web/jsp/admin/node-browser.jsp index c08f7ec4bd..bafba0758e 100644 --- a/source/web/jsp/admin/node-browser.jsp +++ b/source/web/jsp/admin/node-browser.jsp @@ -300,35 +300,7 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/source/web/jsp/content/create-content-wizard/create-form.jsp b/source/web/jsp/content/create-content-wizard/create-form.jsp deleted file mode 100644 index a99423b7ce..0000000000 --- a/source/web/jsp/content/create-content-wizard/create-form.jsp +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - diff --git a/source/web/jsp/dashboards/dashlets/mywebfiles-webscript.jsp b/source/web/jsp/dashboards/dashlets/mywebfiles-webscript.jsp deleted file mode 100644 index 595e279d9f..0000000000 --- a/source/web/jsp/dashboards/dashlets/mywebfiles-webscript.jsp +++ /dev/null @@ -1,21 +0,0 @@ -<%-- - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . ---%> -<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> - - \ No newline at end of file diff --git a/source/web/jsp/dashboards/dashlets/mywebforms-webscript.jsp b/source/web/jsp/dashboards/dashlets/mywebforms-webscript.jsp deleted file mode 100644 index 8e59c5b722..0000000000 --- a/source/web/jsp/dashboards/dashlets/mywebforms-webscript.jsp +++ /dev/null @@ -1,21 +0,0 @@ -<%-- - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . ---%> -<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> - - \ No newline at end of file diff --git a/source/web/scripts/ajax/tiny_mce_wcm_extensions.js b/source/web/scripts/ajax/tiny_mce_wcm_extensions.js deleted file mode 100644 index 13bb713493..0000000000 --- a/source/web/scripts/ajax/tiny_mce_wcm_extensions.js +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -//////////////////////////////////////////////////////////////////////////////// -// TinyMCE extensions for wcm -// -// This script provides callbacks used for overriding the default image and -// link dialogs for presenting a file picker to browse the repository. -// -// This script requires tiny_mce.js, and some alfresco.constants to be -// loaded in advance. -//////////////////////////////////////////////////////////////////////////////// -if (!alfresco.log) -{ - alfresco.log = alfresco.constants.DEBUG ? log : Class.empty; -} - -//MNT-2080: AVM_WEBAPP url rendering in the html view of TinyMCE editor -tinyMCE.avmWebappUrl = alfresco.constants.AVM_WEBAPP_URL; - -function alfresco_TinyMCE_urlconverter_callback(href, element, onsave) -{ - var result = null; - - alfresco.log("element = " + element); - - // NOTE: since upgrade of TinyMCE to v3 'onsave' now seems to always = true - - if (href) - { - if (href.startsWith(alfresco.constants.AVM_WEBAPP_PREFIX)) - { - //do nothin. AVM_WEBAPP_URL will be removed during saving image in _tinyMCE_blurHandler - result = href; - } - else if (href.startsWith("/")) - { - result = alfresco.constants.AVM_WEBAPP_URL + href; - } - else if (href.startsWith(document.location.href)) - { - result = href.substring(document.location.href.length); - } - else - { - result = href; - } - - // handle URL issues(see WCM-1134 and MNT-9749) - var server = document.location.protocol + "//" + document.location.host; - if (href.startsWith(server)) - { - result = href.substring(server.length); - } - } - - alfresco.log("alfresco_TinyMCE_urlconverter_callback('" + href + "', ... , " + onsave + ") = " + result); - - return result; -} - -function alfresco_TinyMCE_file_browser_callback(field_name, url, type, win) -{ - // remove url prefix ready for picker - if (url.startsWith(alfresco.constants.AVM_WEBAPP_URL)) - { - url = url.replace(alfresco.constants.AVM_WEBAPP_URL, ""); - } - else - { - url = url.replace(alfresco.constants.AVM_WEBAPP_CONTEXT, ""); - } - - //tinyMCE.loadCSS doesn't seem to work with plugins so add css manually - //tinyMCE.activeEditor.dom.loadCSS(alfresco.constants.WEBAPP_CONTEXT + "/css/xforms.css"); - var headEl = win.document.getElementsByTagName("head")[0]; - var cssEl = win.document.createElement('link'); - cssEl.type = 'text/css'; - cssEl.rel = 'stylesheet'; - cssEl.href = alfresco.constants.WEBAPP_CONTEXT + "/css/xforms.css"; - cssEl.media = 'screen'; - headEl.appendChild(cssEl); - - // ALF-872: - // Drop-down and list boxes do not have a z-index property, these are window level controls. - // When you want to show a div in a page that contains these controls, you will face an overlapping problem. - // This is a well-known problem with the IE 6 browser. - // To solve this we just hiding form's divs until FilePickerWidget is undestroyed. - - if (window.ie6) - { - var divs = win.document.getElementsByTagName("div"); - for (var i = 0; i < divs.length; i++) - { - divs[i].style.visibility = "hidden"; - } - } - - var div = win.document.createElement("div"); - div.style.width = "100%"; - div.style.height = "100%"; - div.style.backgroundColor = "white"; - div.style.position = "absolute"; - div.style.top = "0px"; - div.style.left = "0px"; - win.document.body.appendChild(div); - var pickerDiv = win.document.createElement("div"); - pickerDiv.style.height = "100%"; - pickerDiv.style.position = "relative"; - div.appendChild(pickerDiv); - var picker = new alfresco.FilePickerWidget("alfFilePicker", - pickerDiv, - url, - false, - function(picker) - { - win.document.getElementById(field_name).value = picker.getValue(); - picker.destroy(); - div.parentNode.removeChild(div); - }, - function() - { - picker.destroy(); - - // Please see comment above - if (window.ie6) - { - var divs = win.document.getElementsByTagName("div"); - for (var i = 0; i < divs.length; i++) - { - divs[i].style.visibility = "visible"; - } - } - - div.parentNode.removeChild(div); - }, - function(picker) - { - picker.node.style.height = div.offsetHeight + "px"; - picker.node.style.width = div.offsetWidth + "px"; - }, - type == "image" ? ["wcm:avmcontent"] : [], - type == "image" ? ["image/*"] : []); - picker._navigateToNode(url); -} diff --git a/source/web/scripts/ajax/xforms.js b/source/web/scripts/ajax/xforms.js deleted file mode 100644 index bc3082df3a..0000000000 --- a/source/web/scripts/ajax/xforms.js +++ /dev/null @@ -1,6174 +0,0 @@ -/* - * Copyright (C) 2005-2013 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -//////////////////////////////////////////////////////////////////////////////// -// XForms user interface -// -// This script communicates with the XFormBean to produce and manage an xform. -// -// This script requires mootools.js, dojo.js, tiny_mce.js, -// tiny_mce_wcm_extensions.js, and upload_helper.js to be loaded in advance. -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -// initialization -// -// Initiliaze dojo requirements, tinymce, and add a hook to load the xform. -//////////////////////////////////////////////////////////////////////////////// - -alfresco.ieVersion = getIEVersion(); -alfresco.ieEngine = alfresco.ieVersion == -1 ? -1 : getIEEngine(); - -djConfig.parseWidgets = false; -dojo.require("dojo.lfx.html"); -dojo.locale=alfresco.constants.LANGUAGE -alfresco.log = alfresco.constants.DEBUG ? log : Class.empty; - -//////////////////////////////////////////////////////////////////////////////// -// constants -// -// These are the client side declared constants. Others relating to namespaces -// and the webapp context path are expected to be provided by the jsp including -// this script. -//////////////////////////////////////////////////////////////////////////////// -alfresco.xforms.constants.XFORMS_ERROR_DIV_ID = "alfresco-xforms-error"; -alfresco.xforms.constants.JSF_ERROR_DIV_ID = "wizard-errors-wrapper"; - -alfresco.xforms.constants.EXPANDED_IMAGE = new Image(); -alfresco.xforms.constants.EXPANDED_IMAGE.src = - alfresco.constants.WEBAPP_CONTEXT + "/images/icons/expanded.gif"; - -alfresco.xforms.constants.COLLAPSED_IMAGE = new Image(); -alfresco.xforms.constants.COLLAPSED_IMAGE.src = - alfresco.constants.WEBAPP_CONTEXT + "/images/icons/collapsed.gif"; - -//////////////////////////////////////////////////////////////////////////////// -// widgets -//////////////////////////////////////////////////////////////////////////////// - -/** - * Base class for all xforms widgets. Each widget has a set of common properties, - * particularly a corresponding xforms node, a node within the browser DOM, - * a parent widget, and state variables. - */ -alfresco.xforms.Widget = new Class({ - initialize: function(xform, xformsNode, parentWidget, domNode) - { - this.xform = xform; - this.xformsNode = xformsNode; - this.parentWidget = parentWidget; - this.id = this.xformsNode.getAttribute("id"); - this._modified = false; - this._valid = true; - var b = this.xform.getBinding(this.xformsNode); - if (b) - { - alfresco.log("adding " + this.id + " to binding " + b.id); - b.widgets[this.id] = this; - } - else - { - alfresco.log("no binding found for " + this.id); - } - this.domNode = domNode || new Element("div"); - this.domNode.setAttribute("id", this.id + "-domNode"); - this.domNode.widget = this; - this.domNode.addClass("xformsItem"); - }, - - ///////////////////////////////////////////////////////////////// - // properties - ///////////////////////////////////////////////////////////////// - - /** A reference to the xform. */ - xform: null, - - /** The xformsNode managed by this widget. */ - xformsNode: null, - - /** The dom node containing the label for this widget. */ - labelNode: null, - - /** The parent widget, or null if this is the root widget. */ - parentWidget: null, - - /** The dom node for this widget. */ - domNode: null, - - /** The dom node containing this widget. */ - domContainer: null, - - /** The parent widget which is using this as a composite. */ - _compositeParent: null, - - ///////////////////////////////////////////////////////////////// - // - ///////////////////////////////////////////////////////////////// - - /** Sets the widget's modified state, as indicated by an XFormsEvent. */ - setModified: function(b) - { - this._modified = b; - this._updateDisplay(false); - if (this.isValidForSubmit()) - { - this.hideAlert(); - } - }, - - /** Sets the widget's valid state, as indicated by an XFormsEvent */ - setValid: function(b) - { - if (this._valid != b) - { - this._valid = b; - this._updateDisplay(false); - if (this.isValidForSubmit()) - { - this.hideAlert(); - } - else - { - this.showAlert(); - } - } - }, - - /** - * Heuristic approach to determine if the widget is valid for submit or - * if it's causing an xforms-error. - */ - isValidForSubmit: function() - { - if (typeof this._valid != "undefined" && !this._valid) - { - alfresco.log(this.id + " is invalid"); - return false; - } - if (!this._modified && - this.isRequired() && - this.getInitialValue() == null) - { - alfresco.log(this.id + " is unmodified and required and empty"); - return false; - } - if (this.isRequired() && this.getValue() == null) - { - alfresco.log(this.id + " is required and empty"); - return false; - } - alfresco.log(this.id + " is valid: {" + - "modified: " + this._modified + - ", required: " + this.isRequired() + - ", initial_value: " + this.getInitialValue() + - ", value: " + this.getValue() + "}"); - return true; - }, - - /** Returns the depth of the widget within the widget heirarchy. */ - getDepth: function() - { - var result = 1; - var p = this.parentWidget; - while (p) - { - result++; - p = p.parentWidget; - } - return result; - }, - - /** Returns the root group element */ - getViewRoot: function() - { - var p = this; - while (p.parentWidget) - { - p = p.parentWidget; - } - if (! (p instanceof alfresco.xforms.ViewRoot)) - { - throw new Error("expected root widget " + p + " to be a view root"); - } - return p; - }, - - /** Returns true if the parent is an ancestor of the given parent */ - isAncestorOf: function(parentWidget) - { - var p = this; - while (p.parentWidget) - { - if (p.parentWidget == parentWidget) - { - return true; - } - p = p.parentWidget; - } - return false; - }, - - /** Sets the widget's enabled state, as indicated by an XFormsEvent */ - setEnabled: function(enabled) - { - }, - - /** Returns the widget's enabled state */ - isEnabled: function() - { - return true; - }, - - /** Sets the widget's required state, as indicated by an XFormsEvent */ - setRequired: function(b) - { - if (this._required != b) - { - this._required = b; - this._updateDisplay(false); - } - }, - - /** Indicates if a value is required for the widget. */ - isRequired: function() - { - if (typeof this._required != "undefined") - { - return this._required; - } - var binding = this.xform.getBinding(this.xformsNode); - return binding && binding.isRequired(); - }, - - /** Sets the widget's readonly state, as indicated by an XFormsEvent */ - setReadonly: function(readonly) - { - this._readonly = readonly; - }, - - /** Indicates if the widget's value is readonly. */ - isReadonly: function() - { - if (typeof this._readonly != "undefined") - { - return this._readonly; - } - var binding = this.xform.getBinding(this.xformsNode); - return binding && binding.isReadonly(); - }, - - isVisible: function() - { - return true; - }, - - /** Commits the changed value to the server */ - _commitValueChange: function(value) - { - if (this.isRequired() && this.domNode.type == "select-one" && this.domNode.selectedIndex == 0) - { - this.xform.setXFormsValue(this.id, null); - this.setValue(null); - } - else - { - if (this._compositeParent) - { - this._compositeParent._commitValueChange(value); - } - else - { - this.xform.setXFormsValue(this.id, value || this.getValue()); - } - } - }, - - /** Sets the value contained by the widget */ - setValue: function(value, forceCommit) - { - if (forceCommit) - { - this.xform.setXFormsValue(this.id, value); - } - }, - - /** Returns the value contained by the widget, or null if none is set */ - getValue: function() - { - return this.widget.getValue().length != 0 ? this.widget.getValue() : null; - }, - - /** Sets the widget's initial value. */ - setInitialValue: function(value, forceCommit) - { - this._initialValue = - (typeof value == "string" && value.length == 0 ? null : value); - if (forceCommit) - { - this.xform.setXFormsValue(this.id, value); - } - }, - - /** - * Returns the widget's local value, either with a local variable, or by - * looking it up within the model section. - */ - getInitialValue: function() - { - if (typeof this._initialValue != "undefined") - { - return this._initialValue; - } - - var xpath = this._getXPathInInstanceDocument(); - var d = this.xformsNode.ownerDocument; - var contextNode = this.xform.getInstance(); - alfresco.log("locating " + xpath + " in " + contextNode.nodeName); - this._initialValue = _evaluateXPath("/" + xpath, - this.xform.getInstance(), - XPathResult.FIRST_ORDERED_NODE_TYPE); - if (!this._initialValue) - { - alfresco.log("unable to resolve xpath /" + xpath + " for " + this.id); - this._initialValue = null; - } - else - { - var getNodeText = function(xmlNode) - { - if(xmlNode) - { - if (xmlNode.firstChild) - { - return (typeof(xmlNode.textContent) != "undefined") ? xmlNode.textContent : xmlNode.firstChild.nodeValue; - } - else - { - return (typeof(xmlNode.textContent) != "undefined") ? xmlNode.textContent : xmlNode.nodeValue; - } - } - return ''; - } - - this._initialValue = (this._initialValue.nodeType == document.ELEMENT_NODE - ? (this._initialValue.firstChild - ? getNodeText(this._initialValue) - : null) - : getNodeText(this._initialValue)); - if (typeof this._initialValue == "string" && this._initialValue.length == 0) - { - this._initialValue = null; - } - alfresco.log("resolved xpath " + xpath + " to " + this._initialValue); - } - return this._initialValue; - }, - - /** Produces an xpath to the model node within the instance data document. */ - _getXPathInInstanceDocument: function() - { - var binding = this.xform.getBinding(this.xformsNode); - var xpath = ''; - var repeatIndices = this.getRepeatIndices(); - do - { - var s = binding.nodeset; - if (binding.nodeset == '.') - { - binding = binding.parentBinding; - } - if (binding.nodeset.match(/.+\[.+\]/)) - { - s = binding.nodeset.replace(/([^\[]+)\[.*/, "$1"); - s += '[' + (repeatIndices.shift().index) + ']'; - } - xpath = s + (xpath.length != 0 ? '/' + xpath : ""); - binding = binding.parentBinding; - } - while (binding); - return xpath; - }, - - /** Returns a child node by name within the xform. */ - _getChildXFormsNode: function(nodeName) - { - var x = _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - nodeName); - for (var i = 0; i < x.length; i++) - { - if (x[i].parentNode == this.xformsNode) - { - return x[i]; - } - } - return null; - }, - - /** Returns the widget's label. */ - getLabel: function() - { - var result = ""; - var node = this._getChildXFormsNode("label"); - - if (node && node.firstChild !== null) - { - result = node.firstChild.nodeValue; - } - - if (alfresco.constants.DEBUG) - { - result += " [" + this.id + "]"; - } - return result; - }, - - /** Returns the widget's alert text. */ - getAlert: function() - { - var result = ""; - var node = this._getChildXFormsNode("alert"); - - if (node && node.firstChild !== null) - { - result = node.firstChild.nodeValue; - } - - return result; - }, - - /** Returns the widget's alert text. */ - getHint: function() - { - var result = null; - var node = this._getChildXFormsNode("hint"); - - if (node && node.firstChild !== null) - { - result = node.firstChild.nodeValue; - } - - return result; - }, - - /** Makes the label red. */ - showAlert: function() - { - if (!this.labelNode.hasClass("xformsItemLabelSubmitError")) - { - this.labelNode.addClass("xformsItemLabelSubmitError"); - } - }, - - /** Restores the label to its original color. */ - hideAlert: function() - { - if (this.labelNode.hasClass("xformsItemLabelSubmitError")) - { - this.labelNode.removeClass("xformsItemLabelSubmitError"); - } - }, - - /** Returns the value of the appearance attribute for widget */ - getAppearance: function() - { - var result = (this.xformsNode.getAttribute("appearance") || - this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":appearance")); - return result == null || result.length == 0 ? null : result; - }, - - /** Updates the display of the widget. This is intended to be overridden. */ - _updateDisplay: function(recursively) - { - }, - - /** Destroy the widget and any resources no longer needed. */ - _destroy: function() - { - alfresco.log("destroying " + this.id); - }, - - /** - * Returns an array of RepeatIndexDatas corresponding to all enclosing repeats. - * The closest repeat will be at index 0. - */ - getRepeatIndices: function() - { - var result = []; - var w = this; - while (w.parentWidget) - { - if (w.parentWidget instanceof alfresco.xforms.Repeat) - { - result.push(new alfresco.xforms.RepeatIndexData(w.parentWidget, - w.parentWidget.getChildIndex(w) + 1)); - } - w = w.parentWidget; - } - return result; - }, - - /** - */ - getParentGroups: function(appearance) - { - var result = []; - var w = this; - while (w.parentWidget) - { - if (w.parentWidget instanceof alfresco.xforms.AbstractGroup) - { - if (appearance && w.parentWidget.getAppearance() == appearance) - { - result.push(w.parentWidget); - } - } - w = w.parentWidget; - } - return result; - } -}); - -//////////////////////////////////////////////////////////////////////////////// -// widgets for atomic types -//////////////////////////////////////////////////////////////////////////////// - -/** The file picker widget which handles xforms widget xf:upload. */ -alfresco.xforms.FilePicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget, params) - { - this.parent(xform, xformsNode, parentWidget); - this._selectableTypes = "selectable_types" in params ? params["selectable_types"].split(",") : null; - this._filterMimetypes = "filter_mimetypes" in params ? params["filter_mimetypes"].split(",") : []; - this._folderRestriction = "folder_restriction" in params ? params["folder_restriction"] : null; - this._configSearchName = "config_search_name" in params ? params["config_search_name"] : null; - this._layout = "layout" in params ? params["layout"] : null; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - this.domNode.addClass("xformsFilePicker"); - attach_point.appendChild(this.domNode); - //XXXarielb support readonly and disabled - var initialValue = this.getInitialValue(), - webFolder = alfresco.constants.AVM_WEBAPP_CONTEXT; - // ALF-12577 fix, remove the webfolder prefix added prevously (if needed) - if (initialValue && webFolder != "ROOT" && initialValue.match("^/" + webFolder + "/")) - { - initialValue = initialValue.replace(new RegExp("/" + webFolder), ""); - } - if (this._layout == "table") - { - this.widget = new alfresco.FilePickerWidgetTableLayout(this.id, - this.domNode, - initialValue, - false, - this._filePicker_changeHandler.bindAsEventListener(this), - null /* cancel is ignored */, - this._filePicker_resizeHandler.bindAsEventListener(this), - this._selectableTypes, - this._filterMimetypes, - this._folderRestriction, - this._configSearchName); - } - else - { - this.widget = new alfresco.FilePickerWidget(this.id, - this.domNode, - initialValue, - false, - this._filePicker_changeHandler.bindAsEventListener(this), - null /* cancel is ignored */, - this._filePicker_resizeHandler.bindAsEventListener(this), - this._selectableTypes, - this._filterMimetypes, - this._folderRestriction, - this._configSearchName); - } - this.widget.render(); - }, - - getValue: function() - { - return this.widget.getValue(); - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this.widget.setValue(value); - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _filePicker_changeHandler: function(fpw) - { - var value = this.getValue(); - // ALF-12557 fix, take into account current web folder - if (value != null && alfresco.constants.AVM_WEBAPP_CONTEXT != "ROOT") - { - value = "/" + alfresco.constants.AVM_WEBAPP_CONTEXT + value; - } - this._commitValueChange(value); - }, - - _filePicker_resizeHandler: function(fpw) - { - this.domContainer.style.height = - Math.max(fpw.node.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - } -}); - -/** The textfield widget which handle xforms widget xf:input with any string or numerical type */ -alfresco.xforms.TextField = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget, new Element("input", { type: "text" })); - this._maxLength = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxLength") - ? Number(this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxLength")) - : -1); - this._length = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":length") - ? Number(this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":length")) - : -1); - - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue() || ""; - attach_point.appendChild(this.domNode); - - this.widget = this.domNode; - this.widget.setAttribute("value", initial_value); - if (this._maxLength >= 0) - { - this.widget.setAttribute("maxlength", this._maxLength); - } - - if (this._length >= 0) - { - this.widget.style.maxWidth = "100%"; - this.widget.setAttribute("size", this._length); - } - else if (this.getAppearance() == "full") - { - var borderWidth = (this.widget.offsetWidth - this.widget.clientWidth); - var marginRight = 2; - this.widget.style.marginRight = marginRight + "px"; - if (attach_point.offsetWidth == 0) - { - this.widget.style.width = "100%"; - } - else - { - this.widget.style.width = (((attach_point.offsetWidth - borderWidth - marginRight) / attach_point.offsetWidth) * 100) + "%"; - } - this.widget.style.minWidth = "50px"; - } - - if (this.isReadonly()) - { - this.widget.setAttribute("readonly", true); - this.widget.setAttribute("disabled", true); - } - else - { - this.widget.onblur = this._widget_changeHandler.bindAsEventListener(this); - } - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this.widget.value = value; - } - }, - - getValue: function() - { - return (this.widget.value != null && this.widget.value.length == 0 - ? null - : this.widget.value); - }, - - isValidForSubmit: function() - { - if (this._maxLength > -1 && this.getValue() != null) - { - if (this.getValue().length > this._maxLength) - { - alfresco.log(this.id + " is invalid"); - return false; - } - } - return this.parent(); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _widget_changeHandler: function(event) - { - this._commitValueChange(); - } -}); - -/** The number range widget which handle xforms widget xf:range with any numerical type */ -alfresco.xforms.NumericalRange = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - dojo.require("dojo.widget.Slider"); - this._fractionDigits = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":fractionDigits") - ? Number(this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":fractionDigits")) - : -1); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue() || ""; - attach_point.appendChild(this.domNode); - var sliderDiv = document.createElement("div"); - sliderDiv.style.fontWeight = "bold"; - sliderDiv.style.marginBottom = "5px"; - this.domNode.appendChild(sliderDiv); - - var minimum = Number(this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":start")); - var maximum = Number(this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":end")); - var snapValues = 0; - if (this._fractionDigits == 0) - { - snapValues = maximum - minimum + 1; - } - sliderDiv.appendChild(document.createTextNode(minimum)); - - var sliderWidgetDiv = document.createElement("div"); - sliderDiv.appendChild(sliderWidgetDiv); - this.widget = dojo.widget.createWidget("SliderHorizontal", - { - initialValue: initial_value, - minimumX: minimum, - maximumX: maximum, - showButtons: false, - activeDrag: false, - snapValues: snapValues - }, - sliderWidgetDiv); - sliderDiv.appendChild(document.createTextNode(maximum)); - - this.currentValueDiv = document.createElement("div"); - this.domNode.appendChild(this.currentValueDiv); - this.currentValueDiv.appendChild(document.createTextNode("Value: " + initial_value)); - - dojo.event.connect(this.widget, - "onValueChanged", - this, - this._hSlider_valueChangedHandler); - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this.widget.setValue(value); - } - }, - - getValue: function() - { - return this.widget.getValue(); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _hSlider_valueChangedHandler: function(value) - { - if (this._fractionDigits >= 0) - { - value = Math.round(value * Math.pow(10, this._fractionDigits)) / Math.pow(10, this._fractionDigits); - } - this.currentValueDiv.replaceChild(document.createTextNode("Value: " + value), - this.currentValueDiv.firstChild); - if (!this.widget._isDragInProgress) - { - this._commitValueChange(value); - } - } -}); - -/** The text area widget handles xforms widget xf:textarea with appearance minimal */ -alfresco.xforms.PlainTextEditor = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget, new Element("textarea")); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - attach_point.appendChild(this.domNode); - this.domNode.addClass("xformsTextArea"); - var initialValue = this.getInitialValue() || ""; - this.widget = this.domNode; - this.widget.appendChild(document.createTextNode(initialValue)); - if (this.isReadonly()) - { - this.widget.setAttribute("readonly", true); - } - var borderWidth = (this.widget.offsetWidth - this.widget.clientWidth); - var marginRight = 2; - this.widget.style.marginRight = marginRight + "px"; - var ow = attach_point.offsetWidth; - this.widget.style.width = (((ow - borderWidth - marginRight) / ow) * 100) + "%"; - this.widget.onchange =this._textarea_changeHandler.bindAsEventListener(this); - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this.widget.value = value; - } - }, - - getValue: function() - { - return this.widget.value; - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _textarea_changeHandler: function(event) - { - this._commitValueChange(); - } -}); - -/** The textfield widget which handle xforms widget xf:textarea. with appearance full or compact */ -alfresco.xforms.RichTextEditor = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget, params) - { - this.parent(xform, xformsNode, parentWidget); - this._focused = false; - this._params = params; - this._oldValue = null; - this._created = false; - if (!document.getElementById('xformsRichTextEditorHoverLayer')) - { - alfresco.xforms.RichTextEditor.clickMask = new Element("div"); - alfresco.xforms.RichTextEditor.clickMask.addClass("xformsRichTextEditorHoverLayer"); - alfresco.xforms.RichTextEditor.clickMask.setText(alfresco.resources["click_to_edit"]); - alfresco.xforms.RichTextEditor.clickMask.id = 'xformsRichTextEditorHoverLayer'; - alfresco.xforms.RichTextEditor.clickMask.style.display='none'; - - alfresco.xforms.RichTextEditor.maskFocusHandler = - { - _focusHandlers: [], - _activatedRTE: null - }; - - document.body.appendChild(alfresco.xforms.RichTextEditor.clickMask); - } - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - _removeTinyMCE: function() - { - var value = this.getValue(); //tinyMCE.getContent(this.id); - if (value != this._oldValue) - { - alfresco.log("commitValueChange from _removeTinyMCE [" + value + "]"); - this._commitValueChange(value); - this._oldValue = value; - } - tinyMCE.get(this.widget.id).hide(); - this._focused = false; - - this._changeTinyMceHotKey((this.widget.id + "QKey"), ""); - this._changeTinyMceHotKey((this.widget.id + "ZKey"), ""); - }, - - _changeTinyMceHotKey: function(id, key) - { - if (null != id) - { - var keyLink = document.getElementById(id); - if (null != keyLink) - { - keyLink.accessKey = key; - } - } - }, - - _createTinyMCE:function() - { - for (var i in alfresco.constants.TINY_MCE_DEFAULT_SETTINGS) - { - if (!(i in this._params)) - { - this._params[i] = alfresco.constants.TINY_MCE_DEFAULT_SETTINGS[i]; - } - } - - // ALF-11956: Each RTE instance MUST BE configured with 'xformstabfocus' plugin to handle Shift + Tab keys - if (!this._params["plugins"] || (0 == this._params["plugins"].length)) - { - this._params["plugins"] = "xformstabfocus"; - } - else - { - if (-1 == this._params["plugins"].indexOf("xformstabfocus")) - { - this._params["plugins"] += ",xformstabfocus" - } - } - - this._params["height"] = (this._params["height"] > 0) ? parseInt(this._params["height"]) : this.widget.style.height; - this._params["width"] = (this._params["width"] > 0) ? parseInt(this._params["width"]) : this.widget.style.width; - - var t = this; - this._params["setup"] = function(ed) - { - ed.onLoadContent.add(function(ed) - { - var editorDocument = ed.getDoc(); - if (null == editorDocument.widget) - { - editorDocument.widget = t; - - var height = t._params["height"]; - - if(!isNaN(parseInt(height))) - { - var num = 1; - - while($(ed.id + '_toolbar' + num) != null) - { - height -= 26; - num++; - } - - $(ed.id + '_tbl').style.height = t._params["height"] + "px"; - $(ed.id + '_ifr').style.height = height + "px"; - } - - if ("false" == t._params["convert_fonts_to_spans"]) - { - ed.settings.convert_fonts_to_spans = false; - } - - ed.settings.auto_focus = t.widget.id; - - if (navigator.userAgent.contains("Safari")) - { - // ETHREEOH-2568 bug fixing - t.domNode.onmouseout = t._tinyMCE_blurHandler.bindAsEventListener(t); - } - else - { - tinymce.dom.Event.add(editorDocument, window.ie ? "mouseout" : "blur", t._tinyMCE_blurHandler); - } - - tinymce.dom.Event.add(editorDocument, "focus", t._tinyMCE_focusHandler); - } - }); - - // Fix for issue in browsers where content is not saved after fullscreen mode is toggled off - ed.onSetContent.add(function(ed, o) - { - //if fullscreen plugin is available and o has these values, then we're coming out of fullscreen mode only - if (o.set && (undefined === o.initial) && ("raw" === o.format) && (-1 != ed.settings.plugins.indexOf('fullscreen'))) - { - alfresco.xforms.RichTextEditor.currentInstance._commitValueChange(alfresco.xforms.RichTextEditor.currentInstance.getValue()); - } - }); - } - - tinyMCE.init(this._params); - tinyMCE.execCommand("mceAddControl", false, this.widget.id); - - this._created = true; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - this._focusLink = this._createFocusHandler(); - this._focusLink._index = alfresco.xforms.RichTextEditor.maskFocusHandler._focusHandlers.length; - attach_point.appendChild(this._focusLink); - attach_point.appendChild(this.domNode); - - alfresco.xforms.RichTextEditor.maskFocusHandler._focusHandlers.push(this._focusLink); - if (!alfresco.xforms.RichTextEditor.maskFocusHandler._applied) - { - alfresco.xforms.RichTextEditor.maskFocusHandler._applied = true; - this._focusLink.accessKey = "e"; - } - - this.domNode.addClass("xformsTextArea"); - if (this._params.height) - { - this.domNode.setStyle("height", parseInt(this._params["height"]) + "px"); - } - this.widget = new Element("div"); - this.domNode.appendChild(this.widget); - this.widget.addClass("xformsTextArea"); - - if (this._params["height"]) - { - this.widget.setStyle("height", parseInt(this._params["height"]) + "px"); - } - this.widget.style.border = "2px inset #f0f0f0"; - this.widget.style.marginRight = "2px"; - this.widget.style.overflow = "auto"; - this.widget.style.position = "absolute"; - - this._oldValue = this.getInitialValue() || ""; - this.widget.innerHTML = this._oldValue; - this.widget.id = this.id+'-editorWidget'; - $each(this.widget.getElementsByTagName("img"), - function(img, index) - { - - var href = img.getAttribute("src"); - //Fix for ETHREEOH-1211 - if (navigator.appName == "Microsoft Internet Explorer" || tinyMCE.isMSIE) - { - var server = document.location.protocol + "//" + document.location.host; - if (href.startsWith(server)) - { - href = href.substring(server.length); - } - } - - if (href && href.match("^/")) - { - var urlToReplace = alfresco.constants.AVM_WEBAPP_PREFIX; - if (alfresco.constants.AVM_WEBAPP_CONTEXT == "ROOT") - { - urlToReplace = alfresco.constants.AVM_WEBAPP_URL; - } - - img.setAttribute("src", urlToReplace + href); - } - }); - //ALF-6807 fix - $each(this.widget.getElementsByTagName("a"), - function(a, index) - { - var href = a.getAttribute("href"); - if (href && href.match("^/")) - { - var urlToReplace = alfresco.constants.AVM_WEBAPP_PREFIX; - if (alfresco.constants.AVM_WEBAPP_CONTEXT == "ROOT") - { - urlToReplace = alfresco.constants.AVM_WEBAPP_URL; - } - a.setAttribute("href", urlToReplace + href); - } - }); - if (!this.isReadonly()) - { - this.domNode.onmouseover = this._div_mouseoverHandler.bindAsEventListener(this); - } - }, - - _createFocusHandler: function() - { - var result = new Element("a"); - result.src = "#"; - result.addClass("xformsAccessibilityInvisibleText"); - result.style.border.width = 0; - result.style.padding = 0; - result.style.margin = 0; - result.tabIndex = 0; - result.innerHTML = '
' + this.getLabel() + '
'; - - var t = this; - result.onfocus = function() - { - alfresco.xforms.RichTextEditor.currentInstance = t; - alfresco.xforms.RichTextEditor.clickMask.onclick = t._hoverLayer_clickHandler.bindAsEventListener(t); - alfresco.xforms.RichTextEditor.clickMask.onmouseout = t._hoverLayer_mouseoutHandler.bindAsEventListener(t); - - alfresco.xforms.RichTextEditor.clickMask.onclick(); - return; - } - - return result; - }, - - setValue: function(value, forceCommit) - { - if (value != this._oldValue || forceCommit) - { - if (alfresco.xforms.RichTextEditor.currentInstance == this) - { - tinyMCE.selectedInstance = tinyMCE.get(this.id); - try - { - tinyMCE.activeEditor.setContent(value); - } - catch (e) - { - //XXXarielb figure this out - getting intermittent errors in IE. - alfresco.log(e); - } - } - else - { - this.widget.innerHTML = value; - } - } - this.parent(value, forceCommit); - }, - - getValue: function() - { - var result = (alfresco.xforms.RichTextEditor.currentInstance == this - ? tinyMCE.get(this.widget.id).getContent() - : this.widget.innerHTML); - - var urlToReplace = alfresco.constants.AVM_WEBAPP_PREFIX; - if (alfresco.constants.AVM_WEBAPP_CONTEXT == "ROOT") - { - urlToReplace = alfresco.constants.AVM_WEBAPP_URL; - } - result = result.replace(new RegExp(urlToReplace, "g"), ""); - - if (result.length == 0) - { - result = null; - } - return result; - }, - - setReadonly: function(readonly) - { - this.parent(readonly); - if (readonly && alfresco.xforms.RichTextEditor.currentInstance == this) - { - this._removeTinyMCE(); - } - }, - - _destroy: function() - { - this.parent(); - if (!this.isReadonly()) - { - alfresco.log("removing mce control " + this.id); - // tinyMCE.removeMCEControl(this.id); - tinyMCE.execCommand('mceRemoveControl', false, this.widget.id); - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _tinyMCE_blurHandler: function(event) - { - var widget; - if (event.type == "mouseout") - { - if (window.ie) - { - event.target = event.srcElement.ownerDocument; - widget = event.target.widget; - } - else - { - widget = this; - } - } - else - { - widget = event.target.widget; - } - - var value = widget.getValue(); - if (value != widget._oldValue) - { - alfresco.log("commitValueChange from _tinyMCE_blurHandler [" + value + "]"); - widget._commitValueChange(value); - widget._oldValue = value; - } - widget._focused = false; - }, - - _tinyMCE_focusHandler: function(event) - { - var widget = event.target.widget; - var repeatIndices = widget.getRepeatIndices(); - if (repeatIndices.length != 0 && !widget._focused) - { - var r = repeatIndices[repeatIndices.length - 1].repeat; - var p = widget; - while (p && p.parentWidget != r) - { - if (p.parentWidget instanceof alfresco.xforms.Repeat) - { - throw new Error("unexpected parent repeat " + p.parentWidget.id); - } - p = p.parentWidget; - } - if (!p) - { - throw new Error("unable to find parent repeat " + r.id + - " of " + widget.id); - } - repeatIndices[repeatIndices.length - 1].repeat.setFocusedChild(p); - } - widget._focused = true; - }, - - _div_mouseoverHandler: function(event) - { - var target = event.target || event.srcElement; - if (target) - { - if (target.className.indexOf('xformsTextArea')==-1) - { - do - { - target=target.parentNode; - } - while(target && target.className!='xformsTextArea'); - } - if (target && target.className=='xformsTextArea' && (alfresco.xforms.RichTextEditor.currentInstance != this)) - { - alfresco.xforms.RichTextEditor.clickMask.style.display='block'; - alfresco.xforms.RichTextEditor.clickMask.style.top=target.getTop()+'px'; - alfresco.xforms.RichTextEditor.clickMask.style.left=target.getLeft()+'px'; - alfresco.xforms.RichTextEditor.clickMask.style.width=target.offsetWidth+'px'; - alfresco.xforms.RichTextEditor.clickMask.style.height=target.offsetHeight+'px'; - alfresco.xforms.RichTextEditor.clickMask.style.lineHeight = alfresco.xforms.RichTextEditor.clickMask.offsetHeight + "px"; - alfresco.xforms.RichTextEditor.clickMask.setOpacity(.8); - - alfresco.xforms.RichTextEditor.clickMask.onclick = this._hoverLayer_clickHandler.bindAsEventListener(this); - alfresco.xforms.RichTextEditor.clickMask.onmouseout = this._hoverLayer_mouseoutHandler.bindAsEventListener(this); - - } - } - }, - - _hoverLayer_mouseoutHandler: function(event) - { - var relatedTarget = (event.relatedTarget) ? event.relatedTarget : event.toElement; - if (relatedTarget && relatedTarget.id!=alfresco.xforms.RichTextEditor.clickMask.id) - { - alfresco.xforms.RichTextEditor.clickMask.style.display='none' - document.body.appendChild(alfresco.xforms.RichTextEditor.clickMask); - } - }, - - _hoverLayer_clickHandler: function(event) - { - alfresco.xforms.RichTextEditor.clickMask.style.display='none' - - document.body.appendChild(alfresco.xforms.RichTextEditor.clickMask); - if (alfresco.xforms.RichTextEditor.currentInstance && document.getElementById(alfresco.xforms.RichTextEditor.currentInstance.domNode.id) - && alfresco.xforms.RichTextEditor.currentInstance != this) - { - alfresco.xforms.RichTextEditor.currentInstance._removeTinyMCE(); - } - - var handler = alfresco.xforms.RichTextEditor.maskFocusHandler; - - this._focusLink.accessKey = null; - this._focusLink.tabIndex = -1; - - if (null != handler._activatedRTE) - { - if (null != tinyMCE.get(handler._activatedRTE.widget.id)) - { - handler._activatedRTE._removeTinyMCE(); - } - - handler._activatedRTE._focusLink.tabIndex = 0; - } - - handler._activatedRTE = this; - - var index = (this._focusLink._index + 1) % handler._focusHandlers.length; - handler._focusHandlers[index].accessKey = "e"; - - this._changeTinyMceHotKey((this.widget.id + "QKey"), "q"); - this._changeTinyMceHotKey((this.widget.id + "ZKey"), "z"); - - if (this._created===false) - { - this._createTinyMCE(); - } - else - { - tinyMCE.get(this.widget.id).show(); - } - alfresco.xforms.RichTextEditor.currentInstance = this; - alfresco.xforms.RichTextEditor.clickMask.style.display='none' - document.body.appendChild(alfresco.xforms.RichTextEditor.clickMask); - - var editor = tinyMCE.get(this.widget.id); - if (null != editor) - { - editor.focus(); - } - } -}); - -/** The currently rendered rich text editor instance */ -alfresco.xforms.RichTextEditor.currentInstance = null; - -/** - * Reads the widget configuration to determine which plugins will - * be needed by tinymce. All plugins must be loaded into tinymce at - * startup so they must be accumulated in advance. - */ -alfresco.xforms.RichTextEditor.determineNecessaryTinyMCEPlugins = function(config) -{ - var result = []; - for (var widget in config) - { - for (var schemaType in config[widget]) - { - for (var appearance in config[widget][schemaType]) - { - if (config[widget][schemaType][appearance].className == "alfresco.xforms.RichTextEditor" && - config[widget][schemaType][appearance].params && - config[widget][schemaType][appearance].params.plugins) - { - alfresco.log("found plugins definition " + config[widget][schemaType][appearance].params.plugins + - " for text editor at config[" + widget + "][" + schemaType + "][" + appearance + "]"); - var plugins = config[widget][schemaType][appearance].params.plugins.split(","); - for (var p = 0; p < plugins.length; p++) - { - if (result.indexOf(plugins[p]) < 0) - { - result.push(plugins[p]); - } - } - } - } - } - } - return result.join(","); -} - -/** Base class for all select widgets. */ -alfresco.xforms.AbstractSelectWidget = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget, domNode) - { - this.parent(xform, xformsNode, parentWidget, domNode); - }, - - ///////////////////////////////////////////////////////////////// - // methods - ///////////////////////////////////////////////////////////////// - - /** - * Returns the possible item values for the select control as an array - * of anonymous objects with properties id, label, value, and valid. - */ - _getItemValues: function() - { - var binding = this.xform.getBinding(this.xformsNode); - var values = _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "item"); - var result = []; - for (var i = 0; i < values.length; i++) - { - var label = _getElementsByTagNameNS(values[i], - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "label")[0]; - label = label.firstChild === null ? "" : label.firstChild.nodeValue; - var value = _getElementsByTagNameNS(values[i], - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "value")[0]; - var valueText = value.firstChild === null ? "" : value.firstChild.nodeValue; - var itemId = value.getAttribute("id"); - var valid = true; - if (binding.constraint) - { - if (!window.ie) - { - valid = _evaluateXPath(binding.constraint, value, XPathResult.BOOLEAN_TYPE); - if (alfresco.constants.DEBUG) - { - alfresco.log("evaludated constraint " + binding.constraint + - " on " + value + " to " + valid); - } - } - else - { - valid = !(valueText == label && valueText.match(/^\[.+\]$/)); - } - } - result.push({ - id: itemId, - label: valid ? label : "", - value: valid ? valueText : "_invalid_value_", - valid: valid - }); - - if (alfresco.constants.DEBUG) - { - alfresco.log("values["+ i + "] = {id: " + result[i].id + - ",label: " + result[i].label + ",value: " + result[i].value + - ",valid: " + result[i].valid + "}"); - } - } - return result; - } -}); - -/** - * Handles xforms widget xf:select. Produces either a multiselect list or a set of - * checkboxes depending on the number of inputs. - */ -alfresco.xforms.CheckboxSelect = alfresco.xforms.AbstractSelectWidget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var values = this._getItemValues(); - var initial_value = this.getInitialValue(); - initial_value = initial_value ? initial_value.split(' ') : []; - this._selectedValues = []; - this.widget = this.domNode; - attach_point.appendChild(this.domNode); - for (var i = 0; i < values.length; i++) - { - var checkboxDiv = document.createElement("div"); - checkboxDiv.style.lineHeight = "16px"; - this.widget.appendChild(checkboxDiv); - - var checkbox = new Element("input"); - checkbox.setAttribute("id", this.id + "_" + i + "-widget"); - checkbox.setAttribute("name", this.id + "_" + i + "-widget"); - checkbox.setAttribute("type", "checkbox"); - checkbox.setAttribute("title", values[i].label); - checkbox.setAttribute("value", values[i].value); - checkboxDiv.appendChild(checkbox); - if (initial_value.indexOf(values[i].value) != -1) - { - this._selectedValues.push(values[i].value); - checkbox.checked = true; - } - - var label = new Element("label", {"for": checkbox.id}); - label.title = values[i].label; - label.appendChild(document.createTextNode(values[i].label)); - - checkboxDiv.appendChild(label); - checkbox.onclick = this._checkbox_clickHandler.bindAsEventListener(this); - } - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this._selectedValues = value.split(' '); - var checkboxes = this.widget.getElementsByTagName("input"); - for (var i = 0; i < checkboxes.length; i++) - { - checkboxes[i].checked = - this._selectedValues.indexOf(checkboxes[i].getAttribute("value")) != -1; - } - } - }, - - getValue: function() - { - return this._selectedValues.length == 0 ? null : this._selectedValues.join(" "); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _checkbox_clickHandler: function(event) - { - this._selectedValues = []; - var all_checkboxes = this.widget.getElementsByTagName("input"); - for (var i = 0; i < all_checkboxes.length; i++) - { - if (all_checkboxes[i] && all_checkboxes[i].checked) - { - this._selectedValues.push(all_checkboxes[i].getAttribute("value")); - } - } - this._commitValueChange(); - } -}); - -/** - * Handles xforms widget xf:select. Produces either a multiselect list or a set of - * checkboxes depending on the number of inputs. - */ -alfresco.xforms.ListSelect = alfresco.xforms.AbstractSelectWidget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - var select = new Element("select"); - var idPrefix = (null != parentWidget) ? (parentWidget.id) : (xformsNode.id); - select.setAttribute("id", idPrefix + "-select"); - this.parent(xform, xformsNode, parentWidget, select); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var values = this._getItemValues(); - var initial_value = this.getInitialValue(); - initial_value = initial_value ? initial_value.split(' ') : []; - this._selectedValues = []; - attach_point.appendChild(this.domNode); - this.widget = this.domNode; - this.widget.setAttribute("multiple", true); - attach_point.appendChild(this.widget); - for (var i = 0; i < values.length; i++) - { - var option = document.createElement("option"); - option.appendChild(document.createTextNode(values[i].label)); - option.setAttribute("value", values[i].value); - if (initial_value.indexOf(values[i].value) != -1) - { - this._selectedValues.push(values[i].value); - option.selected = true; - } - this.widget.appendChild(option); - } - this.widget.onblur = this._list_changeHandler.bindAsEventListener(this); - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this._selectedValues = value.split(' '); - var options = this.widget.getElementsByTagName("option"); - for (var i = 0; i < options.length; i++) - { - options[i].selected = - this._selectedValues.indexOf(options[i].getAttribute("value")) != -1; - } - } - }, - - getValue: function() - { - return this._selectedValues.length == 0 ? null : this._selectedValues.join(" "); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _list_changeHandler: function(event) - { - var target; - - if (window.ie) - { - target = window.event.srcElement; - } - else - { - target = event.target; - } - - this._selectedValues = []; - for (var i = 0; i < target.options.length; i++) - { - if (target.options[i].selected) - { - this._selectedValues.push(target.options[i].getAttribute("value")); - } - } - this._commitValueChange(); - } -}); - -/** - * Handles xforms widget xf:select1. Produces either a combobox or a set of - * radios depending on the number of inputs. - */ -alfresco.xforms.RadioSelect1 = alfresco.xforms.AbstractSelectWidget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var values = this._getItemValues(); - var initial_value = this.getInitialValue(); - this.widget = this.domNode; - attach_point.appendChild(this.domNode); - for (var i = 0; i < values.length; i++) - { - if (!values[i].valid) - { - // always skip the invalid values for radios - continue; - } - - var radio_div = document.createElement("div"); - radio_div.style.lineHeight = "16px"; - this.widget.appendChild(radio_div); - var radio = new Element("input"); - radio.setAttribute("id", this.id + "-" + i + "-widget"); - radio.setAttribute("name", this.id + "-widget"); - radio.setAttribute("type", "radio"); - radio.setAttribute("title", values[i].label); - radio_div.appendChild(radio); - - var label = new Element("label", {"for": radio.id}); - label.title = values[i].label; - label.appendChild(document.createTextNode(values[i].label)); - - radio_div.appendChild(label); - - radio.setAttribute("value", values[i].value); - if (values[i].value == initial_value) - { - this._selectedValue = initial_value; - radio.checked = true; - } - if (this.isReadonly()) - { - radio.setAttribute("disabled", true); - } - radio.onclick = this._radio_clickHandler.bindAsEventListener(this); - } - this.widget.style.height = this.widget.offsetHeight + "px"; - }, - - /** */ - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this._selectedValue = value; - var radios = this.widget.getElementsByTagName("input"); - for (var i = 0; i < radios.length; i++) - { - radios[i].checked = radios[i].getAttribute("value") == this._selectedValue; - } - } - }, - - getValue: function() - { - return this._selectedValue; - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _radio_clickHandler: function(event) - { - var target; - - if (window.ie) - { - target = window.event.srcElement; - } - else - { - target = event.target; - } - - if (!target.checked) - { - var all_radios = this.widget.getElementsByTagName("input"); - for (var i = 0; i < all_radios.length; i++) - { - if (all_radios[i].name == target.name) - { - all_radios[i].checked = target == all_radios[i]; - } - } - } - - this._selectedValue = target.value; - this._commitValueChange(); - } -}); - -/** - * Handles xforms widget xf:select1. Produces either a combobox or a set of - * radios depending on the number of inputs. - */ -alfresco.xforms.ComboboxSelect1 = alfresco.xforms.AbstractSelectWidget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - var select = new Element("select"); - var idPrefix = (null != parentWidget) ? (parentWidget.id) : (xformsNode.id); - select.setAttribute("id", idPrefix + "-select"); - this.parent(xform, xformsNode, parentWidget, select); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var values = this._getItemValues(); - var initial_value = this.getInitialValue(); - - if ((null == this.domNode) || ("SELECT" != this.domNode.tagName)) - { - this.domNode = new Element("select"); - this.domNode.id = attach_point.id + "-select2"; - } - - attach_point.appendChild(this.domNode); - this.widget = this.domNode; - for (var i = 0; i < values.length; i++) - { - if (!values[i].valid) - { - // always skip the invalid values for combos - continue; - } - var option = new Element("option"); - this.widget.appendChild(option); - option.appendChild(document.createTextNode(values[i].label)); - option.setAttribute("value", values[i].value); - if (values[i].value == initial_value) - { - this._selectedValue = initial_value; - option.selected = true; - } - - if (this.isReadonly()) - { - this.widget.setAttribute("disabled", true); - } - } - this.widget.onchange = this._combobox_changeHandler.bindAsEventListener(this); - }, - - /** */ - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this._selectedValue = value; - var options = this.widget.getElementsByTagName("option"); - for (var i = 0; i < options.length; i++) - { - options[i].selected = options[i].getAttribute("value") == this._selectedValue; - } - } - }, - - getValue: function() - { - return this._selectedValue; - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _combobox_changeHandler: function(event) - { - var target; - - if (window.ie) - { - target = window.event.srcElement; - } - else - { - target = event.target; - } - - this._selectedValue = target.options[target.selectedIndex].value; - this._commitValueChange(); - } -}); - -/** - * Handles xforms widget xf:select1 with a type of boolean. - */ -alfresco.xforms.Checkbox = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, - xformsNode, parentWidget, - new Element("input", { type: "checkbox" })); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue() == "true"; - attach_point.appendChild(this.domNode); - this.widget = this.domNode; - - if (initial_value) - { - this.widget.setAttribute("checked", true); - } - if (this.isReadonly()) - { - this.widget.setAttribute("disabled", true); - } - this.widget.onclick = this._checkbox_clickHandler.bindAsEventListener(this); - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - this.widget.checked = value == "true"; - } - }, - - getValue: function() - { - return this.widget.checked; - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _checkbox_clickHandler: function(event) - { - this._commitValueChange(); - } -}); - -//////////////////////////////////////////////////////////////////////////////// -// widgets for date types -//////////////////////////////////////////////////////////////////////////////// - -/** The date picker widget which handles xforms widget xf:input with type xf:date */ -alfresco.xforms.DatePicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - _createExternalLabels(_getDateTimePickerLabels(parentWidget.domNode)); - - this.parent(xform, xformsNode, parentWidget); - this._minInclusive = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":minInclusive") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":minInclusive") - : null); - this._maxInclusive = (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxInclusive") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":maxInclusive") - : null); - - dojo.require("dojo.date.format"); - // XXXarielb - change to a static - this._noValueSet = (alfresco.resources["eg"] + " " + - dojo.date.format(new Date(), - {datePattern: alfresco.xforms.constants.DATE_FORMAT, - selector: 'dateOnly'})); - }, - - _createPicker: function() - { - dojo.require("dojo.widget.DatePicker"); - var datePickerDiv = document.createElement("div"); - this.domNode.parentNode.appendChild(datePickerDiv); - - var dp_initial_value = this.getValue() || null; //dojo.date.toRfc3339(new Date()); - var datePickerProperties = { value: dp_initial_value }; - if (this._minInclusive) - { - datePickerProperties.startDate = this._minInclusive; - } - if (this._maxInclusive) - { - datePickerProperties.endDate = this._maxInclusive; - } - - this.widget.picker = dojo.widget.createWidget("DatePicker", - datePickerProperties, - datePickerDiv); - this.domContainer.style.height = - Math.max(this.widget.picker.domNode.offsetHeight + - this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - - dojo.event.connect(this.widget.picker, - "onValueChanged", - this, - this._datePicker_valueChangedHandler); - - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(true); - } - }, - - _destroyPicker: function() - { - if (this.widget.picker) - { - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(false); - } - - this.domNode.parentNode.removeChild(this.widget.picker.domNode); - this.widget.picker = null; - this.domContainer.style.height = - Math.max(this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-bottom").toInt() + - this.domNode.parentNode.getStyle("margin-top").toInt(), - 20) + "px"; - } - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue(); - attach_point.appendChild(this.domNode); - this.widget = new Element("input", { "id": this.id + "-widget", "type": "text", "aria-live": "polite"}); - - this.widget.setAttribute("alt", alfresco.resources["date_picker_title"]); - this.widget.setAttribute("title", alfresco.resources["date_picker_title"]); - - if (initial_value) - { - var jsDate = dojo.date.fromRfc3339(initial_value); - this.widget.setAttribute("value", - dojo.date.format(jsDate, - {datePattern: alfresco.xforms.constants.DATE_FORMAT, - selector: 'dateOnly'})); - } - else - { - this.widget.setAttribute("value", this._noValueSet); - this.widget.addClass("xformsGhostText"); - } - if (this.isReadonly()) - { - this.widget.setAttribute("disabled", true); - } - this.domNode.appendChild(this.widget); - - var expandoImage = new Element("img"); - expandoImage.id = this.domNode.id + "-expanded-image"; - expandoImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/action.gif"); - expandoImage.align = "absmiddle"; - expandoImage.style.margin = "0px 5px"; - expandoImage.tabIndex = 0; - - var imageTitle = this._buildExpandoImageTitle(false); - - expandoImage.setAttribute("alt", imageTitle); - expandoImage.setAttribute("title", alfresco.resources["date_picker_title"]); - - this.domNode.appendChild(expandoImage); - - if (!this.isReadonly()) - { - expandoImage.onclick = this._expando_clickHandler.bindAsEventListener(this); - expandoImage.onkeypress = this._expando_keypressHandler.bindAsEventListener(this); - - this.widget.onfocus = this._dateTextBox_focusHandler.bindAsEventListener(this); - this.widget.onchange = this._dateTextBox_changeHandler.bindAsEventListener(this); - } - }, - - _buildExpandoImageTitle: function(expanded) - { - var result = ""; - if ((null != this.labelNode) && (null != this.labelNode.getText()) && (this.labelNode.getText().length > 0)) - { - result = this.labelNode.getText() + " "; - } - result += alfresco.resources["date_picker_button_title"] + ". " + ((expanded) ? (alfresco.resources["state_expanded"]) : (alfresco.resources["state_not_expanded"])) + "."; - - return result; - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - var jsDate = dojo.date.fromRfc3339(value); - this.widget.value = dojo.date.format(jsDate, - {datePattern: alfresco.xforms.constants.DATE_FORMAT, - selector: 'dateOnly'}); - this.widget.removeClass("xformsGhostText"); - } - }, - - getValue: function() - { - if (this.widget.value == null || - this.widget.value.length == 0 || - this.widget.value == this._noValueSet) - { - return null; - } - else - { - var jsDate = dojo.date.parse(this.widget.value, - {datePattern: alfresco.xforms.constants.DATE_FORMAT, - selector: 'dateOnly'}); - return dojo.date.toRfc3339(jsDate, "dateOnly"); - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _dateTextBox_focusHandler: function(event) - { - this._destroyPicker(); - }, - - _dateTextBox_changeHandler: function(event) - { - this._commitValueChange(); - }, - - _datePicker_valueChangedHandler: function(date) - { - var rfcDate = dojo.date.toRfc3339(date, "dateOnly"); - this._destroyPicker(); - - var imageTitle = this._buildExpandoImageTitle(false); - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - expandoImage.alt = imageTitle; - - this.setValue(rfcDate); - this._commitValueChange(); - }, - - _expando_clickHandler: function() - { - if (this.widget.picker) - { - this._destroyPicker(); - } - else - { - this._createPicker(); - } - }, - - _expando_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._expando_clickHandler(); - } - } -}); - -/** The date picker widget which handles xforms widget xf:input with type xf:date */ -alfresco.xforms.TimePicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - _createExternalLabels(_getDateTimePickerLabels(parentWidget.domNode)); - - this.parent(xform, xformsNode, parentWidget); - dojo.require("dojo.date.format"); - this._noValueSet = (alfresco.resources["eg"] + " " + - dojo.date.format(new Date(), - {timePattern: alfresco.xforms.constants.TIME_FORMAT, - selector: "timeOnly"})); - this._xformsFormat = new Array("HH:mm:ss.S", "HH:mm:ss"); - }, - - _parseTime: function(timeValue) - { - var resDate = null; - for (i = 0; i < this._xformsFormat.length; i++) - { - resDate = dojo.date.parse(timeValue, {timePattern: this._xformsFormat[i], - selector: "timeOnly"}); - if (resDate != null) - { - return resDate; - } - } - return resDate; - }, - - /** */ - _createPicker: function() - { - dojo.require("dojo.widget.TimePicker"); - var timePickerDiv = document.createElement("div"); - this.domNode.appendChild(timePickerDiv); - var jsDate = (this.getValue() - ? this._parseTime(this.getValue()) - : new Date()); - this.widget.picker = dojo.widget.createWidget("TimePicker", - { - value: jsDate - }, - timePickerDiv); - this.widget.picker.anyTimeContainerNode.innerHTML = ""; - - // don't let it float - it screws up layout somehow - this.widget.picker.domNode.style.cssFloat = "none"; - this.domContainer.style.height = - Math.max(this.widget.picker.domNode.offsetHeight + - this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - dojo.event.connect(this.widget.picker, - "onValueChanged", - this, - this._timePicker_valueChangedHandler); - - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(true); - } - }, - - _destroyPicker: function() - { - if (this.widget.picker) - { - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(false); - } - - this.domNode.removeChild(this.widget.picker.domNode); - this.widget.picker = null; - this.domContainer.style.height = - Math.max(this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - } - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue(); - - attach_point.appendChild(this.domNode); - this.widget = new Element("input", { "id": this.id + "-widget", "type": "text", "aria-live": "polite" }); - - this.widget.setAttribute("alt", alfresco.resources["time_picker_title"]); - this.widget.setAttribute("title", alfresco.resources["time_picker_title"]); - - if (initial_value) - { - var jsDate = this._parseTime(initial_value); - this.widget.setAttribute("value", - dojo.date.format(jsDate, - {timePattern: alfresco.xforms.constants.TIME_FORMAT, - selector: "timeOnly"})); - } - else - { - this.widget.setAttribute("value", this._noValueSet); - this.widget.addClass("xformsGhostText"); - } - if (this.isReadonly()) - { - this.widget.setAttribute("disabled", true); - } - this.domNode.appendChild(this.widget); - - var expandoImage = new Element("img"); - expandoImage.id = this.domNode.id + "-expanded-image"; - expandoImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/action.gif"); - expandoImage.align = "absmiddle"; - expandoImage.style.margin = "0px 5px"; - expandoImage.tabIndex = 0; - - var imageTitle = this._buildExpandoImageTitle(false); - - expandoImage.setAttribute("alt", imageTitle); - expandoImage.setAttribute("title", alfresco.resources["time_picker_title"]); - - this.domNode.appendChild(expandoImage); - - if (!this.isReadonly()) - { - expandoImage.onclick = this._expando_clickHandler.bindAsEventListener(this); - expandoImage.onkeypress = this._expando_keypressHandler.bindAsEventListener(this); - - this.widget.onfocus = this._timeTextBox_focusHandler.bindAsEventListener(this); - this.widget.onchange = this._timeTextBox_changeHandler.bindAsEventListener(this); - } - }, - - _buildExpandoImageTitle: function(expanded) - { - var result = ""; - if ((null != this.labelNode) && (null != this.labelNode.getText()) && (this.labelNode.getText().length > 0)) - { - result = this.labelNode.getText() + " "; - } - result += alfresco.resources["time_picker_button_title"] + ". " + ((expanded) ? (alfresco.resources["state_expanded"]) : (alfresco.resources["state_not_expanded"])) + "."; - - return result; - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - var jsDate = this._parseTime(value); - this.widget.value = dojo.date.format(jsDate, - {timePattern: alfresco.xforms.constants.TIME_FORMAT, - selector: "timeOnly"}); - this.widget.removeClass("xformsghosttext"); - } - }, - - getValue: function() - { - if (this.widget.value == null || - this.widget.value.length == 0 || - this.widget.value == this._noValueSet) - { - return null; - } - else - { - var jsDate = dojo.date.parse(this.widget.value, - {timePattern: alfresco.xforms.constants.TIME_FORMAT, - selector: "timeOnly"}); - return dojo.date.format(jsDate, {timePattern: this._xformsFormat[0], selector: "timeOnly"}); - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _timeTextBox_focusHandler: function(event) - { - this._destroyPicker(); - }, - - _timeTextBox_changeHandler: function(event) - { - this._commitValueChange(); - }, - - _timePicker_valueChangedHandler: function(date) - { - var xfDate = dojo.date.format(date, {timePattern: this._xformsFormat[0], selector: "timeOnly"}); - this.setValue(xfDate); - this._commitValueChange(); - }, - - _expando_clickHandler: function() - { - if (this.widget.picker) - { - this._destroyPicker(); - } - else - { - this._createPicker(); - } - }, - - _expando_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._expando_clickHandler(); - } - } -}); - -/** The date time picker widget which handles xforms widget xf:input with type xf:datetime */ -alfresco.xforms.DateTimePicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - _createExternalLabels(_getDateTimePickerLabels(parentWidget.domNode)); - - this.parent(xform, xformsNode, parentWidget); - dojo.require("dojo.date.format"); - this._noValueSet = (alfresco.resources["eg"] + " " + - dojo.date.format(new Date(), - {datePattern: alfresco.xforms.constants.DATE_TIME_FORMAT, - selector: "dateOnly"})); - }, - - /** */ - _createPicker: function() - { - dojo.require("dojo.widget.DatePicker"); - dojo.require("dojo.widget.TimePicker"); - - this._pickerDiv = document.createElement("div"); - this._pickerDiv.style.position = "relative"; - this._pickerDiv.style.width = this.widget.offsetWidth + "px"; - this.domNode.appendChild(this._pickerDiv); - - var datePickerDiv = document.createElement("div"); - datePickerDiv.style.position = "absolute"; - datePickerDiv.style.left = "0px"; - datePickerDiv.style.top = "0px"; - this._pickerDiv.appendChild(datePickerDiv); - - var dp_initial_value = this.getValue() || dojo.date.toRfc3339(new Date()); - this.widget.datePicker = dojo.widget.createWidget("DatePicker", - { - value: dp_initial_value - }, - datePickerDiv); - var timePickerDiv = document.createElement("div"); - timePickerDiv.style.position = "absolute"; - timePickerDiv.style.right = "0px"; - timePickerDiv.style.top = "0px"; - this._pickerDiv.appendChild(timePickerDiv); - - var jsDate = this.getValue() ? dojo.date.fromRfc3339(this.getValue()) : new Date(); - this.widget.timePicker = dojo.widget.createWidget("TimePicker", - { - value: jsDate - }, - timePickerDiv); - this.widget.timePicker.anyTimeContainerNode.innerHTML = ""; - - // don't let it float - it screws up layout somehow - this.widget.timePicker.domNode.style.cssFloat = "none"; - this._pickerDiv.style.height = Math.max(this.widget.timePicker.domNode.offsetHeight, - this.widget.datePicker.domNode.offsetHeight) + "px"; - this.domContainer.style.height = - Math.max(this._pickerDiv.offsetHeight + - this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - dojo.event.connect(this.widget.datePicker, - "onValueChanged", - this, - this._datePicker_valueChangedHandler); - dojo.event.connect(this.widget.timePicker, - "onValueChanged", - this, - this._timePicker_valueChangedHandler); - - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(true); - } - }, - - _destroyPicker: function() - { - if (this._pickerDiv) - { - var expandoImage = document.getElementById(this.domNode.id + "-expanded-image"); - if (null != expandoImage) - { - expandoImage.alt = this._buildExpandoImageTitle(false); - } - - this.domNode.removeChild(this._pickerDiv); - this.widget.datePicker = null; - this.widget.timePicker = null; - this._pickerDiv = null; - this.domContainer.style.height = - Math.max(this.widget.offsetHeight + - this.domNode.parentNode.getStyle("margin-top").toInt() + - this.domNode.parentNode.getStyle("margin-bottom").toInt(), - 20) + "px"; - } - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - var initial_value = this.getInitialValue(); - - attach_point.appendChild(this.domNode); - this.widget = new Element("input", { "id": this.id + "-widget", "type": "text", "aria-live": "polite" }); - - this.widget.setAttribute("alt", alfresco.resources["date_time_picker_title"]); - this.widget.setAttribute("title", alfresco.resources["date_time_picker_title"]); - - if (initial_value) - { - var jsDate = dojo.date.fromRfc3339(initial_value); - this.widget.setAttribute("value", - dojo.date.format(jsDate, - {timePattern: alfresco.xforms.constants.DATE_TIME_FORMAT, - selector: "timeOnly"})); - } - else - { - this.widget.setAttribute("value", this._noValueSet); - this.widget.addClass("xformsGhostText"); - } - this.domNode.appendChild(this.widget); - this.widget.style.width = (3 * this.widget.offsetWidth) + "px"; - - var expandoImage = new Element("img"); - expandoImage.id = this.domNode.id + "-expanded-image"; - expandoImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/action.gif"); - expandoImage.align = "absmiddle"; - expandoImage.style.margin = "0px 5px"; - expandoImage.tabIndex = 0; - - var imageTitle = this._buildExpandoImageTitle(false); - - expandoImage.setAttribute("alt", imageTitle); - expandoImage.setAttribute("title", alfresco.resources["date_time_picker_title"]); - - this.domNode.appendChild(expandoImage); - - expandoImage.onclick = this._expando_clickHandler.bindAsEventListener(this); - expandoImage.onkeypress = this._expando_keypressHandler.bindAsEventListener(this); - - this.widget.onfocus = this._dateTimeTextBox_focusHandler.bindAsEventListener(this); - this.widget.onchange = this._dateTimeTextBox_changeHandler.bindAsEventListener(this); - }, - - _buildExpandoImageTitle: function(expanded) - { - var result = ""; - if ((null != this.labelNode) && (null != this.labelNode.getText()) && (this.labelNode.getText().length > 0)) - { - result = this.labelNode.getText() + " "; - } - result += alfresco.resources["date_time_picker_button_title"] + ". " + ((expanded) ? (alfresco.resources["state_expanded"]) : (alfresco.resources["state_not_expanded"])) + "."; - - return result; - }, - - setValue: function(value, forceCommit) - { - if (!this.widget) - { - this.setInitialValue(value, forceCommit); - } - else - { - this.parent(value, forceCommit); - var jsDate = dojo.date.fromRfc3339(value); - this.widget.value = dojo.date.format(jsDate, - {datePattern: alfresco.xforms.constants.DATE_TIME_FORMAT, - selector: "dateOnly"}); - this.widget.removeClass("xformsGhostText"); - } - }, - - getValue: function() - { - if (this.widget.value == null || - this.widget.value.length == 0 || - this.widget.value == this._noValueSet) - { - return null; - } - else - { - var jsDate = dojo.date.parse(this.widget.value, - {datePattern: alfresco.xforms.constants.DATE_TIME_FORMAT, - selector: "dateOnly"}); - return dojo.date.toRfc3339(jsDate); - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _dateTimeTextBox_focusHandler: function(event) - { - this._destroyPicker(); - }, - - _dateTimeTextBox_changeHandler: function(event) - { - this._commitValueChange(); - }, - - _timePicker_valueChangedHandler: function(date) - { - var value = this.getValue() ? dojo.date.fromRfc3339(this.getValue()) : new Date(); - value.setHours(date.getHours()); - value.setMinutes(date.getMinutes()); - value = dojo.date.toRfc3339(value); - this.setValue(value); - this._commitValueChange(); - }, - - _datePicker_valueChangedHandler: function(date) - { - var value = this.getValue() ? dojo.date.fromRfc3339(this.getValue()) : new Date(); - value.setYear(date.getYear()); - value.setMonth(date.getMonth()); - value.setDate(date.getDate()); - value = dojo.date.toRfc3339(value); - this.setValue(value); - this._commitValueChange(); - }, - - _expando_clickHandler: function() - { - if (this._pickerDiv) - { - this._destroyPicker(); - } - else - { - this._createPicker(); - } - }, - - _expando_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._expando_clickHandler(); - } - } -}); - -/** The year picker handles xforms widget xf:input with a gYear type */ -alfresco.xforms.YearPicker = alfresco.xforms.TextField.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - }, - - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - render: function(attach_point) - { - this.parent(attach_point); - this.widget.size = "4"; - this.widget.setAttribute("maxlength", "4"); - }, - - getInitialValue: function() - { - var result = this.parent(); - return result ? result.replace(/^0*([^0]+)$/, "$1") : result; - }, - - setValue: function(value, forceCommit) - { - this.parent((value - ? value.replace(/^0*([^0]+)$/, "$1") - : null), - forceCommit); - }, - - getValue: function() - { - var result = this.parent(); - return result ? dojo.string.padLeft(result, 4, "0") : null; - } -}); - -/** The day picker widget which handles xforms widget xf:input with type xf:gDay */ -alfresco.xforms.DayPicker = alfresco.xforms.ComboboxSelect1.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - _getItemValues: function() - { - var result = []; - result.push({id: "day_empty", label: "", value: "", valid: false}); - for (var i = 1; i <= 31; i++) - { - result.push({ - id: "day_" + i, - label: i, - value: "---" + (i < 10 ? "0" + i : i), - valid: true - }); - } - return result; - } -}); - -/** The month picker widget which handles xforms widget xf:input with type xf:gMonth */ -alfresco.xforms.MonthPicker = alfresco.xforms.ComboboxSelect1.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - dojo.require("dojo.date.format"); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - _getItemValues: function() - { - var result = []; - result.push({id: "month_empty", label: "", value: "", valid: false}); - for (var i = 0; i < 12; i++) - { - var d = new Date(); - d.setMonth(i); - result.push({ - id: "month_" + i, - label: dojo.date.getMonthName(d), - value: "--" + (i + 1 < 10 ? "0" + (i + 1) : i + 1), - valid: true - }); - } - return result; - } -}); - -/** The month day picker widget which handles xforms widget xf:input with type xf:gMonthDay */ -alfresco.xforms.MonthDayPicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - - var originalIds = {}; - originalIds.parentId = this._changeStructuralElementId(parentWidget, "-MDP-MonthCombobox", false); - originalIds.xformsId = this._changeStructuralElementId(xformsNode, "-MDP-MonthCombobox", false); - - this.monthPicker = new alfresco.xforms.MonthPicker(xform, xformsNode); - this.monthPicker._compositeParent = this; - - this._changeStructuralElementId(parentWidget, (originalIds.parentId + "-MDP-DayCombobox"), true); - this._changeStructuralElementId(xformsNode, (originalIds.xformsId + "-MDP-DayCombobox"), true); - this.dayPicker = new alfresco.xforms.DayPicker(xform, xformsNode); - this.dayPicker._compositeParent = this; - - this._changeStructuralElementId(parentWidget, originalIds.parentId, true); - this._changeStructuralElementId(xformsNode, originalIds.xformsId, true); - }, - - _changeStructuralElementId: function(element, newId, replace) - { - var result = null; - - if (null != element) - { - var id = ("undefined" != typeof(element.getAttribute)) ? (element.getAttribute("id")) : (element.id); - if (null == id) - { - id = "select-" + (new Date()).getTime(); - } - - result = id; - - newId = (replace) ? (newId) : (id + newId); - - if ("undefined" != typeof(element.setAttribute)) - { - element.setAttribute("id", newId); - } - else - { - element.id = newId; - } - } - - return result; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - render: function(attach_point) - { - this.setValue(this.getInitialValue()); - attach_point.appendChild(this.domNode); - this.dayPicker.render(this.domNode); - this.dayPicker.widget.style.marginRight = "10px"; - this.monthPicker.render(this.domNode); - this.domNode.style.width = this.monthPicker.domNode.offsetWidth + this.dayPicker.domNode.offsetWidth + 10 + "px"; - }, - - setValue: function(value) - { - this.monthPicker.setValue(value ? value.match(/^--[^-]+/)[0] : null); - this.dayPicker.setValue(value ? "---" + value.replace(/^--[^-]+-/, "") : null); - }, - - getValue: function() - { - // format is --MM-DD - var day = this.dayPicker.getValue(); - var month = this.monthPicker.getValue(); - return month && day ? day.replace(/^--/, month) : null; - } -}); - -/** The year month picker widget which handles xforms widget xf:input with type xf:gYearMonth */ -alfresco.xforms.YearMonthPicker = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - this.yearPicker = new alfresco.xforms.YearPicker(xform, xformsNode); - this.yearPicker._compositeParent = this; - - this.monthPicker = new alfresco.xforms.MonthPicker(xform, xformsNode); - this.monthPicker._compositeParent = this; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - render: function(attach_point) - { - this.setValue(this.getInitialValue()); - attach_point.appendChild(this.domNode); - this.monthPicker.render(this.domNode); - this.monthPicker.widget.style.marginRight = "10px"; - this.yearPicker.domNode.style.display = "inline"; - this.yearPicker.render(this.domNode); - this.domNode.style.width = this.yearPicker.domNode.offsetWidth + this.monthPicker.domNode.offsetWidth + 10 + "px"; - }, - - setValue: function(value) - { - this.monthPicker.setValue(value ? value.replace(/^[^-]+-/, "--") : null); - this.yearPicker.setValue(value ? value.match(/^[^-]+/)[0] : null); - }, - - getValue: function() - { - // format is CCYY-MM - var year = this.yearPicker.getValue(); - var month = this.monthPicker.getValue(); - return year && month ? month.replace(/^-/, year) : null; - } -}); - -//////////////////////////////////////////////////////////////////////////////// -// widgets for group types -//////////////////////////////////////////////////////////////////////////////// - -/** - * Handles xforms widget xf:group. A group renders and manages a set of children - * and provides a header for expanding and collapsing the group. A group header - * is shown for all group that don't have xf:appearance set to 'repeated' and - * that are not the root group. - */ -alfresco.xforms.AbstractGroup = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget, domNode) - { - this.parent(xform, xformsNode, parentWidget, domNode); - this._children = []; - this.domNode.removeClass("xformsItem"); - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - /** Returns the child at the specified index or null if the index is out of range. */ - getChildAt: function(index) - { - return index < this._children.length ? this._children[index] : null; - }, - - /** Returns the index of a particular child or -1 if the child was not found. */ - getChildIndex: function(child) - { - for (var i = 0; i < this._children.length; i++) - { - if (alfresco.constants.DEBUG) - { - alfresco.log(this.id + "[" + i + "]: " + - " is " + this._children[i].id + - " the same as " + child.id + "?"); - } - if (this._children[i] == child) - { - return i; - } - } - return -1; - }, - - /** Adds the child to end of the list of children. */ - addChild: function(child) - { - return this._insertChildAt(child, this._children.length); - }, - - _isIndented: function() - { - return !(this.parentWidget instanceof alfresco.xforms.ViewRoot) && this._children.length > 1; - }, - - /** Inserts a child at the specified position. */ - _insertChildAt: function(child, position, nodeName, attach_point) - { - alfresco.log(this.id + "._insertChildAt(" + child.id + ", " + position + ")"); - child.parentWidget = this; - - child.domContainer = new Element($pick(nodeName, "div")); - child.domContainer.setAttribute("id", child.id + "-domContainer"); - child.domContainer.addClass("xformsItemDOMContainer"); - - if (position == this._children.length) - { - $pick(attach_point, this.domNode.childContainerNode).appendChild(child.domContainer); - this._children.push(child); - } - else - { - $pick(attach_point, this.domNode.childContainerNode).insertBefore(child.domContainer, - this.getChildAt(position).domContainer); - this._children.splice(position, 0, child); - } - return child.domContainer; - }, - - /** Removes the child at the specified position. */ - _removeChildAt: function(position) - { - var child = this.getChildAt(position); - if (!child) - { - throw new Error("unable to find child at " + position); - } - - this._children.splice(position, 1); - child.domContainer.group = this; - var anim = dojo.lfx.html.fadeOut(child.domContainer, 500); - anim.onEnd = function() - { - child.domContainer.style.display = "none"; - child._destroy(); - - child.domContainer.remove(); - - child.domContainer.group._updateDisplay(false); - }; - anim.play(); - - this._childRemoved(child); - - return child; - }, - - /** Event handler for when a child has been added. */ - _childAdded: function(child) { }, - - /** Event handler for when a child has been removed. */ - _childRemoved: function(child) { }, - - /** Utility function to create the a label container */ - _createLabelContainer: function(child, nodeName, attach_point) - { - var labelNode = new Element($pick(nodeName, "div"), - { - id: child.id + "-label", - "class": "xformsItemLabelContainer" - }); - - var result = labelNode; - - var needsInLabel = (null != child.domNode) && (null != child.domNode.id) && !document.getElementById(child.domNode.id); - - if (needsInLabel) - { - var labelLabel = new Element("label", {"id": (child.id + "-accessibility-label")}); - - labelNode.appendChild(labelLabel); - - labelNode = labelLabel; - } - - var requiredImage = new Element("img", { "class": "xformsItemRequiredImage" }); - requiredImage.src = alfresco.xforms.AbstractGroup._requiredImage.src; - - labelNode.appendChild(requiredImage); - - if (!child.isRequired()) - { - requiredImage.style.visibility = "hidden"; - } - var label = child.getLabel(); - if (label) - { - child.labelNode = result; - - if (needsInLabel) - { - labelLabel.appendChild(document.createTextNode(label)); - } - else - { - child.labelNode.appendChild(document.createTextNode(label)); - } - } - var hint = child.getHint(); - if (hint) - { - result.setAttribute("title", hint); - requiredImage.setAttribute("alt", (alfresco.resources["mandatory_parameter"] + " " + hint)); - } - else - { - requiredImage.setAttribute("alt", alfresco.resources["mandatory_parameter"]); - } - result.style.width = "0px"; - $pick(attach_point, child.domContainer).appendChild(result); - result.style.width = result.scrollWidth + "px"; - - return result; - }, - - _findControlElement: function(element) - { - if ((("A" == element.tagName) || ("INPUT" == element.tagName) || ("SELECT" == element.tagName)) && ("hidden" != element.visibility) && ("none" != element.style.display) && (element.tabIndex >= 0)) - { - return element; - } - - if(null != element.children) - { - for (var i = 0; i < element.children.length; i++) - { - var result = this._findControlElement(element.children[i]); - - if(null != result) - { - return result; - } - } - } - - return null; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - isValidForSubmit: function() - { - return true; - }, - - /** Iterates all children a produces an array of widgets which are invalid for submit. */ - getWidgetsInvalidForSubmit: function() - { - var result = []; - for (var i = 0; i < this._children.length; i++) - { - var childNodeName = this._children[i].xformsNode.localName == null ? this._children[i].xformsNode.baseName : this._children[i].xformsNode.localName; - if ((this._children[i].domContainer.style.display != "none") || (childNodeName != "case")) - { - if (this._children[i] instanceof alfresco.xforms.AbstractGroup) - { - result = result.concat(this._children[i].getWidgetsInvalidForSubmit()); - } - else if (!this._children[i].isValidForSubmit()) - { - result.push(this._children[i]); - } - } - } - return result; - }, - - /** Recusively destroys all children. */ - _destroy: function() - { - this.parent(); - this._children.each(function(c) { c._destroy() }); - }, - - setReadonly: function(readonly) - { - this.parent(readonly); - this._children.each(function(c) { c.setReadonly(readonly); }); - }, - - render: function(attach_point) - { - this.domNode.widget = this; - return this.domNode; - }, - - _updateDisplay: function(recursively) - { - if (recursively) - { - this._children.each(function(c) { c._updateDisplay(recursively); }); - } - }, - - showAlert: function() - { - this._children.each(function(c) { c.showAlert(); }); - }, - - hideAlert: function() - { - this._children.each(function(c) { c.hideAlert(); }); - } -}); - -alfresco.xforms.AbstractGroup._requiredImage = new Image(); -alfresco.xforms.AbstractGroup._requiredImage.src = alfresco.constants.WEBAPP_CONTEXT + "/images/icons/required_field.gif"; - -/** - * Handles xforms widget xf:group. A group renders and manages a set of children - * and provides a header for expanding and collapsing the group. A group header - * is shown for all group that don't have xf:appearance set to 'repeated' and - * that are not the root group. - */ -alfresco.xforms.VGroup = alfresco.xforms.AbstractGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - _groupHeaderNode: null, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - /** Inserts a child at the specified position. */ - _insertChildAt: function(child, position) - { - if (!this.domNode.childContainerNode.parentNode) - { - // only add this to the dom once we're adding a child - this.domNode.appendChild(this.domNode.childContainerNode); - this._contentDivs = {}; - } - - child.domContainer = this.parent(child, position); - - if (this.parentWidget && this.parentWidget.domNode) - { - child.domContainer.style.top = this.parentWidget.domNode.style.bottom; - } - - function shouldInsertDivider(group, child, position) - { - if (group.getAppearance() != "full") - { - return false; - } - if (group instanceof alfresco.xforms.Repeat) - { - return false; - } - - if (!child.isVisible()) - { - return false; - } - if (group._children[position - 1] instanceof alfresco.xforms.AbstractGroup) - { - return true; - } - if (child instanceof alfresco.xforms.AbstractGroup) - { - for (var i = position - 1; i > 0; i--) - { - if (group._children[i].isVisible()) - { - return true; - } - } - } - return false; - } - - if (shouldInsertDivider(this, child, position)) - { - var divider = new Element("div", { "class": "xformsGroupDivider"}); - this.domNode.childContainerNode.insertBefore(divider, - child.domContainer); - } - - var contentDiv = new Element("div", { "id": child.id + "-content", "class": "xformsGroupItem", - "styles": {"left": (child instanceof alfresco.xforms.AbstractGroup - ? "0px" - : "30%")}}); - this._contentDivs[child.id] = contentDiv; - if (!(child instanceof alfresco.xforms.AbstractGroup)) - { - contentDiv.labelNode = this._createLabelContainer(child); - child.domContainer.appendChild(contentDiv.labelNode); - } - - child.domContainer.appendChild(contentDiv); - - var contentDivWidth = "100%"; - // the following does avoid devision by zero ... in contentDiv.offsetLeft / child.domContainer.offsetWidth - var ow = child.domContainer.offsetWidth; - if (!(child instanceof alfresco.xforms.AbstractGroup) && ow != 0) - { - contentDivWidth = ((1 - (contentDiv.offsetLeft / ow)) * 100) + "%"; - } - contentDiv.style.width = contentDivWidth; - child.render(contentDiv); - - var labelLabel = document.getElementById(child.id + "-accessibility-label"); - if (null != labelLabel) - { - var labelOwner = this._findControlElement(child.domNode); - labelLabel.setAttribute("for", ((null != labelOwner) ? (labelOwner) : (child.domNode)).id); - } - - var oh = contentDiv.offsetHeight; - var mt = contentDiv.getStyle("margin-top").toInt(); - if (!(child instanceof alfresco.xforms.AbstractGroup)) - { - child.domContainer.style.height = - Math.max(oh + - mt + - contentDiv.getStyle("margin-bottom").toInt(), - 20) + "px"; - } - - var ot = contentDiv.offsetTop; - alfresco.log(contentDiv.getAttribute("id") + " offsetTop is " + ot); - var top = Math.max(0, ot - mt); - contentDiv.style.top = "-" + top + "px"; - - if (contentDiv.labelNode) - { -// contentDiv.labelNode.style.top = (contentDiv.offsetTop + ((.5 * contentDiv.offsetHeight) - -// (.5 * contentDiv.labelNode.offsetHeight))) + "px"; - contentDiv.labelNode.style.position = "relative"; - contentDiv.labelNode.style.top = "0px"; - contentDiv.labelNode.style.height = oh + "px"; - contentDiv.labelNode.style.lineHeight = contentDiv.labelNode.style.height; - - } - contentDiv.widget = child; - - // Glen.Johnson@alfresco.com - for each child added to a VGroup, - // the method call below (commented out) recalculates the layout and - // updates the display for each of its siblings (already displayed - // above it). This is extremely expensive in terms of processing time. - // Commenting out the method call below drastically improves form rendering - // time for forms containing lots of VGroup widgets. - // See JIRA issue WCM-629 - // - // this._updateDisplay(false); - - this._childAdded(child); - return child.domContainer; - }, - - render: function(attach_point) - { - this.domNode.widget = this; - - if (this.getAppearance() == "full") - { - this.domNode.addClass("xformsGroup"); - this.domNode.style.position = "relative"; - this.domNode.style.marginRight = (this.domNode.getStyle("margin-left").toInt() / 3) + "px"; - if (window.ie) - { - this.domNode.style.width = "100%"; - } - else - { - var x = ((this.domNode.offsetWidth - this.domNode.clientWidth) + - this.domNode.getStyle("margin-left").toFloat() + - this.domNode.getStyle("margin-right").toFloat()); - this.domNode.style.width = (1 - (x / attach_point.offsetWidth)) * 100 + "%"; - } - - this._groupHeaderNode = new Element("div", - { - "id": this.id + "-groupHeaderNode", - "class": "xformsGroupHeader" - }); - this.domNode.appendChild(this._groupHeaderNode); - - var imageTitle = this._buildAccessibilityLabel(this.getLabel(), true); - - this.toggleExpandedImage = new Element("img", - { - "id": (this.id + "-exapndoImage"), - "align": "absmiddle", - "styles": { "margin": "0px 5px" }, - "src": alfresco.xforms.constants.EXPANDED_IMAGE.src, - "tabIndex": 0, - "alt": imageTitle, - "title": this.getLabel() - }); - this._configureHeadingElements(this._groupHeaderNode, this.toggleExpandedImage); - - this.toggleExpandedImage.onclick = this._toggleExpanded_clickHandler.bindAsEventListener(this); - this.toggleExpandedImage.onkeypress = this._toggleExpanded_keypressHandler.bindAsEventListener(this); - - this._groupHeaderNode.appendChild(document.createTextNode(this.getLabel())); - } - attach_point.appendChild(this.domNode); - this.domNode.childContainerNode = new Element("div", - { - "id": this.id + "-childContainerNode", - "styles": { "position": "relative", "width": "100%" } - }); - return this.domNode; - }, - - _buildAccessibilityLabel: function(label, expanded) - { - var result = ""; - if ((null != label) && (0 != label.length)) - { - result = label + ". "; - } - result += ((expanded) ? (alfresco.resources["state_expanded"]) : (alfresco.resources["state_not_expanded"])) + "."; - - return result; - }, - - _configureHeadingElements: function(parentWidget, child) - { - if (null != parentWidget) - { - var heading = new Element("span", - { - "id": (this.id + "-headingElement"), - "role": "heading", - "aria-level": "3", - "aria-labelledby": (this.id + "-exapndoImage") - }); - heading.appendChild(child); - parentWidget.appendChild(heading); - } - }, - - /** Indicates if the group is expanded. */ - isExpanded: function() - { - return (this.toggleExpandedImage.getAttribute("src") == - alfresco.xforms.constants.EXPANDED_IMAGE.src); - }, - - /** - * Sets the expanded state of the widget. If collapsed, everything but the header - * will be hidden. - */ - setExpanded: function(expanded) - { - if (expanded != this.isExpanded()) - { - this.toggleExpandedImage.src = - (expanded - ? alfresco.xforms.constants.EXPANDED_IMAGE.src - : alfresco.xforms.constants.COLLAPSED_IMAGE.src); - this.domNode.childContainerNode.style.display = expanded ? "block" : "none"; - - this.toggleExpandedImage.alt = this._buildAccessibilityLabel(this.getLabel(), this.isExpanded()); - this.toggleExpandedImage.title = this.toggleExpandedImage.alt; - } - }, - - _updateDisplay: function(recursively) - { - this.domNode.style.width = "100%"; - if (!window.ie) - { - if (this._isIndented()) - { - this.domNode.style.marginLeft = 10 + "px"; - this.domNode.style.marginRight = 5 + "px"; - - this.domNode.style.width = (((this.domNode.offsetWidth - 15) / this.domNode.offsetWidth) * 100) + "%"; - } -// var x = ((this.domNode.offsetWidth - this.domNode.clientWidth) + -// this.domNode.getStyle("margin-left").toFloat() + -// this.domNode.getStyle("margin-right").toFloat()); -// this.domNode.style.width = (1 - (x / this.domNode.parentNode.offsetWidth)) * 100 + "%"; - } - - for (var i = 0; i < this._children.length; i++) - { - if (!this._children[i].isVisible()) - { - continue; - } - var contentDiv = this._contentDivs[this._children[i].id]; - - contentDiv.style.position = "static"; - contentDiv.style.top = "0px"; -// contentDiv.style.left = "0px"; - - contentDiv.style.position = "relative"; - contentDiv.style.left = (this._children[i] instanceof alfresco.xforms.AbstractGroup - ? "0px" - : "30%"); - parentOffsetWidth = this._children[i].domContainer.parentNode.offsetWidth; - if (parentOffsetWidth != 0) - { - contentDiv.style.width = (this._children[i] instanceof alfresco.xforms.AbstractGroup - ? "100%" - : (1 - (contentDiv.offsetLeft / - parentOffsetWidth)) * 100 + "%"); - } - else - { - contentDiv.style.width = "100%"; - } - - if (contentDiv.labelNode) - { - contentDiv.labelNode.style.position = "relative"; - contentDiv.labelNode.style.top = "0px"; - contentDiv.labelNode.style.height = contentDiv.offsetHeight + "px"; - contentDiv.labelNode.style.lineHeight = contentDiv.labelNode.style.height; - contentDiv.labelNode.style.width = contentDiv.labelNode.scrollWidth + "px"; - } - - if (recursively) - { - this._children[i]._updateDisplay(recursively); - } - - if (!(this._children[i] instanceof alfresco.xforms.AbstractGroup)) - { - var contentDivMarginTop = contentDiv.getStyle("margin-top").toInt(); - this._children[i].domContainer.style.height = - Math.max(contentDiv.offsetHeight + - contentDivMarginTop + - contentDiv.getStyle("margin-bottom").toInt(), - 20) + "px"; - } - - contentDiv.style.top = "-" + Math.max(0, contentDiv.offsetTop - - (contentDivMarginTop == undefined ? contentDiv.getStyle("margin-top").toInt() : contentDivMarginTop)) + "px"; - - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _toggleExpanded_clickHandler: function(event) - { - this.setExpanded(!this.isExpanded()); - }, - - _toggleExpanded_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this.setExpanded(!this.isExpanded()); - } - } -}); - -/** - * Handles xforms widget xf:group. A group renders and manages a set of children - * and provides a header for expanding and collapsing the group. A group header - * is shown for all group that don't have xf:appearance set to 'repeated' and - * that are not the root group. - */ -alfresco.xforms.HGroup = alfresco.xforms.AbstractGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget, new Element("table")); - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - /** a map of child ids to contentDivs */ - _contentDivs: {}, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - _isIndented: function() - { - return false; - }, - - /** Inserts a child at the specified position. */ - _insertChildAt: function(child, position) - { - var labelCell = new Element("td"); - this.domNode.childContainerNode.appendChild(labelCell); - var labelNode = this._createLabelContainer(child, "div", labelCell); - labelNode.style.minWidth = "40px"; - labelCell.style.width = labelNode.style.width; - - child.parentWidget = this; - - var contentCell = new Element("td"); - this.domNode.childContainerNode.appendChild(contentCell); - child.domContainer = this.parent(child, position, null, contentCell); - child.domContainer.style.position = "static"; - - var contentDiv = new Element("div", { id: child.id + "-content", "class": "xformsGroupItem" }); - child.domContainer.appendChild(contentDiv); - this._contentDivs[child.id] = contentDiv; - - contentDiv.labelNode = labelNode; - child.render(contentDiv); - - var labelLabel = document.getElementById(child.id + "-accessibility-label"); - if (null != labelLabel) - { - var labelOwner = this._findControlElement(child.domNode); - labelLabel.setAttribute("for", ((null != labelOwner) ? (labelOwner) : (child.domNode)).id); - } - - var labelOwner = this._findControlElement(child.domNode); - var labelLabel = document.getElementById(child.id + "-accessibility-label"); - labelLabel.setAttribute("for", ((null != labelOwner) ? (labelOwner) : (child.domNode)).id); - - var w = child.domNode.style.width; - if (!w || w[w.length - 1] != "%") - { - contentCell.style.width = child.domNode.offsetWidth + "px"; - } - contentDiv.widget = child; - this._childAdded(child); - return child.domContainer; - }, - - render: function(attach_point) - { - this.domNode.widget = this; - this.domNode.style.width = "100%"; - attach_point.appendChild(this.domNode); - - var tbody = new Element("tbody"); - this.domNode.appendChild(tbody); - this.domNode.childContainerNode = new Element("tr"); - tbody.appendChild(this.domNode.childContainerNode); - return this.domNode; - }, - - _updateDisplay: function(recursively) - { - this._children.each(function(child, index) - { - if (recursively) - { - child._updateDisplay(recursively); - } - }.bind(this)); - } -}); - -alfresco.xforms.SwitchGroup = alfresco.xforms.VGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - if (this.getInitialValue()) - { - var initialValueTrigger = this._getCaseToggleTriggerByTypeValue(this.getInitialValue()); - this._selectedCaseId = initialValueTrigger.getActions()["toggle"].properties["case"]; - } - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - /** triggers that belong to the current switch */ - triggers: null, - - ///////////////////////////////////////////////////////////////// - // - ///////////////////////////////////////////////////////////////// - - _getCaseToggleTriggers: function() - { - var bw = this.xform.getBinding(this.xformsNode).widgets; - var result = []; - var cases = []; - for (var i in bw) - { - if (! (bw[i] instanceof alfresco.xforms.Trigger)) - { - continue; - } - - var action = bw[i].getActions()["toggle"]; - var currentCase = cases[action.properties["case"]] - if (action && (!currentCase || eval(bw[i].id.replace('C', '')) > eval(currentCase.id.replace('C', '')))) - { - cases[action.properties["case"]] = bw[i]; - } - } - for (var j in cases) - { - if (cases[j] instanceof alfresco.xforms.Trigger) - { - result.push(cases[j]); - } - } - return result; - }, - - _getCaseToggleTriggerByCaseId: function(caseId) - { - var bw = this.triggers; - for (var i in bw) - { - if (! (bw[i] instanceof alfresco.xforms.Trigger)) - { - continue; - } - - var action = bw[i].getActions()["toggle"]; - if (!action) - { - continue; - } - if (action.properties["case"] == caseId) - { - return bw[i]; - } - } - throw new Error("unable to find trigger " + type + - ", properties " + properties + - " for " + this.id); - - }, - - _getCaseToggleTriggerByTypeValue: function(typeValue) - { - var bw = this.xform.getBinding(this.xformsNode).widgets; - for (var i in bw) - { - if (! (bw[i] instanceof alfresco.xforms.Trigger)) - { - continue; - } - - var action = bw[i].getActions()["setvalue"]; - if (!action) - { - continue; - } - if (action.properties["value"] == typeValue) - { - return bw[i]; - } - } - throw new Error("unable to find toggle trigger for type value " + typeValue + - " for " + this.id); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - /** */ - _insertChildAt: function(child, position) - { - var childDomContainer = this.parent(child, position); - - if (child.id == this._selectedCaseId) - { - this._getCaseToggleTriggerByCaseId(this._selectedCaseId).fire(); - } - - return childDomContainer; - }, - - render: function(attach_point) - { - this.parent(attach_point); - var cases = this._getCaseToggleTriggers(); - this.triggers = cases; - var caseToggleSelect = new Element("select", - { - "id": this.id + "-toggle-select", - "styles": { "position": "absolute", "right": "0px", "top": "0px" } - }); - this._groupHeaderNode.appendChild(caseToggleSelect); - for (var i = 0; i < cases.length; i++) - { - var option = document.createElement("option"); - caseToggleSelect.appendChild(option); - var caseId = cases[i].getActions()["toggle"].properties["case"]; - option.setAttribute("value", caseId); - option.appendChild(document.createTextNode(cases[i].getLabel())); - if (cases[i].getActions()["toggle"].properties["case"] == this._selectedCaseId) - { - option.selected = true; - } - } - caseToggleSelect.onchange = this._caseToggleSelect_changeHandler.bindAsEventListener(this); - }, - - ///////////////////////////////////////////////////////////////// - // XForms event handlers - ///////////////////////////////////////////////////////////////// - - /** */ - handleSwitchToggled: function(selectedCaseId, deselectedCaseId) - { - alfresco.log(this.id + ".handleSwitchToggled(" + selectedCaseId + - ", " + deselectedCaseId + ")"); - this._selectedCaseId = selectedCaseId; - for (var i = 0; i < this._children.length; i++) - { - if (this._children[i].id == selectedCaseId) - { - this._children[i].domContainer.style.display = "block"; - } - else if (this._children[i].id == deselectedCaseId) - { - this._children[i].domContainer.style.display = "none"; - } - } - this._updateDisplay(true); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _caseToggleSelect_changeHandler: function(event) - { - if (event.stopPropagation) - { - event.stopPropagation(); - var t = this._getCaseToggleTriggerByCaseId(event.target.value); - t.fire(); - } - else if (window.event) - { - window.event.cancelBubble = true; - var t = this._getCaseToggleTriggerByCaseId(window.event.srcElement.value); - t.fire(); - } - } -}); - -/** */ -alfresco.xforms.CaseGroup = alfresco.xforms.VGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - } -}); - -/** - * Handles xforms widget xf:group for the root group. Does some special rendering - * to present a title rather than a group header. - */ -alfresco.xforms.ViewRoot = alfresco.xforms.VGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - this.focusedRepeat = null; - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - _isIndented: function() - { - return false; - }, - - render: function(attach_point) - { - this.domNode.widget = this; - this.domNode.style.position = "relative"; - this.domNode.style.width = "100%"; - this.domNode.addClass("xformsViewRoot"); - - this._groupHeaderNode = new Element("div", - { - "id": this.id + "-groupHeaderNode", - "class": "xformsViewRootHeader" - }); - this.domNode.appendChild(this._groupHeaderNode); - - var icon = document.createElement("img"); - this._groupHeaderNode.appendChild(icon); - icon.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/file_large.gif"); - icon.align = "absmiddle"; - icon.style.margin = "0px 5px"; - this._groupHeaderNode.appendChild(document.createTextNode(this.getLabel())); - attach_point.appendChild(this.domNode); - - this.domNode.childContainerNode = new Element("div", - { - "id": this.id + "-childContainerNode", - "styles": {"position": "relative", "width": "100%"} - }); - return this.domNode; - }, - - /** */ - getLabel: function() - { - return this.parent() + " " + alfresco.xforms.constants.FORM_INSTANCE_DATA_NAME; - } -}); - -/** A struct for providing repeat index data. */ -alfresco.xforms.RepeatIndexData = function(repeat, index) -{ - this.repeat = repeat; - this.index = index; - this.toString = function() - { - return "{" + this.repeat.id + " = " + this.index + "}"; - }; -} - -/** - * Handles xforms widget xf:repeat. - */ -alfresco.xforms.Repeat = alfresco.xforms.VGroup.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - this._repeatControls = []; - this._selectedIndex = -1; - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - /** - * Indicates whether or not this repeat can insert more children based - * on the alf:maximum restriction. - */ - isInsertRepeatItemEnabled: function() - { - var maximum = this.xform.getBinding(this.xformsNode).maximum; - maximum = isNaN(maximum) ? Number.MAX_VALUE : maximum; - return this._children.length < maximum; - }, - - /** - * Indicates whether or not this repeat can removed children based - * on the alf:minimum restriction. - */ - isRemoveRepeatItemEnabled: function() - { - var minimum = this.xform.getBinding(this.xformsNode).minimum; - minimum = isNaN(minimum) ? this.isRequired() ? 1 : 0 : minimum; - return this._children.length > minimum; - }, - - /** - * Returns the currently selected index or -1 if this repeat has no repeat items. - */ - getSelectedIndex: function() - { - this._selectedIndex = Math.min(this._children.length, this._selectedIndex); - if (this._children.length == 0) - { - this._selectedIndex = -1; - } - return this._selectedIndex; - }, - - /** - * Helper function to locate the appropriate repeat item trigger for this repeat. - * This is done by locating all related widgets via binding, and selecting the - * Trigger who's action type is the type provided and where the properties - * provided are the same for that action. This approach is used rather than simply - * looking up the trigger by id since the id isn't known for nested repeats as - * chiba modifies them. - */ - _getRepeatItemTrigger: function(type, properties) - { - var bw = this.xform.getBinding(this.xformsNode).widgets; - for (var i in bw) - { - if (! (bw[i] instanceof alfresco.xforms.Trigger)) - { - continue; - } - - var action = bw[i].getActions()[type]; - if (!action) - { - continue; - } - - var propertiesEqual = true; - for (var p in properties) - { - if (!(p in action.properties) || - action.properties[p] != properties[p]) - { - propertiesEqual = false; - break; - } - } - if (propertiesEqual) - { - return bw[i]; - } - } - throw new Error("unable to find trigger " + type + - ", properties " + properties + - " for " + this.id); - - }, - - /** - * Sets the currently selected child by calliing XFormsBean.setRepeatIndeces. - * If the child provided is null, the index is set to 0. - */ - setFocusedChild: function(child) - { - var oldFocusedRepeat = this.getViewRoot().focusedRepeat; - this.getViewRoot().focusedRepeat = this; - if (oldFocusedRepeat != null && oldFocusedRepeat != this) - { - if (!oldFocusedRepeat.isAncestorOf(this)) - { - oldFocusedRepeat._selectedIndex = -1; - } - oldFocusedRepeat._updateDisplay(false); - } - - var repeatIndices = this.getRepeatIndices(); - if (!child) - { - repeatIndices.push(new alfresco.xforms.RepeatIndexData(this, 0)); - this.xform.setRepeatIndeces(repeatIndices); - } - else - { - var index = this.getChildIndex(child); - if (index < 0) - { - throw new Error("unable to find child " + child.id + " in " + this.id); - } - - repeatIndices.push(new alfresco.xforms.RepeatIndexData(this, index + 1)); - // xforms repeat indexes are 1-based - this.xform.setRepeatIndeces(repeatIndices); - } - }, - - /** - * Calls swapRepeatItems on the XFormsBean which will produce the event log - * to insert and remove the appropriate repeat items. - */ - _swapChildren: function(fromIndex, toIndex) - { - alfresco.log(this.id + ".swapChildren(" + fromIndex + ", " + toIndex + ")"); - var fromChild = this.getChildAt(fromIndex); - var toChild = this.getChildAt(toIndex); - this.xform.swapRepeatItems(fromChild, toChild); - - var anim = dojo.lfx.html.fadeOut(fromChild.domContainer, 500); - anim.onEnd = function() - { - fromChild.domContainer.style.display = "none"; - }; - anim.play(); - }, - - /** - * Updates the repeat controls by changing the opacity on the image based on - * whether or not the action is enabled. - */ - _updateRepeatControls: function() - { - var insertEnabled = this.isInsertRepeatItemEnabled(); - var removeEnabled = this.isRemoveRepeatItemEnabled(); - - var label = this.getLabel(); - label = (null != label) ? (label + " ") : (""); - - for (var i = 0; i < this._repeatControls.length; i++) - { - var labelPrefix = label + alfresco.resources["item_title"] + " " + (i + 1) + ". " - - this._repeatControls[i].moveRepeatItemUpImage.setOpacity(i == 0 ? .3 : 1); - this._repeatControls[i].moveRepeatItemUpImage.tabIndex = (0 == i) ? (-1) : (0); - this._repeatControls[i].moveRepeatItemUpImage.alt = labelPrefix + alfresco.resources["move_up_title"]; - - this._repeatControls[i].moveRepeatItemDownImage.setOpacity(i == this._repeatControls.length - 1 ? .3 : 1); - this._repeatControls[i].moveRepeatItemDownImage.tabIndex = (i == (this._repeatControls.length - 1)) ? (-1) : (0); - this._repeatControls[i].moveRepeatItemDownImage.alt = labelPrefix + alfresco.resources["move_down_title"]; - - this._repeatControls[i].insertRepeatItemImage.setOpacity(insertEnabled ? 1 : .3); - this._repeatControls[i].insertRepeatItemImage.tabIndex = (insertEnabled) ? (0) : (-1); - this._repeatControls[i].insertRepeatItemImage.alt = labelPrefix + alfresco.resources["add_item_title"]; - - this._repeatControls[i].removeRepeatItemImage.setOpacity(removeEnabled ? 1 : .3); - this._repeatControls[i].removeRepeatItemImage.tabIndex = (removeEnabled) ? (0) : (-1); - this._repeatControls[i].removeRepeatItemImage.alt = labelPrefix + alfresco.resources["remove_item_title"]; - } - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods & properties - ///////////////////////////////////////////////////////////////// - - /** When debugging, insert the id into the label. */ - getLabel: function() - { - var label = this.parentWidget.getLabel(); - if (alfresco.constants.DEBUG) - { - label += "[" + this.id + "]"; - } - return label; - }, - - /** Overrides _insertChildAt in Group to provide repeater controls. */ - _insertChildAt: function(child, position) - { - this._repeatControls.splice(position, 0, new Element("div")); - var label = this.parentWidget.getLabel(); // this.getLabel() breaks dynamic dispatching mechanism of mootools for _insertChildAt()! - var labelPrefix = ((null != label) ? (label + " ") : ("")) + "Item " + (position + 1) + ". "; - var images = - [ - { name: "insertRepeatItemImage", src: "plus", action: this._insertRepeatItemAfter_handler, accessibilityAction: this._insertRepeatItemAfter_keypressHandler, title: alfresco.resources["add_item_title"] }, - { name: "moveRepeatItemUpImage", src: "arrow_up", action: this._moveRepeatItemUp_handler, accessibilityAction: this._moveRepeatItemUp_keypressHandler, title: alfresco.resources["move_up_title"] }, - { name: "moveRepeatItemDownImage", src: "arrow_down", action: this._moveRepeatItemDown_handler, accessibilityAction: this._moveRepeatItemDown_keypressHandler, title: alfresco.resources["move_down_title"] }, - { name: "removeRepeatItemImage", src: "minus", action: this._removeRepeatItem_handler, accessibilityAction: this._removeRepeatItem_keypressHandler, title: alfresco.resources["remove_item_title"] } - ]; - var _repeatControlsWidth = 0; - for (var i = 0; i < images.length; i++) - { - var img = new Element("img", - { - "src": (alfresco.constants.WEBAPP_CONTEXT + "/images/icons/" + - images[i].src + ".gif"), - "styles": { "width" : "16px", "height" : "16px" }, - "alt": (labelPrefix + images[i].title), - "title": images[i].title - }); - this._repeatControls[position][images[i].name] = img; - var imgMargin = [2, 5, 2, (i == 0 ? 5 : 0) ]; - img.style.margin = imgMargin.join("px ") + "px"; - _repeatControlsWidth += (parseInt(img.style.width) + imgMargin[1] + imgMargin[3]); - this._repeatControls[position].appendChild(img); - img.onclick = images[i].action.bindAsEventListener(this); - img.onkeypress = images[i].accessibilityAction.bindAsEventListener(this); - } - - var result = this.parent(child, position); - child.repeat = this; - result.onclick = function(event) - { - event = new Event(event); - child.repeat.setFocusedChild(child); - event.stopPropagation(); - }; - result.addClass("xformsRepeatItem"); - if (result.nextSibling) - { - result.parentNode.insertBefore(this._repeatControls[position], - result.nextSibling); - } - else - { - result.parentNode.appendChild(this._repeatControls[position]); - } - - this._repeatControls[position].addClass("xformsRepeatControls"); - this._repeatControls[position].style.width = _repeatControlsWidth + "px"; - this._repeatControls[position].style.backgroundColor = result.getStyle("background-color"); - this._repeatControls[position].style.overflow = "hidden"; - - result.style.paddingBottom = (.5 * this._repeatControls[position].offsetHeight) + "px"; - - // this._repeatControls[position].style.top = -((.5 * this._repeatControls[position].offsetHeight) + - // result.getStyle("margin-bottom").toInt() + - // result.getStyle("border-bottom").toInt()) + "px"; - // may need to use this for centering repeat controls in quirks mode on IE - // this._repeatControls[position].style.margin = "0px " + Math.floor(100 * ((result.offsetWidth - - // this._repeatControls[position].offsetWidth) / - // (result.offsetWidth * 2)))+ "%"; - return result; - }, - - /** - * Overrides _removeChildAt in Group to remove the repeat controls associated with - * the repeat item. - */ - _removeChildAt: function(position) - { - this._repeatControls[position].style.display = "none"; - this._repeatControls[position].remove(); - this._repeatControls.splice(position, 1); - return this.parent(position); - }, - - /** Disables insert before. */ - _childAdded: function(child) - { - this.headerInsertRepeatItemImage.setOpacity(.3); - this.headerInsertRepeatItemImage.tabIndex = -1; - this._updateRepeatControls(); - }, - - /** Reenables insert before if there are no children left. */ - _childRemoved: function(child) - { - if (this._children.length == 0) - { - this.headerInsertRepeatItemImage.setOpacity(1); - this.headerInsertRepeatItemImage.tabIndex = 0; - } - this._updateRepeatControls(); - }, - - _isIndented: function() - { - return false; - }, - - render: function(attach_point) - { - this.domNode = this.parent(attach_point); - this.domNode.addClass("xformsRepeat"); - - // clear the border bottom for the group header since we'll be getting it - // from the repeat item border - this._groupHeaderNode.style.borderBottomWidth = "0px"; - - this._groupHeaderNode.repeat = this; - this._groupHeaderNode.onclick = function(event) - { - if ((typeof(event) != 'undefined') && (typeof(event.target) != 'undefined') && (event.target == event.currentTarget)) - { - event.currentTarget.repeat.setFocusedChild(null); - } - }; - - var imageTitle = ""; - if ((null != this.getLabel()) && (this.getLabel().length > 0)) - { - imageTitle = this.getLabel() + " "; - } - imageTitle += alfresco.resources["add_item_title"]; - - this.headerInsertRepeatItemImage = - new Element("img", - { - "align": "absmiddle", - "src": alfresco.constants.WEBAPP_CONTEXT + "/images/icons/plus.gif", - "styles": { "margin-left": "5px", "width": "16px", "height": "16px" }, - "title": alfresco.resources["add_item_title"], - "tabIndex": ((this.isInsertRepeatItemEnabled()) ? (0) : (-1)), - "alt": imageTitle - }); - - this.headerInsertRepeatItemImage.repeat = this; - this._groupHeaderNode.appendChild(this.headerInsertRepeatItemImage); - - this.headerInsertRepeatItemImage.onclick = - this._headerInsertRepeatItemBefore_handler.bindAsEventListener(this); - this.headerInsertRepeatItemImage.onkeypress = this._headerInsertRepeatItemBefore_keypressHandler.bindAsEventListener(this); - - return this.domNode; - }, - - _updateDisplay: function(recursively) - { - var recurseOnChildren = alfresco.ieVersion != -1 && alfresco.ieEngine < 8; - this.parent(recursively && !recurseOnChildren); - - if (this.getViewRoot().focusedRepeat != null && - (this.getViewRoot().focusedRepeat == this || - this.getViewRoot().focusedRepeat.isAncestorOf(this))) - { - this._groupHeaderNode.addClass("xformsRepeatFocusedHeader"); - } - else - { - this._groupHeaderNode.removeClass("xformsRepeatFocusedHeader"); - } - for (var i = 0; i < this._children.length; i++) - { - var domContainerClasses = this._children[i].domContainer.getProperty("class").split(" "); - if (i + 1 == this.getSelectedIndex() && this.getViewRoot().focusedRepeat == this) - { - domContainerClasses.remove("xformsRowOdd"); - domContainerClasses.remove("xformsRowEven"); - domContainerClasses.include("xformsRepeatItemSelected"); - } - else - { - domContainerClasses.remove("xformsRepeatItemSelected"); - domContainerClasses.remove("xformsRow" + (i % 2 ? "Odd" : "Even")); - domContainerClasses.include("xformsRow" + (i % 2 ? "Even" : "Odd")); - } - this._children[i].domContainer.setProperty("class", domContainerClasses.join(" ")); - - this._repeatControls[i].style.backgroundColor = this._children[i].domContainer.getStyle("background-color"); - - if (recurseOnChildren) - { - this._children[i]._updateDisplay(true); - } - } - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - /** - * Event handler for insert after. If insert is enabled, causes a setRepeatIndeces - * and an insert. - */ - _insertRepeatItemAfter_handler: function(event) - { - event = new Event(event); - event.stopPropagation(); - if (this.isInsertRepeatItemEnabled()) - { - var index = this._repeatControls.indexOf(event.target.parentNode); - var repeatItem = this.getChildAt(index); - this.setFocusedChild(repeatItem); - var trigger = this._getRepeatItemTrigger("insert", { position: "after" }); - trigger.fire(); - } - }, - - _insertRepeatItemAfter_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._insertRepeatItemAfter_handler(event); - } - }, - - /** - * Event handler for insert before. If insert is enabled, causes a setRepeatIndeces - * and an insert. - */ - _headerInsertRepeatItemBefore_handler: function(event) - { - event = new Event(event); - if (this._children.length == 0) - { - event.stopPropagation(); - if (this.isInsertRepeatItemEnabled()) - { - this.setFocusedChild(null); - var trigger = this._getRepeatItemTrigger("insert", { position: "before" }); - trigger.fire(); - } - } - }, - - _headerInsertRepeatItemBefore_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._headerInsertRepeatItemBefore_handler(event); - } - }, - - /** - * Event handler for remove. If remove is enabled, causes a setRepeatIndeces - * and an delete. - */ - _removeRepeatItem_handler: function(event) - { - event = new Event(event); - event.stopPropagation(); - if (this.isRemoveRepeatItemEnabled()) - { - var index = this._repeatControls.indexOf(event.target.parentNode); - var repeatItem = this.getChildAt(index); - this.setFocusedChild(repeatItem); - var trigger = this._getRepeatItemTrigger("delete", {}); - trigger.fire(); - } - }, - - _removeRepeatItem_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._removeRepeatItem_handler(event); - } - }, - - /** - * Event handler for move up. Calls swap children with the child before - * if the current select child is not the first child. - */ - _moveRepeatItemUp_handler: function(event) - { - event = new Event(event); - event.stopPropagation(); - var index = this._repeatControls.indexOf(event.target.parentNode); - if (index != 0 && this._children.length != 1) - { - var repeatItem = this.getChildAt(index); - this.setFocusedChild(repeatItem); - this._swapChildren(index, index - 1); - } - }, - - _moveRepeatItemUp_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._moveRepeatItemUp_handler(event); - } - }, - - /** - * Event handler for move down. Calls swap children with the child after - * if the current select child is not the last child. - */ - _moveRepeatItemDown_handler: function(event) - { - event = new Event(event); - event.stopPropagation(); - var index = this._repeatControls.indexOf(event.target.parentNode); - if (index != this._children.length - 1 && this._children.length != 1) - { - var repeatItem = this.getChildAt(index); - this.setFocusedChild(repeatItem); - this._swapChildren(index, index + 1); - } - }, - - _moveRepeatItemDown_keypressHandler: function(event) - { - if ((null != event) && ((13 == event.keyCode) || (32 == event.keyCode) || ((null != event.charCode) && (32 == event.charCode)))) - { - this._moveRepeatItemDown_handler(event); - } - }, - - ///////////////////////////////////////////////////////////////// - // XForms event handlers - ///////////////////////////////////////////////////////////////// - - /** Sets the selected index. */ - handleIndexChanged: function(index) - { - alfresco.log(this.id + ".handleIndexChanged(" + index + ")"); - this._selectedIndex = index; - this._updateDisplay(false); - }, - - /** Returns a clone of the specified prototype id. */ - handlePrototypeCloned: function(prototypeId) - { - alfresco.log(this.id + ".handlePrototypeCloned("+ prototypeId +")"); - var chibaData = _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.CHIBA_NS, - alfresco.xforms.constants.CHIBA_PREFIX, - "data"); - chibaData = chibaData[chibaData.length - 1]; - var prototypeToClone = dojo.dom.firstElement(chibaData); - if (prototypeToClone.getAttribute("id") != prototypeId) - { - throw new Error("unable to locate " + prototypeId + - " in " + this.id); - } - return prototypeToClone.cloneNode(true); - }, - - /** Inserts the clonedPrototype at the specified position. */ - handleItemInserted: function(clonedPrototype, position) - { - alfresco.log(this.id + ".handleItemInserted(" + clonedPrototype.nodeName + - ", " + position + ")"); - var w = this.xform.createWidget(clonedPrototype, this); - this._insertChildAt(w, position); - this.xform.loadWidgets(w.xformsNode, w); - }, - - /** Deletes the item at the specified position. */ - handleItemDeleted: function(position) - { - alfresco.log(this.id + ".handleItemDeleted(" + position + ")"); - this._removeChildAt(position); - } -}); - -//////////////////////////////////////////////////////////////////////////////// -// trigger widgets -//////////////////////////////////////////////////////////////////////////////// - -/** - * Handles xforms widget xf:trigger. - */ -alfresco.xforms.Trigger = alfresco.xforms.Widget.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget, new Element("input", { type: "submit" })); - }, - - ///////////////////////////////////////////////////////////////// - // methods & properties - ///////////////////////////////////////////////////////////////// - - /** TODO: DOCUMENT */ - getActions: function() - { - if (typeof this._actions == "undefined") - { - var actionNode = _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "action")[0]; - this._actions = {}; - for (var i = 0; i < actionNode.childNodes.length; i++) - { - if (actionNode.childNodes[i].nodeType != document.ELEMENT_NODE) - { - continue; - } - - var a = new alfresco.xforms.XFormsAction(this.xform, actionNode.childNodes[i]); - this._actions[a.getType()] = a; - } - } - return this._actions; - }, - - /** fires the xforms action associated with the trigger */ - fire: function(asynchronous) - { - this.xform.fireAction(this.id, asynchronous); - }, - - ///////////////////////////////////////////////////////////////// - // overridden methods - ///////////////////////////////////////////////////////////////// - - isValidForSubmit: function() - { - return true; - }, - - isVisible: function() - { - return false; - }, - - render: function(attach_point) - { - attach_point.appendChild(this.domNode); - this.widget = this.domNode; - this.widget.value = this.getLabel() + " " + this.id; - this.widget.onclick = this._clickHandler.bindAsEventListener(this); - this.domContainer.style.display = "none"; - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - _clickHandler: function(event) - { - this.fire(); - } -}); - -/** - * Handles xforms widget xf:submit. - */ -alfresco.xforms.Submit = alfresco.xforms.Trigger.extend({ - initialize: function(xform, xformsNode, parentWidget) - { - this.parent(xform, xformsNode, parentWidget); - var submit_buttons = (this.id == "submit" - ? _xforms_getSubmitButtons() - : (this.id == "save-draft" - ? _xforms_getSaveDraftButtons() - : null)); - if (submit_buttons == null) - { - throw new Error("unknown submit button " + this.id); - } - submit_buttons.each(function(b) - { - alfresco.log("adding submit handler for " + b.getAttribute('id')); - $(b).onclick = this._submitButton_clickHandler.bindAsEventListener(this); - }.bind(this)); - }, - - ///////////////////////////////////////////////////////////////// - // DOM event handlers - ///////////////////////////////////////////////////////////////// - - _clickHandler: function(event) - { - this.done = false; - _hide_errors(); - this.fire(); - }, - - /** */ - _submitButton_clickHandler: function(event) - { - event = new Event(event); - var result; - if (this.xform.submitWidget && this.xform.submitWidget.done) - { - alfresco.log("done - doing base click on " + this.xform.submitWidget.currentButton.id); - this.xform.submitWidget.currentButton = null; - this.xform.submitWidget = null; - result = true; - } - else - { - alfresco.log("triggering submit from handler " + event.target.id); - event.stopPropagation(); - _hide_errors(); - this.xform.submitWidget = this; - this.xform.submitWidget.currentButton = event.target; - this.xform.submitWidget.fire(true); - result = false; - } - alfresco.log("submit click handler exit " + event.target.id + " with result " + result); - return result; - } -}); - -/** - * A struct describing an xforms action block. - */ -alfresco.xforms.XFormsAction = new Class({ - initialize: function(xform, xformsNode) - { - this.xform = xform; - this.xformsNode = xformsNode; - /** All properties of the action as map of key value pairs */ - this.properties = []; - for (var i = 0; i < this.xformsNode.attributes.length; i++) - { - var attr = this.xformsNode.attributes[i]; - if (attr.nodeName.match(new RegExp("^" + alfresco.xforms.constants.XFORMS_PREFIX + ":"))) - { - this.properties[attr.nodeName.substring((alfresco.xforms.constants.XFORMS_PREFIX + ":").length)] = - attr.nodeValue; - } - } - if (this.getType() == "setvalue" && !this.properties["value"]) - { - this.properties["value"] = this.xformsNode.firstChild.nodeValue; - } - }, - - /** Returns the action type. */ - getType: function() - { - return this.xformsNode.nodeName.substring((alfresco.xforms.constants.XFORMS_PREFIX + ":").length); - } -}); - -//////////////////////////////////////////////////////////////////////////////// -// xforms data model -//////////////////////////////////////////////////////////////////////////////// - -/** - * An xforms event. A log of events is returned by any xforms action and - * is used to update the UI appropriately. - */ -alfresco.xforms.XFormsEvent = new Class({ - initialize: function(node) - { - this.type = node.nodeName; - this.targetId = node.getAttribute("targetId"); - this.targetName = node.getAttribute("targetName"); - this.properties = {}; - for (var i = 0; i < node.childNodes.length; i++) - { - if (node.childNodes[i].nodeType == document.ELEMENT_NODE) - { - this.properties[node.childNodes[i].getAttribute("name")] = - node.childNodes[i].getAttribute("value"); - } - } - }, - - /** Returns the widget managing the specified target id. */ - getTarget: function() - { - var targetDomNode = document.getElementById(this.targetId + "-content"); - if (!targetDomNode) - { - throw new Error("unable to find node " + this.targetId + "-content"); - } - return targetDomNode.widget; - } -}); - -/** - * A parsed xf:bind. - */ -alfresco.xforms.Binding = new Class({ - initialize: function(xformsNode, parentBinding) - { - this.xformsNode = xformsNode; - this.id = this.xformsNode.getAttribute("id"); - this.nodeset = this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":nodeset"); - this._readonly = - (_hasAttribute(this.xformsNode, alfresco.xforms.constants.XFORMS_PREFIX + ":readonly") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":readonly") == "true()" - : null); - this._required = - (_hasAttribute(this.xformsNode, alfresco.xforms.constants.XFORMS_PREFIX + ":required") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":required") == "true()" - : null); - this._type = - (_hasAttribute(this.xformsNode, alfresco.xforms.constants.XFORMS_PREFIX + ":type") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":type") - : null); - this._builtInType = - (_hasAttribute(this.xformsNode, alfresco.xforms.constants.ALFRESCO_PREFIX + ":builtInType") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":builtInType") - : null); - this.constraint = - (_hasAttribute(this.xformsNode, alfresco.xforms.constants.XFORMS_PREFIX + ":constraint") - ? this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":constraint") - : null); - this.maximum = this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":maxOccurs"); - this.maximum = this.maximum == "unbounded" ? Number.MAX_VALUE : parseInt(this.maximum); - this.minimum = parseInt(this.xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":minOccurs")); - this.parentBinding = parentBinding; - this.widgets = {}; - }, - - /** Returns the expected schema type for this binding. */ - getType: function() - { - return (this._type != null - ? this._type - : (this.parentBinding != null ? this.parentBinding.getType() : null)); - }, - - /** Returns the expected built in schema type for this binding. */ - getBuiltInType: function() - { - return (this._builtInType != null - ? this._builtInType - : (this.parentBinding != null ? this.parentBinding.getBuiltInType() : null)); - }, - - /** Returns true if a node bound by this binding has a readonly value */ - isReadonly: function() - { - return (this._readonly != null ? this._readonly : - (this.parentBinding != null ? this.parentBinding.isReadonly() : false)); - }, - - /** Returns true if a node bound by this binding has a required value */ - isRequired: function() - { - return (this._required != null ? this._required : - (this.parentBinding != null ? this.parentBinding.isRequired() : false)); - }, - - toString: function() - { - return ("{id: " + this.id + - ",type: " + this.getType() + - ",builtInType: " + this.getBuiltInType() + - ",required: " + this.isRequired() + - ",readonly: " + this.isReadonly() + - ",nodeset: " + this.nodeset + "}"); - } -}); - -/** - * Manages the xforms document. - */ -alfresco.xforms.XForm = new Class({ - - /** Makes a request to the XFormsBean to load the xforms document. */ - initialize: function() - { - alfresco.AjaxHelper.sendRequest("XFormsBean.getXForm", - null, - true, - this._loadHandler.bindAsEventListener(this)); - }, - - ///////////////////////////////////////////////////////////////// - // Initialization - ///////////////////////////////////////////////////////////////// - - /** Parses the xforms document and produces the widget tree. */ - _loadHandler: function(xformDocument) - { - this.xformDocument = xformDocument; - this.xformsNode = xformDocument.documentElement; - this._bindings = this._loadBindings(this.getModel()); - - var bindings = this.getBindings(); - var alfUI = document.getElementById(alfresco.xforms.constants.XFORMS_UI_DIV_ID); - alfUI.style.width = "100%"; - var rootGroup = _getElementsByTagNameNS(this.getBody(), - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "group")[0]; - - this.rootWidget = new alfresco.xforms.ViewRoot(this, rootGroup); - this.rootWidget.render(alfUI); - - this.loadWidgets(rootGroup, this.rootWidget); - - var resolver = alfresco.xforms.FOCUS_RESOLVER; - var root = document.getElementById("alfresco-xforms-root-group-childContainerNode"); - var firstControl = resolver.findControl(root, false, true); - - if (null != firstControl) - { - firstControl.focus(); - } - }, - - /** Creates the widget for the provided xforms node. */ - createWidget: function(xformsNode, parentWidget) - { - var appearance = (xformsNode.getAttribute("appearance") || - xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":appearance")); - appearance = appearance == null || appearance.length == 0 ? null : appearance; - - var xformsType = xformsNode.nodeName.toLowerCase(); - var binding = this.getBinding(xformsNode); - var schemaType = binding ? binding.getType() : null; - var builtInSchemaType = binding ? binding.getBuiltInType() : null; - - alfresco.log("creating widget for xforms type " + xformsType + - " schema type " + schemaType + - " built in schema type " + builtInSchemaType + - " with appearance " + appearance); - var x = alfresco.xforms.widgetConfig[xformsType]; - if (!x) - { - throw new Error("unknown type " + xformsNode.nodeName); - } - x = schemaType in x ? x[schemaType] : builtInSchemaType in x ? x[builtInSchemaType] : x["*"]; - x = appearance in x ? x[appearance] : x["*"]; - // alfresco.log(xformsType + ":" + schemaType + ":" + appearance + " =>" + x); - if (x === undefined) - { - throw new Error("unable to find widget for xforms type " + xformsType + - " schemaType " + schemaType + - " appearance " + appearance); - } - if (x == null || typeof x.className == "undefined") - { - return null; - } - var cstr = eval(x.className); - if (!cstr) - { - throw new Error("unable to load constructor " + x.className + - " for xforms type " + xformsType + - " schemaType " + schemaType + - " appearance " + appearance); - } - var result = new cstr(this, xformsNode, parentWidget, $merge({}, x.params)); - if (result instanceof alfresco.xforms.Widget) - { - return result; - } - else - { - throw new Error("constructor for widget " + x + - " for xforms type " + xformsType + - " schemaType " + schemaType + - " appearance " + appearance + - " is not an alfresco.xforms.Widget"); - } - }, - - /** Loads all widgets for the provided xforms node's children. */ - loadWidgets: function(xformsNode, parentWidget) - { - for (var i = 0; i < xformsNode.childNodes.length; i++) - { - if (xformsNode.childNodes[i].nodeType != document.ELEMENT_NODE) - { - if (alfresco.ieVersion == -1) - { - // fix for ETWOTWO-490, hide elements after rendering (Mozila/Firefox) - if ((i == (xformsNode.childNodes.length - 1)) && - (parentWidget instanceof alfresco.xforms.SwitchGroup)) - { - for (var x = 0; x < parentWidget._children.length; x++) - { - if (parentWidget.triggers[x].getActions()["toggle"].properties["case"] != parentWidget._selectedCaseId) - { - parentWidget._children[x].domContainer.style.display = "none"; - } - } - } - } - continue; - } - alfresco.log("loading " + xformsNode.childNodes[i].nodeName + - " into " + parentWidget.id); - if (xformsNode.childNodes[i].getAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + - ":prototype") == "true") - { - alfresco.log(xformsNode.childNodes[i].getAttribute("id") + - " is a prototype, ignoring"); - continue; - } - - var w = this.createWidget(xformsNode.childNodes[i], parentWidget); - if (w != null) - { - alfresco.log("created " + w.id + " for " + xformsNode.childNodes[i].nodeName); - parentWidget.addChild(w); - if (w instanceof alfresco.xforms.AbstractGroup) - { - this.loadWidgets(xformsNode.childNodes[i], w); - } - } - - // fix for ETWOTWO-490, hide elements after rendering (Internet Explorer) - if ((i == (xformsNode.childNodes.length - 1)) && - (parentWidget instanceof alfresco.xforms.SwitchGroup)) - { - for (var x = 0; x < parentWidget._children.length; x++) - { - if (parentWidget.triggers[x].getActions()["toggle"].properties["case"] != parentWidget._selectedCaseId) - { - parentWidget._children[x].domContainer.style.display = "none"; - } - } - } - } - }, - - /** Loads all bindings from the xforms document. */ - _loadBindings: function(bind, parentBinding, result) - { - result = result || []; - for (var i = 0; i < bind.childNodes.length; i++) - { - if (bind.childNodes[i].nodeName.toLowerCase() == - alfresco.xforms.constants.XFORMS_PREFIX + ":bind") - { - var b = new alfresco.xforms.Binding(bind.childNodes[i], parentBinding); - result[b.id] = b; - alfresco.log("loaded binding " + b); - this._loadBindings(bind.childNodes[i], result[b.id], result); - } - } - return result; - }, - - ///////////////////////////////////////////////////////////////// - // XForms model properties & methods - ///////////////////////////////////////////////////////////////// - - /** Returns the model section of the xforms document. */ - getModel: function() - { - return _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "model")[0]; - }, - - /** Returns the instance section of the xforms document. */ - getInstance: function() - { - return _getElementsByTagNameNS(this.getModel(), - alfresco.xforms.constants.XFORMS_NS, - alfresco.xforms.constants.XFORMS_PREFIX, - "instance")[0]; - }, - - /** Returns the body section of the xforms document. */ - getBody: function() - { - var b = _getElementsByTagNameNS(this.xformsNode, - alfresco.xforms.constants.XHTML_NS, - alfresco.xforms.constants.XHTML_PREFIX, - "body"); - return b[b.length - 1]; - }, - - /** Returns the binding corresponding to the provided xforms node. */ - getBinding: function(xformsNode) - { - return this._bindings[xformsNode.getAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":bind")]; - }, - - /** Returns all parsed bindings. */ - getBindings: function() - { - return this._bindings; - }, - - ///////////////////////////////////////////////////////////////// - // XFormsBean interaction - ///////////////////////////////////////////////////////////////// - - /** swaps the specified repeat items by calling XFormsBean.swapRepeatItems. */ - swapRepeatItems: function(fromChild, toChild) - { - var params = - { - fromItemId: fromChild.xformsNode.getAttribute("id"), - toItemId: toChild.xformsNode.getAttribute("id"), - instanceId: this.getInstance().getAttribute("id") - }; - - alfresco.AjaxHelper.sendRequest("XFormsBean.swapRepeatItems", - params, - false, - this._handleEventLog.bindAsEventListener(this)); - }, - - /** sets the repeat indexes by calling XFormsBean.setRepeatIndeces. */ - setRepeatIndeces: function(repeatIndeces) - { - // The following debug statement is causing performance and rendering issues (ETWOTWO-1006, - // ETHREEOH-3155 & ETHREEOH-2653), only uncomment this line if necessary for fault finding. - // alfresco.log("setting repeat indeces [" + repeatIndeces.join(", ") + "]"); - - var params = { }; - params["repeatIds"] = []; - for (var i = 0; i < repeatIndeces.length; i++) - { - params.repeatIds.push(repeatIndeces[i].repeat.id); - params[repeatIndeces[i].repeat.id] = repeatIndeces[i].index; - } - params.repeatIds = params.repeatIds.join(","); - alfresco.AjaxHelper.sendRequest("XFormsBean.setRepeatIndeces", - params, - false, - this._handleEventLog.bindAsEventListener(this)); - }, - - /** Fires an action specified by the id by calling XFormsBean.fireAction. */ - fireAction: function(id, asynchronous) - { - alfresco.log("fireAction(" + id + ")"); - alfresco.AjaxHelper.sendRequest("XFormsBean.fireAction", - { id: id }, - $pick(asynchronous, false), - this._handleEventLog.bindAsEventListener(this)); - }, - - /** Sets the value of the specified control id by calling XFormsBean.setXFormsValue. */ - setXFormsValue: function(id, value) - { - value = value == null ? "" : value.toString(); - alfresco.log("setting value " + id + " = " + value); - alfresco.AjaxHelper.sendRequest("XFormsBean.setXFormsValue", - { id: id, value: value }, - true, - this._handleEventLog.bindAsEventListener(this)); - }, - - _previousInvalidWidgets: null, - - /** Handles the xforms event log resulting from a call to the XFormsBean. */ - _handleEventLog: function(events) - { - events = events.documentElement; - var prototypeClones = []; - var generatedIds = null; - for (var i = 0; i < events.childNodes.length; i++) - { - if (events.childNodes[i].nodeType != document.ELEMENT_NODE) - { - continue; - } - var xfe = new alfresco.xforms.XFormsEvent(events.childNodes[i]); - alfresco.log("parsing " + xfe.type + - "(" + xfe.targetId + ", " + xfe.targetName + ")"); - switch (xfe.type) - { - case "chiba-index-changed": - { - var index = Number(xfe.properties["index"]); - try - { - xfe.getTarget().handleIndexChanged(index); - } - catch (e) - { - alfresco.log(e); - } - break; - } - case "chiba-state-changed": - { - alfresco.log("handleStateChanged(" + xfe.targetId + ")"); - - if ("valid" in xfe.properties) - { - xfe.getTarget().setValid(xfe.properties["valid"] == "true"); - xfe.getTarget().setModified(true); - } - if ("required" in xfe.properties) - { - xfe.getTarget().setRequired(xfe.properties["required"] == "true"); - } - if ("readonly" in xfe.properties) - { - xfe.getTarget().setReadonly(xfe.properties["readonly"] == "true"); - } - if ("enabled" in xfe.properties) - { - xfe.getTarget().setEnabled(xfe.properties["enabled"] == "true"); - } - if ("value" in xfe.properties) - { - alfresco.log("setting " + xfe.getTarget().id + " = " + xfe.properties["value"]); - xfe.getTarget().setValue(xfe.properties["value"]); - xfe.getTarget().setModified(true); - } - break; - } - case "chiba-prototype-cloned": - { - var prototypeId = xfe.properties["prototypeId"]; - var originalId = xfe.properties["originalId"]; - alfresco.log("handlePrototypeCloned(" + xfe.targetId + - ", " + originalId + - ", " + prototypeId + ")"); - var clone = null; - var prototypeNode = _findElementById(this.xformsNode, prototypeId); - if (prototypeNode) - { - alfresco.log("cloning prototype " + prototypeNode.getAttribute("id")); - clone = prototypeNode.cloneNode(true); - } - else - { - alfresco.log("cloning prototype " + originalId); - var prototypeNode = _findElementById(this.xformsNode, originalId); - //clone = prototypeNode.cloneNode(true); - clone = prototypeNode.ownerDocument.createElement(alfresco.xforms.constants.XFORMS_PREFIX + ":group"); - clone.setAttribute(alfresco.xforms.constants.XFORMS_PREFIX + ":appearance", "repeated"); - for (var j = 0; j < prototypeNode.childNodes.length; j++) - { - clone.appendChild(prototypeNode.childNodes[j].cloneNode(true)); - } - clone.setAttribute("id", prototypeId); - } - - if (clone == null) - { - throw new Error("unable to clone prototype " + prototypeId); - } - - alfresco.log("created clone " + clone.getAttribute("id") + - " nodeName " + clone.nodeName + - " parentClone " + (prototypeClones.length != 0 - ? prototypeClones.peek().getAttribute("id") - : null)); - prototypeClones.push(clone); - break; - } - case "chiba-id-generated": - { - var originalId = xfe.properties["originalId"]; - - alfresco.log("handleIdGenerated(" + xfe.targetId + ", " + originalId + ")"); - var node = _findElementById(prototypeClones.peek(), originalId); - if (!node) - { - throw new Error("unable to find " + originalId + - " in clone " + dojo.dom.innerXML(clone)); - } - alfresco.log("applying id " + xfe.targetId + - " to " + node.nodeName + "(" + originalId + ")"); - node.setAttribute("id", xfe.targetId); - generatedIds = generatedIds || new Object(); - generatedIds[xfe.targetId] = originalId; - if (prototypeClones.length != 1) - { - var e = _findElementById(prototypeClones[prototypeClones.length - 2], originalId); - if (e) - { - e.setAttribute(alfresco.xforms.constants.ALFRESCO_PREFIX + ":prototype", "true"); - } - } - break; - } - case "chiba-item-inserted": - { - var position = Number(xfe.properties["position"]) - 1; - var originalId = xfe.properties["originalId"]; - var clone = prototypeClones.pop(); - // walk all nodes of the clone and ensure that they have generated ids. - // those that do not are nested repeats that should not be added - if ((clone.getAttribute("id") in generatedIds) == false) - { - throw new Error("expected clone id " + clone.getAttribute("id") + - " to be a generated id"); - } - - function _removeNonGeneratedChildNodes(node, ids) - { - var child = node.firstChild; - while (child) - { - var next = child.nextSibling; - if (child.nodeType == document.ELEMENT_NODE) - { - if (child.getAttribute("id") in ids) - { - _removeNonGeneratedChildNodes(child, ids); - } - else - { - node.removeChild(child); - } - } - child = next; - } - }; - _removeNonGeneratedChildNodes(clone, generatedIds); - - if (prototypeClones.length != 0) - { - alfresco.log("using parentClone " + prototypeClones.peek().getAttribute("id") + - " of " + clone.getAttribute("id")); - var parentRepeat = _findElementById(prototypeClones.peek(), xfe.targetId); - parentRepeat.appendChild(clone); - } - else - { - alfresco.log("no parentClone found, directly insert " + clone.getAttribute("id") + - " on " + xfe.targetId); - xfe.getTarget().handleItemInserted(clone, position); - } - break; - } - case "chiba-item-deleted": - { - var position = Number(xfe.properties["position"]) - 1; - xfe.getTarget().handleItemDeleted(position); - break; - } - case "chiba-replace-all": - { - if (this.submitWidget) - { - this.submitWidget.done = true; - this.submitWidget.currentButton.click(); - } - break; - } - case "chiba-switch-toggled": - { - var switchElement = xfe.getTarget(); - switchElement.handleSwitchToggled(xfe.properties["selected"], - xfe.properties["deselected"]); - } - case "xforms-valid": - { - xfe.getTarget().setValid(true); - xfe.getTarget().setModified(true); - break; - } - case "xforms-invalid": - { - xfe.getTarget().setValid(false); - xfe.getTarget().setModified(true); - break; - } - case "xforms-required": - { - xfe.getTarget().setRequired(true); - break; - } - case "xforms-optional": - { - xfe.getTarget().setRequired(false); - break; - } - case "xforms-submit-error": - { - this.submitWidget = null; - var invalid_widgets = this.rootWidget.getWidgetsInvalidForSubmit(); - _show_error(document.createTextNode(alfresco.resources["validation_provide_values_for_required_fields"]), invalid_widgets.length); - var error_list = document.createElement("ul"); - - var resolver = alfresco.xforms.FOCUS_RESOLVER; - resolver.release(); - - resolver.clearTheScope(); - - _removeAccessibilityErrorNotification(this._previousInvalidWidgets); - - invalid_widgets.each(function(invalid) - { - var error_item = document.createElement("li"); - error_item.id = invalid.domNode.id + "-alertItem"; - error_item.appendChild(document.createTextNode(invalid.getAlert())); - error_list.appendChild(error_item); - - resolver.addParentsAsScopeContainers(invalid.domNode); - _applyAccessibilityErrorNotification(invalid, error_item.id); - - invalid.showAlert(); - }); - - resolver.init(); - this._previousInvalidWidgets = invalid_widgets; - - _show_error(error_list); - break; - } - case "xforms-readonly": - { - xfe.getTarget().setReadonly(true); - break; - } - case "xforms-readwrite": - { - xfe.getTarget().setReadonly(false); - break; - } - case "xforms-submit": - case "xforms-submit-done": - case "xforms-enabled": - case "xforms-disabled": - break; - default: - { - alfresco.log("unhandled event " + events.childNodes[i].nodeName); - } - } - } - } -}); - -/** - * Emulates strict sequence of the elements which are NOT valid for submit in case of Tab navigation - * - * @author Dmitry Velichkevich - */ -alfresco.xforms.FocusResolver = new Class({ - _forced: false, - _scopeContainers: {}, - _currentElement: null, - _currentParent: null, - _navigationDirection: 0, - - initialize: function() - { - }, - - init: function() - { - if (document.addEventListener) - { - document.addEventListener("mouseup", this.mouseUpWatcher, true); - document.addEventListener("keydown", this.keyDownWatcher, true); - - document.addEventListener("focus", this.focusWatcher, true); - } - else - { - if (document.attachEvent) - { - document.onmouseup = this.mouseUpWatcher; - document.onkeydown = this.keyDownWatcher; - - document.onactivate = this.focusWatcher; - } - } - }, - - release: function() - { - if (document.removeEventListener) - { - document.removeEventListener("mouseup", this.mouseUpWatcher, true); - document.removeEventListener("keydown", this.keyDownWatcher, true); - - document.removeEventListener("focus", this.focusWatcher, true); - } - else - { - if (document.detachEvent) - { - document.onmouseup = null; - document.onkeydown = null; - - document.onactivate = null; - } - } - }, - - mouseUpWatcher: function(e) - { - var resolver = alfresco.xforms.FOCUS_RESOLVER; - resolver._navigationDirection = 0; - }, - - keyDownWatcher: function(e) - { - if (null == e) - { - e = event; - } - - if (null == e) - { - return; - } - - var resolver = alfresco.xforms.FOCUS_RESOLVER; - var code = (e.keyCode) ? (e.keyCode) : (e.which); - - if (27 == code) - { - resolver.release(); - } - else - { - resolver._navigationDirection = (9 == code) ? ((e.shiftKey) ? (-1) : (1)) :(0); - } - }, - - focusWatcher: function(e) - { - // In case of IE global handler receives global event object... - if (e == null) - { - e = event; - } - - var focusedElement = ((null != e) && (null != e.target)) ? (e.target) : (document.activeElement); - - var resolver = alfresco.xforms.FOCUS_RESOLVER; - resolver._ensureInUniqueId(focusedElement); - - // Ignores the event if focus actually is the same as at previous time or if nothing is focused - if ((null == focusedElement) || ((null != resolver._currentElement) && !resolver._forced && ((resolver._currentElement.id == focusedElement.id) || (0 == focusedElement.id.indexOf("undefined"))))) - { - if ((null != focusedElement) && (0 != focusedElement.id.indexOf("undefined"))) - { - resolver._navigationDirection = 0; - } - - return; - } - - if (window.ie && !resolver._navigationDirection && ("IFRAME" == focusedElement.tagName)) - { - var frameParent = resolver.getHighestParent(focusedElement); - - if (frameParent.id != resolver._currentParent) - { - resolver._navigationDirection = 0; - resolver._forced = true; - resolver._currentElement.focus(); - resolver._forced = false; - if ("undefined" == typeof(e.stopPropagation)) - { - window.event.cancelBubble = true; - } - else - { - e.stopPropagation(); - } - return; - } - } - - - // Focus received via the Keyboard?.. - if (resolver._navigationDirection) - { - var direction = resolver._navigationDirection; - resolver._navigationDirection = 0; - - // Is focus trapped into the element which is valid for submit?.. - if (!resolver._isElementInTheScope(focusedElement)) - { - // Stopping propagation of the vent since it has been fired for not valid element... - if ("undefined" == typeof(e.stopPropagation)) - { - window.event.cancelBubble = true; - } - else - { - e.stopPropagation(); - } - - var parent = resolver.getHighestParent(focusedElement); - - // Nullifying these value in any case to initiate changes in the resolver - resolver._currentParent = null; - focusedElement = null; - - // Searching for a "label(s) + widget(s)" container with a widget which is NOT valid for submit in accordance with direction (Tab or Shift + Tab) - // This cycle iterates only "label(s) + widget(s)" containers... - while ((null == focusedElement) && (null != parent)) - { - // Does container contain widget(s) which is NOT valid for submit?.. - if (null != resolver._scopeContainers[parent.id]) - { - // Searching for this widget... - focusedElement = resolver._searchForTheBestElement(parent); - } - - // Searching for another "label(s) + widget(s)" container - do - { - parent = (direction > 0) ? (parent.nextSibling) : (parent.previousSibling); - } - while ((null != parent) && (1 != parent.nodeType)) // "1 != parent.nodeType" is a cross-browsers condition for enumerating siblings - } - - // Is the widget found?.. - if (null != focusedElement) - { - // Setting focus to the found widget - - // Preventing processing of focus change without user action - resolver._navigationDirection = 0; - focusedElement.focus(); - } - - // Saving its parent... - resolver._currentParent = parent; - } - else - { - // Receiving a "label(s) + widget(s)" container... - var parent = resolver.getHighestParent(focusedElement); - - // Is container changed? And should navigation between ALL the elements of a group be stopped?.. - if ((null == resolver._currentParent) || (resolver._currentParent.id != parent.id)) - { - // Searching for the first element which is NOT valid for submit in accordance with order of the navigation... - var element = resolver._searchForTheBestElement(parent); - - // Is required element found?.. - if ((null != element) && (element.id != focusedElement.id)) - { - // Setting focus to the found element - - focusedElement = element; - // Preventing processing of focus change without user action - resolver._navigationDirection = 0; - element.focus(); - } - - resolver._currentParent = parent; - } - } - } - else - { - // Updating rosolver in accordance with focused element - if (resolver._isElementInTheScope(focusedElement)) - { - resolver._currentParent = resolver.getHighestParent(focusedElement); - } - else - { - resolver._currentParent = null; - } - } - - resolver._currentElement = focusedElement; - }, - - getDirection: function() - { - return this._navigationDirection; - }, - - setDirection: function(direction) - { - this._navigationDirection = direction; - }, - - _searchForTheBestElement: function(start) - { - var result = this.findControl(start, true, false); - if ((null != result) && ((0 != result.tabIndex) || ("DIV" == result.tagName) || ("SPAN" == result.tagName)) && (null != result.children)) - { - result = this.findControl(result, false, true); - } - return result; - }, - - getHighestParent: function(element) - { - if (null == element) - { - return null; - } - - for (var previousChild = element, parent = element.parentNode; null != parent; previousChild = parent, parent = parent.parentNode) - { - var node = parent.parentNode; - if (((null == parent.className) || (0 == parent.className.length)) && (null != node) && ("xformsViewRoot" == node.className)) - { - return previousChild; - } - } - - return null; - }, - - findControl: function(element, ignoreTabIndex, dontCareAboutValidity) - { - if ((null == element) || (("DIV" == element.tagName) && this._hasClass(element, "xformsItemLabelContainer"))) - { - return null; - } - - var result = null; - - if ((!dontCareAboutValidity || (("LABEL" != element.tagName) && ("DIV" != element.tagName) && ("SPAN" != element.tagName))) && (ignoreTabIndex || (0 == element.tabIndex)) - && (dontCareAboutValidity || ((null != element.widget) && (!element.widget.isValidForSubmit())))) - { - result = element; - } - - if ((null == result) && (null != element.children)) - { - for (var i = 0; (null == result) && (i < element.children.length); i++) - { - result = this.findControl(element.children[i], ignoreTabIndex, dontCareAboutValidity); - } - } - - return result; - }, - - _hasClass: function(element, className) - { - return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; - }, - - _isElementInTheScope: function(element) - { - if (null != element) - { - for (var parent = element.parentNode; null != parent; parent = parent.parentNode) - { - if (null != this._scopeContainers[parent.id]) - { - return true; - } - else - { - var node = parent.parentNode; - if (((null == parent.className) || (0 == parent.className.length)) && (null != node) && ("xformsViewRoot" == node.className)) - { - break; - } - } - } - } - - return false; - }, - - addScopeContainer: function(container) - { - if (null != container) - { - this._scopeContainers[container.id] = container; - return true; - } - - return false; - }, - - addParentsAsScopeContainers: function(element) - { - if (null != element) - { - for (var parent = element.parentNode; null != parent; parent = parent.parentNode) - { - var node = parent.parentNode; - if (((null == parent.className) || (0 == parent.className.length)) && (null != node) && ("xformsViewRoot" == node.className)) - { - break; - } - - this._ensureInUniqueId(parent); - - this.addScopeContainer(parent); - } - } - }, - - _ensureInUniqueId: function(element) - { - if ((null != element) && ((null == element.id) || (0 == element.id.length))) - { - element.id = (((null != element.type) && (element.type.length > 0)) ? (element.type) : (element.tagName)) + "_generated_id_" + (new Date()).getTime(); - } - }, - - removeScopeContainer: function(container) - { - if ((null != container) && (null != this._scopeContainers[container.id])) - { - this._scopeContainers[container.id] = null; - return true; - } - - return false; - }, - - clearTheScope: function() - { - this._currentElement = null; - this._currentParent = null; - this._navigationDirection = 0; - - for (var key in this._scopeContainers) - { - this._scopeContainers[key] = null; - } - - this._scopeContainers = {}; - } -}); - - -//////////////////////////////////////////////////////////////////////////////// -// error message display management -//////////////////////////////////////////////////////////////////////////////// - -/** hides the error message display. */ -function _hide_errors() -{ - var errorDiv = $(alfresco.xforms.constants.XFORMS_ERROR_DIV_ID); - if (errorDiv) - { - errorDiv.empty(); - errorDiv.style.display = "none"; - } - var jsfErrorDiv = $(alfresco.xforms.constants.JSF_ERROR_DIV_ID); - if (jsfErrorDiv) - { - jsfErrorDiv.empty(); - jsfErrorDiv.style.display = "none"; - } - var errorLink = $("errorLink-with-key-v"); - if (null != errorLink) - { - errorLink.tabIndex = -1; - errorLink.parentNode.removeChild(errorLink); - errorLink = null; - } -} - -/** shows the error message display. */ -function _show_error(msg, errorCount) -{ - var errorDiv = $(alfresco.xforms.constants.XFORMS_ERROR_DIV_ID); - if (!errorDiv) - { - errorDiv = new Element("div", { "id": alfresco.xforms.constants.XFORMS_ERROR_DIV_ID }); - errorDiv.addClass("infoText statusErrorText xformsError"); - errorDiv.injectBefore($(alfresco.xforms.constants.XFORMS_UI_DIV_ID)); - } - - var errorLink = $("errorLink-with-key-v"); - if (null == errorLink) - { - errorLink = new Element("a", - { - "id": "errorLink-with-key-v", - "src": "javascript: ;", - "accessKey": "v", - "role": "alert", - "tabIndex": 0 - }); - errorLink.onclick = "return false;" - errorLink.onmousedown = "return false;" - errorLink.onfocus = function(e) - { - alfresco.xforms.FOCUS_RESOLVER.init(); - } - - var errorMessage = new Element("div", - { - "id": "accessibility-error-message" - }); - - if (null != errorCount) - { - errorMessage.appendChild(document.createTextNode(errorCount + " " + alfresco.resources["accessibility_validation_message_with_error_count"])); - } - else - { - errorMessage.appendChild(document.createTextNode(alfresco.resources["accessibility_validation_message"])); - } - - errorLink.appendChild(errorMessage); - errorLink.injectBefore($(alfresco.xforms.constants.XFORMS_ERROR_DIV_ID)); - - errorMessage.style.width = "1px"; - errorMessage.style.height = "1px"; - errorMessage.style.filter = "alpha(opacity=1)"; - errorMessage.style.color = "transparent"; - errorMessage.style.overflow = "hidden"; - } - - if (errorDiv.style.display == "block") - { - errorDiv.appendChild(document.createElement("br")); - } - else - { - errorDiv.style.display = "block"; - } - errorDiv.appendChild(msg); - - errorLink.focus(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Accessibility helpers related to the fields validation -//////////////////////////////////////////////////////////////////////////////// - -function _getDateTimePickerLabels(parent) -{ - return [ - { - "tagName": "div", - "id": "increase-week-label", - "cssClass": "xformsAccessibilityInvisibleText", - "parent": parent, - "text": alfresco.resources["increase_week_label"] - }, - { - "tagName": "div", - "id": "increase-month-label", - "cssClass": "xformsAccessibilityInvisibleText", - "parent": parent, - "text": alfresco.resources["increase_month_label"] - }, - { - "tagName": "div", - "id": "decrease-week-label", - "cssClass": "xformsAccessibilityInvisibleText", - "parent": parent, - "text": alfresco.resources["decrease_week_label"] - }, - { - "tagName": "div", - "id": "decrease-month-label", - "cssClass": "xformsAccessibilityInvisibleText", - "parent": parent, - "text": alfresco.resources["decrease_month_label"] - } - ]; -} - -function _createExternalLabels(labelIds) -{ - if ((null == labelIds) || (null == labelIds.length) || (0 == labelIds.length)) - { - return; - } - - for (var i = 0; i < labelIds.length; i++) - { - var el = labelIds[i]; - if (null == document.getElementById(el.id)) - { - var label = new Element(el.tagName, - { - "id": el.id - }); - - if (null != el.parent) - { - el.parent.appendChild(label); - } - else - { - document.appendChild(label); - } - - label.appendChild(document.createTextNode(el.text)); - - if (null != el.cssClass) - { - label.addClass(el.cssClass); - } - } - } -} - -function _removeAccessibilityErrorNotification(widgets) -{ - if (null != widgets) - { - widgets.each(function(invalid) - { - _applyAccessibilityErrorNotification(invalid, null); - }); - } -} - -function _applyAccessibilityErrorNotification(field, alertId) -{ - if (null == field) - { - return; - } - - var control = _findControl(field.domNode); - - if (null != control) - { - if (null == alertId) - { - control.removeAttribute("aria-labelledby"); - } - else - { - var labelIds = alertId; - if ((null != field.widget) && (null != field.widget.labelNode) && (null != field.widget.labelNode.id) && (field.widget.labelNode.id.length > 0)) - { - labelIds += " " + field.widget.labelNode.id; - } - control.setAttribute("aria-labelledby", labelIds); - - if (null == control.getAttribute("role")) - { - switch (control.tagName) - { - case "SELECT": - { - control.setAttribute("role", ((control.multiple) ? ("listbox") : ("combobox"))); - break; - } - case "A": - { - control.setAttribute("role", "link"); - break; - } - case "TEXTAREA": case "DIV": - { - control.setAttribute("role", "textbox"); - control.setAttribute("aria-multiline", true); - break; - } - case "INPUT": - { - switch (control.type) - { - case "button": case "checkbox": case "radio": - { - control.setAttribute("role", control.type); - break; - } - case "hidden": case "password": case "text": - { - control.setAttribute("role", "textbox"); - break; - } - case "submit": case "reset": - { - control.setAttribute("role", "button"); - } - } - } - } - } - } - } -} - -function _findControl(element, parentNotValid) -{ - if (null == element) - { - return null; - } - - var result = null; - - if (("INPUT" == element.tagName) || ("SELECT" == element.tagName) || ("TEXTAREA" == element.tagName) || ((null != element.id) && (0 == element.id.toLowerCase().indexOf("textarea")))) - { - if (!parentNotValid && ("SELECT" == element.tagName) && (null != element.parentNode) && (null != element.parentNode.widget) && !element.parentNode.widget.isValidForSubmit()) - { - parentNotValid = true; - } - - if (parentNotValid || ((null != element.widget) && !element.widget.isValidForSubmit())) - { - if (("DIV" == element.tagName) && (null != element.parentNode.children) && (0 != element.parentNode.children.length) && ("A" == element.parentNode.children[0].tagName)) - { - result = element.parentNode.children[0]; - } - else - { - result = (0 == element.tabIndex) ? (element) : (null); - } - } - } - - if ((null == result) && (null != element.children)) - { - for (var i = 0; (null == result) && (i < element.children.length); i++) - { - result = _findControl(element.children[i], parentNotValid || ((null != element.widget) && !element.widget.isValidForSubmit())); - } - } - - return result; -} - -alfresco.xforms.FOCUS_RESOLVER = new alfresco.xforms.FocusResolver(); - -//////////////////////////////////////////////////////////////////////////////// -// DOM utilities - XXXarielb should be merged into common.js -//////////////////////////////////////////////////////////////////////////////// - -function _findElementById(node, id) -{ -// alfresco.log("looking for " + id + -// " in " + (node ? node.nodeName : null) + -// "(" + (node ? node.getAttribute("id") : null) + ")"); - if (node.getAttribute("id") == id) - { - return node; - } - for (var i = 0; i < node.childNodes.length; i++) - { - if (node.childNodes[i].nodeType == document.ELEMENT_NODE) - { - var n = _findElementById(node.childNodes[i], id); - if (n) - { - return n; - } - } - } - return null; -} - -function _hasAttribute(node, name) -{ - return (node == null - ? false - : (node.hasAttribute - ? node.hasAttribute(name) - : node.getAttribute(name) != null)); -} - -function _getElementsByTagNameNS(parentNode, ns, nsPrefix, tagName) -{ - return (parentNode.getElementsByTagNameNS - ? parentNode.getElementsByTagNameNS(ns, tagName) - : parentNode.getElementsByTagName(nsPrefix + ":" + tagName)); -} - -//////////////////////////////////////////////////////////////////////////////// -// XPath wrapper -//////////////////////////////////////////////////////////////////////////////// - -function _evaluateXPath(xpath, contextNode, result_type) -{ - var xmlDocument = contextNode.ownerDocument; - if (alfresco.constants.DEBUG) - { - alfresco.log("evaluating xpath " + xpath + - " on node " + contextNode.nodeName + - " in document " + xmlDocument); - } - var result = null; - if (xmlDocument.evaluate) - { - var nsResolver = (xmlDocument.createNSResolver - ? xmlDocument.createNSResolver(xmlDocument.documentElement) - : null); - result = xmlDocument.evaluate(xpath, - contextNode, - nsResolver, - result_type, - null); - if (result) - { - switch (result_type) - { - case XPathResult.FIRST_ORDERED_NODE_TYPE: - result = result.singleNodeValue; - break; - case XPathResult.BOOLEAN_TYPE: - result = result.booleanValue; - break; - case XPathResult.STRING_TYPE: - result = result.stringValue; - break; - } - } - } - else - { - xmlDocument.setProperty("SelectionLanguage", "XPath"); - var namespaces = []; - for (var i = 0; i < xmlDocument.documentElement.attributes.length; i++) - { - var attr = xmlDocument.documentElement.attributes[i]; - if (attr.nodeName.match(/^xmlns:/)) - { - namespaces.push(attr.nodeName + "=\'" + attr.nodeValue + "\'"); - } - } - - if (alfresco.constants.DEBUG) - { - alfresco.log("using namespaces " + namespaces.join(",")); - } - xmlDocument.setProperty("SelectionNamespaces", namespaces.join(' ')); - if (result_type == XPathResult.FIRST_ORDERED_NODE_TYPE) - { - result = xmlDocument.selectSingleNode(xpath); - } - else if (result_type == XPathResult.BOOLEAN_TYPE) - { - result = true; - } - } - alfresco.log("resolved xpath " + xpath + " to " + result); - return result; -} - -if (!XPathResult) -{ - var XPathResult = - { - ANY_TYPE: 0, - NUMBER_TYPE: 1, - STRING_TYPE: 2, - BOOEAN_TYPE: 3, - FIRST_ORDERED_NODE_TYPE: 9 - }; -} - -dojo.html.toCamelCase = function(str) -{ - return str.replace(/-./, function(str) { return str.charAt(1).toUpperCase(); }); -} - -//////////////////////////////////////////////////////////////////////////////// -// tiny mce integration -//////////////////////////////////////////////////////////////////////////////// - -alfresco.constants.TINY_MCE_DEFAULT_PLUGINS = - alfresco.xforms.RichTextEditor.determineNecessaryTinyMCEPlugins(alfresco.xforms.widgetConfig); - -alfresco.constants.TINY_MCE_DEFAULT_SETTINGS = -{ - theme: "advanced", - mode: "exact", - plugins: alfresco.constants.TINY_MCE_DEFAULT_PLUGINS, - form_scope_id: "alfresco-xforms-ui", // ALF-11956: Id of a root container for all widgets. Scope of elements search - editor_condition: 'accesskey="z"', // ALF-11956: CSS select condition for an element which should be interpreted as the "central" element of the RTE. Focusable element searching will be started from this element - forward_element_classes: "xformsAccessibilityInvisibleText", // ALF-11956: These CSS classes MUST BE applied to an element which should be interpreted as focusable during forward navigation - backward_element_classes: "mceButton mceButtonEnabled", // ALF-11956: These CSS classes MUST BE applied to an element which should be interpreted as focusable during backward navigation - pre_focus_changed_handler: function(direction) - { - alfresco.xforms.FOCUS_RESOLVER.setDirection(direction); - }, - language: alfresco.constants.LANGUAGE, - width: -1, - height: -1, - auto_resize: false, - force_p_newlines: false, - encoding: "UTF-8", - entity_encoding: "raw", - add_unload_trigger: false, - add_form_submit_trigger: false, - theme_advanced_toolbar_location: "top", - theme_advanced_toolbar_align: "left", - theme_advanced_buttons1: "fullscreen,table", - theme_advanced_buttons2: "", - theme_advanced_buttons3: "", - urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback", - file_browser_callback: "alfresco_TinyMCE_file_browser_callback" -}; - -window.addEvent("domready", - function() - { - document.xform = new alfresco.xforms.XForm(); - });