mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.1 to HEAD
6338: Some WCM-435. 6344: Fix for AWC-1452 (dialog close navigation issue) 6345: Fix for AR-1611 and other related CIFS and NFS fixes 6346: Minor javadoc fix for ReplicatingContentStore 6347: Handle exceptions arising from UserTransaction.begin(). 6348: Many WCM fixes in one Conflicts resolved on faces-config-beans.xml git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -64,6 +64,7 @@ public class FormImpl
|
||||
private static final Log LOGGER = LogFactory.getLog(FormImpl.class);
|
||||
|
||||
private final NodeRef folderNodeRef;
|
||||
protected final FormsService formsService;
|
||||
private transient Map<String, RenderingEngineTemplate> renderingEngineTemplates;
|
||||
|
||||
private final static LinkedList<FormProcessor> PROCESSORS =
|
||||
@@ -73,9 +74,25 @@ public class FormImpl
|
||||
FormImpl.PROCESSORS.add(new XFormsProcessor());
|
||||
}
|
||||
|
||||
public FormImpl(final NodeRef folderNodeRef)
|
||||
protected FormImpl(final NodeRef folderNodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
if (folderNodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
if (!nodeService.hasAspect(folderNodeRef, WCMAppModel.ASPECT_FORM))
|
||||
{
|
||||
throw new IllegalArgumentException("node " + folderNodeRef +
|
||||
" does not have aspect " + WCMAppModel.ASPECT_FORM);
|
||||
}
|
||||
this.folderNodeRef = folderNodeRef;
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -304,7 +321,7 @@ public class FormImpl
|
||||
final NodeRef renditionPropertiesNodeRef = assoc2.getChildRef();
|
||||
|
||||
final RenderingEngineTemplate ret =
|
||||
new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef);
|
||||
new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef, this.formsService);
|
||||
LOGGER.debug("loaded rendering engine template " + ret);
|
||||
result.put(ret.getName(), ret);
|
||||
}
|
||||
|
@@ -48,26 +48,41 @@ import org.xml.sax.SAXException;
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class FormInstanceDataImpl
|
||||
/* package */ class FormInstanceDataImpl
|
||||
implements FormInstanceData
|
||||
{
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final FormsService formsService;
|
||||
|
||||
public FormInstanceDataImpl(final NodeRef nodeRef)
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
if (!nodeService.hasAspect(nodeRef, 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;
|
||||
}
|
||||
|
||||
public FormInstanceDataImpl(final int version, final String avmPath)
|
||||
/* package */ FormInstanceDataImpl(final int version,
|
||||
final String avmPath,
|
||||
final FormsService formsService)
|
||||
{
|
||||
this(AVMNodeConverter.ToNodeRef(version, avmPath));
|
||||
this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService);
|
||||
}
|
||||
|
||||
/** the name of this rendition */
|
||||
@@ -106,7 +121,7 @@ public class FormInstanceDataImpl
|
||||
final String parentFormName = this.getParentFormName();
|
||||
try
|
||||
{
|
||||
return FormsService.getInstance().getForm(parentFormName);
|
||||
return this.formsService.getForm(parentFormName);
|
||||
}
|
||||
catch (FormNotFoundException fnfe)
|
||||
{
|
||||
@@ -194,7 +209,8 @@ public class FormInstanceDataImpl
|
||||
{
|
||||
if (avmService.lookup(-1, storeName + ':' + (String)path) != null)
|
||||
{
|
||||
final Rendition r = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path));
|
||||
final Rendition r = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, storeName + ':' + (String)path),
|
||||
this.formsService);
|
||||
if (r.getRenderingEngineTemplate() != null)
|
||||
{
|
||||
result.add(r);
|
||||
|
@@ -107,4 +107,14 @@ public class FormNotFoundException
|
||||
this.webProject = webProject;
|
||||
this.fid = fid;
|
||||
}
|
||||
|
||||
public String getFormName()
|
||||
{
|
||||
return this.formName;
|
||||
}
|
||||
|
||||
public WebProject getWebProject()
|
||||
{
|
||||
return this.webProject;
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,8 @@
|
||||
* 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" */
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.*;
|
||||
@@ -58,6 +59,7 @@ import org.alfresco.util.ISO9075;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.bean.wcm.WebProject;
|
||||
import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -76,10 +78,6 @@ public final class FormsService
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(FormsService.class);
|
||||
|
||||
/** the single instance initialized using spring */
|
||||
private static FormsService INSTANCE;
|
||||
|
||||
|
||||
private static final RenderingEngine[] RENDERING_ENGINES = new RenderingEngine[]
|
||||
{
|
||||
new FreeMarkerRenderingEngine(),
|
||||
@@ -104,16 +102,8 @@ public final class FormsService
|
||||
this.nodeService = nodeService;
|
||||
this.namespaceService = namespaceService;
|
||||
this.searchService = searchService;
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
/** Provides the forms service instance, loads config if necessary */
|
||||
public static FormsService getInstance()
|
||||
{
|
||||
return FormsService.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides all registered rendering engines.
|
||||
*/
|
||||
@@ -213,24 +203,9 @@ public final class FormsService
|
||||
public Form getForm(final String name)
|
||||
throws FormNotFoundException
|
||||
{
|
||||
final SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(Repository.getStoreRef());
|
||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp.setQuery("ASPECT:\"" + WCMAppModel.ASPECT_FORM +
|
||||
"\" AND QNAME:\"cm:" + ISO9075.encode(QName.createValidLocalName(name)) + "\"");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("running query [" + sp.getQuery() + "]");
|
||||
final ResultSet rs = this.searchService.query(sp);
|
||||
NodeRef result = null;
|
||||
for (ResultSetRow row : rs)
|
||||
{
|
||||
final NodeRef nr = row.getNodeRef();
|
||||
if (this.nodeService.getProperty(nr, ContentModel.PROP_NAME).equals(name))
|
||||
{
|
||||
result = nr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final NodeRef result = this.nodeService.getChildByName(this.getContentFormsNodeRef(),
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
name);
|
||||
if (result == null)
|
||||
{
|
||||
throw new FormNotFoundException(name);
|
||||
@@ -251,9 +226,47 @@ public final class FormsService
|
||||
{
|
||||
throw new IllegalArgumentException("node " + nodeRef + " is not a form");
|
||||
}
|
||||
final Form result = new FormImpl(nodeRef);
|
||||
final Form result = new FormImpl(nodeRef, this);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("loaded form " + result + " for noderef " + nodeRef);
|
||||
return result;
|
||||
}
|
||||
|
||||
public FormInstanceData getFormInstanceData(final int version, final String avmPath)
|
||||
{
|
||||
return this.getFormInstanceData(AVMNodeConverter.ToNodeRef(version, avmPath));
|
||||
}
|
||||
|
||||
public FormInstanceData getFormInstanceData(final NodeRef nodeRef)
|
||||
{
|
||||
final String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
||||
final WebProject webProject = new WebProject(avmPath);
|
||||
return new FormInstanceDataImpl(nodeRef, this)
|
||||
{
|
||||
@Override
|
||||
public Form getForm()
|
||||
throws FormNotFoundException
|
||||
{
|
||||
final Form f = super.getForm();
|
||||
try
|
||||
{
|
||||
return webProject.getForm(f.getName());
|
||||
}
|
||||
catch (FormNotFoundException fnfne)
|
||||
{
|
||||
throw new FormNotFoundException(f, webProject, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Rendition getRendition(final int version, final String avmPath)
|
||||
{
|
||||
return this.getRendition(AVMNodeConverter.ToNodeRef(version, avmPath));
|
||||
}
|
||||
|
||||
public Rendition getRendition(final NodeRef nodeRef)
|
||||
{
|
||||
return new RenditionImpl(nodeRef, this);
|
||||
}
|
||||
}
|
||||
|
@@ -90,9 +90,11 @@ public class RenderingEngineTemplateImpl
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final NodeRef renditionPropertiesNodeRef;
|
||||
private final FormsService formsService;
|
||||
|
||||
protected RenderingEngineTemplateImpl(final NodeRef nodeRef,
|
||||
final NodeRef renditionPropertiesNodeRef)
|
||||
final NodeRef renditionPropertiesNodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
@@ -102,8 +104,13 @@ public class RenderingEngineTemplateImpl
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.nodeRef = nodeRef;
|
||||
this.renditionPropertiesNodeRef = renditionPropertiesNodeRef;
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@@ -162,8 +169,7 @@ public class RenderingEngineTemplateImpl
|
||||
final String renderingEngineName = (String)
|
||||
nodeService.getProperty(this.nodeRef,
|
||||
WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME);
|
||||
final FormsService fs = FormsService.getInstance();
|
||||
return fs.getRenderingEngine(renderingEngineName);
|
||||
return this.formsService.getRenderingEngine(renderingEngineName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,17 +268,18 @@ public class RenderingEngineTemplateImpl
|
||||
AVMNodeConverter.SplitBase(renditionAvmPath)[1]);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " + renditionAvmPath);
|
||||
|
||||
avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
|
||||
avmService.addAspect(renditionAvmPath, ContentModel.ASPECT_TITLED);
|
||||
avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_RENDITION);
|
||||
}
|
||||
|
||||
final Rendition result = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, renditionAvmPath));
|
||||
final Rendition result = new RenditionImpl(AVMNodeConverter.ToNodeRef(-1, renditionAvmPath),
|
||||
this.formsService);
|
||||
this.render(formInstanceData, result);
|
||||
|
||||
if (!isRegenerate)
|
||||
{
|
||||
avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
|
||||
avmService.addAspect(renditionAvmPath, ContentModel.ASPECT_TITLED);
|
||||
avmService.addAspect(renditionAvmPath, WCMAppModel.ASPECT_RENDITION);
|
||||
|
||||
final PropertyValue pv =
|
||||
avmService.getNodeProperty(-1, formInstanceData.getPath(), WCMAppModel.PROP_RENDITIONS);
|
||||
final Collection<Serializable> renditions = (pv == null
|
||||
|
@@ -51,27 +51,41 @@ import org.xml.sax.SAXException;
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class RenditionImpl
|
||||
/* package */ class RenditionImpl
|
||||
implements Rendition
|
||||
{
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final FormsService formsService;
|
||||
private transient RenderingEngineTemplate renderingEngineTemplate;
|
||||
|
||||
public RenditionImpl(final NodeRef nodeRef)
|
||||
/* package */ RenditionImpl(final NodeRef nodeRef, final FormsService formsService)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
if (!nodeService.hasAspect(nodeRef, WCMAppModel.ASPECT_RENDITION))
|
||||
{
|
||||
throw new IllegalArgumentException("node " + nodeRef +
|
||||
" does not have aspect " + WCMAppModel.ASPECT_RENDITION);
|
||||
}
|
||||
this.nodeRef = nodeRef;
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
public RenditionImpl(final int version, final String avmPath)
|
||||
/* package */ RenditionImpl(final int version,
|
||||
final String avmPath,
|
||||
final FormsService formsService)
|
||||
{
|
||||
this(AVMNodeConverter.ToNodeRef(version, avmPath));
|
||||
this(AVMNodeConverter.ToNodeRef(version, avmPath), formsService);
|
||||
}
|
||||
|
||||
/** the name of this rendition */
|
||||
@@ -115,7 +129,7 @@ public class RenditionImpl
|
||||
{
|
||||
throw new FileNotFoundException("unable to find primary form instance data " + path);
|
||||
}
|
||||
return new FormInstanceDataImpl(-1, path);
|
||||
return this.formsService.getFormInstanceData(-1, path);
|
||||
}
|
||||
|
||||
/** the rendering engine template that generated this rendition */
|
||||
@@ -159,7 +173,7 @@ public class RenditionImpl
|
||||
this.getPath());
|
||||
return null;
|
||||
}
|
||||
this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef);
|
||||
this.renderingEngineTemplate = new RenderingEngineTemplateImpl(retNodeRef, rpNodeRef, this.formsService);
|
||||
}
|
||||
return this.renderingEngineTemplate;
|
||||
}
|
||||
|
@@ -87,6 +87,7 @@ public class Schema2XForms
|
||||
private final String action;
|
||||
private final SubmitMethod submitMethod;
|
||||
private final String base;
|
||||
private final Stack parentStack = new Stack();
|
||||
|
||||
/**
|
||||
* generic counter -> replaced by an hashMap with:
|
||||
@@ -1144,6 +1145,8 @@ public class Schema2XForms
|
||||
final ResourceBundle resourceBundle)
|
||||
throws FormBuilderException
|
||||
{
|
||||
LOGGER.debug("adding element " + elementDecl + " at path " + pathToRoot);
|
||||
|
||||
XSTypeDefinition controlType = elementDecl.getTypeDefinition();
|
||||
if (controlType == null)
|
||||
{
|
||||
@@ -1659,7 +1662,14 @@ public class Schema2XForms
|
||||
final String path = (pathToRoot.length() == 0
|
||||
? elementName
|
||||
: pathToRoot + "/" + elementName);
|
||||
LOGGER.debug("addElement to group " + elementName + " at " + path);
|
||||
LOGGER.debug("addElement to group " + elementName + " at " + path + " parentStack " + this.parentStack);
|
||||
|
||||
if (this.parentStack.contains(element))
|
||||
{
|
||||
throw new FormBuilderException("recursion detected at element " + elementName);
|
||||
}
|
||||
LOGGER.debug("pushing element " + element + " onto parent stack");
|
||||
this.parentStack.push(element);
|
||||
|
||||
final Element newDefaultInstanceElement = xformsDocument.createElement(elementName);
|
||||
if (element.getConstraintType() != XSConstants.VC_NONE)
|
||||
@@ -1677,6 +1687,8 @@ public class Schema2XForms
|
||||
path,
|
||||
occurs,
|
||||
resourceBundle);
|
||||
LOGGER.debug("popped element " + this.parentStack.pop() + " from parent stack");
|
||||
|
||||
|
||||
// final SchemaUtil.Occurrence occurs = SchemaUtil.getOccurrence(element);
|
||||
LOGGER.debug("adding " + (occurs.maximum == 1
|
||||
|
@@ -160,6 +160,7 @@ public class Schema2XFormsTest
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.debug("got expected exception " + fbe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +182,31 @@ public class Schema2XFormsTest
|
||||
// }
|
||||
}
|
||||
|
||||
public void testRecursive()
|
||||
throws Exception
|
||||
{
|
||||
final Document schemaDocument = this.loadTestResourceDocument("xforms/unit-tests/automated/recursive-test.xsd");
|
||||
Document xformsDocument = this.buildXForm(null, schemaDocument, "non-recursive-test");
|
||||
try
|
||||
{
|
||||
xformsDocument = this.buildXForm(null, schemaDocument, "recursive-test");
|
||||
fail("expected failure creating xform with recursive element definition root element recursive-test in schema " + XMLUtil.toString(schemaDocument));
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.debug("got expected exception " + fbe.getMessage());
|
||||
}
|
||||
try
|
||||
{
|
||||
xformsDocument = this.buildXForm(null, schemaDocument, "nested-recursive-test");
|
||||
fail("expected failure creating xform with recursive element definition root element nested-recursive-test in schema " + XMLUtil.toString(schemaDocument));
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.debug("got expected exception " + fbe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRepeatProperties(final Document xformsDocument, final String nodeset, final SchemaUtil.Occurrence o)
|
||||
{
|
||||
final Element[] bindElements = this.resolveBind(xformsDocument, nodeset);
|
||||
|
Reference in New Issue
Block a user