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