getFormData()
+ {
+ return this.formData;
+ }
+}
+
+
+
+
+
diff --git a/source/java/org/alfresco/repo/forms/FormService.java b/source/java/org/alfresco/repo/forms/FormService.java
new file mode 100644
index 0000000000..2e5b25d596
--- /dev/null
+++ b/source/java/org/alfresco/repo/forms/FormService.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.forms;
+
+
+/**
+ * Form service fundamental API.
+ *
+ * This service API is designed to support the public facing Form APIs
+ *
+ * @author Gavin Cornwell
+ */
+public interface FormService
+{
+ /**
+ * Returns a form representation of the item with the given id
+ *
+ * @param id The id of the item to get a form for
+ * @return The Form representation
+ */
+ public Form getForm(String id);
+
+ /**
+ * Persists the given form representation for the given id
+ *
+ * @param id The id of the item to persist the form for
+ * @param form The Form representation
+ */
+ public void saveForm(String id, Form form);
+}
diff --git a/source/java/org/alfresco/repo/forms/FormServiceImpl.java b/source/java/org/alfresco/repo/forms/FormServiceImpl.java
new file mode 100644
index 0000000000..5dfa599a2c
--- /dev/null
+++ b/source/java/org/alfresco/repo/forms/FormServiceImpl.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.forms;
+
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.search.SearchService;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Form Service Implementation.
+ *
+ * @author Gavin Cornwell
+ */
+public class FormServiceImpl implements FormService
+{
+ /** Logger */
+ private static Log logger = LogFactory.getLog(FormServiceImpl.class);
+
+ /** Services */
+ private NodeService nodeService;
+ private FileFolderService fileFolderService;
+ private SearchService searchService;
+ private PermissionService permissionService;
+
+ /**
+ * Set node service
+ *
+ * @param nodeService node service
+ */
+ public void setNodeService(NodeService nodeService)
+ {
+ this.nodeService = nodeService;
+ }
+
+ /**
+ * Set file folder service
+ *
+ * @param fileFolderService file folder service
+ */
+ public void setFileFolderService(FileFolderService fileFolderService)
+ {
+ this.fileFolderService = fileFolderService;
+ }
+
+ /**
+ * Set search service
+ *
+ * @param searchService search service
+ */
+ public void setSearchService(SearchService searchService)
+ {
+ this.searchService = searchService;
+ }
+
+ /**
+ * Set permission service
+ *
+ * @param permissionService permission service
+ */
+ public void setPermissionService(PermissionService permissionService)
+ {
+ this.permissionService = permissionService;
+ }
+
+ /**
+ * @see org.alfresco.repo.forms.FormService#getForm(java.lang.String)
+ */
+ public Form getForm(String id)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Retrieving form for item with id: " + id);
+
+ return null;
+ }
+
+ /*
+ * @see org.alfresco.repo.forms.FormService#saveForm(java.lang.String, org.alfresco.repo.forms.Form)
+ */
+ public void saveForm(String id, Form form)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Saving form for item with id '" + id + "': " + form);
+ }
+}
diff --git a/source/java/org/alfresco/repo/forms/FormServiceImplTest.java b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java
new file mode 100644
index 0000000000..1b8070679b
--- /dev/null
+++ b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.forms;
+
+import org.alfresco.util.BaseAlfrescoSpringTest;
+
+/**
+ * Form service implementation unit test.
+ *
+ * @author Gavin Cornwell
+ */
+public class FormServiceImplTest extends BaseAlfrescoSpringTest
+{
+ private FormService formService;
+
+ /**
+ * Called during the transaction setup
+ */
+ protected void onSetUpInTransaction() throws Exception
+ {
+ super.onSetUpInTransaction();
+
+ // Get the required services
+ this.formService = (FormService)this.applicationContext.getBean("FormService");
+ }
+
+ public void testGetForm() throws Exception
+ {
+ Form form = this.formService.getForm("");
+ assertNull(form);
+ }
+
+ // == Test the JavaScript API ==
+
+// public void testJSAPI() throws Exception
+// {
+// ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/forms/script/test_formService.js");
+// this.scriptService.executeScript(location, new HashMap(0));
+// }
+}
diff --git a/source/java/org/alfresco/repo/forms/PropertyFieldDefiniton.java b/source/java/org/alfresco/repo/forms/PropertyFieldDefiniton.java
new file mode 100644
index 0000000000..6b2f24d222
--- /dev/null
+++ b/source/java/org/alfresco/repo/forms/PropertyFieldDefiniton.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2005-2008 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.repo.forms;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A property field definition.
+ *
+ * @author Gavin Cornwell
+ */
+public class PropertyFieldDefiniton extends FieldDefinition
+{
+ protected String dataType;
+ protected boolean mandatory;
+ protected boolean repeats;
+ protected List constraints;
+
+ /**
+ * Constructs a FieldDefinition
+ *
+ * @param name The name of the property
+ * @param label The display label of the property
+ * @param description The description of the property
+ * @param dataType The data type of the property
+ * @param defaultValue Default value of the property
+ * @param binding Binding of the property
+ * @param protectedField Whether the property should be read only
+ * @param mandatory Whether the property is mandatory
+ * @param repeats Whether the property can contain multiple values
+ * @param group The group the property belongs to
+ * @param constraints List of constraints the property has
+ */
+ // TODO: Look at the Builder pattern to reduce the size of the constructor!!
+ public PropertyFieldDefiniton(String name, String label, String description,
+ String dataType, String defaultValue, String binding,
+ boolean protectedField, boolean mandatory, boolean repeats,
+ FieldGroup group, List constraints)
+ {
+ this.name = name;
+ this.label = label;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.binding = binding;
+ this.protectedField = protectedField;
+ this.group = group;
+
+ this.dataType = dataType;
+ this.mandatory = mandatory;
+ this.repeats = repeats;
+ this.constraints = constraints;
+ }
+
+ /**
+ * Returns the dataType for the property, this is a value from the
+ * Alfresco data dictionary i.e. d:text, d:int etc.
+ *
+ * @return The field's data type
+ */
+ public String getDataType()
+ {
+ return this.dataType;
+ }
+
+ /**
+ * Determines if the property is mandatory
+ *
+ * @return true if the field is mandatory
+ */
+ public boolean isMandatory()
+ {
+ return this.mandatory;
+ }
+
+ /**
+ * Determines if the property can contain multiple values
+ *
+ * @return true if the field can contain multiple values
+ */
+ public boolean isRepeating()
+ {
+ return this.repeats;
+ }
+
+ /**
+ * Returns a list of constraints the property may have
+ *
+ * @return List of FieldContstraint objects or null if there are
+ * no constraints for the field
+ */
+ public List getConstraints()
+ {
+ return this.constraints;
+ }
+
+ /**
+ * Represents a constraint on a property field
+ */
+ public class FieldConstraint
+ {
+ protected String name;
+ protected Map params;
+
+ /**
+ * Constructs a FieldConstraint
+ *
+ * @param name The name of the constraint
+ * @param params Map of parameters for the constraint
+ */
+ public FieldConstraint(String name, Map params)
+ {
+ super();
+ this.name = name;
+ this.params = params;
+ }
+
+ /**
+ * Returns the name of the constraint
+ *
+ * @return The constraint name
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * Returns the parameters for the constraint
+ *
+ * @return Map of parameters for the constraint or null if
+ * there are no parameters
+ */
+ public Map getParams()
+ {
+ return this.params;
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
index 13a2872f7f..eadc8c12ad 100644
--- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
+++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
@@ -27,6 +27,7 @@ package org.alfresco.repo.service;
import java.util.Collection;
import org.alfresco.mbeans.VirtServerRegistry;
+import org.alfresco.repo.forms.FormService;
import org.alfresco.repo.site.SiteService;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
@@ -458,22 +459,32 @@ public class ServiceDescriptorRegistry
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getDeploymentService()
*/
- public DeploymentService getDeploymentService() {
+ public DeploymentService getDeploymentService()
+ {
return (DeploymentService) getService(DEPLOYMENT_SERVICE);
-
}
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getWebProjectService()
*/
- public WebProjectService getWebProjectService() {
+ public WebProjectService getWebProjectService()
+ {
return (WebProjectService)getService(WEBPROJECT_SERVICE);
}
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getSandboxService()
*/
- public SandboxService getSandboxService() {
+ public SandboxService getSandboxService()
+ {
return (SandboxService)getService(SANDBOX_SERVICE);
}
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.ServiceRegistry#getFormService()
+ */
+ public FormService getFormService()
+ {
+ return (FormService)getService(FORM_SERVICE);
+ }
}
diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java
index e5343ef4df..8a9bfbd316 100644
--- a/source/java/org/alfresco/service/ServiceRegistry.java
+++ b/source/java/org/alfresco/service/ServiceRegistry.java
@@ -27,6 +27,7 @@ package org.alfresco.service;
import java.util.Collection;
import org.alfresco.mbeans.VirtServerRegistry;
+import org.alfresco.repo.forms.FormService;
import org.alfresco.repo.site.SiteService;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.action.ActionService;
@@ -131,6 +132,7 @@ public interface ServiceRegistry
static final QName DEPLOYMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DeploymentService");
static final QName WEBPROJECT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WebProjectService");
static final QName SANDBOX_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SandboxService");
+ static final QName FORM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FormService");
/**
* Get the list of services provided by the Repository
@@ -438,4 +440,11 @@ public interface ServiceRegistry
*/
@NotAuditable
SandboxService getSandboxService();
+
+ /**
+ * Get the form service (or null if one is not provided)
+ * @return
+ */
+ @NotAuditable
+ FormService getFormService();
}