mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge of all UI clustering changes originally applied to 2.2
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8292 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -50,6 +50,7 @@ import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.bean.wcm.AVMWorkflowUtil;
|
||||
@@ -63,13 +64,14 @@ import freemarker.ext.dom.NodeModel;
|
||||
import freemarker.template.SimpleDate;
|
||||
import freemarker.template.SimpleHash;
|
||||
|
||||
public class FormImpl
|
||||
implements Form
|
||||
public class FormImpl implements Form
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(FormImpl.class);
|
||||
|
||||
private final NodeRef folderNodeRef;
|
||||
protected final FormsService formsService;
|
||||
private transient FormsService formsService;
|
||||
private transient Map<String, RenderingEngineTemplate> renderingEngineTemplates;
|
||||
|
||||
private final static LinkedList<FormProcessor> PROCESSORS =
|
||||
@@ -100,6 +102,15 @@ public class FormImpl
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
protected FormsService getFormsService()
|
||||
{
|
||||
if (formsService == null)
|
||||
{
|
||||
formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService");
|
||||
}
|
||||
return formsService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
@@ -340,7 +351,7 @@ public class FormImpl
|
||||
final NodeRef renditionPropertiesNodeRef = assoc2.getChildRef();
|
||||
|
||||
final RenderingEngineTemplate ret =
|
||||
new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef, this.formsService);
|
||||
new RenderingEngineTemplateImpl(retNodeRef, renditionPropertiesNodeRef, this.getFormsService());
|
||||
LOGGER.debug("loaded rendering engine template " + ret);
|
||||
result.put(ret.getName(), ret);
|
||||
}
|
||||
|
@@ -1,114 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
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
|
||||
{
|
||||
|
||||
private final RenderingEngineTemplate ret;
|
||||
private final Rendition r;
|
||||
private final Exception e;
|
||||
|
||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||
final Rendition r)
|
||||
{
|
||||
this.ret = ret;
|
||||
this.r = r;
|
||||
this.e = null;
|
||||
}
|
||||
|
||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||
final Exception e)
|
||||
{
|
||||
this.ret = ret;
|
||||
this.e = e;
|
||||
this.r = null;
|
||||
}
|
||||
|
||||
public RenderingEngineTemplate getRenderingEngineTemplate()
|
||||
{
|
||||
return this.ret;
|
||||
}
|
||||
|
||||
public Rendition getRendition()
|
||||
{
|
||||
return this.r;
|
||||
}
|
||||
|
||||
public Exception getException()
|
||||
{
|
||||
return this.e;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** 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<RegenerateResult> regenerateRenditions()
|
||||
throws FormNotFoundException;
|
||||
|
||||
/** returns all renditions of this form instance data */
|
||||
public List<Rendition> getRenditions();
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.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 Rendition r;
|
||||
private final Exception e;
|
||||
|
||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||
final Rendition r)
|
||||
{
|
||||
this.ret = ret;
|
||||
this.r = r;
|
||||
this.e = null;
|
||||
}
|
||||
|
||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||
final Exception e)
|
||||
{
|
||||
this.ret = ret;
|
||||
this.e = e;
|
||||
this.r = null;
|
||||
}
|
||||
|
||||
public RenderingEngineTemplate getRenderingEngineTemplate()
|
||||
{
|
||||
return this.ret;
|
||||
}
|
||||
|
||||
public Rendition getRendition()
|
||||
{
|
||||
return this.r;
|
||||
}
|
||||
|
||||
public Exception getException()
|
||||
{
|
||||
return this.e;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** 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<RegenerateResult> regenerateRenditions()
|
||||
throws FormNotFoundException;
|
||||
|
||||
/** returns all renditions of this form instance data */
|
||||
public List<Rendition> getRenditions();
|
||||
}
|
||||
|
@@ -39,10 +39,13 @@ import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -57,10 +60,12 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
/* package */ class FormInstanceDataImpl implements FormInstanceData
|
||||
{
|
||||
private static final long serialVersionUID = -7806221587661854013L;
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final FormsService formsService;
|
||||
private transient FormsService formsService;
|
||||
|
||||
/* package */ FormInstanceDataImpl(final NodeRef nodeRef,
|
||||
final FormsService formsService)
|
||||
@@ -91,6 +96,15 @@ import org.xml.sax.SAXException;
|
||||
{
|
||||
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()
|
||||
@@ -134,11 +148,11 @@ import org.xml.sax.SAXException;
|
||||
// TODO - forms should be identified by nodeRef rather than name (which can be non-unique)
|
||||
if (getNodeRef().getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
{
|
||||
return this.formsService.getWebForm(parentFormName);
|
||||
return this.getFormsService().getWebForm(parentFormName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.formsService.getForm(parentFormName);
|
||||
return this.getFormsService().getForm(parentFormName);
|
||||
}
|
||||
}
|
||||
catch (FormNotFoundException fnfe)
|
||||
@@ -236,7 +250,7 @@ import org.xml.sax.SAXException;
|
||||
{
|
||||
final Rendition r = new RenditionImpl(-1,
|
||||
storeName + ':' + (String)path,
|
||||
this.formsService);
|
||||
this.getFormsService());
|
||||
try
|
||||
{
|
||||
if (!this.equals(r.getPrimaryFormInstanceData()))
|
||||
|
@@ -1,114 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
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
|
||||
{
|
||||
|
||||
/** 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
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.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;
|
||||
}
|
||||
|
@@ -23,55 +23,34 @@
|
||||
*/
|
||||
package org.alfresco.web.forms;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.policy.Behaviour;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.search.impl.lucene.QueryParser;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.TemplateService;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
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;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Provides management of forms.
|
||||
@@ -79,7 +58,6 @@ import org.xml.sax.SAXException;
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public final class FormsService
|
||||
implements Serializable
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(FormsService.class);
|
||||
|
||||
|
@@ -1,304 +1,304 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.alfresco.service.cmr.repository.*;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.apache.commons.jxpath.JXPathContext;
|
||||
import org.apache.commons.jxpath.Pointer;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
import org.chiba.xml.events.XFormsEventNames;
|
||||
import org.chiba.xml.events.XMLEvent;
|
||||
import org.chiba.xml.xforms.ChibaBean;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
import org.chiba.xml.xforms.XFormsElement;
|
||||
import org.chiba.xml.events.DOMEventNames;
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.events.*;
|
||||
import org.xml.sax.*;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.model.*;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.util.TestWithUserUtils;
|
||||
import org.apache.shale.test.mock.*;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
|
||||
/**
|
||||
* JUnit tests to exercise parts of the forms codebase
|
||||
*
|
||||
* @author ariel backenroth
|
||||
*/
|
||||
public class FormsTest
|
||||
extends BaseSpringTest
|
||||
{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static class MockForm
|
||||
extends FormImpl
|
||||
{
|
||||
|
||||
MockForm(final NodeRef folderNodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
super(folderNodeRef, formsService);
|
||||
}
|
||||
|
||||
|
||||
public void setOutputPathPattern(final String opp)
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
nodeService.setProperty(this.getNodeRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN, opp);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final static Log LOGGER = LogFactory.getLog(FormsTest.class);
|
||||
private final static String WEB_CLIENT_APPLICATION_CONTEXT =
|
||||
"classpath:alfresco/web-client-application-context.xml";
|
||||
|
||||
private NodeService nodeService;
|
||||
private FormsService formsService;
|
||||
private MockForm mockForm;
|
||||
|
||||
protected void onSetUpInTransaction()
|
||||
throws Exception
|
||||
{
|
||||
System.err.println("onSetUpInTransaction");
|
||||
super.onSetUpInTransaction();
|
||||
this.nodeService = (NodeService)super.applicationContext.getBean("dbNodeService");
|
||||
assertNotNull(this.nodeService);
|
||||
final FileFolderService fileFolderService = (FileFolderService)
|
||||
super.applicationContext.getBean("fileFolderService");
|
||||
assertNotNull(fileFolderService);
|
||||
this.formsService = (FormsService)super.applicationContext.getBean("FormsService");
|
||||
assertNotNull(this.formsService);
|
||||
final AuthenticationService authenticationService = (AuthenticationService)
|
||||
applicationContext.getBean("authenticationService");
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
final MutableAuthenticationDao authenticationDAO = (MutableAuthenticationDao)
|
||||
applicationContext.getBean("authenticationDao");
|
||||
|
||||
// Create a workspace that contains the 'live' nodes
|
||||
final StoreRef testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"Test_" + System.currentTimeMillis());
|
||||
|
||||
// Get a reference to the root node
|
||||
final NodeRef rootNodeRef = this.nodeService.getRootNode(testStoreRef);
|
||||
|
||||
// Create an authenticate the user
|
||||
if(!authenticationDAO.userExists("admin"))
|
||||
{
|
||||
authenticationService.createAuthentication("admin", "admin".toCharArray());
|
||||
}
|
||||
|
||||
TestWithUserUtils.authenticateUser("admin",
|
||||
"admin",
|
||||
rootNodeRef,
|
||||
authenticationService);
|
||||
|
||||
// set up a faces context
|
||||
final MockExternalContext ec = new MockExternalContext(new MockServletContext(),
|
||||
new MockHttpServletRequest(),
|
||||
new MockHttpServletResponse());
|
||||
final StaticWebApplicationContext ac = new StaticWebApplicationContext();
|
||||
ac.setParent(this.applicationContext);
|
||||
this.applicationContext = ac;
|
||||
ec.getApplicationMap().put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
|
||||
this.applicationContext);
|
||||
new MockFacesContext(ec);
|
||||
|
||||
|
||||
final FileInfo folderInfo =
|
||||
fileFolderService.create(rootNodeRef,
|
||||
"test_form",
|
||||
WCMAppModel.TYPE_FORMFOLDER);
|
||||
final HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
this.nodeService.addAspect(folderInfo.getNodeRef(),
|
||||
WCMAppModel.ASPECT_FORM,
|
||||
props);
|
||||
this.mockForm = new MockForm(folderInfo.getNodeRef(), this.formsService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations()
|
||||
{
|
||||
return (String[])ArrayUtils.add(super.getConfigLocations(),
|
||||
WEB_CLIENT_APPLICATION_CONTEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurableApplicationContext loadContext(Object key)
|
||||
throws Exception
|
||||
{
|
||||
return new ClassPathXmlApplicationContext((String[])key);
|
||||
}
|
||||
|
||||
public void testOutputPathPatternForFormInstanceData()
|
||||
throws Exception
|
||||
{
|
||||
class OutputPathPatternTest
|
||||
{
|
||||
public final String expected;
|
||||
public final String pattern;
|
||||
public final Document xml;
|
||||
public final String name;
|
||||
public final String parentAVMPath;
|
||||
public final String webapp;
|
||||
|
||||
public OutputPathPatternTest(final String expected,
|
||||
final String pattern,
|
||||
final Document xml,
|
||||
final String name,
|
||||
final String parentAVMPath,
|
||||
final String webapp)
|
||||
{
|
||||
this.expected = expected;
|
||||
this.pattern = pattern;
|
||||
this.xml = xml;
|
||||
this.name = name;
|
||||
this.parentAVMPath = parentAVMPath;
|
||||
this.webapp = webapp;
|
||||
}
|
||||
}
|
||||
|
||||
final OutputPathPatternTest[] opps = new OutputPathPatternTest[] {
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/foo.xml",
|
||||
"/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
|
||||
"/${webapp}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
|
||||
"/${webapp}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/another_webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir1/dir2/foo.xml",
|
||||
"/${webapp}/${cwd}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/another_webapp/dir1/dir2",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/" + Calendar.getInstance().get(Calendar.YEAR) + "_foo.xml",
|
||||
"${date?string('yyyy')}_${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml.root_tag.name}.xml",
|
||||
XMLUtil.parse("<root_tag><name>foo</name></root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/07.xml",
|
||||
"${xml.root_tag.date?date('yyyy-MM-dd')?string('MM')}.xml",
|
||||
XMLUtil.parse("<root_tag><date>1776-07-04</date></root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml['foons:root_tag/foons:name']}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml[\"/*[name()='foons:root_tag']/*[name()='foons:name']\"]}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml['/foons:root_tag/foons:name']}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest(null,
|
||||
"${xml.root_tag.name}",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp")
|
||||
};
|
||||
for (final OutputPathPatternTest oppt : opps)
|
||||
{
|
||||
this.mockForm.setOutputPathPattern(oppt.pattern);
|
||||
if (oppt.expected == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.mockForm.getOutputPathForFormInstanceData(oppt.xml,
|
||||
oppt.name,
|
||||
oppt.parentAVMPath,
|
||||
oppt.webapp);
|
||||
fail("expected pattern " + oppt.pattern + " to fail");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// expected failure
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assertEquals(oppt.pattern + " failed",
|
||||
oppt.expected,
|
||||
this.mockForm.getOutputPathForFormInstanceData(oppt.xml,
|
||||
oppt.name,
|
||||
oppt.parentAVMPath,
|
||||
oppt.webapp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.alfresco.service.cmr.repository.*;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
import org.apache.commons.jxpath.JXPathContext;
|
||||
import org.apache.commons.jxpath.Pointer;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
import org.chiba.xml.events.XFormsEventNames;
|
||||
import org.chiba.xml.events.XMLEvent;
|
||||
import org.chiba.xml.xforms.ChibaBean;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
import org.chiba.xml.xforms.XFormsElement;
|
||||
import org.chiba.xml.events.DOMEventNames;
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.events.*;
|
||||
import org.xml.sax.*;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.model.*;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.util.TestWithUserUtils;
|
||||
import org.apache.shale.test.mock.*;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
|
||||
/**
|
||||
* JUnit tests to exercise parts of the forms codebase
|
||||
*
|
||||
* @author ariel backenroth
|
||||
*/
|
||||
public class FormsTest
|
||||
extends BaseSpringTest
|
||||
{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static class MockForm
|
||||
extends FormImpl
|
||||
{
|
||||
|
||||
MockForm(final NodeRef folderNodeRef,
|
||||
final FormsService formsService)
|
||||
{
|
||||
super(folderNodeRef, formsService);
|
||||
}
|
||||
|
||||
|
||||
public void setOutputPathPattern(final String opp)
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
nodeService.setProperty(this.getNodeRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN, opp);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final static Log LOGGER = LogFactory.getLog(FormsTest.class);
|
||||
private final static String WEB_CLIENT_APPLICATION_CONTEXT =
|
||||
"classpath:alfresco/web-client-application-context.xml";
|
||||
|
||||
private NodeService nodeService;
|
||||
private FormsService formsService;
|
||||
private MockForm mockForm;
|
||||
|
||||
protected void onSetUpInTransaction()
|
||||
throws Exception
|
||||
{
|
||||
System.err.println("onSetUpInTransaction");
|
||||
super.onSetUpInTransaction();
|
||||
this.nodeService = (NodeService)super.applicationContext.getBean("dbNodeService");
|
||||
assertNotNull(this.nodeService);
|
||||
final FileFolderService fileFolderService = (FileFolderService)
|
||||
super.applicationContext.getBean("fileFolderService");
|
||||
assertNotNull(fileFolderService);
|
||||
this.formsService = (FormsService)super.applicationContext.getBean("FormsService");
|
||||
assertNotNull(this.formsService);
|
||||
final AuthenticationService authenticationService = (AuthenticationService)
|
||||
applicationContext.getBean("authenticationService");
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
final MutableAuthenticationDao authenticationDAO = (MutableAuthenticationDao)
|
||||
applicationContext.getBean("authenticationDao");
|
||||
|
||||
// Create a workspace that contains the 'live' nodes
|
||||
final StoreRef testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE,
|
||||
"Test_" + System.currentTimeMillis());
|
||||
|
||||
// Get a reference to the root node
|
||||
final NodeRef rootNodeRef = this.nodeService.getRootNode(testStoreRef);
|
||||
|
||||
// Create an authenticate the user
|
||||
if(!authenticationDAO.userExists("admin"))
|
||||
{
|
||||
authenticationService.createAuthentication("admin", "admin".toCharArray());
|
||||
}
|
||||
|
||||
TestWithUserUtils.authenticateUser("admin",
|
||||
"admin",
|
||||
rootNodeRef,
|
||||
authenticationService);
|
||||
|
||||
// set up a faces context
|
||||
final MockExternalContext ec = new MockExternalContext(new MockServletContext(),
|
||||
new MockHttpServletRequest(),
|
||||
new MockHttpServletResponse());
|
||||
final StaticWebApplicationContext ac = new StaticWebApplicationContext();
|
||||
ac.setParent(this.applicationContext);
|
||||
this.applicationContext = ac;
|
||||
ec.getApplicationMap().put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
|
||||
this.applicationContext);
|
||||
new MockFacesContext(ec);
|
||||
|
||||
|
||||
final FileInfo folderInfo =
|
||||
fileFolderService.create(rootNodeRef,
|
||||
"test_form",
|
||||
WCMAppModel.TYPE_FORMFOLDER);
|
||||
final HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
this.nodeService.addAspect(folderInfo.getNodeRef(),
|
||||
WCMAppModel.ASPECT_FORM,
|
||||
props);
|
||||
this.mockForm = new MockForm(folderInfo.getNodeRef(), this.formsService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations()
|
||||
{
|
||||
return (String[])ArrayUtils.add(super.getConfigLocations(),
|
||||
WEB_CLIENT_APPLICATION_CONTEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurableApplicationContext loadContext(Object key)
|
||||
throws Exception
|
||||
{
|
||||
return new ClassPathXmlApplicationContext((String[])key);
|
||||
}
|
||||
|
||||
public void testOutputPathPatternForFormInstanceData()
|
||||
throws Exception
|
||||
{
|
||||
class OutputPathPatternTest
|
||||
{
|
||||
public final String expected;
|
||||
public final String pattern;
|
||||
public final Document xml;
|
||||
public final String name;
|
||||
public final String parentAVMPath;
|
||||
public final String webapp;
|
||||
|
||||
public OutputPathPatternTest(final String expected,
|
||||
final String pattern,
|
||||
final Document xml,
|
||||
final String name,
|
||||
final String parentAVMPath,
|
||||
final String webapp)
|
||||
{
|
||||
this.expected = expected;
|
||||
this.pattern = pattern;
|
||||
this.xml = xml;
|
||||
this.name = name;
|
||||
this.parentAVMPath = parentAVMPath;
|
||||
this.webapp = webapp;
|
||||
}
|
||||
}
|
||||
|
||||
final OutputPathPatternTest[] opps = new OutputPathPatternTest[] {
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/foo.xml",
|
||||
"/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
|
||||
"/${webapp}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
|
||||
"/${webapp}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/another_webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir1/dir2/foo.xml",
|
||||
"/${webapp}/${cwd}/${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/another_webapp/dir1/dir2",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/" + Calendar.getInstance().get(Calendar.YEAR) + "_foo.xml",
|
||||
"${date?string('yyyy')}_${name}.xml",
|
||||
XMLUtil.parse("<foo/>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml.root_tag.name}.xml",
|
||||
XMLUtil.parse("<root_tag><name>foo</name></root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/07.xml",
|
||||
"${xml.root_tag.date?date('yyyy-MM-dd')?string('MM')}.xml",
|
||||
XMLUtil.parse("<root_tag><date>1776-07-04</date></root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml['foons:root_tag/foons:name']}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml[\"/*[name()='foons:root_tag']/*[name()='foons:name']\"]}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
|
||||
"${xml['/foons:root_tag/foons:name']}.xml",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp"),
|
||||
new OutputPathPatternTest(null,
|
||||
"${xml.root_tag.name}",
|
||||
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
|
||||
"foo",
|
||||
"avmstore:/www/avm_webapps/webapp/dir",
|
||||
"webapp")
|
||||
};
|
||||
for (final OutputPathPatternTest oppt : opps)
|
||||
{
|
||||
this.mockForm.setOutputPathPattern(oppt.pattern);
|
||||
if (oppt.expected == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.mockForm.getOutputPathForFormInstanceData(oppt.xml,
|
||||
oppt.name,
|
||||
oppt.parentAVMPath,
|
||||
oppt.webapp);
|
||||
fail("expected pattern " + oppt.pattern + " to fail");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// expected failure
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assertEquals(oppt.pattern + " failed",
|
||||
oppt.expected,
|
||||
this.mockForm.getOutputPathForFormInstanceData(oppt.xml,
|
||||
oppt.name,
|
||||
oppt.parentAVMPath,
|
||||
oppt.webapp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,6 +61,7 @@ import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.URLEncoder;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -84,6 +85,8 @@ import freemarker.template.SimpleHash;
|
||||
public class RenderingEngineTemplateImpl
|
||||
implements RenderingEngineTemplate
|
||||
{
|
||||
private static final long serialVersionUID = -1656812676972437532L;
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(RenderingEngineTemplateImpl.class);
|
||||
|
||||
private static final DynamicNamespacePrefixResolver namespacePrefixResolver =
|
||||
@@ -100,7 +103,7 @@ public class RenderingEngineTemplateImpl
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final NodeRef renditionPropertiesNodeRef;
|
||||
private final FormsService formsService;
|
||||
private transient FormsService formsService;
|
||||
|
||||
protected RenderingEngineTemplateImpl(final NodeRef nodeRef,
|
||||
final NodeRef renditionPropertiesNodeRef,
|
||||
@@ -123,6 +126,15 @@ public class RenderingEngineTemplateImpl
|
||||
this.formsService = formsService;
|
||||
}
|
||||
|
||||
private FormsService getFormsService()
|
||||
{
|
||||
if (formsService == null)
|
||||
{
|
||||
formsService = (FormsService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "FormsService");
|
||||
}
|
||||
return formsService;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
final NodeService nodeService = this.getServiceRegistry().getNodeService();
|
||||
@@ -179,7 +191,7 @@ public class RenderingEngineTemplateImpl
|
||||
final String renderingEngineName = (String)
|
||||
nodeService.getProperty(this.nodeRef,
|
||||
WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME);
|
||||
return this.formsService.getRenderingEngine(renderingEngineName);
|
||||
return this.getFormsService().getRenderingEngine(renderingEngineName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +298,7 @@ public class RenderingEngineTemplateImpl
|
||||
|
||||
final Rendition result = new RenditionImpl(-1,
|
||||
renditionAvmPath,
|
||||
this.formsService);
|
||||
this.getFormsService());
|
||||
this.render(formInstanceData, result);
|
||||
|
||||
if (!isRegenerate)
|
||||
|
@@ -1,257 +1,271 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
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 Log LOGGER = LogFactory.getLog(RenditionImpl.class);
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final FormsService formsService;
|
||||
private transient RenderingEngineTemplate renderingEngineTemplate;
|
||||
|
||||
/* package */ RenditionImpl(final NodeRef nodeRef, final FormsService formsService)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
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)
|
||||
{
|
||||
this(AVMNodeConverter.ToNodeRef(version, avmPath), 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();
|
||||
return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1];
|
||||
}
|
||||
|
||||
/** the description of this rendition */
|
||||
public String getDescription()
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
|
||||
ContentModel.PROP_DESCRIPTION).getStringValue();
|
||||
}
|
||||
|
||||
public String getWebappRelativePath()
|
||||
{
|
||||
return AVMUtil.getWebappRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getSandboxRelativePath()
|
||||
{
|
||||
return AVMUtil.getSandboxRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public FormInstanceData getPrimaryFormInstanceData()
|
||||
throws FileNotFoundException
|
||||
{
|
||||
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) == null)
|
||||
{
|
||||
throw new FileNotFoundException("unable to find primary form instance data " + path);
|
||||
}
|
||||
return this.formsService.getFormInstanceData(-1, path);
|
||||
}
|
||||
|
||||
/** the rendering engine template that generated this rendition */
|
||||
public RenderingEngineTemplate getRenderingEngineTemplate()
|
||||
{
|
||||
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.formsService);
|
||||
}
|
||||
return this.renderingEngineTemplate;
|
||||
}
|
||||
|
||||
/** the node ref containing the contents of this rendition */
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
|
||||
}
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return AVMUtil.buildAssetUrl(this.getPath());
|
||||
}
|
||||
|
||||
public String getFileTypeImage()
|
||||
{
|
||||
return Utils.getFileTypeImage(this.getName(), false);
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
|
||||
final Pair<Integer, String> 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()));
|
||||
}
|
||||
|
||||
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() +
|
||||
"}");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2005-2007 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.web.forms;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
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;
|
||||
|
||||
/* package */ RenditionImpl(final NodeRef nodeRef, final FormsService formsService)
|
||||
{
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (formsService == null)
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
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)
|
||||
{
|
||||
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();
|
||||
return AVMNodeConverter.SplitBase(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond())[1];
|
||||
}
|
||||
|
||||
/** the description of this rendition */
|
||||
public String getDescription()
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||
return avmService.getNodeProperty(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond(),
|
||||
ContentModel.PROP_DESCRIPTION).getStringValue();
|
||||
}
|
||||
|
||||
public String getWebappRelativePath()
|
||||
{
|
||||
return AVMUtil.getWebappRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public String getSandboxRelativePath()
|
||||
{
|
||||
return AVMUtil.getSandboxRelativePath(this.getPath());
|
||||
}
|
||||
|
||||
public FormInstanceData getPrimaryFormInstanceData()
|
||||
throws FileNotFoundException
|
||||
{
|
||||
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) == null)
|
||||
{
|
||||
throw new FileNotFoundException("unable to find primary form instance data " + path);
|
||||
}
|
||||
return this.getFormsService().getFormInstanceData(-1, path);
|
||||
}
|
||||
|
||||
/** the rendering engine template that generated this rendition */
|
||||
public RenderingEngineTemplate getRenderingEngineTemplate()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/** the node ref containing the contents of this rendition */
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond();
|
||||
}
|
||||
|
||||
public String getUrl()
|
||||
{
|
||||
return AVMUtil.buildAssetUrl(this.getPath());
|
||||
}
|
||||
|
||||
public String getFileTypeImage()
|
||||
{
|
||||
return Utils.getFileTypeImage(this.getName(), false);
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
final AVMService avmService = this.getServiceRegistry().getAVMLockingAwareService();
|
||||
final Pair<Integer, String> 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()));
|
||||
}
|
||||
|
||||
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() +
|
||||
"}");
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ package org.alfresco.web.forms.xforms;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -53,7 +54,7 @@ import org.w3c.dom.ls.*;
|
||||
*
|
||||
* @author $Author: unl $
|
||||
*/
|
||||
public class Schema2XForms
|
||||
public class Schema2XForms implements Serializable
|
||||
{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -24,6 +24,7 @@
|
||||
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;
|
||||
@@ -40,7 +41,6 @@ import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
@@ -81,8 +81,9 @@ 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
|
||||
public class XFormsBean implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -7979077333882370784L;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -102,7 +103,7 @@ public class XFormsBean
|
||||
}
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
//make the XFormsBean available for this session
|
||||
final XFormsBean xforms = (XFormsBean)FacesHelper.getManagedBean(fc, "XFormsBean");
|
||||
final XFormsBean xforms = (XFormsBean)FacesHelper.getManagedBean(fc, BEAN_NAME);
|
||||
xforms.handleSubmit(instance);
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
@@ -114,14 +115,12 @@ public class XFormsBean
|
||||
*/
|
||||
class XFormsSession implements FormProcessor.Session
|
||||
{
|
||||
|
||||
private final Document formInstanceData;
|
||||
private final String formInstanceDataName;
|
||||
private final Form form;
|
||||
|
||||
private ChibaBean chibaBean;
|
||||
private final Schema2XForms schema2XForms;
|
||||
// private final Set<NodeRef> uploads = new HashSet<NodeRef>();
|
||||
private final List<XMLEvent> eventLog = new LinkedList<XMLEvent>();
|
||||
|
||||
public XFormsSession(final Document formInstanceData,
|
||||
@@ -170,15 +169,12 @@ public class XFormsBean
|
||||
private static final Log LOGGER = LogFactory.getLog(XFormsBean.class);
|
||||
|
||||
private XFormsSession xformsSession;
|
||||
private Schema2XFormsProperties schema2XFormsProperties;
|
||||
private transient Schema2XFormsProperties schema2XFormsProperties;
|
||||
private AVMBrowseBean avmBrowseBean;
|
||||
private AVMService avmService;
|
||||
private NavigationBean navigator;
|
||||
|
||||
public XFormsBean()
|
||||
{
|
||||
}
|
||||
|
||||
public static String BEAN_NAME = "XFormsBean";
|
||||
|
||||
/**
|
||||
* @param schema2XFormsProperties the schema2XFormsProperties to set.
|
||||
*/
|
||||
@@ -186,6 +182,16 @@ public class XFormsBean
|
||||
{
|
||||
this.schema2XFormsProperties = schema2XFormsProperties;
|
||||
}
|
||||
|
||||
protected Schema2XFormsProperties getSchema2XFormsProperties()
|
||||
{
|
||||
if (schema2XFormsProperties == null)
|
||||
{
|
||||
schema2XFormsProperties = (Schema2XFormsProperties)FacesHelper.getManagedBean(
|
||||
FacesContext.getCurrentInstance(), "Schema2XFormsProperties");
|
||||
}
|
||||
return schema2XFormsProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param avmBrowseBean the avmBrowseBean to set.
|
||||
@@ -199,14 +205,6 @@ public class XFormsBean
|
||||
{
|
||||
this.navigator = navigator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param avmService the avmService to set.
|
||||
*/
|
||||
public void setAvmService(final AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
/** @param xformsSession the current session */
|
||||
public void setXFormsSession(final XFormsSession xformsSession)
|
||||
@@ -224,7 +222,6 @@ public class XFormsBean
|
||||
|
||||
final ChibaBean chibaBean = new ChibaBean();
|
||||
chibaBean.setConfig(servletContext.getRealPath("/WEB-INF/chiba.xml"));
|
||||
// XFormsBean.storeCookies(request.getCookies(), chibaBean);
|
||||
chibaBean.setXMLContainer(this.getXFormsDocument());
|
||||
|
||||
final EventTarget et = (EventTarget)
|
||||
@@ -234,7 +231,8 @@ public class XFormsBean
|
||||
public void handleEvent(final Event e)
|
||||
{
|
||||
final XMLEvent xmle = (XMLEvent)e;
|
||||
XFormsBean.LOGGER.debug("received event " + xmle.getType() + ": " + xmle);
|
||||
if (XFormsBean.LOGGER.isDebugEnabled())
|
||||
XFormsBean.LOGGER.debug("received event " + xmle.getType() + ": " + xmle);
|
||||
XFormsBean.this.xformsSession.eventLog.add(xmle);
|
||||
}
|
||||
};
|
||||
@@ -310,7 +308,8 @@ public class XFormsBean
|
||||
throws IOException,
|
||||
XFormsException
|
||||
{
|
||||
LOGGER.debug(this + ".getXForm()");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".getXForm()");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
@@ -329,7 +328,8 @@ public class XFormsBean
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final String value = (String)requestParameters.get("value");
|
||||
|
||||
LOGGER.debug(this + ".setXFormsValue(" + id + ", " + value + ")");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".setXFormsValue(" + id + ", " + value + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
if (chibaBean.getContainer().lookup(id) instanceof Upload)
|
||||
{
|
||||
@@ -354,11 +354,13 @@ public class XFormsBean
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String repeatIds = (String)requestParameters.get("repeatIds");
|
||||
LOGGER.debug(this + ".setRepeatIndeces(" + repeatIds + ")");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".setRepeatIndeces(" + repeatIds + ")");
|
||||
for (String id : repeatIds.split(","))
|
||||
{
|
||||
final int index = Integer.parseInt((String)requestParameters.get(id));
|
||||
LOGGER.debug(this + ".setRepeatIndex(" + id + ", " + index + ")");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".setRepeatIndex(" + id + ", " + index + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
chibaBean.updateRepeatIndex(id, index);
|
||||
}
|
||||
@@ -377,7 +379,8 @@ public class XFormsBean
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
|
||||
LOGGER.debug(this + ".fireAction(" + id + ")");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".fireAction(" + id + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
chibaBean.dispatch(id, DOMEventNames.ACTIVATE);
|
||||
|
||||
@@ -391,7 +394,8 @@ public class XFormsBean
|
||||
*/
|
||||
public void handleAction()
|
||||
{
|
||||
LOGGER.debug(this + ".handleAction");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".handleAction");
|
||||
try
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
@@ -439,7 +443,8 @@ public class XFormsBean
|
||||
|
||||
final String fromItemId = (String)requestParameters.get("fromItemId");
|
||||
final String toItemId = (String)requestParameters.get("toItemId");
|
||||
LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
final RepeatItem from = (RepeatItem)chibaBean.getContainer().lookup(fromItemId);
|
||||
if (from == null)
|
||||
@@ -462,9 +467,11 @@ public class XFormsBean
|
||||
final RepeatItem to)
|
||||
throws XFormsException
|
||||
{
|
||||
LOGGER.debug("swapping repeat item " + from + " with " + to);
|
||||
|
||||
LOGGER.debug("from instance id " + from.getInstanceId());
|
||||
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());
|
||||
@@ -491,7 +498,8 @@ public class XFormsBean
|
||||
: to.getRepeat().getLocationPath().replaceAll("\\[position\\(\\)[\\s]*!=[\\s]*last\\(\\)]$",
|
||||
"[position()=last()]"));
|
||||
}
|
||||
LOGGER.debug("inserting node before " + beforeLocation);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("inserting node before " + beforeLocation);
|
||||
instance.insertNode(fromLocationPath, beforeLocation);
|
||||
|
||||
model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REBUILD, null);
|
||||
@@ -499,7 +507,8 @@ public class XFormsBean
|
||||
model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REVALIDATE, null);
|
||||
model.getContainer().dispatch(model.getTarget(), XFormsEventNames.REFRESH, null);
|
||||
|
||||
LOGGER.debug("deleting from " + from.getLocationPath());
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("deleting from " + from.getLocationPath());
|
||||
// need to reload from location path since it has moved
|
||||
instance.deleteNode(from.getLocationPath());
|
||||
|
||||
@@ -528,7 +537,8 @@ public class XFormsBean
|
||||
final NodeList nl =
|
||||
XMLUtil.combine(schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include"),
|
||||
schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "import"));
|
||||
LOGGER.debug("rewriting " + nl.getLength() + " includes");
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("rewriting " + nl.getLength() + " includes");
|
||||
for (int i = 0; i < nl.getLength(); i++)
|
||||
{
|
||||
final Element includeEl = (Element)nl.item(i);
|
||||
@@ -537,7 +547,8 @@ public class XFormsBean
|
||||
String uri = includeEl.getAttribute("schemaLocation");
|
||||
if (uri != null && uri.startsWith("http://"))
|
||||
{
|
||||
LOGGER.debug("not rewriting " + uri);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("not rewriting " + uri);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -545,7 +556,8 @@ public class XFormsBean
|
||||
? AVMUtil.buildStoreUrl(cwdAvmPath)
|
||||
: AVMUtil.buildAssetUrl(cwdAvmPath));
|
||||
|
||||
LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri));
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri));
|
||||
includeEl.setAttribute("schemaLocation", baseURI + uri);
|
||||
}
|
||||
}
|
||||
@@ -677,7 +689,7 @@ public class XFormsBean
|
||||
final Locale locale =
|
||||
Application.getLanguage(FacesContext.getCurrentInstance());
|
||||
final ResourceBundle resourceBundle =
|
||||
this.schema2XFormsProperties.getResourceBundle(this.xformsSession.form,
|
||||
getSchema2XFormsProperties().getResourceBundle(this.xformsSession.form,
|
||||
locale);
|
||||
try
|
||||
{
|
||||
|
@@ -17,35 +17,39 @@
|
||||
*/
|
||||
package org.alfresco.web.forms.xforms;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.Writer;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.config.ConfigElement;
|
||||
import org.alfresco.config.ConfigService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormProcessor;
|
||||
import org.alfresco.web.forms.XMLUtil;
|
||||
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.web.util.JavaScriptUtils;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
|
||||
public class XFormsProcessor
|
||||
implements FormProcessor
|
||||
public class XFormsProcessor implements FormProcessor
|
||||
{
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(XFormsProcessor.class);
|
||||
@@ -116,7 +120,7 @@ public class XFormsProcessor
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
//make the XFormsBean available for this session
|
||||
final XFormsBean xforms = (XFormsBean)
|
||||
FacesHelper.getManagedBean(fc, "XFormsBean");
|
||||
FacesHelper.getManagedBean(fc, XFormsBean.BEAN_NAME);
|
||||
final Session result =
|
||||
xforms.createSession(instanceDataDocument, formInstanceDataName, form);
|
||||
this.process(result, out);
|
||||
@@ -133,9 +137,9 @@ public class XFormsProcessor
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
//make the XFormsBean available for this session
|
||||
final XFormsBean xforms = (XFormsBean)
|
||||
FacesHelper.getManagedBean(fc, "XFormsBean");
|
||||
FacesHelper.getManagedBean(fc, XFormsBean.BEAN_NAME);
|
||||
final AVMBrowseBean avmBrowseBean = (AVMBrowseBean)
|
||||
FacesHelper.getManagedBean(fc, "AVMBrowseBean");
|
||||
FacesHelper.getManagedBean(fc, AVMBrowseBean.BEAN_NAME);
|
||||
try
|
||||
{
|
||||
xforms.setXFormsSession((XFormsBean.XFormsSession)session);
|
||||
|
Reference in New Issue
Block a user