WCM - fix ETHREEOH-569, ETHREEOH-571, ETHREEOH-3123 (after deleting web form)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17116 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-10-23 11:04:11 +00:00
parent ee18156073
commit 9aadc8f493
6 changed files with 211 additions and 89 deletions

View File

@@ -1261,7 +1261,9 @@ public class AVMBrowseBean implements IContextListener
results = getSearchService().query(sp);
if (logger.isDebugEnabled())
{
logger.debug("Search results returned: " + results.length());
}
// filter hidden folders above the web app
boolean isStagingStore = getIsStagingStore();
@@ -1539,8 +1541,10 @@ public class AVMBrowseBean implements IContextListener
/*package*/ void setupContentAction(String path, boolean refresh)
{
if (logger.isDebugEnabled())
{
logger.debug("Setup content action for path: " + path);
}
if (path == null || path.length() == 0)
{
setAvmActionNode(null);
@@ -1608,28 +1612,39 @@ public class AVMBrowseBean implements IContextListener
if (getAvmService().hasAspect(-1, avmPath, WCMAppModel.ASPECT_RENDITION))
{
if (logger.isDebugEnabled())
{
logger.debug(avmPath + " is a rendition, editing primary rendition instead");
}
try
{
final FormInstanceData fid = this.getFormsService().getRendition(-1, avmPath).getPrimaryFormInstanceData();
avmPath = fid.getPath();
if (logger.isDebugEnabled())
{
logger.debug("Editing primary form instance data " + avmPath);
}
this.setAvmActionNode(new AVMNode(getAvmService().lookup(-1, avmPath)));
}
catch (IllegalArgumentException iae)
{
//Utils.addErrorMessage(iae.getMessage(), iae);
logger.warn(iae);
}
catch (FileNotFoundException fnfe)
{
getAvmService().removeAspect(avmPath, WCMAppModel.ASPECT_RENDITION);
getAvmService().removeAspect(avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
Utils.addErrorMessage(fnfe.getMessage(), fnfe);
//Utils.addErrorMessage(fnfe.getMessage(), fnfe);
logger.warn(fnfe);
}
}
if (logger.isDebugEnabled())
{
logger.debug("Editing AVM node: " + avmPath);
}
String outcome = null;
// calculate which editor screen to display
if (getAvmService().hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
@@ -1645,12 +1660,14 @@ public class AVMBrowseBean implements IContextListener
}
catch (FormNotFoundException fnfe)
{
logger.debug(fnfe.getMessage(), fnfe);
//Utils.addErrorMessage(fnfe.getMessage(), fnfe);
logger.warn(fnfe);
final Map<String, String> params = new HashMap<String, String>(2, 1.0f);
params.put("finishOutcome", "wizard:editWebContent");
params.put("cancelOutcome", "dialog:editAvmFile");
Application.getDialogManager().setupParameters(params);
outcome = "dialog:promptForWebForm";
}
}
@@ -1663,8 +1680,11 @@ public class AVMBrowseBean implements IContextListener
this.getAvmService().forceCopy(avmPath);
}
logger.debug("outcome " + outcome + " for path " + path);
if (logger.isDebugEnabled())
{
logger.debug("outcome " + outcome + " for path " + path);
}
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, outcome);
}

View File

@@ -181,6 +181,15 @@ public class PromptForWebFormDialog extends BaseDialogBean
}
}
@Override
public String cancel()
{
getAvmService().removeAspect(this.getAvmNode().getPath(), WCMAppModel.ASPECT_RENDITION);
getAvmService().removeAspect(this.getAvmNode().getPath(), WCMAppModel.ASPECT_FORM_INSTANCE_DATA);
return super.cancel();
}
@Override
protected String finishImpl(final FacesContext context, String outcome)
throws Exception

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -62,6 +62,7 @@ import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.RenderingEngineTemplate;
import org.alfresco.web.forms.RenderingEngineTemplateImpl;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.forms.RenderingEngine.TemplateNotFoundException;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.common.component.UIListItems;
@@ -82,7 +83,7 @@ public class RegenerateRenditionsWizard
public final String REGENERATE_SCOPE_FORM = "form";
public final String REGENERATE_SCOPE_RENDERING_ENGINE_TEMPLATE = "rendering_engine_template";
private final static Log LOGGER = LogFactory.getLog(RegenerateRenditionsWizard.class);
private final static Log logger = LogFactory.getLog(RegenerateRenditionsWizard.class);
transient protected WebProjectService wpService;
transient private AVMLockingService avmLockingService;
@@ -114,8 +115,12 @@ public class RegenerateRenditionsWizard
-1, AVMUtil.getCorrespondingPathInMainStore(r.getPath()),
AVMDifference.NEWER));
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("updating " + diffList.size() + " renditions in staging");
if (logger.isDebugEnabled())
{
logger.debug("updating " + diffList.size() + " renditions in staging");
}
getAvmSyncService().update(diffList, null, true, true, true, true, null, null);
String description = null;
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
@@ -488,8 +493,11 @@ public class RegenerateRenditionsWizard
query.append(" +@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_FORM_NAME) +
":\"" + f.getName() + "\"");
if (LOGGER.isDebugEnabled())
LOGGER.debug("running query " + query);
if (logger.isDebugEnabled())
{
logger.debug("running query " + query);
}
sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp);
try
@@ -520,8 +528,12 @@ public class RegenerateRenditionsWizard
query.append("+ASPECT:\"" + WCMAppModel.ASPECT_RENDITION + "\"");
query.append(" +@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE) +
":\"" + ((RenderingEngineTemplateImpl)ret).getNodeRef() + "\"");
if (LOGGER.isDebugEnabled())
LOGGER.debug("running query " + query);
if (logger.isDebugEnabled())
{
logger.debug("running query " + query);
}
sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp);
try
@@ -585,14 +597,17 @@ public class RegenerateRenditionsWizard
query.append(" +(");
for (int i = 0; i < this.selectedRenderingEngineTemplates.length; i++)
{
String[] parts = this.selectedRenderingEngineTemplates[i].split(":");
String formName = parts[0];
String templateName = parts[1];
try
{
final String formName = this.selectedRenderingEngineTemplates[i].split(":")[0];
final Form f = this.selectedWebProject.getForm(formName);
final RenderingEngineTemplate ret =
f.getRenderingEngineTemplate((String)this.selectedRenderingEngineTemplates[i].split(":")[1]);
Form f = this.selectedWebProject.getForm(formName);
RenderingEngineTemplate ret =
f.getRenderingEngineTemplate(templateName);
query.append("@" + Repository.escapeQName(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE) +
":\"" + ((RenderingEngineTemplateImpl)ret).getNodeRef() + "\"");
if (i != this.selectedRenderingEngineTemplates.length - 1)
{
query.append(" OR ");
@@ -600,22 +615,26 @@ public class RegenerateRenditionsWizard
}
catch (FormNotFoundException fnfe)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug(fnfe);
logger.warn("regenerating renditions of template " + templateName + ": " + fnfe.getMessage(), fnfe);
}
}
query.append(") ");
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("running query " + query);
if (logger.isDebugEnabled())
{
logger.debug("running query " + query);
}
sp.setQuery(query.toString());
final ResultSet rs = getSearchService().query(sp);
try
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("received " + rs.length() + " results");
if (logger.isDebugEnabled())
{
logger.debug("received " + rs.length() + " results");
}
final List<Rendition> result = new ArrayList<Rendition>(rs.length());
for (final ResultSetRow row : rs)
{
@@ -650,9 +669,7 @@ public class RegenerateRenditionsWizard
}
catch (FormNotFoundException fnfe)
{
Utils.addErrorMessage("error regenerating renditions of " + fid.getPath() +
": " + fnfe.getMessage(),
fnfe);
logger.warn("regenerating renditions of " + fid.getPath() + ": " + fnfe.getMessage(), fnfe);
}
}
else
@@ -663,6 +680,14 @@ public class RegenerateRenditionsWizard
r.regenerate();
result.add(r);
}
catch (TemplateNotFoundException tnfe)
{
logger.warn("regenerating renditions of " + previewAvmPath + ": " + tnfe.getMessage(), tnfe);
}
catch (IllegalArgumentException iae)
{
logger.warn("regenerating renditions of " + previewAvmPath + ": " + iae.getMessage(), iae);
}
catch (Exception e)
{
Utils.addErrorMessage("error regenerating rendition using " +

View File

@@ -66,7 +66,9 @@ import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormNotFoundException;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.ui.common.Utils;
@@ -751,6 +753,7 @@ public class SubmitDialog extends BaseDialogBean
this.submitItems.add(new ItemWrapper(node));
submittedPaths.add(node.getPath());
}
// lookup if this item was created via a form - then lookup the workflow defaults
// for that form and store into the list of available workflows
else if (!getNodeService().hasAspect(ref, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
@@ -773,14 +776,27 @@ public class SubmitDialog extends BaseDialogBean
{
fid = getFormsService().getFormInstanceData(ref);
}
// check form's default workflow (if any)
Form f = null;
try
{
f = fid.getForm();
}
catch (FormNotFoundException fnfe)
{
String formName = (String)getNodeService().getProperty(ref, WCMAppModel.PROP_PARENT_FORM_NAME);
logger.warn("Cannot check default workflow (if any) for missing form '"+formName+"' (may have been deleted) - when submitting '"+node.getPath()+"'");
//Utils.addErrorMessage(fnfe.getMessage(), fnfe);
}
// add the form instance data file to the list for submission
if (!submittedPaths.contains(fid.getPath()))
{
this.submitItems.add(new ItemWrapper(getAvmService().lookup(-1, fid.getPath())));
submittedPaths.add(fid.getPath());
}
// locate renditions for this form instance data file and add to list for submission
for (final Rendition rendition : fid.getRenditions())
{
@@ -791,11 +807,15 @@ public class SubmitDialog extends BaseDialogBean
submittedPaths.add(renditionPath);
}
}
WorkflowDefinition defaultWfDef = fid.getForm().getDefaultWorkflow();
if (defaultWfDef != null)
if (f != null)
{
this.workflows.add(new FormWorkflowWrapper(defaultWfDef.getName(),
fid.getForm().getDefaultWorkflowParameters()));
WorkflowDefinition defaultWfDef = f.getDefaultWorkflow();
if (defaultWfDef != null)
{
this.workflows.add(new FormWorkflowWrapper(defaultWfDef.getName(),
f.getDefaultWorkflowParameters()));
}
}
// See WCM-1090 ACT-1551

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 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
@@ -22,14 +22,14 @@
* http://www.alfresco.com/legal/licensing" */
package org.alfresco.web.forms;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Map;
import org.w3c.dom.Document;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.namespace.QName;
import org.xml.sax.SAXException;
/**
@@ -42,25 +42,40 @@ public interface RenderingEngine
{
/////////////////////////////////////////////////////////////////////////////
public static class RenderingException
extends Exception
public static class RenderingException extends Exception
{
private static final long serialVersionUID = 6831222399250770060L;
public RenderingException(final String msg)
{
super(msg);
}
public RenderingException(final Exception cause)
{
super(cause);
}
public RenderingException(final String msg, final Exception cause)
{
super(msg, cause);
}
}
public static class TemplateNotFoundException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 3232973289475043471L;
public TemplateNotFoundException(final String msg)
{
super(msg);
}
public TemplateNotFoundException(final String msg, final Exception cause)
{
super(msg, cause);
}
}
/////////////////////////////////////////////////////////////////////////////

View File

@@ -54,6 +54,7 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.remote.AVMRemote;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateException;
@@ -68,6 +69,7 @@ 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.alfresco.web.forms.RenderingEngine.TemplateNotFoundException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -91,7 +93,7 @@ public class RenderingEngineTemplateImpl
{
private static final long serialVersionUID = -1656812676972437532L;
private static final Log LOGGER = LogFactory.getLog(RenderingEngineTemplateImpl.class);
private static final Log logger = LogFactory.getLog(RenderingEngineTemplateImpl.class);
private static final DynamicNamespacePrefixResolver namespacePrefixResolver =
new DynamicNamespacePrefixResolver();
@@ -192,10 +194,17 @@ public class RenderingEngineTemplateImpl
*/
public RenderingEngine getRenderingEngine()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
final String renderingEngineName = (String)
nodeService.getProperty(this.nodeRef,
WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME);
NodeService nodeService = this.getServiceRegistry().getNodeService();
String renderingEngineName = null;
try
{
renderingEngineName = (String)nodeService.getProperty(this.nodeRef, WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME);
}
catch (InvalidNodeRefException e)
{
logger.warn("RenderingEngineTemplate not found: "+e);
throw new TemplateNotFoundException("RenderingEngineTemplate not found", e);
}
return this.getFormsService().getRenderingEngine(renderingEngineName);
}
@@ -236,7 +245,7 @@ public class RenderingEngineTemplateImpl
}
catch (Exception e)
{
LOGGER.error(e);
logger.error(e);
throw new AlfrescoRuntimeException(e.getMessage(), e);
}
final String parentAVMPath = AVMNodeConverter.SplitBase(formInstanceDataAVMPath)[0];
@@ -257,7 +266,7 @@ public class RenderingEngineTemplateImpl
}
catch (final TemplateException te)
{
LOGGER.error(te.getMessage(), te);
logger.error(te.getMessage(), te);
throw new AlfrescoRuntimeException("Error processing output path pattern " + outputPathPattern +
" for " + formInstanceDataName +
" in webapp " + webappName +
@@ -268,8 +277,11 @@ public class RenderingEngineTemplateImpl
result = AVMUtil.buildPath(parentAVMPath,
result,
AVMUtil.PathRelation.SANDBOX_RELATIVE);
if (LOGGER.isDebugEnabled())
LOGGER.debug("processed pattern " + outputPathPattern + " as " + result);
if (logger.isDebugEnabled())
{
logger.debug("processed pattern " + outputPathPattern + " as " + result);
}
return result;
}
@@ -299,9 +311,9 @@ public class RenderingEngineTemplateImpl
avmService.createFile(parentAVMPath,
AVMNodeConverter.SplitBase(renditionAvmPath)[1]);
if (LOGGER.isDebugEnabled())
if (logger.isDebugEnabled())
{
LOGGER.debug("Created file node for file: " + renditionAvmPath);
logger.debug("Created file node for file: " + renditionAvmPath);
}
avmService.addAspect(renditionAvmPath, ContentModel.ASPECT_TITLED);
@@ -346,10 +358,16 @@ public class RenderingEngineTemplateImpl
SAXException,
RenderingEngine.RenderingException
{
RenderingEngine re = this.getRenderingEngine();
if (re == null)
{
return;
}
final OutputStream out = rendition.getOutputStream();
try
{
this.getRenderingEngine().render(this.buildModel(formInstanceData, rendition),
re.render(this.buildModel(formInstanceData, rendition),
this,
out);
}
@@ -418,12 +436,14 @@ public class RenderingEngineTemplateImpl
RenderingEngineTemplateImpl.this.getServiceRegistry().getNodeService();
final NodeRef parentNodeRef =
nodeService.getPrimaryParent(RenderingEngineTemplateImpl.this.getNodeRef()).getParentRef();
if (LOGGER.isDebugEnabled())
if (logger.isDebugEnabled())
{
LOGGER.debug("request to resolve resource " + name +
logger.debug("request to resolve resource " + name +
" webapp url is " + webappUrl +
" and data dictionary workspace is " + parentNodeRef);
}
}
final NodeRef result = nodeService.getChildByName(parentNodeRef, ContentModel.ASSOC_CONTAINS, name);
if (result != null)
{
@@ -431,14 +451,16 @@ public class RenderingEngineTemplateImpl
RenderingEngineTemplateImpl.this.getServiceRegistry().getContentService();
try
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("found " + name + " in data dictonary: " + result);
if (logger.isDebugEnabled())
{
logger.debug("found " + name + " in data dictonary: " + result);
}
return contentService.getReader(result, ContentModel.PROP_CONTENT).getContentInputStream();
}
catch (Exception e)
{
LOGGER.debug(e);
logger.warn(e);
}
}
@@ -487,19 +509,20 @@ public class RenderingEngineTemplateImpl
request.getContextPath() + "/wcservice/" +
rewrittenName);
if (LOGGER.isDebugEnabled())
LOGGER.debug("loading webscript: " + webscriptURI);
if (logger.isDebugEnabled())
{
logger.debug("loading webscript: " + webscriptURI);
}
final URI uri = new URI(webscriptURI);
return uri.toURL().openStream();
}
catch (Exception e)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug(e);
logger.warn(e);
}
}
try
{
final String[] path = (name.startsWith("/") ? name.substring(1) : name).split("/");
@@ -510,16 +533,16 @@ public class RenderingEngineTemplateImpl
final URI uri = new URI(webappUrl + '/' + StringUtils.join(path, '/'));
if (LOGGER.isDebugEnabled())
LOGGER.debug("loading " + uri);
if (logger.isDebugEnabled())
{
logger.debug("loading " + uri);
}
return uri.toURL().openStream();
}
catch (Exception e)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug(e);
logger.warn(e);
return null;
}
}
@@ -567,8 +590,10 @@ public class RenderingEngineTemplateImpl
}
String text = (String)arguments[0];
if (LOGGER.isDebugEnabled())
LOGGER.debug("tpm_encodeQuotes('" + text + "'), parentPath = " + parentPath);
if (logger.isDebugEnabled())
{
logger.debug("tpm_encodeQuotes('" + text + "'), parentPath = " + parentPath);
}
final String result = fdf.encodeQuotes(text);
return result;
@@ -601,8 +626,10 @@ public class RenderingEngineTemplateImpl
path,
AVMUtil.PathRelation.WEBAPP_RELATIVE);
if (LOGGER.isDebugEnabled())
LOGGER.debug("tpm_parseXMLDocument('" + path + "'), parentPath = " + parentPath);
if (logger.isDebugEnabled())
{
logger.debug("tpm_parseXMLDocument('" + path + "'), parentPath = " + parentPath);
}
final Document d = fdf.parseXMLDocument(path);
return d != null ? d.getDocumentElement() : null;
@@ -640,17 +667,21 @@ public class RenderingEngineTemplateImpl
AVMUtil.PathRelation.WEBAPP_RELATIVE);
final String formName = (String)arguments[0];
if (LOGGER.isDebugEnabled())
LOGGER.debug("tpm_parseXMLDocuments('" + formName + "','" + path +
if (logger.isDebugEnabled())
{
logger.debug("tpm_parseXMLDocuments('" + formName + "','" + path +
"'), parentPath = " + parentPath);
}
final Map<String, Document> resultMap = fdf.parseXMLDocuments(formName, path);
if (LOGGER.isDebugEnabled())
LOGGER.debug("received " + resultMap.size() +
if (logger.isDebugEnabled())
{
logger.debug("received " + resultMap.size() +
" documents in " + path +
" with form name " + formName);
}
// create a root document for rooting all the results. we do this
// so that each document root element has a common parent node
// and so that xpath axes work properly
@@ -698,8 +729,10 @@ public class RenderingEngineTemplateImpl
final String path = (String)arguments[0];
if (LOGGER.isDebugEnabled())
LOGGER.debug("tpm_getAVMPAth('" + path + "'), parentPath = " + parentPath);
if (logger.isDebugEnabled())
{
logger.debug("tpm_getAVMPAth('" + path + "'), parentPath = " + parentPath);
}
return AVMUtil.buildPath(parentPath,
path,